35#ifndef NEKTAR_SOLVERUTILS_EQUATIONSYSTEM_H
36#define NEKTAR_SOLVERUTILS_EQUATIONSYSTEM_H
51#include <boost/numeric/ublas/matrix.hpp>
57template <
typename T>
class Interpolator;
86 bool dumpInitialConditions =
true);
106 template <
class T> std::shared_ptr<T>
as()
108 return std::dynamic_pointer_cast<T>(shared_from_this());
128 std::vector<std::string> &variables);
145 NekDouble initialtime = 0.0,
bool dumpInitialConditions =
true,
146 const int domain = 0);
156 bool Normalised =
false);
160 bool Normalised =
false)
182 std::vector<std::string> &variables);
194 std::vector<std::string> &variables);
198 const std::string &infile,
203 const std::string &infile,
210 const std::string &infile, std::vector<std::string> &fieldStr,
217 std::string &pFieldName);
354 std::map<std::string, SolverUtils::SessionFunctionSharedPtr>
469 bool dumpInitialConditions =
true);
485 bool Normalised =
false);
497 NekDouble initialtime = 0.0,
bool dumpInitialConditions =
true,
498 const int domain = 0);
516 std::vector<std::string> &variables);
525 const int goal)
const
628 std::vector<std::string> &variables)
642 if (
m_session->GetComm()->GetRank() == 0)
644 std::vector<std::pair<std::string, std::string>> vSummary;
647 out <<
"==============================================================="
651 for (
auto &x : vSummary)
655 out << x.first <<
": " << x.second << std::endl << std::flush;
657 out <<
"==============================================================="
670 bool dumpInitialConditions,
708 return m_fields[0]->GetNcoeffs(eid);
713 return m_graph->GetExpansionInfo()
715 ->second->m_basisKeyVector[0]
721 return m_fields[0]->EvalBasisNumModesMaxPerExp();
741 return m_fields[0]->GetTrace()->GetNpoints();
751 return m_fields[0]->GetPhys_Offset(n);
756 return m_fields[0]->GetCoeff_Offset(n);
766 return m_fields[0]->GetTotPoints(n);
#define SOLVER_UTILS_EXPORT
Provides a generic Factory class.
A base class for describing how to solve specific equations.
SOLVER_UTILS_EXPORT void ResetSessionName(std::string newname)
Reset Session name.
SOLVER_UTILS_EXPORT Array< OneD, MultiRegions::ExpListSharedPtr > & UpdateFields()
SOLVER_UTILS_EXPORT int GetSteps()
int m_spacedim
Spatial dimension (>= expansion dim).
SOLVER_UTILS_EXPORT void SetInitialStep(const int step)
SOLVER_UTILS_EXPORT int GetTraceNpoints()
SOLVER_UTILS_EXPORT void ExtraFldOutput(std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables)
bool m_useFFT
Flag to determine if FFT is used for homogeneous transform.
SOLVER_UTILS_EXPORT int GetNvariables()
SOLVER_UTILS_EXPORT int GetCheckpointSteps()
int m_expdim
Expansion dimension.
LibUtilities::FieldIOSharedPtr m_fld
Field input/output.
SOLVER_UTILS_EXPORT void SessionSummary(SummaryList &vSummary)
Write out a session summary.
virtual SOLVER_UTILS_EXPORT void v_SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
virtual SOLVER_UTILS_EXPORT ~EquationSystem()
Destructor.
SOLVER_UTILS_EXPORT void SetSteps(const int steps)
SOLVER_UTILS_EXPORT void TransCoeffToPhys()
Transform from coefficient to physical space.
SpatialDomains::MeshGraphSharedPtr m_graph
Pointer to graph defining mesh.
int m_npointsX
number of points in X direction (if homogeneous)
LibUtilities::CommSharedPtr m_comm
Communicator.
NekDouble m_timestep
Time step size.
int m_infosteps
Number of time steps between outputting status information.
SOLVER_UTILS_EXPORT void ImportFld(const std::string &infile, Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
Input field data from the given file.
NekDouble m_time
Current time of simulation.
SOLVER_UTILS_EXPORT bool NegatedOp()
Identify if operator is negated in DoSolve.
SOLVER_UTILS_EXPORT int GetTraceTotPoints()
SOLVER_UTILS_EXPORT void SetWindowNumberPIT(int num)
int m_iterPIT
Number of parallel-in-time time iteration.
bool m_multipleModes
Flag to determine if use multiple homogenenous modes are used.
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
int m_windowPIT
Index of windows for parallel-in-time time iteration.
SOLVER_UTILS_EXPORT NekDouble LinfError(unsigned int field, const Array< OneD, NekDouble > &exactsoln=NullNekDouble1DArray)
Linf error computation.
SOLVER_UTILS_EXPORT const std::string GetVariable(unsigned int i)
NekDouble m_LhomX
physical length in X direction (if homogeneous)
SOLVER_UTILS_EXPORT void DoSolve()
Solve the problem.
virtual SOLVER_UTILS_EXPORT void v_TransPhysToCoeff()
Virtual function for transformation to coefficient space.
std::vector< std::string > m_strFrameData
variable name in m_movingFrameData
SOLVER_UTILS_EXPORT NekDouble L2Error(unsigned int field, bool Normalised=false)
Compute the L2 error of the fields.
virtual SOLVER_UTILS_EXPORT bool v_NegatedOp(void)
Virtual function to identify if operator is negated in DoSolve.
SOLVER_UTILS_EXPORT void EvaluateExactSolution(int field, Array< OneD, NekDouble > &outfield, const NekDouble time)
Evaluates an exact solution.
NekDouble m_fintime
Finish time of the simulation.
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.
virtual SOLVER_UTILS_EXPORT MultiRegions::ExpListSharedPtr v_GetPressure(void)
NekDouble m_lambda
Lambda constant in real system if one required.
static std::string projectionTypeLookupIds[]
NekDouble m_lastCheckTime
SOLVER_UTILS_EXPORT Array< OneD, NekDouble > & UpdatePhysField(const int i)
SOLVER_UTILS_EXPORT void SetCheckpointNumber(int num)
int m_npointsZ
number of points in Z direction (if homogeneous)
SOLVER_UTILS_EXPORT void Checkpoint_Output(const int n)
Write checkpoint file of m_fields.
virtual SOLVER_UTILS_EXPORT void v_ExtraFldOutput(std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables)
std::map< std::string, SolverUtils::SessionFunctionSharedPtr > m_sessionFunctions
Map of known SessionFunctions.
NekDouble m_checktime
Time between checkpoints.
SOLVER_UTILS_EXPORT NekDouble GetTimeStep()
SOLVER_UTILS_EXPORT void TransPhysToCoeff()
Transform from physical to coefficient space.
virtual SOLVER_UTILS_EXPORT void v_InitObject(bool DeclareFeld=true)
Initialisation object for EquationSystem.
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.
SOLVER_UTILS_EXPORT int GetCoeff_Offset(int n)
std::shared_ptr< T > as()
SOLVER_UTILS_EXPORT void Output()
Perform output operations after solve.
SOLVER_UTILS_EXPORT const Array< OneD, int > GetNumExpModesPerExp()
static std::string equationSystemTypeLookupIds[]
SOLVER_UTILS_EXPORT int GetInfoSteps()
virtual SOLVER_UTILS_EXPORT void v_EvaluateExactSolution(unsigned int field, Array< OneD, NekDouble > &outfield, const NekDouble time)
virtual SOLVER_UTILS_EXPORT void v_DoInitialise(bool dumpInitialConditions=true)
Virtual function for initialisation implementation.
SOLVER_UTILS_EXPORT void WriteFld(const std::string &outname)
Write field data to the given filename.
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.
SOLVER_UTILS_EXPORT int GetExpSize()
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.
SOLVER_UTILS_EXPORT LibUtilities::FieldMetaDataMap & UpdateFieldMetaDataMap()
Get hold of FieldInfoMap so it can be updated.
NekDouble m_LhomY
physical length in Y direction (if homogeneous)
int m_npointsY
number of points in Y direction (if homogeneous)
SOLVER_UTILS_EXPORT void SetModifiedBasis(const bool modbasis)
std::string m_sessionName
Name of the session.
SOLVER_UTILS_EXPORT void Checkpoint_BaseFlow(const int n)
Write base flow file of m_fields.
bool m_specHP_dealiasing
Flag to determine if dealisising is usde for the Spectral/hp element discretisation.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
SOLVER_UTILS_EXPORT Array< OneD, const Array< OneD, NekDouble > > GetTraceNormals()
bool m_singleMode
Flag to determine if single homogeneous mode is used.
SOLVER_UTILS_EXPORT void SetIterationNumberPIT(int num)
HomogeneousType
Parameter for homogeneous expansions.
SOLVER_UTILS_EXPORT void ZeroPhysFields()
int m_HomoDirec
number of homogenous directions
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Array holding trace normals for DG simulations in the forwards direction.
SOLVER_UTILS_EXPORT void SetCheckpointSteps(int num)
int m_initialStep
Number of the step where the simulation should begin.
SOLVER_UTILS_EXPORT void DoInitialise(bool dumpInitialConditions=true)
Perform any initialisation necessary before solving the problem.
enum HomogeneousType m_HomogeneousType
SOLVER_UTILS_EXPORT Array< OneD, NekDouble > ErrorExtraPoints(unsigned int field)
Compute error (L2 and L_inf) over an larger set of quadrature points return [L2 Linf].
SOLVER_UTILS_EXPORT std::string GetSessionName()
Get Session name.
SOLVER_UTILS_EXPORT int GetNpoints()
Array< OneD, bool > m_checkIfSystemSingular
Flag to indicate if the fields should be checked for singularity.
bool m_homogen_dealiasing
Flag to determine if dealiasing is used for homogeneous simulations.
SOLVER_UTILS_EXPORT void SetTimeStep(const NekDouble timestep)
SOLVER_UTILS_EXPORT int GetNcoeffs()
int m_nchk
Number of checkpoints written so far.
SOLVER_UTILS_EXPORT LibUtilities::SessionReaderSharedPtr GetSession()
Get Session name.
SOLVER_UTILS_EXPORT void SetInfoSteps(int num)
enum MultiRegions::ProjectionType m_projectionType
Type of projection; e.g continuous or discontinuous.
NekDouble m_TimeIncrementFactor
SOLVER_UTILS_EXPORT void CopyFromPhysField(const int i, Array< OneD, NekDouble > &output)
virtual SOLVER_UTILS_EXPORT void v_DoSolve()
Virtual function for solve implementation.
SOLVER_UTILS_EXPORT MultiRegions::ExpListSharedPtr GetPressure()
Get pressure field if available.
SOLVER_UTILS_EXPORT int GetPhys_Offset(int n)
virtual SOLVER_UTILS_EXPORT Array< OneD, bool > v_GetSystemSingularChecks()
SOLVER_UTILS_EXPORT void SetLambda(NekDouble lambda)
Set parameter m_lambda.
int m_steps
Number of steps to take.
int m_NumQuadPointsError
Number of Quadrature points used to work out the error.
SOLVER_UTILS_EXPORT void PrintProgressbar(const int position, const int goal) const
SOLVER_UTILS_EXPORT EquationSystem(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Initialises EquationSystem class members.
LibUtilities::FieldMetaDataMap m_fieldMetaDataMap
Map to identify relevant solver info to dump in output fields.
SOLVER_UTILS_EXPORT int GetNumExpModes()
SpatialDomains::BoundaryConditionsSharedPtr m_boundaryConditions
Pointer to boundary conditions object.
Array< OneD, NekDouble > m_movingFrameData
Moving reference frame status in the inertial frame X, Y, Z, Theta_x, Theta_y, Theta_z,...
SOLVER_UTILS_EXPORT void SetBoundaryConditions(NekDouble time)
Evaluates the boundary conditions at the given time.
NekDouble m_LhomZ
physical length in Z direction (if homogeneous)
virtual SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &l)
Virtual function for generating summary information.
bool m_halfMode
Flag to determine if half homogeneous mode is used.
SOLVER_UTILS_EXPORT void FwdTransFields()
int m_checksteps
Number of steps between checkpoints.
SOLVER_UTILS_EXPORT void SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
Initialise the data in the dependent fields.
SOLVER_UTILS_EXPORT void InitObject(bool DeclareField=true)
Initialises the members of this object.
SOLVER_UTILS_EXPORT void CopyToPhysField(const int i, const Array< OneD, const NekDouble > &input)
SOLVER_UTILS_EXPORT int GetCheckpointNumber()
SOLVER_UTILS_EXPORT SessionFunctionSharedPtr GetFunction(std::string name, const MultiRegions::ExpListSharedPtr &field=MultiRegions::NullExpListSharedPtr, bool cache=false)
Get a SessionFunction by name.
SOLVER_UTILS_EXPORT int GetTotPoints()
virtual SOLVER_UTILS_EXPORT void v_Output(void)
SOLVER_UTILS_EXPORT void SetTime(const NekDouble time)
SOLVER_UTILS_EXPORT NekDouble GetTime()
Return final time.
virtual SOLVER_UTILS_EXPORT void v_TransCoeffToPhys()
Virtual function for transformation to physical space.
SOLVER_UTILS_EXPORT void PrintSummary(std::ostream &out)
Print a summary of parameters and solver characteristics.
std::shared_ptr< FieldIO > FieldIOSharedPtr
std::map< std::string, std::string > FieldMetaDataMap
int PrintProgressbar(const int position, const int goal, const std::string message, int lastprogress=-1)
Prints a progressbar.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
ProjectionType
Type of Galerkin projection.
static ExpListSharedPtr NullExpListSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
LibUtilities::NekFactory< std::string, EquationSystem, const LibUtilities::SessionReaderSharedPtr &, const SpatialDomains::MeshGraphSharedPtr & > EquationSystemFactory
Datatype of the NekFactory used to instantiate classes derived from the EquationSystem class.
std::vector< std::pair< std::string, std::string > > SummaryList
std::shared_ptr< EquationSystem > EquationSystemSharedPtr
A shared pointer to an EquationSystem object.
EquationSystemFactory & GetEquationSystemFactory()
std::shared_ptr< SessionFunction > SessionFunctionSharedPtr
std::shared_ptr< BoundaryConditions > BoundaryConditionsSharedPtr
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
static Array< OneD, NekDouble > NullNekDouble1DArray
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)