35 #ifndef FIELDUTILS_FIELD
36 #define FIELDUTILS_FIELD
40 #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;
133 if (
m_comm->TreatAsRankZero())
141 bool expFromFld = fldfilegiven && !vm.count(
"useSessionExpansion");
155 if (
m_session->DefinesSolverInfo(
"HOMOGENEOUS"))
157 std::string HomoStr =
160 if ((HomoStr ==
"HOMOGENEOUS1D") ||
161 (HomoStr ==
"Homogeneous1D") ||
162 (HomoStr ==
"1D") || (HomoStr ==
"Homo1D"))
166 if ((HomoStr ==
"HOMOGENEOUS2D") ||
167 (HomoStr ==
"Homogeneous2D") ||
168 (HomoStr ==
"2D") || (HomoStr ==
"Homo2D"))
177 std::vector<int> IDs;
178 auto domain =
m_graph->GetDomain();
179 for(
int d = 0; d < domain.size(); ++d)
181 for (
auto &compIter : domain[d])
183 for (
auto &x : compIter.second->m_geomVec)
185 IDs.push_back(x->GetGlobalID());
200 if (vm.count(
"output-points"))
202 int nPointsNew = vm[
"output-points"].as<
int>();
203 m_graph->SetExpansionInfoToPointOrder(nPointsNew);
208 if (
m_comm->TreatAsRankZero())
213 std::stringstream ss;
214 ss << cpuTime <<
"s";
215 std::cout <<
"\t CreateExp setexpansion CPU Time: "
216 << std::setw(8) << std::left
217 << ss.str() << std::endl;
224 int expdim =
m_graph->GetMeshDimension();
226 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
243 << ss1.str() << std::endl;
250 int 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(
"useSessionVariables"))
260 m_exp.resize(nfields * nstrips);
262 for (
int s = 0; s < nstrips; ++s)
264 for (i = 0; i < nfields; ++i)
269 if (!
m_exp[s * nfields + i])
294 for (
int s = 0; s < nstrips; ++s)
296 for (j = 0; j < nfields; ++j)
298 for (i = 0; i <
m_data.size() / nstrips; ++i)
300 int n = i * nstrips + s;
308 m_exp[s * nfields + j]->ExtractDataToCoeffs(
312 m_exp[s * nfields + j]->UpdateCoeffs());
315 m_exp[s * nfields + j]->BwdTrans
316 (
m_exp[s * nfields + j]->GetCoeffs(),
317 m_exp[s * nfields + j]->UpdatePhys());
322 m_fielddef = std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
323 m_data = std::vector<std::vector<NekDouble> >();
329 int NumHomogeneousDir,
bool fldfilegiven =
false)
335 int expdim =
m_graph->GetMeshDimension();
336 bool dealiasing =
false;
345 "Quasi-3D approach is only set up for 1 or 2 "
346 "homogeneous directions");
348 if (NumHomogeneousDir == 1)
365 m_session->LoadParameter(
"HomModesZ", nplanes);
380 ASSERTL0(
false,
"ContFieldHomogeneous1D or "
381 "DisContFieldHomogenenous1D has "
382 "not been implemented");
392 else if (NumHomogeneousDir == 2)
396 int nylines, nzlines;
411 m_session->LoadParameter(
"HomModesY", nylines);
412 m_session->LoadParameter(
"HomModesZ", nzlines);
433 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
442 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
451 AllocateSharedPtr(
m_session, BkeyY, BkeyZ, ly, lz,
493 "NumHomogeneousDir is only set up for 1");
495 if (NumHomogeneousDir == 1)
530 m_session->LoadParameter(
"HomModesZ", nplanes);
641 ASSERTL0(
false,
"Expansion dimension not recognised");
660 std::string filename)
665 auto it =
m_fld.find(fmt);
667 if (it ==
m_fld.end())
681 int NumHomogeneousDir,
682 std::string var =
"DefaultVar",
683 bool NewField =
false)
693 switch (
m_graph->GetMeshDimension())
697 if (NumHomogeneousDir == 1)
701 "ContFieldHomogeneous1D or "
702 "DisContFieldHomogenenous1D has not been "
706 std::dynamic_pointer_cast<
712 else if (NumHomogeneousDir == 2)
717 std::dynamic_pointer_cast<
723 AllocateSharedPtr(*tmp2);
728 tmp2 = std::dynamic_pointer_cast<
734 AllocateSharedPtr(*tmp2);
739 std::dynamic_pointer_cast<
744 AllocateSharedPtr(*tmp2);
752 std::dynamic_pointer_cast<
761 std::dynamic_pointer_cast<
770 std::dynamic_pointer_cast<
781 if (NumHomogeneousDir == 1)
787 bool dealiasing =
false;
793 ->GetHomogeneousBasis()
801 tmp2 = std::dynamic_pointer_cast<
805 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
808 AllocateSharedPtr(*tmp2,
m_graph, var);
815 bool dealiasing =
false;
821 ->GetHomogeneousBasis()
829 tmp2 = std::dynamic_pointer_cast<
832 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
836 AllocateSharedPtr(*tmp2);
843 bool dealiasing =
false;
849 ->GetHomogeneousBasis()
857 std::dynamic_pointer_cast<
860 ASSERTL0(tmp2,
"Failed to type cast m_exp[0]");
864 AllocateSharedPtr(*tmp2);
881 std::dynamic_pointer_cast<
898 std::dynamic_pointer_cast<
908 std::dynamic_pointer_cast<
929 std::dynamic_pointer_cast<
946 std::dynamic_pointer_cast<
956 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