MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
CouplerFvMultilevelInterpolation< nDim, SysEqn > Class Template Referencefinal

FV multilevel interpolation coupler to transfer solution data of a coarse grid onto a finer grid. More...

#include <couplerfvmultilevel.h>

Inheritance diagram for CouplerFvMultilevelInterpolation< nDim, SysEqn >:
[legend]
Collaboration diagram for CouplerFvMultilevelInterpolation< nDim, SysEqn >:
[legend]

Public Types

using BaseCoupler = CouplerFvMultilevel< nDim, SysEqn >
 
using Base = typename BaseCoupler::Base
 
using BaseFv = typename BaseCoupler::BaseFv
 
- Public Types inherited from CouplerFvMultilevel< nDim, SysEqn >
using Base = Coupling
 
using BaseFv = CouplingFv< nDim, SysEqn >
 
using SolverType = typename BaseFv::solverType
 
using Grid = CartesianGrid< nDim >
 
using GridProxy = typename SolverType::GridProxy
 
- Public Types inherited from CouplingFv< nDim, SysEqn >
using solverType = FvCartesianSolverXD< nDim, SysEqn >
 

Public Member Functions

 CouplerFvMultilevelInterpolation (const MInt couplingId, std::vector< FvCartesianSolverXD< nDim, SysEqn > * > solvers)
 Constructor for multilevel interpolation coupler. More...
 
 ~CouplerFvMultilevelInterpolation ()
 
void postCouple (MInt) override
 Coupling routine to transfer coarse level restart data to the finest level/solver. More...
 
solverTypefvSolver (const MInt solverId=0) const
 
MInt noSolvers () const
 
void prolongation (const MInt level)
 Prolong the solution on the given coarse level onto the next finer level. More...
 
MBool startTimer (const MString &name)
 
MBool stopTimer (const MString &name)
 
- Public Member Functions inherited from CouplerFvMultilevel< nDim, SysEqn >
 CouplerFvMultilevel (const MInt couplingId, std::vector< FvCartesianSolverXD< nDim, SysEqn > * > solvers)
 
 ~CouplerFvMultilevel ()
 
void init () override
 
void finalizeSubCoupleInit (MInt)
 
void finalizeCouplerInit ()
 call after the initial adaptation when all cells are refined correctly More...
 
void preCouple (MInt) override
 
void subCouple (MInt, MInt, std::vector< MBool > &) override
 
void postCouple (MInt) override
 
void cleanUp ()
 
void getDomainDecompositionInformation (std::vector< std::pair< MString, MInt > > &NotUsed(domainInfo)) override
 Return information on current domain decomposition (e.g. number of coupled cells/elements/...) More...
 
void finalizeAdaptation (MInt solverId)
 call after the initial adaptation when all cells are refined correctly More...
 
void readProperties () override
 
void checkProperties () override
 
void restriction (const MInt level)
 Restrict the solution on the given fine level onto the next coarser level. More...
 
void resetTau (const MInt level)
 Reset the coarse level correction tau. More...
 
void prolongation (const MInt level)
 Prolong the solution on the given coarse level onto the next finer level. More...
 
void sanityCheck ()
 
MBool startTimer (const MString &name)
 
MBool stopTimer (const MString &name)
 
solverTypefvSolver (const MInt solverId=0) const
 
MInt noSolvers () const
 
- Public Member Functions inherited from CouplingFv< nDim, SysEqn >
 CouplingFv (const MInt couplingId, std::vector< FvCartesianSolverXD< nDim, SysEqn > * > fvSolvers, const MInt noSolvers)
 
 CouplingFv (const MInt couplingId, Solver *solvers)
 
 ~CouplingFv () override=default
 
 CouplingFv (const CouplingFv &)=delete
 
CouplingFvoperator= (const CouplingFv &)=delete
 
- Public Member Functions inherited from Coupling
 Coupling (const MInt couplingId)
 
virtual ~Coupling ()=default
 
 Coupling (const Coupling &)=delete
 
Couplingoperator= (const Coupling &)=delete
 
MInt couplerId () const
 
virtual void init ()=0
 
virtual void finalizeSubCoupleInit (MInt solverId)=0
 
virtual void finalizeCouplerInit ()=0
 
virtual void preCouple (MInt recipeStep)=0
 
