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

Coupling condition for direct-hybrid LES-CAA computations. More...

#include <dgccacousticperturbsourcefiles.h>

Inheritance diagram for DgCcAcousticPerturb< nDim, FvSysEqn >:
[legend]
Collaboration diagram for DgCcAcousticPerturb< nDim, FvSysEqn >:
[legend]

Public Types

using Base = Coupling
 
using BaseFv = CouplingFv< nDim, FvSysEqn >
 
using FvCartesianSolverType = typename BaseFv::solverType
 
using BaseDg = CouplingDgApe< nDim, BaseFv >
 
using DgCartesianSolverType = typename BaseDg::DgCartesianSolverType
 
using ProjectionType = typename BaseDg::ProjectionType
 
using CV = typename BaseDg::CV
 
using MV = typename BaseDg::MV
 
using ST = typename BaseDg::ST
 
using SysEqn = typename BaseDg::SysEqn
 
using Timers = typename BaseDg::Timers
 
- Public Types inherited from CouplingDgApe< nDim, CouplingFv< nDim, FvSysEqn > >
using Base = Coupling
 
using BaseDonor = CouplingFv< nDim, FvSysEqn >
 
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 CouplingFv< nDim, FvSysEqn >
using solverType = FvCartesianSolverXD< nDim, FvSysEqn >
 
- Public Types inherited from CouplingDg< nDim, DgSysEqnAcousticPerturb< nDim > >
using solverType = DgCartesianSolver< nDim, DgSysEqnAcousticPerturb< nDim > >
 
using CV = typename SysEqn::CV
 

Public Member Functions

 DgCcAcousticPerturb (const MInt couplingId, FvCartesianSolverType *fvSolver_, DgCartesianSolverType *const dgSolver_)
 
virtual ~DgCcAcousticPerturb ()
 Stop the object lifetime timer and calculate global maximum errors. More...
 
void init () override
 
void finalizeCouplerInit () override
 
void balancePre () override
 Load balancing. More...
 
void balancePost () override
 
MInt noCellDataDlb () const override
 Methods to inquire coupler data during balancing. More...
 
MInt cellDataTypeDlb (const MInt dataId) const override
 
MInt cellDataSizeDlb (const MInt NotUsed(dataId), const MInt NotUsed(cellId)) override
 
void getCellDataDlb (const MInt dataId, const MInt oldNoCells, const MInt *const bufferIdToCellId, MFloat *const data) override
 
void setCellDataDlb (const MInt NotUsed(dataId), const MFloat *const NotUsed(data)) override
 
MBool forceTimeStep () const
 Return true if time step calculation should be overruled by coupling. More...
 
MInt noMeanVars () const
 Return number of mean variables. More...
 
- Public Member Functions inherited from CouplingDgApe< nDim, CouplingFv< nDim, FvSysEqn > >
 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 CouplingFv< nDim, FvSysEqn >
 CouplingFv (const MInt couplingId, std::vector< FvCartesianSolverXD< nDim, FvSysEqn > * > fvSolvers, const MInt noSolvers)
 
 CouplingFv (const MInt couplingId, Solver *solvers)
 
 CouplingFv (const CouplingFv &)=delete
 
 ~CouplingFv () override=default
 
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...
 
- 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...
 

Static Public Member Functions

static constexpr MInt noVelocities ()
 Return number of velocity variables. More...
 
static constexpr MInt noVorticities ()
 Return number of vorticity variables. More...
 
- Static Public Member Functions inherited from CouplingDgApe< nDim, CouplingFv< nDim, FvSysEqn > >
static constexpr MInt noVelocities ()
 Return number of velocity variables. More...
 
static constexpr MInt noVorticities ()
 Return number of vorticity variables. More...
 

Public Attributes

MBool m_calcProjectionError
 Calculate the L2 error of the Galerkin projection. More...
 
std::vector< MIntm_calcSourceDonorCells
 List of all donor cell ids for which source terms need to be computed. More...
 
MBool m_checkConservation
 Check if each Galerkin projection is conservative. More...
 
MFloat m_fixedTimeStep
 Fixed time step to use. 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...
 
MBool m_isFirstSourceCalculation
 Store whether this is the first calculation of the source terms. More...
 
MBool m_isRestart
 Store whether this is a restart (in case special treatment is necessary) 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::array< MInt, s_totalNoMeanVarsm_meanVarsIndex
 
MInt m_noActiveDonorCells
 
MInt m_noDonorCells
 Total number of donor cells on this domain. More...
 
MFloat m_previousTime
 Previous time for the calculation of time derivatives. More...
 
std::array< MInt, Timers::_count > m_timers
 

Private Member Functions

void sanityCheck ()
 Perform sanity checks. More...
 
FvCartesianSolverTypedonorSolver (const MInt xSolverId=0) const override
 
void getDonorVelocityAndVorticity (const std::vector< MInt > &donorCellIds, MFloatScratchSpace &p_velocity, MFloatScratchSpace &p_vorticity) override
 
MFloat calcTimeStep ()
 Return the time step size dt as determined by the coupling condition. More...
 
void calcSourceLambLinearized (const MFloat *const velocity, const MFloat *const vorticity, MFloat *sourceTerms) override
 Calculate the linearized Lamb vector coupling source terms on all donor cells where it is needed. More...
 
void calcSourceLambNonlinear (const MFloat *const velocity, const MFloat *const vorticity, MFloat *const sourceTerms) override
 Calculate the nonlinear Lamb vector coupling source terms on all donor cells where it is needed. More...
 
void calcSourceQmII (const MFloat *const velocity, MFloat *const sourceTerms) override
 Calculate the q_mII source terms on all donor cells where it is needed. More...
 
void calcSourceQmIII (const MFloat *const velocity, MFloat *sourceTerms) override
 Calculate the q_mIII source terms on all donor cells where it is needed. More...
 
void calcSourceQe (const MFloat *const velocity, const MFloat time, MFloat *const sourceTerms) override
 Calculate the q_e source terms on all donor cells where it is needed. More...
 
void calcSourceQc (const MFloat *const velocity, MFloat *const sourceTerms, const MFloat time, const MInt timeStep) override
 Calculate the q_c source terms on all donor cells where it is needed. More...
 

Private Attributes

MInt m_loadBalancingReinitStage = -1
 DLB reinitialization stage. More...
 
std::vector< MFloatm_oldPressure {}
 Store previous pressure term for dp/dt calculation. More...
 

Additional Inherited Members

- Protected Types inherited from CouplingDg< nDim, DgSysEqnAcousticPerturb< nDim > >
using ElementCollector = maia::dg::collector::ElementCollector< nDim, DgSysEqnAcousticPerturb< nDim > >
 
- Protected Member Functions inherited from CouplingDgApe< nDim, CouplingFv< nDim, FvSysEqn > >
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 CouplingFv< nDim, FvSysEqn >
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 CouplingDgApe< nDim, CouplingFv< nDim, FvSysEqn > >
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 CouplingFv< nDim, FvSysEqn >
std::vector< solverType * > m_fvSolvers
 
