35 #ifndef FIELDUTILS_FIELD
36 #define FIELDUTILS_FIELD
44 #include <boost/program_options.hpp>
55 namespace 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;
134 if (
m_comm->TreatAsRankZero())
142 bool expFromFld = fldfilegiven && !vm.count(
"useSessionExpansion");
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 (
int 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());
201 if (vm.count(
"output-points"))
203 int nPointsNew = vm[
"output-points"].as<
int>();
204 m_graph->SetExpansionInfoToPointOrder(nPointsNew);
209 if (
m_comm->TreatAsRankZero())
214 std::stringstream ss;
215 ss << cpuTime <<
"s";
216 std::cout <<
"\t CreateExp setexpansion CPU Time: "
217 << std::setw(8) << std::left << ss.str()
225 int expdim =
m_graph->GetMeshDimension();
227 vm[
"output-points-hom-z"].as<
int>();
232 if (
m_comm->TreatAsRankZero())
237 std::stringstream ss1;
239 ss1 << cpuTime <<
"s";
240 std::cout <<
"\t CreateExp set first exp CPU Time: "
241 << std::setw(8) << std::left << ss1.str()
249 int i, j, nfields, nstrips;
250 m_session->LoadParameter(
"Strip_Z", nstrips, 1);
251 std::vector<std::string> vars =
m_session->GetVariables();
253 if (vm.count(
"useSessionVariables"))
259 m_exp.resize(nfields * nstrips);
261 for (
int s = 0; s < nstrips; ++s)
263 for (i = 0; i < nfields; ++i)
268 if (!
m_exp[s * nfields + i])
270 m_exp[s * nfields + i] =
278 m_exp[s * nfields + i] =
283 m_exp[s * nfields + i] =
291 for (
int s = 0; s < nstrips; ++s)
293 for (j = 0; j < nfields; ++j)
295 for (i = 0; i <
m_data.size() / nstrips; ++i)
297 int n = i * nstrips + s;
305 m_exp[s * nfields + j]->ExtractDataToCoeffs(
307 m_exp[s * nfields + j]->UpdateCoeffs());
310 m_exp[s * nfields + j]->BwdTrans(
311 m_exp[s * nfields + j]->GetCoeffs(),
312 m_exp[s * nfields + j]->UpdatePhys());
317 m_fielddef = std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
318 m_data = std::vector<std::vector<NekDouble>>();
323 int NumHomogeneousDir,
bool fldfilegiven =
false)
329 int expdim =
m_graph->GetMeshDimension();
330 bool dealiasing =
false;
339 "Quasi-3D approach is only set up for 1 or 2 "
340 "homogeneous directions");
342 if (NumHomogeneousDir == 1)
359 m_session->LoadParameter(
"HomModesZ", nplanes);
374 ASSERTL0(
false,
"ContFieldHomogeneous1D or "
375 "DisContFieldHomogenenous1D has "
376 "not been implemented");
386 else if (NumHomogeneousDir == 2)
390 int nylines, nzlines;
405 m_session->LoadParameter(
"HomModesY", nylines);
406 m_session->LoadParameter(
"HomModesZ", nzlines);
427 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
436 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
445 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
485 "NumHomogeneousDir is only set up for 1");
487 if (NumHomogeneousDir == 1)
522 m_session->LoadParameter(
"HomModesZ", nplanes);
557 dealiasing,
m_graph,
"DefaultVar",
623 ASSERTL0(
false,
"Expansion dimension not recognised");
642 std::string filename)
647 auto it =
m_fld.find(fmt);
649 if (it ==
m_fld.end())
663 int NumHomogeneousDir, std::string var =
"DefaultVar",
664 bool NewField =
false)
674 switch (
m_graph->GetMeshDimension())
678 if (NumHomogeneousDir == 1)
682 "ContFieldHomogeneous1D or "
683 "DisContFieldHomogenenous1D has not been "
687 std::dynamic_pointer_cast<
693 else if (NumHomogeneousDir == 2)
698 std::dynamic_pointer_cast<
704 AllocateSharedPtr(*tmp2);
709 tmp2 = std::dynamic_pointer_cast<
715 AllocateSharedPtr(*tmp2);
720 std::dynamic_pointer_cast<
725 AllocateSharedPtr(*tmp2);
733 std::dynamic_pointer_cast<MultiRegions::ContField>(
744 std::dynamic_pointer_cast<
754 std::dynamic_pointer_cast<MultiRegions::ExpList>(
765 if (NumHomogeneousDir == 1)
771 bool dealiasing =
false;
777 ->GetHomogeneousBasis()
779 m_exp[0]->GetHomoLen(),
787 tmp2 = std::dynamic_pointer_cast<
791 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
794 AllocateSharedPtr(*tmp2,
m_graph, var);
801 bool dealiasing =
false;
807 ->GetHomogeneousBasis()
809 m_exp[0]->GetHomoLen(),
817 tmp2 = std::dynamic_pointer_cast<
820 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
824 AllocateSharedPtr(*tmp2);
831 bool dealiasing =
false;
837 ->GetHomogeneousBasis()
839 m_exp[0]->GetHomoLen(),
847 std::dynamic_pointer_cast<
850 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
854 AllocateSharedPtr(*tmp2);
873 std::dynamic_pointer_cast<
892 std::dynamic_pointer_cast<
902 std::dynamic_pointer_cast<MultiRegions::ExpList>(
925 std::dynamic_pointer_cast<MultiRegions::ContField>(
945 std::dynamic_pointer_cast<
955 std::dynamic_pointer_cast<MultiRegions::ExpList>(
965 ASSERTL0(
false,
"Expansion dimension not recognised");
978 m_fielddef = std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
979 m_data = std::vector<std::vector<NekDouble>>();
986 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)
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