//----------------------------------------------------------------------- void EBAMRGodunovGeomFactory:: createRegularCellsFromParms(Box& a_coarsestDomain, RealVect& a_coarsestDx, Vector<int>& a_refRatios) { // Retrieve grid data. Box finestDomain; int maxGridSize, maxCoarsenings; EBAMRGodunovGeomFactory::createRefinedDomainsFromParms(a_coarsestDomain, finestDomain, maxGridSize, maxCoarsenings, a_refRatios); // Retrieve basic geometric information. RealVect domainExtents; RealVect origin, finestDx; EBAMRGodunovGeomFactory::getBasicGeometry(domainExtents, origin, a_coarsestDx, finestDx, a_refRatios); // now define the regular geometry. AllRegularService regServ; EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->define(finestDomain, origin, finestDx[0], regServ, maxGridSize, maxCoarsenings); }
void do_geo(DisjointBoxLayout& a_dbl, EBISLayout & a_ebisl, Box & a_domain, Real & a_dx ) { //define grids int len = 32; int mid = len/2; Real xdom = 1.0; a_dx = xdom/len; const IntVect hi = (len-1)*IntVect::Unit; a_domain= Box(IntVect::Zero, hi); Vector<Box> boxes(4); Vector<int> procs(4); boxes[0] = Box(IntVect(D_DECL(0 , 0, 0)), IntVect(D_DECL(mid-1, mid-1, len-1))); boxes[1] = Box(IntVect(D_DECL(0 ,mid, 0)), IntVect(D_DECL(mid-1, len-1, len-1))); boxes[2] = Box(IntVect(D_DECL(mid, 0, 0)), IntVect(D_DECL(len-1, mid-1, len-1))); boxes[3] = Box(IntVect(D_DECL(mid,mid, 0)), IntVect(D_DECL(len-1, len-1, len-1))); LoadBalance(procs, boxes); /** int loProc = 0; int hiProc = numProc() -1; procs[0] = loProc; procs[1] = hiProc; procs[2] = loProc; procs[3] = hiProc; **/ a_dbl = DisjointBoxLayout(boxes, procs); //define geometry RealVect rampNormal = RealVect::Zero; rampNormal[0] = -0.5; rampNormal[1] = 0.866025404; Real rampAlpha = -0.0625; RealVect rampPoint = RealVect::Zero; rampPoint[0] = rampAlpha / rampNormal[0]; bool inside = true; PlaneIF ramp(rampNormal,rampPoint,inside); RealVect vectDx = RealVect::Unit; vectDx *= a_dx; GeometryShop mygeom( ramp, 0, vectDx ); RealVect origin = RealVect::Zero; EBIndexSpace *ebisPtr = Chombo_EBIS::instance(); ebisPtr->define(a_domain, origin, a_dx, mygeom); //fill layout ebisPtr->fillEBISLayout(a_ebisl, a_dbl, a_domain, 4 ); }
int main(int argc, char** argv) { #ifdef CH_MPI MPI_Init(&argc, &argv); #endif //begin forever present scoping trick { const char* in_file; if (argc < 2 || argv[1][0] == '-') { in_file = "ramp.inputs"; } else { in_file = argv[1]; } //parse input file ParmParse pp(0,NULL,NULL,in_file); int eekflag = 0; //define the geometry object. Box domain; eekflag = makeGeometry(domain); if (eekflag != 0) { pout() << "non zero eek detected = " << eekflag << endl; MayDay::Error("problem in makeGeometry"); } //check that total coarse vol = total fine vol //check that total coarse vol centroid = total fine vol centroid eekflag = checkCoarseAssortment(domain); if (eekflag != 0) { pout() << "checkCoarse: eek = " << eekflag << endl; MayDay::Error("problem in checkEBISL"); } pout() << "pointCoarsening test passed" << endl; }//end scoping trick EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->clear(); #ifdef CH_MPI MPI_Finalize(); #endif return 0; }
int main(int argc, char** argv) { #ifdef CH_MPI MPI_Init(&argc, &argv); #endif //begin scoping trick { int eekflag = 0; //define the geometry object. //need the new and delete because of //strong construction Box domain, coveredDomain; Real dx; //make the gometry. this makes the first Chombo_EBIS //and defines it using a geometryservice eekflag = makeGeometry(domain, dx, coveredDomain); if (eekflag != 0) { pout() << "non zero eek detected = " << eekflag << endl; MayDay::Error("problem in makeGeometry"); } eekflag = checkIrregFabCopy(domain); if (eekflag != 0) { pout() << "non zero eek detected = " << eekflag << endl; MayDay::Error("problem in checkIrregFabCopy"); } eekflag = checkRegularFabCopy(domain); if (eekflag != 0) { pout() << "non zero eek detected = " << eekflag << endl; MayDay::Error("problem in checkRegularFabCopy"); } pout() << "fab copy test passed" << endl; }//end scoping trick EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->clear(); #ifdef CH_MPI MPI_Finalize(); #endif return 0; }
int main(int argc,char **argv) { #ifdef CH_MPI MPI_Init(&argc, &argv); #endif // begin forever present scoping trick { const char* in_file; if (argc < 2 || argv[1][0] == '-') { in_file = "correct12.inputs"; } else { in_file = argv[1]; } //parse input file ParmParse pp(0,NULL,NULL,in_file); Box domain; int eekflag = 0; eekflag = makeGeometry(domain); if (eekflag != 0) { pout() << "non zero eek detected = " << eekflag << endl; MayDay::Error("problem in makeGeometry"); } eekflag = checkCorrection(domain); if (eekflag != 0) { pout() << "checkCorrection: eek = " << eekflag << endl; MayDay::Error("problem in checkCorrection"); } pout() << "correct1d2d test passed" << endl; } // end scoping trick EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->clear(); #ifdef CH_MPI MPI_Finalize(); #endif return 0; }
int main(int a_argc, char* a_argv[]) { #ifdef CH_MPI MPI_Init(&a_argc,&a_argv); // registerDebugger(); // setChomboMPIErrorHandler(); #endif { // Check for an input file char* inFile = NULL; EBDebugPoint::s_ivd = IntVect(D_DECL(16,45,0)); if (a_argc > 1) { inFile = a_argv[1]; } else { pout() << "Usage: <executable name> <inputfile>" << endl; pout() << "No input file specified" << endl; return -1; } // Parse the command line and the input file (if any) ParmParse pp(a_argc-2,a_argv+2,NULL,inFile); Box coarsestDomain; RealVect dx; // run amrGodunov godunovGeometry(coarsestDomain, dx); amrGodunov(coarsestDomain, dx); EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->clear(); } //scoping trick #ifdef CH_MPI pout() << "dumping timers" << endl; CH_TIMER_REPORT(); dumpmemoryatexit(); MPI_Finalize(); #endif pout() << "Done." << endl; }
int main(int argc, char* argv[]) { #ifdef CH_MPI MPI_Init(&argc, &argv); #endif // Scoping trick { #ifdef CH_MPI MPI_Barrier(Chombo_MPI::comm); #endif if (argc < 2) { cerr << " usage " << argv[0] << " <input_file_name> " << endl; exit(0); } char* inFile = argv[1]; ParmParse pp(argc-2,argv+2,NULL,inFile); PoissonParameters params; //read params from file getPoissonParameters(params); //define geometry from given params definePoissonGeometry(params); //solve the stinking problem and output everything solve(params); EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->clear(); } // End scoping trick #ifdef CH_MPI CH_TIMER_REPORT(); dumpmemoryatexit(); MPI_Finalize(); #endif }
int main(int argc, char** argv) { //This test is an attempt to test linearization //of eb data holders directly int eekflag; #ifdef CH_MPI MPI_Init(&argc, &argv); #endif //begin forever present scoping trick { // registerDebugger(); // Set up some geometry. Box domain; Real dx; EBISLayout ebisl; DisjointBoxLayout dbl; do_geo( dbl, ebisl, domain, dx ); eekflag = testIFFAB( dbl, ebisl, domain, dx ); if (eekflag != 0) { pout() << "IFFAB exhange linearization test failed " << endl; return eekflag; } EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->clear(); }//end scoping trick #ifdef CH_MPI MPI_Finalize(); #endif pout() << "IFFAB exchange linearization tests passed "<< endl; return eekflag; }
int main(int a_argc, char* a_argv[]) { #ifdef CH_MPI MPI_Init(&a_argc,&a_argv); { // setChomboMPIErrorHandler(); #endif // Check for an input file const char* inFile = "sphere.inputs"; ParmParse pp(0,NULL,NULL,inFile); divergenceTest(); EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->clear(); #ifdef CH_MPI } MPI_Finalize(); #endif }
//----------------------------------------------------------------------- void EBAMRGodunovGeomFactory:: createSphericalCavityFromParms(Box& a_coarsestDomain, RealVect& a_coarsestDx, Vector<int>& a_refRatios) { // Retrieve grid data. Box finestDomain; int maxGridSize, maxCoarsenings; EBAMRGodunovGeomFactory::createRefinedDomainsFromParms(a_coarsestDomain, finestDomain, maxGridSize, maxCoarsenings, a_refRatios); // Retrieve basic geometric information. RealVect domainExtents; RealVect origin, finestDx; EBAMRGodunovGeomFactory::getBasicGeometry(domainExtents, origin, a_coarsestDx, finestDx, a_refRatios); // now define the cavity. ParmParse pp; vector<Real> x0(SpaceDim); pp.getarr("sphere_center",x0, 0, SpaceDim); RealVect sphereCenter; for (int i = 0; i < SpaceDim; ++i) sphereCenter[i] = x0[i]; Real sphereRadius; pp.get("sphere_radius", sphereRadius); SphereIF sphereIF(sphereRadius, sphereCenter, true); int verbosity = 0; GeometryShop workshop(sphereIF,verbosity,finestDx); EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->define(finestDomain, origin, finestDx[0], workshop, maxGridSize, maxCoarsenings); }
void do_geo( Box &domain, Real &dx ) { int N = 10; Real xdom = 1.0; dx = xdom/N; const IntVect hi = (N-1)*IntVect::Unit; domain= Box(IntVect::Zero, hi); int updir=1; int indv=0; Real start = 0.5; Real slope = tan( M_PI/6.0 ); RealVect normal = RealVect::Zero; normal[updir] = 1.0; normal[indv] = -slope; RealVect point = RealVect::Zero; point[updir] = -slope*start; bool normalInside = true; PlaneIF myramp(normal,point,normalInside); RealVect vectDx = RealVect::Unit; vectDx *= dx; GeometryShop mygeom( myramp, 0, vectDx ); RealVect origin = RealVect::Zero; EBIndexSpace *ebisPtr = Chombo_EBIS::instance(); ebisPtr->define(domain, origin, dx, mygeom); return; }
int EBRestart::makeGeometry(EBIndexSpace& a_ebIndexSpace, const EBRestart::GeomParams& a_geomParams) { int eekflag = 0; SphereIF outside(a_geomParams.radius, a_geomParams.center, false); RealVect vectDx = RealVect::Unit; vectDx *= a_geomParams.dx; GeometryShop workshop(outside,0,vectDx); workshop.m_phase = 0; ProblemDomain pdomain( a_geomParams.domain ); a_ebIndexSpace.define(pdomain, a_geomParams.origin, a_geomParams.dx, workshop); return eekflag; }
int main (int argc, char** argv) { #ifdef CH_MPI MPI_Init(&argc,&argv); #endif // Begin forever present scoping trick { const char* in_file = "plane.inputs"; if (argc > 1) { in_file = argv[1]; } // Parse input file ParmParse pp(0,NULL,NULL,in_file); Box domain; RealVect origin; Real dx; BaseIF* implicit; // Make geometry implicit = makeGeometry(domain,origin,dx); // Make grids DisjointBoxLayout grids; makeLayout(grids,domain); // Create ebislayout int nghost = 0; EBISLayout ebisl; makeEBISL(ebisl,grids,domain,nghost); // Make a LevelData int nComps = 1; IntVect ghost = IntVect::Unit; ghost *= nghost; RefCountedPtr<DataFactory<EBCellFAB> > rcpFactory(new EBCellFactory(ebisl)); LevelData<EBCellFAB> level(grids,nComps,ghost,*rcpFactory); // Put some data in the data holders fillData(level,origin,dx,*implicit); // Done with this object delete implicit; // Write the data and the EB out const char* basename = "plane"; char name[1000]; sprintf(name,"%s%dd.hdf5",basename,SpaceDim); #ifdef CH_USE_HDF5 writeEBLevelname(&level,name); #endif } // End scoping trick // Clean up EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->clear(); CH_TIMER_REPORT(); #ifdef CH_MPI MPI_Finalize(); #endif return 0; }
BaseIF* makeGeometry(Box& a_domain, RealVect& a_origin, Real& a_dx) { RealVect point; RealVect normal; bool normalRegular; // parse input file ParmParse pp; Vector<int> n_cell(SpaceDim); pp.getarr("n_cell",n_cell,0,SpaceDim); CH_assert(n_cell.size() == SpaceDim); IntVect lo = IntVect::Zero; IntVect hi; for (int ivec = 0; ivec < SpaceDim; ivec++) { if (n_cell[ivec] <= 0) { pout() << "Bogus number of cells input = " << n_cell[ivec]; exit(1); } hi[ivec] = n_cell[ivec] - 1; } a_domain.setSmall(lo); a_domain.setBig(hi); Vector<Real> prob_lo(SpaceDim,1.0); Real prob_hi; pp.getarr("prob_lo",prob_lo,0,SpaceDim); pp.get("prob_hi",prob_hi); a_dx = (prob_hi-prob_lo[0])/n_cell[0]; for (int idir = 0; idir < SpaceDim; idir++) { a_origin[idir] = prob_lo[idir]; } // ParmParse doesn't get RealVects, so work-around with Vector<Real> Vector<Real> vectorCenter; pp.getarr("point",vectorCenter,0,SpaceDim); for (int idir = 0; idir < SpaceDim; idir++) { point[idir] = vectorCenter[idir]; } Vector<Real> vectorNormal; pp.getarr("normal",vectorNormal,0,SpaceDim); for (int idir = 0; idir < SpaceDim; idir++) { normal[idir] = vectorNormal[idir]; } // Parm Parse doesn't get bools, so work-around with int int intInsideRegular; pp.get("normalRegular",intInsideRegular); if (intInsideRegular != 0) normalRegular = true; if (intInsideRegular == 0) normalRegular = false; PlaneIF implicit(normal,point,normalRegular); RealVect vectDx = RealVect::Unit; vectDx *= a_dx; GeometryShop workshop(implicit,0,vectDx); // This generates the new EBIS EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->define(a_domain,a_origin,a_dx,workshop); return implicit.newImplicitFunction(); }
int makeGeometry(Box& a_domain) { Real dx; RealVect origin; int eekflag = 0; //parse input file ParmParse pp; Vector<int> n_cell(SpaceDim); pp.getarr("n_cell",n_cell,0,SpaceDim); CH_assert(n_cell.size() == SpaceDim); IntVect lo = IntVect::Zero; IntVect hi; for (int ivec = 0; ivec < SpaceDim; ivec++) { if (n_cell[ivec] <= 0) { pout() << " bogus number of cells input = " << n_cell[ivec]; return(-1); } hi[ivec] = n_cell[ivec] - 1; } a_domain.setSmall(lo); a_domain.setBig(hi); Vector<Real> prob_lo(SpaceDim, 1.0); Real prob_hi; pp.getarr("prob_lo",prob_lo,0,SpaceDim); pp.get("prob_hi",prob_hi); dx = (prob_hi-prob_lo[0])/n_cell[0]; RealVect dxVect = dx*RealVect::Unit; for (int idir = 0; idir < SpaceDim; idir++) { origin[idir] = prob_lo[idir]; } int verbosity = 0; int whichgeom; pp.get("which_geom",whichgeom); EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); if (whichgeom == 0) { //allregular pout() << "all regular geometry" << endl; AllRegularService regserv; ebisPtr->define(a_domain, origin, dx, regserv); } else if (whichgeom == 1) { pout() << "ramp geometry" << endl; int upDir; int indepVar; Real startPt; Real slope; pp.get("up_dir",upDir); pp.get("indep_var",indepVar); pp.get("start_pt", startPt); pp.get("ramp_slope", slope); RealVect normal = RealVect::Zero; normal[upDir] = 1.0; normal[indepVar] = -slope; RealVect point = RealVect::Zero; point[upDir] = -slope*startPt; bool normalInside = true; PlaneIF ramp(normal,point,normalInside); GeometryShop workshop(ramp,verbosity,dxVect); //this generates the new EBIS ebisPtr->define(a_domain, origin, dx, workshop); } else if (whichgeom == 5) { pout() << "sphere geometry" << endl; vector<Real> sphere_center(SpaceDim); pp.getarr("sphere_center",sphere_center, 0, SpaceDim); RealVect sphereCenter; for (int idir = 0; idir < SpaceDim; idir++) { sphereCenter[idir] = sphere_center[idir]; } Real sphereRadius; pp.get("sphere_radius", sphereRadius); bool insideRegular = false; SphereIF implicit(sphereRadius,sphereCenter,insideRegular); GeometryShop workshop(implicit,verbosity,dxVect); //this generates the new EBIS ebisPtr->define(a_domain, origin, dx, workshop); } else if (whichgeom == 13) { pout() << "rhodonea geometry" << endl; vector<Real> tmp(SpaceDim); pp.getarr("rhodonea_center", tmp, 0, SpaceDim); RealVect rhodoneaCenter; for (int idir = 0; idir < SpaceDim; idir++) { rhodoneaCenter[idir] = tmp[idir]; } Real innerRadius; pp.get("inner_radius", innerRadius); Real outerRadius; pp.get("outer_radius", outerRadius); int frequency; pp.get("frequency", frequency); bool insideRegular = false; RhodoneaIF implicit(innerRadius, outerRadius, frequency, rhodoneaCenter, insideRegular); GeometryShop workshop(implicit,verbosity,dxVect); //this generates the new EBIS ebisPtr->define(a_domain, origin, dx, workshop); } else { //bogus which_geom pout() << " bogus which_geom input = " << whichgeom; eekflag = 33; } return eekflag; }
int main(int a_argc, char* a_argv[]) { #ifdef CH_MPI MPI_Init(&a_argc,&a_argv); #endif //Scoping trick { CH_TIMERS("uber_timers"); CH_TIMER("define_geometry", t1); CH_TIMER("run", t2); #ifdef CH_MPI MPI_Barrier(Chombo_MPI::comm); #endif //Check for an input file char* inFile = NULL; if (a_argc > 1) { inFile = a_argv[1]; } else { pout() << "Usage: <executable name> <inputfile>" << endl; pout() << "No input file specified" << endl; return -1; } //Parse the command line and the input file (if any) ParmParse pp(a_argc-2,a_argv+2,NULL,inFile); ProblemDomain coarsestDomain; RealVect coarsestDx; AMRParameters params; getAMRINSParameters(params, coarsestDomain); int numFilt; pp.get("num_filter_iterations", numFilt); params.m_numFilterIterations = numFilt; int gphiIterations; pp.get("num_gphi_iterations", gphiIterations); params.m_gphiIterations = gphiIterations; int initIterations; pp.get("num_init_iterations", initIterations); params.m_initIterations = initIterations; bool doRegridSmoothing; pp.get("do_regrid_smoothing", doRegridSmoothing); params.m_doRegridSmoothing = doRegridSmoothing; CH_START(t1); //define geometry AMRINSGeometry(params, coarsestDomain); CH_STOP(t1); CH_START(t2); ebamriTransport(params, coarsestDomain); CH_STOP(t2); EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->clear(); }//end scoping trick #ifdef CH_MPI CH_TIMER_REPORT(); dumpmemoryatexit(); MPI_Finalize(); #endif }
int main(int argc, char** argv) { #ifdef CH_MPI MPI_Init(&argc, &argv); #endif //begin forever present scoping trick { const char* in_file = "ramp.inputs"; //parse input file ParmParse pp(0,NULL,NULL,in_file); int eekflag = 0; //define the geometry object. //need the new and delete because of //strong construction //make the gometry. this makes the first Chombo_EBIS Box domain; Real dx; RealVect origin; int upDir; int indepVar; Real startPt; Real slope; //and defines it using a geometryservice eekflag = makeGeometry(domain, dx, origin, upDir, indepVar, startPt, slope); if (eekflag != 0) { pout() << "non zero eek detected = " << eekflag << endl; MayDay::Error("problem in makeGeometry"); } //make grids DisjointBoxLayout grids; eekflag = makeLayout(grids, domain); if (eekflag != 0) { pout() << "non zero eek detected = " << eekflag << endl; MayDay::Error("problem in makeLayouts"); } ///create ebislayout int nghost = 2; EBISLayout ebisl; eekflag = makeEBISL(ebisl, grids, domain, nghost); if (eekflag != 0) { pout() << "non zero eek detected = " << eekflag << endl; MayDay::Error("problem in makeEBISL"); } //check everything i can think of on finest level eekflag = checkEBISL(ebisl, grids, domain, dx, origin, upDir, indepVar, startPt, slope); if (eekflag != 0) { pout() << "non zero eek detected = " << eekflag << endl; MayDay::Error("problem in checkEBISL"); } pout() << "ramp test passed" << endl; }//end scoping trick EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->clear(); #ifdef CH_MPI MPI_Finalize(); #endif return 0; }
int makeGeometry(Box& a_domain, Real& a_dx, RealVect& a_origin, int& a_upDir, int& a_indepVar, Real& a_startPt, Real& a_slope) { int eekflag = 0; //parse input file ParmParse pp; Vector<int> n_cell(SpaceDim); pp.getarr("n_cell",n_cell,0,SpaceDim); CH_assert(n_cell.size() == SpaceDim); IntVect lo = IntVect::Zero; IntVect hi; for (int ivec = 0; ivec < SpaceDim; ivec++) { if (n_cell[ivec] <= 0) { pout() << " bogus number of cells input = " << n_cell[ivec]; return(-1); } hi[ivec] = n_cell[ivec] - 1; } a_domain.setSmall(lo); a_domain.setBig(hi); Vector<Real> prob_lo(SpaceDim, 1.0); Real prob_hi; pp.getarr("prob_lo",prob_lo,0,SpaceDim); pp.get("prob_hi",prob_hi); a_dx = (prob_hi-prob_lo[0])/n_cell[0]; for (int idir = 0; idir < SpaceDim; idir++) { a_origin[idir] = prob_lo[idir]; } pp.get("up_dir",a_upDir); a_upDir = SpaceDim-1; pp.get("indep_var",a_indepVar); pp.get("start_pt", a_startPt); pp.get("ramp_slope", a_slope); RealVect normal = RealVect::Zero; normal[a_upDir] = 1.0; normal[a_indepVar] = -a_slope; RealVect point = RealVect::Zero; point[a_upDir] = -a_slope*a_startPt; bool normalInside = true; PlaneIF ramp(normal,point,normalInside); RealVect vectDx = RealVect::Unit; vectDx *= a_dx; GeometryShop workshop(ramp,0,vectDx); //this generates the new EBIS EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->define(a_domain, a_origin, a_dx, workshop); return eekflag; }
BaseIF* makeGeometry(Box& a_domain, RealVect& a_origin, Real& a_dx) { // parse input file ParmParse pp; Vector<int> n_cell(SpaceDim); pp.getarr("n_cell",n_cell,0,SpaceDim); CH_assert(n_cell.size() == SpaceDim); IntVect lo = IntVect::Zero; IntVect hi; for (int ivec = 0; ivec < SpaceDim; ivec++) { if (n_cell[ivec] <= 0) { pout() << "Bogus number of cells input = " << n_cell[ivec]; exit(1); } hi[ivec] = n_cell[ivec] - 1; } a_domain.setSmall(lo); a_domain.setBig(hi); Vector<Real> prob_lo(SpaceDim,1.0); Real prob_hi; pp.getarr("prob_lo",prob_lo,0,SpaceDim); pp.get("prob_hi",prob_hi); a_dx = (prob_hi-prob_lo[0])/n_cell[0]; for (int idir = 0; idir < SpaceDim; idir++) { a_origin[idir] = prob_lo[idir]; } Real outerRadius; pp.get("outer_radius",outerRadius); Real outerThick; pp.get("outer_thick",outerThick); Real outerHeight; pp.get("outer_height",outerHeight); Real outerOffset = ((prob_hi - prob_lo[0]) - outerHeight) / 2.0 + prob_lo[0]; Real innerRadius; pp.get("inner_radius",innerRadius); Real innerThick; pp.get("inner_thick",innerThick); Real innerOffset = 0.0; innerOffset += outerOffset; Real innerHeight; pp.get("inner_height",innerHeight); Real plateHeight; pp.get("plate_height",plateHeight); plateHeight += outerOffset; Real plateThick; pp.get("plate_thick",plateThick); int doHoles; pp.get("do_holes",doHoles); Real holeRadius; pp.get("hole_radius",holeRadius); Real holeSpace; pp.get("hole_space",holeSpace); int vaneNum; pp.get("vane_num",vaneNum); Real vaneThick; pp.get("vane_thick",vaneThick); RealVect vaneNorm; Vector<Real> vectVaneNorm; pp.getarr("vane_norm",vectVaneNorm,0,SpaceDim); for (int idir = 0; idir < SpaceDim; idir++) { vaneNorm[idir] = vectVaneNorm[idir]; } Real vaneOffset; pp.get("vane_offset",vaneOffset); Real vaneHeight = innerHeight - 2*vaneOffset; vaneOffset += outerOffset; // Make the outer chamber BaseIF* outerChamber = makeChamber(outerRadius,outerThick, outerOffset,outerHeight); // Make the inner chamber BaseIF* innerChamber = makeChamber(innerRadius,innerThick, innerOffset,innerHeight); // Make the inner plate with holes BaseIF* holyPlate = makePlate(plateHeight,plateThick,innerRadius, doHoles,holeRadius,holeSpace); // Make the vanes BaseIF* vanes = makeVanes(vaneNum,vaneThick,vaneNorm,innerRadius,outerRadius, vaneOffset,vaneHeight); // Union all the pieces together Vector<BaseIF*> pieces; pieces.push_back(outerChamber); pieces.push_back(innerChamber); pieces.push_back(holyPlate); pieces.push_back(vanes); UnionIF insideSwirl(pieces); ComplementIF outsideSwirl(insideSwirl,true); RealVect vectDx = RealVect::Unit; vectDx *= a_dx; GeometryShop workshop(outsideSwirl,0,vectDx); // This generates the new EBIS EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->define(a_domain,a_origin,a_dx,workshop); return outsideSwirl.newImplicitFunction(); }
BaseIF* makeGeometry(Box& a_domain, RealVect& a_origin, Real& a_dx) { RealVect center1; Real radius1; RealVect center2; Real radius2; bool insideRegular; // parse input file ParmParse pp; Vector<int> n_cell(SpaceDim); pp.getarr("n_cell",n_cell,0,SpaceDim); CH_assert(n_cell.size() == SpaceDim); IntVect lo = IntVect::Zero; IntVect hi; for (int ivec = 0; ivec < SpaceDim; ivec++) { if (n_cell[ivec] <= 0) { pout() << "Bogus number of cells input = " << n_cell[ivec]; exit(1); } hi[ivec] = n_cell[ivec] - 1; } a_domain.setSmall(lo); a_domain.setBig(hi); Vector<Real> prob_lo(SpaceDim,1.0); Real prob_hi; pp.getarr("prob_lo",prob_lo,0,SpaceDim); pp.get("prob_hi",prob_hi); a_dx = (prob_hi-prob_lo[0])/n_cell[0]; for (int idir = 0; idir < SpaceDim; idir++) { a_origin[idir] = prob_lo[idir]; } // ParmParse doesn't get RealVects, so work-around with Vector<Real> Vector<Real> vectorCenter; pp.getarr("center1",vectorCenter,0,SpaceDim); for (int idir = 0; idir < SpaceDim; idir++) { center1[idir] = vectorCenter[idir]; } pp.get("radius1",radius1); pp.getarr("center2",vectorCenter,0,SpaceDim); for (int idir = 0; idir < SpaceDim; idir++) { center2[idir] = vectorCenter[idir]; } pp.get("radius2",radius2); // Parm Parse doesn't get bools, so work-around with int int intInsideRegular; pp.get("insideRegular",intInsideRegular); if (intInsideRegular != 0) insideRegular = true; if (intInsideRegular == 0) insideRegular = false; // Stay inside until the end bool inside = true; // Sphere 1 is the given "radius1" and "center1" SphereIF sphere1(radius1,center1,inside); // Sphere 2 is the given "radius2" and "center2" SphereIF sphere2(radius2,center2,inside); // Take the union of the spheres UnionIF implicit(sphere1,sphere2); // Complement if necessary ComplementIF insideOut(implicit,!insideRegular); RealVect vectDx = RealVect::Unit; vectDx *= a_dx; GeometryShop workshop(insideOut,0,vectDx); // This generates the new EBIS EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->define(a_domain,a_origin,a_dx,workshop); return insideOut.newImplicitFunction(); }
int makeGeometry(Box& a_domain) { Real dx; RealVect origin; int eekflag = 0; //parse input file ParmParse pp; Vector<int> n_cell(SpaceDim); pp.getarr("n_cell",n_cell,0,SpaceDim); CH_assert(n_cell.size() == SpaceDim); IntVect lo = IntVect::Zero; IntVect hi; for (int ivec = 0; ivec < SpaceDim; ivec++) { if (n_cell[ivec] <= 0) { pout() << " bogus number of cells input = " << n_cell[ivec]; return(-1); } hi[ivec] = n_cell[ivec] - 1; } a_domain.setSmall(lo); a_domain.setBig(hi); Vector<Real> prob_lo(SpaceDim, 1.0); Real prob_hi; pp.getarr("prob_lo",prob_lo,0,SpaceDim); pp.get("prob_hi",prob_hi); dx = (prob_hi-prob_lo[0])/n_cell[0]; RealVect dxVect = dx*RealVect::Unit; for (int idir = 0; idir < SpaceDim; idir++) { origin[idir] = prob_lo[idir]; } int verbosity = 0; int whichgeom; pp.get("which_geom",whichgeom); EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); if (whichgeom == 0) { //allregular pout() << "all regular geometry" << endl; AllRegularService regserv; ebisPtr->define(a_domain, origin, dx, regserv); } else if (whichgeom == 1) { pout() << "ramp geometry" << endl; int upDir; int indepVar; Real startPt; Real slope; pp.get("up_dir",upDir); pp.get("indep_var",indepVar); pp.get("start_pt", startPt); pp.get("ramp_slope", slope); RealVect normal = RealVect::Zero; normal[upDir] = 1.0; normal[indepVar] = -slope; RealVect point = RealVect::Zero; point[upDir] = -slope*startPt; bool normalInside = true; PlaneIF ramp(normal,point,normalInside); GeometryShop workshop(ramp,verbosity,dxVect); //this generates the new EBIS ebisPtr->define(a_domain, origin, dx, workshop); } else if (whichgeom == 5) { pout() << "sphere geometry" << endl; vector<Real> sphere_center(SpaceDim); pp.getarr("sphere_center",sphere_center, 0, SpaceDim); RealVect sphereCenter; for (int idir = 0; idir < SpaceDim; idir++) { sphereCenter[idir] = sphere_center[idir]; } Real sphereRadius; pp.get("sphere_radius", sphereRadius); bool insideRegular = false; SphereIF implicit(sphereRadius,sphereCenter,insideRegular); GeometryShop workshop(implicit,verbosity,dxVect); //this generates the new EBIS ebisPtr->define(a_domain, origin, dx, workshop); } else if (whichgeom == 13) { pout() << "rhodonea geometry" << endl; vector<Real> tmp(SpaceDim); pp.getarr("rhodonea_center", tmp, 0, SpaceDim); RealVect rhodoneaCenter; for (int idir = 0; idir < SpaceDim; idir++) { rhodoneaCenter[idir] = tmp[idir]; } Real innerRadius; pp.get("inner_radius", innerRadius); Real outerRadius; pp.get("outer_radius", outerRadius); int frequency; pp.get("frequency", frequency); bool insideRegular = false; RhodoneaIF implicit(innerRadius, outerRadius, frequency, rhodoneaCenter, insideRegular); GeometryShop workshop(implicit,verbosity,dxVect); //this generates the new EBIS ebisPtr->define(a_domain, origin, dx, workshop); } else if (whichgeom == 18) { pout() << "Low swirl burner geometry" << endl; // AttachDebugger(); Box domain; for (int idir = 0; idir < SpaceDim; idir++) { origin[idir] = prob_lo[idir]; } Real outerRadius; pp.get("outer_radius",outerRadius); Real outerThick; pp.get("outer_thick",outerThick); Real outerHeight; pp.get("outer_height",outerHeight); Real outerOffset = ((prob_hi - prob_lo[0]) - outerHeight) / 2.0 + prob_lo[0]; Real innerRadius; pp.get("inner_radius",innerRadius); Real innerThick; pp.get("inner_thick",innerThick); Real innerOffset = 0.0; innerOffset += outerOffset; Real innerHeight; pp.get("inner_height",innerHeight); Real plateHeight; pp.get("plate_height",plateHeight); plateHeight += outerOffset; Real plateThick; pp.get("plate_thick",plateThick); int doHoles; pp.get("do_holes",doHoles); Real holeRadius; pp.get("hole_radius",holeRadius); Real holeSpace; pp.get("hole_space",holeSpace); int vaneNum; pp.get("vane_num",vaneNum); Real vaneThick; pp.get("vane_thick",vaneThick); RealVect vaneNorm; Vector<Real> vectVaneNorm; pp.getarr("vane_norm",vectVaneNorm,0,SpaceDim); for (int idir = 0; idir < SpaceDim; idir++) { vaneNorm[idir] = vectVaneNorm[idir]; } Real vaneOffset; pp.get("vane_offset",vaneOffset); Real vaneHeight = innerHeight - 2*vaneOffset; vaneOffset += outerOffset; // Make the outer chamber BaseIF* outerChamber = makeChamber(outerRadius,outerThick, outerOffset,outerHeight); // Make the inner chamber BaseIF* innerChamber = makeChamber(innerRadius,innerThick, innerOffset,innerHeight); // Make the inner plate with holes BaseIF* holyPlate = makePlate(plateHeight,plateThick,innerRadius, doHoles,holeRadius,holeSpace); // Make the vanes BaseIF* vanes = makeVanes(vaneNum,vaneThick,vaneNorm,innerRadius,outerRadius, vaneOffset,vaneHeight); // Union all the pieces together Vector<BaseIF*> pieces; pieces.push_back(outerChamber); pieces.push_back(innerChamber); pieces.push_back(holyPlate); pieces.push_back(vanes); UnionIF swirl(pieces); ComplementIF outside(swirl,true); GeometryShop workshop(outside,verbosity,dxVect); // This generates the new EBIS EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->define(a_domain, origin, dx, workshop); } else { //bogus which_geom pout() << " bogus which_geom input = " << whichgeom; eekflag = 33; } return eekflag; }
int makeGeometry(Box& a_domain) { int eekflag = 0; //parse input file ParmParse pp; RealVect origin = RealVect::Zero; Vector<int> n_cell(SpaceDim); pp.getarr("n_cell",n_cell,0,SpaceDim); Real probhi; pp.get("prob_hi", probhi); Real dx = probhi/n_cell[0]; CH_assert(n_cell.size() == SpaceDim); IntVect lo = IntVect::Zero; IntVect hi; for (int ivec = 0; ivec < SpaceDim; ivec++) { if (n_cell[ivec] <= 0) { pout() << " bogus number of cells input = " << n_cell[ivec]; return(-1); } hi[ivec] = n_cell[ivec] - 1; } a_domain.setSmall(lo); a_domain.setBig(hi); int iverbose; pp.get("verbose", iverbose); bool verbose = (iverbose==1); int whichgeom; pp.get("which_geom",whichgeom); if (whichgeom == 0) { //allregular if (verbose) pout() << "all regular geometry" << endl; AllRegularService regserv; EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->define(a_domain, origin, dx, regserv, 2048); } else if (whichgeom == 1) { if (verbose) pout() << "ramp geometry" << endl; int upDir; int indepVar; Real startPt; Real slope; pp.get("up_dir",upDir); pp.get("indep_var",indepVar); pp.get("start_pt", startPt); pp.get("ramp_slope", slope); RealVect normal = RealVect::Zero; normal[upDir] = 1.0; normal[indepVar] = -slope; RealVect point = RealVect::Zero; point[upDir] = -slope*startPt; bool normalInside = true; PlaneIF ramp(normal,point,normalInside); RealVect vectDx = RealVect::Unit; vectDx *= dx; GeometryShop workshop(ramp,0,vectDx); //this generates the new EBIS EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->define(a_domain, origin, dx, workshop, 2048); } else if (whichgeom == 2) { if (verbose) pout() << "slab geometry" << endl; vector<int> slab_lo(SpaceDim); pp.getarr("slab_lo",slab_lo,0,SpaceDim); vector<int> slab_hi(SpaceDim); pp.getarr("slab_hi",slab_hi,0,SpaceDim); IntVect lo, hi; for (int idir = 0; idir < SpaceDim; idir++) { lo[idir] = slab_lo[idir]; hi[idir] = slab_hi[idir]; } Box coveredBox(lo,hi); SlabService slab(coveredBox); //this generates the new EBIS EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); RealVect origin = RealVect::Zero; ebisPtr->define(a_domain, origin, dx, slab,2048); } else { //bogus which_geom pout() << " bogus which_geom input = " << whichgeom; eekflag = 33; } return eekflag; }
void sphereGeometry(Box& a_coarsestDomain, Real& a_dx) { ParmParse ppgodunov; //parse input file int max_level = 0; ppgodunov.get("max_level",max_level); int num_read_levels = Max(max_level,1); std::vector<int> refRatios; // (num_read_levels,1); // note this requires a refRatio to be defined for the // finest level (even though it will never be used) ppgodunov.getarr("ref_ratio",refRatios,0,num_read_levels+1); ParmParse pp; RealVect origin = RealVect::Zero; Vector<int> n_cell(SpaceDim); pp.getarr("n_cell",n_cell,0,SpaceDim); CH_assert(n_cell.size() == SpaceDim); IntVect lo = IntVect::Zero; IntVect hi; for (int ivec = 0; ivec < SpaceDim; ivec++) { if (n_cell[ivec] <= 0) { pout() << " bogus number of cells input = " << n_cell[ivec]; MayDay::Error(); } hi[ivec] = n_cell[ivec] - 1; } a_coarsestDomain = Box(lo, hi); Box finestDomain = a_coarsestDomain; for (int ilev = 0; ilev < max_level; ilev++) { finestDomain.refine(refRatios[ilev]); } Real prob_hi; int numOpen = n_cell[0]; pp.get("domain_length",prob_hi); a_dx = prob_hi/numOpen; Real fineDx = a_dx; int ebMaxCoarsen = 2; for (int ilev = 0; ilev < max_level; ilev++) { fineDx /= refRatios[ilev]; ebMaxCoarsen += refRatios[ilev]/2; } int ebMaxSize; ppgodunov.get("max_grid_size", ebMaxSize); EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); pout() << "sphere geometry" << endl; vector<Real> sphere_center(SpaceDim); pp.getarr("sphere_center",sphere_center, 0, SpaceDim); RealVect sphereCenter; for (int idir = 0; idir < SpaceDim; idir++) { sphereCenter[idir] = sphere_center[idir]; } Real sphereRadius; pp.get("sphere_radius", sphereRadius); int inside_fluid; pp.get("sphere_fluid_inside", inside_fluid); bool insideFluid = (inside_fluid==1); SphereIF sphereIF(sphereRadius, sphereCenter, insideFluid); RealVect vectFineDx(D_DECL(fineDx,fineDx,fineDx)); GeometryShop workshop(sphereIF,0,vectFineDx); //this generates the new EBIS ebisPtr->define(finestDomain, origin, fineDx, workshop, ebMaxSize, ebMaxCoarsen); }
int main(int argc, char** argv) { #ifdef CH_MPI MPI_Init(&argc, &argv); #endif int eekflag = 0; {//begin forever present scoping trick const char* in_file = "ramp.inputs"; //parse input file ParmParse pp(0,NULL,NULL,in_file); //define the geometry object. //need the new and delete because of //strong construction //make the gometry. this makes the first Chombo_EBIS Box domainFine, domainCoar; Real dxFine, dxCoar; //and defines it using a geometryservice eekflag = makeGeometry(domainFine, dxFine); CH_assert(eekflag == 0); domainCoar = coarsen(domainFine, 2); dxCoar = 2.0*dxFine; //make grids DisjointBoxLayout gridsFine, gridsCoar; eekflag = makeLayout(gridsFine, domainFine); CH_assert(eekflag == 0); coarsen(gridsCoar, gridsFine, 2); ///create ebislayout int nghost = 2; EBISLayout ebislFine, ebislCoar; eekflag = makeEBISL(ebislFine, gridsFine, domainFine, nghost); if (eekflag != 0) return eekflag; eekflag = makeEBISL(ebislCoar, gridsCoar, domainCoar, nghost); if (eekflag != 0) return eekflag; int nvar = 1; EBCellFactory ebcellfactFine(ebislFine); EBCellFactory ebcellfactCoar(ebislCoar); IntVect ivghost = nghost*IntVect::Unit; LevelData<EBCellFAB> errorFine(gridsFine, nvar, ivghost,ebcellfactFine); LevelData<EBCellFAB> errorCoar(gridsCoar, nvar, ivghost,ebcellfactCoar); eekflag = getError(errorFine,ebislFine, gridsFine, domainFine, dxFine); if (eekflag != 0) return eekflag; eekflag = getError(errorCoar,ebislCoar, gridsCoar, domainCoar, dxCoar); if (eekflag != 0) return eekflag; eekflag = compareError(errorFine, ebislFine, gridsFine, domainFine, errorCoar, ebislCoar, gridsCoar, domainCoar); if (eekflag != 0) return eekflag; }//end omnipresent scoping trick EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->clear(); if (eekflag == 0) { pout() << "aggpwlfpTest passed" << endl; } #ifdef CH_MPI MPI_Finalize(); #endif return eekflag; }
int main(int argc, char** argv) { //This test is an attempt to test linearization //of eb data holders directly int eekflag=0; #ifdef CH_MPI MPI_Init(&argc, &argv); #endif //begin forever present scoping trick { //registerDebugger(); // Set up some geometry. Box domain; Real dx; do_geo( domain, dx ); Vector<Box> boxes(1, domain); Vector<int> procs(1, 0); // Make a layout for the space. DisjointBoxLayout dbl(boxes, procs); // Fill in the layout with the geometrical info. EBISLayout ebisl; EBIndexSpace *ebisPtr = Chombo_EBIS::instance(); ebisPtr->fillEBISLayout(ebisl, dbl, domain, 1 ); // Define the leveldata for my one and only level. DataIterator dit = dbl.dataIterator(); for ( dit.begin(); dit.ok(); ++dit ) { eekflag = testIVFAB(ebisl[dit()], dbl.get(dit())); if (eekflag != 0) { pout() << "IVFAB linearization test failed " << endl; return eekflag; } eekflag = testIFFAB(ebisl[dit()], dbl.get(dit())); if (eekflag != 0) { pout() << "IFFAB linearization test failed " << endl; return eekflag; } eekflag = testEBCellFAB(ebisl[dit()], dbl.get(dit())); if (eekflag != 0) { pout() << "EBCellFAB linearization test failed " << endl; return eekflag; } eekflag = testEBFaceFAB(ebisl[dit()], dbl.get(dit())); if (eekflag != 0) { pout() << "EBFaceFAB linearization test failed " << endl; return eekflag; } eekflag = testEBFluxFAB(ebisl[dit()], dbl.get(dit())); if (eekflag != 0) { pout() << "EBFluxFAB linearization test failed " << endl; return eekflag; } } ebisPtr->clear(); }//end scoping trick pout() << "linearization tests passed "<< endl; #ifdef CH_MPI MPI_Finalize(); #endif return eekflag; }
BaseIF* makeGeometry(Box& a_domain, RealVect& a_origin, Real& a_dx) { RealVect center; RealVect radii; bool insideRegular; // parse input file ParmParse pp; Vector<int> n_cell(SpaceDim); pp.getarr("n_cell",n_cell,0,SpaceDim); CH_assert(n_cell.size() == SpaceDim); IntVect lo = IntVect::Zero; IntVect hi; for (int ivec = 0; ivec < SpaceDim; ivec++) { if (n_cell[ivec] <= 0) { pout() << "Bogus number of cells input = " << n_cell[ivec]; exit(1); } hi[ivec] = n_cell[ivec] - 1; } a_domain.setSmall(lo); a_domain.setBig(hi); Vector<Real> prob_lo(SpaceDim,1.0); Real prob_hi; pp.getarr("prob_lo",prob_lo,0,SpaceDim); pp.get("prob_hi",prob_hi); a_dx = (prob_hi-prob_lo[0])/n_cell[0]; for (int idir = 0; idir < SpaceDim; idir++) { a_origin[idir] = prob_lo[idir]; } // ParmParse doesn't get RealVects, so work-around with Vector<Real> Vector<Real> vectorCenter; pp.getarr("center",vectorCenter,0,SpaceDim); for (int idir = 0; idir < SpaceDim; idir++) { center[idir] = vectorCenter[idir]; } Vector<Real> vectorRadii; pp.getarr("radii",vectorRadii,0,SpaceDim); for (int idir = 0; idir < SpaceDim; idir++) { radii[idir] = vectorRadii[idir]; } int halfTurns; pp.get("halfturns",halfTurns); // Parm Parse doesn't get bools, so work-around with int int intInsideRegular; pp.get("insideRegular",intInsideRegular); if (intInsideRegular != 0) insideRegular = true; if (intInsideRegular == 0) insideRegular = false; IntVect zero=IntVect::Zero; bool inside = true; EllipsoidIF ellipsoid(radii,center,inside); Real coef = halfTurns / 2.0; IntVect power(D_DECL(1,0,0)); Vector<PolyTerm> term; term.resize(1); term[0].coef = coef; term[0].powers = power; PolynomialIF rotate(term,inside); LatheIF implicit(ellipsoid,rotate,center,insideRegular); RealVect vectDx = RealVect::Unit; vectDx *= a_dx; GeometryShop workshop(implicit,0,vectDx); // This generates the new EBIS EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->define(a_domain,a_origin,a_dx,workshop); return implicit.newImplicitFunction(); }