- Protected Attributes inherited from CouplingDg< nDim, DgSysEqnAcousticPerturb< nDim > >
solverTypem_dgSolver
 
- Static Protected Attributes inherited from CouplingDgApe< nDim, CouplingFv< nDim, FvSysEqn > >
static const MInt s_totalNoMeanVars
 
static const std::array< MString, ST::totalNoSourceTermss_sourceTermNames
 Hold indices for source terms. More...
 

Detailed Description

template<MInt nDim, class FvSysEqn>
class DgCcAcousticPerturb< nDim, FvSysEqn >
Author
Michael Schlottke-Lakemper (mic) mic@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2016-07-08

TODO labels:COUPLER,toremove Re-enable offline coupling or remove it entirely

Definition at line 40 of file dgccacousticperturbsourcefiles.h.

Member Typedef Documentation

◆ Base

template<MInt nDim, class FvSysEqn >
using DgCcAcousticPerturb< nDim, FvSysEqn >::Base = Coupling

Definition at line 43 of file dgccacousticperturbsourcefiles.h.

◆ BaseDg

template<MInt nDim, class FvSysEqn >
using DgCcAcousticPerturb< nDim, FvSysEqn >::BaseDg = CouplingDgApe<nDim, BaseFv>

Definition at line 49 of file dgccacousticperturbsourcefiles.h.

◆ BaseFv

template<MInt nDim, class FvSysEqn >
using DgCcAcousticPerturb< nDim, FvSysEqn >::BaseFv = CouplingFv<nDim, FvSysEqn>

Definition at line 45 of file dgccacousticperturbsourcefiles.h.

◆ CV

template<MInt nDim, class FvSysEqn >
using DgCcAcousticPerturb< nDim, FvSysEqn >::CV = typename BaseDg::CV

Definition at line 74 of file dgccacousticperturbsourcefiles.h.

◆ DgCartesianSolverType

template<MInt nDim, class FvSysEqn >
using DgCcAcousticPerturb< nDim, FvSysEqn >::DgCartesianSolverType = typename BaseDg::DgCartesianSolverType

Definition at line 72 of file dgccacousticperturbsourcefiles.h.

◆ FvCartesianSolverType

template<MInt nDim, class FvSysEqn >
using DgCcAcousticPerturb< nDim, FvSysEqn >::FvCartesianSolverType = typename BaseFv::solverType

Definition at line 46 of file dgccacousticperturbsourcefiles.h.

◆ MV

template<MInt nDim, class FvSysEqn >
using DgCcAcousticPerturb< nDim, FvSysEqn >::MV = typename BaseDg::MV

Definition at line 75 of file dgccacousticperturbsourcefiles.h.

◆ ProjectionType

template<MInt nDim, class FvSysEqn >
using DgCcAcousticPerturb< nDim, FvSysEqn >::ProjectionType = typename BaseDg::ProjectionType

Definition at line 73 of file dgccacousticperturbsourcefiles.h.

◆ ST

template<MInt nDim, class FvSysEqn >
using DgCcAcousticPerturb< nDim, FvSysEqn >::ST = typename BaseDg::ST

Definition at line 76 of file dgccacousticperturbsourcefiles.h.

◆ SysEqn

template<MInt nDim, class FvSysEqn >
using DgCcAcousticPerturb< nDim, FvSysEqn >::SysEqn = typename BaseDg::SysEqn

Definition at line 77 of file dgccacousticperturbsourcefiles.h.

◆ Timers

template<MInt nDim, class FvSysEqn >
using DgCcAcousticPerturb< nDim, FvSysEqn >::Timers = typename BaseDg::Timers

Definition at line 78 of file dgccacousticperturbsourcefiles.h.

Constructor & Destructor Documentation

◆ DgCcAcousticPerturb()

template<MInt nDim, class FvSysEqn >
DgCcAcousticPerturb< nDim, FvSysEqn >::DgCcAcousticPerturb ( const MInt  couplingId,
FvCartesianSolverType fvSolver_,
DgCartesianSolverType *const  dgSolver_ 
)
inline

Definition at line 84 of file dgccacousticperturbsourcefiles.h.

85 : Base(couplingId), BaseDg(couplingId, dgSolver_, fvSolver_) {}
CouplingDgApe< nDim, BaseFv > BaseDg

◆ ~DgCcAcousticPerturb()

template<MInt nDim, class FvSysEqn >
DgCcAcousticPerturb< nDim, FvSysEqn >::~DgCcAcousticPerturb
virtual
Author
Michael Schlottke (mic) mic@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2015-10-01

Definition at line 164 of file dgccacousticperturbsourcefiles.h.

164 {
165 TRACE();
166
167 MFloat maxGlobalConservationError = -1.0;
168 MFloat maxGlobalL2Error = -1.0;
169
170 // Compute global maximum conservation error if activated
173 MPI_MAX, dgSolver().mpiComm(), AT_, "m_maxConservationError", "maxGlobalConservationError");
174
175 m_log << "Global maximum Galerkin projection conservation error: " << std::scientific << maxGlobalConservationError
176 << std::endl;
177 m_log << "Local maximum Galerkin projection conservation error: " << std::scientific << m_maxConservationError
178 << std::endl;
179 }
180
181 // Compute global maximum L2 projection error if activated
183 MPI_Allreduce(&m_maxL2Error, &maxGlobalL2Error, 1, maia::type_traits<MFloat>::mpiType(), MPI_MAX,
184 dgSolver().mpiComm(), AT_, "m_maxL2Error", "maxGlobalL2Error");
185
186 m_log << "Global maximum Galerking projection L2 error: " << std::scientific << maxGlobalL2Error << std::endl;
187 m_log << "Local maximum Galerking projection L2 error: " << std::scientific << m_maxL2Error << std::endl;
188 }
189
190 // Write the maximum global errors to file
192 std::ofstream errorFile(outputDir() + "errors.txt");
193
195 errorFile << "maxGlobalConservationError: " << std::scientific << maxGlobalConservationError << std::endl;
196 }
198 errorFile << "maxGlobalProjectionError: " << std::scientific << maxGlobalL2Error << std::endl;
199 }
200
201 errorFile.close();
202 }
203
204 RECORD_TIMER_STOP(m_timers[Timers::Class]);
205}
MString outputDir() const
Return output directory.
Definition: coupling.h:339
solverType & dgSolver() const
Return MPI communicator.
Definition: coupling.h:310
MBool m_checkConservation
Check if each Galerkin projection is conservative.
std::array< MInt, Timers::_count > m_timers
MBool m_calcProjectionError
Calculate the L2 error of the Galerkin projection.
MFloat m_maxL2Error
Maximum computed L2 error of the Galerkin projection.
MBool m_hasDgCartesianSolver
Store whether this domain has DG cells/elements.
MFloat m_maxConservationError
Maximum conservation error.
InfoOutFile m_log
double MFloat
Definition: maiatypes.h:52
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

