42#include <boost/algorithm/string.hpp>
43#include <boost/format.hpp>
75 "review a solution from check point files.");
98 for (
size_t i = 0; i <
m_session->GetVariables().size(); ++i)
105 else if (
m_session->GetFunctionType(
"Solution",
114 ASSERTL0(
false,
"solution not defined for variable " +
121 std::map<std::string, int> series;
123 if (
m_session->DefinesParameter(
"N_slices"))
125 m_session->LoadParameter(
"N_slices", tmp, 1);
126 series[
"slices"] = tmp;
128 if (
m_session->DefinesParameter(
"N_start"))
130 m_session->LoadParameter(
"N_start", tmp, 0);
131 series[
"start"] = tmp;
133 if (
m_session->DefinesParameter(
"N_skip"))
135 m_session->LoadParameter(
"N_skip", tmp, 1);
136 series[
"skip"] = tmp;
138 if (
m_session->DefinesParameter(
"BaseFlow_interporder"))
140 m_session->LoadParameter(
"BaseFlow_interporder", tmp, 1);
141 series[
"order"] = tmp;
143 if (
m_session->DefinesParameter(
"Is_periodic"))
145 m_session->LoadParameter(
"Is_periodic", tmp, 1);
146 series[
"isperiodic"] = tmp;
149 std::map<std::string, NekDouble> times;
151 if (
m_session->DefinesParameter(
"time_start"))
153 m_session->LoadParameter(
"time_start", dtmp, 0.);
154 times[
"start"] = dtmp;
156 if (
m_session->DefinesParameter(
"period"))
158 m_session->LoadParameter(
"period", dtmp, 1.);
159 times[
"period"] = dtmp;
203 for (
size_t i = 0; i < outarray.size(); ++i)
243 for (
int i = 0; i <
m_fields.size(); ++i)
245 std::string var =
m_session->GetVariable(i);
252 bool wavespace =
m_fields[i]->GetWaveSpace();
256 m_fields[i]->SetWaveSpace(wavespace);
268 ASSERTL0(
false,
"solution not defined for variable " + var);
288 for (
size_t i = 0; i <
m_session->GetVariables().size(); ++i)
292 int npoints =
m_fields[i]->GetNpoints();
301 for (
size_t i = 0; i <
m_session->GetVariables().size(); ++i)
315 int npoints =
m_fields[0]->GetNpoints();
316 if (boost::iequals(
m_session->GetVariable(0),
"u"))
319 for (
int i = 0; i < velocity.size(); ++i)
324 else if (boost::iequals(
m_session->GetVariable(0),
"rho") &&
325 boost::iequals(
m_session->GetVariable(1),
"rhou"))
328 for (
int i = 0; i < velocity.size(); ++i)
330 Vmath::Vdiv(npoints, physfield[i], 1, physfield[0], 1, velocity[i],
337 ASSERTL0(
false,
"Could not identify velocity for ProcessVorticity");
342 const std::string functionName,
345 std::set<std::string> &variables, std::map<std::string, int> &series,
346 std::map<std::string, NekDouble> ×)
349 for (
size_t i = 0; i <
m_session->GetVariables().size(); ++i)
351 std::string var =
m_session->GetVariable(i);
352 if (variables.count(var))
355 (
m_session->GetFunctionType(functionName, var) ==
357 functionName +
"(" + var +
") is not defined as a file.");
362 if (series.count(
"start"))
371 if (series.count(
"skip"))
380 if (series.count(
"slices"))
389 if (series.count(
"order"))
398 if (series.count(
"isperiodic"))
407 bool timefromfile =
false;
408 if (times.count(
"period"))
416 if (times.count(
"start"))
425 if (
m_session->GetComm()->GetRank() == 0)
427 cout <<
"baseflow info : interpolation order " <<
m_interporder
428 <<
", period " <<
m_period <<
", periodicity ";
437 cout <<
"baseflow info : files from " <<
m_start <<
" to "
440 <<
" time intervals" << endl;
443 string file =
m_session->GetFunctionFilename(
"Solution", 0);
444 DFT(file, pFields, timefromfile);
465 int pSlice, std::map<std::string, NekDouble> ¶ms)
467 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
468 std::vector<std::vector<NekDouble>> FieldData;
470 int numexp = pFields[0]->GetExpSize();
474 for (
int i = 0; i < numexp; ++i)
476 ElementGIDs[i] = pFields[0]->GetExp(i)->GetGeom()->GetGlobalID();
482 fld->Import(pInfile, FieldDef, FieldData,
485 int nFileVar = FieldDef[0]->m_fields.size();
486 for (
int j = 0; j < nFileVar; ++j)
488 std::string var = FieldDef[0]->m_fields[j];
495 for (
int i = 0; i < FieldDef.size(); ++i)
498 FieldDef[i], FieldData[i], FieldDef[i]->m_fields[j], tmp_coeff);
505 fld->ImportFieldMetaData(pInfile, fieldMetaDataMap);
509 auto iter = fieldMetaDataMap.find(
"Time");
510 if (iter != fieldMetaDataMap.end())
512 params[
"time"] = std::stod(iter->second);
562 &
m_interp[v][npoints], 1, &outarray[0], 1, &outarray[0],
565 for (
int i = 2; i <
m_slices; i += 2)
567 phase = (i >> 1) * BetaT;
570 &outarray[0], 1, &outarray[0], 1);
572 1, &outarray[0], 1, &outarray[0], 1);
606 coeff[i] *= (x - ix + padleft - (
NekDouble)j) /
612 for (
int i = ix - padleft; i < ix + padright + 1; ++i)
615 &
m_interp[v][i * npoints], 1, &outarray[0], 1,
647 for (
int i = 0; i < nexp; ++i)
649 BlkMatrix->SetBlock(i, i, loc_mat);
659 const bool timefromfile)
663 int ncoeffs = pFields[it.second]->GetNcoeffs();
670 size_t found = file.find(
"%d");
671 std::map<std::string, NekDouble> params;
672 if (found != string::npos)
674 ASSERTL0(file.find(
"%d", found + 1) == string::npos,
675 "There are more than one '%d'.");
677 std::vector<NekDouble> times;
680 int filen = nstart + i *
m_skip;
683 if (
m_session->GetComm()->GetRank() == 0)
685 cout <<
"read base flow file " << fmt.str() << endl;
687 if (timefromfile && params.count(
"time"))
689 times.push_back(params[
"time"]);
714 "Since N_slices is specified, the filename provided for function "
715 "'BaseFlow' must include exactly one instance of the format "
716 "specifier '%d', to index the time-slices.");
727 int npoints = pFields[it.first]->GetNcoeffs();
728#ifdef NEKTAR_USING_FFTW
740 Vmath::Vcopy(npoints, &(it.second)[j * npoints], 1, &(fft_in[j]),
748 for (
int i = 0; i < npoints; i++)
750 m_FFT->FFTFwdTrans(m_tmpIN = fft_in + i *
m_slices,
758 &(it.second)[s * npoints], 1);
768 int nrows = blkmat->GetRows();
769 int ncols = blkmat->GetColumns();
786 out = (*blkmat) * in;
792 &(it.second)[s * npoints], 1);
795 for (
int r = 0; r < sortedinarray.size(); ++r)
797 sortedinarray[0] = 0;
798 sortedoutarray[0] = 0;
#define ASSERTL0(condition, msg)
Describes the specification for a Basis.
static std::shared_ptr< FieldIO > CreateForFile(const LibUtilities::SessionReaderSharedPtr session, const std::string &filename)
Construct a FieldIO object for a given input filename.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Defines a specification for a set of points.
void DefineProjection(FuncPointerT func, ObjectPointerT obj)
void DefineOdeRhs(FuncPointerT func, ObjectPointerT obj)
void DefineImplicitSolve(FuncPointerT func, ObjectPointerT obj)
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
A base class for PDEs which include an advection component.
SOLVER_UTILS_EXPORT void v_InitObject(bool DeclareField=true) override
Initialisation object for EquationSystem.
NekDouble m_time
Current time of simulation.
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
virtual SOLVER_UTILS_EXPORT MultiRegions::ExpListSharedPtr v_GetPressure(void)
SOLVER_UTILS_EXPORT void Checkpoint_Output(const int n)
Write checkpoint file of m_fields.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
SOLVER_UTILS_EXPORT int GetNpoints()
int m_nchk
Number of checkpoints written so far.
SOLVER_UTILS_EXPORT void SetBoundaryConditions(NekDouble time)
Evaluates the boundary conditions at the given time.
int m_checksteps
Number of steps between checkpoints.
LibUtilities::SessionReaderSharedPtr m_session
std::map< std::string, int > m_variableMap
variables
void ImportFldBase(std::string pInfile, const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, int slice, std::map< std::string, NekDouble > ¶ms)
Import Base flow.
std::map< int, Array< OneD, NekDouble > > m_interp
interpolation vector
NekDouble m_timeStart
period length
void InterpolateField(const std::string variable, Array< OneD, NekDouble > &outarray, NekDouble time)
void DFT(const std::string file, const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const bool timefromfile)
void InitObject(const std::string functionName, LibUtilities::SessionReaderSharedPtr pSession, const Array< OneD, const MultiRegions::ExpListSharedPtr > pFields, std::set< std::string > &variables, std::map< std::string, int > &series, std::map< std::string, NekDouble > &time)
int m_start
number of slices
DNekBlkMatSharedPtr GetFloquetBlockMatrix(int nexp)
void v_GetDensity(const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &density) override
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
FileFieldInterpolatorSharedPtr m_solutionFile
void UpdateField(NekDouble time)
Array< OneD, Array< OneD, NekDouble > > m_coord
std::set< std::string > m_variableFile
void DoImplicitSolve(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, NekDouble time, NekDouble lambda)
bool v_PostIntegrate(int step) override
void v_DoInitialise(bool dumpInitialConditions) override
Sets up initial conditions.
FileSolution(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Session reader.
void DoOdeProjection(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
Compute the projection.
std::map< std::string, LibUtilities::EquationSharedPtr > m_solutionFunction
void v_GetVelocity(const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, NekDouble > > &velocity) override
void DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
Compute the RHS.
bool v_HasConstantDensity() override
void v_InitObject(bool DeclareField=true) override
Initialise the object.
bool v_RequireFwdTrans() override
static std::string className
Name of class.
~FileSolution() override
Destructor.
Base class for unsteady solvers.
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
DNekMatSharedPtr GetStdMatrix(const StdMatrixKey &mkey)
LibUtilities::ShapeType DetShapeType() const
This function returns the shape of the expansion domain.
Class representing a segment element in reference space All interface of this class sits in StdExpans...
NektarFFTFactory & GetNektarFFTFactory()
std::shared_ptr< FieldIO > FieldIOSharedPtr
std::map< std::string, std::string > FieldMetaDataMap
std::shared_ptr< SessionReader > SessionReaderSharedPtr
static FieldMetaDataMap NullFieldMetaDataMap
@ eFourierEvenlySpaced
1D Evenly-spaced points using Fourier Fit
@ eFunctionTypeExpression
@ eFourier
Fourier Expansion .
EquationSystemFactory & GetEquationSystemFactory()
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::shared_ptr< DNekBlkMat > DNekBlkMatSharedPtr
std::shared_ptr< DNekMat > DNekMatSharedPtr
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Svtvp (scalar times vector plus vector): z = alpha*x + y.
void Vdiv(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x/y.
void Zero(int n, T *x, const int incx)
Zero vector.
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)