Nektar++
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
Nektar::AcousticSystem Class Referenceabstract

#include <AcousticSystem.h>

Inheritance diagram for Nektar::AcousticSystem:
[legend]

Public Member Functions

virtual ~AcousticSystem ()
 Destructor. More...
 
- Public Member Functions inherited from Nektar::SolverUtils::AdvectionSystem
SOLVER_UTILS_EXPORT AdvectionSystem (const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
 
virtual SOLVER_UTILS_EXPORT ~AdvectionSystem ()
 
SOLVER_UTILS_EXPORT AdvectionSharedPtr GetAdvObject ()
 Returns the advection object held by this instance. More...
 
SOLVER_UTILS_EXPORT Array< OneD, NekDoubleGetElmtCFLVals (void)
 
SOLVER_UTILS_EXPORT NekDouble GetCFLEstimate (int &elmtid)
 
- Public Member Functions inherited from Nektar::SolverUtils::UnsteadySystem
virtual SOLVER_UTILS_EXPORT ~UnsteadySystem ()
 Destructor. More...
 
SOLVER_UTILS_EXPORT NekDouble GetTimeStep (const Array< OneD, const Array< OneD, NekDouble >> &inarray)
 Calculate the larger time-step mantaining the problem stable. More...
 
- Public Member Functions inherited from Nektar::SolverUtils::EquationSystem
virtual SOLVER_UTILS_EXPORT ~EquationSystem ()
 Destructor. More...
 
SOLVER_UTILS_EXPORT void SetUpTraceNormals (void)
 
SOLVER_UTILS_EXPORT void InitObject ()
 Initialises the members of this object. More...
 
SOLVER_UTILS_EXPORT void DoInitialise ()
 Perform any initialisation necessary before solving the problem. More...
 
SOLVER_UTILS_EXPORT void DoSolve ()
 Solve the problem. More...
 
SOLVER_UTILS_EXPORT void TransCoeffToPhys ()
 Transform from coefficient to physical space. More...
 
SOLVER_UTILS_EXPORT void TransPhysToCoeff ()
 Transform from physical to coefficient space. More...
 
SOLVER_UTILS_EXPORT void Output ()
 Perform output operations after solve. More...
 
SOLVER_UTILS_EXPORT NekDouble LinfError (unsigned int field, const Array< OneD, NekDouble > &exactsoln=NullNekDouble1DArray)
 Linf error computation. More...
 
SOLVER_UTILS_EXPORT std::string GetSessionName ()
 Get Session name. More...
 
template<class T >
std::shared_ptr< T > as ()
 
SOLVER_UTILS_EXPORT void ResetSessionName (std::string newname)
 Reset Session name. More...
 
SOLVER_UTILS_EXPORT LibUtilities::SessionReaderSharedPtr GetSession ()
 Get Session name. More...
 
SOLVER_UTILS_EXPORT MultiRegions::ExpListSharedPtr GetPressure ()
 Get pressure field if available. More...
 
SOLVER_UTILS_EXPORT void ExtraFldOutput (std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables)
 
SOLVER_UTILS_EXPORT void PrintSummary (std::ostream &out)
 Print a summary of parameters and solver characteristics. More...
 
SOLVER_UTILS_EXPORT void SetLambda (NekDouble lambda)
 Set parameter m_lambda. More...
 
SOLVER_UTILS_EXPORT SessionFunctionSharedPtr GetFunction (std::string name, const MultiRegions::ExpListSharedPtr &field=MultiRegions::NullExpListSharedPtr, bool cache=false)
 Get a SessionFunction by name. More...
 
SOLVER_UTILS_EXPORT void SetInitialConditions (NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
 Initialise the data in the dependent fields. More...
 
SOLVER_UTILS_EXPORT void EvaluateExactSolution (int field, Array< OneD, NekDouble > &outfield, const NekDouble time)
 Evaluates an exact solution. More...
 
SOLVER_UTILS_EXPORT NekDouble L2Error (unsigned int field, const Array< OneD, NekDouble > &exactsoln, bool Normalised=false)
 Compute the L2 error between fields and a given exact solution. More...
 
SOLVER_UTILS_EXPORT NekDouble L2Error (unsigned int field, bool Normalised=false)
 Compute the L2 error of the fields. More...
 
SOLVER_UTILS_EXPORT Array< OneD, NekDoubleErrorExtraPoints (unsigned int field)
 Compute error (L2 and L_inf) over an larger set of quadrature points return [L2 Linf]. More...
 
SOLVER_UTILS_EXPORT void Checkpoint_Output (const int n)
 Write checkpoint file of m_fields. More...
 
SOLVER_UTILS_EXPORT void Checkpoint_Output (const int n, MultiRegions::ExpListSharedPtr &field, std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables)
 Write checkpoint file of custom data fields. More...
 
SOLVER_UTILS_EXPORT void Checkpoint_BaseFlow (const int n)
 Write base flow file of m_fields. More...
 
SOLVER_UTILS_EXPORT void WriteFld (const std::string &outname)
 Write field data to the given filename. More...
 
SOLVER_UTILS_EXPORT void WriteFld (const std::string &outname, MultiRegions::ExpListSharedPtr &field, std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables)
 Write input fields to the given filename. More...
 
SOLVER_UTILS_EXPORT void ImportFld (const std::string &infile, Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
 Input field data from the given file. More...
 
SOLVER_UTILS_EXPORT void ImportFldToMultiDomains (const std::string &infile, Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const int ndomains)
 Input field data from the given file to multiple domains. More...
 
SOLVER_UTILS_EXPORT void ImportFld (const std::string &infile, std::vector< std::string > &fieldStr, Array< OneD, Array< OneD, NekDouble > > &coeffs)
 Output a field. Input field data into array from the given file. More...
 
SOLVER_UTILS_EXPORT void ImportFld (const std::string &infile, MultiRegions::ExpListSharedPtr &pField, std::string &pFieldName)
 Output a field. Input field data into ExpList from the given file. More...
 
SOLVER_UTILS_EXPORT void SessionSummary (SummaryList &vSummary)
 Write out a session summary. More...
 
SOLVER_UTILS_EXPORT Array< OneD, MultiRegions::ExpListSharedPtr > & UpdateFields ()
 
SOLVER_UTILS_EXPORT LibUtilities::FieldMetaDataMapUpdateFieldMetaDataMap ()
 Get hold of FieldInfoMap so it can be updated. More...
 
SOLVER_UTILS_EXPORT NekDouble GetFinalTime ()
 Return final time. More...
 
SOLVER_UTILS_EXPORT int GetNcoeffs ()
 
SOLVER_UTILS_EXPORT int GetNcoeffs (const int eid)
 
SOLVER_UTILS_EXPORT int GetNumExpModes ()
 
SOLVER_UTILS_EXPORT const Array< OneD, int > GetNumExpModesPerExp ()
 
SOLVER_UTILS_EXPORT int GetNvariables ()
 
SOLVER_UTILS_EXPORT const std::string GetVariable (unsigned int i)
 
SOLVER_UTILS_EXPORT int GetTraceTotPoints ()
 
SOLVER_UTILS_EXPORT int GetTraceNpoints ()
 
SOLVER_UTILS_EXPORT int GetExpSize ()
 
SOLVER_UTILS_EXPORT int GetPhys_Offset (int n)
 
SOLVER_UTILS_EXPORT int GetCoeff_Offset (int n)
 
SOLVER_UTILS_EXPORT int GetTotPoints ()
 
SOLVER_UTILS_EXPORT int GetTotPoints (int n)
 
SOLVER_UTILS_EXPORT int GetNpoints ()
 
SOLVER_UTILS_EXPORT int GetSteps ()
 
SOLVER_UTILS_EXPORT NekDouble GetTimeStep ()
 
SOLVER_UTILS_EXPORT void CopyFromPhysField (const int i, Array< OneD, NekDouble > &output)
 
SOLVER_UTILS_EXPORT void CopyToPhysField (const int i, Array< OneD, NekDouble > &output)
 
SOLVER_UTILS_EXPORT void SetSteps (const int steps)
 
SOLVER_UTILS_EXPORT void ZeroPhysFields ()
 
SOLVER_UTILS_EXPORT void FwdTransFields ()
 
SOLVER_UTILS_EXPORT void SetModifiedBasis (const bool modbasis)
 
SOLVER_UTILS_EXPORT int GetCheckpointNumber ()
 
SOLVER_UTILS_EXPORT void SetCheckpointNumber (int num)
 
SOLVER_UTILS_EXPORT int GetCheckpointSteps ()
 
SOLVER_UTILS_EXPORT void SetCheckpointSteps (int num)
 
SOLVER_UTILS_EXPORT void SetTime (const NekDouble time)
 
SOLVER_UTILS_EXPORT void SetInitialStep (const int step)
 
SOLVER_UTILS_EXPORT void SetBoundaryConditions (NekDouble time)
 Evaluates the boundary conditions at the given time. More...
 
virtual SOLVER_UTILS_EXPORT bool v_NegatedOp ()
 Virtual function to identify if operator is negated in DoSolve. More...
 

Protected Member Functions

 AcousticSystem (const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
 Initialises UnsteadySystem class members. More...
 
virtual void v_InitObject ()
 Initialization object for the AcousticSystem class. More...
 
void DoOdeRhs (const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
 Compute the right-hand side. More...
 
void DoOdeProjection (const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
 Compute the projection and call the method for imposing the boundary conditions in case of discontinuous projection. More...
 
virtual void v_GetFluxVector (const Array< OneD, Array< OneD, NekDouble >> &physfield, Array< OneD, Array< OneD, Array< OneD, NekDouble >>> &flux)=0
 
virtual void v_AddLinTerm (const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray)
 
virtual bool v_PreIntegrate (int step)
 v_PreIntegrate More...
 
virtual void v_Output ()
 
virtual Array< OneD, NekDoublev_GetMaxStdVelocity ()
 Compute the advection velocity in the standard space for each element of the expansion. More...
 
virtual void v_ExtraFldOutput (std::vector< Array< OneD, NekDouble >> &fieldcoeffs, std::vector< std::string > &variables)
 
const Array< OneD, const Array< OneD, NekDouble > > & GetNormals ()
 Get the normal vectors. More...
 
const Array< OneD, const Array< OneD, NekDouble > > & GetVecLocs ()
 Get the locations of the components of the directed fields within the fields array. More...
 
const Array< OneD, const Array< OneD, NekDouble > > & GetBasefieldFwdBwd ()
 Get the baseflow field. More...
 
- Protected Member Functions inherited from Nektar::SolverUtils::AdvectionSystem
virtual SOLVER_UTILS_EXPORT bool v_PostIntegrate (int step)
 
- Protected Member Functions inherited from Nektar::SolverUtils::UnsteadySystem
SOLVER_UTILS_EXPORT UnsteadySystem (const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
 Initialises UnsteadySystem class members. More...
 
SOLVER_UTILS_EXPORT NekDouble MaxTimeStepEstimator ()
 Get the maximum timestep estimator for cfl control. More...
 
virtual SOLVER_UTILS_EXPORT void v_DoSolve ()
 Solves an unsteady problem. More...
 
virtual SOLVER_UTILS_EXPORT void v_DoInitialise ()
 Sets up initial conditions. More...
 
virtual SOLVER_UTILS_EXPORT void v_GenerateSummary (SummaryList &s)
 Print a summary of time stepping parameters. More...
 
virtual SOLVER_UTILS_EXPORT void v_AppendOutput1D (Array< OneD, Array< OneD, NekDouble >> &solution1D)
 Print the solution at each solution point in a txt file. More...
 
virtual SOLVER_UTILS_EXPORT NekDouble v_GetTimeStep (const Array< OneD, const Array< OneD, NekDouble >> &inarray)
 Return the timestep to be used for the next step in the time-marching loop. More...
 
virtual SOLVER_UTILS_EXPORT bool v_RequireFwdTrans ()
 
SOLVER_UTILS_EXPORT void CheckForRestartTime (NekDouble &time, int &nchk)
 
SOLVER_UTILS_EXPORT void SVVVarDiffCoeff (const Array< OneD, Array< OneD, NekDouble >> vel, StdRegions::VarCoeffMap &varCoeffMap)
 Evaluate the SVV diffusion coefficient according to Moura's paper where it should proportional to h time velocity. More...
 
- Protected Member Functions inherited from Nektar::SolverUtils::EquationSystem
SOLVER_UTILS_EXPORT EquationSystem (const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
 Initialises EquationSystem class members. More...
 
virtual SOLVER_UTILS_EXPORT NekDouble v_LinfError (unsigned int field, const Array< OneD, NekDouble > &exactsoln=NullNekDouble1DArray)
 Virtual function for the L_inf error computation between fields and a given exact solution. More...
 
virtual SOLVER_UTILS_EXPORT NekDouble v_L2Error (unsigned int field, const Array< OneD, NekDouble > &exactsoln=NullNekDouble1DArray, bool Normalised=false)
 Virtual function for the L_2 error computation between fields and a given exact solution. More...
 
virtual SOLVER_UTILS_EXPORT void v_TransCoeffToPhys ()
 Virtual function for transformation to physical space. More...
 
virtual SOLVER_UTILS_EXPORT void v_TransPhysToCoeff ()
 Virtual function for transformation to coefficient space. More...
 
virtual SOLVER_UTILS_EXPORT void v_SetInitialConditions (NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
 
virtual SOLVER_UTILS_EXPORT void v_EvaluateExactSolution (unsigned int field, Array< OneD, NekDouble > &outfield, const NekDouble time)
 
virtual SOLVER_UTILS_EXPORT MultiRegions::ExpListSharedPtr v_GetPressure (void)
 
virtual SOLVER_UTILS_EXPORT void v_ExtraFldOutput (std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables)
 

Protected Attributes

int m_ip
 indices of the fields More...
 
int m_irho
 
int m_iu
 
bool m_conservative
 we are dealing with a conservative formualtion More...
 
SolverUtils::CouplingSharedPtr m_coupling
 
SolverUtils::AdvectionSharedPtr m_advection
 
std::vector< SolverUtils::ForcingSharedPtrm_forcing
 
SolverUtils::RiemannSolverSharedPtr m_riemannSolver
 
Array< OneD, Array< OneD, NekDouble > > m_bfFwdBwd
 
Array< OneD, Array< OneD, NekDouble > > m_vecLocs
 
Array< OneD, Array< OneD, NekDouble > > m_bf
 
std::vector< std::string > m_bfNames
 
- Protected Attributes inherited from Nektar::SolverUtils::AdvectionSystem
SolverUtils::AdvectionSharedPtr m_advObject
 Advection term. More...
 
- Protected Attributes inherited from Nektar::SolverUtils::UnsteadySystem
int m_infosteps
 Number of time steps between outputting status information. More...
 
int m_abortSteps
 Number of steps between checks for abort conditions. More...
 
int m_filtersInfosteps
 Number of time steps between outputting filters information. More...
 
int m_nanSteps
 
LibUtilities::TimeIntegrationWrapperSharedPtr m_intScheme
 Wrapper to the time integration scheme. More...
 
LibUtilities::TimeIntegrationSchemeOperators m_ode
 The time integration scheme operators to use. More...
 
LibUtilities::TimeIntegrationSolutionSharedPtr m_intSoln
 
NekDouble m_epsilon
 
bool m_explicitDiffusion
 Indicates if explicit or implicit treatment of diffusion is used. More...
 
bool m_explicitAdvection
 Indicates if explicit or implicit treatment of advection is used. More...
 
bool m_explicitReaction
 Indicates if explicit or implicit treatment of reaction is used. More...
 
bool m_homoInitialFwd
 Flag to determine if simulation should start in homogeneous forward transformed state. More...
 
NekDouble m_steadyStateTol
 Tolerance to which steady state should be evaluated at. More...
 
int m_steadyStateSteps
 Check for steady state at step interval. More...
 
Array< OneD, Array< OneD, NekDouble > > m_previousSolution
 Storage for previous solution for steady-state check. More...
 
std::ofstream m_errFile
 
std::vector< int > m_intVariables
 
std::vector< std::pair< std::string, FilterSharedPtr > > m_filters
 
NekDouble m_filterTimeWarning
 Number of time steps between outputting status information. More...
 
- Protected Attributes inherited from Nektar::SolverUtils::EquationSystem
LibUtilities::CommSharedPtr m_comm
 Communicator. More...
 
LibUtilities::SessionReaderSharedPtr m_session
 The session reader. More...
 
std::map< std::string, SolverUtils::SessionFunctionSharedPtrm_sessionFunctions
 Map of known SessionFunctions. More...
 
LibUtilities::FieldIOSharedPtr m_fld
 Field input/output. More...
 
Array< OneD, MultiRegions::ExpListSharedPtrm_fields
 Array holding all dependent variables. More...
 
SpatialDomains::BoundaryConditionsSharedPtr m_boundaryConditions
 Pointer to boundary conditions object. More...
 
SpatialDomains::MeshGraphSharedPtr m_graph
 Pointer to graph defining mesh. More...
 
std::string m_sessionName
 Name of the session. More...
 
NekDouble m_time
 Current time of simulation. More...
 
int m_initialStep
 Number of the step where the simulation should begin. More...
 
NekDouble m_fintime
 Finish time of the simulation. More...
 
NekDouble m_timestep
 Time step size. More...
 
NekDouble m_lambda
 Lambda constant in real system if one required. More...
 
NekDouble m_checktime
 Time between checkpoints. More...
 
int m_nchk
 Number of checkpoints written so far. More...
 
int m_steps
 Number of steps to take. More...
 
int m_checksteps
 Number of steps between checkpoints. More...
 
int m_spacedim
 Spatial dimension (>= expansion dim). More...
 
int m_expdim
 Expansion dimension. More...
 
bool m_singleMode
 Flag to determine if single homogeneous mode is used. More...
 
bool m_halfMode
 Flag to determine if half homogeneous mode is used. More...
 
bool m_multipleModes
 Flag to determine if use multiple homogenenous modes are used. More...
 
bool m_useFFT
 Flag to determine if FFT is used for homogeneous transform. More...
 
bool m_homogen_dealiasing
 Flag to determine if dealiasing is used for homogeneous simulations. More...
 
bool m_specHP_dealiasing
 Flag to determine if dealisising is usde for the Spectral/hp element discretisation. More...
 
enum MultiRegions::ProjectionType m_projectionType
 Type of projection; e.g continuous or discontinuous. More...
 
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
 Array holding trace normals for DG simulations in the forwards direction. More...
 
Array< OneD, bool > m_checkIfSystemSingular
 Flag to indicate if the fields should be checked for singularity. More...
 
LibUtilities::FieldMetaDataMap m_fieldMetaDataMap
 Map to identify relevant solver info to dump in output fields. More...
 
int m_NumQuadPointsError
 Number of Quadrature points used to work out the error. More...
 
enum HomogeneousType m_HomogeneousType
 
NekDouble m_LhomX
 physical length in X direction (if homogeneous) More...
 
NekDouble m_LhomY
 physical length in Y direction (if homogeneous) More...
 
NekDouble m_LhomZ
 physical length in Z direction (if homogeneous) More...
 
int m_npointsX
 number of points in X direction (if homogeneous) More...
 
int m_npointsY
 number of points in Y direction (if homogeneous) More...
 
int m_npointsZ
 number of points in Z direction (if homogeneous) More...
 
int m_HomoDirec
 number of homogenous directions More...
 

Private Member Functions

NekDouble GetCFLEstimate ()
 
void SetBoundaryConditions (Array< OneD, Array< OneD, NekDouble >> &physarray, NekDouble time)
 Apply the Boundary Conditions to the AcousticSystem equations. More...
 
virtual void v_WallBC (int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble >> &Fwd, Array< OneD, Array< OneD, NekDouble >> &physarray)
 Wall boundary conditions for the AcousticSystem equations. More...
 
virtual void v_RiemannInvariantBC (int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble >> &Fwd, Array< OneD, Array< OneD, NekDouble >> &BfFwd, Array< OneD, Array< OneD, NekDouble >> &physarray)=0
 
virtual void v_WhiteNoiseBC (int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble >> &Fwd, Array< OneD, Array< OneD, NekDouble >> &BfFwd, Array< OneD, Array< OneD, NekDouble >> &physarray)
 Wall boundary conditions for the AcousticSystem equations. More...
 
void CopyBoundaryTrace (const Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd)
 
void UpdateBasefieldFwdBwd ()
 

Private Attributes

std::map< int, boost::mt19937 > m_rng
 
NekDouble m_whiteNoiseBC_lastUpdate
 
NekDouble m_whiteNoiseBC_p
 

Friends

class MemoryManager< AcousticSystem >
 

Additional Inherited Members

- Public Attributes inherited from Nektar::SolverUtils::UnsteadySystem
NekDouble m_cflSafetyFactor
 CFL safety factor (comprise between 0 to 1). More...
 
- Protected Types inherited from Nektar::SolverUtils::EquationSystem
enum  HomogeneousType { eHomogeneous1D, eHomogeneous2D, eHomogeneous3D, eNotHomogeneous }
 Parameter for homogeneous expansions. More...
 
- Static Protected Attributes inherited from Nektar::SolverUtils::EquationSystem
static std::string equationSystemTypeLookupIds []
 

Detailed Description

Definition at line 60 of file AcousticSystem.h.

Constructor & Destructor Documentation

◆ ~AcousticSystem()

Nektar::AcousticSystem::~AcousticSystem ( )
virtual

Destructor.

Destructor for AcousticSystem class.

Definition at line 120 of file AcousticSystem.cpp.

121 {
122 }

◆ AcousticSystem()

Nektar::AcousticSystem::AcousticSystem ( const LibUtilities::SessionReaderSharedPtr pSession,
const SpatialDomains::MeshGraphSharedPtr pGraph 
)
protected

Initialises UnsteadySystem class members.

Definition at line 57 of file AcousticSystem.cpp.

60  : UnsteadySystem(pSession, pGraph), AdvectionSystem(pSession, pGraph),
61  m_ip(-1), m_irho(-1), m_iu(1), m_conservative(false)
62 {
63 }
bool m_conservative
we are dealing with a conservative formualtion
int m_ip
indices of the fields
SOLVER_UTILS_EXPORT UnsteadySystem(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Initialises UnsteadySystem class members.
SOLVER_UTILS_EXPORT AdvectionSystem(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)

Member Function Documentation

◆ CopyBoundaryTrace()

void Nektar::AcousticSystem::CopyBoundaryTrace ( const Array< OneD, NekDouble > &  Fwd,
Array< OneD, NekDouble > &  Bwd 
)
private

Definition at line 626 of file AcousticSystem.cpp.

References Nektar::SolverUtils::EquationSystem::m_fields, and Vmath::Vcopy().

Referenced by UpdateBasefieldFwdBwd().

628 {
629  int cnt = 0;
630  // loop over Boundary Regions
631  for (int bcRegion = 0;
632  bcRegion < m_fields[0]->GetBndConditions().num_elements(); ++bcRegion)
633  {
634 
635  // Copy the forward trace of the field to the backward trace
636  int e, id2, npts;
637 
638  for (e = 0;
639  e < m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
640  ++e)
641  {
642  npts = m_fields[0]
643  ->GetBndCondExpansions()[bcRegion]
644  ->GetExp(e)
645  ->GetTotPoints();
646  id2 = m_fields[0]->GetTrace()->GetPhys_Offset(
647  m_fields[0]->GetTraceMap()->GetBndCondCoeffsToGlobalCoeffsMap(
648  cnt + e));
649 
650  Vmath::Vcopy(npts, &Fwd[id2], 1, &Bwd[id2], 1);
651  }
652 
653  cnt += m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
654  }
655 }
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064

◆ DoOdeProjection()

void Nektar::AcousticSystem::DoOdeProjection ( const Array< OneD, const Array< OneD, NekDouble >> &  inarray,
Array< OneD, Array< OneD, NekDouble >> &  outarray,
const NekDouble  time 
)
protected

Compute the projection and call the method for imposing the boundary conditions in case of discontinuous projection.

Definition at line 215 of file AcousticSystem.cpp.

References Nektar::SolverUtils::EquationSystem::m_fields, SetBoundaryConditions(), UpdateBasefieldFwdBwd(), and Vmath::Vcopy().

Referenced by Nektar::APE::v_InitObject(), and Nektar::LEE::v_InitObject().

218 {
219  int nvariables = inarray.num_elements();
220  int nq = m_fields[0]->GetNpoints();
221 
222  // deep copy
223  for (int i = 0; i < nvariables; ++i)
224  {
225  Vmath::Vcopy(nq, inarray[i], 1, outarray[i], 1);
226  }
227 
229 
230  SetBoundaryConditions(outarray, time);
231 }
void SetBoundaryConditions(Array< OneD, Array< OneD, NekDouble >> &physarray, NekDouble time)
Apply the Boundary Conditions to the AcousticSystem equations.
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064

◆ DoOdeRhs()

void Nektar::AcousticSystem::DoOdeRhs ( const Array< OneD, const Array< OneD, NekDouble >> &  inarray,
Array< OneD, Array< OneD, NekDouble >> &  outarray,
const NekDouble  time 
)
protected

Compute the right-hand side.

Definition at line 186 of file AcousticSystem.cpp.

References Nektar::SolverUtils::EquationSystem::GetTotPoints(), m_advection, Nektar::SolverUtils::EquationSystem::m_fields, m_forcing, Nektar::SolverUtils::EquationSystem::m_spacedim, Nektar::SolverUtils::EquationSystem::m_time, Vmath::Neg(), and v_AddLinTerm().

Referenced by Nektar::APE::v_InitObject(), and Nektar::LEE::v_InitObject().

189 {
190  int nVariables = inarray.num_elements();
191  int nq = GetTotPoints();
192 
193  // WeakDG does not use advVel, so we only provide a dummy array
194  Array<OneD, Array<OneD, NekDouble>> advVel(m_spacedim);
195  m_advection->Advect(nVariables, m_fields, advVel, inarray, outarray, time);
196 
197  // Negate the LHS terms
198  for (int i = 0; i < nVariables; ++i)
199  {
200  Vmath::Neg(nq, outarray[i], 1);
201  }
202 
203  v_AddLinTerm(inarray, outarray);
204 
205  for (auto &x : m_forcing)
206  {
207  x->Apply(m_fields, inarray, outarray, m_time);
208  }
209 }
NekDouble m_time
Current time of simulation.
SOLVER_UTILS_EXPORT int GetTotPoints()
std::vector< SolverUtils::ForcingSharedPtr > m_forcing
int m_spacedim
Spatial dimension (>= expansion dim).
void Neg(int n, T *x, const int incx)
Negate x = -x.
Definition: Vmath.cpp:399
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
virtual void v_AddLinTerm(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray)
SolverUtils::AdvectionSharedPtr m_advection

◆ GetBasefieldFwdBwd()

const Array< OneD, const Array< OneD, NekDouble > > & Nektar::AcousticSystem::GetBasefieldFwdBwd ( )
protected

Get the baseflow field.

Definition at line 611 of file AcousticSystem.cpp.

References m_bfFwdBwd.

Referenced by SetBoundaryConditions(), Nektar::APE::v_InitObject(), and Nektar::LEE::v_InitObject().

612 {
613  return m_bfFwdBwd;
614 }
Array< OneD, Array< OneD, NekDouble > > m_bfFwdBwd

◆ GetCFLEstimate()

NekDouble Nektar::AcousticSystem::GetCFLEstimate ( )
private

◆ GetNormals()

const Array< OneD, const Array< OneD, NekDouble > > & Nektar::AcousticSystem::GetNormals ( )
protected

Get the normal vectors.

Definition at line 593 of file AcousticSystem.cpp.

References Nektar::SolverUtils::EquationSystem::m_traceNormals.

Referenced by Nektar::APE::v_InitObject(), and Nektar::LEE::v_InitObject().

594 {
595  return m_traceNormals;
596 }
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Array holding trace normals for DG simulations in the forwards direction.

◆ GetVecLocs()

const Array< OneD, const Array< OneD, NekDouble > > & Nektar::AcousticSystem::GetVecLocs ( )
protected

Get the locations of the components of the directed fields within the fields array.

Definition at line 602 of file AcousticSystem.cpp.

References m_vecLocs.

Referenced by Nektar::APE::v_InitObject(), and Nektar::LEE::v_InitObject().

603 {
604  return m_vecLocs;
605 }
Array< OneD, Array< OneD, NekDouble > > m_vecLocs

◆ SetBoundaryConditions()

void Nektar::AcousticSystem::SetBoundaryConditions ( Array< OneD, Array< OneD, NekDouble >> &  physarray,
NekDouble  time 
)
private

Apply the Boundary Conditions to the AcousticSystem equations.

Definition at line 236 of file AcousticSystem.cpp.

References ASSERTL0, GetBasefieldFwdBwd(), Nektar::SolverUtils::EquationSystem::GetTraceTotPoints(), Nektar::SolverUtils::EquationSystem::m_fields, Nektar::SolverUtils::EquationSystem::m_session, v_RiemannInvariantBC(), v_WallBC(), and v_WhiteNoiseBC().

Referenced by DoOdeProjection().

238 {
239  std::string varName;
240  int nvariables = m_fields.num_elements();
241  int cnt = 0;
242  int nTracePts = GetTraceTotPoints();
243 
244  // Extract trace for boundaries. Needs to be done on all processors to avoid
245  // deadlock.
246  Array<OneD, Array<OneD, NekDouble>> Fwd(nvariables);
247  for (int i = 0; i < nvariables; ++i)
248  {
249  Fwd[i] = Array<OneD, NekDouble>(nTracePts);
250  m_fields[i]->ExtractTracePhys(inarray[i], Fwd[i]);
251  }
252  Array<OneD, Array<OneD, NekDouble>> bfFwd = GetBasefieldFwdBwd();
253 
254  // loop over Boundary Regions
255  for (int n = 0; n < m_fields[0]->GetBndConditions().num_elements(); ++n)
256  {
257  std::string userDefStr =
258  m_fields[0]->GetBndConditions()[n]->GetUserDefined();
259 
260  if (!userDefStr.empty())
261  {
262  // Wall Boundary Condition
263  if (boost::iequals(userDefStr, "Wall"))
264  {
265  v_WallBC(n, cnt, Fwd, inarray);
266  }
267  else if (boost::iequals(userDefStr, "WhiteNoise"))
268  {
269  v_WhiteNoiseBC(n, cnt, Fwd, bfFwd, inarray);
270  }
271  else if (boost::iequals(userDefStr, "RiemannInvariantBC"))
272  {
273  v_RiemannInvariantBC(n, cnt, Fwd, bfFwd, inarray);
274  }
275  else if (boost::iequals(userDefStr, "TimeDependent"))
276  {
277  for (int i = 0; i < nvariables; ++i)
278  {
279  varName = m_session->GetVariable(i);
280  m_fields[i]->EvaluateBoundaryConditions(time, varName);
281  }
282  }
283  else
284  {
285  string errmsg = "Unrecognised boundary condition: ";
286  errmsg += userDefStr;
287  ASSERTL0(false, errmsg.c_str());
288  }
289  }
290  else
291  {
292  for (int i = 0; i < nvariables; ++i)
293  {
294  varName = m_session->GetVariable(i);
295  m_fields[i]->EvaluateBoundaryConditions(time, varName);
296  }
297  }
298 
299  cnt += m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
300  }
301 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
virtual void v_WhiteNoiseBC(int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble >> &Fwd, Array< OneD, Array< OneD, NekDouble >> &BfFwd, Array< OneD, Array< OneD, NekDouble >> &physarray)
Wall boundary conditions for the AcousticSystem equations.
const Array< OneD, const Array< OneD, NekDouble > > & GetBasefieldFwdBwd()
Get the baseflow field.
virtual void v_WallBC(int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble >> &Fwd, Array< OneD, Array< OneD, NekDouble >> &physarray)
Wall boundary conditions for the AcousticSystem equations.
SOLVER_UTILS_EXPORT int GetTraceTotPoints()
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
virtual void v_RiemannInvariantBC(int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble >> &Fwd, Array< OneD, Array< OneD, NekDouble >> &BfFwd, Array< OneD, Array< OneD, NekDouble >> &physarray)=0

◆ UpdateBasefieldFwdBwd()

void Nektar::AcousticSystem::UpdateBasefieldFwdBwd ( )
private

Definition at line 616 of file AcousticSystem.cpp.

References CopyBoundaryTrace(), m_bf, m_bfFwdBwd, m_bfNames, and Nektar::SolverUtils::EquationSystem::m_fields.

Referenced by DoOdeProjection().

617 {
618  for (int i = 0; i < m_bfNames.size(); i++)
619  {
620  int j = m_bfNames.size() + i;
621  m_fields[0]->GetFwdBwdTracePhys(m_bf[i], m_bfFwdBwd[i], m_bfFwdBwd[j]);
623  }
624 }
Array< OneD, Array< OneD, NekDouble > > m_bf
std::vector< std::string > m_bfNames
void CopyBoundaryTrace(const Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd)
Array< OneD, Array< OneD, NekDouble > > m_bfFwdBwd
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.

◆ v_AddLinTerm()

virtual void Nektar::AcousticSystem::v_AddLinTerm ( const Array< OneD, const Array< OneD, NekDouble >> &  inarray,
Array< OneD, Array< OneD, NekDouble >> &  outarray 
)
inlineprotectedvirtual

Reimplemented in Nektar::LEE.

Definition at line 100 of file AcousticSystem.h.

Referenced by DoOdeRhs().

103  {
104  boost::ignore_unused(inarray, outarray);
105  }

◆ v_ExtraFldOutput()

void Nektar::AcousticSystem::v_ExtraFldOutput ( std::vector< Array< OneD, NekDouble >> &  fieldcoeffs,
std::vector< std::string > &  variables 
)
protectedvirtual

Definition at line 563 of file AcousticSystem.cpp.

References Nektar::SolverUtils::EquationSystem::GetNcoeffs(), m_bf, m_bfNames, Nektar::SolverUtils::EquationSystem::m_fields, m_forcing, and Nektar::SolverUtils::EquationSystem::m_session.

566 {
567  for (int i = 0; i < m_bfNames.size(); i++)
568  {
569  variables.push_back(m_bfNames[i]);
570  Array<OneD, NekDouble> tmpC(GetNcoeffs());
571  m_fields[0]->FwdTrans(m_bf[i], tmpC);
572  fieldcoeffs.push_back(tmpC);
573  }
574 
575  int f = 0;
576  for (auto &x : m_forcing)
577  {
578  for (int i = 0; i < x->GetForces().num_elements(); ++i)
579  {
580  variables.push_back("F_" + boost::lexical_cast<string>(f) + "_" +
581  m_session->GetVariable(i));
582  Array<OneD, NekDouble> tmpC(GetNcoeffs());
583  m_fields[0]->FwdTrans(x->GetForces()[i], tmpC);
584  fieldcoeffs.push_back(tmpC);
585  }
586  f++;
587  }
588 }
Array< OneD, Array< OneD, NekDouble > > m_bf
std::vector< std::string > m_bfNames
std::vector< SolverUtils::ForcingSharedPtr > m_forcing
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
SOLVER_UTILS_EXPORT int GetNcoeffs()

◆ v_GetFluxVector()

virtual void Nektar::AcousticSystem::v_GetFluxVector ( const Array< OneD, Array< OneD, NekDouble >> &  physfield,
Array< OneD, Array< OneD, Array< OneD, NekDouble >>> &  flux 
)
protectedpure virtual

Implemented in Nektar::LEE, and Nektar::APE.

◆ v_GetMaxStdVelocity()

Array< OneD, NekDouble > Nektar::AcousticSystem::v_GetMaxStdVelocity ( void  )
protectedvirtual

Compute the advection velocity in the standard space for each element of the expansion.

Returns
Standard velocity field.

Reimplemented from Nektar::SolverUtils::AdvectionSystem.

Definition at line 472 of file AcousticSystem.cpp.

References Nektar::SpatialDomains::eDeformed, m_bf, Nektar::SolverUtils::EquationSystem::m_fields, Nektar::SolverUtils::EquationSystem::m_spacedim, Vmath::Smul(), Vmath::Svtvp(), Vmath::Vmul(), and Vmath::Vvtvp().

473 {
474  int nElm = m_fields[0]->GetExpSize();
475 
476  Array<OneD, NekDouble> stdV(nElm, 0.0);
477 
478  Array<OneD, Array<OneD, NekDouble>> stdVelocity(m_spacedim);
479  Array<OneD, Array<OneD, NekDouble>> velocity(m_spacedim);
481 
482  int cnt = 0;
483 
484  for (int el = 0; el < nElm; ++el)
485  {
486  ptsKeys = m_fields[0]->GetExp(el)->GetPointsKeys();
487 
488  // Possible bug: not multiply by jacobian??
489  const SpatialDomains::GeomFactorsSharedPtr metricInfo =
490  m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo();
491  const Array<TwoD, const NekDouble> &gmat =
492  m_fields[0]
493  ->GetExp(el)
494  ->GetGeom()
495  ->GetMetricInfo()
496  ->GetDerivFactors(ptsKeys);
497 
498  int nq = m_fields[0]->GetExp(el)->GetTotPoints();
499 
500  for (int i = 0; i < m_spacedim; ++i)
501  {
502  stdVelocity[i] = Array<OneD, NekDouble>(nq, 0.0);
503 
504  velocity[i] = Array<OneD, NekDouble>(nq, 0.0);
505  for (int j = 0; j < nq; ++j)
506  {
507  // The total advection velocity is v+c, so we need to scale c by
508  // adding it before we do the transformation.
509  NekDouble c = sqrt(m_bf[0][cnt + j]);
510  velocity[i][j] = m_bf[i + 2][cnt + j] + c;
511  }
512  }
513 
514  // scale the velocity components
515  if (metricInfo->GetGtype() == SpatialDomains::eDeformed)
516  {
517  // d xi/ dx = gmat = 1/J * d x/d xi
518  for (int i = 0; i < m_spacedim; ++i)
519  {
520  Vmath::Vmul(nq, gmat[i], 1, velocity[0], 1, stdVelocity[i], 1);
521  for (int j = 1; j < m_spacedim; ++j)
522  {
523  Vmath::Vvtvp(nq, gmat[m_spacedim * j + i], 1, velocity[j],
524  1, stdVelocity[i], 1, stdVelocity[i], 1);
525  }
526  }
527  }
528  else
529  {
530  for (int i = 0; i < m_spacedim; ++i)
531  {
532  Vmath::Smul(nq, gmat[i][0], velocity[0], 1, stdVelocity[i], 1);
533  for (int j = 1; j < m_spacedim; ++j)
534  {
535  Vmath::Svtvp(nq, gmat[m_spacedim * j + i][0], velocity[j],
536  1, stdVelocity[i], 1, stdVelocity[i], 1);
537  }
538  }
539  }
540 
541  // compute the max absolute velocity of the element
542  for (int i = 0; i < nq; ++i)
543  {
544  NekDouble pntVelocity = 0.0;
545  for (int j = 0; j < m_spacedim; ++j)
546  {
547  pntVelocity += stdVelocity[j][i] * stdVelocity[j][i];
548  }
549  pntVelocity = sqrt(pntVelocity);
550 
551  if (pntVelocity > stdV[el])
552  {
553  stdV[el] = pntVelocity;
554  }
555  }
556 
557  cnt += nq;
558  }
559 
560  return stdV;
561 }
Array< OneD, Array< OneD, NekDouble > > m_bf
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:246
std::shared_ptr< GeomFactors > GeomFactorsSharedPtr
Pointer to a GeomFactors object.
Definition: GeomFactors.h:62
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvp (scalar times vector plus vector): z = alpha*x + y
Definition: Vmath.cpp:488
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:445
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
Definition: Vmath.cpp:216
int m_spacedim
Spatial dimension (>= expansion dim).
double NekDouble
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
Geometry is curved or has non-constant factors.
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition: Vmath.cpp:186

◆ v_InitObject()

void Nektar::AcousticSystem::v_InitObject ( )
protectedvirtual

Initialization object for the AcousticSystem class.

Reimplemented from Nektar::SolverUtils::AdvectionSystem.

Reimplemented in Nektar::LEE, and Nektar::APE.

Definition at line 68 of file AcousticSystem.cpp.

References ASSERTL0, Nektar::MultiRegions::eDiscontinuous, Nektar::SolverUtils::GetCouplingFactory(), Nektar::SolverUtils::Forcing::Load(), m_bfNames, m_coupling, Nektar::SolverUtils::EquationSystem::m_fields, m_forcing, Nektar::SolverUtils::UnsteadySystem::m_homoInitialFwd, m_iu, Nektar::SolverUtils::EquationSystem::m_projectionType, Nektar::SolverUtils::EquationSystem::m_session, Nektar::SolverUtils::EquationSystem::m_spacedim, m_vecLocs, m_whiteNoiseBC_lastUpdate, m_whiteNoiseBC_p, and Nektar::SolverUtils::AdvectionSystem::v_InitObject().

Referenced by Nektar::APE::v_InitObject(), and Nektar::LEE::v_InitObject().

69 {
71 
72  ASSERTL0(
74  "Only Projection=DisContinuous supported by the AcousticSystem class.");
75 
76  m_bfNames.push_back("c0sq");
77  m_bfNames.push_back("rho0");
78  m_bfNames.push_back("u0");
79  m_bfNames.push_back("v0");
80  m_bfNames.push_back("w0");
81 
82  // Resize the advection velocities vector to dimension of the problem
83  m_bfNames.resize(m_spacedim + 2);
84 
85  m_forcing = SolverUtils::Forcing::Load(m_session, shared_from_this(),
86  m_fields, m_fields.num_elements());
87 
88  // Do not forwards transform initial condition
89  m_homoInitialFwd = false;
90 
91  // Set up locations of velocity and base velocity vectors.
92  m_vecLocs = Array<OneD, Array<OneD, NekDouble>>(1);
93  m_vecLocs[0] = Array<OneD, NekDouble>(m_spacedim);
94  for (int i = 0; i < m_spacedim; ++i)
95  {
96  // u', v', w'
97  m_vecLocs[0][i] = m_iu + i;
98  }
99 
100  if (m_session->DefinesElement("Nektar/Coupling"))
101  {
102  TiXmlElement *vCoupling = m_session->GetElement("Nektar/Coupling");
103 
104  ASSERTL0(vCoupling->Attribute("TYPE"),
105  "Missing TYPE attribute in Coupling");
106  string vType = vCoupling->Attribute("TYPE");
107  ASSERTL0(!vType.empty(),
108  "TYPE attribute must be non-empty in Coupling");
109 
110  m_coupling = GetCouplingFactory().CreateInstance(vType, m_fields[0]);
111  }
112 
114  m_whiteNoiseBC_p = 0.0;
115 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
std::vector< std::string > m_bfNames
bool m_homoInitialFwd
Flag to determine if simulation should start in homogeneous forward transformed state.
enum MultiRegions::ProjectionType m_projectionType
Type of projection; e.g continuous or discontinuous.
std::vector< SolverUtils::ForcingSharedPtr > m_forcing
static SOLVER_UTILS_EXPORT std::vector< ForcingSharedPtr > Load(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields=0)
Definition: Forcing.cpp:85
int m_spacedim
Spatial dimension (>= expansion dim).
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
SolverUtils::CouplingSharedPtr m_coupling
CouplingFactory & GetCouplingFactory()
Declaration of the Coupling factory singleton.
Definition: Coupling.cpp:44
virtual SOLVER_UTILS_EXPORT void v_InitObject()
Init object for UnsteadySystem class.
NekDouble m_whiteNoiseBC_lastUpdate
Array< OneD, Array< OneD, NekDouble > > m_vecLocs

◆ v_Output()

void Nektar::AcousticSystem::v_Output ( void  )
protectedvirtual

Write the field data to file. The file is named according to the session name with the extension .fld appended.

Reimplemented from Nektar::SolverUtils::EquationSystem.

Definition at line 173 of file AcousticSystem.cpp.

References m_coupling, and Nektar::SolverUtils::EquationSystem::v_Output().

174 {
175  if (m_coupling)
176  {
177  m_coupling->Finalize();
178  }
179 
181 }
virtual SOLVER_UTILS_EXPORT void v_Output(void)
SolverUtils::CouplingSharedPtr m_coupling

◆ v_PreIntegrate()

bool Nektar::AcousticSystem::v_PreIntegrate ( int  step)
protectedvirtual

v_PreIntegrate

Reimplemented from Nektar::SolverUtils::UnsteadySystem.

Definition at line 127 of file AcousticSystem.cpp.

References Nektar::SolverUtils::EquationSystem::GetFunction(), m_bf, m_bfNames, m_coupling, Nektar::SolverUtils::EquationSystem::m_fields, m_forcing, Nektar::SolverUtils::EquationSystem::m_session, Nektar::SolverUtils::EquationSystem::m_time, and Nektar::SolverUtils::UnsteadySystem::v_PreIntegrate().

128 {
129  GetFunction("Baseflow", m_fields[0], true)
130  ->Evaluate(m_bfNames, m_bf, m_time);
131 
132  if (m_coupling)
133  {
134  int numForceFields = 0;
135  for (auto &x : m_forcing)
136  {
137  numForceFields += x->GetForces().num_elements();
138  }
139  vector<string> varNames;
140  Array<OneD, Array<OneD, NekDouble>> phys(
141  m_fields.num_elements() + m_bfNames.size() + numForceFields);
142  for (int i = 0; i < m_fields.num_elements(); ++i)
143  {
144  varNames.push_back(m_session->GetVariable(i));
145  phys[i] = m_fields[i]->UpdatePhys();
146  }
147  for (int i = 0; i < m_bfNames.size(); ++i)
148  {
149  varNames.push_back(m_bfNames[i]);
150  phys[m_fields.num_elements() + i] = m_bf[i];
151  }
152 
153  int f = 0;
154  for (auto &x : m_forcing)
155  {
156  for (int i = 0; i < x->GetForces().num_elements(); ++i)
157  {
158  phys[m_fields.num_elements() + m_bfNames.size() + f + i] =
159  x->GetForces()[i];
160  varNames.push_back("F_" + boost::lexical_cast<string>(f) + "_" +
161  m_session->GetVariable(i));
162  }
163  f++;
164  }
165 
166  m_coupling->Send(step, m_time, phys, varNames);
167  m_coupling->Receive(step, m_time, phys, varNames);
168  }
169 
170  return AdvectionSystem::v_PreIntegrate(step);
171 }
Array< OneD, Array< OneD, NekDouble > > m_bf
virtual SOLVER_UTILS_EXPORT bool v_PreIntegrate(int step)
std::vector< std::string > m_bfNames
NekDouble m_time
Current time of simulation.
std::vector< SolverUtils::ForcingSharedPtr > m_forcing
SOLVER_UTILS_EXPORT SessionFunctionSharedPtr GetFunction(std::string name, const MultiRegions::ExpListSharedPtr &field=MultiRegions::NullExpListSharedPtr, bool cache=false)
Get a SessionFunction by name.
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
SolverUtils::CouplingSharedPtr m_coupling

◆ v_RiemannInvariantBC()

virtual void Nektar::AcousticSystem::v_RiemannInvariantBC ( int  bcRegion,
int  cnt,
Array< OneD, Array< OneD, NekDouble >> &  Fwd,
Array< OneD, Array< OneD, NekDouble >> &  BfFwd,
Array< OneD, Array< OneD, NekDouble >> &  physarray 
)
privatepure virtual

Implemented in Nektar::LEE, and Nektar::APE.

Referenced by SetBoundaryConditions().

◆ v_WallBC()

void Nektar::AcousticSystem::v_WallBC ( int  bcRegion,
int  cnt,
Array< OneD, Array< OneD, NekDouble >> &  Fwd,
Array< OneD, Array< OneD, NekDouble >> &  physarray 
)
privatevirtual

Wall boundary conditions for the AcousticSystem equations.

Definition at line 306 of file AcousticSystem.cpp.

References Nektar::SolverUtils::EquationSystem::m_fields, m_iu, Nektar::SolverUtils::EquationSystem::m_spacedim, Nektar::SolverUtils::EquationSystem::m_traceNormals, Vmath::Smul(), Vmath::Vcopy(), and Vmath::Vvtvp().

Referenced by SetBoundaryConditions().

309 {
310  int nVariables = physarray.num_elements();
311 
312  const Array<OneD, const int> &traceBndMap = m_fields[0]->GetTraceBndMap();
313 
314  // Adjust the physical values of the trace to take
315  // user defined boundaries into account
316  int id1, id2, nBCEdgePts;
317  int eMax = m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
318 
319  for (int e = 0; e < eMax; ++e)
320  {
321  nBCEdgePts = m_fields[0]
322  ->GetBndCondExpansions()[bcRegion]
323  ->GetExp(e)
324  ->GetTotPoints();
325  id1 = m_fields[0]->GetBndCondExpansions()[bcRegion]->GetPhys_Offset(e);
326  id2 = m_fields[0]->GetTrace()->GetPhys_Offset(traceBndMap[cnt + e]);
327 
328  // For 2D/3D, define: v* = v - 2(v.n)n
329  Array<OneD, NekDouble> tmp(nBCEdgePts, 0.0);
330 
331  // Calculate (v.n)
332  for (int i = 0; i < m_spacedim; ++i)
333  {
334  Vmath::Vvtvp(nBCEdgePts, &Fwd[m_iu + i][id2], 1,
335  &m_traceNormals[i][id2], 1, &tmp[0], 1, &tmp[0], 1);
336  }
337 
338  // Calculate 2.0(v.n)
339  Vmath::Smul(nBCEdgePts, -2.0, &tmp[0], 1, &tmp[0], 1);
340 
341  // Calculate v* = v - 2.0(v.n)n
342  for (int i = 0; i < m_spacedim; ++i)
343  {
344  Vmath::Vvtvp(nBCEdgePts, &tmp[0], 1, &m_traceNormals[i][id2], 1,
345  &Fwd[m_iu + i][id2], 1, &Fwd[m_iu + i][id2], 1);
346  }
347 
348  // Copy boundary adjusted values into the boundary expansion
349  for (int i = 0; i < nVariables; ++i)
350  {
351  Vmath::Vcopy(nBCEdgePts, &Fwd[i][id2], 1,
352  &(m_fields[i]
353  ->GetBndCondExpansions()[bcRegion]
354  ->UpdatePhys())[id1],
355  1);
356  }
357  }
358 }
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:445
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Array holding trace normals for DG simulations in the forwards direction.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
Definition: Vmath.cpp:216
int m_spacedim
Spatial dimension (>= expansion dim).
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064

◆ v_WhiteNoiseBC()

void Nektar::AcousticSystem::v_WhiteNoiseBC ( int  bcRegion,
int  cnt,
Array< OneD, Array< OneD, NekDouble >> &  Fwd,
Array< OneD, Array< OneD, NekDouble >> &  BfFwd,
Array< OneD, Array< OneD, NekDouble >> &  physarray 
)
privatevirtual

Wall boundary conditions for the AcousticSystem equations.

Definition at line 363 of file AcousticSystem.cpp.

References ASSERTL0, Nektar::SpatialDomains::eDirichlet, Nektar::LibUtilities::Equation::Evaluate(), Vmath::Fill(), Nektar::NekConstants::kNekZeroTol, m_conservative, Nektar::SolverUtils::EquationSystem::m_fields, m_ip, m_irho, m_iu, m_rng, Nektar::SolverUtils::EquationSystem::m_spacedim, Nektar::SolverUtils::EquationSystem::m_time, Nektar::SolverUtils::EquationSystem::m_traceNormals, m_whiteNoiseBC_lastUpdate, m_whiteNoiseBC_p, and Vmath::Vcopy().

Referenced by SetBoundaryConditions().

367 {
368  boost::ignore_unused(Fwd);
369 
370  int id1, id2, nBCEdgePts;
371  int nVariables = physarray.num_elements();
372 
373  const Array<OneD, const int> &traceBndMap = m_fields[0]->GetTraceBndMap();
374 
375  if (m_rng.count(bcRegion) == 0)
376  {
377  m_rng[bcRegion] = boost::mt19937(bcRegion);
378  }
379 
380  ASSERTL0(
381  m_fields[0]->GetBndConditions()[bcRegion]->GetBoundaryConditionType() ==
383  "WhiteNoise BCs must be Dirichlet type BCs");
384 
385  LibUtilities::Equation cond =
386  std::static_pointer_cast<SpatialDomains::DirichletBoundaryCondition>(
387  m_fields[0]->GetBndConditions()[bcRegion])
388  ->m_dirichletCondition;
389  NekDouble sigma = cond.Evaluate();
390 
392  "sigma must be greater than zero");
393 
394  // random velocity perturbation
396  {
398 
399  boost::normal_distribution<> dist(0, sigma);
400  m_whiteNoiseBC_p = dist(m_rng[bcRegion]);
401  }
402 
403  int eMax = m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
404  for (int e = 0; e < eMax; ++e)
405  {
406  nBCEdgePts = m_fields[0]
407  ->GetBndCondExpansions()[bcRegion]
408  ->GetExp(e)
409  ->GetTotPoints();
410  id1 = m_fields[0]->GetBndCondExpansions()[bcRegion]->GetPhys_Offset(e);
411  id2 = m_fields[0]->GetTrace()->GetPhys_Offset(traceBndMap[cnt + e]);
412 
413  Array<OneD, Array<OneD, NekDouble>> tmp(nVariables);
414  for (int i = 0; i < nVariables; ++i)
415  {
416  tmp[i] = Array<OneD, NekDouble>(nBCEdgePts, 0.0);
417  }
418 
419  // pressure perturbation
420  Vmath::Fill(nBCEdgePts, m_whiteNoiseBC_p, &tmp[m_ip][0], 1);
421 
422  if (m_conservative)
423  {
424  for (int i = 0; i < nBCEdgePts; ++i)
425  {
426  // density perturbation
427  tmp[m_irho][i] = m_whiteNoiseBC_p *
428  BfFwd[m_spacedim + 2][id2 + i] /
429  BfFwd[0][id2 + i];
430 
431  // velocity perturbation
432  NekDouble ru = m_whiteNoiseBC_p / sqrt(BfFwd[0][id2 + i]);
433  for (int j = 0; j < m_spacedim; ++j)
434  {
435  tmp[m_iu + j][i] = -1.0 * ru * m_traceNormals[j][id2 + i];
436  }
437  }
438  }
439  else
440  {
441  for (int i = 0; i < nBCEdgePts; ++i)
442  {
443  // velocity perturbation
445  (sqrt(BfFwd[0][id2 + i]) * BfFwd[1][id2 + i]);
446 
447  for (int j = 0; j < m_spacedim; ++j)
448  {
449  tmp[m_iu + j][i] = -1.0 * u * m_traceNormals[j][id2 + i];
450  }
451  }
452  }
453 
454  // Copy boundary adjusted values into the boundary expansion
455  for (int i = 0; i < nVariables; ++i)
456  {
457  Vmath::Vcopy(nBCEdgePts, &tmp[i][0], 1,
458  &(m_fields[i]
459  ->GetBndCondExpansions()[bcRegion]
460  ->UpdatePhys())[id1],
461  1);
462  }
463  }
464 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
NekDouble m_time
Current time of simulation.
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.cpp:45
bool m_conservative
we are dealing with a conservative formualtion
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Array holding trace normals for DG simulations in the forwards direction.
static const NekDouble kNekZeroTol
int m_spacedim
Spatial dimension (>= expansion dim).
double NekDouble
int m_ip
indices of the fields
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
std::map< int, boost::mt19937 > m_rng
NekDouble m_whiteNoiseBC_lastUpdate
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064

Friends And Related Function Documentation

◆ MemoryManager< AcousticSystem >

friend class MemoryManager< AcousticSystem >
friend

Definition at line 63 of file AcousticSystem.h.

Member Data Documentation

◆ m_advection

SolverUtils::AdvectionSharedPtr Nektar::AcousticSystem::m_advection
protected

Definition at line 74 of file AcousticSystem.h.

Referenced by DoOdeRhs(), Nektar::APE::v_InitObject(), and Nektar::LEE::v_InitObject().

◆ m_bf

Array<OneD, Array<OneD, NekDouble> > Nektar::AcousticSystem::m_bf
protected

◆ m_bfFwdBwd

Array<OneD, Array<OneD, NekDouble> > Nektar::AcousticSystem::m_bfFwdBwd
protected

◆ m_bfNames

std::vector<std::string> Nektar::AcousticSystem::m_bfNames
protected

◆ m_conservative

bool Nektar::AcousticSystem::m_conservative
protected

we are dealing with a conservative formualtion

Definition at line 72 of file AcousticSystem.h.

Referenced by Nektar::APE::APE(), Nektar::LEE::LEE(), and v_WhiteNoiseBC().

◆ m_coupling

SolverUtils::CouplingSharedPtr Nektar::AcousticSystem::m_coupling
protected

Definition at line 73 of file AcousticSystem.h.

Referenced by v_InitObject(), v_Output(), and v_PreIntegrate().

◆ m_forcing

std::vector<SolverUtils::ForcingSharedPtr> Nektar::AcousticSystem::m_forcing
protected

Definition at line 75 of file AcousticSystem.h.

Referenced by DoOdeRhs(), v_ExtraFldOutput(), v_InitObject(), and v_PreIntegrate().

◆ m_ip

int Nektar::AcousticSystem::m_ip
protected

◆ m_irho

int Nektar::AcousticSystem::m_irho
protected

◆ m_iu

int Nektar::AcousticSystem::m_iu
protected

◆ m_riemannSolver

SolverUtils::RiemannSolverSharedPtr Nektar::AcousticSystem::m_riemannSolver
protected

Definition at line 76 of file AcousticSystem.h.

Referenced by Nektar::APE::v_InitObject(), and Nektar::LEE::v_InitObject().

◆ m_rng

std::map<int, boost::mt19937> Nektar::AcousticSystem::m_rng
private

Definition at line 124 of file AcousticSystem.h.

Referenced by v_WhiteNoiseBC().

◆ m_vecLocs

Array<OneD, Array<OneD, NekDouble> > Nektar::AcousticSystem::m_vecLocs
protected

Definition at line 78 of file AcousticSystem.h.

Referenced by GetVecLocs(), and v_InitObject().

◆ m_whiteNoiseBC_lastUpdate

NekDouble Nektar::AcousticSystem::m_whiteNoiseBC_lastUpdate
private

Definition at line 125 of file AcousticSystem.h.

Referenced by v_InitObject(), and v_WhiteNoiseBC().

◆ m_whiteNoiseBC_p

NekDouble Nektar::AcousticSystem::m_whiteNoiseBC_p
private

Definition at line 126 of file AcousticSystem.h.

Referenced by v_InitObject(), and v_WhiteNoiseBC().