38 #include <boost/core/ignore_unused.hpp> 39 #include <boost/geometry.hpp> 40 #include <boost/math/special_functions/fpclassify.hpp> 49 namespace bg = boost::geometry;
50 namespace bgi = boost::geometry::index;
60 ProcessInterpField::create,
61 "Interpolates one field to another, requires fromxml, " 62 "fromfld to be defined");
68 false,
"NotSet",
"Xml file from which to interpolate field");
70 false,
"NotSet",
"Fld file from which to interpolate field");
73 ConfigOption(
false,
"-10000000",
"Lower bound for interpolation value");
75 ConfigOption(
false,
"10000000",
"Upper bound for interpolation value");
77 ConfigOption(
false,
"0",
"Default value if point is outside domain");
86 boost::ignore_unused(vm);
90 std::vector<std::string> files;
93 char *argv[] = {
const_cast<char *
>(
"FieldConvert"),
nullptr };
95 fromField->m_session =
104 int coordim =
m_f->m_exp[0]->GetCoordim(0);
105 int npts =
m_f->m_exp[0]->GetTotPoints();
108 for (
int i = 0; i < coordim; ++i)
113 for (
int i = coordim; i < 3; ++i)
118 m_f->m_exp[0]->GetCoords(coords[0], coords[1], coords[2]);
120 rng->m_checkShape =
false;
124 rng->m_doZrange =
true;
129 rng->m_doYrange =
true;
134 rng->m_doXrange =
true;
148 fromField->m_graph->GetExpansions();
152 if (!expansions.size())
160 for (
auto &expIt : expansions)
162 ElementGIDs[i++] = expIt.second->m_geomShPtr->GetGlobalID();
165 string fromfld =
m_config[
"fromfld"].as<
string>();
166 m_f->FieldIOForFile(fromfld)->Import(
167 fromfld, fromField->m_fielddef, fromField->m_data,
170 int NumHomogeneousDir = fromField->m_fielddef[0]->m_numHomogeneousDir;
174 fromField->m_graph->SetExpansions(fromField->m_fielddef);
176 int nfields = fromField->m_fielddef[0]->m_fields.size();
178 fromField->m_exp.resize(nfields);
179 fromField->m_exp[0] =
180 fromField->SetUpFirstExpList(NumHomogeneousDir,
true);
182 m_f->m_exp.resize(nfields);
185 for (i = 1; i < nfields; ++i)
187 m_f->m_exp[i] =
m_f->AppendExpList(NumHomogeneousDir);
188 fromField->m_exp[i] = fromField->AppendExpList(NumHomogeneousDir);
192 for (
int j = 0; j < nfields; ++j)
194 for (i = 0; i < fromField->m_fielddef.size(); i++)
196 fromField->m_exp[j]->ExtractDataToCoeffs(
197 fromField->m_fielddef[i], fromField->m_data[i],
198 fromField->m_fielddef[0]->m_fields[j],
199 fromField->m_exp[j]->UpdateCoeffs());
201 fromField->m_exp[j]->BwdTrans(fromField->m_exp[j]->GetCoeffs(),
202 fromField->m_exp[j]->UpdatePhys());
205 int nq1 =
m_f->m_exp[0]->GetTotPoints();
211 for (
int i = 0; i < nfields; i++)
213 for (
int j = 0; j < nq1; ++j)
215 m_f->m_exp[i]->UpdatePhys()[j] = def_value;
220 if (
m_f->m_verbose &&
m_f->m_comm->TreatAsRankZero())
225 if (
m_f->m_verbose &&
m_f->m_comm->TreatAsRankZero())
230 for (
int i = 0; i < nfields; ++i)
232 for (
int j = 0; j < nq1; ++j)
234 if (
m_f->m_exp[i]->GetPhys()[j] > clamp_up)
236 m_f->m_exp[i]->UpdatePhys()[j] = clamp_up;
238 else if (
m_f->m_exp[i]->GetPhys()[j] < clamp_low)
240 m_f->m_exp[i]->UpdatePhys()[j] = clamp_low;
243 m_f->m_exp[i]->FwdTrans_IterPerExp(
244 m_f->m_exp[i]->GetPhys(),
m_f->m_exp[i]->UpdateCoeffs());
247 m_f->m_variables = fromField->m_fielddef[0]->m_fields;
251 const int goal)
const
A class that contains algorithms for interpolation between pts fields, expansions and different meshe...
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
int PrintProgressbar(const int position, const int goal, const std::string message, int lastprogress=-1)
Prints a progressbar.
std::map< std::string, ConfigOption > m_config
List of configuration values.
static Array< OneD, NekDouble > NullNekDouble1DArray
void SetProgressCallback(FuncPointerT func, ObjectPointerT obj)
sets a callback funtion which gets called every time the interpolation progresses ...
Represents a command-line configuration option.
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.
void PrintProgressbar(const int position, const int goal) const
std::shared_ptr< Field > FieldSharedPtr
std::shared_ptr< DomainRange > DomainRangeShPtr
CommFactory & GetCommFactory()
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
std::pair< ModuleType, std::string > ModuleKey
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
FIELD_UTILS_EXPORT void Interpolate(const std::vector< MultiRegions::ExpListSharedPtr > expInField, std::vector< MultiRegions::ExpListSharedPtr > &expOutField, NekDouble def_value=0.0)
Interpolate from an expansion to an expansion.
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
virtual ~ProcessInterpField()
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
virtual void Process(po::variables_map &vm)
Write mesh to output file.
Abstract base class for processing modules.
static FieldMetaDataMap NullFieldMetaDataMap
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, DomainRangeShPtr rng=NullDomainRangeShPtr, bool fillGraph=true)
std::map< int, ExpansionShPtr > ExpansionMap
ModuleFactory & GetModuleFactory()
FieldSharedPtr m_f
Field object.