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

#include <lbdgape.h>

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

Classes

struct  ConversionFactors
 

Public Types

using Base = Coupling
 
using BaseLb = CouplingLB< nDim, nDist, SysEqn >
 
using LbSolver = typename BaseLb::solverType
 
using SysEqnDg = DgSysEqnAcousticPerturb< nDim >
 
using BaseDg = CouplingDgApe< nDim, BaseLb >
 
using DgSolver = typename BaseDg::DgCartesianSolverType
 
- Public Types inherited from CouplingDgApe< nDim, CouplingLB< nDim, nDist, SysEqn > >
using Base = Coupling
 
using BaseDonor = CouplingLB< nDim, nDist, SysEqn >
 
using DonorSolverType = typename BaseDonor::solverType
 
using SysEqn = DgSysEqnAcousticPerturb< nDim >
 
using ProjectionType = DgGalerkinProjection< nDim >
 
using BaseDg = CouplingDg< nDim, DgSysEqnAcousticPerturb< nDim > >
 
using DgCartesianSolverType = typename BaseDg::solverType
 
using MV = MeanVariables< nDim >
 Hold indices for mean variables. More...
 
- Public Types inherited from CouplingLB< nDim, nDist, SysEqn >
using solverType = LbSolverDxQy< nDim, nDist, SysEqn >
 
using LbBndCnd = LbBndCndDxQy< nDim, nDist, SysEqn >
 
using MbCellCollector = maia::lb::collector::LbMbCellCollector< nDim >
 
- Public Types inherited from CouplingDg< nDim, DgSysEqnAcousticPerturb< nDim > >
using solverType = DgCartesianSolver< nDim, DgSysEqnAcousticPerturb< nDim > >
 
using CV = typename SysEqn::CV
 

Public Member Functions

 LbDgApe (const MInt couplingId, LbSolver *const lb, DgSolver *const dg)
 
 ~LbDgApe ()
 
void init () override
 
void finalizeCouplerInit () override
 
solverTypelbSolver (const MInt solverId=0) const
 
- Public Member Functions inherited from CouplingDgApe< nDim, CouplingLB< nDim, nDist, SysEqn > >
 CouplingDgApe (const MInt couplingId, DgCartesianSolverType *dg, DonorSolverType *ds)
 Initialize timers and read properties in c'tor. More...
 
virtual ~CouplingDgApe ()=default
 
void init () override
 
void finalizeSubCoupleInit (MInt) override final
 
void preCouple (MInt) final
 Calculate source terms and add to the external source terms of the DG solver. More...
 
void subCouple (MInt, MInt, std::vector< MBool > &) override final
 
void postCouple (MInt) override final
 
void cleanUp () override final
 
void getCouplingTimings (std::vector< std::pair< MString, MFloat > > &timings, const MBool allTimings) override
 
void getDomainDecompositionInformation (std::vector< std::pair< MString, MInt > > &domainInfo) override final
 
MInt noCouplingTimers (const MBool allTimings) const override
 
MInt noMeanVars () const
 Return number of mean variables. More...
 
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...
 
- Public Member Functions inherited from CouplingLB< nDim, nDist, SysEqn >
 CouplingLB (const MInt couplingId, Solver *solvers, const MInt noSolvers=1)
 
 CouplingLB (const MInt couplingId, std::vector< solverType * > solvers)
 
MFloat a_physicalTime () const
 
MFloat lsTimeStep () const
 
MInt a_RKStep () const
 
MInt a_noLbCells (const MInt id=0) const
 
MInt a_noLevelSetsMb (const MInt id=0) const
 
MFloat a_Ma (const MInt id=0) const
 
MFloat a_Re (const MInt id=0) const
 
MInt a_pvu (const MInt id=0) const
 
MInt a_pvv (const MInt id=0) const
 
MInt a_pvw (const MInt id=0) const
 
MInt a_pvrho (const MInt id=0) const
 
MInt a_pvt (const MInt id=0) const
 
MInt a_isThermal (const MInt id=0) const
 
MInt a_noDistributions (const MInt id=0) const
 
MFloat a_initTemperatureKelvin (const MInt id=0) const
 
MFloat a_time () const
 
MbCellCollectora_mbCell (const MInt id=0)
 
