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);
int PetscJacobianMatNonzeroEntriesImpl(Mat, int, void *)
std::vector< int * > points
#define _ArrayIndex1D_(N, imax, i, ghost, index)
std::vector< double * > globalDOF
#define _ArrayCopy1D_(x, y, size)
Structure containing the variables for time-integration with PETSc.
Structure defining a simulation.
Contains macros and function definitions for common array operations.
Structure of MPI-related variables.
C++ declarations for MPI-related functions.
Structure containing all solver-specific variables and functions.