35#ifndef FIELDUTILS_FIELD
36#define FIELDUTILS_FIELD
44#include <boost/program_options.hpp>
55namespace po = boost::program_options;
73 std::vector<LibUtilities::FieldDefinitionsSharedPtr>
m_fielddef;
74 std::vector<std::vector<double>>
m_data;
75 std::vector<MultiRegions::ExpListSharedPtr>
m_exp;
107 bool equispaced =
false)
120 bool newExp,
bool equispaced =
false)
129 if (
m_comm->TreatAsRankZero())
138 fldfilegiven && !vm.count(
"use-session-expansion");
152 if (
m_session->DefinesSolverInfo(
"HOMOGENEOUS"))
154 std::string HomoStr =
157 if ((HomoStr ==
"HOMOGENEOUS1D") ||
158 (HomoStr ==
"Homogeneous1D") || (HomoStr ==
"1D") ||
159 (HomoStr ==
"Homo1D"))
163 if ((HomoStr ==
"HOMOGENEOUS2D") ||
164 (HomoStr ==
"Homogeneous2D") || (HomoStr ==
"2D") ||
165 (HomoStr ==
"Homo2D"))
174 std::vector<int> IDs;
175 auto domain =
m_graph->GetDomain();
176 for (
size_t d = 0; d < domain.size(); ++d)
178 for (
auto &compIter : domain[d])
180 for (
auto &x : compIter.second->m_geomVec)
182 IDs.push_back(x->GetGlobalID());
199 if (vm.count(
"output-points"))
201 nPointsNew = vm[
"output-points"].as<
int>();
204 m_graph->SetExpansionInfoToPointOrder(nPointsNew);
209 m_graph->SetExpansionInfoToEvenlySpacedPoints(nPointsNew);
214 if (
m_comm->TreatAsRankZero())
219 std::stringstream ss;
220 ss << cpuTime <<
"s";
221 std::cout <<
"\t CreateExp setexpansion CPU Time: "
222 << std::setw(8) << std::left << ss.str()
230 int expdim =
m_graph->GetMeshDimension();
232 vm[
"output-points-hom-z"].as<
int>();
237 if (
m_comm->TreatAsRankZero())
242 std::stringstream ss1;
244 ss1 << cpuTime <<
"s";
245 std::cout <<
"\t CreateExp set first exp CPU Time: "
246 << std::setw(8) << std::left << ss1.str()
254 size_t i, nfields, nstrips;
255 m_session->LoadParameter(
"Strip_Z", nstrips, 1);
256 std::vector<std::string> vars =
m_session->GetVariables();
258 if (vm.count(
"use-session-variables"))
270 if (vars.empty() && !vm.count(
"use-session-expansion"))
277 m_exp.resize(nfields * nstrips);
279 for (
size_t s = 0; s < nstrips; ++s)
281 for (i = 0; i < nfields; ++i)
286 if (!
m_exp[s * nfields + i])
288 m_exp[s * nfields + i] =
296 m_exp[s * nfields + i] =
301 m_exp[s * nfields + i] =
314 size_t i, j, nfields, nstrips;
315 m_session->LoadParameter(
"Strip_Z", nstrips, 1);
316 std::vector<std::string> vars =
m_session->GetVariables();
321 for (
size_t s = 0; s < nstrips; ++s)
323 for (j = 0; j < nfields; ++j)
325 for (i = 0; i <
m_data.size() / nstrips; ++i)
327 size_t n = i * nstrips + s;
335 m_exp[s * nfields + j]->ExtractDataToCoeffs(
337 m_exp[s * nfields + j]->UpdateCoeffs());
340 m_exp[s * nfields + j]->BwdTrans(
341 m_exp[s * nfields + j]->GetCoeffs(),
342 m_exp[s * nfields + j]->UpdatePhys());
348 m_fielddef = std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
349 m_data = std::vector<std::vector<NekDouble>>();
374 int NumHomogeneousDir,
bool fldfilegiven =
false)
381 int expdim =
m_graph->GetMeshDimension();
382 bool dealiasing =
false;
391 "Quasi-3D approach is only set up for 1 or 2 "
392 "homogeneous directions");
394 if (NumHomogeneousDir == 1)
411 m_session->LoadParameter(
"HomModesZ", nplanes);
426 ASSERTL0(
false,
"ContFieldHomogeneous1D or "
427 "DisContFieldHomogenenous1D has "
428 "not been implemented");
438 else if (NumHomogeneousDir == 2)
442 int nylines, nzlines;
457 m_session->LoadParameter(
"HomModesY", nylines);
458 m_session->LoadParameter(
"HomModesZ", nzlines);
479 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
488 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
497 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
537 "NumHomogeneousDir is only set up for 1");
539 if (NumHomogeneousDir == 1)
574 m_session->LoadParameter(
"HomModesZ", nplanes);
609 dealiasing,
m_graph, defaultVar,
675 ASSERTL0(
false,
"Expansion dimension not recognised");
694 std::string filename)
699 auto it =
m_fld.find(fmt);
701 if (it ==
m_fld.end())
715 int NumHomogeneousDir, std::string var =
"DefaultVar",
716 bool NewField =
false)
726 switch (
m_graph->GetMeshDimension())
730 if (NumHomogeneousDir == 1)
734 "ContFieldHomogeneous1D or "
735 "DisContFieldHomogenenous1D has not been "
739 std::dynamic_pointer_cast<
745 else if (NumHomogeneousDir == 2)
750 std::dynamic_pointer_cast<
756 AllocateSharedPtr(*tmp2);
761 tmp2 = std::dynamic_pointer_cast<
767 AllocateSharedPtr(*tmp2);
772 std::dynamic_pointer_cast<
777 AllocateSharedPtr(*tmp2);
785 std::dynamic_pointer_cast<MultiRegions::ContField>(
796 std::dynamic_pointer_cast<
806 std::dynamic_pointer_cast<MultiRegions::ExpList>(
817 if (NumHomogeneousDir == 1)
823 bool dealiasing =
false;
829 ->GetHomogeneousBasis()
831 m_exp[0]->GetHomoLen(),
839 tmp2 = std::dynamic_pointer_cast<
843 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
846 AllocateSharedPtr(*tmp2,
m_graph, var);
853 bool dealiasing =
false;
859 ->GetHomogeneousBasis()
861 m_exp[0]->GetHomoLen(),
869 tmp2 = std::dynamic_pointer_cast<
872 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
876 AllocateSharedPtr(*tmp2);
883 bool dealiasing =
false;
889 ->GetHomogeneousBasis()
891 m_exp[0]->GetHomoLen(),
899 std::dynamic_pointer_cast<
902 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
906 AllocateSharedPtr(*tmp2);
925 std::dynamic_pointer_cast<
944 std::dynamic_pointer_cast<
954 std::dynamic_pointer_cast<MultiRegions::ExpList>(
977 std::dynamic_pointer_cast<MultiRegions::ContField>(
997 std::dynamic_pointer_cast<
1007 std::dynamic_pointer_cast<MultiRegions::ExpList>(
1017 ASSERTL0(
false,
"Expansion dimension not recognised");
1030 m_fielddef = std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
1031 m_data = std::vector<std::vector<NekDouble>>();
1040 m_exp.resize(exp.size());
1043 if (exp.size() == 0)
1052 for (
int i = 0; i < exp.size(); ++i)
1062 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.
tBasePtr 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
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
FIELD_UTILS_EXPORT ~Field()=default
bool m_declareExpansionAsDisContField
SpatialDomains::MeshGraphSharedPtr m_graph
std::vector< std::string > m_variables
std::vector< unsigned int > m_bndRegionsToWrite
LibUtilities::SessionReaderSharedPtr m_session
FIELD_UTILS_EXPORT std::string GetDefaultVar(bool fldfilegiven)
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 SetUpExp(boost::program_options::variables_map &vm, bool equispaced=false)
FIELD_UTILS_EXPORT void ClearField()
std::vector< LibUtilities::FieldDefinitionsSharedPtr > m_fielddef
FIELD_UTILS_EXPORT void CreateExp(boost::program_options::variables_map &vm, bool newExp, bool equispaced=false)
LibUtilities::PtsFieldSharedPtr m_fieldPts
std::vector< std::vector< double > > m_data
std::vector< MultiRegions::ExpListSharedPtr > m_exp
LibUtilities::CommSharedPtr m_comm
LibUtilities::CommSharedPtr m_defComm
FIELD_UTILS_EXPORT LibUtilities::FieldIOSharedPtr FieldIOForFile(std::string filename)
Construct a FieldIO object for the file filename.
LibUtilities::FieldMetaDataMap m_fieldMetaDataMap