MInt a_boundaryCellMb (const MInt cellId, const MInt id=0)
 
MFloata_levelSetFunctionMb (const MInt cellId, const MInt set, const MInt id=0)
 
MFloat a_levelSetFunctionMb (const MInt cellId, const MInt set, const MInt id=0) const
 
MInta_associatedBodyIdsMb (const MInt cellId, const MInt set, const MInt id=0)
 
MInt a_associatedBodyIdsMb (const MInt cellId, const MInt set, const MInt id=0) const
 
MInt a_parentId (const MInt cellId, const MInt id=0)
 
MInt a_childId (const MInt cellId, const MInt child, const MInt id=0)
 
MInt minCell (const MInt index, const MInt id=0) const
 
MInt noMinCells (const MInt id=0) const
 
MInt a_noCells (const MInt id=0) const
 
MFloat a_cellLengthAtLevel (MInt level, const MInt id=0)
 
MInt a_noEmbeddedBodiesLB (const MInt id=0) const
 
MBool a_isActive (const MInt cellId, const MInt id=0) const
 
MBool a_wasActive (const MInt cellId, const MInt id=0) const
 
MInt a_noVariables (const MInt id=0) const
 
MFloata_variable (const MInt cellId, const MInt varId, const MInt id=0)
 
MFloata_oldVariable (const MInt cellId, const MInt varId, const MInt id=0)
 
MInt a_bndCellId (const MInt bndCell, const MInt id=0)
 
MInt a_noBndCells (const MInt id=0)
 
- 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...
 
- Public Member Functions inherited from CouplingDg< nDim, DgSysEqnAcousticPerturb< nDim > >
 CouplingDg (const MInt couplingId, solverType *b)
 
virtual ~CouplingDg ()=default
 
solverTypedgSolver () const
 Return MPI communicator. More...
 
MInt solverId () const
 Return solver id. More...
 
DgSysEqnAcousticPerturb< nDim > & sysEqn ()
 Return reference to SysEqn object. More...
 
ElementCollectorelements ()
 Return reference to elements. More...
 
MInt noElements () const
 Return number of elements. More...
 
MFloatexternalSource () const
 Return pointer to external source memory. More...
 
MInt getElementByCellId (const MInt cellId)
 Return element id for cell id. More...
 
MInt minPolyDeg () const
 Return the minimum polynomial degree. More...
 
MInt maxPolyDeg () const
 Return the maximum polynomial degree. More...
 
MString outputDir () const
 Return output directory. More...
 
void saveNodalData (const MString &fileNameBase, const MInt noVars, const std::vector< MString > &varNames, const MFloat *const data) const
 Save nodal data to file. More...
 

Private Member Functions

void initConversionFactors ()
 
LbSolverdonorSolver (const MInt xSolverId=0) const override
 
void getDonorVelocityAndVorticity (const std::vector< MInt > &donorCellIds, MFloatScratchSpace &p_velocity, MFloatScratchSpace &p_vorticity) override
 Get velocity and vorticity of donor solver. More...
 
virtual void performUnitConversion (const MString &, const MInt, const MInt, MFloat *) override
 Transform data from donor solver unit system into DG unit system. More...
 
void calcSourceLambLinearized (const MFloat *const, const MFloat *const, MFloat *) override
 
void calcSourceLambNonlinear (const MFloat *const velocity, const MFloat *const vorticity, MFloat *const sourceTerms) override
 
void calcSourceQmII (const MFloat *const, MFloat *const) override
 
void calcSourceQmIII (const MFloat *const, MFloat *) override
 
void calcSourceQe (const MFloat *const, const MFloat, MFloat *const) override
 
void calcSourceQc (const MFloat *const, MFloat *const, const MFloat, const MInt) override
 

Private Attributes

struct LbDgApe::ConversionFactors m_conversionLb2Dg
 

Additional Inherited Members

- Static Public Member Functions inherited from CouplingDgApe< nDim, CouplingLB< nDim, nDist, SysEqn > >
static constexpr MInt noVelocities ()
 Return number of velocity variables. More...
 
static constexpr MInt noVorticities ()
 Return number of vorticity variables. More...
 