Member Function Documentation

◆ balancePost()

template<MInt nDim, class FvSysEqn >
void DgCcAcousticPerturb< nDim, FvSysEqn >::balancePost ( )
inlineoverridevirtual

Reimplemented from Coupling.

Definition at line 101 of file dgccacousticperturbsourcefiles.h.

101 {
102 // Nothing to be done here
103 m_loadBalancingReinitStage = -1; // Reset reinitialization stage
104 };
MInt m_loadBalancingReinitStage
DLB reinitialization stage.

◆ balancePre()

template<MInt nDim, class FvSysEqn >
void DgCcAcousticPerturb< nDim, FvSysEqn >::balancePre ( )
inlineoverridevirtual

Reimplemented from Coupling.

Definition at line 97 of file dgccacousticperturbsourcefiles.h.

97 {
98 m_loadBalancingReinitStage = 0; // Set reinitialization stage
99 this->initCoupler(); // Perform main (re-)initialization of coupler
100 };
void initCoupler()
Initialize the coupling condition (data structures).

◆ calcSourceLambLinearized()

template<MInt nDim, class FvSysEqn >
void DgCcAcousticPerturb< nDim, FvSysEqn >::calcSourceLambLinearized ( const MFloat *const  velocity,
const MFloat *const  vorticity,
MFloat sourceTerms 
)
overrideprivatevirtual
Author
Michael Schlottke (mic) mic@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2015-10-01
Parameters
[in]velocityVelocities of all donor cells.
[in]vorticityVorticities of all donor cells.
[out]sourceTermsStorage for computed source terms.

Implements CouplingDgApe< nDim, CouplingFv< nDim, FvSysEqn > >.

Definition at line 412 of file dgccacousticperturbsourcefiles.h.

414 {
415 TRACE();
416 RECORD_TIMER_START(m_timers[Timers::CalcSourceLamb]);
417
418 // Indices of first velocity/vorticity component in m_meanVars
419 const MInt veloIndex = m_meanVarsIndex[MV::UU0[0]];
420 const MInt vortIndex = m_meanVarsIndex[MV::VORT0[0]];
421
422 std::array<MFloat, MAX_SPACE_DIMENSIONS> veloP{};
423 std::array<MFloat, MAX_SPACE_DIMENSIONS> vortP{};
424
425 // Calculate source terms on all 'active' donor leaf cells, i.e. that are
426 // mapped to elements with nonzero filter values
427 for(MInt donorIndex = 0; donorIndex < m_noActiveDonorCells; donorIndex++) {
428 const MInt donorId = m_calcSourceDonorCells[donorIndex];
429 // Create convenience pointers
430 const MFloat* meanVars = &m_meanVars[donorIndex * noMeanVars()];
431 const MFloat* velo = &velocity[donorId * noVelocities()];
432 const MFloat* vort = &vorticity[donorId * noVorticities()];
433
434 // Compute velocity fluctuations
435 for(MInt dim = 0; dim < nDim; dim++) {
436 veloP[dim] = velo[dim] - meanVars[veloIndex + dim];
437 }
438 // Compute vorticity fluctuations
439 for(MInt i = 0; i < noVorticities(); i++) {
440 vortP[i] = vort[i] - meanVars[vortIndex + i];
441 }
442
443 // The complete source term is:
444 // S = -L' = -(w' X u0 + w0 X u')
445 // Since the Lamb vector is defined with vorticity as 'nabla x u' but MAIA
446 // calculates it as '0.5 nabla x u', we multiply the resulting Lamb vector
447 // by 2.0
448 const MInt sourcesOffset = donorId * SysEqn::noVars() + CV::UU[0];
449 IF_CONSTEXPR(nDim == 2) { // 2D
450 // x-component: -(-wz' * u0y - w0z * uy')
451 sourceTerms[sourcesOffset] += -2.0 * (-vortP[0] * meanVars[veloIndex + 1] - meanVars[vortIndex] * veloP[1]);
452
453 // y-component: -(wz' * u0x + w0z * ux')
454 sourceTerms[sourcesOffset + 1] += -2.0 * (vortP[0] * meanVars[veloIndex] + meanVars[vortIndex] * veloP[0]);
455 }
456 else { // 3D
457 // x-component: -(wy' * u0z - wz' * u0y + w0y * uz' - w0z * uy')
458 sourceTerms[sourcesOffset] += -2.0
459 * (vortP[1] * meanVars[veloIndex + 2] - vortP[2] * meanVars[veloIndex + 1]
460 + meanVars[vortIndex + 1] * veloP[2] - meanVars[vortIndex + 2] * veloP[1]);
461
462 // y-component: -(wz' * u0x - wx' * u0z + w0z * ux' - w0x * uz')
463 sourceTerms[sourcesOffset + 1] += -2.0
464 * (vortP[2] * meanVars[veloIndex] - vortP[0] * meanVars[veloIndex + 2]
465 + meanVars[vortIndex + 2] * veloP[0] - meanVars[vortIndex] * veloP[2]);
466
467 // z-component: -(wx' * u0y - wy' * u0x + w0x * uy' - w0y * ux')
468 sourceTerms[sourcesOffset + 2] += -2.0
469 * (vortP[0] * meanVars[veloIndex + 1] - vortP[1] * meanVars[veloIndex]
470 + meanVars[vortIndex] * veloP[1] - meanVars[vortIndex + 1] * veloP[0]);
471 }
472 }
473
474 RECORD_TIMER_STOP(m_timers[Timers::CalcSourceLamb]);
475}
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

◆ calcSourceLambNonlinear()

template<MInt nDim, class FvSysEqn >
void DgCcAcousticPerturb< nDim, FvSysEqn >::calcSourceLambNonlinear ( const MFloat *const  velocity,
const MFloat *const  vorticity,
MFloat *const  sourceTerms 
)
overrideprivatevirtual
Author
Ansgar Niemoeller (ansgar) a.nie.nosp@m.moel.nosp@m.ler@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2016-08-18
Parameters
[in]velocityVelocities of all donor cells.
[in]vorticityVorticities of all donor cells.
[out]sourceTermsStorage for computed source terms.

Implements CouplingDgApe< nDim, CouplingFv< nDim, FvSysEqn > >.

Definition at line 233 of file dgccacousticperturbsourcefiles.h.

