本文整理汇总了C++中BoxArray::define方法的典型用法代码示例。如果您正苦于以下问题:C++ BoxArray::define方法的具体用法?C++ BoxArray::define怎么用?C++ BoxArray::define使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoxArray
的用法示例。
在下文中一共展示了BoxArray::define方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main_main
void main_main ()
{
// What time is it now? We'll use this to compute total run time.
Real strt_time = ParallelDescriptor::second();
// AMREX_SPACEDIM: number of dimensions
int n_cell, max_grid_size;
Vector<int> bc_lo(AMREX_SPACEDIM,0);
Vector<int> bc_hi(AMREX_SPACEDIM,0);
// inputs parameters
{
// ParmParse is way of reading inputs from the inputs file
ParmParse pp;
// We need to get n_cell from the inputs file - this is the
// number of cells on each side of a square (or cubic) domain.
pp.get("n_cell", n_cell);
// The domain is broken into boxes of size max_grid_size
max_grid_size = 32;
pp.query("max_grid_size", max_grid_size);
}
Vector<int> is_periodic(AMREX_SPACEDIM,0);
for (int idim=0; idim < AMREX_SPACEDIM; ++idim) {
is_periodic[idim] = 1;
}
// make BoxArray and Geometry
BoxArray ba;
Geometry geom;
{
IntVect dom_lo(AMREX_D_DECL( 0, 0, 0));
IntVect dom_hi(AMREX_D_DECL(n_cell-1, n_cell-1, n_cell-1));
Box domain(dom_lo, dom_hi);
// Initialize the boxarray "ba" from the single box "bx"
ba.define(domain);
// Break up boxarray "ba" into chunks no larger than
// "max_grid_size" along a direction
ba.maxSize(max_grid_size);
// This defines the physical box, [0, 1] in each direction.
RealBox real_box({AMREX_D_DECL(0.0, 0.0, 0.0)},
{AMREX_D_DECL(1.0, 1.0, 1.0)});
// This defines a Geometry object
geom.define(domain, &real_box,
CoordSys::cartesian, is_periodic.data());
}
// Nghost = number of ghost cells for each array
int Nghost = 0;
// do the runtime parameter initializations and microphysics inits
if (ParallelDescriptor::IOProcessor()) {
std::cout << "reading extern runtime parameters ..." << std::endl;
}
ParmParse ppa("amr");
std::string probin_file = "probin";
ppa.query("probin_file", probin_file);
const int probin_file_length = probin_file.length();
Vector<int> probin_file_name(probin_file_length);
for (int i = 0; i < probin_file_length; i++)
probin_file_name[i] = probin_file[i];
init_unit_test(probin_file_name.dataPtr(), &probin_file_length);
// Ncomp = number of components for each array
int Ncomp = -1;
init_variables();
get_ncomp(&Ncomp);
int name_len = -1;
get_name_len(&name_len);
// get the variable names
Vector<std::string> varnames;
for (int i=0; i<Ncomp; i++) {
char* cstring[name_len+1];
get_var_name(cstring, &i);
std::string name(*cstring);
varnames.push_back(name);
}
// time = starting time in the simulation
Real time = 0.0;
// How Boxes are distrubuted among MPI processes
DistributionMapping dm(ba);
//.........这里部分代码省略.........
示例2: main_main
void main_main ()
{
// What time is it now? We'll use this to compute total run time.
Real strt_time = ParallelDescriptor::second();
std::cout << std::setprecision(15);
int n_cell, max_grid_size, nsteps, plot_int, is_periodic[BL_SPACEDIM];
// Boundary conditions
Array<int> lo_bc(BL_SPACEDIM), hi_bc(BL_SPACEDIM);
// inputs parameters
{
// ParmParse is way of reading inputs from the inputs file
ParmParse pp;
// We need to get n_cell from the inputs file - this is the number of cells on each side of
// a square (or cubic) domain.
pp.get("n_cell",n_cell);
// Default nsteps to 0, allow us to set it to something else in the inputs file
pp.get("max_grid_size",max_grid_size);
// Default plot_int to 1, allow us to set it to something else in the inputs file
// If plot_int < 0 then no plot files will be written
plot_int = 1;
pp.query("plot_int",plot_int);
// Default nsteps to 0, allow us to set it to something else in the inputs file
nsteps = 0;
pp.query("nsteps",nsteps);
// Boundary conditions - default is periodic (INT_DIR)
for (int i = 0; i < BL_SPACEDIM; ++i)
{
lo_bc[i] = hi_bc[i] = INT_DIR; // periodic boundaries are interior boundaries
}
pp.queryarr("lo_bc",lo_bc,0,BL_SPACEDIM);
pp.queryarr("hi_bc",hi_bc,0,BL_SPACEDIM);
}
// make BoxArray and Geometry
BoxArray ba;
Geometry geom;
{
IntVect dom_lo(IntVect(D_DECL(0,0,0)));
IntVect dom_hi(IntVect(D_DECL(n_cell-1, n_cell-1, n_cell-1)));
Box domain(dom_lo, dom_hi);
// Initialize the boxarray "ba" from the single box "bx"
ba.define(domain);
// Break up boxarray "ba" into chunks no larger than "max_grid_size" along a direction
ba.maxSize(max_grid_size);
// This defines the physical size of the box. Right now the box is [-1,1] in each direction.
RealBox real_box;
for (int n = 0; n < BL_SPACEDIM; n++) {
real_box.setLo(n,-1.0);
real_box.setHi(n, 1.0);
}
// This says we are using Cartesian coordinates
int coord = 0;
// This sets the boundary conditions to be doubly or triply periodic
int is_periodic[BL_SPACEDIM];
for (int i = 0; i < BL_SPACEDIM; i++)
{
is_periodic[i] = 0;
if (lo_bc[i] == 0 && hi_bc[i] == 0) {
is_periodic[i] = 1;
}
}
// This defines a Geometry object
geom.define(domain,&real_box,coord,is_periodic);
}
// Boundary conditions
PhysBCFunct physbcf;
BCRec bcr(&lo_bc[0], &hi_bc[0]);
physbcf.define(geom, bcr, BndryFunctBase(phifill)); // phifill is a fortran function
// define dx[]
const Real* dx = geom.CellSize();
// Nghost = number of ghost cells for each array
int Nghost = 1;
// Ncomp = number of components for each array
int Ncomp = 1;
// time = starting time in the simulation
Real time = 0.0;
// we allocate two phi multifabs; one will store the old state, the other the new
// we swap the indices each time step to avoid copies of new into old
PArray<MultiFab> phi(2, PArrayManage);
phi.set(0, new MultiFab(ba, Ncomp, Nghost));
//.........这里部分代码省略.........