Nektar++
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
Nektar::SolverUtils::UnsteadySystem Class Reference

Base class for unsteady solvers. More...

#include <UnsteadySystem.h>

Inheritance diagram for Nektar::SolverUtils::UnsteadySystem:
[legend]

Public Member Functions

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...
 

Public Attributes

NekDouble m_cflSafetyFactor
 CFL safety factor (comprise between 0 to 1). More...
 

Protected Member Functions

SOLVER_UTILS_EXPORT UnsteadySystem (const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
 Initialises UnsteadySystem class members. More...
 
virtual SOLVER_UTILS_EXPORT void v_InitObject ()
 Init object for UnsteadySystem class. 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_PreIntegrate (int step)
 
virtual SOLVER_UTILS_EXPORT bool v_PostIntegrate (int step)
 
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 void v_Output (void)
 
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_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

void InitializeSteadyState ()
 
bool CheckSteadyState (int step)
 Calculate whether the system has reached a steady state by observing residuals to a user-defined tolerance. More...
 

Additional Inherited Members

- 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

Base class for unsteady solvers.

Provides the underlying timestepping framework for unsteady solvers including the general timestepping routines. This class is not intended to be directly instantiated, but rather is a base class on which to define unsteady solvers.

For details on implementing unsteady solvers see sectionADRSolverModuleImplementation here

Definition at line 47 of file UnsteadySystem.h.

Constructor & Destructor Documentation

◆ ~UnsteadySystem()

Nektar::SolverUtils::UnsteadySystem::~UnsteadySystem ( )
virtual

Destructor.

Destructor for the class UnsteadyAdvection.

Definition at line 153 of file UnsteadySystem.cpp.

154  {
155  }

◆ UnsteadySystem()

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

Initialises UnsteadySystem class members.

Processes SolverInfo parameters from the session file and sets up timestepping-specific code.

Parameters
pSessionSession object to read parameters from.

Definition at line 68 of file UnsteadySystem.cpp.

71  : EquationSystem(pSession, pGraph),
72  m_infosteps(10)
73 
74  {
75  }
SOLVER_UTILS_EXPORT EquationSystem(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Initialises EquationSystem class members.
int m_infosteps
Number of time steps between outputting status information.

Member Function Documentation

◆ CheckForRestartTime()

void Nektar::SolverUtils::UnsteadySystem::CheckForRestartTime ( NekDouble time,
int &  nchk 
)
protected

Definition at line 604 of file UnsteadySystem.cpp.

References Nektar::LibUtilities::FieldIO::CreateForFile(), Nektar::LibUtilities::eFunctionTypeFile, Nektar::SolverUtils::EquationSystem::m_fieldMetaDataMap, Nektar::SolverUtils::EquationSystem::m_fields, Nektar::SolverUtils::EquationSystem::m_session, Nektar::LibUtilities::NullFieldMetaDataMap, and Nektar::LibUtilities::PortablePath().

Referenced by v_DoInitialise(), and v_RequireFwdTrans().

605  {
606  if (m_session->DefinesFunction("InitialConditions"))
607  {
608  for (int i = 0; i < m_fields.num_elements(); ++i)
609  {
611 
612  vType = m_session->GetFunctionType(
613  "InitialConditions", m_session->GetVariable(i));
614 
615  if (vType == LibUtilities::eFunctionTypeFile)
616  {
617  std::string filename
618  = m_session->GetFunctionFilename(
619  "InitialConditions", m_session->GetVariable(i));
620 
621  fs::path pfilename(filename);
622 
623  // redefine path for parallel file which is in directory
624  if(fs::is_directory(pfilename))
625  {
626  fs::path metafile("Info.xml");
627  fs::path fullpath = pfilename / metafile;
628  filename = LibUtilities::PortablePath(fullpath);
629  }
632  m_session, filename);
633  fld->ImportFieldMetaData(filename, m_fieldMetaDataMap);
634 
635  // check to see if time defined
636  if (m_fieldMetaDataMap !=
638  {
639  auto iter = m_fieldMetaDataMap.find("Time");
640  if (iter != m_fieldMetaDataMap.end())
641  {
642  time = boost::lexical_cast<NekDouble>(
643  iter->second);
644  }
645 
646  iter = m_fieldMetaDataMap.find("ChkFileNum");
647  if (iter != m_fieldMetaDataMap.end())
648  {
649  nchk = boost::lexical_cast<NekDouble>(
650  iter->second);
651  }
652  }
653 
654  break;
655  }
656  }
657  }
658  }
LibUtilities::FieldMetaDataMap m_fieldMetaDataMap
Map to identify relevant solver info to dump in output fields.
std::string PortablePath(const boost::filesystem::path &path)
create portable path on different platforms for boost::filesystem path
Definition: FileSystem.cpp:41
double NekDouble
static std::shared_ptr< FieldIO > CreateForFile(const LibUtilities::SessionReaderSharedPtr session, const std::string &filename)
Construct a FieldIO object for a given input filename.
Definition: FieldIO.cpp:226
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
std::shared_ptr< FieldIO > FieldIOSharedPtr
Definition: FieldIO.h:306
static FieldMetaDataMap NullFieldMetaDataMap
Definition: FieldIO.h:53

◆ CheckSteadyState()

bool Nektar::SolverUtils::UnsteadySystem::CheckSteadyState ( int  step)
private

Calculate whether the system has reached a steady state by observing residuals to a user-defined tolerance.

Definition at line 777 of file UnsteadySystem.cpp.

References CellMLToNektar.pycml::format, Nektar::SolverUtils::EquationSystem::GetTotPoints(), Nektar::SolverUtils::EquationSystem::m_comm, m_errFile, Nektar::SolverUtils::EquationSystem::m_fields, m_infosteps, m_previousSolution, Nektar::SolverUtils::EquationSystem::m_session, m_steadyStateTol, Nektar::SolverUtils::EquationSystem::m_time, Nektar::LibUtilities::ReduceSum, Vmath::Vcopy(), Vmath::Vmax(), Vmath::Vmul(), Vmath::Vsub(), and Vmath::Vsum().

Referenced by v_DoSolve(), and v_RequireFwdTrans().

778  {
779  const int nPoints = GetTotPoints();
780  const int nFields = m_fields.num_elements();
781 
782  // Holds L2 errors.
783  Array<OneD, NekDouble> L2 (nFields);
784  Array<OneD, NekDouble> residual (nFields);
785  Array<OneD, NekDouble> reference(nFields);
786 
787  for (int i = 0; i < nFields; ++i)
788  {
789  Array<OneD, NekDouble> tmp(nPoints);
790 
791  Vmath::Vsub(nPoints, m_fields[i]->GetPhys(), 1,
792  m_previousSolution[i], 1, tmp, 1);
793  Vmath::Vmul(nPoints, tmp, 1, tmp, 1, tmp, 1);
794  residual[i] = Vmath::Vsum(nPoints, tmp, 1);
795 
796  Vmath::Vmul(nPoints, m_previousSolution[i], 1,
797  m_previousSolution[i], 1, tmp, 1);
798  reference[i] = Vmath::Vsum(nPoints, tmp, 1);
799  }
800 
801  m_comm->AllReduce(residual , LibUtilities::ReduceSum);
802  m_comm->AllReduce(reference, LibUtilities::ReduceSum);
803 
804  // L2 error
805  for (int i = 0; i < nFields; ++i)
806  {
807  reference[i] = (reference[i] == 0) ? 1 : reference[i];
808  L2[i] = sqrt(residual[i] / reference[i]);
809  }
810 
811  if (m_comm->GetRank() == 0 && ((step+1) % m_infosteps == 0))
812  {
813  // Output time
814  m_errFile << boost::format("%25.19e") % m_time;
815 
816  // Output residuals
817  for (int i = 0; i < nFields; ++i)
818  {
819  m_errFile << " " << boost::format("%25.19e") % L2[i];
820  }
821 
822  m_errFile << endl;
823  }
824 
825  // Calculate maximum L2 error
826  NekDouble maxL2 = Vmath::Vmax(nFields, L2, 1);
827 
828  if (m_session->DefinesCmdLineArgument("verbose") &&
829  m_comm->GetRank() == 0 && ((step+1) % m_infosteps == 0))
830  {
831  cout << "-- Maximum L^2 residual: " << maxL2 << endl;
832  }
833 
834  if (maxL2 <= m_steadyStateTol)
835  {
836  return true;
837  }
838 
839  for (int i = 0; i < m_fields.num_elements(); ++i)
840  {
841  Vmath::Vcopy(nPoints, m_fields[i]->GetPhys(), 1,
842  m_previousSolution[i], 1);
843  }
844 
845  return false;
846  }
Array< OneD, Array< OneD, NekDouble > > m_previousSolution
Storage for previous solution for steady-state check.
NekDouble m_time
Current time of simulation.
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
Definition: Vmath.cpp:782
NekDouble m_steadyStateTol
Tolerance to which steady state should be evaluated at.
LibUtilities::CommSharedPtr m_comm
Communicator.
SOLVER_UTILS_EXPORT int GetTotPoints()
double NekDouble
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
Definition: Vmath.cpp:346
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
int m_infosteps
Number of time steps between outputting status information.
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
Definition: Vmath.cpp:740
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064
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

◆ GetTimeStep()

NekDouble Nektar::SolverUtils::UnsteadySystem::GetTimeStep ( const Array< OneD, const Array< OneD, NekDouble >> &  inarray)

Calculate the larger time-step mantaining the problem stable.

Return the timestep to be used for the next step in the time-marching loop.

This function can be overloaded to facilitate solver which utilise a CFL (or other) parameter to determine a maximum timestep under which the problem remains stable.

Definition at line 668 of file UnsteadySystem.cpp.

References v_GetTimeStep().

670  {
671  return v_GetTimeStep(inarray);
672  }
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.

◆ InitializeSteadyState()

void Nektar::SolverUtils::UnsteadySystem::InitializeSteadyState ( )
private

Definition at line 741 of file UnsteadySystem.cpp.

References Nektar::SolverUtils::EquationSystem::m_comm, m_errFile, Nektar::SolverUtils::EquationSystem::m_fields, m_previousSolution, Nektar::SolverUtils::EquationSystem::m_session, m_steadyStateTol, and Vmath::Vcopy().

Referenced by v_DoInitialise(), and v_RequireFwdTrans().

742  {
743  if (m_steadyStateTol > 0.0)
744  {
745  const int nPoints = m_fields[0]->GetTotPoints();
746  m_previousSolution = Array<OneD, Array<OneD, NekDouble> > (
747  m_fields.num_elements());
748 
749  for (int i = 0; i < m_fields.num_elements(); ++i)
750  {
751  m_previousSolution[i] = Array<OneD, NekDouble>(nPoints);
752  Vmath::Vcopy(nPoints, m_fields[i]->GetPhys(), 1,
753  m_previousSolution[i], 1);
754  }
755 
756  if (m_comm->GetRank() == 0)
757  {
758  std::string fName = m_session->GetSessionName() +
759  std::string(".res");
760  m_errFile.open(fName.c_str());
761  m_errFile << setw(26) << left << "# Time";
762 
763  for (int i = 0; i < m_fields.num_elements(); ++i)
764  {
765  m_errFile << setw(26) << m_session->GetVariables()[i];
766  }
767 
768  m_errFile << endl;
769  }
770  }
771  }
Array< OneD, Array< OneD, NekDouble > > m_previousSolution
Storage for previous solution for steady-state check.
NekDouble m_steadyStateTol
Tolerance to which steady state should be evaluated at.
LibUtilities::CommSharedPtr m_comm
Communicator.
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064

◆ MaxTimeStepEstimator()

NekDouble Nektar::SolverUtils::UnsteadySystem::MaxTimeStepEstimator ( )
protected

Get the maximum timestep estimator for cfl control.

Returns the maximum time estimator for CFL control.

Definition at line 160 of file UnsteadySystem.cpp.

References ASSERTL0, Nektar::LibUtilities::eAdamsBashforthOrder1, Nektar::LibUtilities::eAdamsBashforthOrder2, Nektar::LibUtilities::eClassicalRungeKutta4, Nektar::LibUtilities::eForwardEuler, Nektar::LibUtilities::eMidpoint, Nektar::LibUtilities::eRungeKutta2, Nektar::LibUtilities::eRungeKutta2_ImprovedEuler, Nektar::LibUtilities::eRungeKutta2_SSP, Nektar::LibUtilities::eRungeKutta3_SSP, Nektar::LibUtilities::eRungeKutta4, and m_intScheme.

Referenced by Nektar::CompressibleFlowSystem::GetElmtTimeStep().

161  {
162  NekDouble TimeStability = 0.0;
163  switch(m_intScheme->GetIntegrationMethod())
164  {
168  {
169  TimeStability = 2.784;
170  break;
171  }
178  {
179  TimeStability = 2.0;
180  break;
181  }
183  {
184  TimeStability = 1.0;
185  break;
186  }
187  default:
188  {
189  ASSERTL0(
190  false,
191  "No CFL control implementation for this time"
192  "integration scheme");
193  }
194  }
195  return TimeStability;
196  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
Adams-Bashforth Forward multi-step scheme of order 2.
Runge-Kutta multi-stage scheme 4th order explicit (old name)
Classical RungeKutta4 method (new name for eClassicalRungeKutta4)
Nonlinear SSP RungeKutta3 explicit.
Classical RungeKutta2 method (new name for eMidpoint)
Adams-Bashforth Forward multi-step scheme of order 1.
Nonlinear SSP RungeKutta2 explicit (surrogate for eRungeKutta2_ImprovedEuler)
Improved RungeKutta2 explicit (old name meaning Heun&#39;s method)
double NekDouble
LibUtilities::TimeIntegrationWrapperSharedPtr m_intScheme
Wrapper to the time integration scheme.
midpoint method (old name)

◆ SVVVarDiffCoeff()

void Nektar::SolverUtils::UnsteadySystem::SVVVarDiffCoeff ( const Array< OneD, Array< OneD, NekDouble >>  vel,
StdRegions::VarCoeffMap varCoeffMap 
)
protected

Evaluate the SVV diffusion coefficient according to Moura's paper where it should proportional to h time velocity.

Definition at line 700 of file UnsteadySystem.cpp.

References Nektar::StdRegions::eVarCoeffLaplacian, Nektar::SolverUtils::EquationSystem::m_fields, Vmath::Smul(), Vmath::Vmul(), Vmath::Vsqrt(), and Vmath::Vvtvp().

Referenced by Nektar::UnsteadyViscousBurgers::DoImplicitSolve(), Nektar::UnsteadyViscousBurgers::v_InitObject(), and v_RequireFwdTrans().

703  {
704  int phystot = m_fields[0]->GetTotPoints();
705  int nvel = vel.num_elements();
706 
707  Array<OneD, NekDouble> varcoeff(phystot),tmp;
708 
709  // calculate magnitude of v
710  Vmath::Vmul(phystot,vel[0],1,vel[0],1,varcoeff,1);
711  for(int n = 1; n < nvel; ++n)
712  {
713  Vmath::Vvtvp(phystot,vel[n],1,vel[n],1,varcoeff,1,varcoeff,1);
714  }
715  Vmath::Vsqrt(phystot,varcoeff,1,varcoeff,1);
716 
717  for(int i = 0; i < m_fields[0]->GetNumElmts(); ++i)
718  {
719  int offset = m_fields[0]->GetPhys_Offset(i);
720  int nq = m_fields[0]->GetExp(i)->GetTotPoints();
721  Array<OneD, NekDouble> unit(nq,1.0);
722 
723  int nmodes = 0;
724 
725  for(int n = 0; n < m_fields[0]->GetExp(i)->GetNumBases(); ++n)
726  {
727  nmodes = max(nmodes,
728  m_fields[0]->GetExp(i)->GetBasisNumModes(n));
729  }
730 
731  NekDouble h = m_fields[0]->GetExp(i)->Integral(unit);
732  h = pow(h,(NekDouble) (1.0/nvel))/((NekDouble) nmodes);
733 
734  Vmath::Smul(nq,h,varcoeff+offset,1,tmp = varcoeff+offset,1);
735  }
736 
737  // set up map with eVarCoffLaplacian key
738  varCoeffMap[StdRegions::eVarCoeffLaplacian] = varcoeff;
739  }
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
Definition: Vmath.cpp:411
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
double NekDouble
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
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_AppendOutput1D()

void Nektar::SolverUtils::UnsteadySystem::v_AppendOutput1D ( Array< OneD, Array< OneD, NekDouble >> &  solution1D)
protectedvirtual

Print the solution at each solution point in a txt file.

Stores the solution in a file for 1D problems only. This method has been implemented to facilitate the post-processing for 1D problems.

Definition at line 583 of file UnsteadySystem.cpp.

References Nektar::SolverUtils::EquationSystem::GetNpoints(), and Nektar::SolverUtils::EquationSystem::m_fields.

Referenced by v_DoSolve().

585  {
586  // Coordinates of the quadrature points in the real physical space
587  Array<OneD,NekDouble> x(GetNpoints());
588  Array<OneD,NekDouble> y(GetNpoints());
589  Array<OneD,NekDouble> z(GetNpoints());
590  m_fields[0]->GetCoords(x, y, z);
591 
592  // Print out the solution in a txt file
593  ofstream outfile;
594  outfile.open("solution1D.txt");
595  for(int i = 0; i < GetNpoints(); i++)
596  {
597  outfile << scientific << setw (17) << setprecision(16) << x[i]
598  << " " << solution1D[0][i] << endl;
599  }
600  outfile << endl << endl;
601  outfile.close();
602  }
SOLVER_UTILS_EXPORT int GetNpoints()
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.

◆ v_DoInitialise()

void Nektar::SolverUtils::UnsteadySystem::v_DoInitialise ( void  )
protectedvirtual

Sets up initial conditions.

Sets the initial conditions.

Reimplemented from Nektar::SolverUtils::EquationSystem.

Reimplemented in Nektar::MMFSWE, Nektar::CoupledLinearNS, Nektar::VelocityCorrectionScheme, Nektar::PulseWaveSystem, and Nektar::VCSMapping.

Definition at line 537 of file UnsteadySystem.cpp.

References CheckForRestartTime(), InitializeSteadyState(), Nektar::SolverUtils::EquationSystem::m_nchk, Nektar::SolverUtils::EquationSystem::m_time, Nektar::SolverUtils::EquationSystem::SetBoundaryConditions(), and Nektar::SolverUtils::EquationSystem::SetInitialConditions().

Referenced by Nektar::VCSMapping::v_DoInitialise(), and Nektar::VelocityCorrectionScheme::v_DoInitialise().

538  {
543  }
NekDouble m_time
Current time of simulation.
SOLVER_UTILS_EXPORT void CheckForRestartTime(NekDouble &time, int &nchk)
int m_nchk
Number of checkpoints written so far.
SOLVER_UTILS_EXPORT void SetBoundaryConditions(NekDouble time)
Evaluates the boundary conditions at the given time.
SOLVER_UTILS_EXPORT void SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
Initialise the data in the dependent fields.

◆ v_DoSolve()

void Nektar::SolverUtils::UnsteadySystem::v_DoSolve ( void  )
protectedvirtual

Solves an unsteady problem.

Initialises the time integration scheme (as specified in the session file), and perform the time integration.

Reimplemented from Nektar::SolverUtils::EquationSystem.

Reimplemented in Nektar::MMFSWE, Nektar::CoupledLinearNS, Nektar::MMFAdvection, Nektar::PulseWaveSystem, and Nektar::MMFMaxwell.

Definition at line 202 of file UnsteadySystem.cpp.

References ASSERTL0, Nektar::SolverUtils::EquationSystem::Checkpoint_Output(), CheckSteadyState(), Nektar::SolverUtils::EquationSystem::eNotHomogeneous, Nektar::SolverUtils::EquationSystem::GetTimeStep(), Nektar::NekConstants::kNekZeroTol, m_abortSteps, m_cflSafetyFactor, Nektar::SolverUtils::EquationSystem::m_checksteps, Nektar::SolverUtils::EquationSystem::m_checktime, Nektar::SolverUtils::EquationSystem::m_comm, Nektar::SolverUtils::EquationSystem::m_fields, m_filters, m_filtersInfosteps, Nektar::SolverUtils::EquationSystem::m_fintime, Nektar::SolverUtils::EquationSystem::m_HomogeneousType, m_homoInitialFwd, m_infosteps, Nektar::SolverUtils::EquationSystem::m_initialStep, m_intScheme, m_intSoln, m_intVariables, Nektar::SolverUtils::EquationSystem::m_nchk, m_ode, Nektar::SolverUtils::EquationSystem::m_session, Nektar::SolverUtils::EquationSystem::m_spacedim, m_steadyStateSteps, m_steadyStateTol, Nektar::SolverUtils::EquationSystem::m_steps, Nektar::SolverUtils::EquationSystem::m_time, Nektar::SolverUtils::EquationSystem::m_timestep, Vmath::Nnan(), Nektar::LibUtilities::ReduceMax, Nektar::LibUtilities::Timer::Start(), Nektar::LibUtilities::Timer::Stop(), Nektar::LibUtilities::Timer::TimePerTest(), v_AppendOutput1D(), v_PostIntegrate(), v_PreIntegrate(), and v_RequireFwdTrans().

Referenced by Nektar::CoupledLinearNS::v_DoSolve().

203  {
204  ASSERTL0(m_intScheme != 0, "No time integration scheme.");
205 
206  int i = 1;
207  int nvariables = 0;
208  int nfields = m_fields.num_elements();
209 
210  if (m_intVariables.empty())
211  {
212  for (i = 0; i < nfields; ++i)
213  {
214  m_intVariables.push_back(i);
215  }
216  nvariables = nfields;
217  }
218  else
219  {
220  nvariables = m_intVariables.size();
221  }
222 
223  // Integrate in wave-space if using homogeneous1D
225  {
226  for(i = 0; i < nfields; ++i)
227  {
228  m_fields[i]->HomogeneousFwdTrans(m_fields[i]->GetPhys(),
229  m_fields[i]->UpdatePhys());
230  m_fields[i]->SetWaveSpace(true);
231  m_fields[i]->SetPhysState(false);
232  }
233  }
234 
235  // Set up wrapper to fields data storage.
236  Array<OneD, Array<OneD, NekDouble> > fields(nvariables);
237 
238  // Order storage to list time-integrated fields first.
239  for(i = 0; i < nvariables; ++i)
240  {
241  fields[i] = m_fields[m_intVariables[i]]->GetPhys();
242  m_fields[m_intVariables[i]]->SetPhysState(false);
243  }
244 
245  // Initialise time integration scheme
246  m_intSoln = m_intScheme->InitializeScheme(
247  m_timestep, fields, m_time, m_ode);
248 
249  // Initialise filters
250  for (auto &x : m_filters)
251  {
252  x.second->Initialise(m_fields, m_time);
253  }
254 
255  LibUtilities::Timer timer;
256  bool doCheckTime = false;
257  int step = m_initialStep;
258  int stepCounter = 0;
259  NekDouble intTime = 0.0;
260  NekDouble lastCheckTime = 0.0;
261  NekDouble cpuTime = 0.0;
262  NekDouble cpuPrevious = 0.0;
263  NekDouble elapsed = 0.0;
264  NekDouble totFilterTime = 0.0;
265 
266  Array<OneD, int> abortFlags(2, 0);
267  string abortFile = "abort";
268  if (m_session->DefinesSolverInfo("CheckAbortFile"))
269  {
270  abortFile = m_session->GetSolverInfo("CheckAbortFile");
271  }
272 
273  while ((step < m_steps ||
275  abortFlags[1] == 0)
276  {
277  if (m_cflSafetyFactor)
278  {
279  m_timestep = GetTimeStep(fields);
280 
281  // Ensure that the final timestep finishes at the final
282  // time, or at a prescribed IO_CheckTime.
283  if (m_time + m_timestep > m_fintime && m_fintime > 0.0)
284  {
286  }
287  else if (m_checktime &&
288  m_time + m_timestep - lastCheckTime >= m_checktime)
289  {
290  lastCheckTime += m_checktime;
291  m_timestep = lastCheckTime - m_time;
292  doCheckTime = true;
293  }
294  }
295 
296  // Perform any solver-specific pre-integration steps
297  timer.Start();
298  if (v_PreIntegrate(step))
299  {
300  break;
301  }
302 
303  fields = m_intScheme->TimeIntegrate(
304  stepCounter, m_timestep, m_intSoln, m_ode);
305  timer.Stop();
306 
307  m_time += m_timestep;
308  elapsed = timer.TimePerTest(1);
309  intTime += elapsed;
310  cpuTime += elapsed;
311 
312  // Write out status information
313  if (m_session->GetComm()->GetRank() == 0 &&
314  !((step+1) % m_infosteps))
315  {
316  cout << "Steps: " << setw(8) << left << step+1 << " "
317  << "Time: " << setw(12) << left << m_time;
318 
319  if (m_cflSafetyFactor)
320  {
321  cout << " Time-step: " << setw(12)
322  << left << m_timestep;
323  }
324 
325  stringstream ss;
326  ss << cpuTime << "s";
327  cout << " CPU Time: " << setw(8) << left
328  << ss.str() << endl;
329  cpuPrevious = cpuTime;
330  cpuTime = 0.0;
331  }
332 
333  // Transform data into coefficient space
334  for (i = 0; i < nvariables; ++i)
335  {
336  // copy fields into ExpList::m_phys and assign the new
337  // array to fields
338  m_fields[m_intVariables[i]]->SetPhys(fields[i]);
339  fields[i] = m_fields[m_intVariables[i]]->UpdatePhys();
340  if( v_RequireFwdTrans() )
341  {
342  m_fields[m_intVariables[i]]->FwdTrans_IterPerExp(
343  fields[i],
344  m_fields[m_intVariables[i]]->UpdateCoeffs());
345  }
346  m_fields[m_intVariables[i]]->SetPhysState(false);
347  }
348 
349  // Perform any solver-specific post-integration steps
350  if (v_PostIntegrate(step))
351  {
352  break;
353  }
354 
355  // Check for steady-state
356  if (m_steadyStateTol > 0.0 && (!((step+1)%m_steadyStateSteps)) )
357  {
358  if (CheckSteadyState(step))
359  {
360  if (m_comm->GetRank() == 0)
361  {
362  cout << "Reached Steady State to tolerance "
363  << m_steadyStateTol << endl;
364  }
365  break;
366  }
367  }
368 
369  // test for abort conditions (nan, or abort file)
370  if (m_abortSteps && !((step+1) % m_abortSteps) )
371  {
372  abortFlags[0] = 0;
373  for (i = 0; i < nvariables; ++i)
374  {
375  if (Vmath::Nnan(fields[i].num_elements(),
376  fields[i], 1) > 0)
377  {
378  abortFlags[0] = 1;
379  }
380  }
381 
382  //rank zero looks for abort file and deltes it
383  //if it exists. The communicates the abort
384  if(m_session->GetComm()->GetRank() == 0)
385  {
386  if(boost::filesystem::exists(abortFile))
387  {
388  boost::filesystem::remove(abortFile);
389  abortFlags[1] = 1;
390  }
391  }
392 
393  m_session->GetComm()->AllReduce(abortFlags,
395 
396  ASSERTL0 (!abortFlags[0],
397  "NaN found during time integration.");
398  }
399 
400  // Update filters
401  for (auto &x : m_filters)
402  {
403  timer.Start();
404  x.second->Update(m_fields, m_time);
405  timer.Stop();
406  elapsed = timer.TimePerTest(1);
407  totFilterTime += elapsed;
408 
409  // Write out individual filter status information
410  if(m_session->GetComm()->GetRank() == 0 &&
411  !((step+1) % m_filtersInfosteps) && !m_filters.empty() &&
412  m_session->DefinesCmdLineArgument("verbose"))
413  {
414  stringstream s0;
415  s0 << x.first << ":";
416  stringstream s1;
417  s1 << elapsed << "s";
418  stringstream s2;
419  s2 << elapsed / cpuPrevious * 100 << "%";
420  cout << "CPU time for filter " << setw(25) << left
421  << s0.str() << setw(12) << left << s1.str() <<
422  endl << "\t Percentage of time integration: "
423  << setw(10) << left << s2.str() << endl;
424  }
425  }
426 
427  // Write out overall filter status information
428  if (m_session->GetComm()->GetRank() == 0 &&
429  !((step+1) % m_filtersInfosteps) && !m_filters.empty())
430  {
431  stringstream ss;
432  ss << totFilterTime << "s";
433  cout << "Total filters CPU Time:\t\t\t " << setw(10)
434  << left << ss.str() << endl;
435  }
436  totFilterTime = 0.0;
437 
438  // Write out checkpoint files
439  if ((m_checksteps && !((step + 1) % m_checksteps)) ||
440  doCheckTime)
441  {
443  {
444  vector<bool> transformed(nfields, false);
445  for(i = 0; i < nfields; i++)
446  {
447  if (m_fields[i]->GetWaveSpace())
448  {
449  m_fields[i]->SetWaveSpace(false);
450  m_fields[i]->BwdTrans(m_fields[i]->GetCoeffs(),
451  m_fields[i]->UpdatePhys());
452  m_fields[i]->SetPhysState(true);
453  transformed[i] = true;
454  }
455  }
457  m_nchk++;
458  for(i = 0; i < nfields; i++)
459  {
460  if (transformed[i])
461  {
462  m_fields[i]->SetWaveSpace(true);
463  m_fields[i]->HomogeneousFwdTrans(
464  m_fields[i]->GetPhys(),
465  m_fields[i]->UpdatePhys());
466  m_fields[i]->SetPhysState(false);
467  }
468  }
469  }
470  else
471  {
473  m_nchk++;
474  }
475  doCheckTime = false;
476  }
477 
478  // Step advance
479  ++step;
480  ++stepCounter;
481  }
482 
483  // Print out summary statistics
484  if (m_session->GetComm()->GetRank() == 0)
485  {
486  if (m_cflSafetyFactor > 0.0)
487  {
488  cout << "CFL safety factor : " << m_cflSafetyFactor << endl
489  << "CFL time-step : " << m_timestep << endl;
490  }
491 
492  if (m_session->GetSolverInfo("Driver") != "SteadyState")
493  {
494  cout << "Time-integration : " << intTime << "s" << endl;
495  }
496  }
497 
498  // If homogeneous, transform back into physical space if necessary.
500  {
501  for(i = 0; i < nfields; i++)
502  {
503  if (m_fields[i]->GetWaveSpace())
504  {
505  m_fields[i]->SetWaveSpace(false);
506  m_fields[i]->BwdTrans(m_fields[i]->GetCoeffs(),
507  m_fields[i]->UpdatePhys());
508  m_fields[i]->SetPhysState(true);
509  }
510  }
511  }
512  else
513  {
514  for(i = 0; i < nvariables; ++i)
515  {
516  m_fields[m_intVariables[i]]->SetPhys(fields[i]);
517  m_fields[m_intVariables[i]]->SetPhysState(true);
518  }
519  }
520 
521  // Finalise filters
522  for (auto &x : m_filters)
523  {
524  x.second->Finalise(m_fields, m_time);
525  }
526 
527  // Print for 1D problems
528  if(m_spacedim == 1)
529  {
530  v_AppendOutput1D(fields);
531  }
532  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
virtual SOLVER_UTILS_EXPORT bool v_PreIntegrate(int step)
bool m_homoInitialFwd
Flag to determine if simulation should start in homogeneous forward transformed state.
NekDouble m_time
Current time of simulation.
int m_abortSteps
Number of steps between checks for abort conditions.
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
NekDouble m_timestep
Time step size.
std::vector< std::pair< std::string, FilterSharedPtr > > m_filters
SOLVER_UTILS_EXPORT void Checkpoint_Output(const int n)
Write checkpoint file of m_fields.
virtual SOLVER_UTILS_EXPORT void v_AppendOutput1D(Array< OneD, Array< OneD, NekDouble >> &solution1D)
Print the solution at each solution point in a txt file.
virtual SOLVER_UTILS_EXPORT bool v_RequireFwdTrans()
NekDouble m_checktime
Time between checkpoints.
int m_nchk
Number of checkpoints written so far.
int m_checksteps
Number of steps between checkpoints.
NekDouble m_steadyStateTol
Tolerance to which steady state should be evaluated at.
LibUtilities::CommSharedPtr m_comm
Communicator.
NekDouble m_fintime
Finish time of the simulation.
int m_steps
Number of steps to take.
static const NekDouble kNekZeroTol
virtual SOLVER_UTILS_EXPORT bool v_PostIntegrate(int step)
int Nnan(int n, const T *x, const int incx)
Return number of NaN elements of x.
Definition: Vmath.cpp:895
int m_spacedim
Spatial dimension (>= expansion dim).
double NekDouble
SOLVER_UTILS_EXPORT NekDouble GetTimeStep()
NekDouble m_cflSafetyFactor
CFL safety factor (comprise between 0 to 1).
int m_filtersInfosteps
Number of time steps between outputting filters information.
int m_steadyStateSteps
Check for steady state at step interval.
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
LibUtilities::TimeIntegrationWrapperSharedPtr m_intScheme
Wrapper to the time integration scheme.
int m_initialStep
Number of the step where the simulation should begin.
bool CheckSteadyState(int step)
Calculate whether the system has reached a steady state by observing residuals to a user-defined tole...
int m_infosteps
Number of time steps between outputting status information.
LibUtilities::TimeIntegrationSolutionSharedPtr m_intSoln
enum HomogeneousType m_HomogeneousType

◆ v_GenerateSummary()

void Nektar::SolverUtils::UnsteadySystem::v_GenerateSummary ( SummaryList s)
protectedvirtual

Print a summary of time stepping parameters.

Prints a summary with some information regards the time-stepping.

Reimplemented from Nektar::SolverUtils::EquationSystem.

Reimplemented in Nektar::MMFSWE, Nektar::MMFMaxwell, Nektar::CoupledLinearNS, Nektar::VelocityCorrectionScheme, Nektar::SolverUtils::MMFSystem, Nektar::MMFAdvection, Nektar::MMFDiffusion, Nektar::UnsteadyViscousBurgers, Nektar::UnsteadyAdvectionDiffusion, Nektar::CFLtester, Nektar::UnsteadyAdvection, Nektar::NonlinearPeregrine, Nektar::PulseWavePropagation, Nektar::Monodomain, Nektar::Bidomain, Nektar::BidomainRoth, Nektar::ImageWarpingSystem, Nektar::ShallowWaterSystem, Nektar::LinearSWE, Nektar::NonlinearSWE, Nektar::UnsteadyDiffusion, Nektar::VCSWeakPressure, Nektar::IsentropicVortex, and Nektar::RinglebFlow.

Definition at line 549 of file UnsteadySystem.cpp.

References Nektar::SolverUtils::AddSummaryItem(), Nektar::SolverUtils::EquationSystem::m_checksteps, m_explicitAdvection, m_explicitDiffusion, m_explicitReaction, m_intScheme, Nektar::SolverUtils::EquationSystem::m_session, Nektar::SolverUtils::EquationSystem::m_steps, Nektar::SolverUtils::EquationSystem::m_timestep, Nektar::LibUtilities::TimeIntegrationMethodMap, and Nektar::SolverUtils::EquationSystem::v_GenerateSummary().

Referenced by Nektar::IsentropicVortex::v_GenerateSummary(), Nektar::RinglebFlow::v_GenerateSummary(), Nektar::VCSWeakPressure::v_GenerateSummary(), Nektar::UnsteadyDiffusion::v_GenerateSummary(), Nektar::ImageWarpingSystem::v_GenerateSummary(), Nektar::ShallowWaterSystem::v_GenerateSummary(), Nektar::BidomainRoth::v_GenerateSummary(), Nektar::Bidomain::v_GenerateSummary(), Nektar::Monodomain::v_GenerateSummary(), Nektar::PulseWavePropagation::v_GenerateSummary(), Nektar::UnsteadyAdvection::v_GenerateSummary(), Nektar::CFLtester::v_GenerateSummary(), Nektar::UnsteadyAdvectionDiffusion::v_GenerateSummary(), Nektar::UnsteadyViscousBurgers::v_GenerateSummary(), Nektar::SolverUtils::MMFSystem::v_GenerateSummary(), and Nektar::VelocityCorrectionScheme::v_GenerateSummary().

550  {
552  AddSummaryItem(s, "Advection",
553  m_explicitAdvection ? "explicit" : "implicit");
554 
555  if(m_session->DefinesSolverInfo("AdvectionType"))
556  {
557  AddSummaryItem(s, "AdvectionType",
558  m_session->GetSolverInfo("AdvectionType"));
559  }
560 
561  AddSummaryItem(s, "Diffusion",
562  m_explicitDiffusion ? "explicit" : "implicit");
563 
564  if (m_session->GetSolverInfo("EQTYPE")
565  == "SteadyAdvectionDiffusionReaction")
566  {
567  AddSummaryItem(s, "Reaction",
568  m_explicitReaction ? "explicit" : "implicit");
569  }
570 
571  AddSummaryItem(s, "Time Step", m_timestep);
572  AddSummaryItem(s, "No. of Steps", m_steps);
573  AddSummaryItem(s, "Checkpoints (steps)", m_checksteps);
574  AddSummaryItem(s, "Integration Type",
576  m_intScheme->GetIntegrationMethod()]);
577  }
virtual SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &l)
Virtual function for generating summary information.
bool m_explicitReaction
Indicates if explicit or implicit treatment of reaction is used.
bool m_explicitDiffusion
Indicates if explicit or implicit treatment of diffusion is used.
NekDouble m_timestep
Time step size.
const char *const TimeIntegrationMethodMap[]
int m_checksteps
Number of steps between checkpoints.
int m_steps
Number of steps to take.
bool m_explicitAdvection
Indicates if explicit or implicit treatment of advection is used.
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
Definition: Misc.cpp:49
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
LibUtilities::TimeIntegrationWrapperSharedPtr m_intScheme
Wrapper to the time integration scheme.

◆ v_GetTimeStep()

NekDouble Nektar::SolverUtils::UnsteadySystem::v_GetTimeStep ( const Array< OneD, const Array< OneD, NekDouble >> &  inarray)
protectedvirtual

Return the timestep to be used for the next step in the time-marching loop.

See also
UnsteadySystem::GetTimeStep

Definition at line 680 of file UnsteadySystem.cpp.

References Nektar::ErrorUtil::efatal, and NEKERROR.

Referenced by GetTimeStep().

682  {
683  boost::ignore_unused(inarray);
684  NEKERROR(ErrorUtil::efatal, "Not defined for this class");
685  return 0.0;
686  }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:209

◆ v_InitObject()

void Nektar::SolverUtils::UnsteadySystem::v_InitObject ( )
protectedvirtual

Init object for UnsteadySystem class.

Initialization object for UnsteadySystem class.

Reimplemented from Nektar::SolverUtils::EquationSystem.

Reimplemented in Nektar::MMFSWE, Nektar::CoupledLinearNS, Nektar::MMFAdvection, Nektar::IncNavierStokes, Nektar::PulseWaveSystem, Nektar::UnsteadyViscousBurgers, Nektar::CompressibleFlowSystem, Nektar::UnsteadyAdvectionDiffusion, Nektar::MMFDiffusion, Nektar::CFLtester, Nektar::UnsteadyAdvection, Nektar::UnsteadyInviscidBurger, Nektar::MMFMaxwell, Nektar::PulseWavePropagation, Nektar::ShallowWaterSystem, Nektar::NonlinearPeregrine, Nektar::AcousticSystem, Nektar::ImageWarpingSystem, Nektar::NavierStokesCFE, Nektar::UnsteadyDiffusion, Nektar::Monodomain, Nektar::Dummy, Nektar::LEE, Nektar::Bidomain, Nektar::NavierStokesCFEAxisym, Nektar::BidomainRoth, Nektar::LinearSWE, Nektar::NonlinearSWE, Nektar::VCSMapping, Nektar::APE, Nektar::UnsteadyReactionDiffusion, Nektar::PulseWaveSystemOutput, Nektar::VelocityCorrectionScheme, and Nektar::SolverUtils::AdvectionSystem.

Definition at line 80 of file UnsteadySystem.cpp.

References ASSERTL0, Nektar::SolverUtils::GetFilterFactory(), Nektar::LibUtilities::GetTimeIntegrationWrapperFactory(), m_abortSteps, m_cflSafetyFactor, m_explicitAdvection, m_explicitDiffusion, m_explicitReaction, Nektar::SolverUtils::EquationSystem::m_fieldMetaDataMap, m_filters, m_filtersInfosteps, m_filterTimeWarning, Nektar::SolverUtils::EquationSystem::m_fintime, m_homoInitialFwd, m_infosteps, Nektar::SolverUtils::EquationSystem::m_initialStep, m_intScheme, Nektar::SolverUtils::EquationSystem::m_session, m_steadyStateSteps, m_steadyStateTol, Nektar::SolverUtils::EquationSystem::m_steps, Nektar::SolverUtils::EquationSystem::m_time, Nektar::SolverUtils::EquationSystem::m_timestep, and Nektar::SolverUtils::EquationSystem::v_InitObject().

Referenced by Nektar::SolverUtils::AdvectionSystem::v_InitObject(), Nektar::UnsteadyReactionDiffusion::v_InitObject(), Nektar::BidomainRoth::v_InitObject(), Nektar::Bidomain::v_InitObject(), Nektar::Dummy::v_InitObject(), Nektar::Monodomain::v_InitObject(), Nektar::UnsteadyDiffusion::v_InitObject(), Nektar::ShallowWaterSystem::v_InitObject(), Nektar::MMFMaxwell::v_InitObject(), Nektar::MMFDiffusion::v_InitObject(), Nektar::PulseWaveSystem::v_InitObject(), Nektar::MMFAdvection::v_InitObject(), and Nektar::MMFSWE::v_InitObject().

81  {
83 
84  m_initialStep = 0;
85 
86  // Load SolverInfo parameters
87  m_session->MatchSolverInfo("DIFFUSIONADVANCEMENT","Explicit",
88  m_explicitDiffusion,true);
89  m_session->MatchSolverInfo("ADVECTIONADVANCEMENT","Explicit",
90  m_explicitAdvection,true);
91  m_session->MatchSolverInfo("REACTIONADVANCEMENT", "Explicit",
92  m_explicitReaction, true);
93 
94  m_session->LoadParameter("CheckAbortSteps", m_abortSteps, 1);
95  // Steady state tolerance
96  m_session->LoadParameter("SteadyStateTol", m_steadyStateTol, 0.0);
97  // Frequency for checking steady state
98  m_session->LoadParameter("SteadyStateSteps",
100 
101  // For steady problems, we do not initialise the time integration
102  if (m_session->DefinesSolverInfo("TIMEINTEGRATIONMETHOD"))
103  {
105  CreateInstance(m_session->GetSolverInfo(
106  "TIMEINTEGRATIONMETHOD"));
107 
108  // Load generic input parameters
109  m_session->LoadParameter("IO_InfoSteps", m_infosteps, 0);
110  m_session->LoadParameter("IO_FiltersInfoSteps",
112  m_session->LoadParameter("CFL", m_cflSafetyFactor, 0.0);
113 
114  // Time tolerance between filter update time and time integration
115  m_session->LoadParameter("FilterTimeWarning", m_filterTimeWarning, 1);
116 
117  // Ensure that there is no conflict of parameters
118  if(m_cflSafetyFactor > 0.0)
119  {
120  // Check final condition
121  ASSERTL0(m_fintime == 0.0 || m_steps == 0,
122  "Final condition not unique: "
123  "fintime > 0.0 and Nsteps > 0");
124  // Check timestep condition
125  ASSERTL0(m_timestep == 0.0,
126  "Timestep not unique: timestep > 0.0 & CFL > 0.0");
127  }
128  else
129  {
130  ASSERTL0(m_timestep != 0.0,
131  "Need to set either TimeStep or CFL");
132  }
133 
134  // Set up time to be dumped in field information
135  m_fieldMetaDataMap["Time"] =
136  boost::lexical_cast<std::string>(m_time);
137  }
138 
139  // By default attempt to forward transform initial condition.
140  m_homoInitialFwd = true;
141 
142  // Set up filters
143  for (auto &x : m_session->GetFilters())
144  {
145  m_filters.push_back(make_pair(x.first, GetFilterFactory().CreateInstance(
146  x.first, m_session, shared_from_this(), x.second)));
147  }
148  }
NekDouble m_filterTimeWarning
Number of time steps between outputting status information.
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
bool m_explicitReaction
Indicates if explicit or implicit treatment of reaction is used.
bool m_homoInitialFwd
Flag to determine if simulation should start in homogeneous forward transformed state.
NekDouble m_time
Current time of simulation.
bool m_explicitDiffusion
Indicates if explicit or implicit treatment of diffusion is used.
int m_abortSteps
Number of steps between checks for abort conditions.
NekDouble m_timestep
Time step size.
std::vector< std::pair< std::string, FilterSharedPtr > > m_filters
NekDouble m_steadyStateTol
Tolerance to which steady state should be evaluated at.
NekDouble m_fintime
Finish time of the simulation.
virtual SOLVER_UTILS_EXPORT void v_InitObject()
Initialisation object for EquationSystem.
int m_steps
Number of steps to take.
bool m_explicitAdvection
Indicates if explicit or implicit treatment of advection is used.
LibUtilities::FieldMetaDataMap m_fieldMetaDataMap
Map to identify relevant solver info to dump in output fields.
TimeIntegrationWrapperFactory & GetTimeIntegrationWrapperFactory()
NekDouble m_cflSafetyFactor
CFL safety factor (comprise between 0 to 1).
int m_filtersInfosteps
Number of time steps between outputting filters information.
int m_steadyStateSteps
Check for steady state at step interval.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
LibUtilities::TimeIntegrationWrapperSharedPtr m_intScheme
Wrapper to the time integration scheme.
int m_initialStep
Number of the step where the simulation should begin.
FilterFactory & GetFilterFactory()
Definition: Filter.cpp:41
int m_infosteps
Number of time steps between outputting status information.

◆ v_PostIntegrate()

bool Nektar::SolverUtils::UnsteadySystem::v_PostIntegrate ( int  step)
protectedvirtual

Reimplemented in Nektar::VelocityCorrectionScheme, Nektar::Dummy, and Nektar::SolverUtils::AdvectionSystem.

Definition at line 694 of file UnsteadySystem.cpp.

Referenced by v_DoSolve(), Nektar::SolverUtils::AdvectionSystem::v_PostIntegrate(), and Nektar::Dummy::v_PostIntegrate().

695  {
696  boost::ignore_unused(step);
697  return false;
698  }

◆ v_PreIntegrate()

bool Nektar::SolverUtils::UnsteadySystem::v_PreIntegrate ( int  step)
protectedvirtual

Reimplemented in Nektar::IncNavierStokes, Nektar::UnsteadyAdvectionDiffusion, Nektar::AcousticSystem, and Nektar::Dummy.

Definition at line 688 of file UnsteadySystem.cpp.

Referenced by v_DoSolve(), Nektar::Dummy::v_PreIntegrate(), and Nektar::AcousticSystem::v_PreIntegrate().

689  {
690  boost::ignore_unused(step);
691  return false;
692  }

◆ v_RequireFwdTrans()

virtual SOLVER_UTILS_EXPORT bool Nektar::SolverUtils::UnsteadySystem::v_RequireFwdTrans ( )
inlineprotectedvirtual

Reimplemented in Nektar::VelocityCorrectionScheme, and Nektar::Dummy.

Definition at line 132 of file UnsteadySystem.h.

References CheckForRestartTime(), CheckSteadyState(), InitializeSteadyState(), SOLVER_UTILS_EXPORT, and SVVVarDiffCoeff().

Referenced by v_DoSolve().

133  {
134  return true;
135  }

Member Data Documentation

◆ m_abortSteps

int Nektar::SolverUtils::UnsteadySystem::m_abortSteps
protected

Number of steps between checks for abort conditions.

Definition at line 64 of file UnsteadySystem.h.

Referenced by v_DoSolve(), and v_InitObject().

◆ m_cflSafetyFactor

NekDouble Nektar::SolverUtils::UnsteadySystem::m_cflSafetyFactor

◆ m_epsilon

NekDouble Nektar::SolverUtils::UnsteadySystem::m_epsilon
protected

Definition at line 75 of file UnsteadySystem.h.

◆ m_errFile

std::ofstream Nektar::SolverUtils::UnsteadySystem::m_errFile
protected

Definition at line 93 of file UnsteadySystem.h.

Referenced by CheckSteadyState(), and InitializeSteadyState().

◆ m_explicitAdvection

bool Nektar::SolverUtils::UnsteadySystem::m_explicitAdvection
protected

◆ m_explicitDiffusion

bool Nektar::SolverUtils::UnsteadySystem::m_explicitDiffusion
protected

◆ m_explicitReaction

bool Nektar::SolverUtils::UnsteadySystem::m_explicitReaction
protected

Indicates if explicit or implicit treatment of reaction is used.

Definition at line 81 of file UnsteadySystem.h.

Referenced by v_GenerateSummary(), and v_InitObject().

◆ m_filters

std::vector<std::pair<std::string, FilterSharedPtr> > Nektar::SolverUtils::UnsteadySystem::m_filters
protected

◆ m_filtersInfosteps

int Nektar::SolverUtils::UnsteadySystem::m_filtersInfosteps
protected

Number of time steps between outputting filters information.

Definition at line 66 of file UnsteadySystem.h.

Referenced by v_DoSolve(), and v_InitObject().

◆ m_filterTimeWarning

NekDouble Nektar::SolverUtils::UnsteadySystem::m_filterTimeWarning
protected

Number of time steps between outputting status information.

Definition at line 100 of file UnsteadySystem.h.

Referenced by v_InitObject().

◆ m_homoInitialFwd

bool Nektar::SolverUtils::UnsteadySystem::m_homoInitialFwd
protected

◆ m_infosteps

int Nektar::SolverUtils::UnsteadySystem::m_infosteps
protected

◆ m_intScheme

LibUtilities::TimeIntegrationWrapperSharedPtr Nektar::SolverUtils::UnsteadySystem::m_intScheme
protected

◆ m_intSoln

LibUtilities::TimeIntegrationSolutionSharedPtr Nektar::SolverUtils::UnsteadySystem::m_intSoln
protected

◆ m_intVariables

std::vector<int> Nektar::SolverUtils::UnsteadySystem::m_intVariables
protected

◆ m_nanSteps

int Nektar::SolverUtils::UnsteadySystem::m_nanSteps
protected

Definition at line 67 of file UnsteadySystem.h.

Referenced by Nektar::Dummy::v_InitObject().

◆ m_ode

LibUtilities::TimeIntegrationSchemeOperators Nektar::SolverUtils::UnsteadySystem::m_ode
protected

◆ m_previousSolution

Array<OneD, Array<OneD, NekDouble> > Nektar::SolverUtils::UnsteadySystem::m_previousSolution
protected

Storage for previous solution for steady-state check.

Definition at line 91 of file UnsteadySystem.h.

Referenced by CheckSteadyState(), and InitializeSteadyState().

◆ m_steadyStateSteps

int Nektar::SolverUtils::UnsteadySystem::m_steadyStateSteps
protected

Check for steady state at step interval.

Definition at line 89 of file UnsteadySystem.h.

Referenced by v_DoSolve(), and v_InitObject().

◆ m_steadyStateTol

NekDouble Nektar::SolverUtils::UnsteadySystem::m_steadyStateTol
protected

Tolerance to which steady state should be evaluated at.

Definition at line 87 of file UnsteadySystem.h.

Referenced by CheckSteadyState(), InitializeSteadyState(), v_DoSolve(), and v_InitObject().