9 int main(
int argc,
char *argv[])
15 fprintf(stderr,
"Usage: AddModeTo2DFld scal1 scal2 2Dfieldfile1 fieldfile2 outfield\n"
16 "\t produces scal1*2Dfieldfiel1 + scal2*fieldfile2 in outfield\n" );
20 scal1 = boost::lexical_cast<
double>(argv[argc-5]);
21 scal2 = boost::lexical_cast<
double>(argv[argc-4]);
28 string fieldfile1(argv[argc-3]);
29 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef1;
30 vector<vector<NekDouble> > fielddata1;
36 string fieldfile2(argv[argc-2]);
37 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef2;
38 vector<vector<NekDouble> > fielddata2;
42 vector<vector<NekDouble> > combineddata;
44 ASSERTL0(fielddata1.size() == fielddata2.size(),
"Inner has different size");
53 for(i = 0; i < fielddata2.size(); ++i)
55 ASSERTL0(fielddef2[i]->m_numHomogeneousDir == 1,
"Expected second fld to have one homogeneous direction");
56 ASSERTL0(fielddef2[i]->m_numModes[2] == 2,
"Expected Fourier field to have 2 modes");
58 int datalen1 = fielddata1[i].size()/fielddef1[i]->m_fields.size();
59 int datalen2 = fielddata2[i].size()/fielddef2[i]->m_fields.size();
61 ASSERTL0(datalen1*2 == datalen2,
"Data per fields is note compatible");
65 switch(fielddef2[i]->m_shapeType)
71 ncoeffs = fielddef2[i]->m_numModes[0]*fielddef2[i]->m_numModes[1];
74 ASSERTL0(
false,
"Shape not recognised");
82 Vmath::Smul(fielddata1[i].size(), scal1, &fielddata1[i][0], 1,
83 &fielddata1[i][0], 1);
84 Vmath::Smul(fielddata2[i].size(), scal2, &fielddata2[i][0], 1,
85 &fielddata2[i][0], 1);
89 vector<NekDouble> newdata;
90 vec_iter = fielddata2[i].begin();
92 for(k = 0; k < fielddef2[i]->m_fields.size(); ++k)
96 for(j = 0; j < fielddef1[i]->m_fields.size(); ++j)
98 if(fielddef1[i]->m_fields[j] == fielddef2[i]->m_fields[k])
105 if(j != fielddef1[i]->m_fields.size())
107 for(n = 0; n < fielddef2[i]->m_elementIDs.size(); ++n)
110 newdata.insert(newdata.end(),
111 &(fielddata1[i][offset+n*ncoeffs]),
112 &(fielddata1[i][offset+n*ncoeffs])
116 newdata.insert(newdata.end(),&Zero[0],&Zero[0] + ncoeffs);
119 newdata.insert(newdata.end(),vec_iter, vec_iter+2*ncoeffs);
120 vec_iter += 2*ncoeffs;
126 for(n = 0; n < fielddef2[i]->m_elementIDs.size(); ++n)
129 newdata.insert(newdata.end(),&Zero[0],&Zero[0] + ncoeffs);
130 newdata.insert(newdata.end(),&Zero[0],&Zero[0] + ncoeffs);
133 newdata.insert(newdata.end(),vec_iter, vec_iter+2*ncoeffs);
134 vec_iter += 2*ncoeffs;
138 combineddata.push_back(newdata);
139 fielddef2[i]->m_numModes[2] += 2;
140 fielddef2[i]->m_homogeneousZIDs.push_back(2);
141 fielddef2[i]->m_homogeneousZIDs.push_back(3);
145 for(k = 0; k < fielddef1[i]->m_fields.size(); ++k)
147 for(j = 0; j < fielddef2[i]->m_fields.size(); ++j)
149 if(fielddef1[i]->m_fields[k] == fielddef2[i]->m_fields[j])
155 if(j == fielddef2[i]->m_fields.size())
157 cout <<
"Warning: Field \'" << fielddef1[i]->m_fields[k]
158 <<
"\' 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 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.