24 #include "_hypre_utilities.h"
25 #include "HYPRE_sstruct_ls.h"
26 #include "HYPRE_parcsr_ls.h"
27 #include "HYPRE_krylov.h"
66 HYPRE_SStructVariable
chemVartypes[1] = { HYPRE_SSTRUCT_VARIABLE_NODE };
77 if (coord == 0 && boundary == -1) {
85 if (coord == 0 && boundary == 1) {
93 if (coord == 1 && boundary == -1) {
101 if (coord == 1 && boundary == 1) {
109 if (coord == 2 && boundary == -1) {
117 if (coord == 2 && boundary == 1) {
134 long long offsets[7][3] =
135 { {0, 0, 0}, {-1, 0, 0}, {1, 0, 0}, {0, -1, 0}, {0, 1, 0}, {0, 0,
140 double gridResolutionInUnits;
168 HYPRE_SStructGridAssemble(
chemGrid[nch]);
171 HYPRE_SStructStencilCreate(3, 7, &
chemStencil[nch]);
172 for (entry = 0; entry < 7; entry++)
173 HYPRE_SStructStencilSetEntry(
chemStencil[nch], entry, offsets[entry],
181 HYPRE_SStructGraphAssemble(
chemGraph[nch]);
184 long long nentries = 7;
187 long long stencil_indices[7];
194 HYPRE_SStructMatrixInitialize(
chemA[nch]);
196 values = calloc(nvalues,
sizeof(
double));
198 for (j = 0; j < nentries; j++)
199 stencil_indices[j] = j;
205 NGLOB] *
dt[nch] / (gridResolutionInUnits *
206 gridResolutionInUnits);
210 for (i = 0; i < nvalues; i += nentries) {
212 for (j = 1; j < nentries; j++)
213 values[i + j] = -
chemZ[nch];
217 nentries, stencil_indices, values);
252 for (i = 0; i <
gridSize.
x; i++, idx++) {
265 long long stencil_indices[1];
267 double *values, *bvalues;
271 chemPC = (
double *) calloc(nvalues,
sizeof(
double));
272 values = calloc(nvalues,
sizeof(
double));
273 bvalues = calloc(nvalues,
sizeof(
double));
288 HYPRE_SStructVectorInitialize(
chemb[nch]);
289 HYPRE_SStructVectorInitialize(
chemx[nch]);
316 for (i = 0; i < nvalues; i++)
317 values[i] =
chemZ[nch];
318 for (i = 0; i < nvalues; i++)
324 stencil_indices[0] = 1;
326 nentries, stencil_indices, values);
333 stencil_indices[0] = 2;
335 nentries, stencil_indices, values);
342 stencil_indices[0] = 3;
344 nentries, stencil_indices, values);
351 stencil_indices[0] = 4;
353 nentries, stencil_indices, values);
360 stencil_indices[0] = 5;
362 nentries, stencil_indices, values);
369 stencil_indices[0] = 6;
371 nentries, stencil_indices, values);
395 HYPRE_SStructMatrixAssemble(
chemA[nch]);
398 HYPRE_SStructVectorAssemble(
chemb[nch]);
399 HYPRE_SStructVectorAssemble(
chemx[nch]);
401 HYPRE_SStructMatrixGetObject(
chemA[nch], (
void **) &
chemParA[nch]);
402 HYPRE_SStructVectorGetObject(
chemb[nch], (
void **) &
chemParb[nch]);
403 HYPRE_SStructVectorGetObject(
chemx[nch], (
void **) &
chemParx[nch]);
406 HYPRE_ParCSRPCGSetTol(
chemSolver[nch], 1.0e-12);
407 HYPRE_ParCSRPCGSetPrintLevel(
chemSolver[nch], 2);
408 HYPRE_ParCSRPCGSetMaxIter(
chemSolver[nch], 50);
414 HYPRE_BoomerAMGSetCoarsenType(
chemPrecond[nch], 6);
418 HYPRE_ParCSRPCGSetPrecond(
chemSolver[nch], HYPRE_BoomerAMGSolve,
447 values = (
double *) calloc(nvalues,
sizeof(
double));
448 chemPC = (
double *) calloc(nvalues,
sizeof(
double));
461 for (i = 0; i < nvalues; i++)
495 HYPRE_SStructVectorAssemble(
chemb[nch]);
496 HYPRE_SStructVectorAssemble(
chemx[nch]);
503 HYPRE_SStructVectorGather(
chemx[nch]);
509 for (i = 0; i <
gridSize.
x; i++, idx++) {
void chemEnvCellPC(int nch)
HYPRE_ParCSRMatrix chemParA[NCHEM]
void chemEnvInitSystem(int nch)
struct int64Vector3d * gridEndIdx
double * chemField[NCHEM]
double fieldDiffCoef[NFIELDS]
HYPRE_ParVector chemParb[NCHEM]
char fieldName[NFIELDS][128]
contains the most important global variables, arrays and defines
void switchStdOut(const char *newStream)
void chemEnvSolve(int nch)
HYPRE_SStructVariable chemVartypes[1]
struct int64Vector3d gridSize
HYPRE_SStructGraph chemGraph[NCHEM]
HYPRE_ParVector chemParx[NCHEM]
struct int64Vector3d * gridStartIdx
double fieldICMean[NFIELDS]
void chemEnvInitSolver(int nch)
double fieldConsumption[NFIELDS]
HYPRE_SStructStencil chemStencil[NCHEM]
void chemEnvInitBC(int nch)
void chemSetBoundary(int coord, int boundary)
contains variables and arrays for global fields
HYPRE_SStructVector chemb[NCHEM]
double fieldProduction[NFIELDS]
HYPRE_SStructGrid chemGrid[NCHEM]
HYPRE_Solver chemPrecond[NCHEM]
double fieldLambda[NFIELDS]
HYPRE_SStructMatrix chemA[NCHEM]
HYPRE_SStructVector chemx[NCHEM]
HYPRE_Solver chemSolver[NCHEM]