PFModule *WRFSelectTimeStepNewPublicXtra( double initial_step, double growth_factor, double max_step, double min_step) { PFModule *this_module = ThisPFModule; PublicXtra *public_xtra; Type1 *dummy1; public_xtra = ctalloc(PublicXtra, 1); public_xtra -> type = 1; dummy1 = ctalloc(Type1, 1); dummy1 -> initial_step = initial_step; dummy1 -> factor = growth_factor; dummy1 -> max_step = max_step; dummy1 -> min_step = min_step; (public_xtra -> data) = (void *) dummy1; PFModulePublicXtra(this_module) = public_xtra; return this_module; }
PFModule *SelectTimeStepNewPublicXtra() { PFModule *this_module = ThisPFModule; PublicXtra *public_xtra; Type0 *dummy0; Type1 *dummy1; char *switch_name; NameArray type_na; type_na = NA_NewNameArray("Constant Growth"); public_xtra = ctalloc(PublicXtra, 1); switch_name = GetString("TimeStep.Type"); public_xtra -> type = NA_NameToIndex(type_na, switch_name); switch((public_xtra -> type)) { case 0: { dummy0 = ctalloc(Type0, 1); dummy0 -> step = GetDouble("TimeStep.Value"); (public_xtra -> data) = (void *) dummy0; break; } case 1: { dummy1 = ctalloc(Type1, 1); dummy1 -> initial_step = GetDouble("TimeStep.InitialStep"); dummy1 -> factor = GetDouble("TimeStep.GrowthFactor"); dummy1 -> max_step = GetDouble("TimeStep.MaxStep"); dummy1 -> min_step = GetDouble("TimeStep.MinStep"); (public_xtra -> data) = (void *) dummy1; break; } default: { InputError("Error: invalid type <%s> for key <%s>\n", switch_name, "TimeStep.Type"); } } NA_FreeNameArray(type_na); PFModulePublicXtra(this_module) = public_xtra; return this_module; }
TimeCycleData *NewTimeCycleData( int number_of_cycles, int *number_of_intervals) { TimeCycleData *time_cycle_data; int cycle_number; time_cycle_data = ctalloc(TimeCycleData, 1); TimeCycleDataNumberOfCycles(time_cycle_data) = number_of_cycles; TimeCycleDataIntervalDivisions(time_cycle_data) = ctalloc(int, number_of_cycles); TimeCycleDataIntervalsPtr(time_cycle_data) = ctalloc(int *, number_of_cycles); for(cycle_number = 0; cycle_number < number_of_cycles; cycle_number++) { TimeCycleDataIntervalDivision(time_cycle_data, cycle_number) = number_of_intervals[cycle_number]; TimeCycleDataIntervals(time_cycle_data, cycle_number) = ctalloc(int, TimeCycleDataIntervalDivision(time_cycle_data, cycle_number)); } TimeCycleDataRepeatCounts(time_cycle_data) = ctalloc(int, number_of_cycles); TimeCycleDataCycleLengths(time_cycle_data) = ctalloc(int, number_of_cycles); return time_cycle_data; }
void ReadGlobalTimeCycleData() { int i; char *cycle_names; char *cycle_name; char key[IDB_MAX_KEY_LEN]; char *id_names; NameArray id_na; int id; char *interval_name; /* Get the time cycling information */ cycle_names = GetString("Cycle.Names"); GlobalsCycleNames = NA_NewNameArray(cycle_names); GlobalsNumCycles = NA_Sizeof(GlobalsCycleNames); GlobalsIntervalDivisions = ctalloc(int, GlobalsNumCycles); GlobalsIntervals = ctalloc(int *, GlobalsNumCycles); GlobalsIntervalNames = ctalloc(NameArray, GlobalsNumCycles); GlobalsRepeatCounts = ctalloc(int, GlobalsNumCycles); for(i = 0; i < GlobalsNumCycles; i++) { cycle_name = NA_IndexToName(GlobalsCycleNames, i); sprintf(key, "Cycle.%s.Names", cycle_name); id_names = GetString(key); id_na = NA_NewNameArray(id_names); GlobalsIntervalNames[i] = id_na; GlobalsIntervalDivisions[i] = NA_Sizeof(id_na); GlobalsIntervals[i] = ctalloc(int, GlobalsIntervalDivisions[i]); sprintf(key, "Cycle.%s.Repeat", cycle_name); GlobalsRepeatCounts[i] = GetInt(key); for(id = 0; id < GlobalsIntervalDivisions[i]; id++) { interval_name = NA_IndexToName(id_na, id); sprintf(key, "Cycle.%s.%s.Length", cycle_name, interval_name); GlobalsIntervals[i][id] = GetInt(key); } } }
CommPkg *NewCommPkg( Region * send_region, Region * recv_region, SubregionArray *data_space, int num_vars, /* number of variables in the vector */ double * data) { CommPkg *new_comm_pkg; amps_Invoice invoice; SubregionArray *comm_sra; Subregion *comm_sr; Subregion *data_sr; int *loop_array; int *send_proc_array = NULL; int *recv_proc_array = NULL; int num_send_subregions; int num_recv_subregions; int num_send_procs; int num_recv_procs; int proc; int i, j, p; int dim; new_comm_pkg = ctalloc(CommPkg, 1); /*------------------------------------------------------ * compute num send and recv subregions *------------------------------------------------------*/ num_send_subregions = 0; num_recv_subregions = 0; ForSubregionI(i, data_space) { num_send_subregions += SubregionArraySize(RegionSubregionArray(send_region, i)); num_recv_subregions += SubregionArraySize(RegionSubregionArray(recv_region, i)); }
BCPressureData *NewBCPressureData() { BCPressureData *bc_pressure_data; bc_pressure_data = ctalloc(BCPressureData, 1); BCPressureDataNumPhases(bc_pressure_data) = 0; BCPressureDataNumPatches(bc_pressure_data) = -1; BCPressureDataTypes(bc_pressure_data) = NULL; BCPressureDataCycleNumbers(bc_pressure_data) = NULL; BCPressureDataPatchIndexes(bc_pressure_data) = NULL; BCPressureDataBCTypes(bc_pressure_data) = NULL; BCPressureDataValues(bc_pressure_data) = NULL; return bc_pressure_data; }
PFModule *KinsolNonlinSolverNewPublicXtra() { PFModule *this_module = ThisPFModule; PublicXtra *public_xtra; char *switch_name; char key[IDB_MAX_KEY_LEN]; int switch_value; NameArray switch_na; NameArray verbosity_switch_na; NameArray eta_switch_na; NameArray globalization_switch_na; NameArray precond_switch_na; public_xtra = ctalloc(PublicXtra, 1); sprintf(key, "Solver.Nonlinear.ResidualTol"); (public_xtra->residual_tol) = GetDoubleDefault(key, 1e-7); sprintf(key, "Solver.Nonlinear.StepTol"); (public_xtra->step_tol) = GetDoubleDefault(key, 1e-7); sprintf(key, "Solver.Nonlinear.MaxIter"); (public_xtra->max_iter) = GetIntDefault(key, 15); sprintf(key, "Solver.Linear.KrylovDimension"); (public_xtra->krylov_dimension) = GetIntDefault(key, 10); sprintf(key, "Solver.Linear.MaxRestarts"); (public_xtra->max_restarts) = GetIntDefault(key, 0); verbosity_switch_na = NA_NewNameArray("NoVerbosity LowVerbosity " "NormalVerbosity HighVerbosity"); sprintf(key, "Solver.Nonlinear.PrintFlag"); switch_name = GetStringDefault(key, "LowVerbosity"); (public_xtra->print_flag) = NA_NameToIndex(verbosity_switch_na, switch_name); NA_FreeNameArray(verbosity_switch_na); eta_switch_na = NA_NewNameArray("EtaConstant Walker1 Walker2"); sprintf(key, "Solver.Nonlinear.EtaChoice"); switch_name = GetStringDefault(key, "Walker2"); switch_value = NA_NameToIndex(eta_switch_na, switch_name); switch (switch_value) { case 0: { public_xtra->eta_choice = ETACONSTANT; public_xtra->eta_value = GetDoubleDefault("Solver.Nonlinear.EtaValue", 1e-4); public_xtra->eta_alpha = 0.0; public_xtra->eta_gamma = 0.0; break; } case 1: { public_xtra->eta_choice = ETACHOICE1; public_xtra->eta_alpha = 0.0; public_xtra->eta_gamma = 0.0; break; } case 2: { public_xtra->eta_choice = ETACHOICE2; public_xtra->eta_alpha = GetDoubleDefault("Solver.Nonlinear.EtaAlpha", 2.0); public_xtra->eta_gamma = GetDoubleDefault("Solver.Nonlinear.EtaGamma", 0.9); public_xtra->eta_value = 0.0; break; } default: { InputError("Error: Invalid value <%s> for key <%s>\n", switch_name, key); } } NA_FreeNameArray(eta_switch_na); switch_na = NA_NewNameArray("False True"); sprintf(key, "Solver.Nonlinear.UseJacobian"); switch_name = GetStringDefault(key, "False"); switch_value = NA_NameToIndex(switch_na, switch_name); switch (switch_value) { case 0: { (public_xtra->matvec) = NULL; break; } case 1: { (public_xtra->matvec) = KINSolMatVec; break; } default: { InputError("Error: Invalid value <%s> for key <%s>\n", switch_name, key); } } NA_FreeNameArray(switch_na); sprintf(key, "Solver.Nonlinear.DerivativeEpsilon"); (public_xtra->derivative_epsilon) = GetDoubleDefault(key, 1e-7); globalization_switch_na = NA_NewNameArray("InexactNewton LineSearch"); sprintf(key, "Solver.Nonlinear.Globalization"); switch_name = GetStringDefault(key, "LineSearch"); switch_value = NA_NameToIndex(globalization_switch_na, switch_name); switch (switch_value) { case 0: { (public_xtra->globalization) = INEXACT_NEWTON; break; } case 1: { (public_xtra->globalization) = LINESEARCH; break; } default: { InputError("Error: Invalid value <%s> for key <%s>\n", switch_name, key); } } NA_FreeNameArray(globalization_switch_na); precond_switch_na = NA_NewNameArray("NoPC MGSemi SMG PFMG PFMGOctree"); sprintf(key, "Solver.Linear.Preconditioner"); switch_name = GetStringDefault(key, "MGSemi"); switch_value = NA_NameToIndex(precond_switch_na, switch_name); if (switch_value == 0) { (public_xtra->precond) = NULL; (public_xtra->pcinit) = NULL; (public_xtra->pcsolve) = NULL; } else if (switch_value > 0) { (public_xtra->precond) = PFModuleNewModuleType( KinsolPCNewPublicXtraInvoke, KinsolPC, (key, switch_name)); (public_xtra->pcinit) = (KINSpgmrPrecondFn)KINSolInitPC; (public_xtra->pcsolve) = (KINSpgmrPrecondSolveFn)KINSolCallPC; } else { InputError("Error: Invalid value <%s> for key <%s>\n", switch_name, key); } NA_FreeNameArray(precond_switch_na); public_xtra->nl_function_eval = PFModuleNewModule(NlFunctionEval, ()); public_xtra->neq = ((public_xtra->max_restarts) + 1) * (public_xtra->krylov_dimension); if (public_xtra->matvec != NULL) public_xtra->richards_jacobian_eval = PFModuleNewModuleType( RichardsJacobianEvalNewPublicXtraInvoke, RichardsJacobianEval, ("Solver.Nonlinear.Jacobian")); else public_xtra->richards_jacobian_eval = NULL; (public_xtra->time_index) = RegisterTiming("KINSol"); PFModulePublicXtra(this_module) = public_xtra; return this_module; }
PFModule *KinsolNonlinSolverInitInstanceXtra( Problem * problem, Grid * grid, ProblemData *problem_data, double * temp_data) { PFModule *this_module = ThisPFModule; PublicXtra *public_xtra = (PublicXtra*)PFModulePublicXtra(this_module); InstanceXtra *instance_xtra; int neq = public_xtra->neq; int max_restarts = public_xtra->max_restarts; int krylov_dimension = public_xtra->krylov_dimension; int max_iter = public_xtra->max_iter; int print_flag = public_xtra->print_flag; int eta_choice = public_xtra->eta_choice; long int *iopt; double *ropt; double eta_value = public_xtra->eta_value; double eta_alpha = public_xtra->eta_alpha; double eta_gamma = public_xtra->eta_gamma; double derivative_epsilon = public_xtra->derivative_epsilon; Vector *fscale; Vector *uscale; State *current_state; KINSpgmruserAtimesFn matvec = public_xtra->matvec; KINSpgmrPrecondFn pcinit = public_xtra->pcinit; KINSpgmrPrecondSolveFn pcsolve = public_xtra->pcsolve; KINMem kin_mem; FILE *kinsol_file; char filename[255]; int i; if (PFModuleInstanceXtra(this_module) == NULL) instance_xtra = ctalloc(InstanceXtra, 1); else instance_xtra = (InstanceXtra*)PFModuleInstanceXtra(this_module); /*----------------------------------------------------------------------- * Initialize module instances *-----------------------------------------------------------------------*/ if (PFModuleInstanceXtra(this_module) == NULL) { if (public_xtra->precond != NULL) instance_xtra->precond = PFModuleNewInstanceType(KinsolPCInitInstanceXtraInvoke, public_xtra->precond, (problem, grid, problem_data, temp_data, NULL, NULL, NULL, 0, 0)); else instance_xtra->precond = NULL; instance_xtra->nl_function_eval = PFModuleNewInstanceType(NlFunctionEvalInitInstanceXtraInvoke, public_xtra->nl_function_eval, (problem, grid, temp_data)); if (public_xtra->richards_jacobian_eval != NULL) /* Initialize instance for nonsymmetric matrix */ instance_xtra->richards_jacobian_eval = PFModuleNewInstanceType(RichardsJacobianEvalInitInstanceXtraInvoke, public_xtra->richards_jacobian_eval, (problem, grid, problem_data, temp_data, 0)); else instance_xtra->richards_jacobian_eval = NULL; } else { if (instance_xtra->precond != NULL) PFModuleReNewInstanceType(KinsolPCInitInstanceXtraInvoke, instance_xtra->precond, (problem, grid, problem_data, temp_data, NULL, NULL, NULL, 0, 0)); PFModuleReNewInstanceType(NlFunctionEvalInitInstanceXtraInvoke, instance_xtra->nl_function_eval, (problem, grid, temp_data)); if (instance_xtra->richards_jacobian_eval != NULL) PFModuleReNewInstanceType(RichardsJacobianEvalInitInstanceXtraInvoke, instance_xtra->richards_jacobian_eval, (problem, grid, problem_data, temp_data, 0)); } /*----------------------------------------------------------------------- * Initialize KINSol input parameters and memory instance *-----------------------------------------------------------------------*/ if (PFModuleInstanceXtra(this_module) == NULL) { current_state = ctalloc(State, 1); /* Set up the grid data for the kinsol stuff */ SetPf2KinsolData(grid, 1); /* Initialize KINSol parameters */ sprintf(filename, "%s.%s", GlobalsOutFileName, "kinsol.log"); if (!amps_Rank(amps_CommWorld)) kinsol_file = fopen(filename, "w"); else kinsol_file = NULL; instance_xtra->kinsol_file = kinsol_file; /* Initialize KINSol memory */ kin_mem = (KINMem)KINMalloc(neq, kinsol_file, NULL); /* Initialize the gmres linear solver in KINSol */ KINSpgmr((void*)kin_mem, /* Memory allocated above */ krylov_dimension, /* Max. Krylov dimension */ max_restarts, /* Max. no. of restarts - 0 is none */ 1, /* Max. calls to PC Solve w/o PC Set */ pcinit, /* PC Set function */ pcsolve, /* PC Solve function */ matvec, /* ATimes routine */ current_state /* User data for PC stuff */ ); /* Initialize optional arguments for KINSol */ iopt = instance_xtra->int_optional_input; ropt = instance_xtra->real_optional_input; // Only print on rank 0 iopt[PRINTFL] = amps_Rank(amps_CommWorld) ? 0 : print_flag; iopt[MXITER] = max_iter; iopt[PRECOND_NO_INIT] = 0; iopt[NNI] = 0; iopt[NFE] = 0; iopt[NBCF] = 0; iopt[NBKTRK] = 0; iopt[ETACHOICE] = eta_choice; iopt[NO_MIN_EPS] = 0; ropt[MXNEWTSTEP] = 0.0; ropt[RELFUNC] = derivative_epsilon; ropt[RELU] = 0.0; ropt[FNORM] = 0.0; ropt[STEPL] = 0.0; ropt[ETACONST] = eta_value; ropt[ETAALPHA] = eta_alpha; /* Put in conditional assignment of eta_gamma since KINSOL aliases */ /* ETAGAMMA and ETACONST */ if (eta_value == 0.0) ropt[ETAGAMMA] = eta_gamma; /* Initialize iteration counts */ for (i = 0; i < OPT_SIZE; i++) instance_xtra->integer_outputs[i] = 0; /* Scaling vectors*/ uscale = NewVectorType(grid, 1, 1, vector_cell_centered); InitVectorAll(uscale, 1.0); instance_xtra->uscale = uscale; fscale = NewVectorType(grid, 1, 1, vector_cell_centered); InitVectorAll(fscale, 1.0); instance_xtra->fscale = fscale; instance_xtra->feval = KINSolFunctionEval; instance_xtra->kin_mem = kin_mem; instance_xtra->current_state = current_state; } PFModuleInstanceXtra(this_module) = instance_xtra; return this_module; }
int main( int argc, char **argv) { gms_TIN *mask_TIN; gms_TIN **TINs; int nTINs; Vertex **mask_vertices; int mask_nvertices; Triangle **mask_triangles; int mask_ntriangles; Vertex **vertices; int nvertices; Triangle **triangles; int ntriangles; int max_nvertices; int *mask_new_to_old; int *mask_old_to_tin; int *old_to_new; int v0, v1, v2; int compare_result; int T; int mask_t, mask_v; int t, v, new_v; if (argc < 4) { fprintf(stderr, "Usage: gmstriangulate <TIN mask> <TIN input> <TIN output>\n"); exit(1); } /*----------------------------------------------------------------------- * Read in the gms TIN files *-----------------------------------------------------------------------*/ /* read the <TIN mask> file */ gms_ReadTINs(&TINs, &nTINs, argv[1]); /* use the first TIN as the mask */ mask_TIN = TINs[0]; tfree(TINs); /* read the <TIN input> file */ gms_ReadTINs(&TINs, &nTINs, argv[2]); /*----------------------------------------------------------------------- * Triangulate each of the TINs *-----------------------------------------------------------------------*/ /* Get vertices and triangles from mask_TIN structure */ mask_vertices = (mask_TIN->vertices); mask_nvertices = (mask_TIN->nvertices); mask_triangles = (mask_TIN->triangles); mask_ntriangles = (mask_TIN->ntriangles); /* Sort mask_TIN vertices */ mask_new_to_old = SortXYVertices(mask_vertices, mask_nvertices, 1); /* Allocate space for the mask_old_to_tin array */ mask_old_to_tin = ctalloc(int, mask_nvertices); max_nvertices = 0; for (T = 0; T < nTINs; T++) { /* Get vertices from TIN structure */ vertices = (TINs[T]->vertices); nvertices = (TINs[T]->nvertices); max_nvertices = max(max_nvertices, nvertices); /* Sort TIN vertices */ SortXYVertices(vertices, nvertices, 0); /* Construct mask_old_to_tin array */ for (mask_v = 0; mask_v < mask_nvertices; mask_v++) mask_old_to_tin[mask_v] = -1; mask_v = 0; v = 0; while ((mask_v < mask_nvertices) && (v < nvertices)) { Compare(compare_result, mask_vertices[mask_v], vertices[v]); if (compare_result < 0) mask_v++; else if (compare_result > 0) v++; else { mask_old_to_tin[mask_new_to_old[mask_v]] = v; mask_v++; v++; } } /* Delete old triangulation */ tfree(TINs[T]->triangles); /* Allocate the triangles array */ triangles = ctalloc(Triangle *, mask_ntriangles); /* Add triangles to the TIN structure */ t = 0; for (mask_t = 0; mask_t < mask_ntriangles; mask_t++) { v0 = mask_old_to_tin[(mask_triangles[mask_t]->v0)]; v1 = mask_old_to_tin[(mask_triangles[mask_t]->v1)]; v2 = mask_old_to_tin[(mask_triangles[mask_t]->v2)]; if ((v0 > -1) && (v1 > -1) && (v2 > -1)) { triangles[t] = ctalloc(Triangle, 1); (triangles[t]->v0) = v0; (triangles[t]->v1) = v1; (triangles[t]->v2) = v2; t++; } } ntriangles = t; (TINs[T]->triangles) = triangles; (TINs[T]->ntriangles) = ntriangles; } /* Free up the mask_old_to_tin array */ tfree(mask_old_to_tin); /*----------------------------------------------------------------------- * Delete unused vertices *-----------------------------------------------------------------------*/ /* Allocate space for the old_to_new array */ old_to_new = ctalloc(int, max_nvertices); for (T = 0; T < nTINs; T++) { vertices = (TINs[T]->vertices); nvertices = (TINs[T]->nvertices); triangles = (TINs[T]->triangles); ntriangles = (TINs[T]->ntriangles); for (v = 0; v < nvertices; v++) old_to_new[v] = -1; for (t = 0; t < ntriangles; t++) { old_to_new[(triangles[t]->v0)] = 1; old_to_new[(triangles[t]->v1)] = 1; old_to_new[(triangles[t]->v2)] = 1; } new_v = 0; for (v = 0; v < nvertices; v++) { if (old_to_new[v] > -1) { vertices[new_v] = vertices[v]; old_to_new[v] = new_v; new_v++; } } nvertices = new_v; (TINs[T]->nvertices) = nvertices; for (t = 0; t < ntriangles; t++) { (triangles[t]->v0) = old_to_new[(triangles[t]->v0)]; (triangles[t]->v1) = old_to_new[(triangles[t]->v1)]; (triangles[t]->v2) = old_to_new[(triangles[t]->v2)]; } } /* Free up the old_to_new array */ tfree(old_to_new); /*----------------------------------------------------------------------- * Write out the new TINs *-----------------------------------------------------------------------*/ gms_WriteTINs(TINs, nTINs, argv[3]); return(0); }
GrGeomExtentArray *GrGeomCreateExtentArray( SubgridArray *subgrids, int xl_ghost, int xu_ghost, int yl_ghost, int yu_ghost, int zl_ghost, int zu_ghost) { Background *bg = GlobalsBackground; GrGeomExtentArray *extent_array; GrGeomExtents *extents; int size; Subgrid *subgrid; int ref; int bg_ix, bg_iy, bg_iz; int bg_nx, bg_ny, bg_nz; int is; size = SubgridArraySize(subgrids); extents = ctalloc(GrGeomExtents, size); ForSubgridI(is, subgrids) { subgrid = SubgridArraySubgrid(subgrids, is); /* compute background grid extents on MaxRefLevel index space */ ref = (int)pow(2.0, GlobalsMaxRefLevel); bg_ix = BackgroundIX(bg) * ref; bg_iy = BackgroundIY(bg) * ref; bg_iz = BackgroundIZ(bg) * ref; bg_nx = BackgroundNX(bg) * ref; bg_ny = BackgroundNY(bg) * ref; bg_nz = BackgroundNZ(bg) * ref; ref = (int)Pow2(GlobalsMaxRefLevel); /*------------------------------------------ * set the lower extent values *------------------------------------------*/ if (xl_ghost > -1) { xl_ghost = pfmax(xl_ghost, 1); GrGeomExtentsIXLower(extents[is]) = (SubgridIX(subgrid) - xl_ghost) * ref; } else { GrGeomExtentsIXLower(extents[is]) = bg_ix; } if (yl_ghost > -1) { yl_ghost = pfmax(yl_ghost, 1); GrGeomExtentsIYLower(extents[is]) = (SubgridIY(subgrid) - yl_ghost) * ref; } else { GrGeomExtentsIYLower(extents[is]) = bg_iy; } if (zl_ghost > -1) { zl_ghost = pfmax(zl_ghost, 1); GrGeomExtentsIZLower(extents[is]) = (SubgridIZ(subgrid) - zl_ghost) * ref; } else { GrGeomExtentsIZLower(extents[is]) = bg_iz; } /*------------------------------------------ * set the upper extent values *------------------------------------------*/ if (xu_ghost > -1) { xu_ghost = pfmax(xu_ghost, 1); GrGeomExtentsIXUpper(extents[is]) = (SubgridIX(subgrid) + SubgridNX(subgrid) + xu_ghost) * ref - 1; } else { GrGeomExtentsIXUpper(extents[is]) = bg_ix + bg_nx - 1; } if (yu_ghost > -1) { yu_ghost = pfmax(yu_ghost, 1); GrGeomExtentsIYUpper(extents[is]) = (SubgridIY(subgrid) + SubgridNY(subgrid) + yu_ghost) * ref - 1; } else { GrGeomExtentsIYUpper(extents[is]) = bg_iy + bg_ny - 1; } if (zu_ghost > -1) { zu_ghost = pfmax(zu_ghost, 1); GrGeomExtentsIZUpper(extents[is]) = (SubgridIZ(subgrid) + SubgridNZ(subgrid) + zu_ghost) * ref - 1; } else { GrGeomExtentsIZUpper(extents[is]) = bg_iz + bg_nz - 1; } /*------------------------------------------ * convert to "octree coordinates" *------------------------------------------*/ /* Moved into the loop by SGS 7/8/98, was lying outside the is * loop which was an error (accessing invalid array elements) */ GrGeomExtentsIXLower(extents[is]) -= bg_ix; GrGeomExtentsIYLower(extents[is]) -= bg_iy; GrGeomExtentsIZLower(extents[is]) -= bg_iz; GrGeomExtentsIXUpper(extents[is]) -= bg_ix; GrGeomExtentsIYUpper(extents[is]) -= bg_iy; GrGeomExtentsIZUpper(extents[is]) -= bg_iz; }