42#include <boost/format.hpp>
97 for (
int i = n - 1; i > 0; --i)
99 data[i] = data[i - 1];
131 ASSERTL0(
false,
"Integration order not supported.");
139 for (
int i = 0; i <
m_coords.size(); ++i)
156 for (
size_t i = 0; i < str.size(); ++i)
159 ofile.write((
char *)&tmp, 4);
162 ofile.write((
char *)&tmp, 4);
167 const std::vector<std::string> &variables,
168 const std::vector<int> &rawN,
172 std::vector<int> N = rawN;
173 for (
int i = N.size(); i < 3; ++i)
178 odata.open(filename, std::ios::binary);
179 if (!odata.is_open())
181 printf(
"error unable to open file %s\n", filename.c_str());
184 char tecplotversion[] =
"#!TDV112";
185 odata.write((
char *)tecplotversion, 8);
187 odata.write((
char *)&value1, 4);
189 odata.write((
char *)&filetype, 4);
191 std::string filetitle =
"";
193 int nvar = variables.size();
194 odata.write((
char *)&nvar, 4);
195 std::vector<std::string> vartitle;
196 for (
int i = 0; i < nvar; ++i)
200 float zonemarker299I = 299.0f;
201 odata.write((
char *)&zonemarker299I, 4);
203 std::string zonetitle(
"ZONE 0");
206 odata.write((
char *)&parentzone, 4);
208 odata.write((
char *)&strandid, 4);
209 double soltime = 0.0;
210 odata.write((
char *)&soltime, 8);
212 odata.write((
char *)&unused, 4);
214 odata.write((
char *)&zonetype, 4);
216 odata.write((
char *)&zero, 4);
217 odata.write((
char *)&zero, 4);
218 odata.write((
char *)&zero, 4);
219 for (
int i = 0; i < 3; ++i)
222 odata.write((
char *)&tmp, 4);
225 odata.write((
char *)&zero, 4);
226 float eohmarker357 = 357.0f;
227 odata.write((
char *)&eohmarker357, 4);
228 float zonemarker299II = 299.0f;
229 odata.write((
char *)&zonemarker299II, 4);
230 std::vector<int> binarydatatype(nvar, 1 + (isdouble > 0));
231 odata.write((
char *)binarydatatype.data(), 4 * nvar);
232 odata.write((
char *)&zero, 4);
233 odata.write((
char *)&zero, 4);
235 odata.write((
char *)&minus1, 4);
237 int datanumber, datasize;
238 datanumber = N[0] * N[1] * N[2];
239 datasize = N[0] * N[1] * N[2] * 4;
240 for (
int i = 0; i < nvar; ++i)
242 double minv = 0., maxv = 1.;
243 for (
int p = 0;
p < datanumber; ++
p)
245 if (maxv < data[i][
p])
249 if (minv > data[i][
p])
254 odata.write((
char *)&minv, 8);
255 odata.write((
char *)&maxv, 8);
258 std::vector<float> vardata(datanumber);
259 for (
int i = 0; i < nvar; ++i)
263 odata.write((
char *)data[i].data(), datasize * 2);
267 std::vector<float> fdata(datanumber);
268 for (
int j = 0; j < datanumber; ++j)
270 fdata[j] = data[i][j];
272 odata.write((
char *)fdata.data(), datasize);
280 std::string filename,
bool verbose,
281 std::map<std::string, NekDouble> ¶ms)
283 std::vector<std::string> COORDS = {
"x",
"y",
"z"};
284 std::vector<std::string> VELOCI = {
"u",
"v",
"w"};
285 std::vector<std::string> variables;
286 std::vector<Array<OneD, NekDouble>> data;
289 variables.push_back(COORDS[
d]);
293 variables.push_back(VELOCI[
d]);
295 if (params.size() > 0)
333 for (
int i = 0; i < Np; ++i)
337 value =
sqrt(value / Np);
338 cout <<
"L 2 error (variable L" << COORDS[
d] <<
") : " << value
344 for (
int i = 0; i < Np; ++i)
348 value =
sqrt(value / Np);
349 cout <<
"L 2 error (variable L" << VELOCI[
d] <<
") : " << value
353 cout <<
"Write file " << filename << endl;
367 int intOrder,
int idOffset,
369 const std::vector<int> &Np,
370 const std::vector<NekDouble> &Box,
371 std::vector<std::string> extraVars)
385 if (Np.size() <
m_dim || Box.size() <
m_dim * 2)
396 delta[
d] = Np[
d] < 2 ? 1. : (Box[
d * 2 + 1] - Box[
d * 2]) / (Np[
d] - 1);
411 for (
size_t i = 0; i < extraVars.size(); ++i)
418 for (
int k = 0; k <
m_N[2]; ++k)
420 for (
int j = 0; j <
m_N[1]; ++j)
422 for (
int i = 0; i <
m_N[0]; ++i)
426 m_coords[0][0][count] = Box[0] + delta[0] * i;
430 m_coords[0][1][count] = Box[2] + delta[1] * j;
434 m_coords[0][2][count] = Box[4] + delta[2] * k;
449 const std::shared_ptr<EquationSystem> &pEquation,
450 const std::map<std::string, std::string> &pParams)
451 :
Filter(pSession, pEquation), v_params(pParams)
470 auto it =
v_params.find(
"DefaultValues");
477 m_session->LoadParameter(
"TimeStep", dt);
479 it =
v_params.find(
"FrameVelocity");
482 std::vector<std::string> strs;
484 for (
int i = strs.size(); i <
m_spacedim; ++i)
492 pFields[0]->GetSession()->GetInterpreter(), strs[i]);
496 it =
v_params.find(
"FrameDisplacement");
499 std::vector<std::string> strs;
501 for (
int i = strs.size(); i <
m_spacedim; ++i)
509 pFields[0]->GetSession()->GetInterpreter(), strs[i]);
530 it =
v_params.find(
"RootOutputL2Norm");
533 std::string value = it->second;
542 std::string outputFilename;
545 outputFilename =
m_session->GetSessionName();
549 ASSERTL0(it->second.length() > 0,
"Missing parameter 'OutputFile'.");
550 outputFilename = it->second;
555 it =
v_params.find(
"OutputFrequency");
566 it =
v_params.find(
"OutputSampleFrequency");
580 std::vector<NekDouble> values;
586 "(offset,Nx,Ny,Nx,xmin,xmax,ymin,ymax,zmin,zmax): " +
592 int idOffset = std::round(values[0]);
595 Np[
d] = std::round(values[
d + 1]);
601 std::vector<std::string> extraVars;
607 it =
v_params.find(
"OutputSamplePoints");
608 std::vector<unsigned int> samplepts;
613 std::set<int> sampleIds(samplepts.begin(), samplepts.end());
614 it =
v_params.find(
"OutputSamplePointsCondition");
620 pFields[0]->GetSession()->GetInterpreter(), it->second);
633 (sampleCondition ==
nullptr)
635 : (sampleCondition->Evaluate(x, y,
z, time) > 0);
636 if (sampleIds.find(globalId) != sampleIds.end() || issample)
644 std::string sampleFilename = outputFilename +
"_Sample_R%05d.dat";
648 std::vector<std::string> COORDS = {
"x",
"y",
"z"};
649 std::vector<std::string> VELOCI = {
"u",
"v",
"w"};
679 std::vector<std::string> &extraVars)
683 extraVars.push_back(
"u_x");
684 extraVars.push_back(
"u_y");
685 extraVars.push_back(
"v_x");
686 extraVars.push_back(
"v_y");
687 extraVars.push_back(
"LW_z");
691 extraVars.push_back(
"u_x");
692 extraVars.push_back(
"u_y");
693 extraVars.push_back(
"u_z");
694 extraVars.push_back(
"v_x");
695 extraVars.push_back(
"v_y");
696 extraVars.push_back(
"v_z");
697 extraVars.push_back(
"w_x");
698 extraVars.push_back(
"w_y");
699 extraVars.push_back(
"w_z");
700 extraVars.push_back(
"LW_x");
701 extraVars.push_back(
"LW_y");
702 extraVars.push_back(
"LW_z");
710 int npts = pFields[0]->GetTotPoints();
713 PhysicsData.push_back(pFields[i]->UpdatePhys());
715 int offset = PhysicsData.size();
725 pFields[
d]->PhysDeriv(pFields[
d]->UpdatePhys(), data[0], data[1]);
729 pFields[
d]->PhysDeriv(pFields[
d]->UpdatePhys(), data[0], data[1],
734 PhysicsData.push_back(data[i]);
742 for (
int d = 0;
d < vortexdim; ++
d)
754 Vmath::Vsub(npts, PhysicsData[offset + 2], 1, PhysicsData[offset + 1],
760 Vmath::Vsub(npts, PhysicsData[offset + 7], 1, PhysicsData[offset + 5],
762 Vmath::Vsub(npts, PhysicsData[offset + 2], 1, PhysicsData[offset + 6],
764 Vmath::Vsub(npts, PhysicsData[offset + 3], 1, PhysicsData[offset + 1],
767 for (
int d = 0;
d < vortexdim; ++
d)
771 pFields[0]->PhysDeriv(vorticity[
d], temp[0], temp[1]);
775 pFields[0]->PhysDeriv(vorticity[
d], temp[0], temp[1], temp[2]);
779 pFields[0]->PhysDeriv(j, temp[j], temps);
782 PhysicsData.push_back(Ldata[
d]);
794 std::vector<Array<OneD, NekDouble>> PhysicsData;
798 std::map<int, std::set<int>> callbackUpdateMobCoords;
849 std::map<std::string, NekDouble> params;
852 std::vector<std::string> COORDS = {
"x",
"y",
"z"};
853 std::vector<std::string> VELOCI = {
"u",
"v",
"w"};
#define ASSERTL0(condition, msg)
Nektar::ErrorUtil::NekError NekError
NekDouble Evaluate() const
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
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 bool GenerateSeqVector(const std::string &str, std::vector< unsigned int > &out)
Takes a comma-separated compressed string and converts it to entries in a vector.
SOLVER_UTILS_EXPORT void EvaluateMobilePhys(const MultiRegions::ExpListSharedPtr &pField, std::vector< Array< OneD, NekDouble > > &PhysicsData, NekDouble time)
SOLVER_UTILS_EXPORT void Initialise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time, std::vector< std::string > &defaultValues)
SOLVER_UTILS_EXPORT void PassMobilePhysToStatic(std::map< int, std::set< int > > &callbackUpdateMobCoords)
SOLVER_UTILS_EXPORT void PartitionMobilePts(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields)
SOLVER_UTILS_EXPORT void SetUpCommInfo()
SOLVER_UTILS_EXPORT void CopyStaticPtsToMobile()
StationaryPointsSharedPtr m_staticPts
SOLVER_UTILS_EXPORT void PassStaticCoordsToMobile(std::map< int, std::set< int > > &callbackUpdateMobCoords)
LibUtilities::SessionReaderSharedPtr m_session
static FilterSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const std::shared_ptr< EquationSystem > &pEquation, const std::map< std::string, std::string > &pParams)
void v_Update(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time) override
std::vector< NekDouble > m_box
unsigned int m_outputSampleFrequency
std::ofstream m_ofstreamSamplePoints
unsigned int m_outputFrequency
static std::string className
void ExtraPhysicsVars(std::vector< std::string > &extraVars)
SOLVER_UTILS_EXPORT ~FilterLagrangianPoints() override
void OutputSamplePoints(NekDouble time)
struct Nektar::SolverUtils::FilterLagrangianPoints::MovingFrame m_frame
std::vector< std::string > m_defaultValues
void OutputStatPoints(NekDouble time)
std::map< std::string, std::string > v_params
void v_Finalise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time) override
SOLVER_UTILS_EXPORT void v_Initialise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time) override
SOLVER_UTILS_EXPORT FilterLagrangianPoints(const LibUtilities::SessionReaderSharedPtr &pSession, const std::shared_ptr< EquationSystem > &pEquation, const std::map< std::string, std::string > &pParams)
void v_ModifyVelocity(Array< OneD, NekDouble > gcoords, NekDouble time, Array< OneD, NekDouble > vel) override
bool v_IsTimeDependent() override
std::set< int > m_samplePointIDs
void GetPhysicsData(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, std::vector< Array< OneD, NekDouble > > &PhysicsData)
std::vector< std::string > m_extraPhysVars
StatLagrangianPoints(int rank, int dim, int intOrder, int idOffset, NekDouble dt, const std::vector< int > &Np, const std::vector< NekDouble > &Box, std::vector< std::string > extraVars)
void v_GetCoords(int pid, Array< OneD, NekDouble > &gcoords) override
void v_SetPhysics(int pid, const Array< OneD, NekDouble > &data) override
void v_OutputData(std::string filename, bool verbose, std::map< std::string, NekDouble > ¶ms) override
void v_ReSize(int Np) override
void v_TimeAdvance(int order) override
void v_SetCoords(int pid, const Array< OneD, NekDouble > &gcoords) override
void v_GetPhysics(int pid, Array< OneD, NekDouble > &data) override
Array< OneD, Array< OneD, NekDouble > > m_extraPhysics
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_velocity
void v_AssignPoint(int id, int pid, const Array< OneD, NekDouble > &gcoords) override
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_coords
virtual void v_AssignPoint(int id, int pid, const Array< OneD, NekDouble > &gcoords)
std::map< int, int > m_globalIDToLocal
std::map< int, int > m_localIDToGlobal
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Equation > EquationSharedPtr
static void RollOver(Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &data)
static int OutputTec360_binary(const std::string filename, const std::vector< std::string > &variables, const std::vector< int > &rawN, std::vector< Array< OneD, NekDouble > > &data, int isdouble)
FilterFactory & GetFilterFactory()
static int BinaryWrite(std::ofstream &ofile, std::string str)
std::vector< double > z(NPUPPER)
std::vector< double > d(NPUPPER *NPUPPER)
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Svtvp (scalar times vector plus vector): z = alpha*x + y.
void Svtvm(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Svtvm (scalar times vector minus vector): z = alpha*x - y.
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha + x.
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
scalarT< T > sqrt(scalarT< T > in)
std::map< int, LibUtilities::EquationSharedPtr > m_frameVelFunction
std::map< int, NekDouble > m_frameDisp
std::map< int, NekDouble > m_frameVel
void Update(NekDouble time)
std::map< int, LibUtilities::EquationSharedPtr > m_frameDispFunction