235 {
236 TRACE();
237 RECORD_TIMER_START(m_timers[Timers::CalcSourceLamb]);
238
239 // Index of first lamb vector component in m_meanVars
240 const MInt lambIndex = m_meanVarsIndex[MV::LAMB0[0]];
241
242 std::array<MFloat, MAX_SPACE_DIMENSIONS> lambVector{};
243
244 // Calculate source terms on all 'active' donor leaf cells, i.e. that are
245 // mapped to elements with nonzero filter values
246 for(MInt donorIndex = 0; donorIndex < m_noActiveDonorCells; donorIndex++) {
247 const MInt donorId = m_calcSourceDonorCells[donorIndex];
248 // Create convenience pointers
249 const MFloat* meanVars = &m_meanVars[donorIndex * noMeanVars()];
250 const MFloat* velo = &velocity[donorId * noVelocities()];
251 const MFloat* vort = &vorticity[donorId * noVorticities()];
252
253 // Compute instantaneous Lamb vector
254 if constexpr(nDim == 2) {
255 lambVector[0] = -vort[0] * velo[1];
256 lambVector[1] = vort[0] * velo[0];
257 } else {
258 lambVector[0] = vort[1] * velo[2] - vort[2] * velo[1];
259 lambVector[1] = vort[2] * velo[0] - vort[0] * velo[2];
260 lambVector[2] = vort[0] * velo[1] - vort[1] * velo[0];
261 }
262
263 // The complete source term is:
264 // S = -L' = -(w x u - bar(w x u))
265 // Since the Lamb vector is defined with vorticity as 'nabla x u' but MAIA
266 // calculates it as '0.5 nabla x u', we multiply the resulting Lamb vector
267 // by 2.0
268 for(MInt dim = 0; dim < nDim; dim++) {
269 // Note: source terms are accumulated, thus "+=" and not "="
270 sourceTerms[donorId * SysEqn::noVars() + dim] += -2.0 * (lambVector[dim] - meanVars[lambIndex + dim]);
271 }
272 }
273
274 RECORD_TIMER_STOP(m_timers[Timers::CalcSourceLamb]);
275}

◆ calcSourceQc()

template<MInt nDim, class FvSysEqn >
void DgCcAcousticPerturb< nDim, FvSysEqn >::calcSourceQc ( const MFloat *const  velocity,
MFloat *const  sourceTerms,
const MFloat  time,
const MInt  timeStep 
)
overrideprivatevirtual
Author
Bjoern Peeters (bjoern) b.pee.nosp@m.ters.nosp@m.@aia..nosp@m.rwth.nosp@m.-aach.nosp@m.en.d.nosp@m.e
Date
2017-05-01
Parameters
[in]velocityVelocities of all donor cells.
[in]timeCurrent simulation time.
[in]timeStepCurrent simulation time step.
[out]sourceTermsStorage for computed source terms.

Implements CouplingDgApe< nDim, CouplingFv< nDim, FvSysEqn > >.

Definition at line 633 of file dgccacousticperturbsourcefiles.h.

636 {
637 TRACE();
638 RECORD_TIMER_START(m_timers[Timers::CalcSourceQc]);
639
640 const MInt veloIndex = m_meanVarsIndex[MV::UU0[0]];
641 const MInt drhoIndex = m_meanVarsIndex[MV::DRHO[0]];
642 const MInt rhoDivUIndex = m_meanVarsIndex[MV::RHODIVU[0]];
643 const MInt uGradRhoIndex = m_meanVarsIndex[MV::UGRADRHO[0]];
644 std::array<MInt, nDim> divIndex;
645 for(MInt i = 0; i < nDim; i++) {
646 divIndex[i] = m_meanVarsIndex[MV::DU[i]];
647 }
648 const MInt cIndex = m_meanVarsIndex[MV::C0];
649 const MInt rhoIndex = m_meanVarsIndex[MV::RHO0];
650
651 // Calculate source terms on all donor leaf cells that are mapped to
652 // elements
653 // with nonzero filter values
654 for(MInt donorIndex = 0; donorIndex < m_noActiveDonorCells; donorIndex++) {
655 const MInt donorId = m_calcSourceDonorCells[donorIndex];
656
657 // Create convenience pointer
658 const MFloat* const meanVars = &m_meanVars[donorIndex * noMeanVars()];
659
660 // bar(u)
661 std::array<MFloat, nDim> veloM;
662 for(MInt dim = 0; dim < nDim; dim++) {
663 veloM[dim] = meanVars[veloIndex + dim];
664 }
665
666 // bar(grad(rho))
667 std::array<MFloat, nDim> drhoM;
668 for(MInt dim = 0; dim < nDim; dim++) {
669 drhoM[dim] = meanVars[drhoIndex + dim];
670 }
671
672 // bar(rho * div(u))
673 MFloat rhodivuM = 0.0;
674 for(MInt dim = 0; dim < nDim; dim++) {
675 rhodivuM += meanVars[rhoDivUIndex + dim];
676 }
677
678 // bar(u * grad(rho))
679 MFloat ugradrhoM = 0.0;
680 for(MInt dim = 0; dim < nDim; dim++) {
681 ugradrhoM += meanVars[uGradRhoIndex + dim];
682 }
683
684 MFloat divUm = 0.0;
685 for(MInt dim = 0; dim < nDim; dim++) {
686 divUm += meanVars[divIndex[dim]];
687 }
688
689 MFloat divU = 0.0;
690 divU += fvSolver().a_slope(donorId, fvSolver().PV->U, 0);
691 divU += fvSolver().a_slope(donorId, fvSolver().PV->V, 1);
692 IF_CONSTEXPR(nDim == 3) { divU += fvSolver().a_slope(donorId, fvSolver().PV->W, 2); }
693
694 // Compute q_c
695 const MFloat rhoM = meanVars[rhoIndex];
696 const MFloat curRho = fvSolver().a_variable(donorId, fvSolver().CV->RHO);
697 const MFloat* const velo = &velocity[donorId * noVelocities()];
698 MFloat qcSource = 0.0;
699 qcSource += (curRho - rhoM) * (divU - divUm);
700 qcSource -= rhodivuM;
701 qcSource -= ugradrhoM;
702 qcSource += rhoM * divUm;
703 for(MInt dim = 0; dim < nDim; dim++) {
704 qcSource += (velo[dim] - veloM[dim]) * ((fvSolver().a_slope(donorId, fvSolver().PV->RHO, dim)) - drhoM[dim]);
705 qcSource += veloM[dim] * drhoM[dim];
706 }
707
708 // Note: the multiplication with c^2 is technically not part of q_c
709 qcSource *= -meanVars[cIndex] * meanVars[cIndex];
710
711 // Store source term at output memory location
712 // Note: source terms are accumulated, thus "+=" and not "="
713 sourceTerms[donorId * SysEqn::noVars() + CV::P] += qcSource;
714 }
715
716 RECORD_TIMER_STOP(m_timers[Timers::CalcSourceQc]);
717}
solverType & fvSolver(const MInt solverId=0) const
Definition: coupling.h:386
MFloat & a_slope(const MInt cellId, MInt const varId, const MInt dir) override
Returns the slope of the cell cellId for the variable varId in direction dir.
MFloat & a_variable(const MInt cellId, const MInt varId)
Returns conservative variable v of the cell cellId for variables varId.

◆ calcSourceQe()

