17 const int clearval = TagBox::CLEAR;
18 const int tagval = TagBox::SET;
19 for (
int j=0; j <
ref_tags.size(); ++j)
21 std::unique_ptr<MultiFab> mf;
26 mf = std::make_unique<MultiFab>(grids[levc], dmap[levc], 1, 0);
28 }
else if (
ref_tags[j].Field() ==
"temp") {
29 mf = std::make_unique<MultiFab>(grids[levc], dmap[levc], 1, 0);
31 }
else if (
ref_tags[j].Field() ==
"salt") {
32 mf = std::make_unique<MultiFab>(grids[levc], dmap[levc], 1, 0);
34 }
else if (
ref_tags[j].Field() ==
"x_velocity") {
35 mf = std::make_unique<MultiFab>(grids[levc], dmap[levc], 1, 0);
36 MultiFab::Copy(*mf,*
xvel_new[levc],0,0,1,0);
37 }
else if (
ref_tags[j].Field() ==
"y_velocity") {
38 mf = std::make_unique<MultiFab>(grids[levc], dmap[levc], 1, 0);
39 MultiFab::Copy(*mf,*
yvel_new[levc],0,0,1,0);
40 }
else if (
ref_tags[j].Field() ==
"z_velocity") {
41 mf = std::make_unique<MultiFab>(grids[levc], dmap[levc], 1, 0);
42 MultiFab::Copy(*mf,*
zvel_new[levc],0,0,1,0);
43 }
else if (
ref_tags[j].Field() ==
"vorticity") {
44 mf = std::make_unique<MultiFab>(grids[levc], dmap[levc], 1, 0);
45 MultiFab mf_cc_vel(grids[levc],dmap[levc],3,1);
46 average_face_to_cellcenter(mf_cc_vel,0,
47 Array<const MultiFab*,3>{
xvel_new[levc],
54#pragma omp parallel if (Gpu::notInLaunchRegion())
56 for (MFIter mfi(*mf, TilingIfNotGPU()); mfi.isValid(); ++mfi)
58 const Box& bx = mfi.tilebox();
59 auto& dfab = (*mf)[mfi];
60 auto& sfab = mf_cc_vel[mfi];
61 auto pm =
vec_pm[levc]->const_array(mfi);
62 auto pn =
vec_pn[levc]->const_array(mfi);
63 derived::remora_dervort(bx, dfab, 0, 1, sfab, pm, pn, Geom(levc), time,
nullptr, levc);
66#ifdef REMORA_USE_PARTICLES
76 const auto& particles_namelist( particleData.getNames() );
78 for (ParticlesNamesVector::size_type i = 0; i < particles_namelist.size(); i++)
80 std::string tmp_string(particles_namelist[i]+
"_count");
81 IntVect rr = IntVect::TheUnitVector();
82 if (
ref_tags[j].Field() == tmp_string) {
83 for (
int lev = levc; lev <= finest_level; lev++)
85 MultiFab temp_dat(grids[lev], dmap[lev], 1, 0); temp_dat.setVal(0);
86 particleData[particles_namelist[i]]->IncrementWithTotal(temp_dat, lev);
88 MultiFab temp_dat_crse(grids[levc], dmap[levc], 1, 0); temp_dat_crse.setVal(0);
91 MultiFab::Copy(*mf, temp_dat, 0, 0, 1, 0);
93 for (
int d = 0; d < AMREX_SPACEDIM; d++) {
94 rr[d] *= ref_ratio[levc][d];
96 average_down(temp_dat, temp_dat_crse, 0, 1, rr);
97 MultiFab::Add(*mf, temp_dat_crse, 0, 0, 1, 0);
107 ref_tags[j](tags,mf.get(),clearval,tagval,time,levc,geom[levc]);
120 Vector<std::string> refinement_indicators;
121 pp.queryarr(
"refinement_indicators",refinement_indicators,0,pp.countval(
"refinement_indicators"));
123 for (
int i=0; i<refinement_indicators.size(); ++i)
125 std::string ref_prefix =
pp_prefix +
"." + refinement_indicators[i];
127 ParmParse ppr(ref_prefix);
130 if (ppr.countval(
"in_box_lo")) {
131 std::vector<Real> box_lo(3), box_hi(3);
132 ppr.get(
"max_level",lev_for_box);
133 if (lev_for_box <= max_level)
135 ppr.getarr(
"in_box_lo",box_lo,0,2);
136 ppr.getarr(
"in_box_hi",box_hi,0,2);
137 box_lo[2] = geom[0].ProbLo(2);
138 box_hi[2] = geom[0].ProbHi(2);
139 realbox = RealBox(&(box_lo[0]),&(box_hi[0]));
141 amrex::Print() <<
"Reading " << realbox <<
" at level " << lev_for_box << std::endl;
144 const auto* dx = geom[lev_for_box].CellSize();
145 const Real* plo = geom[lev_for_box].ProbLo();
146 int ilo =
static_cast<int>((box_lo[0] - plo[0])/dx[0]);
147 int jlo =
static_cast<int>((box_lo[1] - plo[1])/dx[1]);
148 int klo =
static_cast<int>((box_lo[2] - plo[2])/dx[2]);
149 int ihi =
static_cast<int>((box_hi[0] - plo[0])/dx[0]-1);
150 int jhi =
static_cast<int>((box_hi[1] - plo[1])/dx[1]-1);
151 int khi =
static_cast<int>((box_hi[2] - plo[2])/dx[2]-1);
152 Box bx_old(IntVect(ilo,jlo,klo),IntVect(ihi,jhi,khi));
153 int mod_ilo = ilo%ref_ratio[lev_for_box-1][0];
154 int mod_ihi = (ihi+1)%ref_ratio[lev_for_box-1][0];
155 int mod_jlo = jlo%ref_ratio[lev_for_box-1][0];
156 int mod_jhi = (jhi+1)%ref_ratio[lev_for_box-1][0];
164 ihi += ref_ratio[lev_for_box-1][0] - mod_ihi;
167 jhi += ref_ratio[lev_for_box-1][1] - mod_jhi;
169 Box bx(IntVect(ilo,jlo,klo),IntVect(ihi,jhi,khi));
170 if (mod_ilo !=0 || mod_jlo !=0 || mod_ihi != 0 || mod_jhi != 0) {
171 amrex::Print() <<
"Fine box on level " << lev_for_box <<
" adjusted from " << bx_old <<
" to " << bx <<
" to make it valid for refinement." << std::endl;
174 amrex::Print() <<
"Saving in 'boxes at level' as " << bx << std::endl;
178 AMRErrorTagInfo info;
181 info.SetRealBox(realbox);
183 if (ppr.countval(
"start_time") > 0) {
184 Real ref_min_time; ppr.get(
"start_time",ref_min_time);
185 info.SetMinTime(ref_min_time);
187 if (ppr.countval(
"end_time") > 0) {
188 Real ref_max_time; ppr.get(
"end_time",ref_max_time);
189 info.SetMaxTime(ref_max_time);
191 if (ppr.countval(
"max_level") > 0) {
192 int ref_max_level; ppr.get(
"max_level",ref_max_level);
193 info.SetMaxLevel(ref_max_level);
196 if (ppr.countval(
"value_greater")) {
197 int num_val = ppr.countval(
"value_greater");
198 Vector<Real> value(num_val);
199 ppr.getarr(
"value_greater",value,0,num_val);
200 std::string field; ppr.get(
"field_name",field);
201 ref_tags.push_back(AMRErrorTag(value,AMRErrorTag::GREATER,field,info));
203 else if (ppr.countval(
"value_less")) {
204 int num_val = ppr.countval(
"value_less");
205 Vector<Real> value(num_val);
206 ppr.getarr(
"value_less",value,0,num_val);
207 std::string field; ppr.get(
"field_name",field);
208 ref_tags.push_back(AMRErrorTag(value,AMRErrorTag::LESS,field,info));
210 else if (ppr.countval(
"adjacent_difference_greater")) {
211 int num_val = ppr.countval(
"adjacent_difference_greater");
212 Vector<Real> value(num_val);
213 ppr.getarr(
"adjacent_difference_greater",value,0,num_val);
214 std::string field; ppr.get(
"field_name",field);
215 ref_tags.push_back(AMRErrorTag(value,AMRErrorTag::GRAD,field,info));
217 else if (realbox.ok())
219 ref_tags.push_back(AMRErrorTag(info));
221 Abort(std::string(
"Unrecognized refinement indicator for " + refinement_indicators[i]).c_str());
void remora_dervort(const amrex::Box &bx, amrex::FArrayBox &derfab, int dcomp, int ncomp, const amrex::FArrayBox &datfab, const amrex::Array4< const amrex::Real > &pm, const amrex::Array4< const amrex::Real > &pn, const amrex::Geometry &, amrex::Real, const int *, const int)