41 #include <boost/geometry.hpp>
48 #include <boost/math/special_functions/fpclassify.hpp>
50 namespace bg = boost::geometry;
51 namespace bgi = boost::geometry::index;
58 ModuleKey ProcessInterpPointDataToFld::className =
61 ProcessInterpPointDataToFld::create,
62 "Interpolates given discrete data using a finite difference "
63 "approximation to a fld file given a xml file");
70 ConfigOption(
false,
"-1",
"coordinate id to use for interpolation");
81 if (
m_f->m_comm->TreatAsRankZero())
84 <<
"ProcessInterpPointDataToFld: interpolating data to field..."
93 "No input points found");
95 int nFields =
m_f->m_fieldPts->GetNFields();
96 ASSERTL0(nFields > 0,
"No field values provided in input");
99 m_f->m_exp.resize(nFields);
100 for (i = 1; i < nFields; ++i)
102 m_f->m_exp[i] =
m_f->AppendExpList(0);
105 int totpoints =
m_f->m_exp[0]->GetTotPoints();
107 for (
int i = 0; i < 3 + nFields; ++i)
111 m_f->m_exp[0]->GetCoords(intFields[0], intFields[1], intFields[2]);
115 int coord_id =
m_config[
"interpcoord"].as<
int>();
116 ASSERTL0(coord_id <= m_f->m_fieldPts->GetDim() - 1,
117 "interpcoord is bigger than the Pts files dimension");
121 if (
m_f->m_comm->GetRank() == 0)
123 interp.SetProgressCallback(
126 interp.Interpolate(
m_f->m_fieldPts, outPts);
127 if (
m_f->m_comm->GetRank() == 0)
132 for (i = 0; i < totpoints; ++i)
134 for (j = 0; j < nFields; ++j)
136 m_f->m_exp[j]->SetPhys(i, outPts->GetPointVal(3 + j, i));
141 for (i = 0; i < nFields; ++i)
143 m_f->m_exp[i]->FwdTrans_IterPerExp(
m_f->m_exp[i]->GetPhys(),
144 m_f->m_exp[i]->UpdateCoeffs());
148 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
149 m_f->m_exp[0]->GetFieldDefinitions();
150 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
152 for (j = 0; j < nFields; ++j)
154 for (i = 0; i < FieldDef.size(); ++i)
156 FieldDef[i]->m_fields.push_back(
m_f->m_fieldPts->GetFieldName(j));
158 m_f->m_exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
162 m_f->m_fielddef = FieldDef;
163 m_f->m_data = FieldData;
map< string, ConfigOption > m_config
List of configuration values.
#define ASSERTL0(condition, msg)
A class that contains algorithms for interpolation between pts fields, expansions and different meshe...
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
Represents a command-line configuration option.
virtual ~ProcessInterpPointDataToFld()
pair< ModuleType, string > ModuleKey
boost::shared_ptr< PtsField > PtsFieldSharedPtr
boost::shared_ptr< Field > FieldSharedPtr
static PtsFieldSharedPtr NullPtsField
void PrintProgressbar(const int position, const int goal) const
virtual void Process(po::variables_map &vm)
Write mesh to output file.
Abstract base class for processing modules.
ModuleFactory & GetModuleFactory()
FieldSharedPtr m_f
Field object.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.