37#include <boost/geometry.hpp>
48namespace bg = boost::geometry;
49namespace bgi = boost::geometry::index;
57 "Interpolates one field to another, requires fromxml, "
58 "fromfld to be defined");
64 false,
"NotSet",
"Xml file from which to interpolate field");
66 false,
"NotSet",
"Fld file from which to interpolate field");
69 ConfigOption(
false,
"-10000000",
"Lower bound for interpolation value");
71 ConfigOption(
false,
"10000000",
"Upper bound for interpolation value");
73 ConfigOption(
false,
"0",
"Default value if point is outside domain");
75 ConfigOption(
false,
"NotSet",
"Take fields as sin mode");
77 ConfigOption(
false,
"1e-5",
"The maximum acceptable distance.");
90 std::vector<std::string> files;
93 char *argv[] = {
const_cast<char *
>(
"FieldConvert"),
nullptr};
103 int numHomoDir =
m_f->m_numHomogeneousDir;
104 int coordim =
m_f->m_exp[0]->GetCoordim(0) + numHomoDir;
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->GetExpansionInfo();
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 fromNumHomoDir = fromField->m_fielddef[0]->m_numHomogeneousDir;
171 for (i = 0; i < fromField->m_fielddef.size(); ++i)
173 int d1 = fromField->m_fielddef[i]->m_basis.size();
175 if (d1 >= 0 && (fromField->m_fielddef[i]->m_basis[d1] ==
177 fromField->m_fielddef[i]->m_basis[d1] ==
180 fromField->m_fielddef[i]->m_homogeneousZIDs[0] += 2;
181 fromField->m_fielddef[i]->m_numModes[d1] = 4;
188 fromField->m_graph->SetExpansionInfo(fromField->m_fielddef);
190 int nfields = fromField->m_fielddef[0]->m_fields.size();
192 fromField->m_exp.resize(nfields);
193 fromField->m_exp[0] = fromField->SetUpFirstExpList(fromNumHomoDir,
true);
195 m_f->m_exp.resize(nfields);
198 for (i = 1; i < nfields; ++i)
200 m_f->m_exp[i] =
m_f->AppendExpList(numHomoDir);
201 fromField->m_exp[i] = fromField->AppendExpList(fromNumHomoDir);
206 if (
m_config[
"realmodetoimag"].as<string>().compare(
"NotSet"))
209 m_f->m_variables, sinmode);
211 for (
int j = 0; j < nfields; ++j)
213 for (i = 0; i < fromField->m_fielddef.size(); i++)
215 fromField->m_exp[j]->ExtractDataToCoeffs(
216 fromField->m_fielddef[i], fromField->m_data[i],
217 fromField->m_fielddef[0]->m_fields[j],
218 fromField->m_exp[j]->UpdateCoeffs());
220 if (fromNumHomoDir == 1)
222 fromField->m_exp[j]->SetWaveSpace(
true);
223 if (sinmode.count(j))
225 int Ncoeff = fromField->m_exp[j]->GetPlane(2)->GetNcoeffs();
227 Ncoeff, -1., fromField->m_exp[j]->GetPlane(2)->GetCoeffs(),
228 1, fromField->m_exp[j]->GetPlane(3)->UpdateCoeffs(), 1);
230 fromField->m_exp[j]->GetPlane(2)->UpdateCoeffs(),
234 fromField->m_exp[j]->BwdTrans(fromField->m_exp[j]->GetCoeffs(),
235 fromField->m_exp[j]->UpdatePhys());
238 int nq1 =
m_f->m_exp[0]->GetTotPoints();
246 if (
m_f->m_verbose &&
m_f->m_comm->TreatAsRankZero())
251 interp.Interpolate(fromField->m_exp,
m_f->m_exp, def_value, tolerance);
253 if (
m_f->m_verbose &&
m_f->m_comm->TreatAsRankZero())
258 for (
int i = 0; i < nfields; ++i)
260 for (
int j = 0; j < nq1; ++j)
262 if (
m_f->m_exp[i]->GetPhys()[j] > clamp_up)
264 m_f->m_exp[i]->UpdatePhys()[j] = clamp_up;
266 else if (
m_f->m_exp[i]->GetPhys()[j] < clamp_low)
268 m_f->m_exp[i]->UpdatePhys()[j] = clamp_low;
271 m_f->m_exp[i]->FwdTransLocalElmt(
m_f->m_exp[i]->GetPhys(),
272 m_f->m_exp[i]->UpdateCoeffs());
275 m_f->m_variables = fromField->m_fielddef[0]->m_fields;
279 const int goal)
const
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
A class that contains algorithms for interpolation between pts fields, expansions and different meshe...
FieldSharedPtr m_f
Field object.
std::map< std::string, ConfigOption > m_config
List of configuration values.
void PrintProgressbar(const int position, const int goal) const
~ProcessInterpField() override
void v_Process(po::variables_map &vm) override
Write mesh to output file.
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
static ModuleKey className
ProcessInterpField(FieldSharedPtr f)
Abstract base class for processing modules.
void SetProgressCallback(FuncPointerT func, ObjectPointerT obj)
sets a callback funtion which gets called every time the interpolation progresses
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
static bool GenerateVariableSet(const std::string &str, const std::vector< std::string > &variables, std::set< int > &out)
Generate a set of variable locations.
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::DomainRangeShPtr rng=LibUtilities::NullDomainRangeShPtr, bool fillGraph=true, SpatialDomains::MeshGraphSharedPtr partitionedGraph=nullptr)
std::shared_ptr< Field > FieldSharedPtr
std::pair< ModuleType, std::string > ModuleKey
ModuleFactory & GetModuleFactory()
int PrintProgressbar(const int position, const int goal, const std::string message, int lastprogress=-1)
Prints a progressbar.
static FieldMetaDataMap NullFieldMetaDataMap
std::shared_ptr< DomainRange > DomainRangeShPtr
CommFactory & GetCommFactory()
@ eFourierHalfModeIm
Fourier Modified expansions with just the imaginary part of the first mode .
@ eFourierHalfModeRe
Fourier Modified expansions with just the real part of the first mode .
@ eFourier
Fourier Expansion .
std::map< int, ExpansionInfoShPtr > ExpansionInfoMap
static Array< OneD, NekDouble > NullNekDouble1DArray
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
void Zero(int n, T *x, const int incx)
Zero vector.
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
Represents a command-line configuration option.