MCPcopy Create free account
hub / github.com/AMReX-Astro/Castro / problem_post_init

Method problem_post_init

Exec/gravity_tests/uniform_cube/Prob.cpp:15–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13using namespace amrex;
14
15void Castro::problem_post_init()
16{
17 BL_ASSERT(level == 0);
18
19 gravity->multilevel_solve_for_new_phi(0, parent->finestLevel());
20
21 const int norm_power = 2;
22
23 ReduceOps<ReduceOpSum, ReduceOpSum> reduce_op;
24 ReduceData<Real, Real> reduce_data(reduce_op);
25 using ReduceTuple = typename decltype(reduce_data)::Type;
26
27 for (int lev = 0; lev <= parent->finestLevel(); lev++)
28 {
29 const auto dx = getLevel(lev).geom.CellSizeArray();
30 const auto problo = getLevel(lev).geom.ProbLoArray();
31
32 const Real time = getLevel(lev).state[State_Type].curTime();
33
34 auto phiGrav = getLevel(lev).derive("phiGrav", time, 0);
35
36 if (lev < parent->finestLevel())
37 {
38 const MultiFab& mask = getLevel(lev+1).build_fine_mask();
39 MultiFab::Multiply(*phiGrav, mask, 0, 0, 1, 0);
40 }
41
42#ifdef _OPENMP
43#pragma omp parallel
44#endif
45 for (MFIter mfi(*phiGrav, TilingIfNotGPU()); mfi.isValid(); ++mfi)
46 {
47 const Box& box = mfi.tilebox();
48
49 auto phi = (*phiGrav)[mfi].array();
50 auto vol = getLevel(lev).Volume()[mfi].array();
51
52 // Compute the norm of the difference between the calculated potential
53 // and the analytical solution.
54
55 reduce_op.eval(box, reduce_data,
56 [=] AMREX_GPU_HOST_DEVICE (int i, int j, int k) -> ReduceTuple
57 {
58 Real radius = 0.5_rt * problem::diameter;
59 Real mass = (4.0_rt / 3.0_rt) * M_PI * radius * radius * radius * problem::density;
60
61 Real xx = problo[0] + dx[0] * (static_cast<Real>(i) + 0.5_rt) - problem::center[0];
62
63#if AMREX_SPACEDIM >= 2
64 Real yy = problo[1] + dx[1] * (static_cast<Real>(j) + 0.5_rt) - problem::center[1];
65#else
66 Real yy = 0.0_rt;
67#endif
68
69#if AMREX_SPACEDIM == 3
70 Real zz = problo[2] + dx[2] * (static_cast<Real>(k) + 0.5_rt) - problem::center[2];
71#else
72 Real zz = 0.0_rt;

Callers

nothing calls this directly

Calls 4

deriveMethod · 0.80
isValidMethod · 0.80
valueMethod · 0.80

Tested by

no test coverage detected