chombo-discharge
CD_McPhotoImplem.H
Go to the documentation of this file.
1 /* chombo-discharge
2  * Copyright © 2021 SINTEF Energy Research.
3  * Please refer to Copyright.txt and LICENSE in the chombo-discharge root directory.
4  */
5 
12 #ifndef CD_McPhotoImplem_H
13 #define CD_McPhotoImplem_H
14 
15 // Our includes
16 #include <CD_McPhoto.H>
17 #include <CD_NamespaceHeader.H>
18 
19 template <class P, const Real& (P::*particleScalarField)() const>
20 void
22  ParticleContainer<P>& a_photons,
23  const DepositionType& a_deposition) const noexcept
24 {
25  CH_TIME("McPhoto::depositPhotons(ParticleContainer)");
26  if (m_verbosity > 5) {
27  pout() << m_name + "::depositPhotons(ParticleContainer)" << endl;
28  }
29 
30  // a_phi contains only weights, i.e. not divided by kappa
31  this->depositKappaConservative<P, particleScalarField>(a_phi, a_photons, a_deposition, m_coarseFineDeposition);
32 
33  // Compute m_depositionNC = sum(kappa*Wc)/sum(kappa)
34  this->depositNonConservative(m_depositionNC, a_phi);
35 
36  // Compute hybrid deposition, including mass differnce
37  this->depositHybrid(a_phi, m_massDiff, m_depositionNC);
38 
39  // Redistribute
40  if (m_blendConservation) {
41  Vector<RefCountedPtr<EBFluxRedistribution>>& redistOps = m_amr->getRedistributionOp(m_realm, m_phase);
42  for (int lvl = 0; lvl <= m_amr->getFinestLevel(); lvl++) {
43  const Real scale = 1.0;
44  const Interval variables = Interval(0, 0);
45  const bool hasCoar = lvl > 0;
46  const bool hasFine = lvl < m_amr->getFinestLevel();
47 
48  if (hasCoar) {
49  redistOps[lvl]->redistributeCoar(*a_phi[lvl - 1], *m_massDiff[lvl], scale, variables);
50  }
51 
52  redistOps[lvl]->redistributeLevel(*a_phi[lvl], *m_massDiff[lvl], scale, variables);
53 
54  if (hasFine) {
55  redistOps[lvl]->redistributeFine(*a_phi[lvl + 1], *m_massDiff[lvl], scale, variables);
56  }
57  }
58  }
59 
60  // Average down and interpolate
61  m_amr->conservativeAverage(a_phi, m_realm, m_phase);
62  m_amr->interpGhost(a_phi, m_realm, m_phase);
63 }
64 
65 template <class P, const Real& (P::*particleScalarField)() const>
66 void
68  ParticleContainer<P>& a_particles,
69  const DepositionType a_deposition,
70  const CoarseFineDeposition a_coarseFineDeposition) const noexcept
71 {
72  CH_TIME("McPhoto::depositKappaConservative");
73  if (m_verbosity > 5) {
74  pout() << m_name + "::depositKappaConservative" << endl;
75  }
76 
77  CH_assert(a_phi[0]->nComp() == 1);
78 
79  switch (a_coarseFineDeposition) {
80  case CoarseFineDeposition::Interp: {
81  m_amr->depositParticles<P, particleScalarField>(a_phi,
82  m_realm,
83  m_phase,
84  a_particles,
85  a_deposition,
86  CoarseFineDeposition::Interp,
87  false);
88 
89  break;
90  }
91  case CoarseFineDeposition::Halo: {
92 
93  // Copy particles living on the mask.
94  const AMRMask& mask = m_amr->getMask(s_particle_halo, m_haloBuffer, m_realm);
95  a_particles.copyMaskParticles(mask);
96 
97  m_amr->depositParticles<P, particleScalarField>(a_phi,
98  m_realm,
99  m_phase,
100  a_particles,
101  a_deposition,
102  CoarseFineDeposition::Halo,
103  false);
104 
105  // Clear out the mask particles.
106  a_particles.clearMaskParticles();
107 
108  break;
109  }
110  case CoarseFineDeposition::HaloNGP: {
111  const AMRMask& mask = m_amr->getMask(s_particle_halo, m_haloBuffer, m_realm);
112 
113  // Transfer particles living on the mask.
114  a_particles.transferMaskParticles(mask);
115 
116  m_amr->depositParticles<P, particleScalarField>(a_phi,
117  m_realm,
118  m_phase,
119  a_particles,
120  a_deposition,
121  CoarseFineDeposition::HaloNGP,
122  false);
123 
124  // Transfer them back.
125  a_particles.transferParticles(a_particles.getMaskParticles());
126 
127  break;
128  }
129  default: {
130  MayDay::Error("McPhoto::depositKappaConservative -- logic bust due to unsupported coarse-fine deposition");
131  }
132  }
133 }
134 
135 #include <CD_NamespaceFooter.H>
136 
137 #endif
CoarseFineDeposition
Coarse-fine deposition types (see CD_EBAMRParticleMesh for how these are handled).
Definition: CD_CoarseFineDeposition.H:26
DepositionType
Deposition types.
Definition: CD_DepositionType.H:23
Declaration of a radiative transfer solver which uses Monte Carlo sampling of computational or real p...
Vector< RefCountedPtr< LevelData< BaseFab< bool > >> > AMRMask
Alias for cutting down on the typic of booleans defined over AMR grids.
Definition: CD_Realm.H:36
void depositKappaConservative(EBAMRCellData &a_phi, ParticleContainer< P > &a_particles, const DepositionType a_deposition, const CoarseFineDeposition a_coarseFineDeposition) const noexcept
This computes the "conservative" deposition, multiplied by kappa.
Definition: CD_McPhotoImplem.H:67
virtual void depositPhotons()
Deposit photons on the mesh.
Definition: CD_McPhoto.cpp:1286
Templated class for holding particles on an AMR hierarchy with particle remapping.
Definition: CD_ParticleContainer.H:50