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