- Protected Types inherited from CouplingDg< nDim, DgSysEqnAcousticPerturb< nDim > >
using ElementCollector = maia::dg::collector::ElementCollector< nDim, DgSysEqnAcousticPerturb< nDim > >
 
- Protected Member Functions inherited from CouplingDgApe< nDim, CouplingLB< nDim, nDist, SysEqn > >
void calcInitialCondition (const MFloat time)
 Apply initial conditions for this coupling condition. More...
 
void initCoupler ()
 Initialize the coupling condition (data structures). More...
 
void initData ()
 Initialize the data (initial conditions or for a restart) of the coupling condition. More...
 
void initProjection ()
 Initialize the projection information for spatial coupling. More...
 
void initRestart (const MFloat time, const MFloat dt)
 Perform initializations for a restart. More...
 
void initSourceFilter ()
 Calculate source filter values for all elements and store element ids on which source terms need to be computed. More...
 
void initTimers ()
 Create timers. More...
 
MBool loadCouplingData (const MString &filename, const MString &name_, const MInt stride, MFloat *data)
 Auxiliary method to load coupling data (i.e. anything coming from the LES) from a file. More...
 
void loadMeanQuantities (const MBool skipNodeVars=false)
 Load mean velocities from file and store them to the node variables. More...
 
void projectToElement (const MInt elementId, const MInt noVars, const MFloat *data, const MFloat *defaultValues, MFloat *target)
 Project the given data fields onto a single element. More...
 
void saveFilterValues ()
 Save filter values to file. More...
 
void saveFilterValuesDonor ()
 Save the filter values on the donor cells. More...
 
void applyStoredSources (const MFloat time)
 Apply the stored source terms to the time derivative. More...
 
void storeSources (const MFloat time, const MInt timeStep)
 Load coupling data from LES, then calculate, accumulate, project and store coupling source terms. More...
 
virtual void performUnitConversion (const MString &, const MInt, const MInt, MFloat *)
 
virtual void calcSourceLambLinearized (const MFloat *const velocity, const MFloat *const vorticity, MFloat *sourceTerms)=0
 
virtual void calcSourceLambNonlinear (const MFloat *const velocity, const MFloat *const vorticity, MFloat *const sourceTerms)=0
 
virtual void calcSourceQmII (const MFloat *const velocity, MFloat *const sourceTerms)=0
 
virtual void calcSourceQmIII (const MFloat *const velocity, MFloat *sourceTerms)=0
 
virtual void calcSourceQe (const MFloat *const velocity, const MFloat time, MFloat *const sourceTerms)=0
 
virtual void calcSourceQc (const MFloat *const velocity, MFloat *const sourceTerms, const MFloat time, const MInt timeStep)=0
 
void saveSourceTermsDonorGrid (const MInt timeStep, const MFloat *const data)
 Store the source terms on the donor grid. More...
 
void saveSourceTermsTargetGrid (const MInt timeStep)
 Store the source terms on the target grid, i.e. after interpolation. More...
 
void readProperties () override final
 Read properties and store in member variables. More...
 
void checkProperties () override final
 
virtual DonorSolverTypedonorSolver (const MInt solverId=0) const=0
 
virtual void getDonorVelocityAndVorticity (const std::vector< MInt > &donorCellIds, MFloatScratchSpace &p_velocity, MFloatScratchSpace &p_vorticity)=0
 
- Protected Member Functions inherited from CouplingLB< nDim, nDist, SysEqn >
MInt noSolvers () const
 
solverTypelbSolver (const MInt solverId=0) const
 
LbBndCndlbBndCnd (const MInt id=0)
 
- Protected Member Functions inherited from Coupling
MFloat returnLoadRecord () const
 
MFloat returnIdleRecord () const
 
- Protected Attributes inherited from CouplingDgApe< nDim, CouplingLB< nDim, nDist, SysEqn > >
MBool m_isRestart
 Store whether this is a restart (in case special treatment is necessary) More...
 
MBool m_hasDgCartesianSolver
 Store whether this domain has DG cells/elements. More...
 
MBool m_hasDonorCartesianSolver
 Store whether this domain has Cartesian donor solver cells. More...
 
MInt m_maxNoNodesXD
 Maximum number of nodes of an element (corresponding to maxPolyDeg) More...
 
MFloat m_fixedTimeStep
 Fixed time step to use. More...
 
