13#ifndef CD_ITOKMCGODUNOVSTEPPERIMPLEM_H
14#define CD_ITOKMCGODUNOVSTEPPERIMPLEM_H
29#include <CD_NamespaceHeader.H>
31using namespace Physics::ItoKMC;
43depositPointParticlesLikeSolver(
const RefCountedPtr<ItoSolver>& a_solver,
47 a_solver->depositWeight(a_phi, a_particles, a_solver->getDeposition(), a_solver->getCoarseFineDeposition());
52template <
typename I,
typename C,
typename R,
typename F>
56 CH_TIME(
"ItoKMCGodunovStepper::ItoKMCGodunovStepper");
58 this->
m_name =
"ItoKMCGodunovStepper";
74template <
typename I,
typename C,
typename R,
typename F>
77 CH_TIME(
"ItoKMCGodunovStepper::~ItoKMCGodunovStepper");
79 pout() <<
"ItoKMCGodunovStepper::~ItoKMCGodunovStepper" << endl;
83template <
typename I,
typename C,
typename R,
typename F>
87 CH_TIME(
"ItoKMCGodunovStepper::registerOperators");
89 pout() <<
"ItoKMCGodunovStepper::registerOperators" << endl;
99template <
typename I,
typename C,
typename R,
typename F>
103 CH_TIME(
"ItoKMCGodunovStepper::allocate");
105 pout() <<
"ItoKMCGodunovStepper::allocate" << endl;
113 const int numItoSpecies = this->
m_physics->getNumItoSpecies();
119 for (
auto solverIt = (this->
m_ito)->iterator(); solverIt.ok(); ++solverIt) {
120 const int idx = solverIt.index();
132template <
typename I,
typename C,
typename R,
typename F>
136 CH_TIME(
"ItoKMCGodunovStepper::allocateInternals");
138 pout() << this->
m_name +
"::allocateInternals" << endl;
143 const int numCdrSpecies = this->
m_physics->getNumCdrSpecies();
146 for (
int i = 0; i < numCdrSpecies; i++) {
173 if ((mfis->numPhases() > 1) && (dielectrics.size() > 0)) {
180template <
typename I,
typename C,
typename R,
typename F>
184 CH_TIME(
"ItoKMCGodunovStepper::barrier");
186 pout() << this->
m_name +
"::barrier" << endl;
194template <
typename I,
typename C,
typename R,
typename F>
198 CH_TIME(
"ItoKMCGodunovStepper::parseOptions");
200 pout() << this->
m_name +
"::parseOptions" << endl;
214template <
typename I,
typename C,
typename R,
typename F>
218 CH_TIME(
"ItoKMCGodunovStepper::parseRuntimeOptions");
220 pout() << this->
m_name +
"::parseRuntimeOptions" << endl;
234template <
typename I,
typename C,
typename R,
typename F>
238 CH_TIME(
"ItoKMCGodunovStepper::parseAlgorithm");
240 pout() << this->
m_name +
"::parseAlgorithm" << endl;
243 ParmParse pp(this->
m_name.c_str());
247 pp.get(
"algorithm", str);
251 if (str ==
"euler_maruyama") {
255 MayDay::Abort(
"ItoKMCGodunovStepper::parseAlgorithm - unknown algorithm requested");
259template <
typename I,
typename C,
typename R,
typename F>
263 CH_TIME(
"ItoKMCGodunovStepper::parseFiltering");
265 pout() << this->
m_name +
"::parseFiltering" << endl;
268 ParmParse pp(this->
m_name.c_str());
287 if (m_rhoFilterAlpha <= 0.0 || m_rhoFilterAlpha >= 1.0) {
288 MayDay::Abort(
"ItoKMCGodunovStepper::parseFiltering -- cannot have alpha <= 0 or alpha >= 1 for rho_filter");
290 if (m_condFilterAlpha <= 0.0 || m_condFilterAlpha >= 1.0) {
291 MayDay::Abort(
"ItoKMCGodunovStepper::parseFiltering -- cannot have alpha <= 0 or alpha >= 1 for cond_filter");
295template <
typename I,
typename C,
typename R,
typename F>
299 CH_TIME(
"ItoKMCGodunovStepper::parseCheckpointParticles");
301 pout() << this->
m_name +
"::parseCheckpointParticles" << endl;
304 ParmParse pp(this->
m_name.c_str());
309template <
typename I,
typename C,
typename R,
typename F>
313 CH_TIME(
"ItoKMCGodunovStepper::parseSecondaryEmissionSpecifiation");
315 pout() << this->
m_name +
"::parseSecondaryEmissionSpecification" << endl;
318 ParmParse pp(this->
m_name.c_str());
322 pp.query(
"secondary_emission", str);
324 if (str ==
"before_reactions") {
327 else if (str ==
"after_reactions") {
333 err =
"ItoKMCGodunovStepper::parseSecondaryEmissionSpecification - expected 'before_reactions' or 'after_reactions'";
334 err +=
"but got" + str;
336 MayDay::Abort(err.c_str());
340template <
typename I,
typename C,
typename R,
typename F>
343 const RealVect& a_disp,
347 const Real a_bisectStep)
const noexcept
351 constexpr int numAttempts = 2;
354 constexpr Real raycastTolerance = 1.E-3;
356 const RefCountedPtr<BaseIF>& baseif = (this->
m_amr)->getBaseImplicitFunction(this->
m_plasmaPhase);
360 const Real fluidSign = (a_fOld > 0.0) ? 1.0 : -1.0;
361 const Real h = 1.E-2 * a_dx;
363 const auto inFluid = [&](
const RealVect& a_x) ->
bool {
364 return fluidSign * baseif->value(a_x) > 0.0;
369 const auto findCrossing = [&](
const RealVect& a_end, Real& a_s) ->
bool {
370 switch (a_intersectionAlg) {
371 case EBIntersection::Bisection: {
374 case EBIntersection::Raycast: {
378 MayDay::Abort(
"ItoKMCGodunovStepper::reflectDiffusionHop - unsupported EB intersection requested");
385 RealVect end = a_pos + a_disp;
387 for (
int attempt = 0; attempt < numAttempts; attempt++) {
388 Real s = std::numeric_limits<Real>::max();
393 if (!findCrossing(end, s)) {
397 return inFluid(end) ? (end - a_pos) : RealVect::Zero;
400 const RealVect cross = a_pos + s * (end - a_pos);
403 RealVect grad = RealVect::Zero;
405 for (
int dir = 0; dir < SpaceDim; dir++) {
412 grad[dir] = (baseif->value(hi) - baseif->value(lo)) / (2.0 * h);
415 const Real gradLen = grad.vectorLength();
417 if (gradLen <= 0.0) {
418 return RealVect::Zero;
421 const RealVect n = grad / gradLen;
425 const RealVect overshoot = end - cross;
427 end = cross + overshoot - 2.0 * overshoot.dotProduct(n) * n;
434 return RealVect::Zero;
437template <
typename I,
typename C,
typename R,
typename F>
441 CH_TIME(
"ItoKMCGodunovStepper::parseDiffusiveDeposit");
443 pout() << this->
m_name +
"::parseDiffusiveDeposit" << endl;
446 ParmParse pp(this->
m_name.c_str());
450 pp.get(
"diffusive_deposit", str);
452 if (str ==
"inside") {
455 else if (str ==
"cancel") {
456 m_diffusiveDeposit = DiffusiveDeposit::Cancel;
458 else if (str ==
"reflect_rho") {
461 else if (str ==
"reflect_ito") {
462 m_diffusiveDeposit = DiffusiveDeposit::ReflectIto;
465 const std::string err =
"ItoKMCGodunovStepper::parseDiffusiveDeposit - expected 'inside', 'cancel', "
466 "'reflect_rho' or 'reflect_ito' but got '" +
469 MayDay::Abort(err.c_str());
473template <
typename I,
typename C,
typename R,
typename F>
477 CH_TIME(
"ItoKMCGodunovStepper::parseRhoDaggerHop");
479 pout() << this->
m_name +
"::parseRhoDaggerHop" << endl;
482 ParmParse pp(this->
m_name.c_str());
487template <
typename I,
typename C,
typename R,
typename F>
491 CH_TIME(
"ItoKMCGodunovStepper::parseReactiveFieldCentering");
493 pout() << this->
m_name +
"::parseReactiveFieldCentering" << endl;
496 ParmParse pp(this->m_name.c_str());
498 pp.get(
"reactive_E_centering", m_reactiveFieldCentering);
502 if (m_reactiveFieldCentering < 0.0 || m_reactiveFieldCentering > 1.0) {
503 MayDay::Abort(
"ItoKMCGodunovStepper::parseReactiveFieldCentering -- 'reactive_E_centering' must lie in [0,1]");
507template <
typename I,
typename C,
typename R,
typename F>
511 CH_TIME(
"ItoKMCGodunovStepper::computeDt");
513 pout() << this->
m_name +
"::computeDt" << endl;
518 if ((this->m_maxReducedField > m_maxFieldAbort) && (m_maxFieldAbort > 0.0)) {
519 pout() << this->m_name +
" stopping because maximum field is too high (" << this->m_maxReducedField <<
")" << endl;
521 this->m_keepGoing =
false;
527template <
typename I,
typename C,
typename R,
typename F>
531 CH_TIME(
"ItoKMCGodunovStepper::advance");
533 pout() << this->
m_name +
"::advance" << endl;
551 m_timer.startEvent(
"Store E^k");
555 m_timer.stopEvent(
"Store E^k");
560 case WhichAlgorithm::EulerMaruyama: {
566 MayDay::Abort(
"ItoKMCGodunovStepper::advance - logic bust");
575 m_timer.startEvent(
"EB/Particle intersection");
576 if (m_extendConductivityEB) {
585 const std::size_t i) ->
void {
586 leaf.template get<&ItoParticle::scratch>(i) = 1.0;
590 leaf.template get<&ItoParticle::scratch>(i) = -1.0;
596 for (
auto it = this->
m_ito->iterator(); it.ok(); ++it) {
597 const RefCountedPtr<ItoSolver>& solver = it();
599 if (solver->isMobile() || solver->isDiffusive()) {
607 const bool deleteParticles =
false;
612 for (
auto it = this->
m_ito->iterator(); it.ok(); ++it) {
613 const RefCountedPtr<ItoSolver>& solver = it();
614 const RefCountedPtr<ItoSpecies>& species = solver->getSpecies();
616 const int idx = it.index();
617 const int Z = species->getChargeNumber();
625 if (Z != 0 && solver->isMobile()) {
626 for (
int lvl = 0; lvl <= (this->
m_amr)->getFinestLevel(); lvl++) {
628 const DataIterator& dit = dbl.dataIterator();
630 const int nbox = dit.size();
632#pragma omp parallel for schedule(runtime)
633 for (
int mybox = 0; mybox < nbox; mybox++) {
634 const DataIndex& din = dit[mybox];
639 for (std::size_t i = 0; i < leaf.
size(); i++) {
640 if (leaf.template get<&ItoParticle::scratch>(i) < 0.0) {
641 const RealVect pos = leaf.
position(i);
642 const Real weight = leaf.
weight(i);
643 const Real mobility = leaf.template get<&ItoParticle::mobility>(i);
645 pointParticles.
append(pos, weight * mobility);
654 for (
auto it = this->m_ito->iterator(); it.ok(); ++it) {
655 const RefCountedPtr<ItoSolver>& solver = it();
657 if (!(solver->isMobile() || solver->isDiffusive())) {
661 ParticleContainer<ItoParticle>& bulkParticles = solver->
getParticles(ItoSolver::WhichContainer::Bulk);
663 for (
int lvl = 0; lvl <= (this->m_amr)->getFinestLevel(); lvl++) {
664 const DisjointBoxLayout& dbl = (this->m_amr)->getGrids((this->m_particleRealm))[lvl];
665 const DataIterator& dit = dbl.dataIterator();
667 const int nbox = dit.size();
669#pragma omp parallel for schedule(runtime)
670 for (
int mybox = 0; mybox < nbox; mybox++) {
671 const DataIndex& din = dit[mybox];
673 ParticleSoA<ItoParticle>& leaf = bulkParticles[lvl][din];
676 while (i < leaf.
size()) {
677 if (leaf.template get<&ItoParticle::scratch>(i) < 0.0) {
703 for (
auto it = this->m_ito->iterator(); it.ok(); ++it) {
704 const RefCountedPtr<ItoSolver>& solver = it();
706 ParticleContainer<ItoParticle>& ebParticles = solver->
getParticles(ItoSolver::WhichContainer::EB);
707 ParticleContainer<ItoParticle>& bulkParticles = solver->
getParticles(ItoSolver::WhichContainer::Bulk);
709 this->m_amr->transferIrregularParticles(ebParticles, bulkParticles, this->m_plasmaPhase);
711 m_timer.stopEvent(
"EB/Particle intersection");
716 m_timer.startEvent(
"Photon transport");
717 this->advancePhotons(a_dt);
718 m_timer.stopEvent(
"Photon transport");
721 if ((this->m_physics)->needGradients()) {
722 m_timer.startEvent(
"Gradient calculation");
729 for (
auto solverIt = (this->m_ito)->iterator(); solverIt.ok(); ++solverIt) {
730 if ((this->m_physics)->needGradient(solverIt.index())) {
731 solverIt()->depositParticles();
735 this->computeDensityGradients();
736 m_timer.stopEvent(
"Gradient calculation");
741 if (m_emitSecondaryParticlesBeforeReactions) {
743 m_timer.startEvent(
"EB particle injection");
744 if (this->needSecondaryEmissionEB()) {
745 this->fillSecondaryEmissionEB(a_dt);
746 this->resolveSecondaryEmissionEB(a_dt);
748 m_timer.stopEvent(
"EB particle injection");
750 m_timer.startEvent(
"Domain particle injection");
751 if (this->needSecondaryEmissionDomain()) {
752 this->fillSecondaryEmissionDomain(a_dt);
753 this->resolveSecondaryEmissionDomain();
755 m_timer.stopEvent(
"Domain particle injection");
760 m_timer.startEvent(
"Sort by cell");
761 (this->m_ito)->organizeParticlesByCell(ItoSolver::WhichContainer::Bulk);
762 this->sortPhotonsByCell(McPhoto::WhichContainer::Bulk);
763 this->sortPhotonsByCell(McPhoto::WhichContainer::Source);
764 m_timer.stopEvent(
"Sort by cell");
774 m_timer.startEvent(
"Reaction network");
775 if (m_reactiveFieldCentering >= 1.0) {
777 this->advanceReactionNetwork(this->m_electricFieldFluid, a_dt);
781 if (m_reactiveFieldCentering > 0.0) {
782 DataOps::scale(m_reactiveElectricField, 1.0 - m_reactiveFieldCentering);
783 DataOps::incr(m_reactiveElectricField, this->m_electricFieldFluid, m_reactiveFieldCentering);
786 this->advanceReactionNetwork(m_reactiveElectricField, a_dt);
788 m_timer.stopEvent(
"Reaction network");
795 m_timer.startEvent(
"Make superparticles");
796 if (this->m_mergeInterval > 0 && (this->m_timeStep + 1) % this->m_mergeInterval == 0) {
797 (this->m_ito)->makeSuperparticles(ItoSolver::WhichContainer::Bulk);
799 m_timer.stopEvent(
"Make superparticles");
803 m_timer.startEvent(
"Sort by patch");
804 (this->m_ito)->organizeParticlesByPatch(ItoSolver::WhichContainer::Bulk);
805 this->sortPhotonsByPatch(McPhoto::WhichContainer::Bulk);
806 this->sortPhotonsByPatch(McPhoto::WhichContainer::Source);
807 m_timer.stopEvent(
"Sort by patch");
811 if (!m_emitSecondaryParticlesBeforeReactions) {
813 m_timer.startEvent(
"EB particle injection");
814 if (this->needSecondaryEmissionEB()) {
815 this->fillSecondaryEmissionEB(a_dt);
816 this->resolveSecondaryEmissionEB(a_dt);
818 m_timer.stopEvent(
"EB particle injection");
820 m_timer.startEvent(
"Domain particle injection");
821 if (this->needSecondaryEmissionDomain()) {
822 this->fillSecondaryEmissionDomain(a_dt);
823 this->resolveSecondaryEmissionDomain();
825 m_timer.stopEvent(
"Domain particle injection");
831 m_timer.startEvent(
"Remove covered");
833 m_timer.stopEvent(
"Remove covered");
836 for (
auto solverIt = (this->m_ito)->iterator(); solverIt.ok(); ++solverIt) {
837 solverIt()->clear(ItoSolver::WhichContainer::EB);
838 solverIt()->clear(ItoSolver::WhichContainer::Domain);
850 m_timer.startEvent(
"Post-compute v");
851 this->setCdrVelocityFunctions();
852 this->computeMobilities();
853 for (
auto solverIt = (this->m_ito)->iterator(); solverIt.ok(); ++solverIt) {
854 solverIt()->interpolateVelocities();
856 this->multiplyCdrVelocitiesByMobilities();
857 m_timer.stopEvent(
"Post-compute v");
860 m_timer.startEvent(
"Post-compute D");
861 this->computeDiffusionCoefficients();
862 m_timer.stopEvent(
"Post-compute D");
864 this->computePhysicsDt();
866 if ((this->m_profile)) {
867 m_timer.eventReport(pout(),
false);
873 this->m_maxReducedField = this->computeMaxReducedElectricField(this->m_plasmaPhase);
878template <
typename I,
typename C,
typename R,
typename F>
882 CH_TIME(
"ItoKMCGodunovStepper::preRegrid");
884 pout() <<
"ItoKMCGodunovStepper::preRegrid" << endl;
887 const int numItoSpecies = (this->
m_physics)->getNumItoSpecies();
888 const int numCdrSpecies = (this->
m_physics)->getNumCdrSpecies();
889 const int numPlasmaSpecies = (this->
m_physics)->getNumPlasmaSpecies();
890 const int numPhotonSpecies = (this->
m_physics)->getNumPhotonSpecies();
894 for (
auto solverIt = (this->
m_ito)->iterator(); solverIt.ok(); ++solverIt) {
895 const int idx = solverIt.index();
909 for (
int i = 0; i < numCdrSpecies; i++) {
917template <
typename I,
typename C,
typename R,
typename F>
920 const int a_oldFinestLevel,
921 const int a_newFinestLevel)
noexcept
923 CH_TIME(
"ItoKMCGodunovStepper::regrid");
925 pout() <<
"ItoKMCGodunovStepper::regrid" << endl;
933 const std::string baseErr =
"ItoKMCGodunovStepper::regrid -- can't regrid because";
934 const std::string err1 =
"checkpoint file does not contain particles. Set Driver.initial_regrids=0";
936 pout() << baseErr + err1 << endl;
938 MayDay::Error((baseErr + err1).c_str());
942 m_timer.startEvent(
"Regrid ItoSolver");
943 (this->
m_ito)->
regrid(a_lmin, a_oldFinestLevel, a_newFinestLevel);
950 m_timer.stopEvent(
"Regrid ItoSolver");
952 m_timer.startEvent(
"Regrid CdrSolver");
953 (this->
m_cdr)->
regrid(a_lmin, a_oldFinestLevel, a_newFinestLevel);
954 m_timer.stopEvent(
"Regrid CdrSolver");
956 m_timer.startEvent(
"Regrid FieldSolver");
958 m_timer.stopEvent(
"Regrid FieldSolver");
960 m_timer.startEvent(
"Regrid RTE");
961 (this->
m_rte)->
regrid(a_lmin, a_oldFinestLevel, a_newFinestLevel);
962 m_timer.stopEvent(
"Regrid RTE");
964 m_timer.startEvent(
"Regrid SurfaceODESolver");
965 this->
m_sigmaSolver->regrid(a_lmin, a_oldFinestLevel, a_newFinestLevel);
966 m_timer.stopEvent(
"Regrid SurfaceODESolver");
969 m_timer.startEvent(
"Allocate internals");
971 m_timer.stopEvent(
"Allocate internals");
974 m_timer.startEvent(
"Remap algorithm-particles");
975 for (
auto solverIt = (this->
m_ito)->iterator(); solverIt.ok(); ++solverIt) {
976 const int idx = solverIt.index();
981 m_timer.stopEvent(
"Remap algorithm-particles");
990 EBCoarseToFineInterp::Type::ConservativeMinMod);
998 EBCoarseToFineInterp::Type::ConservativeMinMod);
1002 m_timer.startEvent(
"Setup field solver");
1006 m_timer.stopEvent(
"Setup field solver");
1009 m_timer.startEvent(
"Solve Poisson");
1021 const std::string errMsg =
"ItoKMCGodunovStepper::regrid - Poisson solve did not converge after regrid";
1023 pout() << errMsg << endl;
1026 MayDay::Error(errMsg.c_str());
1029 m_timer.stopEvent(
"Solve Poisson");
1045 m_timer.startEvent(
"Deposit particles");
1047 m_timer.stopEvent(
"Deposit particles");
1050 m_timer.startEvent(
"Prepare next step");
1053 m_timer.stopEvent(
"Prepare next step");
1055 m_timer.eventReport(pout(),
false);
1065template <
typename I,
typename C,
typename R,
typename F>
1069 CH_TIME(
"ItoKMCGodunovStepper::setOldPositions");
1071 pout() << this->
m_name +
"::setOldPositions" << endl;
1074 for (
auto solverIt = (this->
m_ito)->iterator(); solverIt.ok(); ++solverIt) {
1075 RefCountedPtr<ItoSolver>& solver = solverIt();
1077 for (
int lvl = 0; lvl <= (this->
m_amr)->getFinestLevel(); lvl++) {
1079 const DataIterator& dit = dbl.dataIterator();
1081 auto& particles = solver->getParticles(ItoSolver::WhichContainer::Bulk)[lvl];
1083 const int nbox = dit.size();
1085#pragma omp parallel for schedule(runtime)
1086 for (
int mybox = 0; mybox < nbox; mybox++) {
1087 const DataIndex& din = dit[mybox];
1092 double*
const oldPos[SpaceDim] = {D_DECL(leaf.template column<&ItoParticle::old_x>(),
1093 leaf.template column<&ItoParticle::old_y>(),
1094 leaf.template column<&ItoParticle::old_z>())};
1097 D_DECL(oldPos[0][i] = pos[0][i], oldPos[1][i] = pos[1][i], oldPos[2][i] = pos[2][i]);
1104template <
typename I,
typename C,
typename R,
typename F>
1109 CH_TIME(
"ItoKMCGodunovStepper::remapPointParticles");
1111 pout() << this->
m_name +
"::remapPointParticles" << endl;
1114 for (
auto solverIt = (this->
m_ito)->iterator(); solverIt.ok(); ++solverIt) {
1115 RefCountedPtr<ItoSolver>& solver = solverIt();
1116 const RefCountedPtr<ItoSpecies>& species = solver->getSpecies();
1118 const int idx = solverIt.index();
1120 const bool mobile = solver->isMobile();
1121 const bool diffusive = solver->isDiffusive();
1122 const bool charged = species->getChargeNumber() != 0;
1126 a_particles[idx]->remap();
1132 a_particles[idx]->remap();
1139 a_particles[idx]->remap();
1145 if (mobile || diffusive) {
1146 a_particles[idx]->remap();
1152 if (mobile && diffusive) {
1153 a_particles[idx]->remap();
1160 a_particles[idx]->remap();
1166 if (charged && mobile) {
1167 a_particles[idx]->remap();
1173 if (charged && diffusive) {
1174 a_particles[idx]->remap();
1180 if (charged && (mobile || diffusive)) {
1181 a_particles[idx]->remap();
1187 if (charged && (mobile && diffusive)) {
1188 a_particles[idx]->remap();
1194 if (!mobile && !diffusive) {
1195 a_particles[idx]->remap();
1201 MayDay::Abort(
"ItoKMCGodunovStepper::remapPointParticles - logic bust");
1209template <
typename I,
typename C,
typename R,
typename F>
1215 CH_TIME(
"ItoKMCGodunovStepper::depositPointParticles");
1217 pout() << this->
m_name +
"::depositPointParticles" << endl;
1220 for (
auto solverIt = (this->
m_ito)->iterator(); solverIt.ok(); ++solverIt) {
1221 RefCountedPtr<ItoSolver>& solver = solverIt();
1222 const RefCountedPtr<ItoSpecies>& species = solver->getSpecies();
1224 const int idx = solverIt.index();
1226 const bool mobile = solver->isMobile();
1227 const bool diffusive = solver->isDiffusive();
1228 const bool charged = species->getChargeNumber() != 0;
1232 depositPointParticlesLikeSolver(solver, solver->getPhi(), *a_particles[idx]);
1238 depositPointParticlesLikeSolver(solver, solver->getPhi(), *a_particles[idx]);
1245 depositPointParticlesLikeSolver(solver, solver->getPhi(), *a_particles[idx]);
1251 if (mobile || diffusive) {
1252 depositPointParticlesLikeSolver(solver, solver->getPhi(), *a_particles[idx]);
1257 if (mobile && diffusive) {
1258 depositPointParticlesLikeSolver(solver, solver->getPhi(), *a_particles[idx]);
1264 depositPointParticlesLikeSolver(solver, solver->getPhi(), *a_particles[idx]);
1269 if (charged && mobile) {
1270 depositPointParticlesLikeSolver(solver, solver->getPhi(), *a_particles[idx]);
1275 if (charged && diffusive) {
1276 depositPointParticlesLikeSolver(solver, solver->getPhi(), *a_particles[idx]);
1282 if (charged && (mobile || diffusive)) {
1283 depositPointParticlesLikeSolver(solver, solver->getPhi(), *a_particles[idx]);
1289 if (charged && (mobile && diffusive)) {
1290 depositPointParticlesLikeSolver(solver, solver->getPhi(), *a_particles[idx]);
1296 if (!mobile && !diffusive) {
1297 depositPointParticlesLikeSolver(solver, solver->getPhi(), *a_particles[idx]);
1303 MayDay::Abort(
"ItoKMCGodunovStepper::depositPointParticles - logic bust");
1311template <
typename I,
typename C,
typename R,
typename F>
1317 CH_TIME(
"ItoKMCGodunovStepper::clearPointParticles");
1319 pout() << this->
m_name +
"::clearPointParticles" << endl;
1322 for (
auto solverIt = (this->
m_ito)->iterator(); solverIt.ok(); ++solverIt) {
1323 RefCountedPtr<ItoSolver>& solver = solverIt();
1324 const RefCountedPtr<ItoSpecies>& species = solver->getSpecies();
1326 const int idx = solverIt.index();
1328 const bool mobile = solver->isMobile();
1329 const bool diffusive = solver->isDiffusive();
1330 const bool charged = species->getChargeNumber() != 0;
1334 a_particles[idx]->clearParticles();
1340 a_particles[idx]->clearParticles();
1347 a_particles[idx]->clearParticles();
1353 if (mobile || diffusive) {
1354 a_particles[idx]->clearParticles();
1360 if (mobile && diffusive) {
1361 a_particles[idx]->clearParticles();
1368 a_particles[idx]->clearParticles();
1374 if (charged && mobile) {
1375 a_particles[idx]->clearParticles();
1381 if (charged && diffusive) {
1382 a_particles[idx]->clearParticles();
1388 if (charged && (mobile || diffusive)) {
1389 a_particles[idx]->clearParticles();
1395 if (charged && (mobile && diffusive)) {
1396 a_particles[idx]->clearParticles();
1402 if (!mobile && !diffusive) {
1403 a_particles[idx]->clearParticles();
1409 MayDay::Abort(
"ItoKMCGodunovStepper::clearPointParticles - logic bust");
1417template <
typename I,
typename C,
typename R,
typename F>
1421 CH_TIME(
"ItoKMCGodunovStepper::computeCdrConductivity");
1423 pout() << this->
m_name +
"::computeCdrConductivity" << endl;
1428 for (
auto solverIt = (this->
m_cdr)->iterator(); solverIt.ok(); ++solverIt) {
1429 const RefCountedPtr<CdrSolver>& solver = solverIt();
1430 const RefCountedPtr<CdrSpecies>& species = solver->getSpecies();
1432 const int index = solverIt.index();
1433 const int Z = species->getChargeNumber();
1435 if (Z != 0 && solver->isMobile()) {
1436 const EBAMRCellData& phi = solver->getPhi();
1447template <
typename I,
typename C,
typename R,
typename F>
1451 const bool a_useStoredCdrConductivity)
noexcept
1453 CH_TIME(
"ItoKMCGodunovStepper::computeConductivities");
1455 pout() << this->
m_name +
"::computeConductivities" << endl;
1462template <
typename I,
typename C,
typename R,
typename F>
1465 EBAMRCellData& a_conductivityCell,
1467 const bool a_useStoredCdrConductivity)
noexcept
1469 CH_TIME(
"ItoKMCGodunovStepper::computeCellConductivity(EBAMRCellData, ParticleContainer)");
1471 pout() << this->
m_name +
"::computeCellConductivity(EBAMRCellData, ParticleContainer)" << endl;
1482 bool anyItoConductivity =
false;
1484 for (
auto solverIt = (this->
m_ito)->iterator(); solverIt.ok(); ++solverIt) {
1485 RefCountedPtr<ItoSolver>& solver = solverIt();
1486 const RefCountedPtr<ItoSpecies>& species = solver->getSpecies();
1488 const int idx = solverIt.index();
1489 const int Z = species->getChargeNumber();
1491 if (Z != 0 && solver->isMobile()) {
1493 depositPointParticlesLikeSolver(solver, this->
m_particleScratch1, *a_particles[idx]);
1497 anyItoConductivity =
true;
1501 if (anyItoConductivity) {
1514 if (!a_useStoredCdrConductivity) {
1548template <
typename I,
typename C,
typename R,
typename F>
1552 CH_TIME(
"ItoKMCGodunovStepper::computeFaceConductivity");
1554 pout() << this->
m_name +
"::computeFaceConductivity" << endl;
1562 const Average average = Average::Arithmetic;
1563 const int tanGhost = 1;
1564 const Interval interv(0, 0);
1569 (this->
m_amr)->getDomains(),
1583template <
typename I,
typename C,
typename R,
typename F>
1587 CH_TIMERS(
"ItoKMCGodunovStepper::computeSemiImplicitRho");
1588 CH_TIMER(
"ItoKMCGodunovStepper::computeSemiImplicitRho::plasma_phase", t1);
1589 CH_TIMER(
"ItoKMCGodunovStepper::computeSemiImplicitRho::solid_phase", t2);
1590 CH_TIMER(
"ItoKMCGodunovStepper::computeSemiImplicitRho::filter", t3);
1592 pout() << this->
m_name +
"::computeSemiImplicitRho" << endl;
1601 const bool hasDielectrics = (mfis->numPhases() > 1) && (dielectrics.size() > 0);
1605 EBAMRCellData rhoSolid;
1607 if (hasDielectrics) {
1619 bool anyItoCharge =
false;
1621 for (
auto solverIt = this->
m_ito->iterator(); solverIt.ok(); ++solverIt) {
1622 const RefCountedPtr<ItoSolver>& solver = solverIt();
1623 const RefCountedPtr<ItoSpecies>& species = solver->getSpecies();
1624 const int Z = species->getChargeNumber();
1632 anyItoCharge =
true;
1651 if (hasDielectrics) {
1658 bool anySolidCharge =
false;
1660 for (
auto solverIt = (this->
m_ito)->iterator(); solverIt.ok(); ++solverIt) {
1661 const RefCountedPtr<ItoSolver>& solver = solverIt();
1662 const RefCountedPtr<ItoSpecies>& species = solver->getSpecies();
1663 const int Z = species->getChargeNumber();
1677 DepositionType::CIC,
1678 CoarseFineDeposition::Halo,
1684 anySolidCharge =
true;
1688 if (anySolidCharge) {
1720 if (hasDielectrics) {
1725template <
typename I,
typename C,
typename R,
typename F>
1729 CH_TIME(
"ItoKMCGodunovStepper::setupSemiImplicitPoisson");
1731 pout() << this->
m_name +
"::setupSemiImplicitPoisson" << endl;
1738 MFAMRCellData& permCell = (this->
m_fieldSolver)->getPermittivityCell();
1739 MFAMRFluxData& permFace = (this->
m_fieldSolver)->getPermittivityFace();
1740 MFAMRIVData& permEB = (this->
m_fieldSolver)->getPermittivityEB();
1759 (this->
m_fieldSolver)->setSolverPermittivities(permCell, permFace, permEB);
1762template <
typename I,
typename C,
typename R,
typename F>
1767 const Real a_tolerance)
const noexcept
1769 CH_TIME(
"ItoKMCGodunovStepper::removeCoveredPointParticles");
1771 pout() << this->
m_name +
"::removeCoveredPointParticles" << endl;
1774 for (
int i = 0; i < a_particles.size(); i++) {
1775 if (a_particles[i] !=
nullptr) {
1778 switch (a_representation) {
1779 case EBRepresentation::Discrete: {
1780 (this->
m_amr)->removeCoveredParticlesDiscrete(particles, (this->
m_plasmaPhase), a_tolerance);
1784 case EBRepresentation::ImplicitFunction: {
1785 (this->
m_amr)->removeCoveredParticlesIF(particles, (this->
m_plasmaPhase), a_tolerance);
1789 case EBRepresentation::Voxel: {
1795 MayDay::Error(
"ItoKMCGodunovStepper::removeCoveredParticles - logic bust");
1802template <
typename I,
typename C,
typename R,
typename F>
1807 CH_TIME(
"ItoKMCGodunovStepper::copyConductivityParticles");
1809 pout() << this->
m_name +
"::copyConductivityParticles" << endl;
1815 for (
auto solverIt = (this->
m_ito)->iterator(); solverIt.ok(); ++solverIt) {
1816 const RefCountedPtr<ItoSolver>& solver = solverIt();
1817 const RefCountedPtr<ItoSpecies>& species = solver->getSpecies();
1819 const int idx = solverIt.index();
1820 const int Z = species->getChargeNumber();
1822 if (Z != 0 && solver->isMobile()) {
1825 for (
int lvl = 0; lvl <= (this->
m_amr)->getFinestLevel(); lvl++) {
1827 const DataIterator& dit = dbl.dataIterator();
1829 const int nbox = dit.size();
1831#pragma omp parallel for schedule(runtime)
1832 for (
int mybox = 0; mybox < nbox; mybox++) {
1833 const DataIndex& din = dit[mybox];
1845 for (std::size_t i = 0; i < leaf.
size(); i++) {
1846 const RealVect pos = leaf.
position(i);
1847 const Real weight = leaf.
weight(i);
1848 const Real mobility = leaf.template get<&ItoParticle::mobility>(i);
1850 pointParticles.
append(pos, weight * mobility);
1853 pointParticles.
catenate(irregParticles);
1860template <
typename I,
typename C,
typename R,
typename F>
1864 CH_TIME(
"ItoKMCGodunovStepper::solvePoisson()");
1866 pout() << this->
m_name +
"::solvePoisson()" << endl;
1874 const bool converged = (this->
m_fieldSolver)->solve(phi, rho, sigma,
false);
1899template <
typename I,
typename C,
typename R,
typename F>
1903 CH_TIME(
"ItoKMCGodunovStepper::advanceEulerMaruyama");
1905 pout() << this->
m_name +
"::advanceEulerMaruyama" << endl;
1915 m_timer.startEvent(
"Diffuse particles");
1918 m_timer.stopEvent(
"Diffuse particles");
1922 m_timer.startEvent(
"Diffuse CDR");
1924 m_timer.stopEvent(
"Diffuse CDR");
1928 m_timer.startEvent(
"Compute conductivities");
1931 m_timer.stopEvent(
"Compute conductivities");
1935 m_timer.startEvent(
"Setup Poisson");
1937 m_timer.stopEvent(
"Setup Poisson");
1942 m_timer.startEvent(
"Deposit point particles");
1945 m_timer.stopEvent(
"Deposit point particles");
1949 m_timer.startEvent(
"Solve Poisson");
1952 const std::string errMsg =
"ItoKMCGodunovStepper::advanceEulerMaruyama - Poisson solve did not converge";
1954 pout() << errMsg << endl;
1957 MayDay::Error(errMsg.c_str());
1960 m_timer.stopEvent(
"Solve Poisson");
1965 m_timer.startEvent(
"Step-compute v");
1969 (this->
m_ito)->interpolateVelocities();
1974 m_timer.stopEvent(
"Step-compute v");
1978 m_timer.startEvent(
"Euler-Maruyama step");
1981 m_timer.stopEvent(
"Euler-Maruyama step");
1984template <
typename I,
typename C,
typename R,
typename F>
1988 const Real a_dt)
noexcept
1990 CH_TIME(
"ItoKMCGodunovStepper::diffuseParticlesEulerMaruyama");
1992 pout() << this->
m_name +
"::diffuseParticlesEulerMaruyama" << endl;
1998 long long numCrossings = 0;
1999 long long numTotalTested = 0;
2000 long long numReflectFailed = 0;
2002 for (
auto solverIt = (this->
m_ito)->iterator(); solverIt.ok(); ++solverIt) {
2003 RefCountedPtr<ItoSolver>& solver = solverIt();
2004 const RefCountedPtr<ItoSpecies>& species = solver->getSpecies();
2006 const int idx = solverIt.index();
2008 const bool mobile = solver->isMobile();
2009 const bool diffusive = solver->isDiffusive();
2010 const int Z = species->getChargeNumber();
2012 const auto& diffusionFunction = (this->
m_physics)->getItoDiffusionFunctions()[idx];
2023 const bool gradientDrift = diffusive && solver->isDiffusionGradientDrift();
2025 if (gradientDrift) {
2026 solver->computeDiffusionGradient();
2029 for (
int lvl = 0; lvl <= (this->
m_amr)->getFinestLevel(); lvl++) {
2031 const DataIterator& dit = dbl.dataIterator();
2036 const RefCountedPtr<BaseIF>& baseif = (this->
m_amr)->getBaseImplicitFunction(this->
m_plasmaPhase);
2037 const Real dx = (this->
m_amr)->getDx()[lvl];
2038 const EBIntersection intersectionAlg = solver->getIntersectionAlgorithm();
2039 const Real bisectStep = solver->getBisectionStep();
2046 auto& particles = solver->getParticles(ItoSolver::WhichContainer::Bulk)[lvl];
2048 const int nbox = dit.size();
2050#pragma omp parallel for schedule(runtime) reduction(+ : numCrossings, numTotalTested, numReflectFailed)
2051 for (
int mybox = 0; mybox < nbox; mybox++) {
2052 const DataIndex& din = dit[mybox];
2068 if (gradientDrift) {
2069 solver->interpolateDiffusionGradient(lvl, din);
2077 const bool depositFollowsHop = correctTrajectory &&
m_rhoDaggerHop;
2080 std::vector<std::size_t> hopCrossings;
2081 std::vector<Real> hopCrossingsFOld;
2085 std::vector<std::size_t> depositCrossings;
2086 std::vector<Real> depositCrossingsFOld;
2087 std::vector<RealVect> depositCrossingsDisp;
2090 for (std::size_t i = 0; i < leaf.
size(); i++) {
2091 const Real weight = leaf.
weight(i);
2092 const RealVect pos = leaf.
position(i);
2098 const RealVect hop = diffusive ? diffusionFunction(p, a_dt) : RealVect::Zero;
2106 const RealVect disp = hop + a_dt * gradD;
2108 D_DECL(leaf.template get<&ItoParticle::scratch_x>(i) =
static_cast<ParticleReal>(disp[0]),
2109 leaf.template get<&ItoParticle::scratch_y>(i) =
static_cast<ParticleReal>(disp[1]),
2110 leaf.template get<&ItoParticle::scratch_z>(i) =
static_cast<ParticleReal>(disp[2]));
2115 const RealVect depositDisp =
m_rhoDaggerHop ? disp : a_dt * gradD;
2117 const bool deposits = (Z != 0);
2121 pointParticles.
append(pos + depositDisp, weight);
2129 const Real fOld = baseif->value(pos);
2131 const auto crosses = [&](
const RealVect& a_disp) ->
bool {
2132 return fOld * baseif->value(pos + a_disp) < 0.0;
2137 bool hopCrossed =
false;
2139 if (correctTrajectory) {
2142 hopCrossed = crosses(disp);
2145 hopCrossings.push_back(i);
2146 hopCrossingsFOld.push_back(fOld);
2156 if (depositFollowsHop) {
2158 pointParticles.
append(pos + depositDisp, weight);
2166 if (crosses(depositDisp)) {
2167 depositCrossings.push_back(i);
2168 depositCrossingsFOld.push_back(fOld);
2169 depositCrossingsDisp.push_back(depositDisp);
2172 pointParticles.
append(pos + depositDisp, weight);
2181 for (std::size_t k = 0; k < hopCrossings.size(); k++) {
2182 const std::size_t i = hopCrossings[k];
2183 const Real fOld = hopCrossingsFOld[k];
2185 const RealVect pos = leaf.
position(i);
2186 const RealVect disp = RealVect(D_DECL(leaf.template get<&ItoParticle::scratch_x>(i),
2187 leaf.template get<&ItoParticle::scratch_y>(i),
2188 leaf.template get<&ItoParticle::scratch_z>(i)));
2192 const RealVect correctedDisp = this->
reflectDiffusionHop(pos, disp, fOld, dx, intersectionAlg, bisectStep);
2194 if (correctedDisp == RealVect::Zero) {
2198 D_DECL(leaf.template get<&ItoParticle::scratch_x>(i) =
static_cast<ParticleReal>(correctedDisp[0]),
2199 leaf.template get<&ItoParticle::scratch_y>(i) =
static_cast<ParticleReal>(correctedDisp[1]),
2200 leaf.template get<&ItoParticle::scratch_z>(i) =
static_cast<ParticleReal>(correctedDisp[2]));
2203 if (Z != 0 && depositFollowsHop) {
2204 pointParticles.
append(pos + correctedDisp, leaf.
weight(i));
2211 for (std::size_t k = 0; k < depositCrossings.size(); k++) {
2212 const std::size_t i = depositCrossings[k];
2213 const Real fOld = depositCrossingsFOld[k];
2214 const RealVect depositDisp = depositCrossingsDisp[k];
2216 const RealVect pos = leaf.
position(i);
2220 RealVect correctedDisp = RealVect::Zero;
2223 correctedDisp = this->
reflectDiffusionHop(pos, depositDisp, fOld, dx, intersectionAlg, bisectStep);
2225 if (correctedDisp == RealVect::Zero) {
2230 pointParticles.
append(pos + correctedDisp, leaf.
weight(i));
2241 if (this->
m_verbosity > 5 && numTotalTested > 0) {
2243 :
"rho^dagger deposits";
2245 pout() << this->
m_name +
"::diffuseParticlesEulerMaruyama - "
2247 << numTotalTested <<
" " << what <<
" (" << (100.0 * numCrossings) / numTotalTested
2248 <<
"%) that would have crossed the EB";
2251 pout() <<
"; " << numReflectFailed <<
" could not be reflected into the fluid and were cancelled";
2258template <
typename I,
typename C,
typename R,
typename F>
2262 CH_TIME(
"ItoKMCGodunovStepper::diffuseCDREulerMaruyama");
2264 pout() << this->
m_name +
"::diffuseCDREulerMaruyama" << endl;
2269 for (
auto solverIt = this->
m_cdr->iterator(); solverIt.ok(); ++solverIt) {
2270 const RefCountedPtr<CdrSolver>& solver = solverIt();
2271 const RefCountedPtr<CdrSpecies>& species = solver->getSpecies();
2273 const int index = solverIt.index();
2274 const int Z = species->getChargeNumber();
2276 const EBAMRCellData& phi = solver->getPhi();
2280 if (solver->isDiffusive()) {
2281 solver->computeDivD(
m_cdrDivD[index], solver->getPhi(), a_dt,
true,
false,
false);
2291 if (solver->isDiffusive()) {
2307template <
typename I,
typename C,
typename R,
typename F>
2311 CH_TIME(
"ItoKMCGodunovStepper::stepEulerMaruyamaParticles");
2313 pout() << this->
m_name +
"::stepEulerMaruyamaParticles" << endl;
2316 for (
auto solverIt = (this->
m_ito)->iterator(); solverIt.ok(); ++solverIt) {
2317 RefCountedPtr<ItoSolver>& solver = solverIt();
2319 const bool mobile = solver->isMobile();
2320 const bool diffusive = solver->isDiffusive();
2322 const Real f = mobile ? a_dt : 0.0;
2323 const Real g = diffusive ? 1.0 : 0.0;
2325 if (mobile || diffusive) {
2326 for (
int lvl = 0; lvl <= (this->
m_amr)->getFinestLevel(); lvl++) {
2328 const DataIterator& dit = dbl.dataIterator();
2330 auto& particles = solver->getParticles(ItoSolver::WhichContainer::Bulk)[lvl];
2332 const int nbox = dit.size();
2334#pragma omp parallel for schedule(runtime)
2335 for (
int mybox = 0; mybox < nbox; mybox++) {
2336 const DataIndex& din = dit[mybox];
2340 double*
const pos[SpaceDim] = {
2342 double*
const oldPos[SpaceDim] = {D_DECL(leaf.template column<&ItoParticle::old_x>(),
2343 leaf.template column<&ItoParticle::old_y>(),
2344 leaf.template column<&ItoParticle::old_z>())};
2345 ParticleReal*
const vel[SpaceDim] = {D_DECL(leaf.template column<&ItoParticle::vx>(),
2346 leaf.template column<&ItoParticle::vy>(),
2347 leaf.template column<&ItoParticle::vz>())};
2348 ParticleReal*
const disp[SpaceDim] = {D_DECL(leaf.template column<&ItoParticle::scratch_x>(),
2349 leaf.template column<&ItoParticle::scratch_y>(),
2350 leaf.template column<&ItoParticle::scratch_z>())};
2354 for (
int dir = 0; dir < SpaceDim; dir++) {
2355 pos[dir][i] = oldPos[dir][i] + f * vel[dir][i] + g * disp[dir][i];
2364template <
typename I,
typename C,
typename R,
typename F>
2368 CH_TIME(
"ItoKMCGodunovStepper::stepEulerMaruyamaCDR");
2370 pout() << this->
m_name +
"::stepEulerMaruyamaCDR" << endl;
2373 for (
auto solverIt = (this->
m_cdr)->iterator(); solverIt.ok(); ++solverIt) {
2374 RefCountedPtr<CdrSolver>& solver = solverIt();
2376 const int index = solverIt.index();
2378 EBAMRCellData& phi = solver->getPhi();
2387 if (!solver->isDiffusive()) {
2395 if (solver->isMobile() || solver->isDiffusive()) {
2400 if (solver->isMobile()) {
2403 solver->computeDivF(this->
m_fluidScratch1, phi, a_dt, a_dt,
true,
true,
true);
2407 if (solver->isDiffusive()) {
2416 DataOps::floor(phi, 0.0, this->
m_amr->getVofIterator(this->m_fluidRealm, this->m_plasmaPhase));
2423template <
typename I,
typename C,
typename R,
typename F>
2427 CH_TIME(
"ItoKMCGodunovStepper::writeCheckpointHeader");
2428 if (this->m_verbosity > 5) {
2429 pout() << this->m_name +
"::writeCheckpointHeader" << endl;
2432 a_header.m_real[
"prev_dt"] = this->m_prevDt;
2433 a_header.m_real[
"physics_dt"] = this->m_physicsDt;
2434 a_header.m_int[
"checkpoint_particles"] = m_writeCheckpointParticles ? 1 : 0;
2439template <
typename I,
typename C,
typename R,
typename F>
2443 CH_TIME(
"ItoKMCGodunovStepper::readCheckpointHeader");
2444 if (this->m_verbosity > 5) {
2445 pout() << this->m_name +
"::readCheckpointHeader" << endl;
2448 this->m_prevDt = a_header.m_real[
"prev_dt"];
2449 this->m_physicsDt = a_header.m_real[
"physics_dt"];
2451 m_readCheckpointParticles = (a_header.m_int[
"checkpoint_particles"] != 0) ?
true : false;
2452 m_canRegridOnRestart = m_readCheckpointParticles;
2457template <
typename I,
typename C,
typename R,
typename F>
2461 CH_TIME(
"ItoKMCGodunovStepper::writeCheckpointData");
2462 if (this->m_verbosity > 5) {
2463 pout() << this->m_name +
"::writeCheckpointData" << endl;
2469 if (m_writeCheckpointParticles) {
2470 for (
int i = 0; i < (this->m_physics)->getNumItoSpecies(); i++) {
2471 const std::string identifierSigma =
"ItoKMCGodunovStepper::conductivityParticles_" + std::to_string(i);
2472 const std::string identifierRho =
"ItoKMCGodunovStepper::spaceChargeParticles_" + std::to_string(i);
2474 const ParticleContainer<NoPayload>& conductivityParticles = *m_conductivityParticles[i];
2475 const ParticleContainer<NoPayload>& rhoDaggerParticles = *m_rhoDaggerParticles[i];
2477 DischargeIO::writeCheckParticlesToHDF(a_handle, conductivityParticles[a_lvl], identifierSigma);
2478 DischargeIO::writeCheckParticlesToHDF(a_handle, rhoDaggerParticles[a_lvl], identifierRho);
2483 if (this->m_physics->getNumCdrSpecies() > 0) {
2484 write(a_handle, *m_semiImplicitRhoCDR[a_lvl],
"ItoKMCGodunovStepper::semiImplicitRhoCDR");
2485 write(a_handle, *m_semiImplicitConductivityCDR[a_lvl],
"ItoKMCGodunovStepper::semiImplicitConductivityCDR");
2491template <
typename I,
typename C,
typename R,
typename F>
2495 CH_TIME(
"ItoKMCGodunovStepper::readCheckpointData");
2496 if (this->m_verbosity > 5) {
2497 pout() << this->m_name +
"::readCheckpointData" << endl;
2503 if (m_readCheckpointParticles) {
2504 for (
int i = 0; i < (this->m_physics)->getNumItoSpecies(); i++) {
2505 const std::string identifierSigma =
"ItoKMCGodunovStepper::conductivityParticles_" + std::to_string(i);
2506 const std::string identifierRho =
"ItoKMCGodunovStepper::spaceChargeParticles_" + std::to_string(i);
2508 ParticleContainer<NoPayload>& conductivityParticles = *m_conductivityParticles[i];
2509 ParticleContainer<NoPayload>& rhoDaggerParticles = *m_rhoDaggerParticles[i];
2511 DischargeIO::readCheckParticlesFromHDF(a_handle, conductivityParticles[a_lvl], identifierSigma);
2512 DischargeIO::readCheckParticlesFromHDF(a_handle, rhoDaggerParticles[a_lvl], identifierRho);
2517 if (this->m_physics->getNumCdrSpecies() > 0) {
2518 const Interval interv(0, 0);
2520 read<EBCellFAB>(a_handle,
2521 *m_semiImplicitRhoCDR[a_lvl],
2522 "ItoKMCGodunovStepper::semiImplicitRhoCDR",
2523 this->m_amr->getGrids(this->m_fluidRealm)[a_lvl],
2527 read<EBCellFAB>(a_handle,
2528 *m_semiImplicitConductivityCDR[a_lvl],
2529 "ItoKMCGodunovStepper::semiImplicitConductivityCDR",
2530 this->m_amr->getGrids(this->m_fluidRealm)[a_lvl],
2537template <
typename I,
typename C,
typename R,
typename F>
2541 CH_TIME(
"ItoKMCGodunovStepper::prePlot");
2543 pout() <<
"ItoKMCGodunovStepper::prePlot" << endl;
2555 for (
auto solverIt = (this->
m_rte)->iterator(); solverIt.ok(); ++solverIt) {
2556 RefCountedPtr<McPhoto> solver = solverIt();
2558 EBAMRCellData& phi = solver->getPhi();
2561 solver->depositPhotons(phi, photons, DepositionType::NGP);
2565template <
typename I,
typename C,
typename R,
typename F>
2569 CH_TIME(
"ItoKMCGodunovStepper::postPlot");
2571 pout() << this->
m_name +
"::postPlot" << endl;
2579template <
typename I,
typename C,
typename R,
typename F>
2583 CH_TIME(
"ItoKMCGodunovStepper::plotParticles");
2585 pout() << this->
m_name +
"::plotParticles" << endl;
2590 ParmParse pp(this->
m_name.c_str());
2596 for (
auto solverIt = (this->
m_ito)->iterator(); solverIt.ok(); ++solverIt) {
2597 const RefCountedPtr<ItoSolver>& solver = solverIt();
2603 std::string cmd =
"mkdir -p 'particles/" + solver->getName() +
"'";
2605 if (procID() == 0) {
2606 success = system(cmd.c_str());
2610 MayDay::Error(
"ItoKMCGodunovStepper::plotParticles - could not create 'particles' directory");
2614 const std::string prefix =
"./particles/" + solver->getName() +
"/" + solver->getName();
2615 char fileChar[1000];
2616 sprintf(fileChar,
"%s.step%07d.%dd.h5part", prefix.c_str(), this->m_timeStep, SpaceDim);
2625#include <CD_NamespaceFooter.H>
Average
Various averaging methods.
Definition CD_Average.H:25
Agglomeration of useful data operations.
Silly, but useful functions that override standard Chombo HDF5 IO.
EBIntersection
Enum for putting some logic into how we think about intersection between particles and EBs.
Definition CD_EBIntersection.H:22
EBRepresentation
Enum for putting some logic into how we think about EBs. This is just a simply supporting class for v...
Definition CD_EBRepresentation.H:23
@ NGP
Put the particle's entire cloud in its own cell when that cell is a cut cell.
Definition CD_IrregularDeposition.H:48
Declaration of a class which uses a semi-implicit Godunov method for Ito plasma equations.
SpeciesSubset
Enum for selecting a subset of plasma species by mobility/diffusion/charge properties.
Definition CD_ItoKMCStepper.H:43
@ ChargedDiffusive
All charged, diffusive species.
Definition CD_ItoKMCStepper.H:51
@ AllMobileOrDiffusive
All species that are mobile or diffusive.
Definition CD_ItoKMCStepper.H:47
@ ChargedMobileAndDiffusive
All charged species that are both mobile and diffusive.
Definition CD_ItoKMCStepper.H:53
@ Stationary
All stationary (non-mobile, non-diffusive) species.
Definition CD_ItoKMCStepper.H:54
@ AllMobileAndDiffusive
All species that are both mobile and diffusive.
Definition CD_ItoKMCStepper.H:48
@ AllDiffusive
All species with nonzero diffusion coefficient.
Definition CD_ItoKMCStepper.H:46
@ AllMobile
All species with nonzero mobility.
Definition CD_ItoKMCStepper.H:45
@ Charged
All charged species (any mobility/diffusion).
Definition CD_ItoKMCStepper.H:49
@ All
All plasma species.
Definition CD_ItoKMCStepper.H:44
@ ChargedMobile
All charged, mobile species.
Definition CD_ItoKMCStepper.H:50
@ ChargedMobileOrDiffusive
All charged species that are mobile or diffusive.
Definition CD_ItoKMCStepper.H:52
Agglomeration of basic MPI reductions.
Declaration of a namespace for SIMD-decorated loops over SoA particles.
Declaration of a static class containing some common useful particle routines that would otherwise be...
CD_PARTICLE_REAL ParticleReal
Floating-point type a user may use for payload columns.
Definition CD_ParticleSoA.H:156
SoA payload for Monte Carlo radiative-transfer photons.
Implementation of CD_Timer.H.
Declaration of various useful units.
static void scale(MFAMRCellData &a_lhs, const Real &a_scale) noexcept
Scale data by factor.
Definition CD_DataOps.cpp:2564
static void floor(EBAMRCellData &a_lhs, const Real a_value, const Vector< RefCountedPtr< LayoutData< VoFIterator > > > &a_vofIter)
Floor values in data holder. This sets all values below a_value to a_value.
Definition CD_DataOps.cpp:1526
static void filterSmooth(EBAMRCellData &a_data, const Real a_alpha, const int a_stride, const bool a_zeroEB) noexcept
Apply a convolved filter phi = alpha * phi_i + 0.5*(1-alpha) * [phi_(i+s) + phi_(i-s)] in each direct...
Definition CD_DataOps.cpp:680
static void multiply(EBAMRCellData &a_lhs, const EBAMRCellData &a_rhs)
Multiply data holder by another data holder.
Definition CD_DataOps.cpp:2307
static void incr(MFAMRCellData &a_lhs, const MFAMRCellData &a_rhs, const Real a_scale) noexcept
Function which increments data in the form a_lhs = a_lhs + a_rhs*a_scale for all components.
Definition CD_DataOps.cpp:881
static void setValue(LevelData< MFInterfaceFAB< T > > &a_lhs, const T &a_value)
Set value in an MFInterfaceFAB data holder.
Definition CD_DataOpsImplem.H:24
static void copy(MFAMRCellData &a_dst, const MFAMRCellData &a_src)
Copy data from one data holder to another.
Definition CD_DataOps.cpp:1262
static void averageCellToFace(EBAMRFluxData &a_faceData, const EBAMRCellData &a_cellData, const Vector< ProblemDomain > &a_domains, Vector< RefCountedPtr< LayoutData< std::array< FaceIterator, SpaceDim > > > > &a_faceIter)
Average all components of the cell-centered data to faces (arithmetic, no tangential ghost faces).
Definition CD_DataOps.cpp:149
AMR-hierarchy container of computational particles, stored per patch in Struct-of-Arrays form.
Definition CD_ParticleContainer.H:123
void clearParticles()
Drop all valid particles on every level (keeps each leaf's arena capacity).
Definition CD_ParticleContainer.H:447
AMRParticlesSoA< P, Traits > & getParticles()
The valid particles on all levels.
Definition CD_ParticleContainer.H:322
static bool ebIntersectionRaycast(const RefCountedPtr< BaseIF > &a_impFunc, const RealVect &a_oldPos, const RealVect &a_newPos, const Real &a_tolerance, Real &a_s)
Compute the intersection point between a particle path and an implicit function using a ray-casting a...
Definition CD_ParticleOpsImplem.H:224
static bool ebIntersectionBisect(const RefCountedPtr< BaseIF > &a_impFunc, const RealVect &a_oldPos, const RealVect &a_newPos, const Real &a_bisectStep, Real &a_s)
Compute the intersection point between a particle path and an implicit function using a bisection alg...
Definition CD_ParticleOpsImplem.H:175
static void setData(ParticleContainer< P, Traits > &a_particles, const std::function< void(ParticleSoA< P, Traits > &, std::size_t)> &a_functor) noexcept
Set value function for SoA containers. Lets the user set particle parameters via a (leaf,...
Definition CD_ParticleOpsImplem.H:334
Arena-backed Struct-of-Arrays particle container for a single grid patch.
Definition CD_ParticleSoA.H:655
void append(const RealVect &a_position, const double a_weight)
Append one particle with a default-constructed payload.
Definition CD_ParticleSoA.H:962
RealVect position(const std::size_t a_index) const noexcept
Position of particle i as a RealVect (by value, assembled from the scalar columns).
Definition CD_ParticleSoA.H:1195
double & weight(const std::size_t a_index) noexcept
Weight of particle i.
Definition CD_ParticleSoA.H:1229
std::size_t size() const noexcept
Number of particles currently stored.
Definition CD_ParticleSoA.H:882
double * positionColumn(const int a_dir) noexcept
Raw position component column dir (double*, for SIMD kernels).
Definition CD_ParticleSoA.H:1144
P gather(const std::size_t a_index) const
Gather particle i's payload back into the AoS payload view.
Definition CD_ParticleSoA.H:1028
void catenate(ParticleSoA &a_other)
Move every particle of another container into this one, leaving a_other empty (catenate).
Definition CD_ParticleSoA.H:1009
void remove(const std::size_t a_index) noexcept
Remove particle i using swap-and-pop (O(1), does NOT preserve order).
Definition CD_ParticleSoA.H:1040
void reserve(const std::size_t a_capacity)
Ensure capacity for at least a_capacity particles (reallocates + moves on growth).
Definition CD_ParticleSoAImplem.H:88
Implementation of ItoKMCStepper that uses a semi-implicit split-step formalism for advancing the Ito-...
Definition CD_ItoKMCGodunovStepper.H:32
virtual void setupSemiImplicitPoisson(const Real a_dt) noexcept
Set up the semi-implicit Poisson solver.
Definition CD_ItoKMCGodunovStepperImplem.H:1727
virtual void regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) noexcept override
Regrid methods – puts all data on the new mesh.
Definition CD_ItoKMCGodunovStepperImplem.H:919
virtual void computeDiffusionTermCDR(EBAMRCellData &m_semiImplicitRhoCDR, const Real a_dt) noexcept
Compute the diffusion term for the CDR equations as well as the resulting CDR-contributions to the sp...
Definition CD_ItoKMCGodunovStepperImplem.H:2260
virtual void allocate() noexcept override
Allocate storage required for advancing the equations.
Definition CD_ItoKMCGodunovStepperImplem.H:101
bool m_readCheckpointParticles
Definition CD_ItoKMCGodunovStepper.H:222
@ ReflectIto
Reflect the particle's displacement about the boundary. The deposit follows the corrected hop.
Definition CD_ItoKMCGodunovStepper.H:201
@ Inside
Deposit from inside the solid, into a covered cell that contributes nothing to rho.
Definition CD_ItoKMCGodunovStepper.H:198
@ Cancel
Deposit at the pre-hop position. Conserves charge, but biases density towards where it started.
Definition CD_ItoKMCGodunovStepper.H:199
Vector< RefCountedPtr< ParticleContainer< NoPayload > > > m_rhoDaggerParticles
Definition CD_ItoKMCGodunovStepper.H:314
virtual Real advance(const Real a_dt) override
Advance the Ito-Poisson-KMC system over a_dt.
Definition CD_ItoKMCGodunovStepperImplem.H:529
EBAMRCellData m_particleScratchSum
Definition CD_ItoKMCGodunovStepper.H:361
bool m_emitSecondaryParticlesBeforeReactions
If true, particles will be emitted before the reactive step.
Definition CD_ItoKMCGodunovStepper.H:238
virtual void allocateInternals() noexcept override
Allocate "internal" storage.
Definition CD_ItoKMCGodunovStepperImplem.H:134
Real m_maxFieldAbort
Definition CD_ItoKMCGodunovStepper.H:288
Real m_reactiveFieldCentering
Definition CD_ItoKMCGodunovStepper.H:297
virtual void stepEulerMaruyamaCDR(const Real a_dt) noexcept
Step the CDR equations according to the regular Euler-Maruyama scheme.
Definition CD_ItoKMCGodunovStepperImplem.H:2366
EBAMRCellData m_particleScratchSumSolid
Definition CD_ItoKMCGodunovStepper.H:373
DiffusiveDeposit m_diffusiveDeposit
Definition CD_ItoKMCGodunovStepper.H:243
virtual void computeConductivities(const Vector< RefCountedPtr< ParticleContainer< NoPayload > > > &a_particles, const bool a_useStoredCdrConductivity) noexcept
Compute all conductivities (cell, face, and EB) from the input point particles.
Definition CD_ItoKMCGodunovStepperImplem.H:1449
WhichAlgorithm m_algorithm
Which advancement algorithm to use.
Definition CD_ItoKMCGodunovStepper.H:248
EBAMRCellData m_semiImplicitRhoCDR
Storage for CDR densities used during the semi-implicit solve.
Definition CD_ItoKMCGodunovStepper.H:321
virtual void parseAlgorithm() noexcept
Parse advancement algorithm.
Definition CD_ItoKMCGodunovStepperImplem.H:236
virtual void clearPointParticles(const Vector< RefCountedPtr< ParticleContainer< NoPayload > > > &a_particles, const SpeciesSubset a_subset) noexcept
Clear the input particle data holders.
Definition CD_ItoKMCGodunovStepperImplem.H:1313
int m_condFilterNum
Number of filterings of the conductivity.
Definition CD_ItoKMCGodunovStepper.H:273
Vector< RefCountedPtr< ParticleContainer< NoPayload > > > m_conductivityParticles
Definition CD_ItoKMCGodunovStepper.H:303
virtual void postPlot() noexcept override
Perform post-plot operations.
Definition CD_ItoKMCGodunovStepperImplem.H:2567
EBAMRCellData m_reactiveElectricField
Definition CD_ItoKMCGodunovStepper.H:352
virtual Real computeDt() override
Compute a time step used for the advance method.
Definition CD_ItoKMCGodunovStepperImplem.H:509
Vector< EBAMRCellData > m_cdrDivD
Storage for the conservative finite-volume approximation of kappa*div(D*grad(phi)) for the CDR equati...
Definition CD_ItoKMCGodunovStepper.H:345
EBAMRCellData m_scratchSemiImplicitRhoCDR
Scratch storage for CDR contribution to space charge density.
Definition CD_ItoKMCGodunovStepper.H:334
virtual void diffuseParticlesEulerMaruyama(Vector< RefCountedPtr< ParticleContainer< NoPayload > > > &a_rhoDaggerParticles, const Real a_dt) noexcept
Perform the explicit half of the Ito advance in the Euler-Maruyama step.
Definition CD_ItoKMCGodunovStepperImplem.H:1986
virtual void parseSecondaryEmissionSpecification() noexcept
Parse when secondary particles are emitted.
Definition CD_ItoKMCGodunovStepperImplem.H:311
virtual void parseFiltering() noexcept
Parse filter settings.
Definition CD_ItoKMCGodunovStepperImplem.H:261
virtual void parseRuntimeOptions() noexcept override
Parse run-time options.
Definition CD_ItoKMCGodunovStepperImplem.H:216
Real m_condFilterAlpha
Factor for strided filter. Alpha=0.5 yields a bilinear filter.
Definition CD_ItoKMCGodunovStepper.H:283
EBAMRCellData m_particleScratchSolid
Definition CD_ItoKMCGodunovStepper.H:367
virtual void depositPointParticles(const Vector< RefCountedPtr< ParticleContainer< NoPayload > > > &a_particles, const SpeciesSubset a_subset) noexcept
Deposit the input point particles on the mesh.
Definition CD_ItoKMCGodunovStepperImplem.H:1211
virtual bool solvePoisson() noexcept override
Solve the electrostatic problem.
Definition CD_ItoKMCGodunovStepperImplem.H:1862
bool m_canRegridOnRestart
Definition CD_ItoKMCGodunovStepper.H:228
virtual void computeFaceConductivity() noexcept
Compute the cell-centered conductivity.
Definition CD_ItoKMCGodunovStepperImplem.H:1550
virtual void computeCellConductivity(EBAMRCellData &a_conductivityCell, const Vector< RefCountedPtr< ParticleContainer< NoPayload > > > &a_particles, const bool a_useStoredCdrConductivity) noexcept
Compute the cell-centered conductivity.
Definition CD_ItoKMCGodunovStepperImplem.H:1464
EBAMRCellData m_fluidScratchSolid
Definition CD_ItoKMCGodunovStepper.H:379
int m_condFilterMaxStride
Stride when filtering the conductivity.
Definition CD_ItoKMCGodunovStepper.H:278
EBAMRCellData m_semiImplicitConductivityCDR
Storage for conductivity term due to mobile CDR species.
Definition CD_ItoKMCGodunovStepper.H:328
virtual void removeCoveredPointParticles(Vector< RefCountedPtr< ParticleContainer< NoPayload > > > &a_particles, const EBRepresentation a_representation, const Real a_tolerance) const noexcept
Remove covered particles.
Definition CD_ItoKMCGodunovStepperImplem.H:1764
bool m_rhoDaggerHop
Definition CD_ItoKMCGodunovStepper.H:217
virtual void remapPointParticles(Vector< RefCountedPtr< ParticleContainer< NoPayload > > > &a_particles, const SpeciesSubset a_subset) noexcept
Remap the input point particles.
Definition CD_ItoKMCGodunovStepperImplem.H:1106
virtual void prePlot() noexcept override
Perform pre-plot operations.
Definition CD_ItoKMCGodunovStepperImplem.H:2539
virtual ~ItoKMCGodunovStepper()
Destructor. Does nothing.
Definition CD_ItoKMCGodunovStepperImplem.H:75
bool m_extendConductivityEB
Definition CD_ItoKMCGodunovStepper.H:233
virtual void setOldPositions() noexcept
Set the starting positions for the ItoSolver particles.
Definition CD_ItoKMCGodunovStepperImplem.H:1067
virtual void parseDiffusiveDeposit() noexcept
Parse what happens to a diffusion hop that would cross the embedded boundary.
Definition CD_ItoKMCGodunovStepperImplem.H:439
bool m_writeCheckpointParticles
Definition CD_ItoKMCGodunovStepper.H:207
virtual void parseRhoDaggerHop() noexcept
Parse whether the stochastic diffusion hop enters rho^dagger.
Definition CD_ItoKMCGodunovStepperImplem.H:475
virtual void computeSemiImplicitRho() noexcept
Set up the space charge density for the regrid operation.
Definition CD_ItoKMCGodunovStepperImplem.H:1585
virtual void advanceEulerMaruyama(const Real a_dt) noexcept
Definition CD_ItoKMCGodunovStepperImplem.H:1901
virtual void preRegrid(const int a_lmin, const int a_oldFinestLevel) noexcept override
Perform pre-regrid operations.
Definition CD_ItoKMCGodunovStepperImplem.H:880
virtual void registerOperators() noexcept override
Register operators used for the simulation.
Definition CD_ItoKMCGodunovStepperImplem.H:85
virtual RealVect reflectDiffusionHop(const RealVect &a_pos, const RealVect &a_disp, const Real a_fOld, const Real a_dx, const EBIntersection a_intersectionAlg, const Real a_bisectStep) const noexcept
Reflect a rho^dagger deposit displacement that crosses the embedded boundary back into the fluid.
Definition CD_ItoKMCGodunovStepperImplem.H:342
EBAMRCellData m_scratchSemiImplicitConductivityCDR
Scratch storage for CDR contribution to conductivity.
Definition CD_ItoKMCGodunovStepper.H:340
virtual void plotParticles() const noexcept
Utility function for plotting the ItoSolver particles. These are written in a particles folder.
Definition CD_ItoKMCGodunovStepperImplem.H:2581
ItoKMCGodunovStepper()=delete
Disallowed default constructor. Use the full constructor.
Vector< RefCountedPtr< ParticleContainer< NoPayload > > > m_irregularParticles
Definition CD_ItoKMCGodunovStepper.H:308
Real m_rhoFilterAlpha
Factor for strided filter. Alpha=0.5 yields a bilinear filter.
Definition CD_ItoKMCGodunovStepper.H:268
int m_rhoFilterNum
Number of filterings when computing the semi-implicit space charge density.
Definition CD_ItoKMCGodunovStepper.H:258
Timer m_timer
Definition CD_ItoKMCGodunovStepper.H:253
virtual void parseReactiveFieldCentering() noexcept
Parse the time-centering of the electric field used for the reactive substep.
Definition CD_ItoKMCGodunovStepperImplem.H:489
virtual void parseCheckpointParticles() noexcept
Parse checkpoint-restart functionality.
Definition CD_ItoKMCGodunovStepperImplem.H:297
virtual void barrier() const noexcept
Set an MPI barrier if using debug mode.
Definition CD_ItoKMCGodunovStepperImplem.H:182
virtual void parseOptions() noexcept override
Parse options.
Definition CD_ItoKMCGodunovStepperImplem.H:196
int m_rhoFilterMaxStride
Stride when filtering the space charge density.
Definition CD_ItoKMCGodunovStepper.H:263
virtual void computeCdrConductivity() noexcept
Compute the CDR contribution to the semi-implicit conductivity, i.e. sum(|Z| * phi * mu).
Definition CD_ItoKMCGodunovStepperImplem.H:1419
virtual void stepEulerMaruyamaParticles(const Real a_dt) noexcept
Step the particles according to the regular Euler-Maruyama scheme.
Definition CD_ItoKMCGodunovStepperImplem.H:2309
virtual void copyConductivityParticles(Vector< RefCountedPtr< ParticleContainer< NoPayload > > > &a_conductivityParticles) noexcept
Copy particles from the ItoSolver into PointParticles whose weight are ItoParticle::m_weight * ItoPar...
Definition CD_ItoKMCGodunovStepperImplem.H:1804
Abstract TimeStepper for the Ito-KMC-Poisson system of equations.
Definition CD_ItoKMCStepper.H:66
bool m_abortOnFailure
Definition CD_ItoKMCStepper.H:475
RefCountedPtr< SurfaceODESolver< 1 > > m_sigmaSolver
Definition CD_ItoKMCStepper.H:439
EBAMRCellData m_conductivityCell
Definition CD_ItoKMCStepper.H:721
virtual void parseRuntimeOptions() noexcept override
Parse runtime configurable options.
Definition CD_ItoKMCStepperImplem.H:173
std::string m_name
Definition CD_ItoKMCStepper.H:402
phase::which_phase m_plasmaPhase
Definition CD_ItoKMCStepper.H:408
bool m_profile
Definition CD_ItoKMCStepper.H:500
virtual void computeElectricField(EBAMRCellData &a_electricField, const phase::which_phase a_phase) const noexcept
Definition CD_ItoKMCStepperImplem.H:1978
EBAMRCellData m_electricFieldParticle
Definition CD_ItoKMCStepper.H:791
virtual void computeSpaceChargeDensity() noexcept
Definition CD_ItoKMCStepperImplem.H:2005
virtual void fillNeutralDensity() noexcept
Definition CD_ItoKMCStepperImplem.H:1880
EBAMRCellData m_physicsPlotVariables
Definition CD_ItoKMCStepper.H:710
virtual void remapParticles(const SpeciesSubset a_speciesSubset) noexcept
Definition CD_ItoKMCStepperImplem.H:2728
RefCountedPtr< FieldSolver > m_fieldSolver
Definition CD_ItoKMCStepper.H:434
virtual void registerOperators() noexcept override
Register operators used for the simulation.
Definition CD_ItoKMCStepperImplem.H:1651
EBAMRCellData m_particleScratch1
Definition CD_ItoKMCStepper.H:824
virtual void multiplyCdrVelocitiesByMobilities() noexcept
Definition CD_ItoKMCStepperImplem.H:3023
virtual void intersectParticles(const SpeciesSubset a_speciesSubset, const bool a_delete, const std::function< void(ParticleSoA< ItoParticle > &, std::size_t)> a_nonDeletionModifier=[](ParticleSoA< ItoParticle > &, std::size_t) -> void { return;}) noexcept
Definition CD_ItoKMCStepperImplem.H:2300
ItoKMCStepper() noexcept
Definition CD_ItoKMCStepperImplem.H:98
virtual void depositParticles(const SpeciesSubset a_speciesSubset) noexcept
Definition CD_ItoKMCStepperImplem.H:2843
Vector< EBAMRCellData > m_cdrMobilities
Definition CD_ItoKMCStepper.H:660
virtual void parseOptions() noexcept
Parse options.
Definition CD_ItoKMCStepperImplem.H:152
virtual void preRegrid(const int a_lmin, const int a_oldFinestLevel) noexcept override
Perform pre-regrid operations - storing relevant data from the old grids.
Definition CD_ItoKMCStepperImplem.H:1703
EBAMRCellData m_fluidScratch1
Definition CD_ItoKMCStepper.H:814
std::string m_fluidRealm
Definition CD_ItoKMCStepper.H:392
virtual void computeDriftVelocities() noexcept
Definition CD_ItoKMCStepperImplem.H:3049
EBAMRCellData m_electricFieldFluid
Definition CD_ItoKMCStepper.H:786
Real m_prevDt
Definition CD_ItoKMCStepper.H:541
std::string m_particleRealm
Definition CD_ItoKMCStepper.H:397
RefCountedPtr< CdrLayout< CdrSolver > > m_cdr
Definition CD_ItoKMCStepper.H:424
virtual Real computeDt() override
Compute a time step used for the advance method.
Definition CD_ItoKMCStepperImplem.H:1522
virtual void coarsenCDRSolvers(const bool a_interpGhosts) noexcept
Definition CD_ItoKMCStepperImplem.H:5110
EBAMRFluxData m_conductivityFace
Definition CD_ItoKMCStepper.H:727
virtual void computeDiffusionCoefficients() noexcept
Definition CD_ItoKMCStepperImplem.H:3307
virtual void allocateInternals() noexcept
Allocate "internal" storage.
Definition CD_ItoKMCStepperImplem.H:621
EBAMRIVData m_conductivityEB
Definition CD_ItoKMCStepper.H:733
virtual void setCdrVelocityFunctions() noexcept
Definition CD_ItoKMCStepperImplem.H:2989
RefCountedPtr< ItoKMCPhysics > m_physics
Definition CD_ItoKMCStepper.H:414
virtual void allocate() noexcept override
Allocate storage for solvers.
Definition CD_ItoKMCStepperImplem.H:603
RefCountedPtr< RtLayout< McPhoto > > m_rte
Definition CD_ItoKMCStepper.H:429
RefCountedPtr< ItoLayout< ItoSolver > > m_ito
Definition CD_ItoKMCStepper.H:419
virtual void prePlot() noexcept override
Perform pre-plot operations.
Definition CD_ItoKMCStepperImplem.H:1670
virtual void setItoVelocityFunctions() noexcept
Definition CD_ItoKMCStepperImplem.H:2958
int m_verbosity
Class verbosity.
Definition CD_TimeStepper.H:343
RefCountedPtr< ComputationalGeometry > m_computationalGeometry
Computational geometry.
Definition CD_TimeStepper.H:375
int m_timeStep
Time step.
Definition CD_TimeStepper.H:348
RefCountedPtr< AmrMesh > m_amr
AmrMesh.
Definition CD_TimeStepper.H:370
Class which is used for run-time monitoring of events.
Definition CD_Timer.H:32
void writeH5Part(std::string a_filename, const ParticleContainer< P, Traits > &a_particles, RealVect a_shift, Real a_time) noexcept
Write an SoA particle container to an H5Part file (quick visualization).
Definition CD_DischargeIOImplem.H:201
Real sum(const Real &a_value) noexcept
Compute the sum across all MPI ranks.
Definition CD_ParallelOpsImplem.H:354
void barrier() noexcept
MPI barrier.
Definition CD_ParallelOpsImplem.H:26
ALWAYS_INLINE void loop(const ParticleSoA< P, Traits > &a_soa, Functor &&a_kernel)
Launch a kernel over every particle in a ParticleSoA, decorating the loop with CD_PRAGMA_SIMD.
Definition CD_ParticleLoops.H:87
void deleteParticles(ParticleSoA< P, Traits > &a_particles, const Real a_weightThresh) noexcept
Remove particles from an SoA container if their weight is below the threshold (swap-and-pop).
Definition CD_ParticleManagementImplem.H:788
constexpr Real eps0
Permittivity of free space.
Definition CD_Units.H:30
constexpr Real Qe
Elementary charge.
Definition CD_Units.H:35
@ solid
Solid (dielectric) phase.
Definition CD_MultiFluidIndexSpace.H:40
@ gas
Gas phase.
Definition CD_MultiFluidIndexSpace.H:39
SoA payload for ItoSolver particles, i.e. drifting Brownian walkers.
Definition CD_ItoParticle.H:31
ParticleReal scratch_x
Scratch vector storage, x-component.
Definition CD_ItoParticle.H:49
ParticleReal scratch_y
Scratch vector storage, y-component.
Definition CD_ItoParticle.H:50
ParticleReal scratch_z
Scratch vector storage, z-component.
Definition CD_ItoParticle.H:52