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

Method ParticleDerive

Source/particles/CastroParticles.cpp:117–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117std::unique_ptr<MultiFab>
118Castro::ParticleDerive(const std::string& name,
119 Real time,
120 int ngrow)
121{
122 BL_PROFILE("Castro::ParticleDerive()");
123
124 if (TracerPC && name == "particle_count")
125 {
126 auto derive_dat = new MultiFab(grids,dmap,1,0);
127 MultiFab temp_dat(grids,dmap,1,0);
128 temp_dat.setVal(0);
129 TracerPC->Increment(temp_dat,level);
130 MultiFab::Copy(*derive_dat,temp_dat,0,0,1,0);
131 return std::unique_ptr<MultiFab>(derive_dat);
132 }
133 else if (TracerPC && name == "total_particle_count")
134 {
135 //
136 // We want the total particle count at this level or higher.
137 //
138 auto derive_dat = ParticleDerive("particle_count",time,ngrow);
139
140 IntVect trr(AMREX_D_DECL(1,1,1));
141
142 for (int lev = level+1; lev <= parent->finestLevel(); lev++)
143 {
144 BoxArray ba = parent->boxArray(lev);
145 const DistributionMapping& dm = parent->DistributionMap(lev);
146
147 MultiFab temp_dat(ba,dm,1,0);
148
149 trr *= parent->refRatio(lev-1);
150
151 ba.coarsen(trr);
152
153 MultiFab ctemp_dat(ba,dm,1,0);
154
155 temp_dat.setVal(0);
156 ctemp_dat.setVal(0);
157
158 TracerPC->Increment(temp_dat,lev);
159
160 for (MFIter mfi(temp_dat); mfi.isValid(); ++mfi)
161 {
162 const FArrayBox& ffab = temp_dat[mfi];
163 FArrayBox& cfab = ctemp_dat[mfi];
164 const Box& fbx = ffab.box();
165
166 BL_ASSERT(cfab.box() == amrex::coarsen(fbx,trr));
167
168 for (IntVect p = fbx.smallEnd(); p <= fbx.bigEnd(); fbx.next(p))
169 {
170 const Real val = ffab(p);
171 if (val > 0)
172 cfab(amrex::coarsen(p,trr)) += val;
173 }
174 }

Callers

nothing calls this directly

Calls 2

isValidMethod · 0.80
clearMethod · 0.80

Tested by

no test coverage detected