Athena++/Atmosphere
Planetary Atmosphere Simulator
mesh.hpp
Go to the documentation of this file.
1 #ifndef MESH_MESH_HPP_
2 #define MESH_MESH_HPP_
3 //========================================================================================
4 // Athena++ astrophysical MHD code
5 // Copyright(C) 2014 James M. Stone <jmstone@princeton.edu> and other code contributors
6 // Licensed under the 3-clause BSD License, see LICENSE file for details
7 //========================================================================================
9 // \brief defines Mesh and MeshBlock classes, and various structs used in them
10 // The Mesh is the overall grid structure, and MeshBlocks are local patches of data
11 // (potentially on different levels) that tile the entire domain.
12 
13 // C headers
14 
15 // C++ headers
16 #include <cstdint> // int64_t
17 #include <functional> // reference_wrapper
18 #include <string>
19 #include <vector>
20 
21 // Athena++ headers
22 #include "../athena.hpp"
23 #include "../athena_arrays.hpp"
24 #include "../bvals/bvals.hpp"
25 #include "../outputs/io_wrapper.hpp"
26 #include "../parameter_input.hpp"
27 #include "../task_list/task_list.hpp"
28 #include "../utils/interp_table.hpp"
29 #include "mesh_refinement.hpp"
30 #include "meshblock_tree.hpp"
31 
32 // Forward declarations
33 class ParameterInput;
34 class Mesh;
35 class MeshRefinement;
36 class MeshBlockTree;
37 class BoundaryValues;
39 class FaceCenteredBoundaryVariable;
40 class TaskList;
41 struct TaskStates;
42 class Coordinates;
43 class Reconstruction;
44 class Hydro;
45 class Field;
46 class PassiveScalars;
47 class Gravity;
48 class MGGravity;
49 class MGGravityDriver;
50 class EquationOfState;
51 class FFTDriver;
52 class FFTGravityDriver;
53 class TurbulenceDriver;
54 class Thermodynamics;
55 class Chemistry;
56 class Radiation;
57 class Physics;
58 class Diagnostics;
59 class Debugger;
60 class Particles;
61 class Inversion;
62 class Communicator;
63 
64 FluidFormulation GetFluidFormulation(const std::string& input_string);
65 
66 //----------------------------------------------------------------------------------------
68 // \brief data/functions associated with a single block
69 
70 class MeshBlock {
71  friend class RestartOutput;
72  friend class BoundaryValues;
75  friend class Mesh;
76  friend class Hydro;
77  friend class TaskList;
78 #ifdef HDF5OUTPUT
79  friend class ATHDF5Output;
80 #endif
81 
82  public:
83  MeshBlock(int igid, int ilid, LogicalLocation iloc, RegionSize input_size,
84  BoundaryFlag *input_bcs, Mesh *pm, ParameterInput *pin, int igflag,
85  bool ref_flag = false);
86  MeshBlock(int igid, int ilid, Mesh *pm, ParameterInput *pin, LogicalLocation iloc,
87  RegionSize input_block, BoundaryFlag *input_bcs, double icost,
88  char *mbdata, int igflag);
89  ~MeshBlock();
90 
91  // data
92  Mesh *pmy_mesh; // ptr to Mesh containing this MeshBlock
95  // for convenience: "max" # of real+ghost cells along each dir for allocating "standard"
96  // sized MeshBlock arrays, depending on ndim (i.e. ncells2=nx2+2*NGHOST if nx2>1)
98  // on 1x coarser level MeshBlock (i.e. ncc2=nx2/2 + 2*NGHOST, if nx2>1)
99  int ncc1, ncc2, ncc3;
100  int is, ie, js, je, ks, ke;
101  int gid, lid;
102  int cis, cie, cjs, cje, cks, cke, cnghost;
103  int gflag;
104  // At every cycle n, hydro and field registers (u, b) are advanced from t^n -> t^{n+1},
105  // the time-integration scheme may partially substep several storage register pairs
106  // (u,b), (u1,b1), (u2, b2), ..., (um, bm) through the dt interval. Track their time
107  // abscissae at the end of each stage (1<=l<=nstage) as (dt_m^l) relative to t^n
108  Real stage_abscissae[MAX_NSTAGE+1][MAX_NREGISTER];
109 
110  // user output variables for analysis
113  std::string *user_out_var_names_;
115  std::string *user_out_var_units_;
116 
117  // user MeshBlock data that can be stored in restart files
120 
121  // mesh-related objects
125  MeshRefinement *pmr;
126 
127  // physics-related objects (possibly containing their derived bvals classes)
129  Field *pfield;
130  Gravity *pgrav;
131  MGGravity* pmg;
134 
136  Chemistry *pchem;
138  Physics *pphy;
140  Debugger *pdebug;
141  Particles *ppart;
142  Inversion *pfit;
143  Communicator *pcomm;
144 
146 
147  // functions
148  std::size_t GetBlockSizeInBytes();
151  void SearchAndSetNeighbors(MeshBlockTree &tree, int *ranklist, int *nslist);
152  void WeightedAve(AthenaArray<Real> &u_out, AthenaArray<Real> &u_in1,
153  AthenaArray<Real> &u_in2, const Real wght[3]);
154  void WeightedAve(FaceField &b_out, FaceField &b_in1, FaceField &b_in2,
155  const Real wght[3]);
157  NeighborBlock &bblock, NeighborBlock &tblock);
158 
159  // inform MeshBlock which arrays contained in member Hydro, Field, Particles,
160  // ... etc. classes are the "primary" representations of a quantity. when registered,
161  // that data are used for (1) load balancing (2) (future) dumping to restart file
163  void RegisterMeshBlockData(FaceField &pvar_fc);
164 
165  // defined in either the prob file or default_pgen.cpp in ../pgen/
166  void UserWorkBeforeOutput(ParameterInput *pin); // called in Mesh fn (friend class)
167  void UserWorkInLoop(); // called in TimeIntegratorTaskList
168 
169  private:
170  // data
173  // TODO(felker): make global TaskList a member of MeshBlock, store TaskStates in list
174  // shared by main integrator + FFT gravity task lists. Multigrid has separate TaskStates
177  std::vector<std::reference_wrapper<AthenaArray<Real>>> vars_cc_;
178  std::vector<std::reference_wrapper<FaceField>> vars_fc_;
179 
180  // functions
183  void AllocateUserOutputVariables(int n);
184  void SetUserOutputVariableName(int n, const char *name,
185  const char *long_name = "", const char *units = "");
186  void SetCostForLoadBalancing(double cost);
187 
188  // defined in either the prob file or default_pgen.cpp in ../pgen/
191 
192  // functions and variables for automatic load balancing based on timing
193  double cost_, lb_time_;
194  void ResetTimeMeasurement();
195  void StartTimeMeasurement();
196  void StopTimeMeasurement();
197 };
198 
199 //----------------------------------------------------------------------------------------
201 // \brief data/functions associated with the overall mesh
202 
203 class Mesh {
204  friend class RestartOutput;
205  friend class HistoryOutput;
206  friend class MeshBlock;
207  friend class MeshBlockTree;
208  friend class BoundaryBase;
209  friend class BoundaryValues;
212  friend class MGBoundaryValues;
213  friend class Coordinates;
214  friend class MeshRefinement;
215  friend class HydroSourceTerms;
216  friend class Hydro;
217  friend class FFTDriver;
218  friend class FFTGravityDriver;
219  friend class TurbulenceDriver;
220  friend class MultigridDriver;
221  friend class MGGravityDriver;
222  friend class Gravity;
223  friend class HydroDiffusion;
224  friend class FieldDiffusion;
225 #ifdef HDF5OUTPUT
226  friend class ATHDF5Output;
227 #endif
228 
229  public:
230  // 2x function overloads of ctor: normal and restarted simulation
231  explicit Mesh(ParameterInput *pin, int test_flag=0);
232  Mesh(ParameterInput *pin, IOWrapper &resfile, int test_flag=0);
233  ~Mesh();
234 
235  // accessors
237  int GetNumMeshThreads() const {return num_mesh_threads_;}
238  std::int64_t GetTotalCells() {return static_cast<std::int64_t> (nbtotal)*
240 
241  // data
243  BoundaryFlag mesh_bcs[6];
244  const bool f2, f3; // flags indicating (at least) 2D or 3D Mesh
245  const int ndim; // number of dimensions
246  const bool adaptive, multilevel;
252 
254  int gflag;
255  int turb_flag; // turbulence flag
256  EosTable *peos_table;
257 
258  // ptr to first MeshBlock (node) in linked list of blocks belonging to this MPI rank:
260 
264 
267 
268  // functions
269  void Initialize(int res_flag, ParameterInput *pin);
271  BoundaryFlag *block_bcs);
272  void NewTimeStep();
273  void OutputCycleDiagnostics();
275  int CreateAMRMPITag(int lid, int ox1, int ox2, int ox3);
276  MeshBlock* FindMeshBlock(int tgid);
278 
279  // function for distributing unique "phys" bitfield IDs to BoundaryVariable objects and
280  // other categories of MPI communication for generating unique MPI_TAGs
281  int ReserveTagPhysIDs(int num_phys);
282 
283  // defined in either the prob file or default_pgen.cpp in ../pgen/
284  void UserWorkAfterLoop(ParameterInput *pin); // called in main loop
285  void UserWorkInLoop(); // called in main after each cycle
286 
287  private:
288  // data
289  int next_phys_id_; // next unused value for encoding final component of MPI tag bitfield
293  double *costlist;
294  // 8x arrays used exclusively for AMR (not SMR):
295  int *nref, *nderef;
296  int *rdisp, *ddisp;
297  int *bnref, *bnderef;
298  int *brdisp, *bddisp;
299  // the last 4x should be std::size_t, but are limited to int by MPI
300 
303  // number of MeshBlocks in the x1, x2, x3 directions of the root grid:
304  // (unlike LogicalLocation.lxi, nrbxi don't grow w/ AMR # of levels, so keep 32-bit int)
306  // TODO(felker) find unnecessary static_cast<> ops. from old std::int64_t type in 2018:
307  //std::int64_t nrbx1, nrbx2, nrbx3;
308 
309  // flags are false if using non-uniform or user meshgen function
312 
316 
317  // global constants
319 
320  // variables for load balancing control
324 
325  // functions
337 
338  void AllocateRealUserMeshDataField(int n);
339  void AllocateIntUserMeshDataField(int n);
340  void OutputMeshStructure(int dim);
341  void CalculateLoadBalance(double *clist, int *rlist, int *slist, int *nlist, int nb);
343 
344  void CorrectMidpointInitialCondition(std::vector<MeshBlock*> &pmb_array, int nmb);
346 
347  // Mesh::LoadBalancingAndAdaptiveMeshRefinement() helper functions:
349  void UpdateMeshBlockTree(int &nnew, int &ndel);
352 
353  // Mesh::RedistributeAndRefineMeshBlocks() helper functions:
354  // step 6: send
355  void PrepareSendSameLevel(MeshBlock* pb, Real *sendbuf);
358  // step 7: create new MeshBlock list (same MPI rank but diff level: create new block)
360  LogicalLocation &loc);
362  LogicalLocation &newloc);
363  // step 8: receive
364  void FinishRecvSameLevel(MeshBlock *pb, Real *recvbuf);
367 
368  // defined in either the prob file or default_pgen.cpp in ../pgen/
370 
371  // often used (not defined) in prob file in ../pgen/
372  void EnrollUserBoundaryFunction(BoundaryFace face, BValFunc my_func);
373  void EnrollUserMGGravityBoundaryFunction(BoundaryFace dir, MGBoundaryFunc my_bc);
374  // DEPRECATED(felker): provide trivial overload for old-style BoundaryFace enum argument
375  void EnrollUserBoundaryFunction(int face, BValFunc my_func);
377 
382  void AllocateUserHistoryOutput(int n);
383  void EnrollUserHistoryOutput(int i, HistoryOutputFunc my_func, const char *name,
385  void EnrollUserMetric(MetricFunc my_func);
390  void SetFourPiG(Real fpg) { four_pi_G_=fpg; }
391  void SetGravityThreshold(Real eps) { grav_eps_=eps; }
393 };
394 
395 
396 //----------------------------------------------------------------------------------------
397 // \!fn Real ComputeMeshGeneratorX(std::int64_t index, std::int64_t nrange,
398 // bool sym_interval)
399 // \brief wrapper fn to compute Real x logical location for either [0., 1.] or [-0.5, 0.5]
400 // real cell ranges for MeshGenerator_[] functions (default/user vs. uniform)
401 
402 inline Real ComputeMeshGeneratorX(std::int64_t index, std::int64_t nrange,
403  bool sym_interval) {
404  // index is typically 0, ... nrange for non-ghost boundaries
405  if (!sym_interval) {
406  // to map to fractional logical position [0.0, 1.0], simply divide by # of faces
407  return static_cast<Real>(index)/static_cast<Real>(nrange);
408  } else {
409  // to map to a [-0.5, 0.5] range, rescale int indices around 0 before FP conversion
410  // if nrange is even, there is an index at center x=0.0; map it to (int) 0
411  // if nrange is odd, the center x=0.0 is between two indices; map them to -1, 1
412  std::int64_t noffset = index - (nrange)/2;
413  std::int64_t noffset_ceil = index - (nrange+1)/2; // = noffset if nrange is even
414  //std::cout << "noffset, noffset_ceil = " << noffset << ", " << noffset_ceil << "\n";
415  // average the (possibly) biased integer indexing
416  return static_cast<Real>(noffset + noffset_ceil)/(2.0*nrange);
417  }
418 }
419 
420 //----------------------------------------------------------------------------------------
421 // \!fn Real DefaultMeshGeneratorX1(Real x, RegionSize rs)
422 // \brief x1 mesh generator function, x is the logical location; x=i/nx1, real in [0., 1.]
423 
425  Real lw, rw;
426  if (rs.x1rat==1.0) {
427  rw=x, lw=1.0-x;
428  } else {
429  Real ratn=std::pow(rs.x1rat,rs.nx1);
430  Real rnx=std::pow(rs.x1rat,x*rs.nx1);
431  lw=(rnx-ratn)/(1.0-ratn);
432  rw=1.0-lw;
433  }
434  // linear interp, equally weighted from left (x(xmin)=0.0) and right (x(xmax)=1.0)
435  return rs.x1min*lw+rs.x1max*rw;
436 }
437 
438 //----------------------------------------------------------------------------------------
439 // \!fn Real DefaultMeshGeneratorX2(Real x, RegionSize rs)
440 // \brief x2 mesh generator function, x is the logical location; x=j/nx2, real in [0., 1.]
441 
443  Real lw, rw;
444  if (rs.x2rat==1.0) {
445  rw=x, lw=1.0-x;
446  } else {
447  Real ratn=std::pow(rs.x2rat,rs.nx2);
448  Real rnx=std::pow(rs.x2rat,x*rs.nx2);
449  lw=(rnx-ratn)/(1.0-ratn);
450  rw=1.0-lw;
451  }
452  return rs.x2min*lw+rs.x2max*rw;
453 }
454 
455 //----------------------------------------------------------------------------------------
456 // \!fn Real DefaultMeshGeneratorX3(Real x, RegionSize rs)
457 // \brief x3 mesh generator function, x is the logical location; x=k/nx3, real in [0., 1.]
458 
460  Real lw, rw;
461  if (rs.x3rat==1.0) {
462  rw=x, lw=1.0-x;
463  } else {
464  Real ratn=std::pow(rs.x3rat,rs.nx3);
465  Real rnx=std::pow(rs.x3rat,x*rs.nx3);
466  lw=(rnx-ratn)/(1.0-ratn);
467  rw=1.0-lw;
468  }
469  return rs.x3min*lw+rs.x3max*rw;
470 }
471 
472 //----------------------------------------------------------------------------------------
473 // \!fn Real UniformMeshGeneratorX1(Real x, RegionSize rs)
474 // \brief x1 mesh generator function, x is the logical location; real cells in [-0.5, 0.5]
475 
477  // linear interp, equally weighted from left (x(xmin)=-0.5) and right (x(xmax)=0.5)
478  return static_cast<Real>(0.5)*(rs.x1min+rs.x1max) + (x*rs.x1max - x*rs.x1min);
479 }
480 
481 //----------------------------------------------------------------------------------------
482 // \!fn Real UniformMeshGeneratorX2(Real x, RegionSize rs)
483 // \brief x2 mesh generator function, x is the logical location; real cells in [-0.5, 0.5]
484 
486  return static_cast<Real>(0.5)*(rs.x2min+rs.x2max) + (x*rs.x2max - x*rs.x2min);
487 }
488 
489 //----------------------------------------------------------------------------------------
490 // \!fn Real UniformMeshGeneratorX3(Real x, RegionSize rs)
491 // \brief x3 mesh generator function, x is the logical location; real cells in [-0.5, 0.5]
492 
494  return static_cast<Real>(0.5)*(rs.x3min+rs.x3max) + (x*rs.x3max - x*rs.x3min);
495 }
496 
497 #endif // MESH_MESH_HPP_
void(*)(FieldDiffusion *pfdif, MeshBlock *pmb, const AthenaArray< Real > &w, const AthenaArray< Real > &bmag, int is, int ie, int js, int je, int ks, int ke) FieldDiffusionCoeffFunc
Definition: athena.hpp:204
UserHistoryOperation
Definition: athena.hpp:167
void(*)(AthenaArray< Real > &dst, Real time, int nvar, int is, int ie, int js, int je, int ks, int ke, int ngh, Real x0, Real y0, Real z0, Real dx, Real dy, Real dz) MGBoundaryFunc
Definition: athena.hpp:191
double Real
Definition: athena.hpp:29
Real(*)(Real x, RegionSize rs) MeshGenFunc
Definition: athena.hpp:178
CoordinateDirection
Definition: athena.hpp:155
void(*)(Real x1, Real x2, Real x3, ParameterInput *pin, AthenaArray< Real > &g, AthenaArray< Real > &g_inv, AthenaArray< Real > &dg_dx1, AthenaArray< Real > &dg_dx2, AthenaArray< Real > &dg_dx3) MetricFunc
Definition: athena.hpp:187
void(*)(HydroDiffusion *phdif, MeshBlock *pmb, const AthenaArray< Real > &w, const AthenaArray< Real > &bc, int is, int ie, int js, int je, int ks, int ke) ViscosityCoeffFunc
Definition: athena.hpp:195
FluidFormulation
Definition: athena.hpp:166
int(*)(MeshBlock *pmb) AMRFlagFunc
Definition: athena.hpp:177
Real(*)(MeshBlock *pmb) TimeStepFunc
Definition: athena.hpp:182
void(*)(MeshBlock *pmb, Coordinates *pco, AthenaArray< Real > &prim, FaceField &b, Real time, Real dt, int is, int ie, int js, int je, int ks, int ke, int ngh) BValFunc
Definition: athena.hpp:176
void(*)(MeshBlock *pmb, const Real time, const Real dt, const AthenaArray< Real > &prim, const AthenaArray< Real > &bcc, AthenaArray< Real > &cons) SrcTermFunc
Definition: athena.hpp:181
Real(*)(MeshBlock *pmb, int iout) HistoryOutputFunc
Definition: athena.hpp:183
void(*)(HydroDiffusion *phdif, MeshBlock *pmb, const AthenaArray< Real > &w, const AthenaArray< Real > &bc, int is, int ie, int js, int je, int ks, int ke) ConductionCoeffFunc
Definition: athena.hpp:199
Definition: hydro.hpp:34
MeshRefinement * pmr
Definition: mesh.hpp:125
void AllocateUserOutputVariables(int n)
Definition: meshblock.cpp:504
std::string * user_out_var_units_
Definition: mesh.hpp:115
Reconstruction * precon
Definition: mesh.hpp:124
double cost_
Definition: mesh.hpp:193
Physics * pphy
Definition: mesh.hpp:138
void StopTimeMeasurement()
Definition: meshblock.cpp:617
BoundaryValues * pbval
Definition: mesh.hpp:123
Debugger * pdebug
Definition: mesh.hpp:140
int nint_user_meshblock_data_
Definition: mesh.hpp:176
Gravity * pgrav
Definition: mesh.hpp:130
int cie
Definition: mesh.hpp:102
int ncc2
Definition: mesh.hpp:99
void UserWorkBeforeOutput(ParameterInput *pin)
friend class BoundaryValues
Definition: mesh.hpp:72
MeshBlock * prev
Definition: mesh.hpp:145
Communicator * pcomm
Definition: mesh.hpp:143
Inversion * pfit
Definition: mesh.hpp:142
void ProblemGenerator(ParameterInput *pin)
void RegisterMeshBlockData(AthenaArray< Real > &pvar_cc)
Definition: meshblock.cpp:629
Real new_block_dt_
Definition: mesh.hpp:171
RegionSize block_size
Definition: mesh.hpp:94
Hydro * phydro
Definition: mesh.hpp:128
AthenaArray< Real > * ruser_meshblock_data
Definition: mesh.hpp:118
EquationOfState * peos
Definition: mesh.hpp:133
int cjs
Definition: mesh.hpp:102
Real stage_abscissae[MAX_NSTAGE+1][MAX_NREGISTER]
Definition: mesh.hpp:108
Mesh * pmy_mesh
Definition: mesh.hpp:92
MGGravity * pmg
Definition: mesh.hpp:131
int ie
Definition: mesh.hpp:100
int cnghost
Definition: mesh.hpp:102
int GetNumberOfMeshBlockCells()
Definition: mesh.hpp:149
void AllocateRealUserMeshBlockDataField(int n)
Definition: meshblock.cpp:471
TaskStates tasks
Definition: mesh.hpp:175
AthenaArray< Real > user_out_var
Definition: mesh.hpp:112
void UserWorkInLoop()
int js
Definition: mesh.hpp:100
Real new_block_dt_hyperbolic_
Definition: mesh.hpp:171
std::vector< std::reference_wrapper< AthenaArray< Real > > > vars_cc_
Definition: mesh.hpp:177
int ncells1
Definition: mesh.hpp:97
Diagnostics * pdiag
Definition: mesh.hpp:139
int je
Definition: mesh.hpp:100
Real new_block_dt_parabolic_
Definition: mesh.hpp:171
void AllocateIntUserMeshBlockDataField(int n)
Definition: meshblock.cpp:487
AthenaArray< int > * iuser_meshblock_data
Definition: mesh.hpp:119
std::string * user_out_var_longnames_
Definition: mesh.hpp:114
int ncc3
Definition: mesh.hpp:99
Particles * ppart
Definition: mesh.hpp:141
int ke
Definition: mesh.hpp:100
int cis
Definition: mesh.hpp:102
PassiveScalars * pscalars
Definition: mesh.hpp:132
int ncells3
Definition: mesh.hpp:97
void FindNeighbors(CoordinateDirection dir, NeighborBlock &bblock, NeighborBlock &tblock)
void StartTimeMeasurement()
Definition: meshblock.cpp:603
void WeightedAve(AthenaArray< Real > &u_out, AthenaArray< Real > &u_in1, AthenaArray< Real > &u_in2, const Real wght[3])
double lb_time_
Definition: mesh.hpp:193
Radiation * prad
Definition: mesh.hpp:137
LogicalLocation loc
Definition: mesh.hpp:93
Real new_block_dt_user_
Definition: mesh.hpp:172
void SearchAndSetNeighbors(MeshBlockTree &tree, int *ranklist, int *nslist)
int ncc1
Definition: mesh.hpp:99
Chemistry * pchem
Definition: mesh.hpp:136
int is
Definition: mesh.hpp:100
int cks
Definition: mesh.hpp:102
int nuser_out_var
Definition: mesh.hpp:111
void ResetTimeMeasurement()
Definition: meshblock.cpp:595
int ks
Definition: mesh.hpp:100
Coordinates * pcoord
Definition: mesh.hpp:122
int gid
Definition: mesh.hpp:101
int cke
Definition: mesh.hpp:102
int lid
Definition: mesh.hpp:101
int cje
Definition: mesh.hpp:102
int nreal_user_meshblock_data_
Definition: mesh.hpp:176
void InitUserMeshBlockData(ParameterInput *pin)
void SetUserOutputVariableName(int n, const char *name, const char *long_name="", const char *units="")
Definition: meshblock.cpp:526
Thermodynamics * pthermo
Definition: mesh.hpp:135
std::vector< std::reference_wrapper< FaceField > > vars_fc_
Definition: mesh.hpp:178
int ncells2
Definition: mesh.hpp:97
std::size_t GetBlockSizeInBytes()
Definition: meshblock.cpp:545
void SetCostForLoadBalancing(double cost)
Definition: meshblock.cpp:584
MeshBlock(int igid, int ilid, LogicalLocation iloc, RegionSize input_size, BoundaryFlag *input_bcs, Mesh *pm, ParameterInput *pin, int igflag, bool ref_flag=false)
Definition: meshblock.cpp:55
friend class FaceCenteredBoundaryVariable
Definition: mesh.hpp:74
int gflag
Definition: mesh.hpp:103
MeshBlock * next
Definition: mesh.hpp:145
std::string * user_out_var_names_
Definition: mesh.hpp:113
Field * pfield
Definition: mesh.hpp:129
Definition: mesh.hpp:203
int GetNumMeshBlocksThisRank(int my_rank)
Definition: mesh.hpp:236
int * rdisp
Definition: mesh.hpp:296
void EnrollFieldDiffusivity(FieldDiffusionCoeffFunc my_func)
Definition: mesh.cpp:1274
void PrepareSendFineToCoarseAMR(MeshBlock *pb, Real *sendbuf)
void OutputCycleDiagnostics()
Definition: mesh.cpp:1855
Real grav_mean_rho_
Definition: mesh.hpp:318
Real muj
Definition: mesh.hpp:250
Real nuj
Definition: mesh.hpp:250
void SetGravityThreshold(Real eps)
Definition: mesh.hpp:391
friend class FieldDiffusion
Definition: mesh.hpp:224
int * nslist
Definition: mesh.hpp:292
bool lb_flag_
Definition: mesh.hpp:321
int nrbx1
Definition: mesh.hpp:305
int nlim
Definition: mesh.hpp:249
int nint_user_mesh_data_
Definition: mesh.hpp:311
friend class BoundaryValues
Definition: mesh.hpp:209
friend class HydroDiffusion
Definition: mesh.hpp:223
int * nref
Definition: mesh.hpp:295
ConductionCoeffFunc ConductionCoeff_
Definition: mesh.hpp:334
void InitUserMeshData(ParameterInput *pin)
double lb_tolerance_
Definition: mesh.hpp:322
FFTGravityDriver * pfgrd
Definition: mesh.hpp:262
Real dt_parabolic
Definition: mesh.hpp:248
int nreal_user_mesh_data_
Definition: mesh.hpp:311
Real dt
Definition: mesh.hpp:248
int lb_interval_
Definition: mesh.hpp:323
const int ndim
Definition: mesh.hpp:245
Real muj_tilde
Definition: mesh.hpp:250
UserHistoryOperation * user_history_ops_
Definition: mesh.hpp:315
int CreateAMRMPITag(int lid, int ox1, int ox2, int ox3)
BoundaryFlag mesh_bcs[6]
Definition: mesh.hpp:243
void EnrollUserMGGravityBoundaryFunction(BoundaryFace dir, MGBoundaryFunc my_bc)
Definition: mesh.cpp:1128
int num_mesh_threads_
Definition: mesh.hpp:291
void EnrollUserTimeStepFunction(TimeStepFunc my_func)
Definition: mesh.cpp:1207
void CalculateLoadBalance(double *clist, int *rlist, int *slist, int *nlist, int nb)
const bool multilevel
Definition: mesh.hpp:246
int * bnderef
Definition: mesh.hpp:297
Real start_time
Definition: mesh.hpp:248
Real dt_user
Definition: mesh.hpp:248
FieldDiffusionCoeffFunc FieldDiffusivity_
Definition: mesh.hpp:335
void UpdateMeshBlockTree(int &nnew, int &ndel)
void EnrollUserBoundaryFunction(BoundaryFace face, BValFunc my_func)
Definition: mesh.cpp:1106
void PrepareSendCoarseToFineAMR(MeshBlock *pb, Real *sendbuf, LogicalLocation &lloc)
int nrbx2
Definition: mesh.hpp:305
int current_level
Definition: mesh.hpp:290
friend class FFTDriver
Definition: mesh.hpp:217
friend class MeshBlockTree
Definition: mesh.hpp:207
int next_phys_id_
Definition: mesh.hpp:289
int * ranklist
Definition: mesh.hpp:292
int nbdel
Definition: mesh.hpp:251
int ncycle_out
Definition: mesh.hpp:249
const bool adaptive
Definition: mesh.hpp:246
int * ddisp
Definition: mesh.hpp:296
void EnrollUserMetric(MetricFunc my_func)
Definition: mesh.cpp:1247
int nbtotal
Definition: mesh.hpp:251
~Mesh()
Definition: mesh.cpp:876
int * nblist
Definition: mesh.hpp:292
Mesh(ParameterInput *pin, int test_flag=0)
Definition: mesh.cpp:63
Real tlim
Definition: mesh.hpp:248
SrcTermFunc UserSourceTerm_
Definition: mesh.hpp:329
bool lb_manual_
Definition: mesh.hpp:321
AMRFlagFunc AMRFlag_
Definition: mesh.hpp:328
int max_level
Definition: mesh.hpp:290
int * nderef
Definition: mesh.hpp:295
void NewTimeStep()
Definition: mesh.cpp:1065
void FillSameRankCoarseToFineAMR(MeshBlock *pob, MeshBlock *pmb, LogicalLocation &newloc)
TurbulenceDriver * ptrbd
Definition: mesh.hpp:261
int ReserveTagPhysIDs(int num_phys)
Definition: mesh.cpp:1799
void ResetLoadBalanceVariables()
Real grav_eps_
Definition: mesh.hpp:318
void FinishRecvCoarseToFineAMR(MeshBlock *pb, Real *recvbuf)
void UserWorkInLoop()
int * brdisp
Definition: mesh.hpp:298
const FluidFormulation fluid_setup
Definition: mesh.hpp:247
void FillSameRankFineToCoarseAMR(MeshBlock *pob, MeshBlock *pmb, LogicalLocation &loc)
void EnrollUserExplicitSourceFunction(SrcTermFunc my_func)
Definition: mesh.cpp:1198
bool lb_automatic_
Definition: mesh.hpp:321
MeshBlockTree tree
Definition: mesh.hpp:302
void Initialize(int res_flag, ParameterInput *pin)
Definition: mesh.cpp:1327
friend class MeshRefinement
Definition: mesh.hpp:214
HistoryOutputFunc * user_history_func_
Definition: mesh.hpp:331
void AllocateIntUserMeshDataField(int n)
Definition: mesh.cpp:1298
int step_since_lb
Definition: mesh.hpp:253
const bool f3
Definition: mesh.hpp:244
friend class Gravity
Definition: mesh.hpp:222
int dt_diagnostics
Definition: mesh.hpp:249
friend class MultigridDriver
Definition: mesh.hpp:220
void FinishRecvFineToCoarseAMR(MeshBlock *pb, Real *recvbuf, LogicalLocation &lloc)
MGGravityDriver * pmgrd
Definition: mesh.hpp:263
void EnrollUserHistoryOutput(int i, HistoryOutputFunc my_func, const char *name, UserHistoryOperation op=UserHistoryOperation::sum)
Definition: mesh.cpp:1229
Real time
Definition: mesh.hpp:248
void EnrollUserRefinementCondition(AMRFlagFunc amrflag)
Definition: mesh.cpp:1154
bool GatherCostListAndCheckBalance()
int * bnref
Definition: mesh.hpp:297
int nrbx3
Definition: mesh.hpp:305
MGBoundaryFunc MGGravityBoundaryFunction_[6]
Definition: mesh.hpp:336
BValFunc BoundaryFunction_[6]
Definition: mesh.hpp:327
Real cfl_number
Definition: mesh.hpp:248
void FinishRecvSameLevel(MeshBlock *pb, Real *recvbuf)
Real four_pi_G_
Definition: mesh.hpp:318
friend class BoundaryBase
Definition: mesh.hpp:208
void UpdateCostList()
int root_level
Definition: mesh.hpp:290
EosTable * peos_table
Definition: mesh.hpp:256
void SetBlockSizeAndBoundaries(LogicalLocation loc, RegionSize &block_size, BoundaryFlag *block_bcs)
Definition: mesh.cpp:1592
void ReserveMeshBlockPhysIDs()
Definition: mesh.cpp:1814
void PrepareSendSameLevel(MeshBlock *pb, Real *sendbuf)
const bool f2
Definition: mesh.hpp:244
double * costlist
Definition: mesh.hpp:293
void LoadBalancingAndAdaptiveMeshRefinement(ParameterInput *pin)
void EnrollUserMeshGenerator(CoordinateDirection dir, MeshGenFunc my_mg)
Definition: mesh.cpp:1164
void OutputMeshStructure(int dim)
Definition: mesh.cpp:915
friend class TurbulenceDriver
Definition: mesh.hpp:219
void SetMeanDensity(Real d0)
Definition: mesh.hpp:392
int nuser_history_output_
Definition: mesh.hpp:313
std::string * user_history_output_names_
Definition: mesh.hpp:314
void EnrollViscosityCoefficient(ViscosityCoeffFunc my_func)
Definition: mesh.cpp:1256
void AllocateUserHistoryOutput(int n)
Definition: mesh.cpp:1216
friend class MGGravityDriver
Definition: mesh.hpp:221
MeshBlock * pblock
Definition: mesh.hpp:259
int nbnew
Definition: mesh.hpp:251
int gflag
Definition: mesh.hpp:254
MetricFunc UserMetric_
Definition: mesh.hpp:332
friend class MGBoundaryValues
Definition: mesh.hpp:212
Real dt_hyperbolic
Definition: mesh.hpp:248
friend class FFTGravityDriver
Definition: mesh.hpp:218
void ApplyUserWorkBeforeOutput(ParameterInput *pin)
Definition: mesh.cpp:1315
MeshBlock * FindMeshBlock(int tgid)
Definition: mesh.cpp:1577
RegionSize mesh_size
Definition: mesh.hpp:242
void SetFourPiG(Real fpg)
Definition: mesh.hpp:390
std::int64_t GetTotalCells()
Definition: mesh.hpp:238
void SetGravitationalConstant(Real g)
Definition: mesh.hpp:389
int ncycle
Definition: mesh.hpp:249
void RedistributeAndRefineMeshBlocks(ParameterInput *pin, int ntot)
AthenaArray< int > * iuser_mesh_data
Definition: mesh.hpp:266
int turb_flag
Definition: mesh.hpp:255
int GetNumMeshThreads() const
Definition: mesh.hpp:237
friend class FaceCenteredBoundaryVariable
Definition: mesh.hpp:211
bool use_uniform_meshgen_fn_[3]
Definition: mesh.hpp:310
void EnrollConductionCoefficient(ConductionCoeffFunc my_func)
Definition: mesh.cpp:1265
void UserWorkAfterLoop(ParameterInput *pin)
AthenaArray< Real > * ruser_mesh_data
Definition: mesh.hpp:265
LogicalLocation * loclist
Definition: mesh.hpp:301
int * bddisp
Definition: mesh.hpp:298
TimeStepFunc UserTimeStep_
Definition: mesh.hpp:330
ViscosityCoeffFunc ViscosityCoeff_
Definition: mesh.hpp:333
MeshGenFunc MeshGenerator_[3]
Definition: mesh.hpp:326
void CorrectMidpointInitialCondition(std::vector< MeshBlock * > &pmb_array, int nmb)
Definition: mesh.cpp:1678
void AllocateRealUserMeshDataField(int n)
Definition: mesh.cpp:1282
Real DefaultMeshGeneratorX3(Real x, RegionSize rs)
Definition: mesh.hpp:459
Real DefaultMeshGeneratorX2(Real x, RegionSize rs)
Definition: mesh.hpp:442
Real UniformMeshGeneratorX1(Real x, RegionSize rs)
Definition: mesh.hpp:476
FluidFormulation GetFluidFormulation(const std::string &input_string)
Definition: mesh.cpp:1839
Real UniformMeshGeneratorX2(Real x, RegionSize rs)
Definition: mesh.hpp:485
Real DefaultMeshGeneratorX1(Real x, RegionSize rs)
Definition: mesh.hpp:424
Real UniformMeshGeneratorX3(Real x, RegionSize rs)
Definition: mesh.hpp:493
Real ComputeMeshGeneratorX(std::int64_t index, std::int64_t nrange, bool sym_interval)
Definition: mesh.hpp:402
int my_rank
Definition: globals.cpp:23
double wght[2]
Real x3rat
Definition: athena.hpp:86
int nx3
Definition: athena.hpp:88
Real x1max
Definition: athena.hpp:85
Real x1min
Definition: athena.hpp:84
Real x2rat
Definition: athena.hpp:86
Real x3min
Definition: athena.hpp:84
Real x1rat
Definition: athena.hpp:86
int nx2
Definition: athena.hpp:88
Real x3max
Definition: athena.hpp:85
Real x2min
Definition: athena.hpp:84
int nx1
Definition: athena.hpp:88
Real x2max
Definition: athena.hpp:85