virtual void subCouple (MInt recipeStep, MInt solverId, std::vector< MBool > &solverCompleted)=0
 
virtual void postCouple (MInt recipeStep)=0
 
virtual void cleanUp ()=0
 
virtual void balancePre ()
 Load balancing. More...
 
virtual void balancePost ()
 
virtual void reinitAfterBalance ()
 
virtual void prepareAdaptation ()
 
virtual void postAdaptation ()
 
virtual void finalizeAdaptation (const MInt)
 
virtual void writeRestartFile (const MInt)
 
virtual MInt noCellDataDlb () const
 Methods to inquire coupler data during balancing. More...
 
virtual MInt cellDataTypeDlb (const MInt NotUsed(dataId)) const
 
virtual MInt cellDataSizeDlb (const MInt NotUsed(dataId), const MInt NotUsed(cellId))
 
virtual void getCellDataDlb (const MInt NotUsed(dataId), const MInt NotUsed(oldNoCells), const MInt *const NotUsed(bufferIdToCellId), MInt *const NotUsed(data))
 
virtual void getCellDataDlb (const MInt NotUsed(dataId), const MInt NotUsed(oldNoCells), const MInt *const NotUsed(bufferIdToCellId), MLong *const NotUsed(data))
 
virtual void getCellDataDlb (const MInt NotUsed(dataId), const MInt NotUsed(oldNoCells), const MInt *const NotUsed(bufferIdToCellId), MFloat *const NotUsed(data))
 
virtual void setCellDataDlb (const MInt NotUsed(dataId), const MInt *const NotUsed(data))
 
virtual void setCellDataDlb (const MInt NotUsed(dataId), const MLong *const NotUsed(data))
 
virtual void setCellDataDlb (const MInt NotUsed(dataId), const MFloat *const NotUsed(data))
 
virtual void finalizeBalance (const MInt)
 
virtual MInt noCouplingTimers (const MBool NotUsed(allTimings)) const
 Number of coupling timers. More...
 
virtual void getCouplingTimings (std::vector< std::pair< MString, MFloat > > &NotUsed(timings), const MBool NotUsed(allTimings))
 Return coupling timings. More...
 
virtual void getDomainDecompositionInformation (std::vector< std::pair< MString, MInt > > &NotUsed(domainInfo))
 Return information on current domain decomposition (e.g. number of coupled cells/elements/...) More...
 
void setDlbTimer (const MInt timerId)
 
void startLoadTimer (const MString &name) const
 Start the load timer of the coupler. More...
 
void stopLoadTimer (const MString &name) const
 Stop the load timer of the coupler. More...
 

Private Member Functions

void reset (const MInt level)
 Reset variables/slopes of a level/solver. More...
 

Additional Inherited Members

- Protected Member Functions inherited from CouplingFv< nDim, SysEqn >
MInt noSolvers () const
 
solverTypefvSolver (const MInt solverId=0) const
 
MInt a_noFvCells () const
 
MInt a_noFvGridCells () const
 
- Protected Member Functions inherited from Coupling
MFloat returnLoadRecord () const
 
MFloat returnIdleRecord () const
 
- Protected Attributes inherited from CouplingFv< nDim, SysEqn >
std::vector< solverType * > m_fvSolvers {}
 

Detailed Description

template<MInt nDim, class SysEqn>
class CouplerFvMultilevelInterpolation< nDim, SysEqn >

Definition at line 106 of file couplerfvmultilevel.h.

Member Typedef Documentation

◆ Base

template<MInt nDim, class SysEqn >
using CouplerFvMultilevelInterpolation< nDim, SysEqn >::Base = typename BaseCoupler::Base

Definition at line 109 of file couplerfvmultilevel.h.

◆ BaseCoupler

template<MInt nDim, class SysEqn >
using CouplerFvMultilevelInterpolation< nDim, SysEqn >::BaseCoupler = CouplerFvMultilevel<nDim, SysEqn>

Definition at line 108 of file couplerfvmultilevel.h.

◆ BaseFv

template<MInt nDim, class SysEqn >
using CouplerFvMultilevelInterpolation< nDim, SysEqn >::BaseFv = typename BaseCoupler::BaseFv

Definition at line 110 of file couplerfvmultilevel.h.

Constructor & Destructor Documentation