MFloat m_previousTime
 Previous time for the calculation of time derivatives. More...
 
MInt m_previousTimeStep
 Previous time step (to determine whether new sources need to be calculated) More...
 
std::vector< MIntm_activeMeanVars
 List of active mean variables for all active source terms. More...
 
MString m_meanDataFileName
 File name for mean quantities. More...
 
std::vector< MIntm_activeSourceTerms
 List of active source terms. More...
 
MBool m_saveSourceTermsDonorGrid
 Store whether the sources on the donor grid should be saved as well. More...
 
MInt m_saveSourceTermsInterval
 Interval at which source term data should be saved to disk. More...
 
MBool m_calcProjectionError
 Calculate the L2 error of the Galerkin projection. More...
 
MInt m_noActiveDonorCells
 
MInt m_noDonorCells
 Total number of donor cells on this domain. More...
 
std::vector< std::vector< MInt > > m_elementDonorLevels
 Donor cell levels relative to element. More...
 
std::vector< std::vector< MInt > > m_elementDonorMap
 Mapping from donor cells to elements. More...
 
std::vector< std::vector< MInt > > m_elementDonorPos
 Donor cell positions on the corresponding cell level. More...
 
std::vector< ProjectionTypem_projection
 Galerkin projection (access by polynomial degree) More...
 
MBool m_isFirstSourceCalculation
 Store whether this is the first calculation of the source terms. More...
 
std::vector< MFloatm_sourceTerms
 Local storage for source terms. More...
 
std::vector< MIntm_calcSourceDonorCells
 List of all donor cell ids for which source terms need to be computed. More...
 
std::vector< MIntm_calcSourceElements
 List of all element ids for which source terms need to be computed. More...
 
MFloat m_sourceFactor
 Factor by which the source terms are multiplied. More...
 
MBool m_checkConservation
 Check if each Galerkin projection is conservative. More...
 
MFloat m_maxConservationError
 Maximum conservation error. More...
 
MFloat m_maxL2Error
 Maximum computed L2 error of the Galerkin projection. More...
 
std::vector< MFloatm_meanVars
 Local storage for mean variables of the donor cells. More...
 
std::vector< MIntm_elementInsideBody
 Marker if elements are inside a geometric object. More...
 
Filter< nDim > m_sourceTermFilter
 Auxiliary object that handles source filtering. More...
 
std::vector< MFloatm_filter
 Local storage for source filter values. More...
 
std::vector< MFloatm_filterDonor
 Local storage for source filter values on donor cells. More...
 
MInt m_noCutModesLowPass
 Number of modes to cut using the low-pass source term. More...
 
MBool m_useLowPassFilter
 Switch low pass on and off to allow disabling e.g. for node vars. More...
 
std::vector< MFloatTensorm_vdmLowPass
 Vandermonde matrix/matrices for the low-pass filter. More...
 
MBool m_applySourceFilterDonor
 Apply source filter on donor cells or on DG elements after projection. More...
 
MBool m_saveSourceTermFilter
 Store whether filter values should be written to a file at initialization. More...
 
MBool m_projectionFilter
 Use spatial projection filter (i.e. exclude elements from the projection) More...
 
std::vector< MFloatm_projectionFilterBox
 Spatial projection filter box (excluding) More...
 
std::array< MInt, s_totalNoMeanVarsm_meanVarsIndex
 
std::array< MInt, Timers::_countm_timers
 
- Protected Attributes inherited from CouplingDg< nDim, DgSysEqnAcousticPerturb< nDim > >
solverTypem_dgSolver
 
- Static Protected Attributes inherited from CouplingDgApe< nDim, CouplingLB< nDim, nDist, SysEqn > >
static const MInt s_totalNoMeanVars
 
static const std::array< MString, ST::totalNoSourceTermss_sourceTermNames
 Hold indices for source terms. More...
 

Detailed Description

template<MInt nDim, MInt nDist, class SysEqn>
class LbDgApe< nDim, nDist, SysEqn >

Definition at line 14 of file lbdgape.h.

Member Typedef Documentation

◆ Base

template<MInt nDim, MInt nDist, class SysEqn >
using LbDgApe< nDim, nDist, SysEqn >::Base = Coupling

Definition at line 17 of file lbdgape.h.

