chombo-discharge
Loading...
Searching...
No Matches
CD_MFHelmholtzOpImplem.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// Our includes
14#include <CD_MFHelmholtzOp.H>
15#include <CD_ParallelOps.H>
16#include <CD_NamespaceHeader.H>
17
18template <typename Duration>
21{
22 CH_TIME("MFHelmholtzOp::computeOperatorLoads");
23
24 // TLDR: This routine estimates the time spent in each grid patch for a typical relaxation step. This includes
25 // coarse-fine interpolation, BC matching, and applying the operator.
26
28 CH_assert(a_phi.ghostVect() == m_ghostPhi);
29
31 this->create(Lphi, a_phi);
32
33 const DisjointBoxLayout& dbl = a_phi.disjointBoxLayout();
34 const DataIterator& dit = dbl.dataIterator();
35
36 Vector<long long> loads(dbl.size(), 0LL);
37
38 const int nbox = dit.size();
39
40#pragma omp parallel for schedule(runtime)
41 for (int mybox = 0; mybox < nbox; mybox++) {
42 const DataIndex& din = dit[mybox];
43 const int intCode = din.intCode();
44
45 const auto t0 = std::chrono::steady_clock::now();
46
47 for (int i = 0; i < a_numApply; i++) {
48
49 // Homogeneous interpolation with coarser level.
50 if (m_hasCoar) {
51 for (auto& op : m_helmOps) {
52 const int iphase = op.first;
53
54 RefCountedPtr<EBMultigridInterpolator>& phaseInterpolator = m_interpolator.getInterpolator(iphase);
55
56 EBCellFAB& phi = (EBCellFAB&)a_phi[din].getPhase(iphase);
57
58 phaseInterpolator->coarseFineInterpH(phi, Interval(m_comp, m_comp), din);
59 }
60 }
61
62 // Matching time
63 if (m_multifluid) {
64 m_jumpBC->matchBC((*m_jump)[din], a_phi[din], true, din);
65 }
66
67 // Apply operator application
68 for (auto& op : m_helmOps) {
69 const Box cellBox = Lphi.disjointBoxLayout()[din];
70
71 const int iphase = op.first;
72
73 EBCellFAB& Lph = Lphi[din].getPhase(iphase);
74 EBCellFAB& phi = a_phi[din].getPhase(iphase);
75
76 const EBCellFAB& Acoef = (*m_Acoef)[din].getPhase(iphase);
77 const EBFluxFAB& Bcoef = (*m_Bcoef)[din].getPhase(iphase);
78 const BaseIVFAB<Real>& BcoefIrreg = *(*m_BcoefIrreg)[din].getPhasePtr(iphase);
79
80 op.second->applyOp(Lph, phi, Acoef, Bcoef, BcoefIrreg, cellBox, din, true);
81 }
82 }
83
84 const auto t1 = std::chrono::steady_clock::now();
85 const auto duration = (std::chrono::duration_cast<Duration>(t1 - t0));
86
87 loads[intCode] = (long long)duration.count();
88 }
89
91
92 return loads;
93}
94
95#include <CD_NamespaceFooter.H>
Declaration of a class for solving multiphase Helmholtz equations.
Agglomeration of basic MPI reductions.
Vector< long long > computeOperatorLoads(LevelData< MFCellFAB > &a_phi, const int a_numApply) noexcept
Time the applyOp routine. Template parameter is std::chrono duration. E.g. std::chrono::microseconds.
Definition CD_MFHelmholtzOpImplem.H:20
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition CD_TracerParticleSolver.H:38
Real sum(const Real &a_value) noexcept
Compute the sum across all MPI ranks.
Definition CD_ParallelOpsImplem.H:354