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"))
264 m_exp.resize(nfields * nstrips);
266 for (
size_t s = 0; s < nstrips; ++s)
268 for (i = 0; i < nfields; ++i)
273 if (!
m_exp[s * nfields + i])
275 m_exp[s * nfields + i] =
283 m_exp[s * nfields + i] =
288 m_exp[s * nfields + i] =
301 size_t i, j, nfields, nstrips;
302 m_session->LoadParameter(
"Strip_Z", nstrips, 1);
303 std::vector<std::string> vars =
m_session->GetVariables();
308 for (
size_t s = 0; s < nstrips; ++s)
310 for (j = 0; j < nfields; ++j)
312 for (i = 0; i <
m_data.size() / nstrips; ++i)
314 size_t n = i * nstrips + s;
322 m_exp[s * nfields + j]->ExtractDataToCoeffs(
324 m_exp[s * nfields + j]->UpdateCoeffs());
327 m_exp[s * nfields + j]->BwdTrans(
328 m_exp[s * nfields + j]->GetCoeffs(),
329 m_exp[s * nfields + j]->UpdatePhys());
335 m_fielddef = std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
336 m_data = std::vector<std::vector<NekDouble>>();
340 int NumHomogeneousDir,
bool fldfilegiven =
false)
346 int expdim =
m_graph->GetMeshDimension();
347 bool dealiasing =
false;
356 "Quasi-3D approach is only set up for 1 or 2 "
357 "homogeneous directions");
359 if (NumHomogeneousDir == 1)
376 m_session->LoadParameter(
"HomModesZ", nplanes);
391 ASSERTL0(
false,
"ContFieldHomogeneous1D or "
392 "DisContFieldHomogenenous1D has "
393 "not been implemented");
403 else if (NumHomogeneousDir == 2)
407 int nylines, nzlines;
422 m_session->LoadParameter(
"HomModesY", nylines);
423 m_session->LoadParameter(
"HomModesZ", nzlines);
444 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
453 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
462 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
502 "NumHomogeneousDir is only set up for 1");
504 if (NumHomogeneousDir == 1)
539 m_session->LoadParameter(
"HomModesZ", nplanes);
574 dealiasing,
m_graph,
"DefaultVar",
640 ASSERTL0(
false,
"Expansion dimension not recognised");
659 std::string filename)
664 auto it =
m_fld.find(fmt);
666 if (it ==
m_fld.end())
680 int NumHomogeneousDir, std::string var =
"DefaultVar",
681 bool NewField =
false)
691 switch (
m_graph->GetMeshDimension())
695 if (NumHomogeneousDir == 1)
699 "ContFieldHomogeneous1D or "
700 "DisContFieldHomogenenous1D has not been "
704 std::dynamic_pointer_cast<
710 else if (NumHomogeneousDir == 2)
715 std::dynamic_pointer_cast<
721 AllocateSharedPtr(*tmp2);
726 tmp2 = std::dynamic_pointer_cast<
732 AllocateSharedPtr(*tmp2);
737 std::dynamic_pointer_cast<
742 AllocateSharedPtr(*tmp2);
750 std::dynamic_pointer_cast<MultiRegions::ContField>(
761 std::dynamic_pointer_cast<
771 std::dynamic_pointer_cast<MultiRegions::ExpList>(
782 if (NumHomogeneousDir == 1)
788 bool dealiasing =
false;
794 ->GetHomogeneousBasis()
796 m_exp[0]->GetHomoLen(),
804 tmp2 = std::dynamic_pointer_cast<
808 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
811 AllocateSharedPtr(*tmp2,
m_graph, var);
818 bool dealiasing =
false;
824 ->GetHomogeneousBasis()
826 m_exp[0]->GetHomoLen(),
834 tmp2 = std::dynamic_pointer_cast<
837 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
841 AllocateSharedPtr(*tmp2);
848 bool dealiasing =
false;
854 ->GetHomogeneousBasis()
856 m_exp[0]->GetHomoLen(),
864 std::dynamic_pointer_cast<
867 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
871 AllocateSharedPtr(*tmp2);
890 std::dynamic_pointer_cast<
909 std::dynamic_pointer_cast<
919 std::dynamic_pointer_cast<MultiRegions::ExpList>(
942 std::dynamic_pointer_cast<MultiRegions::ContField>(
962 std::dynamic_pointer_cast<
972 std::dynamic_pointer_cast<MultiRegions::ExpList>(
982 ASSERTL0(
false,
"Expansion dimension not recognised");
995 m_fielddef = std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
996 m_data = std::vector<std::vector<NekDouble>>();
1005 m_exp.resize(exp.size());
1008 if (exp.size() == 0)
1017 for (
int i = 0; i < exp.size(); ++i)
1027 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
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
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