35#ifndef FIELDUTILS_FIELD
36#define FIELDUTILS_FIELD
44#include <boost/program_options.hpp>
55namespace po = boost::program_options;
80 std::vector<LibUtilities::FieldDefinitionsSharedPtr>
m_fielddef;
81 std::vector<std::vector<double>>
m_data;
82 std::vector<MultiRegions::ExpListSharedPtr>
m_exp;
135 if (
m_comm->TreatAsRankZero())
143 bool expFromFld = fldfilegiven && !vm.count(
"useSessionExpansion");
157 if (
m_session->DefinesSolverInfo(
"HOMOGENEOUS"))
159 std::string HomoStr =
162 if ((HomoStr ==
"HOMOGENEOUS1D") ||
163 (HomoStr ==
"Homogeneous1D") || (HomoStr ==
"1D") ||
164 (HomoStr ==
"Homo1D"))
168 if ((HomoStr ==
"HOMOGENEOUS2D") ||
169 (HomoStr ==
"Homogeneous2D") || (HomoStr ==
"2D") ||
170 (HomoStr ==
"Homo2D"))
179 std::vector<int> IDs;
180 auto domain =
m_graph->GetDomain();
181 for (
size_t d = 0;
d < domain.size(); ++
d)
183 for (
auto &compIter : domain[
d])
185 for (
auto &x : compIter.second->m_geomVec)
187 IDs.push_back(x->GetGlobalID());
203 if (vm.count(
"output-points"))
205 int nPointsNew = vm[
"output-points"].as<
int>();
206 m_graph->SetExpansionInfoToPointOrder(nPointsNew);
211 if (
m_comm->TreatAsRankZero())
216 std::stringstream ss;
217 ss << cpuTime <<
"s";
218 std::cout <<
"\t CreateExp setexpansion CPU Time: "
219 << std::setw(8) << std::left << ss.str()
227 int expdim =
m_graph->GetMeshDimension();
229 vm[
"output-points-hom-z"].as<
int>();
234 if (
m_comm->TreatAsRankZero())
239 std::stringstream ss1;
241 ss1 << cpuTime <<
"s";
242 std::cout <<
"\t CreateExp set first exp CPU Time: "
243 << std::setw(8) << std::left << ss1.str()
251 size_t i, j, nfields, nstrips;
252 m_session->LoadParameter(
"Strip_Z", nstrips, 1);
253 std::vector<std::string> vars =
m_session->GetVariables();
255 if (vm.count(
"useSessionVariables"))
261 m_exp.resize(nfields * nstrips);
263 for (
size_t s = 0; s < nstrips; ++s)
265 for (i = 0; i < nfields; ++i)
270 if (!
m_exp[s * nfields + i])
272 m_exp[s * nfields + i] =
280 m_exp[s * nfields + i] =
285 m_exp[s * nfields + i] =
293 for (
size_t s = 0; s < nstrips; ++s)
295 for (j = 0; j < nfields; ++j)
297 for (i = 0; i <
m_data.size() / nstrips; ++i)
299 size_t n = i * nstrips + s;
307 m_exp[s * nfields + j]->ExtractDataToCoeffs(
309 m_exp[s * nfields + j]->UpdateCoeffs());
312 m_exp[s * nfields + j]->BwdTrans(
313 m_exp[s * nfields + j]->GetCoeffs(),
314 m_exp[s * nfields + j]->UpdatePhys());
319 m_fielddef = std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
320 m_data = std::vector<std::vector<NekDouble>>();
325 int NumHomogeneousDir,
bool fldfilegiven =
false)
331 int expdim =
m_graph->GetMeshDimension();
332 bool dealiasing =
false;
341 "Quasi-3D approach is only set up for 1 or 2 "
342 "homogeneous directions");
344 if (NumHomogeneousDir == 1)
361 m_session->LoadParameter(
"HomModesZ", nplanes);
376 ASSERTL0(
false,
"ContFieldHomogeneous1D or "
377 "DisContFieldHomogenenous1D has "
378 "not been implemented");
388 else if (NumHomogeneousDir == 2)
392 int nylines, nzlines;
407 m_session->LoadParameter(
"HomModesY", nylines);
408 m_session->LoadParameter(
"HomModesZ", nzlines);
429 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
438 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
447 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
487 "NumHomogeneousDir is only set up for 1");
489 if (NumHomogeneousDir == 1)
524 m_session->LoadParameter(
"HomModesZ", nplanes);
559 dealiasing,
m_graph,
"DefaultVar",
625 ASSERTL0(
false,
"Expansion dimension not recognised");
644 std::string filename)
649 auto it =
m_fld.find(fmt);
651 if (it ==
m_fld.end())
665 int NumHomogeneousDir, std::string var =
"DefaultVar",
666 bool NewField =
false)
676 switch (
m_graph->GetMeshDimension())
680 if (NumHomogeneousDir == 1)
684 "ContFieldHomogeneous1D or "
685 "DisContFieldHomogenenous1D has not been "
689 std::dynamic_pointer_cast<
695 else if (NumHomogeneousDir == 2)
700 std::dynamic_pointer_cast<
706 AllocateSharedPtr(*tmp2);
711 tmp2 = std::dynamic_pointer_cast<
717 AllocateSharedPtr(*tmp2);
722 std::dynamic_pointer_cast<
727 AllocateSharedPtr(*tmp2);
735 std::dynamic_pointer_cast<MultiRegions::ContField>(
746 std::dynamic_pointer_cast<
756 std::dynamic_pointer_cast<MultiRegions::ExpList>(
767 if (NumHomogeneousDir == 1)
773 bool dealiasing =
false;
779 ->GetHomogeneousBasis()
781 m_exp[0]->GetHomoLen(),
789 tmp2 = std::dynamic_pointer_cast<
793 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
796 AllocateSharedPtr(*tmp2,
m_graph, var);
803 bool dealiasing =
false;
809 ->GetHomogeneousBasis()
811 m_exp[0]->GetHomoLen(),
819 tmp2 = std::dynamic_pointer_cast<
822 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
826 AllocateSharedPtr(*tmp2);
833 bool dealiasing =
false;
839 ->GetHomogeneousBasis()
841 m_exp[0]->GetHomoLen(),
849 std::dynamic_pointer_cast<
852 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
856 AllocateSharedPtr(*tmp2);
875 std::dynamic_pointer_cast<
894 std::dynamic_pointer_cast<
904 std::dynamic_pointer_cast<MultiRegions::ExpList>(
927 std::dynamic_pointer_cast<MultiRegions::ContField>(
947 std::dynamic_pointer_cast<
957 std::dynamic_pointer_cast<MultiRegions::ExpList>(
967 ASSERTL0(
false,
"Expansion dimension not recognised");
980 m_fielddef = std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
981 m_data = std::vector<std::vector<NekDouble>>();
988 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)
The above copyright notice and this permission notice shall be included.
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