53 ProcessAddFld::create,
"rescale input field by a constant factor.");
57 if((f->m_inputfiles.count(
"fld") == 0) &&
58 (f->m_inputfiles.count(
"rst") == 0) &&
59 (f->m_inputfiles.count(
"chk") == 0))
61 cout <<
"A fld, chk or rst input file must be specified for the "
62 "scaleinputfld module" << endl;
69 "Fld file form which to interpolate field");
72 "Need to specify fromfld=file.fld ");
84 cout <<
"ProcessAddFld: Adding new fld to input fld" << endl;
87 ASSERTL0(
m_f->m_data.size() != 0,
"No input data defined");
89 string scalestr =
m_config[
"scale"].as<
string>();
92 string fromfld =
m_config[
"fromfld"].as<
string>();
98 Array<OneD,int> ElementGIDs(
m_f->m_exp[0]->GetExpSize());
99 for (
int i = 0; i <
m_f->m_exp[0]->GetExpSize(); ++i)
101 ElementGIDs[i] =
m_f->m_exp[0]->GetExp(i)->GetGeom()->GetGlobalID();
103 m_f->m_fld->Import(fromfld,m_fromField->m_fielddef,
110 m_f->m_fld->Import(fromfld,m_fromField->m_fielddef,
115 bool samelength =
true;
116 if(m_fromField->m_data.size() !=
m_f->m_data.size())
122 for(
int i = 0; i < m_fromField->m_data.size(); ++i)
124 int datalen = m_fromField->m_data[i].size();
126 Vmath::Smul(datalen, scale, &(m_fromField->m_data[i][0]), 1,
127 &(m_fromField->m_data[i][0]), 1);
131 if(datalen !=
m_f->m_data[i].size())
138 if(samelength ==
true)
141 for(
int i = 0; i <
m_f->m_data.size(); ++i)
143 int datalen =
m_f->m_data[i].size();
146 &(m_fromField->m_data[i][0]), 1,
147 &(
m_f->m_data[i][0]), 1);
153 "Input fields have partitions of different length and so xml "
154 "file needs to be specified");
156 int nfields =
m_f->m_fielddef[0]->m_fields.size();
157 int ncoeffs =
m_f->m_exp[0]->GetNcoeffs();
158 Array<OneD, NekDouble> SaveFld(ncoeffs);
160 for (
int j = 0; j < nfields; ++j)
165 for (
int i = 0; i < m_fromField->m_data.size(); ++i)
167 m_f->m_exp[j]->ExtractDataToCoeffs(
168 m_fromField->m_fielddef[i],
169 m_fromField->m_data[i],
170 m_fromField->m_fielddef[i]->m_fields[j],
171 m_f->m_exp[j]->UpdateCoeffs());
176 m_f->m_exp[j]->UpdateCoeffs(), 1);
179 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
180 =
m_f->m_exp[0]->GetFieldDefinitions();
181 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
183 for(
int i = 0; i < nfields; ++i)
185 for (
int j = 0; j < FieldDef.size(); ++j)
187 FieldDef[j]->m_fields.push_back(
m_f->m_fielddef[0]->m_fields[i]);
188 m_f->m_exp[i]->AppendFieldData(FieldDef[j], FieldData[j]);
192 m_f->m_fielddef = FieldDef;
193 m_f->m_data = FieldData;