45 #include <boost/math/special_functions/fpclassify.hpp>
54 ProcessInterpField::create,
55 "Interpolates one field to another, requires fromxml, "
56 "fromfld to be defined");
62 false,
"NotSet",
"Xml file form which to interpolate field");
64 false,
"NotSet",
"Fld file form which to interpolate field");
67 ConfigOption(
false,
"-10000000",
"Lower bound for interpolation value");
69 ConfigOption(
false,
"10000000",
"Upper bound for interpolation value");
71 ConfigOption(
false,
"0",
"Default value if point is outside domain");
82 if (
m_f->m_comm->TreatAsRankZero())
84 cout <<
"ProcessInterpField: Interpolating field..." << endl;
90 std::vector<std::string> files;
101 int coordim =
m_f->m_exp[0]->GetCoordim(0);
102 int npts =
m_f->m_exp[0]->GetTotPoints();
105 for (
int i = 0; i < coordim; ++i)
110 for (
int i = coordim; i < 3; ++i)
115 m_f->m_exp[0]->GetCoords(coords[0], coords[1], coords[2]);
117 rng->m_checkShape =
false;
121 rng->m_doZrange =
true;
125 rng->m_doYrange =
true;
129 rng->m_doXrange =
true;
134 ASSERTL0(
false,
"too many values specfied in range");
147 if (!expansions.size())
153 SpatialDomains::ExpansionMap::const_iterator expIt;
156 for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
158 ElementGIDs[i++] = expIt->second->m_geomShPtr->GetGlobalID();
161 string fromfld =
m_config[
"fromfld"].as<
string>();
162 m_f->FieldIOForFile(fromfld)->Import(
166 int NumHomogeneousDir =
m_fromField->m_fielddef[0]->m_numHomogeneousDir;
172 int nfields =
m_fromField->m_fielddef[0]->m_fields.size();
176 m_fromField->SetUpFirstExpList(NumHomogeneousDir,
true);
178 m_f->m_exp.resize(nfields);
181 for (i = 1; i < nfields; ++i)
183 m_f->m_exp[i] =
m_f->AppendExpList(NumHomogeneousDir);
188 for (
int j = 0; j < nfields; ++j)
190 for (i = 0; i <
m_fromField->m_fielddef.size(); i++)
201 int nq1 =
m_f->m_exp[0]->GetTotPoints();
209 m_f->m_exp[0]->GetCoords(x1, y1);
211 else if (coordim == 3)
213 m_f->m_exp[0]->GetCoords(x1, y1, z1);
220 for (
int i = 0; i < nfields; i++)
222 for (
int j = 0; j < nq1; ++j)
224 m_f->m_exp[i]->UpdatePhys()[j] = def_value;
229 if (
m_f->m_comm->GetRank() == 0)
234 if (
m_f->m_comm->GetRank() == 0)
239 for (
int i = 0; i < nfields; ++i)
241 for (
int j = 0; j < nq1; ++j)
243 if (
m_f->m_exp[i]->GetPhys()[j] > clamp_up)
245 m_f->m_exp[i]->UpdatePhys()[j] = clamp_up;
247 else if (
m_f->m_exp[i]->GetPhys()[j] < clamp_low)
249 m_f->m_exp[i]->UpdatePhys()[j] = clamp_low;
255 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
256 m_f->m_exp[0]->GetFieldDefinitions();
257 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
259 for (
int j = 0; j < nfields; ++j)
261 m_f->m_exp[j]->FwdTrans(
m_f->m_exp[j]->GetPhys(),
262 m_f->m_exp[j]->UpdateCoeffs());
263 for (i = 0; i < FieldDef.size(); ++i)
265 FieldDef[i]->m_fields.push_back(
267 m_f->m_exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
271 m_f->m_fielddef = FieldDef;
272 m_f->m_data = FieldData;
276 const int goal)
const
map< string, ConfigOption > m_config
List of configuration values.
#define ASSERTL0(condition, msg)
static bool GenerateOrderedStringVector(const char *const str, std::vector< std::string > &vec)
A class that contains algorithms for interpolation between pts fields, expansions and different meshe...
void SetProgressCallback(FuncPointerT func, ObjectPointerT obj)
sets a callback funtion which gets called every time the interpolation progresses ...
static Array< OneD, NekDouble > NullNekDouble1DArray
int PrintProgressbar(const int position, const int goal, const string message, int lastprogress=-1)
Prints a progressbar.
static boost::shared_ptr< MeshGraph > Read(const LibUtilities::SessionReaderSharedPtr &pSession, DomainRangeShPtr &rng=NullDomainRangeShPtr)
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
Represents a command-line configuration option.
FIELD_UTILS_EXPORT void Interpolate(const LibUtilities::PtsFieldSharedPtr ptsInField, LibUtilities::PtsFieldSharedPtr &ptsOutField)
Interpolate from a pts field to a pts field.
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
pair< ModuleType, string > ModuleKey
void PrintProgressbar(const int position, const int goal) const
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
boost::shared_ptr< Field > FieldSharedPtr
boost::shared_ptr< DomainRange > DomainRangeShPtr
FieldSharedPtr m_fromField
virtual ~ProcessInterpField()
virtual void Process(po::variables_map &vm)
Write mesh to output file.
Abstract base class for processing modules.
static FieldMetaDataMap NullFieldMetaDataMap
std::map< int, ExpansionShPtr > ExpansionMap
ModuleFactory & GetModuleFactory()
FieldSharedPtr m_f
Field object.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.