◆ CouplerFvMultilevelInterpolation()

template<MInt nDim, class SysEqn >
CouplerFvMultilevelInterpolation< nDim, SysEqn >::CouplerFvMultilevelInterpolation ( const MInt  couplingId,
std::vector< FvCartesianSolverXD< nDim, SysEqn > * >  solvers 
)

Definition at line 1311 of file couplerfvmultilevel.cpp.

1313 : Base(couplingId), BaseCoupler(couplingId, solvers) {
1314 TRACE();
1315}
typename BaseCoupler::Base Base
CouplerFvMultilevel< nDim, SysEqn > BaseCoupler
MInt * solvers
Definition: maiatypes.h:72

◆ ~CouplerFvMultilevelInterpolation()

template<MInt nDim, class SysEqn >
CouplerFvMultilevelInterpolation< nDim, SysEqn >::~CouplerFvMultilevelInterpolation ( )
inline

Definition at line 121 of file couplerfvmultilevel.h.

121{ TRACE(); };

Member Function Documentation

◆ fvSolver()

template<MInt nDim, class SysEqn >
solverType & CouplingFv< nDim, SysEqn >::fvSolver ( const MInt  solverId = 0) const
inline

Definition at line 38 of file coupling.h.

386 {
387 ASSERT(solverId < noSolvers(), "Invalid solverId " + std::to_string(solverId) + "/" + std::to_string(noSolvers()));
388 return *m_fvSolvers[solverId];
389 }
std::vector< solverType * > m_fvSolvers
Definition: coupling.h:395

◆ noSolvers()

template<MInt nDim, class SysEqn >
MInt CouplingFv< nDim, SysEqn >::noSolvers ( ) const
inline

Definition at line 39 of file coupling.h.

385{ return m_fvSolvers.size(); }

◆ postCouple()

template<MInt nDim, class SysEqn >
void CouplerFvMultilevelInterpolation< nDim, SysEqn >::postCouple ( MInt  )
overridevirtual

Reimplemented from CouplerFvMultilevel< nDim, SysEqn >.

Definition at line 1320 of file couplerfvmultilevel.cpp.

1320 {
1321 TRACE();
1322 startTimer("Main");
1323
1324 for(MInt solverId = 0; solverId < noSolvers(); solverId++) {
1325 if(fvSolver(solverId).getSolverStatus()) {
1326 TERMM(1, "Multilevel interpolation postCouple(): found active solver/level - all solvers should be inactive!");
1327 }
1328 }
1329
1330 // Reset solution unless for the coarsest level with the actual restart data
1331 for(MInt i = 0; i < noSolvers() - 1; i++) {
1332 reset(i); // Resets also the restricted variables for the next coarser level
1333 }
1334
1335 // Prolong the coarse level restart data to the finest level (since the restricted vars and the stored slopes are set
1336 // to 0 above the full solution is transferred to the next finer level)
1337 for(MInt i = noSolvers() - 1; i > 0; i--) {
1338 prolongation(i);
1339 }
1340
1341 stopTimer("Main");
1342}
solverType & fvSolver(const MInt solverId=0) const
Definition: coupling.h:386
void reset(const MInt level)
Reset variables/slopes of a level/solver.
MBool stopTimer(const MString &name)
void prolongation(const MInt level)
Prolong the solution on the given coarse level onto the next finer level.
MBool startTimer(const MString &name)
MBool getSolverStatus()
Get the solver status indicating if the solver is currently active in the execution recipe.
Definition: solver.h:401
int32_t MInt
Definition: maiatypes.h:62

◆ prolongation()

template<MInt nDim, class SysEqn >
void CouplerFvMultilevel< nDim, SysEqn >::prolongation ( const MInt  level)

Definition at line 60 of file couplerfvmultilevel.cpp.

