39 #include <boost/core/ignore_unused.hpp>
40 #include <boost/math/special_functions/fpclassify.hpp>
51 ModuleKey ProcessPointDataToFld::className =
54 ProcessPointDataToFld::create,
55 "Given discrete data at quadrature points project them onto an "
57 "basis and output fld file. Requires frompts and .xml and .fld files.");
63 false,
"NotSet",
"reset any nan value to prescribed value");
66 false,
"NotSet",
"Pts file from which to interpolate field");
78 bool setnantovalue =
false;
81 if (!boost::iequals(
m_config[
"setnantovalue"].as<string>(),
"NotSet"))
91 "ProcessInterpPointDataToFld requires frompts parameter");
92 string inFile =
m_config[
"frompts"].as<
string>().c_str();
97 ptsIO->Import(inFile, fieldPts);
99 int nFields = fieldPts->GetNFields();
100 ASSERTL0(nFields > 0,
"No field values provided in input");
102 int dim = fieldPts->GetDim();
106 m_f->m_numHomogeneousDir == 0,
107 "ProcessInterpPointDataToFld does not support homogeneous expansion");
109 m_f->m_exp.resize(nFields);
110 for (i = 1; i < nFields; ++i)
112 m_f->m_exp[i] =
m_f->AppendExpList(
m_f->m_numHomogeneousDir);
116 fieldPts->GetPts(pts);
121 for (
int i = 0; i < pts[0].size(); ++i)
123 for (
int j = 0; j < nFields; ++j)
125 if ((boost::math::isnan)(pts[j + dim][i]))
127 pts[j + dim][i] = defvalue;
135 int totcoeffs =
m_f->m_exp[0]->GetNcoeffs();
137 ASSERTL0(pts[0].size() != totcoeffs,
138 "length of points in .pts file is different "
139 "to the number of coefficients in expansion ");
141 for (
int i = 0; i < nFields; ++i)
145 for (
int e = 0; e <
m_f->m_exp[0]->GetNumElmts(); ++e)
147 int ncoeffs =
m_f->m_exp[i]->GetExp(e)->GetNcoeffs();
148 int offset =
m_f->m_exp[i]->GetCoeff_Offset(e);
149 Vmath::Vcopy(ncoeffs, &pts[i + dim][cnt], 1, &coeffs[offset],
152 m_f->m_exp[i]->GetExp(e)->EquiSpacedToCoeffs(
153 coeffs + offset, tmp = coeffs + offset);
156 m_f->m_exp[i]->BwdTrans(
m_f->m_exp[i]->GetCoeffs(),
157 m_f->m_exp[i]->UpdatePhys());
162 int totpoints =
m_f->m_exp[0]->GetTotPoints();
169 m_f->m_exp[0]->GetCoords(coords[0], coords[1], coords[2]);
171 if (pts[0].size() != totpoints)
173 WARNINGL0(
false,
"length of points in .pts file is different to "
174 "the number of quadrature points in xml file");
175 totpoints = min(totpoints, (
int)pts[0].size());
178 for (j = 0; j < dim; ++j)
180 for (i = 0; i < totpoints; ++i)
182 if (fabs(coords[j][i] - pts[j][i]) > 1e-4)
185 "Coordinates do not match within 1e-4: " +
186 boost::lexical_cast<string>(coords[j][i]) +
" versus " +
187 boost::lexical_cast<string>(pts[j][i]) +
" diff " +
188 boost::lexical_cast<string>(
189 fabs(coords[j][i] - pts[j][i]));
196 for (j = 0; j < nFields; ++j)
200 for (i = 0; i < totpoints; ++i)
202 phys[i] = pts[j + dim][i];
206 m_f->m_exp[j]->FwdTransLocalElmt(phys,
207 m_f->m_exp[j]->UpdateCoeffs());
212 for (
int j = 0; j < fieldPts->GetNFields(); ++j)
214 m_f->m_variables.push_back(fieldPts->GetFieldName(j));
#define ASSERTL0(condition, msg)
#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()
virtual void v_Process(po::variables_map &vm) override
Write mesh to output file.
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.
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()
std::shared_ptr< PtsField > PtsFieldSharedPtr
std::shared_ptr< PtsIO > PtsIOSharedPtr
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.