◆ BaseDg

template<MInt nDim, MInt nDist, class SysEqn >
using LbDgApe< nDim, nDist, SysEqn >::BaseDg = CouplingDgApe<nDim, BaseLb>

Definition at line 23 of file lbdgape.h.

◆ BaseLb

template<MInt nDim, MInt nDist, class SysEqn >
using LbDgApe< nDim, nDist, SysEqn >::BaseLb = CouplingLB<nDim, nDist, SysEqn>

Definition at line 19 of file lbdgape.h.

◆ DgSolver

template<MInt nDim, MInt nDist, class SysEqn >
using LbDgApe< nDim, nDist, SysEqn >::DgSolver = typename BaseDg::DgCartesianSolverType

Definition at line 24 of file lbdgape.h.

◆ LbSolver

template<MInt nDim, MInt nDist, class SysEqn >
using LbDgApe< nDim, nDist, SysEqn >::LbSolver = typename BaseLb::solverType

Definition at line 20 of file lbdgape.h.

◆ SysEqnDg

template<MInt nDim, MInt nDist, class SysEqn >
using LbDgApe< nDim, nDist, SysEqn >::SysEqnDg = DgSysEqnAcousticPerturb<nDim>

Definition at line 22 of file lbdgape.h.

Constructor & Destructor Documentation

◆ LbDgApe()

template<MInt nDim, MInt nDist, class SysEqn >
LbDgApe< nDim, nDist, SysEqn >::LbDgApe ( const MInt  couplingId,
LbSolver *const  lb,
DgSolver *const  dg 
)
inline

Definition at line 29 of file lbdgape.h.

30 : Base(couplingId), BaseDg(couplingId, dg, lb) {}
Coupling Base
Definition: lbdgape.h:17
CouplingDgApe< nDim, BaseLb > BaseDg
Definition: lbdgape.h:23

◆ ~LbDgApe()

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

Definition at line 31 of file lbdgape.h.

31{};

Member Function Documentation

◆ calcSourceLambLinearized()

template<MInt nDim, MInt nDist, class SysEqn >
void LbDgApe< nDim, nDist, SysEqn >::calcSourceLambLinearized ( const MFloat * const  ,
const MFloat * const  ,
MFloat  
)
inlineoverrideprivatevirtual

Implements CouplingDgApe< nDim, CouplingLB< nDim, nDist, SysEqn > >.

Definition at line 52 of file lbdgape.h.

53 {
54 mTerm(1, AT_, "Error: calcSourceLambLinearized source term not implemented, yet, for lbdgape!");
55 };
void mTerm(const MInt errorCode, const MString &location, const MString &message)
Definition: functions.cpp:29

◆ calcSourceLambNonlinear()

template<MInt nDim, MInt nDist, class SysEqn >
void LbDgApe< nDim, nDist, SysEqn >::calcSourceLambNonlinear ( const MFloat *const  velocity,
const MFloat *const  vorticity,
MFloat *const  sourceTerms 
)
overrideprivatevirtual

Implements CouplingDgApe< nDim, CouplingLB< nDim, nDist, SysEqn > >.

Definition at line 141 of file lbdgape.cpp.

