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 <typename P, typename Traits>
31void
32EBAMRSurfaceDeposition::deposit(EBAMRIVData& a_meshData, const ParticleContainer<P, Traits>& a_particles) const noexcept
33{
34 CH_TIME("EBAMRSurfaceDeposition::deposit");
35 if (m_verbose) {
36 pout() << "EBAMRSurfaceDeposition::deposit" << endl;
37 }
38
39 CH_assert(a_meshData.getRealm() == a_particles.getRealm());
40
41 // Deposit on this level
42 for (int lvl = 0; lvl <= m_finestLevel; lvl++) {
43 const DisjointBoxLayout& dbl = m_ebGrids[lvl]->getDBL();
44 const EBISLayout& ebisl = m_ebGrids[lvl]->getEBISL();
45 const DataIterator& dit = dbl.dataIterator();
46
47 const int nbox = dit.size();
48
49#pragma omp parallel for schedule(runtime)
50 for (int mybox = 0; mybox < nbox; mybox++) {
51 const DataIndex& din = dit[mybox];
52
53 const Box cellBox = dbl[din];
54 const EBISBox& ebisbox = ebisl[din];
55 const BaseIVFAB<VoFStencil>& stencils = (*m_depositionStencils[lvl])[din];
56
57 BaseIVFAB<Real>& meshData = (*m_data[lvl])[din];
58 const ParticleSoA<P, Traits>& leaf = a_particles[lvl][din];
59
60 meshData.setVal(0.0);
61
62 for (std::size_t i = 0; i < leaf.size(); i++) {
63 const IntVect iv = ParticleOps::getParticleCellIndex(leaf.position(i), m_probLo, m_dx[lvl]);
64
65 // If this fails the particle is not in a valid cell.
66 if (!(cellBox.contains(iv))) {
67 MayDay::Error("CD_EBAMRSurfaceDeposition::deposit -- particle is not inside the box");
68 }
69
70 if (ebisbox.isIrregular(iv)) {
71 const VoFStencil& stencil = stencils(VolIndex(iv, 0), 0);
72
73 for (int k = 0; k < stencil.size(); k++) {
74 const VolIndex& stencilVoF = stencil.vof(k);
75 const Real& stencilWeight = stencil.weight(k);
76 const Real depositionWeight = stencilWeight * leaf.weight(i);
77
78 meshData(stencilVoF, 0) += depositionWeight;
79 }
80 }
81 }
82 }
83
84 // Above, we will have deposited over patch boundaries. Add the deposted data into the neighboring patches.
85 m_data[lvl]->exchange(Interval(0, 0), m_copierLevel[lvl], IrregAddOp());
86 }
87
88 // Ensure conservation across coarse-fine interface. This involves interpolation of the data going from
89 // the coarse level to the fine level, and coarsening of the data from the fine level to coarse level.
90 this->addInvalidCoarseDataToFineData();
91 this->addFineGhostDataToValidCoarData();
92
93 // Finally, copy our buffers to the input data.
94 for (int lvl = 0; lvl <= m_finestLevel; lvl++) {
95 CH_assert(!(a_meshData[lvl].isNull()));
96 CH_assert(a_meshData[lvl]->nComp() == 1);
97
98 const Interval interv = Interval(0, 0);
99
100 m_data[lvl]->copyTo(interv, *a_meshData[lvl], interv, m_validToValidCopiers[lvl]);
101 }
102}
103
104#include <CD_NamespaceFooter.H>
105
106#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, Traits > &a_particles) const noexcept
Deposit the container-owned weight column of an SoA particle container onto 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:28
AMR-hierarchy container of computational particles, stored per patch in Struct-of-Arrays form.
Definition CD_ParticleContainer.H:123
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:32
Arena-backed Struct-of-Arrays particle container for a single grid patch.
Definition CD_ParticleSoA.H:655
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:1188
double & weight(const std::size_t a_index) noexcept
Weight of particle i.
Definition CD_ParticleSoA.H:1222
std::size_t size() const noexcept
Number of particles currently stored.
Definition CD_ParticleSoA.H:882