chombo-discharge
Loading...
Searching...
No Matches
CD_EBAMRSurfaceDepositionImplem.H
Go to the documentation of this file.
1/* chombo-discharge
2 * Copyright © 2023 SINTEF Energy Research.
3 * Please refer to Copyright.txt and LICENSE in the chombo-discharge root directory.
4 */
5
12#ifndef CD_EBAMRSurfaceDepositionImplem_H
13#define CD_EBAMRSurfaceDepositionImplem_H
14
15// Std includes
16#include <type_traits>
17
18// Chombo includes
19#include <ParmParse.H>
20#include <CH_Timer.H>
21
22// Our includes
23#include <CD_IrregAddOp.H>
24#include <CD_DataOps.H>
25#include <CD_ParticleOps.H>
27#include <CD_NamespaceHeader.H>
28
29template <class P, class Ret, Ret (P::*MemberFunc)() const>
30void
32{
33 CH_TIME("EBAMRSurfaceDeposition::deposit");
34 if (m_verbose) {
35 pout() << "EBAMRSurfaceDeposition::deposit<P, const Real& P::*func const>" << endl;
36 }
37
38 using NoRef = typename std::remove_reference<Ret>::type;
39 using Base = typename std::remove_cv<NoRef>::type;
40
41 static_assert(std::is_same<Base, Real>::value, "Ret should be Real or const Real&");
42
43 CH_assert(a_meshData.getRealm() == a_particles.getRealm());
44
45 // Deposit on this level
46 for (int lvl = 0; lvl <= m_finestLevel; lvl++) {
47 const DisjointBoxLayout& dbl = m_ebGrids[lvl]->getDBL();
48 const EBISLayout& ebisl = m_ebGrids[lvl]->getEBISL();
49 const DataIterator& dit = dbl.dataIterator();
50
51 const int nbox = dit.size();
52#pragma omp parallel for schedule(runtime)
53 for (int mybox = 0; mybox < nbox; mybox++) {
54 const DataIndex& din = dit[mybox];
55
56 const Box cellBox = dbl[din];
57 const EBISBox& ebisbox = ebisl[din];
58 const BaseIVFAB<VoFStencil>& stencils = (*m_depositionStencils[lvl])[din];
59
60 BaseIVFAB<Real>& meshData = (*m_data[lvl])[din];
61 const List<P>& particles = a_particles[lvl][din].listItems();
62
63 meshData.setVal(0.0);
64
65 for (ListIterator<P> lit(particles); lit.ok(); ++lit) {
66 const P& p = lit();
67
68 const IntVect iv = ParticleOps::getParticleCellIndex(p.position(), m_probLo, m_dx[lvl]);
69
70 // If this fails the particle is not in a valid cell.
71 if (!(cellBox.contains(iv))) {
72 MayDay::Error("CD_EBAMRSurfaceDeposition::deposit -- particle is not inside the box");
73 }
74
75 if (ebisbox.isIrregular(iv)) {
76 const VoFStencil& stencil = stencils(VolIndex(iv, 0), 0);
77
78 for (int i = 0; i < stencil.size(); i++) {
79 const VolIndex& stencilVoF = stencil.vof(i);
80 const Real& stencilWeight = stencil.weight(i);
82
84 }
85 }
86 }
87 }
88
89 // Above, we will have deposited over patch boundaries. Add the deposted data into the neighboring patches.
90 m_data[lvl]->exchange(Interval(0, 0), m_copierLevel[lvl], IrregAddOp());
91 }
92
93 // Ensure conservation across coarse-fine interface. This involves interpolation of the data going from
94 // the coarse level to the fine level, and coarsening of the data from the fine level to coarse level.
95 this->addInvalidCoarseDataToFineData();
96 this->addFineGhostDataToValidCoarData();
97
98 // Finally, copy our buffers to the input data.
99 for (int lvl = 0; lvl <= m_finestLevel; lvl++) {
101 CH_assert(a_meshData[lvl]->nComp() == 1);
102
103 const Interval interv = Interval(0, 0);
104
105 m_data[lvl]->copyTo(interv, *a_meshData[lvl], interv, m_validToValidCopiers[lvl]);
106 }
107}
108
109#include <CD_NamespaceFooter.H>
110
111#endif
Agglomeration of useful data operations.
Declaration of a class for handling surface deposition of particles with EB and AMR.
Declaration of a Copier class for making incrementation between LevelData<BaseIVFAB<Real>> easier.
Declaration of a static class containing some common useful particle routines that would otherwise be...
void deposit(EBAMRIVData &a_meshData, const ParticleContainer< P > &a_particles) const noexcept
Deposition function which deposites the particles on the surface.
Definition CD_EBAMRSurfaceDepositionImplem.H:31
A Copier class for making copying between LevelData<BaseIVFAB<Real>> easier. This is an incrementatio...
Definition CD_IrregAddOp.H:26
static IntVect getParticleCellIndex(const RealVect &a_particlePosition, const RealVect &a_probLo, const Real &a_dx) noexcept
Get the cell index corresponding to the particle position.
Definition CD_ParticleOpsImplem.H:30
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition CD_TracerParticleSolver.H:37