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");
75 boost::ignore_unused(vm);
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 "ProcessInterpPointDataToFld does not support homogeneous expansion");
108 m_f->m_exp.resize(nFields);
109 for (i = 1; i < nFields; ++i)
111 m_f->m_exp[i] =
m_f->AppendExpList(
m_f->m_numHomogeneousDir);
114 fieldPts->GetPts(pts);
119 for (
int i = 0; i < pts[0].num_elements(); ++i)
121 for (
int j = 0; j < nFields; ++j)
123 if ((boost::math::isnan)(pts[j + dim][i]))
125 pts[j + dim][i] = defvalue;
133 int totcoeffs =
m_f->m_exp[0]->GetNcoeffs();
135 ASSERTL0(pts[0].num_elements() != totcoeffs,
136 "length of points in .pts file is different " 137 "to the number of coefficients in expansion ");
139 for (
int i = 0; i < nFields; ++i)
143 for (
int e = 0; e <
m_f->m_exp[0]->GetNumElmts(); ++e)
145 int ncoeffs =
m_f->m_exp[i]->GetExp(e)->GetNcoeffs();
146 int offset =
m_f->m_exp[i]->GetCoeff_Offset(e);
147 Vmath::Vcopy(ncoeffs, &pts[i + dim][cnt], 1, &coeffs[offset],
150 m_f->m_exp[i]->GetExp(e)->EquiSpacedToCoeffs(
151 coeffs + offset, tmp = coeffs + offset);
154 m_f->m_exp[i]->BwdTrans(
m_f->m_exp[i]->GetCoeffs(),
155 m_f->m_exp[i]->UpdatePhys());
160 int totpoints =
m_f->m_exp[0]->GetTotPoints();
167 m_f->m_exp[0]->GetCoords(coords[0], coords[1], coords[2]);
169 if (pts[0].num_elements() != totpoints)
171 WARNINGL0(
false,
"length of points in .pts file is different to " 172 "the number of quadrature points in xml file");
173 totpoints = min(totpoints, (
int)pts[0].num_elements());
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]));
195 for (j = 0; j < nFields; ++j)
197 m_f->m_exp[j]->SetPhys(i, pts[j + dim][i]);
202 for (i = 0; i < nFields; ++i)
204 m_f->m_exp[i]->FwdTrans_IterPerExp(
m_f->m_exp[i]->GetPhys(),
205 m_f->m_exp[i]->UpdateCoeffs());
210 for (
int j = 0; j < fieldPts->GetNFields(); ++j)
212 m_f->m_variables.push_back(fieldPts->GetFieldName(j));
#define ASSERTL0(condition, msg)
std::map< std::string, ConfigOption > m_config
List of configuration values.
Represents a command-line configuration option.
virtual void Process(po::variables_map &vm)
Write mesh to output file.
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
virtual ~ProcessPointDataToFld()
std::shared_ptr< Field > FieldSharedPtr
CommFactory & GetCommFactory()
std::shared_ptr< PtsIO > PtsIOSharedPtr
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
std::shared_ptr< PtsField > PtsFieldSharedPtr
std::pair< ModuleType, std::string > ModuleKey
#define WARNINGL0(condition, msg)
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Abstract base class for processing modules.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
ModuleFactory & GetModuleFactory()
FieldSharedPtr m_f
Field object.