16 #define __FUNCT__ "PetscJacobianMatNonzeroEntriesImpl" 46 int nsims = context->
nsims;
50 for (
int ns = 0; ns < nsims; ns++) {
52 HyPar* solver( &(sim[ns].solver) );
55 int ndims = solver->
ndims,
56 nvars = solver->
nvars,
60 *points = context->
points[ns],
61 index[ndims],indexL[ndims],indexR[ndims],
62 rows[nvars],cols[nvars];
64 std::vector<double> values(nvars*nvars, 1.0);
67 for (
int n = 0; n < npoints; n++) {
69 int *this_point = points + n*(ndims+1);
70 int p = this_point[ndims];
73 for (
int dir = 0; dir < ndims; dir++) {
77 for (
int v=0; v<nvars; v++) { rows[v] = nvars*pg + v; cols[v] = nvars*pg + v; }
78 MatSetValues(Amat,nvars,rows,nvars,cols,values.data(),ADD_VALUES);
80 for (
int d = 1; d <= width; d++) {
86 int pgL = (int) context->
globalDOF[ns][pL];
88 for (
int v=0; v<nvars; v++) { rows[v] = nvars*pg + v; cols[v] = nvars*pgL + v; }
89 MatSetValues(Amat,nvars,rows,nvars,cols,values.data(),ADD_VALUES);
95 int pgR = (int) context->
globalDOF[ns][pR];
98 for (
int v=0; v<nvars; v++) { rows[v] = nvars*pg + v; cols[v] = nvars*pgR + v; }
99 MatSetValues(Amat,nvars,rows,nvars,cols,values.data(),ADD_VALUES);
108 MatAssemblyBegin(Amat,MAT_FINAL_ASSEMBLY);
109 MatAssemblyEnd (Amat,MAT_FINAL_ASSEMBLY);
111 PetscFunctionReturn(0);
std::vector< int * > points
Structure defining a simulation.
C++ declarations for MPI-related functions.
int PetscJacobianMatNonzeroEntriesImpl(Mat Amat, int width, void *ctxt)
Structure containing all solver-specific variables and functions.
#define _ArrayIndex1D_(N, imax, i, ghost, index)
Structure containing the variables for time-integration with PETSc.
Structure of MPI-related variables.
std::vector< double * > globalDOF
#define _ArrayCopy1D_(x, y, size)
Contains macros and function definitions for common array operations.