chombo-discharge
Loading...
Searching...
No Matches
CD_MFHelmholtzOp.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_MFHELMHOLTZOP_H
14#define CD_MFHELMHOLTZOP_H
15
16// Std includes
17#include <map>
18#include <chrono>
19
20// Chombo includes
21#include <MFCellFAB.H>
22#include <MFFluxFAB.H>
23
24// Our includes
25#include <CD_Location.H>
27#include <CD_MFCoarAve.H>
28#include <CD_MFReflux.H>
29#include <CD_MFLevelGrid.H>
30#include <CD_MFBaseIVFAB.H>
32#include <CD_EBHelmholtzOp.H>
36#include <CD_NamespaceHeader.H>
37
43class MFHelmholtzOp : public LevelTGAHelmOp<LevelData<MFCellFAB>, MFFluxFAB>
44{
45public:
49 enum class Smoother
50 {
51 PointJacobi,
52 GauSaiRedBlack,
53 GauSaiMultiColor,
54 };
55
59 MFHelmholtzOp() = delete;
60
65
69 MFHelmholtzOp(const MFHelmholtzOp&& a_op) = delete;
70
108 const MFLevelGrid& a_mflgFine,
109 const MFLevelGrid& a_mflg,
110 const MFLevelGrid& a_mflgCoFi,
111 const MFLevelGrid& a_mflgCoar,
114 const MFReflux& a_fluxReg,
115 const MFCoarAve& a_coarAve,
120 const RealVect& a_probLo,
121 const Real& a_dx,
122 const int& a_refToFine,
123 const int& a_refToCoar,
124 const bool& a_hasFine,
125 const bool& a_hasCoar,
126 const bool& a_hasMGObjects,
127 const bool& a_isMGOperator,
128 const Real& a_alpha,
129 const Real& a_beta,
133 const IntVect& a_ghostPhi,
134 const IntVect& a_ghostRhs,
135 const int& a_jumpOrder,
136 const int& a_jumpWeight,
137 const int& a_preCondSmooth,
138 const Smoother& a_relaxType,
139 const Real& a_relaxFactor);
140
144 virtual ~MFHelmholtzOp();
145
151
156 operator=(const MFHelmholtzOp&& a_oper) = delete;
157
164 void
168
174 getAcoef();
175
181 getBcoef();
182
189
194 void
196
203 getHelmOp(const int a_phase);
204
209 int
211
217 void
219
224 void
226
232 void
234
239 void
241
250 void
256
264 void
269
276 void
278
286 void
288
295 template <typename Duration = std::chrono::microseconds>
296 Vector<long long>
298
305 void
307
314 void
316
323 void
325
332 void
334
340 void
342
349 void
351
358 void
360
367 void
369
376 Real
378
384 void
386
391 void
393
399 void
401
410 void
412
418 void
420
427 void
429
436 Real
438
447 void
451 const Real a_a,
453
460 void
464
470 void
472
479 void
483
492 void
498
504 void
506
517 void
525
534 void
540
550 void
557
566 void
571
581 void
587
593
598
603
608
613
618
623
628
633
638
643
648
653
658
663
668
673
678
683
688
693
698
703
708
713
718
723
728
733
738
743
749 void
751
756 void
758
766 void
768
778 void
784
795 void
802};
803
804#include <CD_NamespaceFooter.H>
805
807
808#endif
Declaration of Helmholtz multigrid operators.
Declaration of cell positions.
Declaration of a multiphase BaseIVFAB<Real>
Wrapper class for holding multifluid EBCoarAves.
Declaration of a factory class for making boundary condition objects for MFHelmholtzOp.
Declaration of an EB boundary condition factory class for MFHelmholtzOp.
Declaration of a factory class for making MFHelmholtzJumpBC objects for use in a multifluid MFHelmhol...
Declaration of class for computing "jump interface" boundary conditions for multifluid Helmholtz code...
Implementation of CD_MFHelmholtzOp.H.
Declaration of a wrapper for wrapping multifluid EBLevelGrids.
Declaration of a wrapper class for holding multifluid EBMultigridInterpolators.
Declaration of a class for refluxing in a multiphase context.
Helmholtz operator for equations like alpha*a(x)*phi(x) + beta*div(b(x)*grad(phi(x))) = rho.
Definition CD_EBHelmholtzOp.H:42
Multiphase BaseIVFAB<Real>.
Definition CD_MFBaseIVFAB.H:30
Class for coarsening data in a multifluid context.
Definition CD_MFCoarAve.H:27
Class for computing "jump interface" boundary conditions for multifluid code.
Definition CD_MFHelmholtzJumpBC.H:43
Operator for solving multifluid Helmholtz on a grid level.
Definition CD_MFHelmholtzOp.H:44
void AMROperator(LevelData< MFCellFAB > &a_Lphi, const LevelData< MFCellFAB > &a_phiFine, const LevelData< MFCellFAB > &a_phi, const LevelData< MFCellFAB > &a_phiCoar, const bool a_homogeneousPhysBC, AMRLevelOp< LevelData< MFCellFAB > > *a_finerOp) override
Apply the AMR operator, i.e. compute L(phi) in an AMR context.
Definition CD_MFHelmholtzOp.cpp:1187
void fillGrad(const LevelData< MFCellFAB > &a_phi) override final
Not called, I think.
Definition CD_MFHelmholtzOp.cpp:327
RefCountedPtr< MFHelmholtzJumpBC > m_jumpBC
BC jump object. This is the one that has the stencils and can compute derivatives.
Definition CD_MFHelmholtzOp.H:622
MFHelmholtzOp()=delete
Constructor. Must subsequently call define(...)
Copier m_exchangeCopier
Copier for exchange operation.
Definition CD_MFHelmholtzOp.H:692
void prolongIncrement(LevelData< MFCellFAB > &a_phi, const LevelData< MFCellFAB > &a_correctCoarse) override final
Prolongation method.
Definition CD_MFHelmholtzOp.cpp:944
void scale(LevelData< MFCellFAB > &a_lhs, const Real &a_scale) override final
Scale function.
Definition CD_MFHelmholtzOp.cpp:359
MFHelmholtzOp(const MFHelmholtzOp &a_op)=delete
No copy construction allowed.
void incr(LevelData< MFCellFAB > &a_lhs, const LevelData< MFCellFAB > &a_rhs, Real a_scale) override final
Increment function.
Definition CD_MFHelmholtzOp.cpp:351
const RefCountedPtr< LevelData< MFFluxFAB > > & getBcoef()
Get the Helmholtz B-coefficient on faces.
Definition CD_MFHelmholtzOp.cpp:259
void applyOpNoBoundary(LevelData< MFCellFAB > &a_ans, const LevelData< MFCellFAB > &a_phi) override final
Apply operator but turn off all BCs.
Definition CD_MFHelmholtzOp.cpp:311
MFLevelGrid m_mflg
Level grid.
Definition CD_MFHelmholtzOp.H:642
void preCond(LevelData< MFCellFAB > &a_corr, const LevelData< MFCellFAB > &a_residual) override final
Precondition system before bottom solve.
Definition CD_MFHelmholtzOp.cpp:538
MFLevelGrid m_mflgCoar
Coarse grid.
Definition CD_MFHelmholtzOp.H:652
void getFlux(MFFluxFAB &a_flux, const LevelData< MFCellFAB > &a_data, const Box &a_grid, const DataIndex &a_dit, Real a_scale) override final
Fill flux.
Definition CD_MFHelmholtzOp.cpp:341
static constexpr int m_nComp
Number of components that we solve for.
Definition CD_MFHelmholtzOp.H:597
void createCoarser(LevelData< MFCellFAB > &a_coarse, const LevelData< MFCellFAB > &a_fine, bool a_ghosted) override final
Create coarsened data.
Definition CD_MFHelmholtzOp.cpp:506
RefCountedPtr< LevelData< BaseFab< bool > > > m_validCells
Valid grid cells (will be nullpointer on MG levels)
Definition CD_MFHelmholtzOp.H:632
void AMRResidual(LevelData< MFCellFAB > &a_residual, const LevelData< MFCellFAB > &a_phiFine, const LevelData< MFCellFAB > &a_phi, const LevelData< MFCellFAB > &a_phiCoar, const LevelData< MFCellFAB > &a_rhs, bool a_homogeneousPhysBC, AMRLevelOp< LevelData< MFCellFAB > > *a_finerOp) override final
Compute residual on this level. AMR version.
Definition CD_MFHelmholtzOp.cpp:1053
void AMRProlong(LevelData< MFCellFAB > &a_correction, const LevelData< MFCellFAB > &a_coarseCorrection) override final
Prolongation onto AMR level.
Definition CD_MFHelmholtzOp.cpp:1037
void relax(LevelData< MFCellFAB > &a_correction, const LevelData< MFCellFAB > &a_residual, int a_iterations) override final
Relaxation method. This does smoothing for the system L(correction) = residual.
Definition CD_MFHelmholtzOp.cpp:721
MFCoarAve m_coarAve
Coarsener.
Definition CD_MFHelmholtzOp.H:672
void assign(LevelData< MFCellFAB > &a_lhs, const LevelData< MFCellFAB > &a_rhs) override final
Assignment function.
Definition CD_MFHelmholtzOp.cpp:375
int m_numPhases
Number of phases.
Definition CD_MFHelmholtzOp.H:712
void applyOp(LevelData< MFCellFAB > &a_Lphi, const LevelData< MFCellFAB > &a_phi, bool a_homogeneousPhysBc) override final
Apply operator.
Definition CD_MFHelmholtzOp.cpp:559
int m_numSmoothPreCond
Number of smoothings in the preconditioner.
Definition CD_MFHelmholtzOp.H:707
bool m_hasFine
True if there is a finer AMR level.
Definition CD_MFHelmholtzOp.H:737
const RefCountedPtr< LevelData< MFBaseIVFAB > > & getBcoefIrreg()
Get the Helmholtz B-coefficient on the EB.
Definition CD_MFHelmholtzOp.cpp:265
RefCountedPtr< LevelData< MFFluxFAB > > m_Bcoef
Helmholtz B-coefficient.
Definition CD_MFHelmholtzOp.H:682
void restrictResidual(LevelData< MFCellFAB > &a_resCoar, LevelData< MFCellFAB > &a_phi, const LevelData< MFCellFAB > &a_rhs) override final
Restrict residual onto coarse level.
Definition CD_MFHelmholtzOp.cpp:917
IntVect m_ghostPhi
Number of ghost cells.
Definition CD_MFHelmholtzOp.H:722
std::map< int, RefCountedPtr< LevelData< BaseIVFAB< Real > > > > m_dirichletBcValues
Dirichlet BC values for each phase.
Definition CD_MFHelmholtzOp.H:637
Location::Cell m_dataLocation
Interpretation of data. Either on cell center or on cell centroid.
Definition CD_MFHelmholtzOp.H:602
void divideByIdentityCoef(LevelData< MFCellFAB > &a_rhs) override final
Divide by the a-coefficient.
Definition CD_MFHelmholtzOp.cpp:297
void AMROperatorNF(LevelData< MFCellFAB > &a_Lphi, const LevelData< MFCellFAB > &a_phi, const LevelData< MFCellFAB > &a_phiCoar, bool a_homogeneousPhysBC) override final
Apply the AMR operator, i.e. compute L(phi) in an AMR context, assuming no finer levels.
Definition CD_MFHelmholtzOp.cpp:1103
virtual ~MFHelmholtzOp()
Destructor.
Definition CD_MFHelmholtzOp.cpp:218
void AMRUpdateResidual(LevelData< MFCellFAB > &a_residual, const LevelData< MFCellFAB > &a_correction, const LevelData< MFCellFAB > &a_coarseCorrection) override final
Update AMR residual.
Definition CD_MFHelmholtzOp.cpp:960
void axby(LevelData< MFCellFAB > &a_lhs, const LevelData< MFCellFAB > &a_x, const LevelData< MFCellFAB > &a_y, const Real a_a, const Real a_b) override final
Set a_lhs = a*x + b*y.
Definition CD_MFHelmholtzOp.cpp:677
void residual(LevelData< MFCellFAB > &a_residual, const LevelData< MFCellFAB > &a_phi, const LevelData< MFCellFAB > &a_rhs, const bool a_homogeneousPhysBc) override final
Compute residual on this level.
Definition CD_MFHelmholtzOp.cpp:663
void relaxGSMultiColor(LevelData< MFCellFAB > &a_correction, const LevelData< MFCellFAB > &a_residual, const int a_iterations)
Multi-colored gauss-seidel relaxation.
Definition CD_MFHelmholtzOp.cpp:859
static constexpr int m_comp
Component that we solve for.
Definition CD_MFHelmholtzOp.H:592
bool m_multifluid
Multifluid operator or not.
Definition CD_MFHelmholtzOp.H:697
void AMRRestrict(LevelData< MFCellFAB > &a_residualCoarse, const LevelData< MFCellFAB > &a_residual, const LevelData< MFCellFAB > &a_correction, const LevelData< MFCellFAB > &a_coarseCorrection, bool a_skip_res) override final
Restrict residual.
Definition CD_MFHelmholtzOp.cpp:997
bool m_hasMGObjects
Has MG objects or not.
Definition CD_MFHelmholtzOp.H:702
void AMROperatorNC(LevelData< MFCellFAB > &a_Lphi, const LevelData< MFCellFAB > &a_phiFine, const LevelData< MFCellFAB > &a_phi, bool a_homogeneousPhysBC, AMRLevelOp< LevelData< MFCellFAB > > *a_finerOp) override final
Apply the AMR operator, i.e. compute L(phi) in an AMR context, assuming no coarser AMR levels.
Definition CD_MFHelmholtzOp.cpp:1137
void AMRResidualNC(LevelData< MFCellFAB > &a_residual, const LevelData< MFCellFAB > &a_phiFine, const LevelData< MFCellFAB > &a_phi, const LevelData< MFCellFAB > &a_rhs, bool a_homogeneousPhysBC, AMRLevelOp< LevelData< MFCellFAB > > *a_finerOp) override final
Compute AMR residual on coarsest.
Definition CD_MFHelmholtzOp.cpp:1087
Vector< IntVect > m_colors
"Colors" for the multi-coloered relaxation method
Definition CD_MFHelmholtzOp.H:612
void relaxPointJacobi(LevelData< MFCellFAB > &a_correction, const LevelData< MFCellFAB > &a_residual, const int a_iterations)
Jacobi relaxation.
Definition CD_MFHelmholtzOp.cpp:752
void setAcoAndBco(const RefCountedPtr< LevelData< MFCellFAB > > &a_Acoef, const RefCountedPtr< LevelData< MFFluxFAB > > &a_Bcoef, const RefCountedPtr< LevelData< MFBaseIVFAB > > &a_BcoefIrreg)
Update operators with new coefficients.
Definition CD_MFHelmholtzOp.cpp:226
void interpolateCF(const LevelData< MFCellFAB > &a_phi, const LevelData< MFCellFAB > *a_phiCoar, const bool a_homogeneousCF)
Do coarse-fine interpolation.
Definition CD_MFHelmholtzOp.cpp:612
IntVect m_ghostRhs
Number of ghost cells.
Definition CD_MFHelmholtzOp.H:727
MFHelmholtzOp & operator=(const MFHelmholtzOp &&a_oper)=delete
No move assignment allowed.
bool m_hasMGObjcts
True if there are multigrid levels.
Definition CD_MFHelmholtzOp.H:742
void AMRResidualNF(LevelData< MFCellFAB > &a_residual, const LevelData< MFCellFAB > &a_phi, const LevelData< MFCellFAB > &a_phiCoar, const LevelData< MFCellFAB > &a_rhs, bool a_homogeneousPhysBC) override final
Compute AMR residual on finest AMR level.
Definition CD_MFHelmholtzOp.cpp:1071
void relaxGSRedBlack(LevelData< MFCellFAB > &a_correction, const LevelData< MFCellFAB > &a_residual, const int a_iterations)
Jacobi relaxation.
Definition CD_MFHelmholtzOp.cpp:804
Real dotProduct(const LevelData< MFCellFAB > &a_lhs, const LevelData< MFCellFAB > &a_rhs) override final
Dot product.
Definition CD_MFHelmholtzOp.cpp:426
RefCountedPtr< LevelData< BaseIVFAB< Real > > > m_jump
Actual BC jump in data-based format. This is the right-hand side of dphi/dn1 + dphi/dn2 = jump.
Definition CD_MFHelmholtzOp.H:627
void setToZero(LevelData< MFCellFAB > &a_lhs) override final
Set to zero.
Definition CD_MFHelmholtzOp.cpp:367
void createCoarsened(LevelData< MFCellFAB > &a_lhs, const LevelData< MFCellFAB > &a_rhs, const int &a_refRat) override final
Create coarsening of data holder.
Definition CD_MFHelmholtzOp.cpp:522
std::map< int, RefCountedPtr< EBHelmholtzOp > > m_helmOps
Helmholtz operators on each phase. Note that I'm using int rather than Phase as identifier because th...
Definition CD_MFHelmholtzOp.H:617
Smoother m_smoother
Relaxation method.
Definition CD_MFHelmholtzOp.H:607
RefCountedPtr< EBHelmholtzOp > & getHelmOp(const int a_phase)
Get Helmholtz operator.
void updateJumpBC(const LevelData< MFCellFAB > &a_phi, const bool a_homogeneousPhysBC)
Update the jump condition.
Definition CD_MFHelmholtzOp.cpp:699
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
MFLevelGrid m_mflgCoFi
Coarsened version of this grid.
Definition CD_MFHelmholtzOp.H:657
MFHelmholtzOp(const MFHelmholtzOp &&a_op)=delete
No move construction allowed.
bool m_hasCoar
True if there is a coarser AMR level.
Definition CD_MFHelmholtzOp.H:732
void assignCopier(LevelData< MFCellFAB > &a_lhs, const LevelData< MFCellFAB > &a_rhs, const Copier &a_copier) override final
Assign lhs.
Definition CD_MFHelmholtzOp.cpp:383
int refToCoarser() override final
Return coarsening factor to coarser level (1 if there is no coarser level);.
Definition CD_MFHelmholtzOp.cpp:279
MFLevelGrid m_mflgFine
Fine level grid.
Definition CD_MFHelmholtzOp.H:647
Real norm(const LevelData< MFCellFAB > &a_lhs, int a_order) override final
Compute solution norm.
Definition CD_MFHelmholtzOp.cpp:407
void setAlphaAndBeta(const Real &a_alpha, const Real &a_beta) override final
Set alpha and beta.
Definition CD_MFHelmholtzOp.cpp:287
RefCountedPtr< LevelData< MFBaseIVFAB > > m_BcoefIrreg
Helmholtz B-coefficient on EB.
Definition CD_MFHelmholtzOp.H:687
int m_refToCoar
Refinement factor to coarser AMR level.
Definition CD_MFHelmholtzOp.H:717
const RefCountedPtr< LevelData< MFCellFAB > > & getAcoef()
Get the Helmholtz A-coefficient on cell centers.
Definition CD_MFHelmholtzOp.cpp:253
RefCountedPtr< LevelData< MFCellFAB > > m_Acoef
Helmholtz A-coefficient.
Definition CD_MFHelmholtzOp.H:677
void setJump(RefCountedPtr< LevelData< BaseIVFAB< Real > > > &a_jump)
Set the jump boundary condition.
Definition CD_MFHelmholtzOp.cpp:271
MFMultigridInterpolator m_interpolator
Multi grid interpolator.
Definition CD_MFHelmholtzOp.H:667
MFHelmholtzOp & operator=(const MFHelmholtzOp &a_oper)=delete
No copy assignment allowed.
MFLevelGrid m_mflgCoarMG
Coarse multigrid-grid.
Definition CD_MFHelmholtzOp.H:662
void assignLocal(LevelData< MFCellFAB > &a_lhs, const LevelData< MFCellFAB > &a_rhs) override final
Local assignment function.
Definition CD_MFHelmholtzOp.cpp:391
void buildCopier(Copier &a_copier, const LevelData< MFCellFAB > &a_lhs, const LevelData< MFCellFAB > &a_rhs) override
Build copier.
Definition CD_MFHelmholtzOp.cpp:399
Smoother
Relaxation methods for this operator.
Definition CD_MFHelmholtzOp.H:50
void create(LevelData< MFCellFAB > &a_lhs, const LevelData< MFCellFAB > &a_rhs) override final
Create method.
Definition CD_MFHelmholtzOp.cpp:490
void exchangeGhost(const LevelData< MFCellFAB > &a_phi) const
Perform an exchange operation, event if the data is const.
Definition CD_MFHelmholtzOp.cpp:707
Wrapper class for holding multifluid EBLevelGrids.
Definition CD_MFLevelGrid.H:30
Wrapper class for holding multifluid EBMultigridInterpolators.
Definition CD_MFMultigridInterpolator.H:27
Class which wraps EBRefluxs in multiphase.
Definition CD_MFReflux.H:27
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition CD_TracerParticleSolver.H:38
Namespace for encapsulating various data centerings.
Definition CD_Location.H:25
Cell
Enum for distinguishing between cell locations.
Definition CD_Location.H:31