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();
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;
136 ASSERTL0(
false,
"unknown frompts file type");
139 int nFields = fieldPts->GetNFields();
140 ASSERTL0(nFields > 0,
"No field values provided in input");
144 "ProcessInterpPointDataToFld does not support homogeneous expansion");
146 m_f->m_exp.resize(nFields);
147 for (i = 1; i < nFields; ++i)
149 m_f->m_exp[i] =
m_f->AppendExpList(
m_f->m_numHomogeneousDir);
154 for (
int i = 0; i < 3; ++i)
156 intFields1[i] = intFields[i];
160 for (
int i = 3; i < 3 + nFields; ++i)
168 int coord_id =
m_config[
"interpcoord"].as<
int>();
169 ASSERTL0(coord_id <=
static_cast<int>(outPts->GetDim()) - 1,
170 "interpcoord is bigger than the Pts files dimension");
174 if (
m_f->m_verbose &&
m_f->m_comm->TreatAsRankZero())
180 if (
m_f->m_verbose &&
m_f->m_comm->TreatAsRankZero())
185 for (i = 0; i < totpoints; ++i)
187 for (j = 0; j < nFields; ++j)
189 m_f->m_exp[j]->SetPhys(i, outPts->GetPointVal(3 + j, i));
194 for (i = 0; i < nFields; ++i)
196 m_f->m_exp[i]->FwdTrans_IterPerExp(
m_f->m_exp[i]->GetPhys(),
197 m_f->m_exp[i]->UpdateCoeffs());
201 for (
int j = 0; j < fieldPts->GetNFields(); ++j)
203 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.