@@ -30,9 +30,9 @@ void OversetOps::initialize(CFDSim& sim)
30
30
31
31
pp.query (" verbose" , m_verbose);
32
32
33
- m_vof_exists = (* m_sim_ptr). repo ().field_exists (" vof" );
33
+ m_vof_exists = m_sim_ptr-> repo ().field_exists (" vof" );
34
34
if (m_vof_exists) {
35
- m_mphase = &(* m_sim_ptr). physics_manager ().get <MultiPhase>();
35
+ m_mphase = &m_sim_ptr-> physics_manager ().get <MultiPhase>();
36
36
37
37
// Check combination of pressure options
38
38
if (m_mphase->perturb_pressure () &&
@@ -51,7 +51,7 @@ void OversetOps::initialize(CFDSim& sim)
51
51
}
52
52
}
53
53
if (m_replace_gradp_postsolve) {
54
- m_gp_copy = &(* m_sim_ptr). repo ().declare_field (" gp_copy" , 3 );
54
+ m_gp_copy = &m_sim_ptr-> repo ().declare_field (" gp_copy" , 3 );
55
55
}
56
56
57
57
parameter_output ();
@@ -60,6 +60,14 @@ void OversetOps::initialize(CFDSim& sim)
60
60
void OversetOps::pre_advance_work ()
61
61
{
62
62
if (!(m_vof_exists && m_use_hydrostatic_gradp)) {
63
+ if (m_mphase != nullptr ) {
64
+ // Avoid modifying pressure upon initialization, assume pressure = 0
65
+ if (m_mphase->perturb_pressure () &&
66
+ m_sim_ptr->time ().current_time () > 0.0 ) {
67
+ // Modify to be consistent with internal source terms
68
+ form_perturb_pressure ();
69
+ }
70
+ }
63
71
// Update pressure gradient using updated overset pressure field
64
72
update_gradp ();
65
73
}
@@ -71,20 +79,15 @@ void OversetOps::pre_advance_work()
71
79
// Use hydrostatic pressure gradient
72
80
set_hydrostatic_gradp ();
73
81
} else {
74
- if (m_mphase->perturb_pressure ()) {
75
- // Modify to be consistent with internal source terms
76
- form_perturb_pressure ();
77
- }
78
82
// Update pressure gradient using sharpened pressure field
79
83
update_gradp ();
80
84
}
81
85
}
82
86
83
87
// If pressure gradient will be replaced, store current pressure gradient
84
88
if (m_replace_gradp_postsolve) {
85
- const auto & gp = (*m_sim_ptr).repo ().get_field (" gp" );
86
- for (int lev = 0 ; lev < (*m_sim_ptr).repo ().num_active_levels ();
87
- ++lev) {
89
+ const auto & gp = m_sim_ptr->repo ().get_field (" gp" );
90
+ for (int lev = 0 ; lev < m_sim_ptr->repo ().num_active_levels (); ++lev) {
88
91
amrex::MultiFab::Copy (
89
92
(*m_gp_copy)(lev), gp (lev), 0 , 0 , gp (lev).nComp (),
90
93
(m_gp_copy)->num_grow ());
@@ -97,30 +100,30 @@ void OversetOps::update_gradp()
97
100
BL_PROFILE (" amr-wind::OversetOps::update_gradp" );
98
101
99
102
// Get relevant fields
100
- auto & grad_p = (* m_sim_ptr). repo ().get_field (" gp" );
101
- auto & pressure = (* m_sim_ptr). repo ().get_field (" p" );
102
- auto & velocity = (* m_sim_ptr). repo ().get_field (" velocity" );
103
+ auto & grad_p = m_sim_ptr-> repo ().get_field (" gp" );
104
+ auto & pressure = m_sim_ptr-> repo ().get_field (" p" );
105
+ auto & velocity = m_sim_ptr-> repo ().get_field (" velocity" );
103
106
104
107
// Set up projection object
105
108
std::unique_ptr<Hydro::NodalProjector> nodal_projector;
106
109
// Boundary conditions from field, periodicity
107
110
auto bclo = nodal_projection::get_projection_bc (
108
111
amrex::Orientation::low, pressure,
109
- (* m_sim_ptr). mesh ().Geom (0 ).isPeriodic ());
112
+ m_sim_ptr-> mesh ().Geom (0 ).isPeriodic ());
110
113
auto bchi = nodal_projection::get_projection_bc (
111
114
amrex::Orientation::high, pressure,
112
- (* m_sim_ptr). mesh ().Geom (0 ).isPeriodic ());
115
+ m_sim_ptr-> mesh ().Geom (0 ).isPeriodic ());
113
116
// Velocity multifab is needed for proper initialization, but only the size
114
117
// matters for the purpose of calculating gradp, the values do not matter
115
- int finest_level = (* m_sim_ptr). mesh ().finestLevel ();
118
+ int finest_level = m_sim_ptr-> mesh ().finestLevel ();
116
119
Vector<MultiFab*> vel;
117
120
for (int lev = 0 ; lev <= finest_level; ++lev) {
118
121
vel.push_back (&(velocity (lev)));
119
122
}
120
123
amr_wind::MLMGOptions options (" nodal_proj" );
121
124
// Create nodal projector with unity scaling factor for simplicity
122
125
nodal_projector = std::make_unique<Hydro::NodalProjector>(
123
- vel, 1.0 , (* m_sim_ptr). mesh ().Geom (0 , finest_level), options.lpinfo ());
126
+ vel, 1.0 , m_sim_ptr-> mesh ().Geom (0 , finest_level), options.lpinfo ());
124
127
// Set MLMG and NodalProjector options
125
128
options (*nodal_projector);
126
129
nodal_projector->setDomainBC (bclo, bchi);
@@ -203,9 +206,9 @@ void OversetOps::parameter_output() const
203
206
204
207
void OversetOps::sharpen_nalu_data ()
205
208
{
206
- const auto & repo = (* m_sim_ptr). repo ();
209
+ const auto & repo = m_sim_ptr-> repo ();
207
210
const auto nlevels = repo.num_active_levels ();
208
- const auto geom = (* m_sim_ptr). mesh ().Geom ();
211
+ const auto geom = m_sim_ptr-> mesh ().Geom ();
209
212
210
213
// Get blanking for cells
211
214
const auto & iblank_cell = repo.get_int_field (" iblank_cell" );
@@ -333,7 +336,7 @@ void OversetOps::sharpen_nalu_data()
333
336
for (int lev = nlevels - 1 ; lev > 0 ; --lev) {
334
337
amrex::average_down_faces (
335
338
GetArrOfConstPtrs (fluxes[lev]), fluxes[lev - 1 ],
336
- repo.mesh ().refRatio (lev), geom[lev - 1 ]);
339
+ repo.mesh ().refRatio (lev - 1 ), geom[lev - 1 ]);
337
340
}
338
341
339
342
// Get pseudo dt (dtau)
@@ -382,7 +385,7 @@ void OversetOps::sharpen_nalu_data()
382
385
}
383
386
384
387
// Fillpatch for pressure to make sure pressure stencil has all points
385
- p.fillpatch ((* m_sim_ptr). time ().current_time ());
388
+ p.fillpatch (m_sim_ptr-> time ().current_time ());
386
389
387
390
// Purely for debugging via visualization, should be removed later
388
391
// Currently set up to overwrite the levelset field (not used as time
@@ -395,19 +398,19 @@ void OversetOps::sharpen_nalu_data()
395
398
396
399
void OversetOps::form_perturb_pressure ()
397
400
{
398
- auto & pressure = (* m_sim_ptr). repo ().get_field (" p" );
399
- const auto & p0 = (* m_sim_ptr). repo ().get_field (" reference_pressure" );
400
- for (int lev = 0 ; lev < (* m_sim_ptr). repo ().num_active_levels (); lev++) {
401
+ auto & pressure = m_sim_ptr-> repo ().get_field (" p" );
402
+ const auto & p0 = m_sim_ptr-> repo ().get_field (" reference_pressure" );
403
+ for (int lev = 0 ; lev < m_sim_ptr-> repo ().num_active_levels (); lev++) {
401
404
amrex::MultiFab::Subtract (
402
405
pressure (lev), p0 (lev), 0 , 0 , 1 , pressure.num_grow ()[0 ]);
403
406
}
404
407
}
405
408
406
409
void OversetOps::set_hydrostatic_gradp ()
407
410
{
408
- const auto & repo = (* m_sim_ptr). repo ();
411
+ const auto & repo = m_sim_ptr-> repo ();
409
412
const auto nlevels = repo.num_active_levels ();
410
- const auto geom = (* m_sim_ptr). mesh ().Geom ();
413
+ const auto geom = m_sim_ptr-> mesh ().Geom ();
411
414
412
415
// Get blanking for cells
413
416
const auto & iblank_cell = repo.get_int_field (" iblank_cell" );
@@ -417,7 +420,7 @@ void OversetOps::set_hydrostatic_gradp()
417
420
auto & rho = repo.get_field (" density" );
418
421
auto & gp = repo.get_field (" gp" );
419
422
if (m_mphase->perturb_pressure ()) {
420
- rho0 = &((* m_sim_ptr). repo ().get_field (" reference_density" ));
423
+ rho0 = &(m_sim_ptr-> repo ().get_field (" reference_density" ));
421
424
} else {
422
425
// Point to existing field, won't be used
423
426
rho0 = ρ
@@ -433,11 +436,11 @@ void OversetOps::set_hydrostatic_gradp()
433
436
434
437
void OversetOps::replace_masked_gradp ()
435
438
{
436
- const auto & repo = (* m_sim_ptr). repo ();
439
+ const auto & repo = m_sim_ptr-> repo ();
437
440
const auto nlevels = repo.num_active_levels ();
438
441
439
442
// Get timestep
440
- const amrex::Real dt = (* m_sim_ptr). time ().delta_t ();
443
+ const amrex::Real dt = m_sim_ptr-> time ().delta_t ();
441
444
442
445
// Get blanking for cells
443
446
const auto & iblank_cell = repo.get_int_field (" iblank_cell" );
0 commit comments