template<MInt nDim, class FvSysEqn >
void DgCcAcousticPerturb< nDim, FvSysEqn >::calcSourceQe ( const MFloat *const  velocity,
const MFloat  time,
MFloat *const  sourceTerms 
)
overrideprivatevirtual
Author
Bjoern Peeters (bjoern) b.pee.nosp@m.ters.nosp@m.@aia..nosp@m.rwth.nosp@m.-aach.nosp@m.en.d.nosp@m.e
Date
2017-05-01
Parameters
[in]velocityVelocities of all donor cells.
[in]timeCurrent simulation time.
[out]sourceTermsStorage for computed source terms.

Implements CouplingDgApe< nDim, CouplingFv< nDim, FvSysEqn > >.

Definition at line 487 of file dgccacousticperturbsourcefiles.h.

489 {
490 TRACE();
491 RECORD_TIMER_START(m_timers[Timers::CalcSourceQe]);
492 TERMM(1, "untested in new coupling condition");
493
494 // If this is the first invocation, we need to perform some initializations.
496 // Create persistent storage for old pressure values
498
499 if(m_isRestart) {
500 // If this is a restart, initialize old pressure values from oldVariables, which should have
501 // been loaded by setting the property "restartOldVariables" to true.
502 // @ansgar TODO labels:COUPLER,FV support for balance, redistribute oldPressure/oldVariables in FV solver
503 MFloatScratchSpace buffer(m_noDonorCells, AT_, "buffer");
504 fvSolver().oldPressure(&buffer[0]);
505 for(MInt donorIndex = 0; donorIndex < m_noActiveDonorCells; donorIndex++) {
506 const MInt donorId = m_calcSourceDonorCells[donorIndex];
507 m_oldPressure[donorIndex] = buffer[donorId];
508 }
509 } else {
510 // If this is *not* a restart, assume that this is the first time step. In this case, the old
511 // pressure values are initialized with the current values to have a gradient of zero
512 for(MInt donorIndex = 0; donorIndex < m_noActiveDonorCells; donorIndex++) {
513 const MInt donorId = m_calcSourceDonorCells[donorIndex];
514 m_oldPressure[donorIndex] = fvSolver().a_pvariable(donorId, fvSolver().PV->P);
515 }
516 }
517
518 // Calculate slopes for the calculation of the velocity divergence
520 }
521
522 // Calculate dt (set to infinity if this is the first time step of a non-restarted simulation)
523 const MFloat dt =
524 (m_isFirstSourceCalculation && !m_isRestart) ? std::numeric_limits<MFloat>::infinity() : time - m_previousTime;
525
526 // Calculate source terms on all donor leaf cells that are mapped to elements with nonzero filter
527 // values
528 const MInt rhoIndex = m_meanVarsIndex[MV::RHO0];
529 const MInt pIndex = m_meanVarsIndex[MV::P0];
530 const MInt cIndex = m_meanVarsIndex[MV::C0];
531 const MInt veloIndex = m_meanVarsIndex[MV::UU0[0]];
532 const MInt dcIndex = m_meanVarsIndex[MV::DC0[0]];
533 std::array<MInt, nDim> divIndex;
534 for(MInt i = 0; i < nDim; i++) {
535 divIndex[i] = m_meanVarsIndex[MV::DU[i]];
536 }
537 const MInt drhoIndex = m_meanVarsIndex[MV::DRHO[0]];
538 const MInt dpIndex = m_meanVarsIndex[MV::DP[0]];
539
540 for(MInt donorIndex = 0; donorIndex < m_noActiveDonorCells; donorIndex++) {
541 const MInt donorId = m_calcSourceDonorCells[donorIndex];
542
543 // Calculate dp/dt and store current pressure for the next time step
544 const MFloat curP = fvSolver().a_pvariable(donorId, fvSolver().PV->P);
545 const MFloat dpdt = (curP - m_oldPressure[donorIndex]) / dt;
546 m_oldPressure[donorIndex] = curP;
547
548 // Create convenience pointers
549 const MFloat* meanVars = &m_meanVars[donorIndex * noMeanVars()];
550
551 // bar(u)
552 std::array<MFloat, nDim> veloM;
553 for(MInt dim = 0; dim < nDim; dim++) {
554 veloM[dim] = meanVars[veloIndex + dim];
555 }
556
557 // bar(grad(c))
558 std::array<MFloat, nDim> dcM;
559 for(MInt dim = 0; dim < nDim; dim++) {
560 dcM[dim] = meanVars[dcIndex + dim];
561 }
562
563 // bar(grad(rho))
564 std::array<MFloat, nDim> drhoM;
565 for(MInt dim = 0; dim < nDim; dim++) {
566 drhoM[dim] = meanVars[drhoIndex + dim];
567 }
568
569 // bar(grad(p))
570 std::array<MFloat, nDim> dpM;
571 for(MInt dim = 0; dim < nDim; dim++) {
572 dpM[dim] = meanVars[dpIndex + dim];
573 }
574
575 // Mean of du/dx, dv/dy, dw/dz for the divergence u
576 MFloat divUm = 0.0;
577 for(MInt dim = 0; dim < nDim; dim++) {
578 divUm += meanVars[divIndex[dim]];
579 }
580
581 MFloat divU = 0.0;
582 for(MInt dim = 0; dim < nDim; dim++) {
583 divU += fvSolver().a_slope(donorId, fvSolver().PV->VV[dim], dim);
584 }
585
586 // Compute drho/dt = -(rho* div(u) + u * grad(rho))
587 const MFloat* const velo = &velocity[donorId * noVelocities()];
588 MFloat drhodttmp = 0.0;
589 for(MInt dim = 0; dim < nDim; dim++) {
590 drhodttmp += velo[dim] * fvSolver().a_slope(donorId, fvSolver().PV->RHO, dim);
591 }
592 const MFloat curRho = fvSolver().a_variable(donorId, fvSolver().CV->RHO);
593 const MFloat drhodt = -curRho * divU - drhodttmp;
594
595 // Compute q_e
596 const MFloat rhoM = meanVars[rhoIndex];
597 const MFloat pM = meanVars[pIndex];
598 const MFloat cM = meanVars[cIndex];
599 const MFloat cTerm = cM * cM;
600 MFloat qeSource = 0.0;
601 qeSource += drhodt - (1.0 / cTerm) * dpdt;
602 qeSource += (curRho - rhoM) * divUm;
603 qeSource -= ((curP - pM) / cTerm) * divUm;
604 for(MInt dim = 0; dim < nDim; dim++) {
605 // bar(u) * (grad(rho) - bar(grad(rho)))
606 qeSource += veloM[dim] * ((fvSolver().a_slope(donorId, fvSolver().PV->RHO, dim)) - drhoM[dim]);
607 qeSource -= (1.0 / cTerm) * veloM[dim] * ((fvSolver().a_slope(donorId, fvSolver().PV->P, dim)) - dpM[dim]);
608 qeSource += 2.0 * ((curP - pM) / (cM * cM * cM)) * veloM[dim] * dcM[dim];
609 }
610
611 // Note: the multiplication with c^2 is technically not part of q_e
612 qeSource *= -cTerm;
613
614 // Store source term at output memory location
615 // Note: source terms are accumulated, thus "+=" and not "="
616 sourceTerms[donorId * SysEqn::noVars() + CV::P] += qeSource;
617 }
618
619 RECORD_TIMER_STOP(m_timers[Timers::CalcSourceQe]);
620}
MBool m_isRestart
Store whether this is a restart (in case special treatment is necessary)
MBool m_isFirstSourceCalculation
Store whether this is the first calculation of the source terms.
MInt m_noDonorCells
Total number of donor cells on this domain.
MFloat m_previousTime
Previous time for the calculation of time derivatives.
std::vector< MFloat > m_oldPressure
Store previous pressure term for dp/dt calculation.
virtual void LSReconstructCellCenter()
Dispatch the reconstruction computation to the appropiate loop.
void oldPressure(MFloat *const p)
This function computes the pressure from the oldVariables.
MFloat & a_pvariable(const MInt cellId, const MInt varId)
Returns primitive variable v of the cell cellId for variables varId.
This class is a ScratchSpace.
Definition: scratch.h:758