143 {
144 TRACE();
145 RECORD_TIMER_START(this->m_timers[BaseDg::Timers::CalcSourceLamb]);
146 // Index of first lamb vector component in m_meanVars
147 const MInt lambIndex = this->m_meanVarsIndex[BaseDg::MV::LAMB0[0]];
148 // Calculate source terms on all 'active' donor leaf cells, i.e. that are
149 // mapped to elements with nonzero filter values
150 for(MInt donorIndex = 0; donorIndex < this->m_noActiveDonorCells; donorIndex++) {
151 const MInt donorId = this->m_calcSourceDonorCells[donorIndex];
152 // Create convenience pointers
153 const MFloat* const meanVars = &this->m_meanVars[donorIndex * this->noMeanVars()];
154 const MFloat* const velo = &velocity[donorId * this->noVelocities()];
155 const MFloat* const vort = &vorticity[donorId * this->noVorticities()];
156 // Compute instantaneous Lamb vector
157 MFloat lambVector[nDim];
158 if(nDim == 2) {
159 lambVector[0] = -vort[0] * velo[1];
160 lambVector[1] = vort[0] * velo[0];
161 } else {
162 lambVector[0] = vort[1] * velo[2] - vort[2] * velo[1];
163 lambVector[1] = vort[2] * velo[0] - vort[0] * velo[2];
164 lambVector[2] = vort[0] * velo[1] - vort[1] * velo[0];
165 }
166 // The complete source term is:
167 // S = -L' = -(w x u - bar(w x u))
168 const MInt offset = donorId * SysEqnDg::noVars() + BaseDg::CV::UU[0];
169 for(MInt dim = 0; dim < nDim; dim++) {
170 sourceTerms[offset + dim] += -(lambVector[dim] - meanVars[lambIndex + dim]);
171 }
172 }
173 RECORD_TIMER_STOP(this->m_timers[BaseDg::Timers::CalcSourceLamb]);
174}
static constexpr MInt noVelocities()
Return number of velocity variables.
std::array< MInt, s_totalNoMeanVars > m_meanVarsIndex
MInt noMeanVars() const
Return number of mean variables.
static constexpr MInt noVorticities()
Return number of vorticity variables.
std::vector< MInt > m_calcSourceDonorCells
List of all donor cell ids for which source terms need to be computed.
std::vector< MFloat > m_meanVars
Local storage for mean variables of the donor cells.
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52

◆ calcSourceQc()

template<MInt nDim, MInt nDist, class SysEqn >
void LbDgApe< nDim, nDist, SysEqn >::calcSourceQc ( const MFloat * const  ,
MFloat * const  ,
const  MFloat,
const  MInt 
)
inlineoverrideprivatevirtual

Implements CouplingDgApe< nDim, CouplingLB< nDim, nDist, SysEqn > >.

Definition at line 67 of file lbdgape.h.

68 {
69 mTerm(1, AT_, "Error: calcSourceQc source term not implemented, yet, for lbdgape!");
70 };

◆ calcSourceQe()

template<MInt nDim, MInt nDist, class SysEqn >
void LbDgApe< nDim, nDist, SysEqn >::calcSourceQe ( const MFloat * const  ,
const  MFloat,
MFloat * const   
)
inlineoverrideprivatevirtual

Implements CouplingDgApe< nDim, CouplingLB< nDim, nDist, SysEqn > >.

Definition at line 64 of file lbdgape.h.

64 {
65 mTerm(1, AT_, "Error: calcSourceQe source term not implemented, yet, for lbdgape!");
66 };

◆ calcSourceQmII()

template<MInt nDim, MInt nDist, class SysEqn >
void LbDgApe< nDim, nDist, SysEqn >::calcSourceQmII ( const MFloat * const  ,
MFloat * const   
)
inlineoverrideprivatevirtual

Implements CouplingDgApe< nDim, CouplingLB< nDim, nDist, SysEqn > >.

Definition at line 58 of file lbdgape.h.

58 {
59 mTerm(1, AT_, "Error: calcSourceQmII source term not implemented, yet, for lbdgape!");
60 };

◆ calcSourceQmIII()

template<MInt nDim, MInt nDist, class SysEqn >
void LbDgApe< nDim, nDist, SysEqn >::calcSourceQmIII ( const MFloat * const  ,
MFloat  
)
inlineoverrideprivatevirtual

Implements CouplingDgApe< nDim, CouplingLB< nDim, nDist, SysEqn > >.

Definition at line 61 of file lbdgape.h.

61 {
62 mTerm(1, AT_, "Error: calcSourceQmIII source term not implemented, yet, for lbdgape!");
63 };

◆ donorSolver()

template<MInt nDim, MInt nDist, class SysEqn >
LbSolver & LbDgApe< nDim, nDist, SysEqn >::donorSolver ( const MInt  xSolverId = 0) const
inlineoverrideprivatevirtual

Implements CouplingDgApe< nDim, CouplingLB< nDim, nDist, SysEqn > >.

Definition at line 46 of file lbdgape.h.

46{ return lbSolver(xSolverId); };
solverType & lbSolver(const MInt solverId=0) const
Definition: coupling.h:454

◆ finalizeCouplerInit()

template<MInt nDim, MInt nDist, class SysEqn >
void LbDgApe< nDim, nDist, SysEqn >::finalizeCouplerInit
overridevirtual

