chombo-discharge
Loading...
Searching...
No Matches
CD_FieldSolverMG.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
12
13#ifndef CD_FIELDSOLVERMG_H
14#define CD_FIELDSOLVERMG_H
15
16// Std includes
17#include <string>
18
19// Our includes
20#include <CD_FieldSolver.H>
21#include <CD_FieldSolverGMG.H>
22#ifdef CH_USE_PETSC
23#include <CD_FieldSolverAMG.H>
24#endif
25#include <CD_NamespaceHeader.H>
26
48{
49public:
54
59 FieldSolverMG(const FieldSolverMG& a_other) = delete;
60
65 FieldSolverMG(const FieldSolverMG&& a_other) = delete;
66
73 operator=(const FieldSolverMG& a_other) = delete;
74
81 operator=(const FieldSolverMG&& a_other) = delete;
82
86 virtual ~FieldSolverMG();
87
96 virtual bool
97 solve(MFAMRCellData& a_phi, const MFAMRCellData& a_rho, const EBAMRIVData& a_sigma, const bool a_zeroPhi) override;
98
102 virtual void
103 parseOptions() override;
104
108 virtual void
109 parseRuntimeOptions() override;
110
114 virtual void
115 registerOperators() override;
116
120 virtual void
121 allocate() override;
122
126 virtual void
127 deallocate() override;
128
132 virtual void
133 setupSolver() override;
134
138 virtual void
139 invalidateSolver() override;
140
149 virtual void
150 setSolverPermittivities(const MFAMRCellData& a_permittivityCell,
151 const MFAMRFluxData& a_permittivityFace,
152 const MFAMRIVData& a_permittivityEB) override;
153
159 virtual void
160 preRegrid(const int a_lbase, const int a_oldFinestLevel) override;
161
168 virtual void
169 regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override;
170
176 virtual void
177 computeElectricField(MFAMRCellData& a_E, const MFAMRCellData& a_potential) const override;
178
184 virtual void
185 computeElectricField(MFAMRFluxData& a_E, const MFAMRCellData& a_potential) const override;
186
193 virtual void
194 computeElectricField(EBAMRCellData& a_E,
195 const phase::which_phase a_phase,
196 const MFAMRCellData& a_potential) const override;
197
204 virtual void
205 computeElectricField(EBAMRFluxData& a_E,
206 const phase::which_phase a_phase,
207 const MFAMRCellData& a_potential) const override;
208
215 virtual Vector<long long>
216 computeLoads(const DisjointBoxLayout& a_dbl, const int a_level) override;
217
218protected:
222 RefCountedPtr<FieldSolverGMG> m_gmg;
223
228
233
238
243
247 MFAMRCellData m_solverPermCell;
248
252 MFAMRFluxData m_solverPermFace;
253
257 MFAMRIVData m_solverPermEB;
258
259#ifdef CH_USE_PETSC
263 RefCountedPtr<FieldSolverAMG> m_amg;
264
268 MFAMRCellData m_phiStart;
269
274
279
284
289#endif
290
296 virtual void
298
302 virtual void
303 syncSolvers();
304
305#ifdef CH_USE_PETSC
311 virtual bool
312 isAMGSupported(std::string& a_reason) const;
313
321 virtual bool
322 solveAMG(MFAMRCellData& a_phi, const MFAMRCellData& a_rho, const EBAMRIVData& a_sigma);
323#endif
324};
325
326#include <CD_NamespaceFooter.H>
327
328#endif
Declaration of the FieldSolverAMG class.
Declaration of FieldSolverGMG.
Contains declaration of a base electrostatics solver class.
virtual Vector< long long > computeLoads(const DisjointBoxLayout &a_dbl, const int a_level) override
Compute grid loads, from the geometric multigrid relaxation.
Definition CD_FieldSolverMG.cpp:548
virtual void parseRuntimeOptions() override
Parse class options that can change at run time.
Definition CD_FieldSolverMG.cpp:70
virtual void invalidateSolver() override
Discard the discretizations and the solver hierarchies of both solvers.
Definition CD_FieldSolverMG.cpp:266
FieldSolverMG & operator=(const FieldSolverMG &&a_other)=delete
Disallowed move assignment operator.
int m_solvesSinceProbe
Number of solves since geometric multigrid was last tried.
Definition CD_FieldSolverMG.H:288
virtual void syncSolvers()
Share this solver's data and configuration with the solvers that exist.
Definition CD_FieldSolverMG.cpp:162
virtual void registerOperators() override
Register the AMR operators that the geometric and algebraic multigrid solvers need.
Definition CD_FieldSolverMG.cpp:179
virtual void parseOptions() override
Parse class options, including those of the geometric and algebraic multigrid solvers.
Definition CD_FieldSolverMG.cpp:51
virtual void regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override
Regrid. The solvers are set up again on the next solve.
Definition CD_FieldSolverMG.cpp:328
int m_bcOrder
Order of the EB stencils on electrodes and dielectric interfaces, in both solvers.
Definition CD_FieldSolverMG.H:232
RefCountedPtr< FieldSolverAMG > m_amg
The algebraic multigrid solver. Null unless amg_fallback is true.
Definition CD_FieldSolverMG.H:263
virtual void allocate() override
Allocate the data, and share it with the solvers.
Definition CD_FieldSolverMG.cpp:195
virtual ~FieldSolverMG()
Destructor.
Definition CD_FieldSolverMG.cpp:45
MFAMRCellData m_solverPermCell
Cell-centered permittivity from the last setSolverPermittivities. Shares the caller's storage.
Definition CD_FieldSolverMG.H:247
RefCountedPtr< FieldSolverGMG > m_gmg
The geometric multigrid solver.
Definition CD_FieldSolverMG.H:222
virtual bool solveAMG(MFAMRCellData &a_phi, const MFAMRCellData &a_rho, const EBAMRIVData &a_sigma)
Solve with algebraic multigrid, setting it up first if needed.
Definition CD_FieldSolverMG.cpp:464
bool m_amgFallback
Fall back to algebraic multigrid or not.
Definition CD_FieldSolverMG.H:273
virtual void deallocate() override
Release the data, also in the solvers.
Definition CD_FieldSolverMG.cpp:214
MFAMRCellData m_phiStart
Initial guess of the current solve. Algebraic multigrid starts from it when geometric multigrid fails...
Definition CD_FieldSolverMG.H:268
bool m_amgLatched
True after algebraic multigrid rescued a solve, until geometric multigrid converges again.
Definition CD_FieldSolverMG.H:278
virtual void setupSolver() override
Set up geometric multigrid. Algebraic multigrid is set up when it is first needed.
Definition CD_FieldSolverMG.cpp:238
MFAMRFluxData m_solverPermFace
Face-centered permittivity from the last setSolverPermittivities. Shares the caller's storage.
Definition CD_FieldSolverMG.H:252
virtual void preRegrid(const int a_lbase, const int a_oldFinestLevel) override
Cache the potential before a regrid, and discard both solvers.
Definition CD_FieldSolverMG.cpp:315
bool m_hasSolverPermittivities
True if setSolverPermittivities was called after the last setup.
Definition CD_FieldSolverMG.H:242
FieldSolverMG()
Constructor. Creates the geometric multigrid solver.
Definition CD_FieldSolverMG.cpp:25
virtual void parseSolverSettings()
Parse the settings of both solvers, the EB stencils and the fallback.
Definition CD_FieldSolverMG.cpp:84
FieldSolverMG(const FieldSolverMG &&a_other)=delete
Disallowed move constructor.
MFAMRIVData m_solverPermEB
EB-centered permittivity from the last setSolverPermittivities. Shares the caller's storage.
Definition CD_FieldSolverMG.H:257
int m_amgRetryInterval
While latched, geometric multigrid is re-tried every this many solves.
Definition CD_FieldSolverMG.H:283
int m_bcWeight
Least-squares weight of the EB stencils on electrodes and dielectric interfaces, in both solvers.
Definition CD_FieldSolverMG.H:237
FieldSolverMG & operator=(const FieldSolverMG &a_other)=delete
Disallowed copy assignment operator.
FieldSolverMG(const FieldSolverMG &a_other)=delete
Disallowed copy constructor.
virtual bool isAMGSupported(std::string &a_reason) const
Check if algebraic multigrid supports the current domain and grids.
Definition CD_FieldSolverMG.cpp:431
virtual void setSolverPermittivities(const MFAMRCellData &a_permittivityCell, const MFAMRFluxData &a_permittivityFace, const MFAMRIVData &a_permittivityEB) override
Change the permittivities used by the solvers, e.g. for a semi-implicit scheme.
Definition CD_FieldSolverMG.cpp:285
virtual bool solve(MFAMRCellData &a_phi, const MFAMRCellData &a_rho, const EBAMRIVData &a_sigma, const bool a_zeroPhi) override
Solve the Poisson equation, with geometric multigrid first and algebraic multigrid as fallback.
Definition CD_FieldSolverMG.cpp:341
bool m_isSolverSetup
Is the solver set up or not.
Definition CD_FieldSolverMG.H:227
FieldSolver()
Constructor.
Definition CD_FieldSolver.cpp:34
virtual void computeElectricField()
Compute the cell-centered electric field.
Definition CD_FieldSolver.cpp:131
which_phase
Enumeration of supported phases.
Definition CD_MultiFluidIndexSpace.H:38