35 #ifndef NEKTAR_SOLVERUTILS_EQUATIONSYSTEM_H 36 #define NEKTAR_SOLVERUTILS_EQUATIONSYSTEM_H 54 namespace FieldUtils {
74 class EquationSystem :
public std::enable_shared_from_this<EquationSystem>
108 return m_sessionName;
112 std::shared_ptr<T>
as()
114 return std::dynamic_pointer_cast<T>( shared_from_this() );
120 m_sessionName = newname;
134 std::vector<std::string> &variables);
151 bool dumpInitialConditions =
true,
152 const int domain = 0);
165 bool Normalised =
false);
170 bool Normalised =
false)
188 std::vector<std::string> &variables);
198 const std::string &outname,
201 std::vector<std::string> &variables);
205 const std::string &infile,
210 const std::string &infile,
217 const std::string &infile,
218 std::vector<std::string> &fieldStr,
224 const std::string &infile,
226 std::string &pFieldName);
237 &UpdateFieldMetaDataMap();
249 GetNumExpModesPerExp();
254 GetVariable(
unsigned int i);
289 const bool modbasis);
320 m_initialStep = step;
421 const LibUtilities::SessionReaderSharedPtr& pSession,
442 bool Normalised =
false);
455 bool dumpInitialConditions =
true,
456 const int domain = 0);
471 std::vector<std::string> &variables);
473 static std::string equationSystemTypeLookupIds[];
480 const int goal)
const 517 v_TransCoeffToPhys();
527 v_TransPhysToCoeff();
556 return v_LinfError(field, exactsoln);
565 return v_L2Error(field, exactsoln, Normalised);
573 return v_GetPressure();
585 std::vector<std::string> &variables)
587 v_ExtraFldOutput(fieldcoeffs, variables);
599 if (m_session->GetComm()->GetRank() == 0)
601 std::vector<std::pair<std::string, std::string> > vSummary;
602 v_GenerateSummary(vSummary);
604 out <<
"=======================================================================" << std::endl;
605 for (
auto &x : vSummary)
609 out << x.first <<
": " << x.second << std::endl;
611 out <<
"=======================================================================" << std::endl;
621 bool dumpInitialConditions,
624 v_SetInitialConditions(initialtime,dumpInitialConditions,domain);
632 v_EvaluateExactSolution(field, outfield, time);
648 return m_fields[0]->GetNcoeffs();
653 return m_fields[0]->GetNcoeffs(eid);
658 return m_graph->GetExpansions().begin()->second->m_basisKeyVector[0]
664 return m_fields[0]->EvalBasisNumModesMaxPerExp();
669 return m_session->GetVariables().size();
674 return m_session->GetVariable(i);
679 return GetTraceNpoints();
684 return m_fields[0]->GetTrace()->GetNpoints();
689 return m_fields[0]->GetExpSize();
694 return m_fields[0]->GetPhys_Offset(n);
699 return m_fields[0]->GetCoeff_Offset(n);
704 return m_fields[0]->GetNpoints();
709 return m_fields[0]->GetTotPoints(n);
714 return m_fields[0]->GetNpoints();
735 Vmath::Vcopy(output.num_elements(), m_fields[i]->GetPhys(), 1, output, 1 );
741 Vmath::Vcopy(output.num_elements(), output, 1, m_fields[i]->UpdatePhys(), 1 );
bool m_singleMode
Flag to determine if single homogeneous mode is used.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
int PrintProgressbar(const int position, const int goal, const std::string message, int lastprogress=-1)
Prints a progressbar.
A base class for describing how to solve specific equations.
static ExpListSharedPtr NullExpListSharedPtr
static Array< OneD, NekDouble > NullNekDouble1DArray
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.
NekDouble m_time
Current time of simulation.
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
NekDouble m_timestep
Time step size.
SOLVER_UTILS_EXPORT void SetSteps(const int steps)
std::vector< std::pair< std::string, std::string > > SummaryList
NekDouble m_lambda
Lambda constant in real system if one required.
SOLVER_UTILS_EXPORT int GetNvariables()
bool m_halfMode
Flag to determine if half homogeneous mode is used.
NekDouble m_LhomZ
physical length in Z direction (if homogeneous)
std::shared_ptr< BoundaryConditions > BoundaryConditionsSharedPtr
SOLVER_UTILS_EXPORT const Array< OneD, int > GetNumExpModesPerExp()
Array< OneD, bool > m_checkIfSystemSingular
Flag to indicate if the fields should be checked for singularity.
int m_expdim
Expansion dimension.
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
NekDouble m_LhomX
physical length in X direction (if homogeneous)
SOLVER_UTILS_EXPORT Array< OneD, MultiRegions::ExpListSharedPtr > & UpdateFields()
ProjectionType
Type of Galerkin projection.
NekDouble m_checktime
Time between checkpoints.
bool m_useFFT
Flag to determine if FFT is used for homogeneous transform.
NekDouble m_LhomY
physical length in Y direction (if homogeneous)
bool m_specHP_dealiasing
Flag to determine if dealisising is usde for the Spectral/hp element discretisation.
SOLVER_UTILS_EXPORT int GetNumExpModes()
SOLVER_UTILS_EXPORT void TransCoeffToPhys()
Transform from coefficient to physical space.
SOLVER_UTILS_EXPORT void InitObject()
Initialises the members of this object.
int m_npointsZ
number of points in Z direction (if homogeneous)
std::string m_sessionName
Name of the session.
int m_nchk
Number of checkpoints written so far.
std::map< std::string, std::string > FieldMetaDataMap
int m_checksteps
Number of steps between checkpoints.
SOLVER_UTILS_EXPORT int GetCoeff_Offset(int n)
LibUtilities::CommSharedPtr m_comm
Communicator.
SOLVER_UTILS_EXPORT void ResetSessionName(std::string newname)
Reset Session name.
SOLVER_UTILS_EXPORT int GetTotPoints()
SOLVER_UTILS_EXPORT const std::string GetVariable(unsigned int i)
SOLVER_UTILS_EXPORT void PrintProgressbar(const int position, const int goal) const
SOLVER_UTILS_EXPORT void Output()
Perform output operations after solve.
NekDouble m_fintime
Finish time of the simulation.
SOLVER_UTILS_EXPORT void CopyToPhysField(const int i, Array< OneD, NekDouble > &output)
int m_steps
Number of steps to take.
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Array holding trace normals for DG simulations in the forwards direction.
int m_HomoDirec
number of homogenous directions
SOLVER_UTILS_EXPORT int GetSteps()
SOLVER_UTILS_EXPORT int GetCheckpointSteps()
bool m_multipleModes
Flag to determine if use multiple homogenenous modes are used.
SOLVER_UTILS_EXPORT void TransPhysToCoeff()
Transform from physical to coefficient space.
SOLVER_UTILS_EXPORT void CopyFromPhysField(const int i, Array< OneD, NekDouble > &output)
SOLVER_UTILS_EXPORT void SetCheckpointSteps(int num)
int m_npointsY
number of points in Y direction (if homogeneous)
std::map< std::string, SolverUtils::SessionFunctionSharedPtr > m_sessionFunctions
Map of known SessionFunctions.
std::shared_ptr< T > as()
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...
SpatialDomains::BoundaryConditionsSharedPtr m_boundaryConditions
Pointer to boundary conditions object.
int m_spacedim
Spatial dimension (>= expansion dim).
SOLVER_UTILS_EXPORT NekDouble L2Error(unsigned int field, bool Normalised=false)
Compute the L2 error of the fields.
LibUtilities::FieldMetaDataMap m_fieldMetaDataMap
Map to identify relevant solver info to dump in output fields.
SOLVER_UTILS_EXPORT void DoInitialise()
Perform any initialisation necessary before solving the problem.
SOLVER_UTILS_EXPORT LibUtilities::SessionReaderSharedPtr GetSession()
Get Session name.
SOLVER_UTILS_EXPORT NekDouble GetTimeStep()
bool m_homogen_dealiasing
Flag to determine if dealiasing is used for homogeneous simulations.
SOLVER_UTILS_EXPORT std::string GetSessionName()
Get Session name.
EquationSystemFactory & GetEquationSystemFactory()
int m_npointsX
number of points in X direction (if homogeneous)
SOLVER_UTILS_EXPORT int GetTraceTotPoints()
SOLVER_UTILS_EXPORT int GetPhys_Offset(int n)
SOLVER_UTILS_EXPORT NekDouble GetFinalTime()
Return final time.
SOLVER_UTILS_EXPORT void PrintSummary(std::ostream &out)
Print a summary of parameters and solver characteristics.
SOLVER_UTILS_EXPORT int GetNpoints()
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
SOLVER_UTILS_EXPORT int GetExpSize()
#define SOLVER_UTILS_EXPORT
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
SOLVER_UTILS_EXPORT NekDouble LinfError(unsigned int field, const Array< OneD, NekDouble > &exactsoln=NullNekDouble1DArray)
Linf error computation.
SOLVER_UTILS_EXPORT int GetTraceNpoints()
SOLVER_UTILS_EXPORT int GetNcoeffs()
LibUtilities::FieldIOSharedPtr m_fld
Field input/output.
HomogeneousType
Parameter for homogeneous expansions.
int m_initialStep
Number of the step where the simulation should begin.
SOLVER_UTILS_EXPORT MultiRegions::ExpListSharedPtr GetPressure()
Get pressure field if available.
SOLVER_UTILS_EXPORT void EvaluateExactSolution(int field, Array< OneD, NekDouble > &outfield, const NekDouble time)
Evaluates an exact solution.
SOLVER_UTILS_EXPORT void SetTime(const NekDouble time)
SpatialDomains::MeshGraphSharedPtr m_graph
Pointer to graph defining mesh.
SOLVER_UTILS_EXPORT void ExtraFldOutput(std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables)
SOLVER_UTILS_EXPORT void SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
Initialise the data in the dependent fields.
std::shared_ptr< SessionFunction > SessionFunctionSharedPtr
int m_NumQuadPointsError
Number of Quadrature points used to work out the error.
std::shared_ptr< FieldIO > FieldIOSharedPtr
SOLVER_UTILS_EXPORT void DoSolve()
Solve the problem.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
SOLVER_UTILS_EXPORT void SetInitialStep(const int step)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
SOLVER_UTILS_EXPORT void SetLambda(NekDouble lambda)
Set parameter m_lambda.
SOLVER_UTILS_EXPORT void SetCheckpointNumber(int num)
std::shared_ptr< EquationSystem > EquationSystemSharedPtr
A shared pointer to an EquationSystem object.
SOLVER_UTILS_EXPORT int GetCheckpointNumber()
Provides a generic Factory class.