◆ calcSourceQmII()

template<MInt nDim, class FvSysEqn >
void DgCcAcousticPerturb< nDim, FvSysEqn >::calcSourceQmII ( const MFloat *const  velocity,
MFloat *const  sourceTerms 
)
overrideprivatevirtual
Author
Bjoern Peeters (bjoern) b.pee.nosp@m.ters.nosp@m.@aia..nosp@m.rwth.nosp@m.-aach.nosp@m.en.d.nosp@m.e
Date
2017-05-01
Parameters
[in]velocityVelocities of all donor cells.
[in]timeCurrent simulation time.
[out]sourceTermsStorage for computed source terms.

Implements CouplingDgApe< nDim, CouplingFv< nDim, FvSysEqn > >.

Definition at line 287 of file dgccacousticperturbsourcefiles.h.

288 {
289 TRACE();
290 RECORD_TIMER_START(m_timers[Timers::CalcSourceQmII]);
291
292 const MInt rhoIndex = m_meanVarsIndex[MV::RHO0];
293 const MInt pIndex = m_meanVarsIndex[MV::P0];
294 const MInt drhoIndex = m_meanVarsIndex[MV::DRHO[0]];
295 const MInt dpIndex = m_meanVarsIndex[MV::DP[0]];
296 const MInt dprhoIndex = m_meanVarsIndex[MV::GRADPRHO[0]];
297
298 // Calculate source terms on all donor leaf cells that are mapped to elements
299 // with nonzero filter values
300 for(MInt donorIndex = 0; donorIndex < m_noActiveDonorCells; donorIndex++) {
301 const MInt donorId = m_calcSourceDonorCells[donorIndex];
302 // Create convenience pointers
303 const MFloat* meanVars = &m_meanVars[donorIndex * noMeanVars()];
304 const MFloat curRho = fvSolver().a_variable(donorId, fvSolver().CV->RHO);
305 const MFloat curP = fvSolver().a_pvariable(donorId, fvSolver().PV->P);
306 const MFloat rhoM = meanVars[rhoIndex];
307 const MFloat pM = meanVars[pIndex];
308
309 // bar(grad(rho))
310 std::array<MFloat, nDim> drhoM;
311 for(MInt dim = 0; dim < nDim; dim++) {
312 drhoM[dim] = meanVars[drhoIndex + dim];
313 }
314
315 // bar(grad(p))
316 std::array<MFloat, nDim> dpM;
317 for(MInt dim = 0; dim < nDim; dim++) {
318 dpM[dim] = meanVars[dpIndex + dim];
319 }
320
321 // bar(grad(p)/rho)
322 std::array<MFloat, nDim> dprhoM;
323 for(MInt dim = 0; dim < nDim; dim++) {
324 dprhoM[dim] = meanVars[dprhoIndex + dim];
325 }
326
327 std::array<MFloat, nDim> qmIISource;
328 for(MInt dim = 0; dim < nDim; dim++) {
329 // Calculate source term, starting with term 1
330 qmIISource[dim] = ((fvSolver().a_slope(donorId, fvSolver().PV->P, dim)) - dpM[dim]) / rhoM
331 // term 2
332 - ((curP - pM) / (rhoM * rhoM)) * drhoM[dim]
333 // term 3
334 - (fvSolver().a_slope(donorId, fvSolver().PV->P, dim)) / curRho
335 // term 4
336 + dprhoM[dim];
337 }
338
339 // Store source term at output memory location
340 for(MInt dim = 0; dim < nDim; dim++) {
341 // Note: source terms are accumulated, thus "+=" and not "="
342 sourceTerms[donorId * SysEqn::noVars() + CV::UU[0] + dim] += qmIISource[dim];
343 }
344 }
345
346 RECORD_TIMER_STOP(m_timers[Timers::CalcSourceQmII]);
347}
SysEqn::PrimitiveVariables * PV

◆ calcSourceQmIII()

template<MInt nDim, class FvSysEqn >
void DgCcAcousticPerturb< nDim, FvSysEqn >::calcSourceQmIII ( const MFloat *const  velocity,
MFloat sourceTerms 
)
overrideprivatevirtual

TODO labels:COUPLER,totest requires testing!

Implements CouplingDgApe< nDim, CouplingFv< nDim, FvSysEqn > >.

Definition at line 354 of file dgccacousticperturbsourcefiles.h.

354 {
355 TRACE();
356 RECORD_TIMER_START(m_timers[Timers::CalcSourceQmIII]);
357 TERMM(1, "requires testing");
358
359 const MInt umIndex = m_meanVarsIndex[MV::UU0[0]];
360
361 // Calculate source terms on all donor leaf cells that are mapped to elements
362 // with nonzero filter values
363 for(MInt donorIndex = 0; donorIndex < m_noActiveDonorCells; donorIndex++) {
364 const MInt donorId = m_calcSourceDonorCells[donorIndex];
365 // Create convenience pointers
366 const MFloat* meanVars = &m_meanVars[donorIndex * noMeanVars()];
367
368 std::array<MFloat, nDim> qmIIISource;
369 std::fill_n(&qmIIISource[0], nDim, 0.0);
370
371 // Calculate source term
372 for(MInt dim = 0; dim < nDim; dim++) {
373 const MFloat velDiff = velocity[donorId * nDim + dim] - meanVars[umIndex + dim];
374
375 for(MInt i = 0; i < nDim; i++) {
376 const MFloat velGrad = fvSolver().a_slope(donorId, fvSolver().PV->VV[dim], i);
377 const MFloat velGradM = meanVars[m_meanVarsIndex[MV::GRADU[dim * nDim + i]]];
378
379 qmIIISource[i] += velDiff * (velGrad - velGradM);
380 }
381
382 // Substract mean term
383 qmIIISource[dim] -= meanVars[m_meanVarsIndex[MV::UGRADU[dim]]];
384
385 for(MInt i = 0; i < nDim; i++) {
386 const MInt gradUPos = i * nDim + dim;
387 qmIIISource[dim] += meanVars[m_meanVarsIndex[MV::UU0[i]]] * meanVars[m_meanVarsIndex[MV::GRADU[gradUPos]]];
388 }
389 }
390
391 // Store source term at output memory location
392 for(MInt dim = 0; dim < nDim; dim++) {
393 // Note: source terms are accumulated, thus "-=" and not "="
394 sourceTerms[donorId * SysEqn::noVars() + CV::UU[0] + dim] -= qmIIISource[dim];
395 }
396 }
397
398 RECORD_TIMER_STOP(m_timers[Timers::CalcSourceQmIII]);
399}

