38#include <boost/geometry.hpp>
50namespace bg = boost::geometry;
51namespace bgi = boost::geometry::index;
60 "Interpolates given discrete data using a finite difference "
61 "approximation to a fld file given a xml file");
67 false,
"NotSet",
"Pts file from which to interpolate field");
70 ConfigOption(
false,
"-1",
"coordinate id to use for interpolation");
85 "ProcessInterpPointDataToFld requires frompts parameter");
86 string inFile =
m_config[
"frompts"].as<
string>().c_str();
88 int totpoints =
m_f->m_exp[0]->GetTotPoints();
91 for (
int i = 0; i < 3; ++i)
95 m_f->m_exp[0]->GetCoords(intFields[0], intFields[1], intFields[2]);
97 if (fs::path(inFile).extension() ==
".pts")
102 ptsIO->Import(inFile, fieldPts);
104 else if (fs::path(inFile).extension() ==
".csv")
113 vmax = intFields[0][
Vmath::Imax(totpoints, intFields[0], 1)];
114 vmin = intFields[0][
Vmath::Imin(totpoints, intFields[0], 1)];
115 Range->m_xmax = (vmax - vmin) * margin + vmax;
116 Range->m_xmin = -(vmax - vmin) * margin + vmin;
118 vmax = intFields[1][
Vmath::Imax(totpoints, intFields[1], 1)];
119 vmin = intFields[1][
Vmath::Imin(totpoints, intFields[1], 1)];
120 Range->m_ymax = (vmax - vmin) * margin + vmax;
121 Range->m_ymin = -(vmax - vmin) * margin + vmin;
123 vmax = intFields[2][
Vmath::Imax(totpoints, intFields[2], 1)];
124 vmin = intFields[2][
Vmath::Imin(totpoints, intFields[2], 1)];
125 Range->m_zmax = (vmax - vmin) * margin + vmax;
126 Range->m_zmin = -(vmax - vmin) * margin + vmin;
133 ASSERTL0(
false,
"unknown frompts file type");
136 int nFields = fieldPts->GetNFields();
137 ASSERTL0(nFields > 0,
"No field values provided in input");
141 m_f->m_numHomogeneousDir == 0,
142 "ProcessInterpPointDataToFld does not support homogeneous expansion");
144 m_f->m_exp.resize(nFields);
145 for (i = 1; i < nFields; ++i)
147 m_f->m_exp[i] =
m_f->AppendExpList(
m_f->m_numHomogeneousDir);
152 for (
int i = 0; i < 3; ++i)
154 intFields1[i] = intFields[i];
158 for (
int i = 3; i < 3 + nFields; ++i)
166 int coord_id =
m_config[
"interpcoord"].as<
int>();
167 ASSERTL0(coord_id <=
static_cast<int>(outPts->GetDim()) - 1,
168 "interpcoord is bigger than the Pts files dimension");
173 if (
m_f->m_verbose &&
m_f->m_comm->TreatAsRankZero())
179 if (
m_f->m_verbose &&
m_f->m_comm->TreatAsRankZero())
184 for (i = 0; i < totpoints; ++i)
186 for (j = 0; j < nFields; ++j)
188 m_f->m_exp[j]->SetPhys(i, outPts->GetPointVal(3 + j, i));
192 for (i = 0; i < nFields; ++i)
194 m_f->m_exp[i]->FwdTransLocalElmt(
m_f->m_exp[i]->GetPhys(),
195 m_f->m_exp[i]->UpdateCoeffs());
199 for (
int j = 0; j < fieldPts->GetNFields(); ++j)
201 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., NekDouble tolerance=NekConstants::kFindDistanceMin)
Interpolate from an expansion to an expansion.
FieldSharedPtr m_f
Field object.
std::map< std::string, ConfigOption > m_config
List of configuration values.
~ProcessInterpPointDataToFld() override
ProcessInterpPointDataToFld(FieldSharedPtr f)
void v_Process(po::variables_map &vm) override
Write mesh to output file.
void PrintProgressbar(const int position, const int goal) const
static ModuleKey className
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
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
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.