Implements Coupling.

Definition at line 14 of file lbdgape.cpp.

14 {
15 TRACE();
16 // TODO labels:COUPLER,LB,DG for now, DG does the same time step as LB on finest level
17 this->dgSolver().forceTimeStep(m_conversionLb2Dg.time * 1.0);
18}
solverType & dgSolver() const
Return MPI communicator.
Definition: coupling.h:310
struct LbDgApe::ConversionFactors m_conversionLb2Dg

◆ getDonorVelocityAndVorticity()

template<MInt nDim, MInt nDist, class SysEqn >
void LbDgApe< nDim, nDist, SysEqn >::getDonorVelocityAndVorticity ( const std::vector< MInt > &  donorCellIds,
MFloatScratchSpace p_velocity,
MFloatScratchSpace p_vorticity 
)
overrideprivatevirtual
Author
Miro Gondrum
Date
03.08.2021
Parameters
[in]donorCellIdscollections of cellIds of interest
[out]p_velocitypointer to write velocity field
[out]p_vorticitypointer to write vorticity field
Note
Here, in case of LB solver as donor solver, the units are converted into the dimensions used by the DG solver.

Implements CouplingDgApe< nDim, CouplingLB< nDim, nDist, SysEqn > >.

Definition at line 70 of file lbdgape.cpp.

72 {
73 TRACE();
75 // Velocity
76 for(auto donorId : donorCellIds) {
77 const MFloat* cellVars = nullptr;
78 this->donorSolver().getSampleVariables(donorId, cellVars);
79 for(MInt dirId = 0; dirId < this->noVelocities(); dirId++) {
80 p_velocity(donorId, dirId) = cellVars[this->donorSolver().PV->VV[dirId]] * m_conversionLb2Dg.velocity;
81 }
82 }
83 // Vorticity
84 for(auto donorId : donorCellIds) {
85 MFloat velocityGradient[nDim][nDim];
86 this->donorSolver().calculateVelocityDerivative(donorId, velocityGradient);
87 if constexpr(nDim == 2) {
88 p_vorticity(donorId, 0) = (velocityGradient[1][0] - velocityGradient[0][1]) * m_conversionLb2Dg.vorticity;
89 } else if(nDim == 3) {
90 p_vorticity(donorId, 0) = (velocityGradient[2][1] - velocityGradient[1][2]) * m_conversionLb2Dg.vorticity;
91 p_vorticity(donorId, 1) = (velocityGradient[0][2] - velocityGradient[2][0]) * m_conversionLb2Dg.vorticity;
92 p_vorticity(donorId, 2) = (velocityGradient[1][0] - velocityGradient[0][1]) * m_conversionLb2Dg.vorticity;
93 }
94 }
95 }
96}
MBool m_hasDonorCartesianSolver
Store whether this domain has Cartesian donor solver cells.
LbSolver & donorSolver(const MInt xSolverId=0) const override
Definition: lbdgape.h:46

◆ init()

template<MInt nDim, MInt nDist, class SysEqn >
void LbDgApe< nDim, nDist, SysEqn >::init ( )
inlineoverridevirtual

Implements Coupling.

Definition at line 36 of file lbdgape.h.

36 {
39 };
void init() override
void initConversionFactors()
Definition: lbdgape.cpp:25

◆ initConversionFactors()

template<MInt nDim, MInt nDist, class SysEqn >
void LbDgApe< nDim, nDist, SysEqn >::initConversionFactors
private

Definition at line 25 of file lbdgape.cpp.

25 {
26 // TODO labels:lb Miro: document why conversion factors are needed for inactive solver
27 TRACE();
28
29 // Description: for generic variable phi conversion factor C_phi is defined as
30 // phi_dg = phi_lb * C_phi
31 // base units
32 constexpr MFloat dgGamma = 1.4;
33 MFloat maSq = this->a_Ma() * this->a_Ma(); // Note: Ma is present in inactive LB solver
34
35 // Inactive donor solver does not know the maxLevel
36 const MBool hasLbSolver = this->lbSolver().isActive();
37 MFloat dxLb =
38 (hasLbSolver) ? this->a_cellLengthAtLevel(donorSolver().maxLevel()) : std::numeric_limits<MFloat>::max();
39 MPI_Allreduce(MPI_IN_PLACE,
40 &dxLb,
41 1,
43 MPI_MIN,
44 this->dgSolver().grid().raw().mpiComm(),
45 AT_,
46 "MPI_IN_PLACE",
47 "dxLb");
48
50 m_conversionLb2Dg.density = pow(1.0 + 0.5 * (dgGamma - 1.0) * maSq, 1.0 / (1.0 - dgGamma));
51 m_conversionLb2Dg.time = dxLb * LBCS * sqrt(1.0 + 0.5 * (dgGamma - 1.0) * maSq); // sqrt-term: a_0 / a_inf
52 // derived units
56}
MFloat a_cellLengthAtLevel(MInt level, const MInt id=0)
Definition: coupling.h:518
MFloat a_Ma(const MInt id=0) const
Definition: coupling.h:472
bool MBool
Definition: maiatypes.h:58
int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, const MString &name, const MString &sndvarname, const MString &rcvvarname)
same as MPI_Allreduce

◆ lbSolver()

template<MInt nDim, MInt nDist, class SysEqn >
solverType & CouplingLB< nDim, nDist, SysEqn >::lbSolver ( const MInt  solverId = 0) const
inline

Definition at line 454 of file coupling.h.

454 {
455 ASSERT(solverId < noSolvers(), "Invalid solverId " + std::to_string(solverId) + "/" + std::to_string(noSolvers()));
456 return *m_lbSolvers[solverId];
457 }
MInt solverId() const
Return solver id.
Definition: coupling.h:315
std::vector< solverType * > m_lbSolvers
Definition: coupling.h:464
MInt noSolvers() const
Definition: coupling.h:453

◆ performUnitConversion()

template<MInt nDim, MInt nDist, class SysEqn >
void LbDgApe< nDim, nDist, SysEqn >::performUnitConversion ( const MString name,
const MInt  count,
const MInt  stride,
MFloat data 
)
overrideprivatevirtual
Author
Miro Gondrum
Date
03.08.2021
Note
Here, in case of LB solver as donor solver, the units are converted into the dimensions used by the DG solver.

Reimplemented from CouplingDgApe< nDim, CouplingLB< nDim, nDist, SysEqn > >.

Definition at line 105 of file lbdgape.cpp.

108 {
109 TRACE();
110 // Determine corresponding conversion factor
111 std::map<MString, MFloat> conversionMap;
112 conversionMap["wxv_x"] = m_conversionLb2Dg.lamb;
113 conversionMap["wxv_y"] = m_conversionLb2Dg.lamb;
114 conversionMap["wxv_z"] = m_conversionLb2Dg.lamb;
115 conversionMap["um"] = m_conversionLb2Dg.velocity;
116 conversionMap["vm"] = m_conversionLb2Dg.velocity;
117 conversionMap["wm"] = m_conversionLb2Dg.velocity;
118 conversionMap["rhom"] = m_conversionLb2Dg.density;
119 conversionMap["c0"] = m_conversionLb2Dg.velocity;
120 conversionMap["dc0_dx"] = m_conversionLb2Dg.vorticity;
121 conversionMap["dc0_dy"] = m_conversionLb2Dg.vorticity;
122 conversionMap["dc0_dz"] = m_conversionLb2Dg.vorticity;
123 conversionMap["vort_x"] = m_conversionLb2Dg.vorticity;
124 conversionMap["vort_y"] = m_conversionLb2Dg.vorticity;
125 conversionMap["vort_z"] = m_conversionLb2Dg.vorticity;
126
127 auto search = conversionMap.find(name);
128 if(search == conversionMap.end()) {
129 std::stringstream ss;
130 ss << "ERROR: No unit type found for " << name << " ." << std::endl;
131 TERMM(1, ss.str());
132 }
133 const MFloat conversionFactor = conversionMap[name];
134 for(MInt i = 0; i < count; i++) {
135 const MInt j = i * stride;
136 data[j] *= conversionFactor;
137 }
138}

Member Data Documentation

◆ m_conversionLb2Dg

template<MInt nDim, MInt nDist, class SysEqn >
struct LbDgApe::ConversionFactors LbDgApe< nDim, nDist, SysEqn >::m_conversionLb2Dg
private

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