39#include <boost/core/ignore_unused.hpp>
40#include <boost/math/special_functions/fpclassify.hpp>
57 "Given discrete data at quadrature points project them onto an "
59 "basis and output fld file. Requires frompts and .xml and .fld files.");
65 false,
"NotSet",
"reset any nan value to prescribed value");
68 false,
"NotSet",
"Pts file from which to interpolate field");
80 bool setnantovalue =
false;
83 if (!boost::iequals(
m_config[
"setnantovalue"].as<string>(),
"NotSet"))
93 "ProcessInterpPointDataToFld requires frompts parameter");
94 string inFile =
m_config[
"frompts"].as<
string>().c_str();
99 if (boost::filesystem::path(inFile).extension() ==
".pts")
103 else if (boost::filesystem::path(inFile).extension() ==
".csv")
110 "Unsupported file format for the \"frompts\" parameter. "
111 "Supported formats: \".pts\" and \".csv\"");
114 int nFields = fieldPts->GetNFields();
115 ASSERTL0(nFields > 0,
"No field values provided in input");
117 int dim = fieldPts->GetDim();
121 m_f->m_numHomogeneousDir == 0,
122 "ProcessInterpPointDataToFld does not support homogeneous expansion");
124 m_f->m_exp.resize(nFields);
125 for (i = 1; i < nFields; ++i)
127 m_f->m_exp[i] =
m_f->AppendExpList(
m_f->m_numHomogeneousDir);
131 fieldPts->GetPts(pts);
136 for (
int i = 0; i < pts[0].size(); ++i)
138 for (
int j = 0; j < nFields; ++j)
140 if ((boost::math::isnan)(pts[j + dim][i]))
142 pts[j + dim][i] = defvalue;
150 int totcoeffs =
m_f->m_exp[0]->GetNcoeffs();
152 ASSERTL0(pts[0].size() != totcoeffs,
153 "length of points in .pts file is different "
154 "to the number of coefficients in expansion ");
156 for (
int i = 0; i < nFields; ++i)
160 for (
int e = 0; e <
m_f->m_exp[0]->GetNumElmts(); ++e)
162 int ncoeffs =
m_f->m_exp[i]->GetExp(e)->GetNcoeffs();
163 int offset =
m_f->m_exp[i]->GetCoeff_Offset(e);
164 Vmath::Vcopy(ncoeffs, &pts[i + dim][cnt], 1, &coeffs[offset],
167 m_f->m_exp[i]->GetExp(e)->EquiSpacedToCoeffs(
168 coeffs + offset, tmp = coeffs + offset);
171 m_f->m_exp[i]->BwdTrans(
m_f->m_exp[i]->GetCoeffs(),
172 m_f->m_exp[i]->UpdatePhys());
177 int totpoints =
m_f->m_exp[0]->GetTotPoints();
184 m_f->m_exp[0]->GetCoords(coords[0], coords[1], coords[2]);
186 if (pts[0].size() != totpoints)
188 WARNINGL0(
false,
"length of points in .pts file is different to "
189 "the number of quadrature points in xml file");
190 totpoints = min(totpoints, (
int)pts[0].size());
193 for (j = 0; j < dim; ++j)
195 for (i = 0; i < totpoints; ++i)
197 if (fabs(coords[j][i] - pts[j][i]) > 1e-4)
200 "Coordinates do not match within 1e-4: " +
201 boost::lexical_cast<string>(coords[j][i]) +
" versus " +
202 boost::lexical_cast<string>(pts[j][i]) +
" diff " +
203 boost::lexical_cast<string>(
204 fabs(coords[j][i] - pts[j][i]));
211 for (j = 0; j < nFields; ++j)
215 for (i = 0; i < totpoints; ++i)
217 phys[i] = pts[j + dim][i];
221 m_f->m_exp[j]->FwdTransLocalElmt(phys,
222 m_f->m_exp[j]->UpdateCoeffs());
227 for (
int j = 0; j < fieldPts->GetNFields(); ++j)
229 m_f->m_variables.push_back(fieldPts->GetFieldName(j));
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
#define WARNINGL0(condition, msg)
FieldSharedPtr m_f
Field object.
std::map< std::string, ConfigOption > m_config
List of configuration values.
Abstract base class for processing modules.
virtual ~ProcessPointDataToFld()
static ModuleKey className
virtual void v_Process(po::variables_map &vm) override
Write mesh to output file.
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
ProcessPointDataToFld(FieldSharedPtr f)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
void Import(const std::string &inFile, PtsFieldSharedPtr &ptsField, FieldMetaDataMap &fieldmetadatamap=NullFieldMetaDataMap, DomainRangeShPtr &Range=NullDomainRangeShPtr)
Import a pts field from file.
std::shared_ptr< Field > FieldSharedPtr
std::pair< ModuleType, std::string > ModuleKey
ModuleFactory & GetModuleFactory()
std::shared_ptr< PtsField > PtsFieldSharedPtr
CommFactory & GetCommFactory()
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
The above copyright notice and this permission notice shall be included.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Represents a command-line configuration option.