◆ calcTimeStep()

template<MInt nDim, class FvSysEqn >
MFloat DgCcAcousticPerturb< nDim, FvSysEqn >::calcTimeStep
private
Author
Michael Schlottke (mic) mic@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2015-10-01
Returns
The next time step size (dt).

Definition at line 745 of file dgccacousticperturbsourcefiles.h.

745 {
746 TRACE();
747
748 if(m_fixedTimeStep < 0.0) {
749 TERMM(1, "Fixed time step less than zero.");
750 }
751
754
755 // FIXME labels:COUPLER Return proper time step determined by both solvers
756 return m_fixedTimeStep;
757}
MFloat m_fixedTimeStep
Fixed time step to use.
void forceTimeStep(const MFloat dt)
Force time step externally.

◆ cellDataSizeDlb()

template<MInt nDim, class FvSysEqn >
MInt DgCcAcousticPerturb< nDim, FvSysEqn >::cellDataSizeDlb ( const MInt   NotUseddataId,
const MInt   NotUsedcellId 
)
overridevirtual

Reimplemented from Coupling.

Definition at line 760 of file dgccacousticperturbsourcefiles.h.

760 {
761 TRACE();
762 TERMM_IF_NOT_COND(dataId == 0, "invalid data id");
763
764 // Convert to solver cell id and check
765 const MInt fvCellId = fvSolver().grid().tree().grid2solver(gridCellId);
766 if(fvCellId < 0) {
767 return 0;
768 }
769
770 MInt dataSize = 0;
771 // TODO labels:COUPLER Check that ids in m_calcSourceDonorCells are sorted in get/setCellDataDlb
772 const MBool foundDonorCell =
773 std::binary_search(m_calcSourceDonorCells.begin(), m_calcSourceDonorCells.end(), fvCellId);
774 if(foundDonorCell) {
775 dataSize = noMeanVars();
776 }
777 return dataSize;
778}
constexpr GridProxy & grid() const
bool MBool
Definition: maiatypes.h:58

◆ cellDataTypeDlb()

template<MInt nDim, class FvSysEqn >
MInt DgCcAcousticPerturb< nDim, FvSysEqn >::cellDataTypeDlb ( const MInt  dataId) const
inlineoverride

Definition at line 110 of file dgccacousticperturbsourcefiles.h.

110 {
111 TERMM_IF_NOT_COND(dataId == 0, "invalid data id");
112 return MFLOAT;
113 };
@ MFLOAT
Definition: enums.h:269

◆ donorSolver()

template<MInt nDim, class FvSysEqn >
FvCartesianSolverType & DgCcAcousticPerturb< nDim, FvSysEqn >::donorSolver ( const MInt  xSolverId = 0) const
inlineoverrideprivatevirtual

Implements CouplingDgApe< nDim, CouplingFv< nDim, FvSysEqn > >.

Definition at line 126 of file dgccacousticperturbsourcefiles.h.

126{ return fvSolver(xSolverId); };

◆ finalizeCouplerInit()

template<MInt nDim, class FvSysEqn >
void DgCcAcousticPerturb< nDim, FvSysEqn >::finalizeCouplerInit ( )
inlineoverridevirtual

Implements Coupling.

Definition at line 94 of file dgccacousticperturbsourcefiles.h.

94{ calcTimeStep(); };
MFloat calcTimeStep()
Return the time step size dt as determined by the coupling condition.

◆ forceTimeStep()

template<MInt nDim, class FvSysEqn >
MBool DgCcAcousticPerturb< nDim, FvSysEqn >::forceTimeStep ( ) const
inline

Definition at line 121 of file dgccacousticperturbsourcefiles.h.

121{ return true; }

◆ getCellDataDlb()

template<MInt nDim, class FvSysEqn >
void DgCcAcousticPerturb< nDim, FvSysEqn >::getCellDataDlb ( const MInt  dataId,
const MInt  oldNoCells,
const MInt *const  bufferIdToCellId,
MFloat *const  data 
)
override

Definition at line 782 of file dgccacousticperturbsourcefiles.h.

785 {
786 TRACE();
787 TERMM_IF_NOT_COND(dataId == 0, "invalid data id");
788
789 const MBool donorIdsSorted = std::is_sorted(m_calcSourceDonorCells.begin(), m_calcSourceDonorCells.end());
790 TERMM_IF_NOT_COND(donorIdsSorted, "donor ids not sorted");
791
792 if(m_noActiveDonorCells > 0) {
793 std::copy_n(&m_meanVars[0], m_noActiveDonorCells * noMeanVars(), data);
794 }
795}

◆ getDonorVelocityAndVorticity()

template<MInt nDim, class FvSysEqn >
void DgCcAcousticPerturb< nDim, FvSysEqn >::getDonorVelocityAndVorticity ( const std::vector< MInt > &  donorCellIds,
MFloatScratchSpace p_velocity,
MFloatScratchSpace p_vorticity 
)
overrideprivatevirtual

Implements CouplingDgApe< nDim, CouplingFv< nDim, FvSysEqn > >.

Definition at line 720 of file dgccacousticperturbsourcefiles.h.

722 {
723 // Load velocities of all donor leaf cells (if there are any on this domain)
724 for(auto donorId : donorCellIds) {
725 for(MInt varId = 0; varId < noVelocities(); varId++) {
726 p_velocity(donorId, varId) = fvSolver().a_pvariable(donorId, fvSolver().PV->VV[varId]);
727 }
728 }
729
730 // Only calculate vorticity if this domain has FV cells at all, otherwise
731 // the FV solver pointer is null and a segmentation fault occurs
732 // TODO labels:COUPLER,FV only compute vorticity on donor cells where it is needed?
734 fvSolver().getVorticityT(&p_vorticity[0]);
735 }
736}
MBool m_hasDonorCartesianSolver
Store whether this domain has Cartesian donor solver cells.
virtual void getVorticityT(MFloat *const vorticity)
wrapper for vorticity computation (transposed version)

◆ init()

template<MInt nDim, class FvSysEqn >
void DgCcAcousticPerturb< nDim, FvSysEqn >::init ( )
inlineoverridevirtual

Implements Coupling.

Definition at line 89 of file dgccacousticperturbsourcefiles.h.

89 {
92 };
void init() override
void sanityCheck()
Perform sanity checks.

