38 #include <boost/core/ignore_unused.hpp>
39 #include <boost/geometry.hpp>
40 #include <boost/math/special_functions/fpclassify.hpp>
52 namespace bg = boost::geometry;
53 namespace bgi = boost::geometry::index;
60 ModuleKey ProcessInterpPointDataToFld::className =
63 ProcessInterpPointDataToFld::create,
64 "Interpolates given discrete data using a finite difference "
65 "approximation to a fld file given a xml file");
71 false,
"NotSet",
"Pts file from which to interpolate field");
74 ConfigOption(
false,
"-1",
"coordinate id to use for interpolation");
89 "ProcessInterpPointDataToFld requires frompts parameter");
90 string inFile =
m_config[
"frompts"].as<
string>().c_str();
92 int totpoints =
m_f->m_exp[0]->GetTotPoints();
95 for (
int i = 0; i < 3; ++i)
99 m_f->m_exp[0]->GetCoords(intFields[0], intFields[1], intFields[2]);
101 if (boost::filesystem::path(inFile).extension() ==
".pts")
106 ptsIO->Import(inFile, fieldPts);
108 else if (boost::filesystem::path(inFile).extension() ==
".csv")
117 vmax = intFields[0][
Vmath::Imax(totpoints, intFields[0], 1)];
118 vmin = intFields[0][
Vmath::Imin(totpoints, intFields[0], 1)];
119 Range->m_xmax = (vmax - vmin) * margin + vmax;
120 Range->m_xmin = -(vmax - vmin) * margin + vmin;
122 vmax = intFields[1][
Vmath::Imax(totpoints, intFields[1], 1)];
123 vmin = intFields[1][
Vmath::Imin(totpoints, intFields[1], 1)];
124 Range->m_ymax = (vmax - vmin) * margin + vmax;
125 Range->m_ymin = -(vmax - vmin) * margin + vmin;
127 vmax = intFields[2][
Vmath::Imax(totpoints, intFields[2], 1)];
128 vmin = intFields[2][
Vmath::Imin(totpoints, intFields[2], 1)];
129 Range->m_zmax = (vmax - vmin) * margin + vmax;
130 Range->m_zmin = -(vmax - vmin) * margin + vmin;
137 ASSERTL0(
false,
"unknown frompts file type");
140 int nFields = fieldPts->GetNFields();
141 ASSERTL0(nFields > 0,
"No field values provided in input");
145 m_f->m_numHomogeneousDir == 0,
146 "ProcessInterpPointDataToFld does not support homogeneous expansion");
148 m_f->m_exp.resize(nFields);
149 for (i = 1; i < nFields; ++i)
151 m_f->m_exp[i] =
m_f->AppendExpList(
m_f->m_numHomogeneousDir);
156 for (
int i = 0; i < 3; ++i)
158 intFields1[i] = intFields[i];
162 for (
int i = 3; i < 3 + nFields; ++i)
170 int coord_id =
m_config[
"interpcoord"].as<
int>();
171 ASSERTL0(coord_id <=
static_cast<int>(outPts->GetDim()) - 1,
172 "interpcoord is bigger than the Pts files dimension");
177 if (
m_f->m_verbose &&
m_f->m_comm->TreatAsRankZero())
183 if (
m_f->m_verbose &&
m_f->m_comm->TreatAsRankZero())
188 for (i = 0; i < totpoints; ++i)
190 for (j = 0; j < nFields; ++j)
192 m_f->m_exp[j]->SetPhys(i, outPts->GetPointVal(3 + j, i));
196 for (i = 0; i < nFields; ++i)
198 m_f->m_exp[i]->FwdTransLocalElmt(
m_f->m_exp[i]->GetPhys(),
199 m_f->m_exp[i]->UpdateCoeffs());
203 for (
int j = 0; j < fieldPts->GetNFields(); ++j)
205 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 T expInField, T &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 ~ProcessInterpPointDataToFld()
virtual void v_Process(po::variables_map &vm) override
Write mesh to output file.
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.