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);
115 fieldPts->GetPts(pts);
120 for (
int i = 0; i < pts[0].size(); ++i)
122 for (
int j = 0; j < nFields; ++j)
124 if ((boost::math::isnan)(pts[j + dim][i]))
126 pts[j + dim][i] = defvalue;
134 int totcoeffs =
m_f->m_exp[0]->GetNcoeffs();
136 ASSERTL0(pts[0].size() != totcoeffs,
137 "length of points in .pts file is different "
138 "to the number of coefficients in expansion ");
140 for (
int i = 0; i < nFields; ++i)
144 for (
int e = 0; e <
m_f->m_exp[0]->GetNumElmts(); ++e)
146 int ncoeffs =
m_f->m_exp[i]->GetExp(e)->GetNcoeffs();
147 int offset =
m_f->m_exp[i]->GetCoeff_Offset(e);
148 Vmath::Vcopy(ncoeffs, &pts[i + dim][cnt], 1, &coeffs[offset],
151 m_f->m_exp[i]->GetExp(e)->EquiSpacedToCoeffs(
152 coeffs + offset, tmp = coeffs + offset);
155 m_f->m_exp[i]->BwdTrans(
m_f->m_exp[i]->GetCoeffs(),
156 m_f->m_exp[i]->UpdatePhys());
161 int totpoints =
m_f->m_exp[0]->GetTotPoints();
168 m_f->m_exp[0]->GetCoords(coords[0], coords[1], coords[2]);
170 if (pts[0].size() != totpoints)
172 WARNINGL0(
false,
"length of points in .pts file is different to "
173 "the number of quadrature points in xml file");
174 totpoints = min(totpoints, (
int)pts[0].size());
177 for (i = 0; i < totpoints; ++i)
179 for (j = 0; j < dim; ++j)
181 if (fabs(coords[j][i] - pts[j][i]) > 1e-4)
184 "Coordinates do not match within 1e-4: " +
185 boost::lexical_cast<string>(coords[j][i]) +
" versus " +
186 boost::lexical_cast<string>(pts[j][i]) +
" diff " +
187 boost::lexical_cast<string>(
188 fabs(coords[j][i] - pts[j][i]));
194 for (j = 0; j < nFields; ++j)
196 m_f->m_exp[j]->SetPhys(i, pts[j + dim][i]);
201 for (i = 0; i < nFields; ++i)
203 m_f->m_exp[i]->FwdTransLocalElmt(
m_f->m_exp[i]->GetPhys(),
204 m_f->m_exp[i]->UpdateCoeffs());
209 for (
int j = 0; j < fieldPts->GetNFields(); ++j)
211 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 Process(po::variables_map &vm)
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.