8 int main(
int argc,
char *argv[])
14 fprintf(stderr,
"Usage: AddModeTo2DFld scal1 scal2 2Dfieldfile1 fieldfile2 outfield\n"
15 "\t produces scal1*2Dfieldfiel1 + scal2*fieldfile2 in outfield\n" );
19 scal1 = boost::lexical_cast<
double>(argv[argc-5]);
20 scal2 = boost::lexical_cast<
double>(argv[argc-4]);
27 string fieldfile1(argv[argc-3]);
28 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef1;
29 vector<vector<NekDouble> > fielddata1;
35 string fieldfile2(argv[argc-2]);
36 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef2;
37 vector<vector<NekDouble> > fielddata2;
41 vector<vector<NekDouble> > combineddata;
43 ASSERTL0(fielddata1.size() == fielddata2.size(),
"Inner has different size");
52 for(i = 0; i < fielddata2.size(); ++i)
54 ASSERTL0(fielddef2[i]->m_numHomogeneousDir == 1,
"Expected second fld to have one homogeneous direction");
55 ASSERTL0(fielddef2[i]->m_numModes[2] == 2,
"Expected Fourier field to have 2 modes");
57 int datalen1 = fielddata1[i].size()/fielddef1[i]->m_fields.size();
58 int datalen2 = fielddata2[i].size()/fielddef2[i]->m_fields.size();
60 ASSERTL0(datalen1*2 == datalen2,
"Data per fields is note compatible");
64 switch(fielddef2[i]->m_shapeType)
70 ncoeffs = fielddef2[i]->m_numModes[0]*fielddef2[i]->m_numModes[1];
73 ASSERTL0(
false,
"Shape not recognised");
81 Vmath::Smul(fielddata1[i].size(), scal1, &fielddata1[i][0], 1,
82 &fielddata1[i][0], 1);
83 Vmath::Smul(fielddata2[i].size(), scal2, &fielddata2[i][0], 1,
84 &fielddata2[i][0], 1);
88 vector<NekDouble> newdata;
89 vec_iter = fielddata2[i].begin();
91 for(k = 0; k < fielddef2[i]->m_fields.size(); ++k)
95 for(j = 0; j < fielddef1[i]->m_fields.size(); ++j)
97 if(fielddef1[i]->m_fields[j] == fielddef2[i]->m_fields[k])
104 if(j != fielddef1[i]->m_fields.size())
106 for(n = 0; n < fielddef2[i]->m_elementIDs.size(); ++n)
109 newdata.insert(newdata.end(),
110 &(fielddata1[i][offset+n*ncoeffs]),
111 &(fielddata1[i][offset+n*ncoeffs])
115 newdata.insert(newdata.end(),&Zero[0],&Zero[0] + ncoeffs);
118 newdata.insert(newdata.end(),vec_iter, vec_iter+2*ncoeffs);
119 vec_iter += 2*ncoeffs;
125 for(n = 0; n < fielddef2[i]->m_elementIDs.size(); ++n)
128 newdata.insert(newdata.end(),&Zero[0],&Zero[0] + ncoeffs);
129 newdata.insert(newdata.end(),&Zero[0],&Zero[0] + ncoeffs);
132 newdata.insert(newdata.end(),vec_iter, vec_iter+2*ncoeffs);
133 vec_iter += 2*ncoeffs;
137 combineddata.push_back(newdata);
138 fielddef2[i]->m_numModes[2] += 2;
139 fielddef2[i]->m_homogeneousZIDs.push_back(2);
140 fielddef2[i]->m_homogeneousZIDs.push_back(3);
144 for(k = 0; k < fielddef1[i]->m_fields.size(); ++k)
146 for(j = 0; j < fielddef2[i]->m_fields.size(); ++j)
148 if(fielddef1[i]->m_fields[k] == fielddef2[i]->m_fields[j])
154 if(j == fielddef2[i]->m_fields.size())
156 cout <<
"Warning: Field \'" << fielddef1[i]->m_fields[k]
157 <<
"\' was not included in output " << endl;
#define ASSERTL0(condition, msg)
void Import(const std::string &infilename, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, FieldMetaDataMap &fieldinfomap, const Array< OneD, int > ElementiDs)
Imports an FLD file.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
int getNumberOfCoefficients(int Na, int Nb)
int main(int argc, char *argv[])
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
Base class for a spectral/hp element mesh.
void Write(const std::string &outFile, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, const FieldMetaDataMap &fieldinfomap)
Write a field file in serial only.
void Zero(int n, T *x, const int incx)
Zero vector.