492 {
493 TRACE();
494
495 startTimer("Prolongation");
496
497 // Store references and variables for convenience
498 auto& coarse = static_cast<SolverType&>(fvSolver(level));
499 auto& fine = static_cast<SolverType&>(fvSolver(level - 1));
500
501 // only halo cells only primary variables are correct at this point!
502 if(m_prolongationMethod == 2) {
503 // Temporarily store gradients
504 startTimer("StoreGradients");
505 const MInt noCells = coarse.noInternalCells();
506 const MInt noVars = coarse.CV->noVariables;
507 MFloatScratchSpace slopes(noCells * noVars * nDim, AT_, "slopes");
508 for(MInt cellId = 0; cellId < noCells; cellId++) {
509 for(MInt varId = 0; varId < noVars; varId++) {
510 for(MInt i = 0; i < nDim; i++) {
511 slopes[cellId * noVars * nDim + varId * nDim + i] = coarse.a_storedSlope(cellId, varId, i);
512 }
513 }
514 }
515 stopTimer("StoreGradients");
516
517 // Calculate new gradients after the completed coarse time step
518 startTimer("CalcGradientsProlongation");
519 coarse.LSReconstructCellCenterCons(0);
520 stopTimer("CalcGradientsProlongation");
521
522 // Compute delta in gradients
523 startTimer("CalcGradientDelta");
524 for(MInt cellId = 0; cellId < noCells; cellId++) {
525 for(MInt varId = 0; varId < noVars; varId++) {
526 for(MInt i = 0; i < nDim; i++) {
527 coarse.a_storedSlope(cellId, varId, i) -= slopes[cellId * noVars * nDim + varId * nDim + i];
528 }
529 }
530 }
531 stopTimer("CalcGradientDelta");
532 }
533
534 prolongData(level);
535
536 // Re-compute boundary conditions etc. based on new/corrected variable state in the fine cell
537 startTimer("FineLhsBnd");
538 fine.exchangeData(&fine.a_variable(0, 0), fine.CV->noVariables);
539
540 fine.lhsBnd();
541
542 stopTimer("FineLhsBnd");
543
544 stopTimer("Prolongation");
545}
void prolongData(const MInt level)
Prolong the data of a coarse level.
This class is a ScratchSpace.
Definition: scratch.h:758
SolverType
Definition: enums.h:22
void const MInt cellId
Definition: collector.h:239

◆ reset()

template<MInt nDim, class SysEqn >
void CouplerFvMultilevelInterpolation< nDim, SysEqn >::reset ( const MInt  level)
private

Definition at line 1347 of file couplerfvmultilevel.cpp.

1347 {
1348 TRACE();
1349
1350 auto& fine = fvSolver(level);
1351 auto& coarse = fvSolver(level + 1);
1352 const MInt noVars = fine.CV->noVariables;
1353
1354 for(MInt cellId = 0; cellId < fine.noInternalCells(); cellId++) {
1355 for(MInt varId = 0; varId < noVars; varId++) {
1356 // Reset variables on this level
1357 fine.a_variable(cellId, varId) = 0.0;
1358 for(MInt dim = 0; dim < nDim; dim++) {
1359 // ... and slopes (of conservative variables)
1360 fine.a_storedSlope(cellId, varId, dim) = 0.0;
1361 }
1362 }
1363 }
1364
1365 for(MInt cellId = 0; cellId < coarse.noInternalCells(); cellId++) {
1366 for(MInt varId = 0; varId < noVars; varId++) {
1367 // Reset restricted variables on next coarser level
1368 coarse.a_restrictedVar(cellId, varId) = 0.0;
1369 for(MInt dim = 0; dim < nDim; dim++) {
1370 // ... and slopes (of conservative variables)
1371 coarse.a_storedSlope(cellId, varId, dim) = 0.0;
1372 }
1373 }
1374 }
1375}

◆ startTimer()

template<MInt nDim, class SysEqn >
MBool CouplerFvMultilevel< nDim, SysEqn >::startTimer ( const MString name)

Definition at line 62 of file couplerfvmultilevel.cpp.

1252 {
1253 if(name.empty()) {
1254 TERMM(1, "Empty timer name");
1255 }
1256 RECORD_TIMER_START(timer(name));
1257 return true;
1258}
MInt timer(const MString &name)

◆ stopTimer()

template<MInt nDim, class SysEqn >
MBool CouplerFvMultilevel< nDim, SysEqn >::stopTimer ( const MString name)

Definition at line 63 of file couplerfvmultilevel.cpp.

1262 {
1263 if(name.empty()) {
1264 TERMM(1, "Empty timer name");
1265 }
1266 RECORD_TIMER_STOP(timer(name));
1267 return true;
1268}

The documentation for this class was generated from the following files: