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
60 string fieldfile(argv[argc - 2]);
61 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
62 vector<vector<NekDouble>> fielddata;
64
65
66 vector<vector<NekDouble>> combineddata;
67 vector<LibUtilities::FieldDefinitionsSharedPtr> newfielddef;
68
69
70
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
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
110 for (n = 0; n < fielddef[i]->m_elementIDs.size(); ++n)
111 {
112
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
125
126
127 return 0;
128}
#define ASSERTL0(condition, msg)
int getNumberOfCoefficients(int Na)
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...
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 ...