◆ noCellDataDlb()

template<MInt nDim, class FvSysEqn >
MInt DgCcAcousticPerturb< nDim, FvSysEqn >::noCellDataDlb ( ) const
inlineoverridevirtual

Reimplemented from Coupling.

Definition at line 107 of file dgccacousticperturbsourcefiles.h.

107 {
108 return 1; // One (float) data field to communicate
109 };

◆ noMeanVars()

template<MInt nDim, class FvSysEqn >
MInt CouplingDgApe< nDim, CouplingDonor >::noMeanVars ( ) const
inline

Definition at line 308 of file couplingdgape.h.

◆ noVelocities()

template<MInt nDim, class FvSysEqn >
static constexpr MInt CouplingDgApe< nDim, CouplingDonor >::noVelocities ( )
inlinestaticconstexpr

Definition at line 306 of file couplingdgape.h.

◆ noVorticities()

template<MInt nDim, class FvSysEqn >
static constexpr MInt CouplingDgApe< nDim, CouplingDonor >::noVorticities ( )
inlinestaticconstexpr

Definition at line 307 of file couplingdgape.h.

◆ sanityCheck()

template<MInt nDim, class FvSysEqn >
void DgCcAcousticPerturb< nDim, FvSysEqn >::sanityCheck
private
Author
Miro Gondrum (refactored)
Date
28.04.2021

Definition at line 213 of file dgccacousticperturbsourcefiles.h.

213 {
214 TRACE();
215
216 if(!fvSolver().calcSlopesAfterStep()) {
217 TERMM(1,
218 "Enable calcSlopesAfterStep for FV-solver for coupled simulation (else the slopes are not "
219 "initialized prior to the first source term calculation and will contain garbage)");
220 }
221}

◆ setCellDataDlb()

template<MInt nDim, class FvSysEqn >
void DgCcAcousticPerturb< nDim, FvSysEqn >::setCellDataDlb ( const MInt   NotUseddataId,
const MFloat *const   NotUseddata 
)
overridevirtual

Reimplemented from Coupling.

Definition at line 799 of file dgccacousticperturbsourcefiles.h.

799 {
800 TRACE();
801 TERMM_IF_NOT_COND(dataId == 0, "invalid data id");
802
803 // Return if not on the right reinitialization stage
805 return;
806 }
807
808 const MBool donorIdsSorted = std::is_sorted(m_calcSourceDonorCells.begin(), m_calcSourceDonorCells.end());
809 TERMM_IF_NOT_COND(donorIdsSorted, "donor ids not sorted");
810
811 if(m_noActiveDonorCells > 0) {
812 std::copy_n(data, m_noActiveDonorCells * noMeanVars(), &m_meanVars[0]);
813 }
814}

Member Data Documentation

◆ m_calcProjectionError

template<MInt nDim, class FvSysEqn >
MBool CouplingDgApe< nDim, CouplingDonor >::m_calcProjectionError

Definition at line 374 of file couplingdgape.h.

◆ m_calcSourceDonorCells

template<MInt nDim, class FvSysEqn >
std::vector<MInt> CouplingDgApe< nDim, CouplingDonor >::m_calcSourceDonorCells

Definition at line 390 of file couplingdgape.h.

◆ m_checkConservation

template<MInt nDim, class FvSysEqn >
MBool CouplingDgApe< nDim, CouplingDonor >::m_checkConservation

Definition at line 395 of file couplingdgape.h.

◆ m_fixedTimeStep

template<MInt nDim, class FvSysEqn >
MFloat CouplingDgApe< nDim, CouplingDonor >::m_fixedTimeStep

Definition at line 364 of file couplingdgape.h.

◆ m_hasDgCartesianSolver

template<MInt nDim, class FvSysEqn >
MBool CouplingDgApe< nDim, CouplingDonor >::m_hasDgCartesianSolver

Definition at line 357 of file couplingdgape.h.

◆ m_hasDonorCartesianSolver

template<MInt nDim, class FvSysEqn >
MBool CouplingDgApe< nDim, CouplingDonor >::m_hasDonorCartesianSolver

Definition at line 358 of file couplingdgape.h.

◆ m_isFirstSourceCalculation

template<MInt nDim, class FvSysEqn >
MBool CouplingDgApe< nDim, CouplingDonor >::m_isFirstSourceCalculation

Definition at line 388 of file couplingdgape.h.

◆ m_isRestart

template<MInt nDim, class FvSysEqn >
MBool CouplingDgApe< nDim, CouplingDonor >::m_isRestart

Definition at line 356 of file couplingdgape.h.

◆ m_loadBalancingReinitStage

template<MInt nDim, class FvSysEqn >
MInt DgCcAcousticPerturb< nDim, FvSysEqn >::m_loadBalancingReinitStage = -1
private

Definition at line 154 of file dgccacousticperturbsourcefiles.h.

◆ m_maxConservationError

template<MInt nDim, class FvSysEqn >
MFloat CouplingDgApe< nDim, CouplingDonor >::m_maxConservationError

Definition at line 396 of file couplingdgape.h.

◆ m_maxL2Error

template<MInt nDim, class FvSysEqn >
MFloat CouplingDgApe< nDim, CouplingDonor >::m_maxL2Error

Definition at line 397 of file couplingdgape.h.

◆ m_meanVars

template<MInt nDim, class FvSysEqn >
std::vector<MFloat> CouplingDgApe< nDim, CouplingDonor >::m_meanVars

Definition at line 400 of file couplingdgape.h.

◆ m_meanVarsIndex

template<MInt nDim, class FvSysEqn >
std::array<MInt, s_totalNoMeanVars> CouplingDgApe< nDim, CouplingDonor >::m_meanVarsIndex

Definition at line 426 of file couplingdgape.h.

◆ m_noActiveDonorCells

template<MInt nDim, class FvSysEqn >
MInt CouplingDgApe< nDim, CouplingDonor >::m_noActiveDonorCells

Number of 'active' donor cells, i.e. those donor leaf cells on which source terms need to be computed

Definition at line 377 of file couplingdgape.h.

◆ m_noDonorCells

template<MInt nDim, class FvSysEqn >
MInt CouplingDgApe< nDim, CouplingDonor >::m_noDonorCells

Definition at line 379 of file couplingdgape.h.

◆ m_oldPressure

template<MInt nDim, class FvSysEqn >
std::vector<MFloat> DgCcAcousticPerturb< nDim, FvSysEqn >::m_oldPressure {}
private

Definition at line 156 of file dgccacousticperturbsourcefiles.h.

◆ m_previousTime

template<MInt nDim, class FvSysEqn >
MFloat CouplingDgApe< nDim, CouplingDonor >::m_previousTime

Definition at line 365 of file couplingdgape.h.

◆ m_timers

template<MInt nDim, class FvSysEqn >
std::array<MInt, Timers::_count> CouplingDgApe< nDim, CouplingDonor >::m_timers

Definition at line 464 of file couplingdgape.h.


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