10 int main(
int argc,
char *argv[])
16 fprintf(stderr,
"Usage: FldAddFld scal1 scal2 fieldfile1 fieldfile2 outfield\n"
17 "\t produces scal1*fieldfiel1 + scal2*fieldfile2 in outfield\n" );
21 scal1 = boost::lexical_cast<
double>(argv[argc-5]);
22 scal2 = boost::lexical_cast<
double>(argv[argc-4]);
29 string fieldfile1(argv[argc-3]);
30 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef1;
31 vector<vector<NekDouble> > fielddata1;
37 string fieldfile2(argv[argc-2]);
38 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef2;
39 vector<vector<NekDouble> > fielddata2;
44 ASSERTL0(fielddata1.size() == fielddata2.size(),
"Inner has different size");
50 for(
int i = 0; i < fielddata1.size(); ++i)
53 int datalen1 = fielddata1[i].size()/fielddef1[i]->m_fields.size();
54 int datalen2 = fielddata2[i].size()/fielddef2[i]->m_fields.size();
56 ASSERTL0(datalen1 == datalen2,
"Data per field is of different length");
58 for(
int k = 0; k < fielddef1[i]->m_fields.size(); ++k)
61 for(j = 0; j < fielddef2[i]->m_fields.size(); ++j)
63 if(fielddef1[i]->m_fields[k] == fielddef2[i]->m_fields[j])
70 if(j == fielddef2[i]->m_fields.size())
72 for(j = 0; j < datalen1; ++j)
74 fielddata1[i][datalen1*k+j] *= scal1;
79 for(j = 0; j < datalen1; ++j)
81 fielddata1[i][datalen1*k+j] *= scal1;
82 fielddata1[i][datalen1*k+j] += scal2*fielddata2[i][offset + j];
90 for(
int k = 0; k < fielddef2[i]->m_fields.size(); ++k)
92 for(j = 0; j < fielddef1[i]->m_fields.size(); ++j)
94 if(fielddef2[i]->m_fields[k] == fielddef1[i]->m_fields[j])
100 if(j == fielddef1[i]->m_fields.size())
102 for(j = 0; j < datalen2; ++j)
104 fielddata2[i][datalen2*k+j] *= scal2;
108 fielddef1[i]->m_fields.push_back(fielddef2[i]->m_fields[k]);
109 fielddata1[i].insert(fielddata1[i].end(),&(fielddata2[i][k*datalen2]),
110 &(fielddata2[i][k*datalen2])+datalen1);
#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)
This function allows for data to be imported from an FLD file when a session and/or communicator is n...
int main(int argc, char *argv[])
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 ...
Base class for a spectral/hp element mesh.