35#ifndef FIELDUTILS_FIELD
36#define FIELDUTILS_FIELD
44#include <boost/program_options.hpp>
55namespace po = boost::program_options;
78 std::vector<LibUtilities::FieldDefinitionsSharedPtr>
m_fielddef;
79 std::vector<std::vector<double>>
m_data;
80 std::vector<MultiRegions::ExpListSharedPtr>
m_exp;
133 if (
m_comm->TreatAsRankZero())
142 fldfilegiven && !vm.count(
"use-session-expansion");
156 if (
m_session->DefinesSolverInfo(
"HOMOGENEOUS"))
158 std::string HomoStr =
161 if ((HomoStr ==
"HOMOGENEOUS1D") ||
162 (HomoStr ==
"Homogeneous1D") || (HomoStr ==
"1D") ||
163 (HomoStr ==
"Homo1D"))
167 if ((HomoStr ==
"HOMOGENEOUS2D") ||
168 (HomoStr ==
"Homogeneous2D") || (HomoStr ==
"2D") ||
169 (HomoStr ==
"Homo2D"))
178 std::vector<int> IDs;
179 auto domain =
m_graph->GetDomain();
180 for (
size_t d = 0;
d < domain.size(); ++
d)
182 for (
auto &compIter : domain[
d])
184 for (
auto &x : compIter.second->m_geomVec)
186 IDs.push_back(x->GetGlobalID());
202 if (vm.count(
"output-points"))
204 int nPointsNew = vm[
"output-points"].as<
int>();
205 m_graph->SetExpansionInfoToPointOrder(nPointsNew);
210 if (
m_comm->TreatAsRankZero())
215 std::stringstream ss;
216 ss << cpuTime <<
"s";
217 std::cout <<
"\t CreateExp setexpansion CPU Time: "
218 << std::setw(8) << std::left << ss.str()
226 int expdim =
m_graph->GetMeshDimension();
228 vm[
"output-points-hom-z"].as<
int>();
233 if (
m_comm->TreatAsRankZero())
238 std::stringstream ss1;
240 ss1 << cpuTime <<
"s";
241 std::cout <<
"\t CreateExp set first exp CPU Time: "
242 << std::setw(8) << std::left << ss1.str()
250 size_t i, nfields, nstrips;
251 m_session->LoadParameter(
"Strip_Z", nstrips, 1);
252 std::vector<std::string> vars =
m_session->GetVariables();
254 if (vm.count(
"use-session-variables"))
260 m_exp.resize(nfields * nstrips);
262 for (
size_t s = 0; s < nstrips; ++s)
264 for (i = 0; i < nfields; ++i)
269 if (!
m_exp[s * nfields + i])
271 m_exp[s * nfields + i] =
279 m_exp[s * nfields + i] =
284 m_exp[s * nfields + i] =
297 size_t i, j, nfields, nstrips;
298 m_session->LoadParameter(
"Strip_Z", nstrips, 1);
299 std::vector<std::string> vars =
m_session->GetVariables();
304 for (
size_t s = 0; s < nstrips; ++s)
306 for (j = 0; j < nfields; ++j)
308 for (i = 0; i <
m_data.size() / nstrips; ++i)
310 size_t n = i * nstrips + s;
318 m_exp[s * nfields + j]->ExtractDataToCoeffs(
320 m_exp[s * nfields + j]->UpdateCoeffs());
323 m_exp[s * nfields + j]->BwdTrans(
324 m_exp[s * nfields + j]->GetCoeffs(),
325 m_exp[s * nfields + j]->UpdatePhys());
331 m_fielddef = std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
332 m_data = std::vector<std::vector<NekDouble>>();
336 int NumHomogeneousDir,
bool fldfilegiven =
false)
342 int expdim =
m_graph->GetMeshDimension();
343 bool dealiasing =
false;
352 "Quasi-3D approach is only set up for 1 or 2 "
353 "homogeneous directions");
355 if (NumHomogeneousDir == 1)
372 m_session->LoadParameter(
"HomModesZ", nplanes);
387 ASSERTL0(
false,
"ContFieldHomogeneous1D or "
388 "DisContFieldHomogenenous1D has "
389 "not been implemented");
399 else if (NumHomogeneousDir == 2)
403 int nylines, nzlines;
418 m_session->LoadParameter(
"HomModesY", nylines);
419 m_session->LoadParameter(
"HomModesZ", nzlines);
440 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
449 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
458 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
498 "NumHomogeneousDir is only set up for 1");
500 if (NumHomogeneousDir == 1)
535 m_session->LoadParameter(
"HomModesZ", nplanes);
570 dealiasing,
m_graph,
"DefaultVar",
636 ASSERTL0(
false,
"Expansion dimension not recognised");
655 std::string filename)
660 auto it =
m_fld.find(fmt);
662 if (it ==
m_fld.end())
676 int NumHomogeneousDir, std::string var =
"DefaultVar",
677 bool NewField =
false)
687 switch (
m_graph->GetMeshDimension())
691 if (NumHomogeneousDir == 1)
695 "ContFieldHomogeneous1D or "
696 "DisContFieldHomogenenous1D has not been "
700 std::dynamic_pointer_cast<
706 else if (NumHomogeneousDir == 2)
711 std::dynamic_pointer_cast<
717 AllocateSharedPtr(*tmp2);
722 tmp2 = std::dynamic_pointer_cast<
728 AllocateSharedPtr(*tmp2);
733 std::dynamic_pointer_cast<
738 AllocateSharedPtr(*tmp2);
746 std::dynamic_pointer_cast<MultiRegions::ContField>(
757 std::dynamic_pointer_cast<
767 std::dynamic_pointer_cast<MultiRegions::ExpList>(
778 if (NumHomogeneousDir == 1)
784 bool dealiasing =
false;
790 ->GetHomogeneousBasis()
792 m_exp[0]->GetHomoLen(),
800 tmp2 = std::dynamic_pointer_cast<
804 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
807 AllocateSharedPtr(*tmp2,
m_graph, var);
814 bool dealiasing =
false;
820 ->GetHomogeneousBasis()
822 m_exp[0]->GetHomoLen(),
830 tmp2 = std::dynamic_pointer_cast<
833 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
837 AllocateSharedPtr(*tmp2);
844 bool dealiasing =
false;
850 ->GetHomogeneousBasis()
852 m_exp[0]->GetHomoLen(),
860 std::dynamic_pointer_cast<
863 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
867 AllocateSharedPtr(*tmp2);
886 std::dynamic_pointer_cast<
905 std::dynamic_pointer_cast<
915 std::dynamic_pointer_cast<MultiRegions::ExpList>(
938 std::dynamic_pointer_cast<MultiRegions::ContField>(
958 std::dynamic_pointer_cast<
968 std::dynamic_pointer_cast<MultiRegions::ExpList>(
978 ASSERTL0(
false,
"Expansion dimension not recognised");
991 m_fielddef = std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
992 m_data = std::vector<std::vector<NekDouble>>();
1001 m_exp.resize(exp.size());
1004 if (exp.size() == 0)
1013 for (
int i = 0; i < exp.size(); ++i)
1023 std::map<std::string, LibUtilities::FieldIOSharedPtr>
m_fld;
#define ASSERTL0(condition, msg)
#define FIELD_UTILS_EXPORT
Describes the specification for a Basis.
static const std::string GetFileType(const std::string &filename, CommSharedPtr comm)
Determine file type of given input file.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Defines a specification for a set of points.
NekDouble TimePerTest(unsigned int n)
Returns amount of seconds per iteration in a test with n iterations.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
This class is the abstraction of a global continuous two- dimensional spectral/hp element expansion w...
This class is the abstractio n of a global discontinuous two- dimensional spectral/hp element expansi...
Abstraction of a two-dimensional multi-elemental expansion which is merely a collection of local expa...
Abstraction of a two-dimensional multi-elemental expansion which is merely a collection of local expa...
Abstraction of a one-dimensional multi-elemental expansion which is merely a collection of local expa...
Base class for all multi-elemental spectral/hp expansions.
std::shared_ptr< Field > FieldSharedPtr
std::shared_ptr< FieldIO > FieldIOSharedPtr
std::map< std::string, std::string > FieldMetaDataMap
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< PtsField > PtsFieldSharedPtr
static PtsFieldSharedPtr NullPtsField
FieldIOFactory & GetFieldIOFactory()
Returns the FieldIO factory.
@ eFourierEvenlySpaced
1D Evenly-spaced points using Fourier Fit
@ ePolyEvenlySpaced
1D Evenly-spaced points using Lagrange polynomial
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
@ eFourierSingleMode
Fourier ModifiedExpansion with just the first mode .
@ eFourierHalfModeRe
Fourier Modified expansions with just the real part of the first mode .
@ eFourier
Fourier Expansion .
std::shared_ptr< DisContField3DHomogeneous2D > DisContField3DHomogeneous2DSharedPtr
std::shared_ptr< DisContField3DHomogeneous1D > DisContField3DHomogeneous1DSharedPtr
std::shared_ptr< DisContField > DisContFieldSharedPtr
std::shared_ptr< ContField3DHomogeneous2D > ContField3DHomogeneous2DSharedPtr
std::shared_ptr< ContField3DHomogeneous1D > ContField3DHomogeneous1DSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< ExpList2DHomogeneous1D > ExpList2DHomogeneous1DSharedPtr
Shared pointer to an ExpList2DHomogeneous1D object.
std::shared_ptr< ExpList3DHomogeneous2D > ExpList3DHomogeneous2DSharedPtr
Shared pointer to an ExpList3DHomogeneous2D object.
std::shared_ptr< ExpList3DHomogeneous1D > ExpList3DHomogeneous1DSharedPtr
Shared pointer to an ExpList3DHomogeneous1D object.
std::shared_ptr< ContField > ContFieldSharedPtr
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
std::vector< double > d(NPUPPER *NPUPPER)
FIELD_UTILS_EXPORT void SetupFromExpList(Array< OneD, MultiRegions::ExpListSharedPtr > &exp)
LibUtilities::CommSharedPtr m_partComm
FIELD_UTILS_EXPORT void ReadFieldDefs()
FIELD_UTILS_EXPORT MultiRegions::ExpListSharedPtr SetUpFirstExpList(int NumHomogeneousDir, bool fldfilegiven=false)
FIELD_UTILS_EXPORT MultiRegions::ExpListSharedPtr AppendExpList(int NumHomogeneousDir, std::string var="DefaultVar", bool NewField=false)
bool m_requireBoundaryExpansion
bool m_declareExpansionAsDisContField
SpatialDomains::MeshGraphSharedPtr m_graph
std::vector< std::string > m_variables
std::vector< unsigned int > m_bndRegionsToWrite
LibUtilities::SessionReaderSharedPtr m_session
std::map< std::string, LibUtilities::FieldIOSharedPtr > m_fld
Map to store FieldIO instances. Key is the reader type, value is the FieldIO object.
std::map< std::string, std::vector< std::string > > m_inputfiles
FIELD_UTILS_EXPORT Field()
bool m_declareExpansionAsContField
FIELD_UTILS_EXPORT void ClearField()
std::vector< LibUtilities::FieldDefinitionsSharedPtr > m_fielddef
FIELD_UTILS_EXPORT void SetUpExp(boost::program_options::variables_map &vm)
LibUtilities::PtsFieldSharedPtr m_fieldPts
FIELD_UTILS_EXPORT ~Field()
std::vector< std::vector< double > > m_data
std::vector< MultiRegions::ExpListSharedPtr > m_exp
LibUtilities::CommSharedPtr m_comm
LibUtilities::CommSharedPtr m_defComm
FIELD_UTILS_EXPORT void CreateExp(boost::program_options::variables_map &vm, bool newExp)
FIELD_UTILS_EXPORT LibUtilities::FieldIOSharedPtr FieldIOForFile(std::string filename)
Construct a FieldIO object for the file filename.
LibUtilities::FieldMetaDataMap m_fieldMetaDataMap