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