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, j, 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] =
292 for (
size_t s = 0; s < nstrips; ++s)
294 for (j = 0; j < nfields; ++j)
296 for (i = 0; i <
m_data.size() / nstrips; ++i)
298 size_t n = i * nstrips + s;
306 m_exp[s * nfields + j]->ExtractDataToCoeffs(
308 m_exp[s * nfields + j]->UpdateCoeffs());
311 m_exp[s * nfields + j]->BwdTrans(
312 m_exp[s * nfields + j]->GetCoeffs(),
313 m_exp[s * nfields + j]->UpdatePhys());
318 m_fielddef = std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
319 m_data = std::vector<std::vector<NekDouble>>();
324 int NumHomogeneousDir,
bool fldfilegiven =
false)
330 int expdim =
m_graph->GetMeshDimension();
331 bool dealiasing =
false;
340 "Quasi-3D approach is only set up for 1 or 2 "
341 "homogeneous directions");
343 if (NumHomogeneousDir == 1)
360 m_session->LoadParameter(
"HomModesZ", nplanes);
375 ASSERTL0(
false,
"ContFieldHomogeneous1D or "
376 "DisContFieldHomogenenous1D has "
377 "not been implemented");
387 else if (NumHomogeneousDir == 2)
391 int nylines, nzlines;
406 m_session->LoadParameter(
"HomModesY", nylines);
407 m_session->LoadParameter(
"HomModesZ", nzlines);
428 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
437 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
446 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
486 "NumHomogeneousDir is only set up for 1");
488 if (NumHomogeneousDir == 1)
523 m_session->LoadParameter(
"HomModesZ", nplanes);
558 dealiasing,
m_graph,
"DefaultVar",
624 ASSERTL0(
false,
"Expansion dimension not recognised");
643 std::string filename)
648 auto it =
m_fld.find(fmt);
650 if (it ==
m_fld.end())
664 int NumHomogeneousDir, std::string var =
"DefaultVar",
665 bool NewField =
false)
675 switch (
m_graph->GetMeshDimension())
679 if (NumHomogeneousDir == 1)
683 "ContFieldHomogeneous1D or "
684 "DisContFieldHomogenenous1D has not been "
688 std::dynamic_pointer_cast<
694 else if (NumHomogeneousDir == 2)
699 std::dynamic_pointer_cast<
705 AllocateSharedPtr(*tmp2);
710 tmp2 = std::dynamic_pointer_cast<
716 AllocateSharedPtr(*tmp2);
721 std::dynamic_pointer_cast<
726 AllocateSharedPtr(*tmp2);
734 std::dynamic_pointer_cast<MultiRegions::ContField>(
745 std::dynamic_pointer_cast<
755 std::dynamic_pointer_cast<MultiRegions::ExpList>(
766 if (NumHomogeneousDir == 1)
772 bool dealiasing =
false;
778 ->GetHomogeneousBasis()
780 m_exp[0]->GetHomoLen(),
788 tmp2 = std::dynamic_pointer_cast<
792 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
795 AllocateSharedPtr(*tmp2,
m_graph, var);
802 bool dealiasing =
false;
808 ->GetHomogeneousBasis()
810 m_exp[0]->GetHomoLen(),
818 tmp2 = std::dynamic_pointer_cast<
821 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
825 AllocateSharedPtr(*tmp2);
832 bool dealiasing =
false;
838 ->GetHomogeneousBasis()
840 m_exp[0]->GetHomoLen(),
848 std::dynamic_pointer_cast<
851 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
855 AllocateSharedPtr(*tmp2);
874 std::dynamic_pointer_cast<
893 std::dynamic_pointer_cast<
903 std::dynamic_pointer_cast<MultiRegions::ExpList>(
926 std::dynamic_pointer_cast<MultiRegions::ContField>(
946 std::dynamic_pointer_cast<
956 std::dynamic_pointer_cast<MultiRegions::ExpList>(
966 ASSERTL0(
false,
"Expansion dimension not recognised");
979 m_fielddef = std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
980 m_data = std::vector<std::vector<NekDouble>>();
987 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)
LibUtilities::CommSharedPtr m_partComm
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