45 #include <boost/math/special_functions/fpclassify.hpp>
51 ModuleKey ProcessInterpPointDataToFld::className =
54 ProcessInterpPointDataToFld::create,
55 "Interpolates given discrete data using a finite difference "
56 "approximation to a fld file given a xml file");
64 "coordinate id to use for interpolation");
76 if(
m_f->m_comm->GetRank() == 0)
78 cout <<
"ProcessInterpPointDataToFld: interpolating data to field..."
87 "No input points found");
89 int nFields =
m_f->m_fieldPts->GetNFields();
91 "No field values provided in input");
94 m_f->m_exp.resize(nFields+1);
95 for(i = 1; i < nFields; ++i)
97 m_f->m_exp[i] =
m_f->AppendExpList(0);
100 int totpoints =
m_f->m_exp[0]->GetTotPoints();
107 m_f->m_exp[0]->GetCoords(coords[0],coords[1],coords[2]);
109 int coord_id =
m_config[
"interpcoord"].as<
int>();
110 ASSERTL0(coord_id <= m_f->m_fieldPts->GetDim() - 1,
111 "interpcoord is bigger than the Pts files dimension");
115 if (
m_f->m_session->GetComm()->GetRank() == 0)
117 m_f->m_fieldPts->setProgressCallback(
119 cout <<
"Interpolating: ";
121 m_f->m_fieldPts->Interpolate(coords, intFields, coord_id);
123 for(i = 0; i < totpoints; ++i)
125 for(j = 0; j < nFields; ++j)
127 m_f->m_exp[j]->SetPhys(i, intFields[j][i]);
131 if(
m_f->m_session->GetComm()->GetRank() == 0)
137 for(i = 0; i < nFields; ++i)
139 m_f->m_exp[i]->FwdTrans_IterPerExp(
m_f->m_exp[i]->GetPhys(),
140 m_f->m_exp[i]->UpdateCoeffs());
145 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
146 =
m_f->m_exp[0]->GetFieldDefinitions();
147 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
149 for (j = 0; j < nFields; ++j)
151 for (i = 0; i < FieldDef.size(); ++i)
153 FieldDef[i]->m_fields.push_back(
m_f->m_fieldPts->GetFieldName(j));
155 m_f->m_exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
159 m_f->m_fielddef = FieldDef;
160 m_f->m_data = FieldData;
#define ASSERTL0(condition, msg)
pair< ModuleType, string > ModuleKey
map< string, ConfigOption > m_config
List of configuration values.
FieldSharedPtr m_f
Field object.
virtual ~ProcessInterpPointDataToFld()
boost::shared_ptr< Field > FieldSharedPtr
Represents a command-line configuration option.
static PtsFieldSharedPtr NullPtsField
void PrintProgressbar(const int position, const int goal) const
ModuleFactory & GetModuleFactory()
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.