Nektar++
Functions
ExtractMeanModeFromHomo1DFld.cpp File Reference
#include <SpatialDomains/MeshGraph.h>
#include <StdRegions/StdTriExp.h>
#include <cstdio>
#include <cstdlib>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 43 of file ExtractMeanModeFromHomo1DFld.cpp.

44{
45 if (argc != 3)
46 {
47 fprintf(stderr,
48 "Usage: ExtractmeanModeFromHomo1DFld fieldfile outfield\n");
49 exit(1);
50 }
51
52 int i = 0;
53 int k = 0;
54 int n = 0;
55 int nz = 0;
56 int ncoeffs = 0;
57
58 //----------------------------------------------
59 // Import fieldfile.
60 string fieldfile(argv[argc - 2]);
61 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
62 vector<vector<NekDouble>> fielddata;
63 LibUtilities::Import(fieldfile, fielddef, fielddata);
64 //----------------------------------------------
65
66 vector<vector<NekDouble>> combineddata;
67 vector<LibUtilities::FieldDefinitionsSharedPtr> newfielddef;
68
69 //----------------------------------------------
70 // put mean data consecutively
71 for (i = 0; i < fielddata.size(); ++i)
72 {
73 ASSERTL0(fielddef[i]->m_numHomogeneousDir == 1,
74 "Expected fieldfile to have one homogeneous direction");
75
76 if (fielddef[i]->m_homogeneousZIDs[0] != 0)
77 {
78 continue;
79 }
80 else
81 {
82 nz = fielddef[i]->m_homogeneousZIDs.size();
83
84 fielddef[i]->m_numHomogeneousDir = 0;
85 fielddef[i]->m_basis.resize(2);
86 newfielddef.push_back(fielddef[i]);
87
88 // Determine the number of coefficients per element
89 switch (fielddef[i]->m_shapeType)
90 {
93 fielddef[i]->m_numModes[0], fielddef[i]->m_numModes[1]);
94 break;
96 ncoeffs =
97 fielddef[i]->m_numModes[0] * fielddef[i]->m_numModes[1];
98 break;
99 default:
100 ASSERTL0(false, "Shape not recognised");
101 break;
102 }
103
104 vector<NekDouble> newdata;
105 auto vec_iter = fielddata[i].begin();
106
107 for (k = 0; k < fielddef[i]->m_fields.size(); ++k)
108 {
109 // copy data from each field into consecutive order
110 for (n = 0; n < fielddef[i]->m_elementIDs.size(); ++n)
111 {
112 // put zero mode into newdata
113 newdata.insert(newdata.end(), vec_iter, vec_iter + ncoeffs);
114 vec_iter += nz * ncoeffs;
115 }
116 }
117 combineddata.push_back(newdata);
118 }
119 }
120 //----------------------------------------------
121
122 //-----------------------------------------------
123 // Write out datafile.
124 LibUtilities::Write(argv[argc - 1], newfielddef, combineddata);
125 //-----------------------------------------------
126
127 return 0;
128}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
void Import(const std::string &infilename, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, FieldMetaDataMap &fieldinfomap, const Array< OneD, int > &ElementIDs)
This function allows for data to be imported from an FLD file when a session and/or communicator is n...
Definition: FieldIO.cpp:288
void Write(const std::string &outFile, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, const FieldMetaDataMap &fieldinfomap, const bool backup)
This function allows for data to be written to an FLD file when a session and/or communicator is not ...
Definition: FieldIO.cpp:245

References ASSERTL0, Nektar::LibUtilities::eQuadrilateral, Nektar::LibUtilities::eTriangle, Nektar::LibUtilities::StdSegData::getNumberOfCoefficients(), Nektar::LibUtilities::Import(), and Nektar::LibUtilities::Write().