12 #ifndef CD_ItoKMCGodunovStepperImplem_H
13 #define CD_ItoKMCGodunovStepperImplem_H
16 #include <ParmParse.H>
26 #include <CD_NamespaceHeader.H>
28 using namespace Physics::ItoKMC;
30 template <
typename I,
typename C,
typename R,
typename F>
34 CH_TIME(
"ItoKMCGodunovStepper::ItoKMCGodunovStepper");
36 this->
m_name =
"ItoKMCGodunovStepper";
48 template <
typename I,
typename C,
typename R,
typename F>
51 CH_TIME(
"ItoKMCGodunovStepper::~ItoKMCGodunovStepper");
52 if (this->m_verbosity > 5) {
53 pout() <<
"ItoKMCGodunovStepper::~ItoKMCGodunovStepper" << endl;
57 template <
typename I,
typename C,
typename R,
typename F>
61 CH_TIME(
"ItoKMCGodunovStepper::allocate");
62 if (this->m_verbosity > 5) {
63 pout() <<
"ItoKMCGodunovStepper::allocate" << endl;
71 const int numItoSpecies = this->m_physics->getNumItoSpecies();
73 m_conductivityParticles.resize(numItoSpecies);
74 m_irregularParticles.resize(numItoSpecies);
75 m_rhoDaggerParticles.resize(numItoSpecies);
77 for (
auto solverIt = (this->m_ito)->iterator(); solverIt.ok(); ++solverIt) {
78 const int idx = solverIt.index();
80 m_conductivityParticles[idx] = RefCountedPtr<ParticleContainer<PointParticle>>(
85 (this->m_amr)->allocate(*m_conductivityParticles[idx], this->m_particleRealm);
86 (this->m_amr)->allocate(*m_irregularParticles[idx], this->m_particleRealm);
87 (this->m_amr)->allocate(*m_rhoDaggerParticles[idx], this->m_particleRealm);
91 template <
typename I,
typename C,
typename R,
typename F>
95 CH_TIME(
"ItoKMCGodunovStepper::allocateInternals");
96 if (this->m_verbosity > 5) {
97 pout() << this->m_name +
"::allocateInternals" << endl;
102 const int numCdrSpecies = this->m_physics->getNumCdrSpecies();
104 m_cdrDivD.resize(numCdrSpecies);
105 for (
int i = 0; i < numCdrSpecies; i++) {
106 this->m_amr->allocate(m_cdrDivD[i], this->m_fluidRealm, this->m_plasmaPhase, 1);
109 this->m_amr->allocate(m_semiImplicitRhoCDR, this->m_fluidRealm, this->m_plasmaPhase, 1);
110 this->m_amr->allocate(m_semiImplicitConductivityCDR, this->m_fluidRealm, this->m_plasmaPhase, 1);
113 template <
typename I,
typename C,
typename R,
typename F>
117 CH_TIME(
"ItoKMCGodunovStepper::barrier");
118 if (this->m_verbosity > 5) {
119 pout() << this->m_name +
"::barrier" << endl;
122 if ((this->m_profile)) {
127 template <
typename I,
typename C,
typename R,
typename F>
131 CH_TIME(
"ItoKMCGodunovStepper::parseOptions");
132 if (this->m_verbosity > 5) {
133 pout() << this->m_name +
"::parseOptions" << endl;
138 this->parseAlgorithm();
139 this->parseCheckpointParticles();
142 template <
typename I,
typename C,
typename R,
typename F>
146 CH_TIME(
"ItoKMCGodunovStepper::parseRuntimeOptions");
147 if (this->m_verbosity > 5) {
148 pout() << this->m_name +
"::parseRuntimeOptions" << endl;
153 this->parseAlgorithm();
154 this->parseCheckpointParticles();
157 template <
typename I,
typename C,
typename R,
typename F>
161 CH_TIME(
"ItoKMCGodunovStepper::parseAlgorithm");
162 if (this->m_verbosity > 5) {
163 pout() << this->m_name +
"::parseAlgorithm" << endl;
166 ParmParse pp(this->m_name.c_str());
169 pp.get(
"extend_conductivity", m_extendConductivityEB);
170 pp.get(
"smooth_conductivity", m_smoothConductivity);
171 pp.get(
"algorithm", str);
174 if (str ==
"euler_maruyama") {
175 m_algorithm = WhichAlgorithm::EulerMaruyama;
178 MayDay::Abort(
"ItoKMCGodunovStepper::parseAlgorithm - unknown algorithm requested");
182 template <
typename I,
typename C,
typename R,
typename F>
186 CH_TIME(
"ItoKMCGodunovStepper::parseCheckpointParticles");
187 if (this->m_verbosity > 5) {
188 pout() << this->m_name +
"::parseCheckpointParticles" << endl;
191 ParmParse pp(this->m_name.c_str());
193 pp.query(
"checkpoint_particles", m_writeCheckpointParticles);
196 template <
typename I,
typename C,
typename R,
typename F>
200 CH_TIME(
"ItoKMCGodunovStepper::advance");
201 if (this->m_verbosity > 5) {
202 pout() << this->m_name +
"::advance" << endl;
205 auto debugCharge = [
this](
const std::string a_message) ->
void {
206 const Real Qtot = this->computeTotalCharge();
208 std::cout << a_message <<
" = " << Qtot <<
"\n";
216 m_canRegridOnRestart =
true;
218 m_timer =
Timer(
"ItoKMCGodunovStepper::advance");
223 this->m_prevDt = a_dt;
226 m_timer.startEvent(
"Deposit photons");
227 for (
auto solverIt = (this->m_rte)->iterator(); solverIt.ok(); ++solverIt) {
228 RefCountedPtr<McPhoto> solver = solverIt();
235 m_timer.stopEvent(
"Deposit photons");
239 switch (m_algorithm) {
240 case WhichAlgorithm::EulerMaruyama: {
241 this->advanceEulerMaruyama(a_dt);
246 MayDay::Abort(
"ItoKMCGodunovStepper::advance - logic bust");
254 m_timer.startEvent(
"EB/Particle intersection");
255 if (m_extendConductivityEB) {
264 auto nonDeletionModifier = [](
ItoParticle& p) ->
void {
267 auto removeCrit = [](
const ItoParticle& p) ->
bool {
268 return p.tmpReal() < 0.0;
272 for (
auto it = this->m_ito->iterator(); it.ok(); ++it) {
273 ParticleOps::setData<ItoParticle>(it()->getParticles(ItoSolver::WhichContainer::Bulk), setFlag);
277 const bool deleteParticles =
false;
278 this->intersectParticles(SpeciesSubset::AllMobileOrDiffusive, deleteParticles, nonDeletionModifier);
281 for (
auto it = this->m_ito->iterator(); it.ok(); ++it) {
282 const RefCountedPtr<ItoSolver>& solver = it();
283 const RefCountedPtr<ItoSpecies>& species = solver->getSpecies();
285 const int idx = it.index();
286 const int Z = species->getChargeNumber();
294 if (Z != 0 && solver->isMobile()) {
295 for (
int lvl = 0; lvl <= (this->m_amr)->getFinestLevel(); lvl++) {
296 const DisjointBoxLayout& dbl = (this->m_amr)->getGrids((this->m_particleRealm))[lvl];
297 const DataIterator& dit = dbl.dataIterator();
299 const int nbox = dit.size();
301 #pragma omp parallel for schedule(runtime)
302 for (
int mybox = 0; mybox < nbox; mybox++) {
303 const DataIndex& din = dit[mybox];
305 List<PointParticle>& pointParticles = irregParticles[lvl][din].listItems();
306 const List<ItoParticle>& patchParticles = bulkParticles[lvl][din].listItems();
308 for (ListIterator<ItoParticle> lit(patchParticles); lit.ok(); ++lit) {
313 const Real& weight = p.
weight();
314 const Real& mobility = p.
mobility();
325 for (
auto it = this->m_ito->iterator(); it.ok(); ++it) {
327 ParticleOps::removeParticles<ItoParticle>(bulkParticles, removeCrit);
331 const bool deleteParticles =
true;
333 this->intersectParticles(SpeciesSubset::AllMobileOrDiffusive, deleteParticles);
338 for (
auto it = this->m_ito->iterator(); it.ok(); ++it) {
339 const RefCountedPtr<ItoSolver>& solver = it();
344 this->m_amr->transferIrregularParticles(ebParticles, bulkParticles, this->m_plasmaPhase);
347 m_timer.stopEvent(
"EB/Particle intersection");
354 m_timer.startEvent(
"Photon transport");
355 this->advancePhotons(a_dt);
356 m_timer.stopEvent(
"Photon transport");
359 if ((this->m_physics)->needGradients()) {
360 m_timer.startEvent(
"Gradient calculation");
361 (this->m_ito)->depositParticles();
362 this->computeDensityGradients();
363 m_timer.stopEvent(
"Gradient calculation");
368 m_timer.startEvent(
"Sort by cell");
369 (this->m_ito)->organizeParticlesByCell(ItoSolver::WhichContainer::Bulk);
370 this->sortPhotonsByCell(McPhoto::WhichContainer::Bulk);
371 this->sortPhotonsByCell(McPhoto::WhichContainer::Source);
372 m_timer.stopEvent(
"Sort by cell");
376 m_timer.startEvent(
"Reaction network");
377 this->advanceReactionNetwork(a_dt);
378 m_timer.stopEvent(
"Reaction network");
382 m_timer.startEvent(
"Sort by patch");
383 (this->m_ito)->organizeParticlesByPatch(ItoSolver::WhichContainer::Bulk);
384 this->sortPhotonsByPatch(McPhoto::WhichContainer::Bulk);
385 this->sortPhotonsByPatch(McPhoto::WhichContainer::Source);
386 m_timer.stopEvent(
"Sort by patch");
391 m_timer.startEvent(
"EB particle injection");
392 this->fillSecondaryEmissionEB(a_dt);
393 this->resolveSecondaryEmissionEB(a_dt);
394 m_timer.stopEvent(
"EB particle injection");
399 m_timer.startEvent(
"Remove covered");
400 this->removeCoveredParticles(SpeciesSubset::AllMobileOrDiffusive, EBRepresentation::Discrete, this->m_toleranceEB);
401 m_timer.stopEvent(
"Remove covered");
404 for (
auto solverIt = (this->m_ito)->iterator(); solverIt.ok(); ++solverIt) {
405 solverIt()->clear(ItoSolver::WhichContainer::EB);
406 solverIt()->clear(ItoSolver::WhichContainer::Domain);
411 m_timer.startEvent(
"Post-compute v");
412 this->computeDriftVelocities();
413 m_timer.stopEvent(
"Post-compute v");
416 m_timer.startEvent(
"Post-compute D");
417 this->computeDiffusionCoefficients();
418 m_timer.stopEvent(
"Post-compute D");
420 if ((this->m_profile)) {
421 m_timer.eventReport(pout(),
false);
429 template <
typename I,
typename C,
typename R,
typename F>
433 CH_TIME(
"ItoKMCGodunovStepper::preRegrid");
434 if (this->m_verbosity > 5) {
435 pout() <<
"ItoKMCGodunovStepper::preRegrid" << endl;
438 const int numItoSpecies = (this->m_physics)->getNumItoSpecies();
439 const int numCdrSpecies = (this->m_physics)->getNumCdrSpecies();
440 const int numPlasmaSpecies = (this->m_physics)->getNumPlasmaSpecies();
441 const int numPhotonSpecies = (this->m_physics)->getNumPhotonSpecies();
445 for (
auto solverIt = (this->m_ito)->iterator(); solverIt.ok(); ++solverIt) {
446 const int idx = solverIt.index();
448 m_conductivityParticles[idx]->preRegrid(a_lmin);
449 m_irregularParticles[idx]->preRegrid(a_lmin);
450 m_rhoDaggerParticles[idx]->preRegrid(a_lmin);
453 this->m_amr->allocate(m_scratchSemiImplicitRhoCDR, this->m_fluidRealm, this->m_plasmaPhase, 1);
454 this->m_amr->allocate(m_scratchSemiImplicitConductivityCDR, this->m_fluidRealm, this->m_plasmaPhase, 1);
456 DataOps::copy(m_scratchSemiImplicitRhoCDR, m_semiImplicitRhoCDR);
457 DataOps::copy(m_scratchSemiImplicitConductivityCDR, m_semiImplicitConductivityCDR);
460 for (
int i = 0; i < numCdrSpecies; i++) {
461 m_cdrDivD[i].clear();
464 m_semiImplicitRhoCDR.clear();
465 m_semiImplicitConductivityCDR.clear();
468 template <
typename I,
typename C,
typename R,
typename F>
471 const int a_oldFinestLevel,
472 const int a_newFinestLevel) noexcept
474 CH_TIME(
"ItoKMCGodunovStepper::regrid");
475 if (this->m_verbosity > 5) {
476 pout() <<
"ItoKMCGodunovStepper::regrid" << endl;
479 m_timer =
Timer(
"ItoKMCGodunovStepper::regrid");
483 if (!m_canRegridOnRestart) {
484 const std::string baseErr =
"ItoKMCGodunovStepper::regrid -- can't regrid because";
485 const std::string err1 =
"checkpoint file does not contain particles. Set Driver.initial_regrids=0";
487 pout() << baseErr + err1 << endl;
489 MayDay::Error((baseErr + err1).c_str());
493 m_timer.startEvent(
"Regrid ItoSolver");
494 (this->m_ito)->regrid(a_lmin, a_oldFinestLevel, a_newFinestLevel);
495 if (this->m_timeStep == 0) {
499 (this->m_ito)->depositParticles();
501 m_timer.stopEvent(
"Regrid ItoSolver");
503 m_timer.startEvent(
"Regrid CdrSolver");
504 (this->m_cdr)->regrid(a_lmin, a_oldFinestLevel, a_newFinestLevel);
505 m_timer.stopEvent(
"Regrid CdrSolver");
507 m_timer.startEvent(
"Regrid FieldSolver");
508 (this->m_fieldSolver)->regrid(a_lmin, a_oldFinestLevel, a_newFinestLevel);
509 m_timer.stopEvent(
"Regrid FieldSolver");
511 m_timer.startEvent(
"Regrid RTE");
512 (this->m_rte)->regrid(a_lmin, a_oldFinestLevel, a_newFinestLevel);
513 m_timer.stopEvent(
"Regrid RTE");
515 m_timer.startEvent(
"Regrid SurfaceODESolver");
516 this->m_sigmaSolver->regrid(a_lmin, a_oldFinestLevel, a_newFinestLevel);
517 m_timer.stopEvent(
"Regrid SurfaceODESolver");
520 m_timer.startEvent(
"Allocate internals");
521 this->allocateInternals();
522 m_timer.stopEvent(
"Allocate internals");
525 m_timer.startEvent(
"Remap algorithm-particles");
526 for (
auto solverIt = (this->m_ito)->iterator(); solverIt.ok(); ++solverIt) {
527 const int idx = solverIt.index();
528 (this->m_amr)->remapToNewGrids(*m_rhoDaggerParticles[idx], a_lmin, a_newFinestLevel);
529 (this->m_amr)->remapToNewGrids(*m_conductivityParticles[idx], a_lmin, a_newFinestLevel);
530 (this->m_amr)->remapToNewGrids(*m_irregularParticles[idx], a_lmin, a_newFinestLevel);
532 m_timer.stopEvent(
"Remap algorithm-particles");
535 this->m_amr->interpToNewGrids(m_semiImplicitRhoCDR,
536 m_scratchSemiImplicitRhoCDR,
541 EBCoarseToFineInterp::Type::ConservativePWC);
543 this->m_amr->interpToNewGrids(m_semiImplicitConductivityCDR,
544 m_scratchSemiImplicitConductivityCDR,
549 EBCoarseToFineInterp::Type::ConservativePWC);
553 m_timer.startEvent(
"Setup field solver");
554 (this->m_fieldSolver)->setupSolver();
555 this->computeConductivities(m_conductivityParticles);
556 this->setupSemiImplicitPoisson(this->m_prevDt);
557 m_timer.stopEvent(
"Setup field solver");
560 m_timer.startEvent(
"Solve Poisson");
561 if (this->m_timeStep == 0) {
562 this->computeSpaceChargeDensity();
565 this->depositPointParticles(m_rhoDaggerParticles, SpeciesSubset::All);
566 this->computeSemiImplicitRho();
569 const bool converged = this->solvePoisson();
572 const std::string errMsg =
"ItoKMCGodunovStepper::regrid - Poisson solve did not converge after regrid";
574 pout() << errMsg << endl;
576 if (this->m_abortOnFailure) {
577 MayDay::Error(errMsg.c_str());
580 m_timer.stopEvent(
"Solve Poisson");
583 if (this->m_regridSuperparticles) {
584 m_timer.startEvent(
"Make superparticles");
585 (this->m_ito)->organizeParticlesByCell(ItoSolver::WhichContainer::Bulk);
586 (this->m_ito)->makeSuperparticles(ItoSolver::WhichContainer::Bulk, (this->m_particlesPerCell));
587 (this->m_ito)->organizeParticlesByPatch(ItoSolver::WhichContainer::Bulk);
588 m_timer.stopEvent(
"Make superparticles");
592 m_timer.startEvent(
"Deposit particles");
593 (this->m_ito)->depositParticles();
594 m_timer.stopEvent(
"Deposit particles");
597 m_timer.startEvent(
"Prepare next step");
598 this->computeDiffusionCoefficients();
599 this->computeDriftVelocities();
600 m_timer.stopEvent(
"Prepare next step");
602 m_timer.eventReport(pout(),
false);
605 this->m_amr->deallocate(m_scratchSemiImplicitRhoCDR);
608 template <
typename I,
typename C,
typename R,
typename F>
612 CH_TIME(
"ItoKMCGodunovStepper::setOldPositions");
613 if (this->m_verbosity > 5) {
614 pout() << this->m_name +
"::setOldPositions" << endl;
617 for (
auto solverIt = (this->m_ito)->iterator(); solverIt.ok(); ++solverIt) {
618 RefCountedPtr<ItoSolver>& solver = solverIt();
620 for (
int lvl = 0; lvl <= (this->m_amr)->getFinestLevel(); lvl++) {
621 const DisjointBoxLayout& dbl = (this->m_amr)->getGrids((this->m_particleRealm))[lvl];
622 const DataIterator& dit = dbl.dataIterator();
624 ParticleData<ItoParticle>& particles = solver->getParticles(ItoSolver::WhichContainer::Bulk)[lvl];
626 const int nbox = dit.size();
628 #pragma omp parallel for schedule(runtime)
629 for (
int mybox = 0; mybox < nbox; mybox++) {
630 const DataIndex& din = dit[mybox];
632 List<ItoParticle>& particleList = particles[din].listItems();
634 for (ListIterator<ItoParticle> lit(particleList); lit.ok(); ++lit) {
644 template <
typename I,
typename C,
typename R,
typename F>
650 CH_TIME(
"ItoKMCGodunovStepper::remapPointParticles");
651 if (this->m_verbosity > 5) {
652 pout() << this->m_name +
"::remapPointParticles" << endl;
655 for (
auto solverIt = (this->m_ito)->iterator(); solverIt.ok(); ++solverIt) {
656 RefCountedPtr<ItoSolver>& solver = solverIt();
657 const RefCountedPtr<ItoSpecies>& species = solver->getSpecies();
659 const int idx = solverIt.index();
661 const bool mobile = solver->isMobile();
662 const bool diffusive = solver->isDiffusive();
663 const bool charged = species->getChargeNumber() != 0;
666 case SpeciesSubset::All: {
667 a_particles[idx]->remap();
671 case SpeciesSubset::AllMobile: {
673 a_particles[idx]->remap();
678 case SpeciesSubset::AllDiffusive: {
680 a_particles[idx]->remap();
685 case SpeciesSubset::AllMobileOrDiffusive: {
686 if (mobile || diffusive) {
687 a_particles[idx]->remap();
692 case SpeciesSubset::AllMobileAndDiffusive: {
693 if (mobile && diffusive) {
694 a_particles[idx]->remap();
699 case SpeciesSubset::Charged: {
701 a_particles[idx]->remap();
706 case SpeciesSubset::ChargedMobile: {
707 if (charged && mobile) {
708 a_particles[idx]->remap();
713 case SpeciesSubset::ChargedDiffusive: {
714 if (charged && diffusive) {
715 a_particles[idx]->remap();
720 case SpeciesSubset::ChargedMobileOrDiffusive: {
721 if (charged && (mobile || diffusive)) {
722 a_particles[idx]->remap();
727 case SpeciesSubset::ChargedMobileAndDiffusive: {
728 if (charged && (mobile && diffusive)) {
729 a_particles[idx]->remap();
734 case SpeciesSubset::Stationary: {
735 if (!mobile && !diffusive) {
736 a_particles[idx]->remap();
742 MayDay::Abort(
"ItoKMCGodunovStepper::remapPointParticles - logic bust");
750 template <
typename I,
typename C,
typename R,
typename F>
756 CH_TIME(
"ItoKMCGodunovStepper::depositPointParticles");
757 if (this->m_verbosity > 5) {
758 pout() << this->m_name +
"::depositPointParticles" << endl;
761 for (
auto solverIt = (this->m_ito)->iterator(); solverIt.ok(); ++solverIt) {
762 RefCountedPtr<ItoSolver>& solver = solverIt();
763 const RefCountedPtr<ItoSpecies>& species = solver->getSpecies();
765 const int idx = solverIt.index();
767 const bool mobile = solver->isMobile();
768 const bool diffusive = solver->isDiffusive();
769 const bool charged = species->getChargeNumber() != 0;
772 case SpeciesSubset::All: {
777 case SpeciesSubset::AllMobile: {
784 case SpeciesSubset::AllDiffusive: {
791 case SpeciesSubset::AllMobileOrDiffusive: {
792 if (mobile || diffusive) {
797 case SpeciesSubset::AllMobileAndDiffusive: {
798 if (mobile && diffusive) {
803 case SpeciesSubset::Charged: {
809 case SpeciesSubset::ChargedMobile: {
810 if (charged && mobile) {
815 case SpeciesSubset::ChargedDiffusive: {
816 if (charged && diffusive) {
822 case SpeciesSubset::ChargedMobileOrDiffusive: {
823 if (charged && (mobile || diffusive)) {
829 case SpeciesSubset::ChargedMobileAndDiffusive: {
830 if (charged && (mobile && diffusive)) {
836 case SpeciesSubset::Stationary: {
837 if (!mobile && !diffusive) {
844 MayDay::Abort(
"ItoKMCGodunovStepper::depositPointParticles - logic bust");
852 template <
typename I,
typename C,
typename R,
typename F>
858 CH_TIME(
"ItoKMCGodunovStepper::clearPointParticles");
859 if (this->m_verbosity > 5) {
860 pout() << this->m_name +
"::clearPointParticles" << endl;
863 for (
auto solverIt = (this->m_ito)->iterator(); solverIt.ok(); ++solverIt) {
864 RefCountedPtr<ItoSolver>& solver = solverIt();
865 const RefCountedPtr<ItoSpecies>& species = solver->getSpecies();
867 const int idx = solverIt.index();
869 const bool mobile = solver->isMobile();
870 const bool diffusive = solver->isDiffusive();
871 const bool charged = species->getChargeNumber() != 0;
874 case SpeciesSubset::All: {
875 a_particles[idx]->clearParticles();
879 case SpeciesSubset::AllMobile: {
881 a_particles[idx]->clearParticles();
886 case SpeciesSubset::AllDiffusive: {
888 a_particles[idx]->clearParticles();
893 case SpeciesSubset::AllMobileOrDiffusive: {
894 if (mobile || diffusive) {
895 a_particles[idx]->clearParticles();
900 case SpeciesSubset::AllMobileAndDiffusive: {
901 if (mobile && diffusive) {
902 a_particles[idx]->clearParticles();
907 case SpeciesSubset::Charged: {
909 a_particles[idx]->clearParticles();
914 case SpeciesSubset::ChargedMobile: {
915 if (charged && mobile) {
916 a_particles[idx]->clearParticles();
921 case SpeciesSubset::ChargedDiffusive: {
922 if (charged && diffusive) {
923 a_particles[idx]->clearParticles();
928 case SpeciesSubset::ChargedMobileOrDiffusive: {
929 if (charged && (mobile || diffusive)) {
930 a_particles[idx]->clearParticles();
935 case SpeciesSubset::ChargedMobileAndDiffusive: {
936 if (charged && (mobile && diffusive)) {
937 a_particles[idx]->clearParticles();
942 case SpeciesSubset::Stationary: {
943 if (!mobile && !diffusive) {
944 a_particles[idx]->clearParticles();
950 MayDay::Abort(
"ItoKMCGodunovStepper::clearPointParticles - logic bust");
958 template <
typename I,
typename C,
typename R,
typename F>
963 CH_TIME(
"ItoKMCGodunovStepper::computeConductivities");
964 if (this->m_verbosity > 5) {
965 pout() << this->m_name +
"::computeConductivities" << endl;
968 this->computeCellConductivity((this->m_conductivityCell), a_particles);
969 this->computeFaceConductivity();
972 template <
typename I,
typename C,
typename R,
typename F>
978 CH_TIME(
"ItoKMCGodunovStepper::computeCellConductivity(EBAMRCellData, PointParticle");
979 if (this->m_verbosity > 5) {
980 pout() << this->m_name +
"::computeCellConductivity(EBAMRCellData, PointParticle)" << endl;
986 for (
auto solverIt = (this->m_ito)->iterator(); solverIt.ok(); ++solverIt) {
987 RefCountedPtr<ItoSolver>& solver = solverIt();
988 const RefCountedPtr<ItoSpecies>& species = solver->getSpecies();
990 const int idx = solverIt.index();
991 const int Z = species->getChargeNumber();
993 if (Z != 0 && solver->isMobile()) {
999 (this->m_amr)->copyData(this->m_fluidScratch1, this->m_particleScratch1);
1000 DataOps::incr(a_conductivityCell, this->m_fluidScratch1, 1.0 * std::abs(Z));
1006 for (
auto solverIt = (this->m_cdr)->iterator(); solverIt.ok(); ++solverIt) {
1007 const RefCountedPtr<CdrSolver>& solver = solverIt();
1008 const RefCountedPtr<CdrSpecies>& species = solver->getSpecies();
1010 const int index = solverIt.index();
1011 const int Z = species->getChargeNumber();
1013 if (Z != 0 && solver->isMobile()) {
1020 DataOps::incr(a_conductivityCell, this->m_fluidScratch1, 1.0 * std::abs(Z));
1028 (this->m_amr)->arithmeticAverage(a_conductivityCell, this->m_fluidRealm, (this->m_plasmaPhase));
1029 (this->m_amr)->interpGhostPwl(a_conductivityCell, this->m_fluidRealm, (this->m_plasmaPhase));
1031 if (this->m_smoothConductivity) {
1032 const Real alpha = 0.5;
1033 const int stride = 1;
1037 (this->m_amr)->arithmeticAverage(a_conductivityCell, this->m_fluidRealm, (this->m_plasmaPhase));
1038 (this->m_amr)->interpGhostPwl(a_conductivityCell, this->m_fluidRealm, (this->m_plasmaPhase));
1041 (this->m_amr)->interpToCentroids(a_conductivityCell, this->m_fluidRealm, (this->m_plasmaPhase));
1044 template <
typename I,
typename C,
typename R,
typename F>
1048 CH_TIME(
"ItoKMCGodunovStepper::computeFaceConductivity");
1049 if (this->m_verbosity > 5) {
1050 pout() << this->m_name +
"::computeFaceConductivity" << endl;
1059 const int tanGhost = 1;
1060 const Interval interv(0, 0);
1063 (this->m_conductivityCell),
1064 (this->m_amr)->getDomains(),
1071 DataOps::incr((this->m_conductivityEB), (this->m_conductivityCell), 1.0);
1074 template <
typename I,
typename C,
typename R,
typename F>
1078 CH_TIME(
"ItoKMCGodunovStepper::computeSemiImplicitRho");
1079 if (this->m_verbosity > 5) {
1080 pout() << this->m_name +
"::computeSemiImplicitRho" << endl;
1084 EBAMRCellData rhoPhase = this->m_amr->alias(this->m_plasmaPhase, rho);
1089 for (
auto solverIt = this->m_ito->iterator(); solverIt.ok(); ++solverIt) {
1090 const RefCountedPtr<ItoSolver>& solver = solverIt();
1091 const RefCountedPtr<ItoSpecies>& species = solver->getSpecies();
1092 const int Z = species->getChargeNumber();
1095 (this->m_amr)->copyData(this->m_fluidScratch1, solver->getPhi());
1105 this->m_amr->arithmeticAverage(rho, this->m_fluidRealm);
1106 this->m_amr->interpGhostPwl(rho, this->m_fluidRealm);
1108 this->m_amr->interpToCentroids(rhoPhase, this->m_fluidRealm, this->m_plasmaPhase);
1111 template <
typename I,
typename C,
typename R,
typename F>
1115 CH_TIME(
"ItoKMCGodunovStepper::setupSemiImplicitPoisson");
1116 if (this->m_verbosity > 5) {
1117 pout() << this->m_name +
"::setupSemiImplicitPoisson" << endl;
1121 (this->m_fieldSolver)->setPermittivities();
1125 MFAMRCellData& permCell = (this->m_fieldSolver)->getPermittivityCell();
1126 MFAMRFluxData& permFace = (this->m_fieldSolver)->getPermittivityFace();
1127 MFAMRIVData& permEB = (this->m_fieldSolver)->getPermittivityEB();
1130 EBAMRFluxData permFaceGas = (this->m_amr)->alias((this->m_plasmaPhase), permFace);
1131 EBAMRIVData permEBGas = (this->m_amr)->alias((this->m_plasmaPhase), permEB);
1139 (this->m_amr)->arithmeticAverage(permFaceGas, this->m_fluidRealm, (this->m_plasmaPhase));
1140 (this->m_amr)->arithmeticAverage(permEBGas, this->m_fluidRealm, (this->m_plasmaPhase));
1143 (this->m_fieldSolver)->setSolverPermittivities(permCell, permFace, permEB);
1146 template <
typename I,
typename C,
typename R,
typename F>
1151 const Real a_tolerance)
const noexcept
1153 CH_TIME(
"ItoKMCGodunovStepper::removeCoveredPointParticles");
1154 if (this->m_verbosity > 5) {
1155 pout() << this->m_name +
"::removeCoveredPointParticles" << endl;
1158 for (
int i = 0; i < a_particles.size(); i++) {
1159 if (a_particles[i] !=
nullptr) {
1162 switch (a_representation) {
1163 case EBRepresentation::Discrete: {
1164 (this->m_amr)->removeCoveredParticlesDiscrete(particles, (this->m_plasmaPhase), a_tolerance);
1168 case EBRepresentation::ImplicitFunction: {
1169 (this->m_amr)->removeCoveredParticlesIF(particles, (this->m_plasmaPhase), a_tolerance);
1173 case EBRepresentation::Voxel: {
1174 (this->m_amr)->removeCoveredParticlesVoxels(particles, (this->m_plasmaPhase));
1179 MayDay::Error(
"ItoKMCGodunovStepper::removeCoveredParticles - logic bust");
1186 template <
typename I,
typename C,
typename R,
typename F>
1191 CH_TIME(
"ItoKMCGodunovStepper::copyConductivityParticles");
1192 if (this->m_verbosity > 5) {
1193 pout() << this->m_name +
"::copyConductivityParticles" << endl;
1197 this->clearPointParticles(a_conductivityParticles, SpeciesSubset::All);
1199 for (
auto solverIt = (this->m_ito)->iterator(); solverIt.ok(); ++solverIt) {
1200 const RefCountedPtr<ItoSolver>& solver = solverIt();
1201 const RefCountedPtr<ItoSpecies>& species = solver->getSpecies();
1203 const int idx = solverIt.index();
1204 const int Z = species->getChargeNumber();
1206 if (Z != 0 && solver->isMobile()) {
1209 for (
int lvl = 0; lvl <= (this->m_amr)->getFinestLevel(); lvl++) {
1210 const DisjointBoxLayout& dbl = (this->m_amr)->getGrids((this->m_particleRealm))[lvl];
1211 const DataIterator& dit = dbl.dataIterator();
1213 const int nbox = dit.size();
1215 #pragma omp parallel for schedule(runtime)
1216 for (
int mybox = 0; mybox < nbox; mybox++) {
1217 const DataIndex& din = dit[mybox];
1219 const List<ItoParticle>& patchParticles = solverParticles[lvl][din].listItems();
1221 List<PointParticle>& pointParticles = (*a_conductivityParticles[idx])[lvl][din].listItems();
1222 List<PointParticle>& irregParticles = (*m_irregularParticles[idx])[lvl][din].listItems();
1224 for (ListIterator<ItoParticle> lit(patchParticles); lit.ok(); ++lit) {
1226 const RealVect& pos = p.
position();
1227 const Real& weight = p.
weight();
1228 const Real& mobility = p.
mobility();
1233 pointParticles.catenate(irregParticles);
1240 template <
typename I,
typename C,
typename R,
typename F>
1244 CH_TIME(
"ItoKMCGodunovStepper::advanceEulerMaruyama");
1245 if (this->m_verbosity > 5) {
1246 pout() << this->m_name +
"::advanceEulerMaruyama" << endl;
1250 this->setOldPositions();
1255 m_timer.startEvent(
"Diffuse particles");
1256 this->diffuseParticlesEulerMaruyama(m_rhoDaggerParticles, a_dt);
1257 this->remapPointParticles(m_rhoDaggerParticles, SpeciesSubset::ChargedDiffusive);
1258 m_timer.stopEvent(
"Diffuse particles");
1262 m_timer.startEvent(
"Diffuse CDR");
1263 this->computeDiffusionTermCDR(m_semiImplicitRhoCDR, a_dt);
1264 m_timer.stopEvent(
"Diffuse CDR");
1268 m_timer.startEvent(
"Compute conductivities");
1269 this->copyConductivityParticles(m_conductivityParticles);
1270 this->computeConductivities(m_conductivityParticles);
1271 m_timer.stopEvent(
"Compute conductivities");
1275 m_timer.startEvent(
"Setup Poisson");
1276 this->setupSemiImplicitPoisson(a_dt);
1277 m_timer.stopEvent(
"Setup Poisson");
1282 m_timer.startEvent(
"Deposit point particles");
1283 this->depositPointParticles(m_rhoDaggerParticles, SpeciesSubset::Charged);
1284 this->computeSemiImplicitRho();
1285 m_timer.stopEvent(
"Deposit point particles");
1289 m_timer.startEvent(
"Solve Poisson");
1290 const bool converged = this->solvePoisson();
1293 errMsg =
"ItoKMCGodunovStepper::advanceEulerMaruyama - Poisson solve did not converge after regrid";
1295 pout() << errMsg << endl;
1297 if (this->m_abortOnFailure) {
1298 MayDay::Error(errMsg.c_str());
1301 m_timer.stopEvent(
"Solve Poisson");
1306 m_timer.startEvent(
"Step-compute v");
1308 this->setCdrVelocityFunctions();
1309 this->setItoVelocityFunctions();
1310 (this->m_ito)->interpolateVelocities();
1311 this->multiplyCdrVelocitiesByMobilities();
1313 this->computeDriftVelocities();
1315 m_timer.stopEvent(
"Step-compute v");
1319 m_timer.startEvent(
"Euler-Maruyama step");
1320 this->stepEulerMaruyamaParticles(a_dt);
1321 this->remapParticles(SpeciesSubset::AllMobileOrDiffusive);
1322 this->stepEulerMaruyamaCDR(a_dt);
1323 m_timer.stopEvent(
"Euler-Maruyama step");
1326 template <
typename I,
typename C,
typename R,
typename F>
1330 const Real a_dt) noexcept
1332 CH_TIME(
"ItoKMCGodunovStepper::diffuseParticlesEulerMaruyama");
1333 if (this->m_verbosity > 5) {
1334 pout() << this->m_name +
"::diffuseParticlesEulerMaruyama" << endl;
1337 this->clearPointParticles(a_rhoDaggerParticles, SpeciesSubset::All);
1339 for (
auto solverIt = (this->m_ito)->iterator(); solverIt.ok(); ++solverIt) {
1340 RefCountedPtr<ItoSolver>& solver = solverIt();
1341 const RefCountedPtr<ItoSpecies>& species = solver->getSpecies();
1343 const int idx = solverIt.index();
1345 const bool diffusive = solver->isDiffusive();
1346 const int Z = species->getChargeNumber();
1348 for (
int lvl = 0; lvl <= (this->m_amr)->getFinestLevel(); lvl++) {
1349 const DisjointBoxLayout& dbl = (this->m_amr)->getGrids((this->m_particleRealm))[lvl];
1350 const DataIterator& dit = dbl.dataIterator();
1352 ParticleData<ItoParticle>& particles = solver->getParticles(ItoSolver::WhichContainer::Bulk)[lvl];
1354 const int nbox = dit.size();
1356 #pragma omp parallel for schedule(runtime)
1357 for (
int mybox = 0; mybox < nbox; mybox++) {
1358 const DataIndex& din = dit[mybox];
1360 List<ItoParticle>& itoParticles = particles[din].listItems();
1361 List<PointParticle>& pointParticles = (*a_rhoDaggerParticles[idx])[lvl][din].listItems();
1363 for (ListIterator<ItoParticle> lit(itoParticles); lit.ok(); ++lit) {
1365 const Real& weight = p.
weight();
1366 const RealVect& pos = p.
position();
1371 hop = sqrt(2.0 * p.
diffusion() * a_dt) * solver->randomGaussian();
1374 hop = RealVect::Zero;
1386 template <
typename I,
typename C,
typename R,
typename F>
1390 CH_TIME(
"ItoKMCGodunovStepper::diffuseCDREulerMaruyama");
1391 if (this->m_verbosity > 5) {
1392 pout() << this->m_name +
"::diffuseCDREulerMaruyama" << endl;
1397 for (
auto solverIt = this->m_cdr->iterator(); solverIt.ok(); ++solverIt) {
1398 const RefCountedPtr<CdrSolver>& solver = solverIt();
1399 const RefCountedPtr<CdrSpecies>& species = solver->getSpecies();
1401 const int index = solverIt.index();
1402 const int Z = species->getChargeNumber();
1407 if (solver->isDiffusive()) {
1408 solver->computeDivD(m_cdrDivD[index], solver->getPhi(),
false,
false,
false);
1414 if (solver->isDiffusive()) {
1415 DataOps::incr(a_semiImplicitRhoCDR, m_cdrDivD[index], 1.0 * Z * a_dt);
1422 this->m_amr->arithmeticAverage(a_semiImplicitRhoCDR, this->m_fluidRealm, this->m_plasmaPhase);
1423 this->m_amr->interpGhostPwl(a_semiImplicitRhoCDR, this->m_fluidRealm, this->m_plasmaPhase);
1426 template <
typename I,
typename C,
typename R,
typename F>
1430 CH_TIME(
"ItoKMCGodunovStepper::stepEulerMaruyamaParticles");
1431 if (this->m_verbosity > 5) {
1432 pout() << this->m_name +
"::stepEulerMaruyamaParticles" << endl;
1435 for (
auto solverIt = (this->m_ito)->iterator(); solverIt.ok(); ++solverIt) {
1436 RefCountedPtr<ItoSolver>& solver = solverIt();
1438 const bool mobile = solver->isMobile();
1439 const bool diffusive = solver->isDiffusive();
1441 const Real f = mobile ? a_dt : 0.0;
1442 const Real g = diffusive ? 1.0 : 0.0;
1444 if (mobile || diffusive) {
1445 for (
int lvl = 0; lvl <= (this->m_amr)->getFinestLevel(); lvl++) {
1446 const DisjointBoxLayout& dbl = (this->m_amr)->getGrids((this->m_particleRealm))[lvl];
1447 const DataIterator& dit = dbl.dataIterator();
1449 ParticleData<ItoParticle>& particles = solver->getParticles(ItoSolver::WhichContainer::Bulk)[lvl];
1451 const int nbox = dit.size();
1453 #pragma omp parallel for schedule(runtime)
1454 for (
int mybox = 0; mybox < nbox; mybox++) {
1455 const DataIndex& din = dit[mybox];
1457 List<ItoParticle>& particleList = particles[din].listItems();
1459 for (ListIterator<ItoParticle> lit(particleList); lit.ok(); ++lit) {
1463 const RealVect& hop = p.
tmpVect();
1472 template <
typename I,
typename C,
typename R,
typename F>
1476 CH_TIME(
"ItoKMCGodunovStepper::stepEulerMaruyamaCDR");
1477 if (this->m_verbosity > 5) {
1478 pout() << this->m_name +
"::stepEulerMaruyamaCDR" << endl;
1481 for (
auto solverIt = (this->m_cdr)->iterator(); solverIt.ok(); ++solverIt) {
1482 RefCountedPtr<CdrSolver>& solver = solverIt();
1484 const int index = solverIt.index();
1488 this->m_amr->conservativeAverage(phi, this->m_fluidRealm, this->m_plasmaPhase);
1489 this->m_amr->interpGhostPwl(phi, this->m_fluidRealm, this->m_plasmaPhase);
1492 if (solver->isMobile()) {
1497 solver->computeDivF(this->m_fluidScratch1, phi, 0.5 * a_dt,
false,
true,
true);
1503 if (solver->isDiffusive()) {
1510 this->coarsenCDRSolvers();
1514 template <
typename I,
typename C,
typename R,
typename F>
1518 CH_TIME(
"ItoKMCGodunovStepper::writeCheckpointHeader");
1519 if (this->m_verbosity > 5) {
1520 pout() << this->m_name +
"::writeCheckpointHeader" << endl;
1523 a_header.m_real[
"prev_dt"] = this->m_prevDt;
1524 a_header.m_int[
"checkpoint_particles"] = m_writeCheckpointParticles ? 1 : 0;
1529 template <
typename I,
typename C,
typename R,
typename F>
1533 CH_TIME(
"ItoKMCGodunovStepper::readCheckpointHeader");
1534 if (this->m_verbosity > 5) {
1535 pout() << this->m_name +
"::readCheckpointHeader" << endl;
1538 this->m_prevDt = a_header.m_real[
"prev_dt"];
1539 m_readCheckpointParticles = (a_header.m_int[
"checkpoint_particles"] != 0) ?
true :
false;
1540 m_canRegridOnRestart = m_readCheckpointParticles;
1545 template <
typename I,
typename C,
typename R,
typename F>
1549 CH_TIME(
"ItoKMCGodunovStepper::writeCheckpointData");
1550 if (this->m_verbosity > 5) {
1551 pout() << this->m_name +
"::writeCheckpointData" << endl;
1557 if (m_writeCheckpointParticles) {
1558 for (
int i = 0; i < (this->m_physics)->getNumItoSpecies(); i++) {
1559 const std::string identifierSigma =
"ItoKMCGodunovStepper::conductivityParticles_" + std::to_string(i);
1560 const std::string identifierRho =
"ItoKMCGodunovStepper::spaceChargeParticles_" + std::to_string(i);
1565 writeParticlesToHDF(a_handle, conductivityParticles[a_lvl], identifierSigma);
1566 writeParticlesToHDF(a_handle, rhoDaggerParticles[a_lvl], identifierRho);
1571 if (this->m_physics->getNumCdrSpecies() > 0) {
1572 write(a_handle, *m_semiImplicitRhoCDR[a_lvl],
"ItoKMCGodunovStepper::semiImplicitRhoCDR");
1573 write(a_handle, *m_semiImplicitConductivityCDR[a_lvl],
"ItoKMCGodunovStepper::semiImplicitConductivityCDR");
1579 template <
typename I,
typename C,
typename R,
typename F>
1583 CH_TIME(
"ItoKMCGodunovStepper::readCheckpointData");
1584 if (this->m_verbosity > 5) {
1585 pout() << this->m_name +
"::readCheckpointData" << endl;
1591 if (m_readCheckpointParticles) {
1592 for (
int i = 0; i < (this->m_physics)->getNumItoSpecies(); i++) {
1593 const std::string identifierSigma =
"ItoKMCGodunovStepper::conductivityParticles_" + std::to_string(i);
1594 const std::string identifierRho =
"ItoKMCGodunovStepper::spaceChargeParticles_" + std::to_string(i);
1599 readParticlesFromHDF(a_handle, conductivityParticles[a_lvl], identifierSigma);
1600 readParticlesFromHDF(a_handle, rhoDaggerParticles[a_lvl], identifierRho);
1605 if (this->m_physics->getNumCdrSpecies() > 0) {
1606 const Interval interv(0, 0);
1608 read<EBCellFAB>(a_handle,
1609 *m_semiImplicitRhoCDR[a_lvl],
1610 "ItoKMCGodunovStepper::semiImplicitRhoCDR",
1611 this->m_amr->getGrids(this->m_fluidRealm)[a_lvl],
1615 read<EBCellFAB>(a_handle,
1616 *m_semiImplicitConductivityCDR[a_lvl],
1617 "ItoKMCGodunovStepper::semiImplicitConductivityCDR",
1618 this->m_amr->getGrids(this->m_fluidRealm)[a_lvl],
1625 template <
typename I,
typename C,
typename R,
typename F>
1629 CH_TIME(
"ItoKMCGodunovStepper::postPlot");
1630 if (this->m_verbosity > 5) {
1631 pout() << this->m_name +
"::postPlot" << endl;
1634 this->m_physicsPlotVariables.clear();
1636 this->plotParticles();
1639 template <
typename I,
typename C,
typename R,
typename F>
1643 CH_TIME(
"ItoKMCGodunovStepper::plotParticles");
1644 if (this->m_verbosity > 2) {
1645 pout() << this->m_name +
"::plotParticles" << endl;
1648 bool plotParticles =
false;
1650 ParmParse pp(this->m_name.c_str());
1652 pp.query(
"plot_particles", plotParticles);
1654 if (plotParticles) {
1656 for (
auto solverIt = (this->m_ito)->iterator(); solverIt.ok(); ++solverIt) {
1657 const RefCountedPtr<ItoSolver>& solver = solverIt();
1661 std::string cmd =
"mkdir -p particles/" + solver->getName();
1663 if (procID() == 0) {
1664 success = system(cmd.c_str());
1668 MayDay::Error(
"ItoKMCGodunovStepper::plotParticles - could not create 'particles' directory");
1672 const std::string prefix =
"./particles/" + solver->getName() +
"/" + solver->getName();
1673 char fileChar[1000];
1674 sprintf(fileChar,
"%s.step%07d.%dd.h5part", prefix.c_str(), this->m_timeStep, SpaceDim);
1681 this->m_amr->getProbLo(),
1687 #include <CD_NamespaceFooter.H>
Average
Various averaging methods.
Definition: CD_Average.H:24
Agglomeration of useful data operations.
Silly, but useful functions that override standard Chombo HDF5 IO.
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:22
Declaration of a class which uses a semi-implicit Godunov method for Ito plasma equations.
SpeciesSubset
Enum for differentiating between types of particles.
Definition: CD_ItoKMCStepper.H:40
Agglomeration of basic MPI reductions.
Declaration of a photon class for particle methods.
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:2384
static void floor(EBAMRCellData &a_lhs, const Real a_value)
Floor values in data holder. This sets all values below a_value to a_value.
Definition: CD_DataOps.cpp:1380
static void setValue(LevelData< MFInterfaceFAB< T >> &a_lhs, const T &a_value)
Set value in an MFInterfaceFAB data holder.
Definition: CD_DataOpsImplem.H:23
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:660
static void multiply(EBAMRCellData &a_lhs, const EBAMRCellData &a_rhs)
Multiply data holder by another data holder.
Definition: CD_DataOps.cpp:2142
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:787
static void averageCellToFace(EBAMRFluxData &a_faceData, const EBAMRCellData &a_cellData, const Vector< ProblemDomain > &a_domains)
Average all components of the cell-centered data to faces.
Definition: CD_DataOps.cpp:153
static void copy(MFAMRCellData &a_dst, const MFAMRCellData &a_src)
Copy data from one data holder to another.
Definition: CD_DataOps.cpp:1118
RealVect & position()
Get the particle position.
Definition: CD_GenericParticleImplem.H:47
A particle class for use with ItoSolvers, i.e. drifting Brownian walkers.
Definition: CD_ItoParticle.H:40
Real & diffusion()
Get particle diffusion coefficient.
Definition: CD_ItoParticleImplem.H:95
Real & mobility()
Get mobility coefficient.
Definition: CD_ItoParticleImplem.H:83
RealVect & oldPosition()
Get the old particle position.
Definition: CD_ItoParticleImplem.H:119
RealVect & tmpVect()
Return scratch RealVect storage.
Definition: CD_ItoParticleImplem.H:173
static std::vector< std::string > s_vectVariables
Naming convention for vector fields.
Definition: CD_ItoParticle.H:50
Real & weight()
Get particle weight.
Definition: CD_ItoParticleImplem.H:71
static std::vector< std::string > s_realVariables
Naming convention for scalar fields.
Definition: CD_ItoParticle.H:45
RealVect & velocity()
Get the particle velocity.
Definition: CD_ItoParticleImplem.H:131
Real & tmpReal()
Return scratch scalar storage.
Definition: CD_ItoParticleImplem.H:161
Templated class for holding particles on an AMR hierarchy with particle remapping.
Definition: CD_ParticleContainer.H:50
void clearParticles()
Clear all particles.
Definition: CD_ParticleContainerImplem.H:1670
AMRParticles< P > & getParticles()
Get all particles on all levels.
Definition: CD_ParticleContainerImplem.H:270
Particle class for usage with Monte Carlo radiative transfer.
Definition: CD_Photon.H:29
Real & weight()
Get photon weight.
Definition: CD_PhotonImplem.H:40
Implementation of ItoKMCStepper that uses a semi-implicit split-step formalism for advancing the Ito-...
Definition: CD_ItoKMCGodunovStepper.H:29
virtual void setupSemiImplicitPoisson(const Real a_dt) noexcept
Set up the semi-implicit Poisson solver.
Definition: CD_ItoKMCGodunovStepperImplem.H:1113
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:470
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:1388
virtual void allocate() noexcept override
Allocate storage required for advancing the equations.
Definition: CD_ItoKMCGodunovStepperImplem.H:59
bool m_readCheckpointParticles
If true, then the HDF5 checkpoint file contained particles that we can read.
Definition: CD_ItoKMCGodunovStepper.H:152
virtual Real advance(const Real a_dt) override
Advance the Ito-Poisson-KMC system over a_dt.
Definition: CD_ItoKMCGodunovStepperImplem.H:198
virtual void allocateInternals() noexcept override
Allocate "internal" storage.
Definition: CD_ItoKMCGodunovStepperImplem.H:93
virtual void copyConductivityParticles(Vector< RefCountedPtr< ParticleContainer< PointParticle >>> &a_conductivityParticles) noexcept
Copy particles from the ItoSolver into PointParticles whose weight are ItoParticle::m_weight * ItoPar...
Definition: CD_ItoKMCGodunovStepperImplem.H:1188
virtual void stepEulerMaruyamaCDR(const Real a_dt) noexcept
Step the CDR equations according to the regular Euler-Maruyama scheme.
Definition: CD_ItoKMCGodunovStepperImplem.H:1474
virtual void depositPointParticles(const Vector< RefCountedPtr< ParticleContainer< PointParticle >>> &a_particles, const SpeciesSubset a_subset) noexcept
Deposit the input point particles on the mesh.
Definition: CD_ItoKMCGodunovStepperImplem.H:752
virtual void parseAlgorithm() noexcept
Parse advancement algorithm.
Definition: CD_ItoKMCGodunovStepperImplem.H:159
virtual void postPlot() noexcept override
Perform post-plot operations.
Definition: CD_ItoKMCGodunovStepperImplem.H:1627
virtual void parseRuntimeOptions() noexcept override
Parse run-time options.
Definition: CD_ItoKMCGodunovStepperImplem.H:144
virtual void remapPointParticles(Vector< RefCountedPtr< ParticleContainer< PointParticle >>> &a_particles, const SpeciesSubset a_subset) noexcept
Remap the input point particles.
Definition: CD_ItoKMCGodunovStepperImplem.H:646
bool m_canRegridOnRestart
If true, then the class supports regrid-on-restart.
Definition: CD_ItoKMCGodunovStepper.H:158
virtual void computeFaceConductivity() noexcept
Compute the cell-centered conductivity.
Definition: CD_ItoKMCGodunovStepperImplem.H:1046
virtual void clearPointParticles(const Vector< RefCountedPtr< ParticleContainer< PointParticle >>> &a_particles, const SpeciesSubset a_subset) noexcept
Clear the input particle data holders.
Definition: CD_ItoKMCGodunovStepperImplem.H:854
virtual void computeConductivities(const Vector< RefCountedPtr< ParticleContainer< PointParticle >>> &a_particles) noexcept
Compute all conductivities (cell, face, and EB) from the input point particles.
Definition: CD_ItoKMCGodunovStepperImplem.H:960
virtual ~ItoKMCGodunovStepper()
Destructor. Does nothing.
Definition: CD_ItoKMCGodunovStepperImplem.H:49
bool m_extendConductivityEB
For achieving a slightly smoother gradient in the conductivity near the EB.
Definition: CD_ItoKMCGodunovStepper.H:163
virtual void setOldPositions() noexcept
Set the starting positions for the ItoSolver particles.
Definition: CD_ItoKMCGodunovStepperImplem.H:610
bool m_smoothConductivity
Smooth the conductivity or not.
Definition: CD_ItoKMCGodunovStepper.H:168
bool m_writeCheckpointParticles
If true, then the particles are checkpointed so we can regrid on checkpoint-restart.
Definition: CD_ItoKMCGodunovStepper.H:147
virtual void removeCoveredPointParticles(Vector< RefCountedPtr< ParticleContainer< PointParticle >>> &a_particles, const EBRepresentation a_representation, const Real a_tolerance) const noexcept
Remove covered particles.
Definition: CD_ItoKMCGodunovStepperImplem.H:1148
virtual void computeSemiImplicitRho() noexcept
Set up the space charge density for the regrid operation.
Definition: CD_ItoKMCGodunovStepperImplem.H:1076
virtual void computeCellConductivity(EBAMRCellData &a_conductivityCell, const Vector< RefCountedPtr< ParticleContainer< PointParticle >>> &a_particles) noexcept
Compute the cell-centered conductivity.
Definition: CD_ItoKMCGodunovStepperImplem.H:974
virtual void advanceEulerMaruyama(const Real a_dt) noexcept
Advance the particles using the Euler-Maruyama scheme.
Definition: CD_ItoKMCGodunovStepperImplem.H:1242
virtual void preRegrid(const int a_lmin, const int a_oldFinestLevel) noexcept override
Perform pre-regrid operations.
Definition: CD_ItoKMCGodunovStepperImplem.H:431
virtual void plotParticles() const noexcept
Utility function for plotting the ItoSolver particles. These are written in a particles folder.
Definition: CD_ItoKMCGodunovStepperImplem.H:1641
ItoKMCGodunovStepper()=delete
Disallowed default constructor. Use the full constructor.
virtual void diffuseParticlesEulerMaruyama(Vector< RefCountedPtr< ParticleContainer< PointParticle >>> &a_rhoDaggerParticles, const Real a_dt) noexcept
Perform the diffusive Ito advance in the Euler-Maruyama step.
Definition: CD_ItoKMCGodunovStepperImplem.H:1328
virtual void parseCheckpointParticles() noexcept
Parse checkpoint-restart functionality.
Definition: CD_ItoKMCGodunovStepperImplem.H:184
virtual void barrier() const noexcept
Set an MPI barrier if using debug mode.
Definition: CD_ItoKMCGodunovStepperImplem.H:115
virtual void parseOptions() noexcept override
Parse options.
Definition: CD_ItoKMCGodunovStepperImplem.H:129
virtual void stepEulerMaruyamaParticles(const Real a_dt) noexcept
Step the particles according to the regular Euler-Maruyama scheme.
Definition: CD_ItoKMCGodunovStepperImplem.H:1428
Base time stepper class that advances the Ito-KMC-Poisson system of equations. If you want a differen...
Definition: CD_ItoKMCStepper.H:60
virtual void parseRuntimeOptions() noexcept override
Parse runtime configurable options.
Definition: CD_ItoKMCStepperImplem.H:106
std::string m_name
Time stepper name.
Definition: CD_ItoKMCStepper.H:367
virtual void parseOptions() noexcept
Parse options.
Definition: CD_ItoKMCStepperImplem.H:86
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:1547
Real m_prevDt
Previous time step.
Definition: CD_ItoKMCStepper.H:501
virtual void allocateInternals() noexcept
Allocate "internal" storage.
Definition: CD_ItoKMCStepperImplem.H:524
virtual void allocate() noexcept override
Allocate storage for solvers.
Definition: CD_ItoKMCStepperImplem.H:506
A particle class that only has a position and a weight.
Definition: CD_PointParticle.H:29
Real & weight()
Get weight.
Definition: CD_PointParticleImplem.H:38
Class which is used for run-time monitoring of events.
Definition: CD_Timer.H:31
void writeH5Part(const std::string a_filename, const ParticleContainer< GenericParticle< M, N >> &a_particles, const std::vector< std::string > a_realVars=std::vector< std::string >(), const std::vector< std::string > a_vectVars=std::vector< std::string >(), const RealVect a_shift=RealVect::Zero, const Real a_time=0.0) noexcept
A shameless copy of Chombo's writeEBHDF5 but including the lower-left corner of the physical domain a...
Definition: CD_DischargeIOImplem.H:26
Real average(const Real &a_val) noexcept
Compute the average (across MPI ranks) of the input value.
Definition: CD_ParallelOpsImplem.H:500
void barrier() noexcept
MPI barrier.
Definition: CD_ParallelOpsImplem.H:25
constexpr Real eps0
Permittivity of free space.
Definition: CD_Units.H:29
constexpr Real R
Universal gas constant.
Definition: CD_Units.H:64
constexpr Real Qe
Elementary charge.
Definition: CD_Units.H:34