39 #include <boost/core/ignore_unused.hpp>
40 #include <boost/geometry.hpp>
41 #include <boost/math/special_functions/fpclassify.hpp>
51 namespace bg = boost::geometry;
52 namespace bgi = boost::geometry::index;
59 ModuleKey ProcessInterpPointDataToFld::className =
62 ProcessInterpPointDataToFld::create,
63 "Interpolates given discrete data using a finite difference "
64 "approximation to a fld file given a xml file");
70 false,
"NotSet",
"Pts file from which to interpolate field");
73 ConfigOption(
false,
"-1",
"coordinate id to use for interpolation");
88 "ProcessInterpPointDataToFld requires frompts parameter");
89 string inFile =
m_config[
"frompts"].as<
string>().c_str();
91 int totpoints =
m_f->m_exp[0]->GetTotPoints();
94 for (
int i = 0; i < 3; ++i)
98 m_f->m_exp[0]->GetCoords(intFields[0], intFields[1], intFields[2]);
100 if (boost::filesystem::path(inFile).extension() ==
".pts")
105 ptsIO->Import(inFile, fieldPts);
107 else if (boost::filesystem::path(inFile).extension() ==
".csv")
116 vmax = intFields[0][
Vmath::Imax(totpoints, intFields[0], 1)];
117 vmin = intFields[0][
Vmath::Imin(totpoints, intFields[0], 1)];
118 Range->m_xmax = (vmax - vmin) * margin + vmax;
119 Range->m_xmin = -(vmax - vmin) * margin + vmin;
121 vmax = intFields[1][
Vmath::Imax(totpoints, intFields[1], 1)];
122 vmin = intFields[1][
Vmath::Imin(totpoints, intFields[1], 1)];
123 Range->m_ymax = (vmax - vmin) * margin + vmax;
124 Range->m_ymin = -(vmax - vmin) * margin + vmin;
126 vmax = intFields[2][
Vmath::Imax(totpoints, intFields[2], 1)];
127 vmin = intFields[2][
Vmath::Imin(totpoints, intFields[2], 1)];
128 Range->m_zmax = (vmax - vmin) * margin + vmax;
129 Range->m_zmin = -(vmax - vmin) * margin + vmin;
136 ASSERTL0(
false,
"unknown frompts file type");
139 int nFields = fieldPts->GetNFields();
140 ASSERTL0(nFields > 0,
"No field values provided in input");
144 m_f->m_numHomogeneousDir == 0,
145 "ProcessInterpPointDataToFld does not support homogeneous expansion");
147 m_f->m_exp.resize(nFields);
148 for (i = 1; i < nFields; ++i)
150 m_f->m_exp[i] =
m_f->AppendExpList(
m_f->m_numHomogeneousDir);
155 for (
int i = 0; i < 3; ++i)
157 intFields1[i] = intFields[i];
161 for (
int i = 3; i < 3 + nFields; ++i)
169 int coord_id =
m_config[
"interpcoord"].as<
int>();
170 ASSERTL0(coord_id <=
static_cast<int>(outPts->GetDim()) - 1,
171 "interpcoord is bigger than the Pts files dimension");
175 if (
m_f->m_verbose &&
m_f->m_comm->TreatAsRankZero())
181 if (
m_f->m_verbose &&
m_f->m_comm->TreatAsRankZero())
186 for (i = 0; i < totpoints; ++i)
188 for (j = 0; j < nFields; ++j)
190 m_f->m_exp[j]->SetPhys(i, outPts->GetPointVal(3 + j, i));
195 for (i = 0; i < nFields; ++i)
197 m_f->m_exp[i]->FwdTransLocalElmt(
m_f->m_exp[i]->GetPhys(),
198 m_f->m_exp[i]->UpdateCoeffs());
202 for (
int j = 0; j < fieldPts->GetNFields(); ++j)
204 m_f->m_variables.push_back(fieldPts->GetFieldName(j));
#define ASSERTL0(condition, msg)
A class that contains algorithms for interpolation between pts fields, expansions and different meshe...
FIELD_UTILS_EXPORT void Interpolate(const std::vector< MultiRegions::ExpListSharedPtr > expInField, std::vector< MultiRegions::ExpListSharedPtr > &expOutField, NekDouble def_value=0.0)
Interpolate from an expansion to an expansion.
FieldSharedPtr m_f
Field object.
std::map< std::string, ConfigOption > m_config
List of configuration values.
virtual void Process(po::variables_map &vm)
Write mesh to output file.
virtual ~ProcessInterpPointDataToFld()
void PrintProgressbar(const int position, const int goal) const
Abstract base class for processing modules.
void SetProgressCallback(FuncPointerT func, ObjectPointerT obj)
sets a callback funtion which gets called every time the interpolation progresses
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< Field > FieldSharedPtr
std::pair< ModuleType, std::string > ModuleKey
ModuleFactory & GetModuleFactory()
static FieldMetaDataMap NullFieldMetaDataMap
std::shared_ptr< PtsField > PtsFieldSharedPtr
std::shared_ptr< DomainRange > DomainRangeShPtr
std::shared_ptr< CsvIO > CsvIOSharedPtr
std::shared_ptr< PtsIO > PtsIOSharedPtr
The above copyright notice and this permission notice shall be included.
int Imax(int n, const T *x, const int incx)
Return the index of the maximum element in x.
int Imin(int n, const T *x, const int incx)
Return the index of the minimum element in x.
Represents a command-line configuration option.