7 using namespace Nektar;
9 int main(
int argc,
char *argv[])
15 fprintf(stderr,
"Usage: FldAddFld scal1 scal2 fieldfile1 fieldfile2 outfield\n"
16 "\t produces scal1*fieldfiel1 + 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;
43 ASSERTL0(fielddata1.size() == fielddata2.size(),
"Inner has different size");
49 for(
int i = 0; i < fielddata1.size(); ++i)
52 int datalen1 = fielddata1[i].size()/fielddef1[i]->m_fields.size();
53 int datalen2 = fielddata2[i].size()/fielddef2[i]->m_fields.size();
55 ASSERTL0(datalen1 == datalen2,
"Data per field is of different length");
57 for(
int k = 0; k < fielddef1[i]->m_fields.size(); ++k)
60 for(j = 0; j < fielddef2[i]->m_fields.size(); ++j)
62 if(fielddef1[i]->m_fields[k] == fielddef2[i]->m_fields[j])
69 if(j == fielddef2[i]->m_fields.size())
71 for(j = 0; j < datalen1; ++j)
73 fielddata1[i][datalen1*k+j] *= scal1;
78 for(j = 0; j < datalen1; ++j)
80 fielddata1[i][datalen1*k+j] *= scal1;
81 fielddata1[i][datalen1*k+j] += scal2*fielddata2[i][offset + j];
89 for(
int k = 0; k < fielddef2[i]->m_fields.size(); ++k)
91 for(j = 0; j < fielddef1[i]->m_fields.size(); ++j)
93 if(fielddef2[i]->m_fields[k] == fielddef1[i]->m_fields[j])
99 if(j == fielddef1[i]->m_fields.size())
101 for(j = 0; j < datalen2; ++j)
103 fielddata2[i][datalen2*k+j] *= scal2;
107 fielddef1[i]->m_fields.push_back(fielddef2[i]->m_fields[k]);
108 fielddata1[i].insert(fielddata1[i].end(),&(fielddata2[i][k*datalen2]),
109 &(fielddata2[i][k*datalen2])+datalen1);