67 UnsteadySystem::UnsteadySystem(
85 m_session->MatchSolverInfo(
"DIFFUSIONADVANCEMENT",
"Explicit",
87 m_session->MatchSolverInfo(
"ADVECTIONADVANCEMENT",
"Explicit",
89 m_session->MatchSolverInfo(
"REACTIONADVANCEMENT",
"Explicit",
95 if (
m_session->DefinesSolverInfo(
"TIMEINTEGRATIONMETHOD"))
99 "TIMEINTEGRATIONMETHOD"));
107 boost::lexical_cast<std::string>(
m_time);
114 LibUtilities::FilterMap::const_iterator x;
116 for (x = f.begin(); x != f.end(); ++x)
144 TimeStability = 2.784;
166 "No CFL control implementation for this time"
167 "integration scheme");
170 return TimeStability;
183 int nfields =
m_fields.num_elements();
187 for (i = 0; i < nfields; ++i)
191 nvariables = nfields;
201 for(i = 0; i < nfields; ++i)
215 for(i = 0; i < nvariables; ++i)
237 "Final condition not unique: "
238 "fintime > 0.0 and Nsteps > 0");
242 "Timestep not unique: timestep > 0.0 & CFL > 0.0");
249 "Only one of IO_CheckTime and IO_CheckSteps "
253 bool doCheckTime =
false;
299 if (
m_session->GetComm()->GetRank() == 0 &&
302 cout <<
"Steps: " << setw(8) << left << step+1 <<
" "
303 <<
"Time: " << setw(12) << left <<
m_time;
307 cout <<
" Time-step: " << setw(12)
312 ss << cpuTime <<
"s";
313 cout <<
" CPU Time: " << setw(8) << left
319 for (i = 0; i < nvariables; ++i)
341 for (i = 0; i < nvariables; ++i)
349 m_session->GetComm()->AllReduce(nanFound,
352 "NaN found during time integration.");
367 vector<bool> transformed(nfields,
false);
368 for(i = 0; i < nfields; i++)
376 transformed[i] =
true;
381 for(i = 0; i < nfields; i++)
406 if (
m_session->GetComm()->GetRank() == 0)
414 if (
m_session->GetSolverInfo(
"Driver") !=
"SteadyState")
416 cout <<
"Time-integration : " << intTime <<
"s" << endl;
423 for(i = 0; i < nfields; i++)
436 for(i = 0; i < nvariables; ++i)
476 if(
m_session->DefinesSolverInfo(
"AdvectionType"))
479 m_session->GetSolverInfo(
"AdvectionType"));
486 ==
"SteadyAdvectionDiffusionReaction")
515 outfile.open(
"solution1D.txt");
518 outfile << scientific << setw (17) << setprecision(16) << x[i]
519 <<
" " << solution1D[0][i] << endl;
521 outfile << endl << endl;
530 "This function is not implemented for this equation.");
539 "This function is not implemented for this equation.");
548 int nvariables =
m_fields.num_elements();
549 int nqvar = uflux.num_elements();
560 for (j = 0; j < nqvar; ++j)
562 for (i = 0; i < nvariables ; ++i)
565 m_fields[i]->GetFwdBwdTracePhys(ufield[i], Fwd, Bwd);
587 if(
m_fields[0]->GetBndCondExpansions().num_elements())
618 int nvariables =
m_fields.num_elements();
619 int nqvar = qfield.num_elements();
634 for (
int i = 0; i < nvariables; ++i)
637 for (
int j = 0; j < nqvar; ++j)
640 m_fields[i]->GetFwdBwdTracePhys(qfield[j][i],qFwd,qBwd);
664 m_fields[i]->GetFwdBwdTracePhys(ufield[i], Fwd, Bwd);
671 -1.0 * C11, uterm, 1,
681 if (
m_fields[0]->GetBndCondExpansions().num_elements())
702 if (
m_session->DefinesFunction(
"InitialConditions"))
704 for (
int i = 0; i <
m_fields.num_elements(); ++i)
709 "InitialConditions",
m_session->GetVariable(i));
715 "InitialConditions",
m_session->GetVariable(i));
717 fs::path pfilename(filename);
720 if(fs::is_directory(pfilename))
722 fs::path metafile(
"Info.xml");
723 fs::path fullpath = pfilename / metafile;
764 int i, e, npoints, id1, id2;
767 int nbnd =
m_fields[var]->GetBndCondExpansions().num_elements();
774 m_fields[var]->ExtractTracePhys(physfield, uplus);
775 for (i = 0; i < nbnd; ++i)
779 GetBndCondExpansions()[i]->GetExpSize();
783 m_session->GetFunction(
"InitialConditions", 0);
786 GetBndCondExpansions()[i]->GetNpoints();
793 m_fields[var]->GetBndCondExpansions()[i]->GetCoords(x0,x1,x2);
794 ifunc->Evaluate(x0,x1,x2,time,BDphysics);
797 for (e = 0; e < numBDEdge ; ++e)
801 GetBndCondExpansions()[i]->GetExp(e)->GetNumPoints(0);
804 GetBndCondExpansions()[i]->GetPhys_Offset(e);
808 GetBndCondTraceToGlobalTraceMap(cnt++));
811 if (
m_fields[var]->GetBndConditions()[i]->
816 &penaltyflux[id2], 1);
819 else if ((
m_fields[var]->GetBndConditions()[i])->
824 &penaltyflux[id2], 1);
843 int i, e, npoints, id1, id2;
844 int nbnd =
m_fields[var]->GetBndCondExpansions().num_elements();
851 m_fields[var]->ExtractTracePhys(physfield,qtemp);
853 for (i = 0; i < nbnd; ++i)
856 GetBndCondExpansions()[i]->GetExpSize();
860 m_session->GetFunction(
"InitialConditions", 0);
863 GetBndCondExpansions()[i]->GetNpoints();
870 m_fields[var]->GetBndCondExpansions()[i]->GetCoords(x0,x1,x2);
871 ifunc->Evaluate(x0,x1,x2,time,BDphysics);
874 for (e = 0; e < numBDEdge ; ++e)
877 GetBndCondExpansions()[i]->GetExp(e)->GetNumPoints(0);
880 GetBndCondExpansions()[i]->GetPhys_Offset(e);
884 GetBndCondTraceToGlobalTraceMap(cnt++));
888 if(
m_fields[var]->GetBndConditions()[i]->
894 &penaltyflux[id2], 1);
897 else if((
m_fields[var]->GetBndConditions()[i])->
903 &penaltyflux[id2], 1);
932 ASSERTL0(
false,
"Not defined for this class");
955 int phystot =
m_fields[0]->GetTotPoints();
956 int nvel = vel.num_elements();
962 for(
int n = 1; n < nvel; ++n)
964 Vmath::Vvtvp(phystot,vel[n],1,vel[n],1,varcoeff,1,varcoeff,1);
968 for(
int i = 0; i <
m_fields[0]->GetNumElmts(); ++i)
970 int offset =
m_fields[0]->GetPhys_Offset(i);
971 int nq =
m_fields[0]->GetExp(i)->GetTotPoints();
976 for(
int n = 0; n <
m_fields[0]->GetExp(i)->GetNumBases(); ++n)
979 m_fields[0]->GetExp(i)->GetBasisNumModes(n));
985 Vmath::Smul(nq,h,varcoeff+offset,1,tmp = varcoeff+offset,1);
virtual SOLVER_UTILS_EXPORT bool v_SteadyStateCheck(int step)
virtual SOLVER_UTILS_EXPORT void v_DoSolve()
Solves an unsteady problem.
virtual SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &l)
Virtual function for generating summary information.
#define ASSERTL0(condition, msg)
bool m_explicitReaction
Indicates if explicit or implicit treatment of reaction is used.
virtual SOLVER_UTILS_EXPORT void v_NumFluxforVector(const Array< OneD, Array< OneD, NekDouble > > &ufield, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &qfield, Array< OneD, Array< OneD, NekDouble > > &qflux)
virtual SOLVER_UTILS_EXPORT bool v_PreIntegrate(int step)
A base class for describing how to solve specific equations.
bool m_homoInitialFwd
Flag to determine if simulation should start in homogeneous forward transformed state.
Adams-Bashforth Forward multi-step scheme of order 2.
NekDouble m_time
Current time of simulation.
bool m_explicitDiffusion
Indicates if explicit or implicit treatment of diffusion is used.
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
Runge-Kutta multi-stage scheme 4th order explicit (old name)
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
NekDouble m_timestep
Time step size.
std::vector< std::pair< std::string, std::string > > SummaryList
void WeakPenaltyforVector(const int var, const int dir, const Array< OneD, const NekDouble > &physfield, Array< OneD, NekDouble > &penaltyflux, NekDouble C11, NekDouble time=0.0)
Classical RungeKutta4 method (new name for eClassicalRungeKutta4)
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.
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
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.
virtual SOLVER_UTILS_EXPORT bool v_RequireFwdTrans()
NekDouble m_checktime
Time between checkpoints.
SOLVER_UTILS_EXPORT void CheckForRestartTime(NekDouble &time, int &nchk)
const char *const TimeIntegrationMethodMap[]
SOLVER_UTILS_EXPORT NekDouble MaxTimeStepEstimator()
Get the maximum timestep estimator for cfl control.
Nonlinear SSP RungeKutta3 explicit.
int m_nchk
Number of checkpoints written so far.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
int m_checksteps
Number of steps between checkpoints.
NekDouble m_fintime
Finish time of the simulation.
virtual SOLVER_UTILS_EXPORT void v_InitObject()
Initialisation object for EquationSystem.
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 t...
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.
virtual SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &s)
Print a summary of time stepping parameters.
Classical RungeKutta2 method (new name for eMidpoint)
static const NekDouble kNekZeroTol
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
bool m_explicitAdvection
Indicates if explicit or implicit treatment of advection is used.
virtual SOLVER_UTILS_EXPORT ~UnsteadySystem()
Destructor.
virtual SOLVER_UTILS_EXPORT bool v_PostIntegrate(int step)
Adams-Bashforth Forward multi-step scheme of order 1.
std::map< StdRegions::VarCoeffType, Array< OneD, NekDouble > > VarCoeffMap
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
int Nnan(int n, const T *x, const int incx)
Return number of NaN elements of x.
std::vector< std::pair< std::string, FilterParams > > FilterMap
Nonlinear SSP RungeKutta2 explicit (surrogate for eRungeKutta2_ImprovedEuler)
Improved RungeKutta2 explicit (old name meaning Heun's method)
int m_spacedim
Spatial dimension (>= expansion dim).
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
boost::shared_ptr< FieldIO > FieldIOSharedPtr
TimeIntegrationWrapperFactory & GetTimeIntegrationWrapperFactory()
virtual SOLVER_UTILS_EXPORT void v_InitObject()
Init object for UnsteadySystem class.
SOLVER_UTILS_EXPORT NekDouble GetTimeStep()
NekDouble m_cflSafetyFactor
CFL safety factor (comprise between 0 to 1).
virtual SOLVER_UTILS_EXPORT void v_NumFluxforScalar(const Array< OneD, Array< OneD, NekDouble > > &ufield, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &uflux)
boost::shared_ptr< Equation > EquationSharedPtr
SOLVER_UTILS_EXPORT void SetBoundaryConditions(NekDouble time)
Evaluates the boundary conditions at the given time.
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.
virtual SOLVER_UTILS_EXPORT void v_NumericalFlux(Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, NekDouble > > &numflux)
SOLVER_UTILS_EXPORT int GetPhys_Offset(int n)
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
static boost::shared_ptr< FieldIO > CreateForFile(const LibUtilities::SessionReaderSharedPtr session, const std::string &filename)
Construct a FieldIO object for a given input filename.
SOLVER_UTILS_EXPORT int GetNpoints()
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
SOLVER_UTILS_EXPORT int GetTraceNpoints()
LibUtilities::TimeIntegrationWrapperSharedPtr m_intScheme
Wrapper to the time integration scheme.
int m_initialStep
Number of the step where the simulation should begin.
FilterFactory & GetFilterFactory()
std::vector< FilterSharedPtr > m_filters
int m_infosteps
Number of time steps between outputting status information.
SOLVER_UTILS_EXPORT void SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
Initialise the data in the dependent fields.
void WeakPenaltyforScalar(const int var, const Array< OneD, const NekDouble > &physfield, Array< OneD, NekDouble > &penaltyflux, NekDouble time=0.0)
midpoint method (old name)
NekDouble TimePerTest(unsigned int n)
Returns amount of seconds per iteration in a test with n iterations.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
static FieldMetaDataMap NullFieldMetaDataMap
LibUtilities::TimeIntegrationSolutionSharedPtr m_intSoln
virtual SOLVER_UTILS_EXPORT void v_DoInitialise()
Sets up initial conditions.
enum HomogeneousType m_HomogeneousType
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
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.
std::vector< int > m_intVariables