43int main(
int argc,
char *argv[])
51 "Usage: AddModeTo2DFld scal1 scal2 2Dfieldfile1 fieldfile2 "
53 "\t produces scal1*2Dfieldfiel1 + scal2*fieldfile2 in outfield\n");
57 scal1 = boost::lexical_cast<double>(argv[argc - 5]);
58 scal2 = boost::lexical_cast<double>(argv[argc - 4]);
62 string fieldfile1(argv[argc - 3]);
63 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef1;
64 vector<vector<NekDouble>> fielddata1;
70 string fieldfile2(argv[argc - 2]);
71 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef2;
72 vector<vector<NekDouble>> fielddata2;
76 vector<vector<NekDouble>> combineddata;
78 ASSERTL0(fielddata1.size() == fielddata2.size(),
79 "Inner has different size");
88 for (i = 0; i < fielddata2.size(); ++i)
90 ASSERTL0(fielddef2[i]->m_numHomogeneousDir == 1,
91 "Expected second fld to have one homogeneous direction");
92 ASSERTL0(fielddef2[i]->m_numModes[2] == 2,
93 "Expected Fourier field to have 2 modes");
95 int datalen1 = fielddata1[i].size() / fielddef1[i]->m_fields.size();
96 int datalen2 = fielddata2[i].size() / fielddef2[i]->m_fields.size();
99 "Data per fields is note compatible");
103 switch (fielddef2[i]->m_shapeType)
107 fielddef2[i]->m_numModes[0], fielddef2[i]->m_numModes[1]);
111 fielddef2[i]->m_numModes[0] * fielddef2[i]->m_numModes[1];
114 ASSERTL0(
false,
"Shape not recognised");
122 Vmath::Smul(fielddata1[i].size(), scal1, &fielddata1[i][0], 1,
123 &fielddata1[i][0], 1);
124 Vmath::Smul(fielddata2[i].size(), scal2, &fielddata2[i][0], 1,
125 &fielddata2[i][0], 1);
127 vector<NekDouble> newdata;
128 auto vec_iter = fielddata2[i].begin();
130 for (k = 0; k < fielddef2[i]->m_fields.size(); ++k)
134 for (j = 0; j < fielddef1[i]->m_fields.size(); ++j)
136 if (fielddef1[i]->m_fields[j] == fielddef2[i]->m_fields[k])
143 if (j != fielddef1[i]->m_fields.size())
145 for (n = 0; n < fielddef2[i]->m_elementIDs.size(); ++n)
149 newdata.end(), &(fielddata1[i][offset + n * ncoeffs]),
150 &(fielddata1[i][offset + n * ncoeffs]) + ncoeffs);
153 newdata.insert(newdata.end(), &
Zero[0], &
Zero[0] + ncoeffs);
156 newdata.insert(newdata.end(), vec_iter,
157 vec_iter + 2 * ncoeffs);
158 vec_iter += 2 * ncoeffs;
164 for (n = 0; n < fielddef2[i]->m_elementIDs.size(); ++n)
167 newdata.insert(newdata.end(), &
Zero[0], &
Zero[0] + ncoeffs);
168 newdata.insert(newdata.end(), &
Zero[0], &
Zero[0] + ncoeffs);
171 newdata.insert(newdata.end(), vec_iter,
172 vec_iter + 2 * ncoeffs);
173 vec_iter += 2 * ncoeffs;
177 combineddata.push_back(newdata);
178 fielddef2[i]->m_numModes[2] += 2;
179 fielddef2[i]->m_homogeneousZIDs.push_back(2);
180 fielddef2[i]->m_homogeneousZIDs.push_back(3);
184 for (k = 0; k < fielddef1[i]->m_fields.size(); ++k)
186 for (j = 0; j < fielddef2[i]->m_fields.size(); ++j)
188 if (fielddef1[i]->m_fields[k] == fielddef2[i]->m_fields[j])
194 if (j == fielddef2[i]->m_fields.size())
196 cout <<
"Warning: Field \'" << fielddef1[i]->m_fields[k]
197 <<
"\' was not included in output " << endl;
int main(int argc, char *argv[])
#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 ...
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.