15 #include "PatchPluto.H"
19 PatchPluto::PatchPluto()
22 m_isBoundarySet =
false;
23 m_isRiemannSet =
false;
24 m_isCurrentTimeSet =
false;
25 m_isCurrentBoxSet =
false;
28 PatchPluto::~PatchPluto()
33 void PatchPluto::define(ProblemDomain& a_domain,
36 const int& a_numGhost)
43 m_numGhost = a_numGhost;
50 PatchPluto* PatchPluto::new_patchPluto()
const
54 static_cast<PatchPluto*
>(
new PatchPluto());
57 retval->setBoundary(left_bound_side,
59 retval->setRiemann(rsolver);
66 void PatchPluto::setCurrentTime(
const Real& a_currentTime)
68 m_currentTime = a_currentTime;
69 m_isCurrentTimeSet =
true;
73 void PatchPluto::setCurrentBox(
const Box& a_currentBox)
75 m_currentBox = a_currentBox;
76 m_isCurrentBoxSet =
true;
80 void PatchPluto::setBoundary(
const int *leftbound,
81 const int *rightbound)
84 for (
int i = 0;
i < 3;
i++)
86 left_bound_side[
i] = leftbound[
i];
87 right_bound_side[
i] = rightbound[
i];
90 m_isBoundarySet =
true;
99 m_isRiemannSet =
true;
105 void PatchPluto::setGrid(
const Box& a_box,
struct GRID *grid, FArrayBox& a_dV)
109 double stretch,
scrh, scrh1, scrh2, scrh3, dxmin[3];
110 double ***
dV[CHOMBO_NDV];
113 for (
int dir = 0; dir < SpaceDim; ++dir){
114 grid[dir].
level = m_level;
115 grid[dir].
np_tot = a_box.size()[dir]+2*m_numGhost;
116 grid[dir].
np_int = a_box.size()[dir];
117 grid[dir].
np_tot_glob = m_domain.domainBox().size()[dir]+2*m_numGhost;
118 grid[dir].
np_int_glob = m_domain.domainBox().size()[dir];
119 grid[dir].
nghost = m_numGhost;
120 grid[dir].
beg = a_box.loVect()[dir]+m_numGhost;
121 grid[dir].
end = a_box.hiVect()[dir]+m_numGhost;
122 grid[dir].
gbeg = m_domain.domainBox().loVect()[dir]+m_numGhost;
123 grid[dir].
gend = m_domain.domainBox().hiVect()[dir]+m_numGhost;
124 grid[dir].
lbeg = m_numGhost;
125 grid[dir].
lend = grid[dir].
np_int+m_numGhost-1;
135 if (tmp != a_box) grid[dir].
lbound = 1;
141 if (tmp != a_box) grid[dir].
rbound = 1;
145 for (
int dir = 0; dir < 3; ++dir){
147 if (dir >= SpaceDim) {
163 if (dir ==
JDIR) stretch = g_x2stretch;
164 if (dir ==
KDIR) stretch = g_x3stretch;
166 for (i = 0; i <
np_tot; i++){
167 #if (CHOMBO_LOGR == YES)
175 G->
xl[
i] = Real(i+grid[dir].
beg-2*grid[dir].
nghost)*m_dx*stretch;
177 G->
x[
i] = G->
xl[
i]+0.5*m_dx*stretch;
178 G->
xr[
i] = G->
xl[
i]+m_dx*stretch;
179 G->
dx[
i] = m_dx*stretch;
180 #if (CHOMBO_LOGR == YES)
186 CH_assert(m_isBoundarySet);
197 #if GEOMETRY != CARTESIAN
204 #if GEOMETRY == CYLINDRICAL
205 for (k = 0; k <
NX3_TOT; k++) {
206 for (j = 0; j <
NX2_TOT; j++) {
207 for (i = 0; i <
NX1_TOT; i++) {
208 dV[0][
k][
j][
i] = fabs(grid[
IDIR].
x[i]);
210 dV[0][
k][
j][
i] *= g_x2stretch;
213 #if CHOMBO_CONS_AM == YES
219 #if GEOMETRY == SPHERICAL
220 for (k = 0; k <
NX3_TOT; k++) {
221 for (j = 0; j <
NX2_TOT; j++) {
222 for (i = 0; i <
NX1_TOT; i++) {
228 dV[0][
k][
j][
i] *= g_x3stretch;
231 #if CHOMBO_CONS_AM == YES
234 dV[1][
k][
j][
i] *= sin(grid[
JDIR].
x[j]);
240 #if GEOMETRY == POLAR
241 for (k = 0; k <
NX3_TOT; k++) {
242 for (j = 0; j <
NX2_TOT; j++) {
243 for (i = 0; i <
NX1_TOT; i++) {
246 dV[0][
k][
j][
i] *= g_x2stretch;
249 dV[0][
k][
j][
i] *= g_x3stretch;
252 #if CHOMBO_CONS_AM == YES
263 #if (GEOMETRY == CARTESIAN) || (GEOMETRY == CYLINDRICAL)
275 for (idim = 0; idim < 3; idim++) dxmin[idim] = 1.e30;
281 #if (TIME_STEPPING == RK2)
286 scrh =
D_EXPAND(1./scrh1, +1./scrh2, +1./scrh3);
293 dxmin[
IDIR] =
MIN (dxmin[IDIR], scrh);
314 void PatchPluto::initialize(LevelData<FArrayBox>& a_U)
317 CH_assert(m_isDefined);
319 DataIterator dit = a_U.boxLayout().dataIterator();
322 for (dit.begin(); dit.ok(); ++dit)
325 FArrayBox& U = a_U[dit()];
334 int PatchPluto::numConserved()
340 Vector<string> PatchPluto::ConsStateNames()
342 Vector<string> retval;
344 char varNameChar[80];
346 for (nv = 0; nv <
NVAR; nv++){
347 if (nv ==
RHO) retval.push_back(
"Density");
348 if (nv ==
MX1) retval.push_back(
"X-momentum");
349 if (nv ==
MX2) retval.push_back(
"Y-momentum");
350 if (nv ==
MX3) retval.push_back(
"Z-momentum");
351 #if PHYSICS == MHD || PHYSICS == RMHD
352 if (nv ==
BX1) retval.push_back(
"X-magnfield");
353 if (nv ==
BX2) retval.push_back(
"Y-magnfield");
354 if (nv ==
BX3) retval.push_back(
"Z-magnfield");
356 #if EOS != ISOTHERMAL
357 if (nv == ENG) retval.push_back(
"energy-density");
362 sprintf(varNameChar,
"rho*tracer%d",nv+1-
TRC);
363 retval.push_back(
string(varNameChar));
367 if (nv == ENTR) retval.push_back(
"rho*entropy");
371 if (nv ==
PSI_GLM) retval.push_back(
"psi_glm");
375 if (nv ==
X_HI) retval.push_back(
"rho*x_hi");
378 #if COOLING == H2_COOL
380 sprintf(varNameChar,
"rho*fX%d",nv-
NFLX);
381 retval.push_back(
string(varNameChar));
387 sprintf(varNameChar,
"rho*fX%d",nv-
NFLX);
388 retval.push_back(
string(varNameChar));
396 Vector<string> PatchPluto::PrimStateNames()
398 Vector<string> retval;
403 for (nv = 0; nv <
NVAR; nv++){
409 for (nv = 0; nv <
NVAR; nv++){
410 retval.push_back(output.
var_name[nv]);
416 int PatchPluto::numFluxes()
423 int PatchPluto::numPrimitives()
431 int PatchPluto::pressureIndex()
433 #if EOS != ISOTHERMAL
442 bool PatchPluto::isDefined()
const
444 return m_isDefined &&
447 m_isCurrentTimeSet &&
double Length_2(int i, int j, int k, Grid *)
int lbound
When different from zero, it specifies the boundary condition to be applied at leftmost grid side whe...
int level
The current refinement level (chombo only).
void MakeGeometry(Grid *)
int end
Global end index for the local array.
void Riemann_Solver(const State_1D *, int, int, double *, Grid *)
int np_int_glob
Total number of points in the global domain (boundaries excluded).
void SetDefaultVarNames(Output *)
int rbound
Same as lbound, but for the right edge of the grid.
long int NX2_TOT
Total number of zones in the X2 direction (boundaries included) for the local processor.
int lend
Local end index for the local array.
int lbeg
Local start index for the local array.
int gend
Global end index for the global array.
int np_tot_glob
Total number of points in the global domain (boundaries included).
void FreeArrayMap(double ***t)
double Length_1(int i, int j, int k, Grid *)
int beg
Global start index for the local array.
int gbeg
Global start index for the global array.
long int NX3_TOT
Total number of zones in the X3 direction (boundaries included) for the local processor.
int nghost
Number of ghost zones.
long int IEND
Upper grid index of the computational domain in the the X1 direction for the local processor...
double dl_min
minimum cell length (e.g.
double g_domBeg[3]
Lower limits of the computational domain.
#define ARRAY_1D(nx, type)
D_EXPAND(tot/[n]=(double) grid[IDIR].np_int_glob;, tot/[n]=(double) grid[JDIR].np_int_glob;, tot/[n]=(double) grid[KDIR].np_int_glob;)
double Length_3(int i, int j, int k, Grid *)
long int KBEG
Lower grid index of the computational domain in the the X3 direction for the local processor...
#define ARRAY_2D(nx, ny, type)
int np_tot
Total number of points in the local domain (boundaries included).
long int KEND
Upper grid index of the computational domain in the the X3 direction for the local processor...
long int JBEG
Lower grid index of the computational domain in the the X2 direction for the local processor...
long int JEND
Upper grid index of the computational domain in the the X2 direction for the local processor...
long int NX1_TOT
Total number of zones in the X1 direction (boundaries included) for the local processor.
char ** var_name
variable names - same for all
long int IBEG
Lower grid index of the computational domain in the the X1 direction for the local processor...
double *** ArrayMap(int nx, int ny, int nz, double *uptr)
int np_int
Total number of points in the local domain (boundaries excluded).