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");
79 false,
"NotSet",
"Take fields as sin mode");
92 std::vector<std::string> files;
95 char *argv[] = {
const_cast<char *
>(
"FieldConvert"),
nullptr };
97 fromField->m_session =
106 int numHomoDir =
m_f->m_numHomogeneousDir;
107 int coordim =
m_f->m_exp[0]->GetCoordim(0) + numHomoDir;
108 int npts =
m_f->m_exp[0]->GetTotPoints();
111 for (
int i = 0; i < coordim; ++i)
116 for (
int i = coordim; i < 3; ++i)
121 m_f->m_exp[0]->GetCoords(coords[0], coords[1], coords[2]);
123 rng->m_checkShape =
false;
127 rng->m_doZrange =
true;
132 rng->m_doYrange =
true;
137 rng->m_doXrange =
true;
151 fromField->m_graph->GetExpansionInfo();
155 if (!expansions.size())
163 for (
auto &expIt : expansions)
165 ElementGIDs[i++] = expIt.second->m_geomShPtr->GetGlobalID();
168 string fromfld =
m_config[
"fromfld"].as<
string>();
169 m_f->FieldIOForFile(fromfld)->Import(
170 fromfld, fromField->m_fielddef, fromField->m_data,
173 int fromNumHomoDir = fromField->m_fielddef[0]->m_numHomogeneousDir;
174 for (i=0; i<fromField->m_fielddef.size(); ++i)
176 int d1 = fromField->m_fielddef[i]->m_basis.size();
179 (fromField->m_fielddef[i]->m_basis[d1] ==
181 fromField->m_fielddef[i]->m_basis[d1] ==
184 fromField->m_fielddef[i]->m_homogeneousZIDs[0] += 2;
185 fromField->m_fielddef[i]->m_numModes[d1] = 4;
192 fromField->m_graph->SetExpansionInfo(fromField->m_fielddef);
194 int nfields = fromField->m_fielddef[0]->m_fields.size();
196 fromField->m_exp.resize(nfields);
197 fromField->m_exp[0] =
198 fromField->SetUpFirstExpList(fromNumHomoDir,
true);
200 m_f->m_exp.resize(nfields);
203 for (i = 1; i < nfields; ++i)
205 m_f->m_exp[i] =
m_f->AppendExpList(numHomoDir);
206 fromField->m_exp[i] = fromField->AppendExpList(fromNumHomoDir);
211 if (
m_config[
"realmodetoimag"].as<string>().compare(
"NotSet"))
215 m_config[
"realmodetoimag"].as<string>(), value),
216 "Failed to interpret realmodetoimag string");
222 for (
int j = 0; j < nfields; ++j)
224 for (i = 0; i < fromField->m_fielddef.size(); i++)
226 fromField->m_exp[j]->ExtractDataToCoeffs(
227 fromField->m_fielddef[i], fromField->m_data[i],
228 fromField->m_fielddef[0]->m_fields[j],
229 fromField->m_exp[j]->UpdateCoeffs());
231 if (fromNumHomoDir == 1)
233 fromField->m_exp[j]->SetWaveSpace(
true);
234 if (sinmode.count(j))
236 int Ncoeff = fromField->m_exp[j]->GetPlane(2)->GetNcoeffs();
238 fromField->m_exp[j]->GetPlane(2)->GetCoeffs() , 1,
239 fromField->m_exp[j]->GetPlane(3)->UpdateCoeffs(), 1);
241 fromField->m_exp[j]->GetPlane(2)->UpdateCoeffs(), 1);
244 fromField->m_exp[j]->BwdTrans(fromField->m_exp[j]->GetCoeffs(),
245 fromField->m_exp[j]->UpdatePhys());
248 int nq1 =
m_f->m_exp[0]->GetTotPoints();
254 for (
int i = 0; i < nfields; i++)
256 for (
int j = 0; j < nq1; ++j)
258 m_f->m_exp[i]->UpdatePhys()[j] = def_value;
263 if (
m_f->m_verbose &&
m_f->m_comm->TreatAsRankZero())
268 if (
m_f->m_verbose &&
m_f->m_comm->TreatAsRankZero())
273 for (
int i = 0; i < nfields; ++i)
275 for (
int j = 0; j < nq1; ++j)
277 if (
m_f->m_exp[i]->GetPhys()[j] > clamp_up)
279 m_f->m_exp[i]->UpdatePhys()[j] = clamp_up;
281 else if (
m_f->m_exp[i]->GetPhys()[j] < clamp_low)
283 m_f->m_exp[i]->UpdatePhys()[j] = clamp_low;
286 m_f->m_exp[i]->FwdTrans_IterPerExp(
287 m_f->m_exp[i]->GetPhys(),
m_f->m_exp[i]->UpdateCoeffs());
290 m_f->m_variables = fromField->m_fielddef[0]->m_fields;
294 const int goal)
const
#define ASSERTL0(condition, msg)
#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...
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.
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
virtual void Process(po::variables_map &vm)
Write mesh to output file.
virtual ~ProcessInterpField()
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 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)
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
The above copyright notice and this permission notice shall be included.
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.