52 ProcessAddFld::create,
"rescale input field by a constant factor.");
56 if((f->m_inputfiles.count(
"fld") == 0) &&
57 (f->m_inputfiles.count(
"rst") == 0) &&
58 (f->m_inputfiles.count(
"chk") == 0))
60 cout <<
"A fld, chk or rst input file must be specified for the "
61 "scaleinputfld module" << endl;
68 "Fld file form which to interpolate field");
71 "Need to specify fromfld=file.fld ");
83 cout <<
"ProcessAddFld: Adding new fld to input fld" << endl;
86 ASSERTL0(
m_f->m_data.size() != 0,
"No input data defined");
88 string scalestr =
m_config[
"scale"].as<
string>();
91 string fromfld =
m_config[
"fromfld"].as<
string>();
97 Array<OneD,int> ElementGIDs(
m_f->m_exp[0]->GetExpSize());
98 for (
int i = 0; i <
m_f->m_exp[0]->GetExpSize(); ++i)
100 ElementGIDs[i] =
m_f->m_exp[0]->GetExp(i)->GetGeom()->GetGlobalID();
102 m_f->m_fld->Import(fromfld,m_fromField->m_fielddef,
109 m_f->m_fld->Import(fromfld,m_fromField->m_fielddef,
114 bool samelength =
true;
115 if(m_fromField->m_data.size() !=
m_f->m_data.size())
121 for(
int i = 0; i < m_fromField->m_data.size(); ++i)
123 int datalen = m_fromField->m_data[i].size();
125 Vmath::Smul(datalen, scale, &(m_fromField->m_data[i][0]), 1,
126 &(m_fromField->m_data[i][0]), 1);
130 if(datalen !=
m_f->m_data[i].size())
137 if(samelength ==
true)
140 for(
int i = 0; i <
m_f->m_data.size(); ++i)
142 int datalen =
m_f->m_data[i].size();
145 &(m_fromField->m_data[i][0]), 1,
146 &(
m_f->m_data[i][0]), 1);
152 "Input fields have partitions of different length and so xml "
153 "file needs to be specified");
155 int nfields =
m_f->m_fielddef[0]->m_fields.size();
156 int ncoeffs =
m_f->m_exp[0]->GetNcoeffs();
157 Array<OneD, NekDouble> SaveFld(ncoeffs);
159 for (
int j = 0; j < nfields; ++j)
164 for (
int i = 0; i < m_fromField->m_data.size(); ++i)
166 m_f->m_exp[j]->ExtractDataToCoeffs(
167 m_fromField->m_fielddef[i],
168 m_fromField->m_data[i],
169 m_fromField->m_fielddef[i]->m_fields[j],
170 m_f->m_exp[j]->UpdateCoeffs());
175 m_f->m_exp[j]->UpdateCoeffs(), 1);
178 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
179 =
m_f->m_exp[0]->GetFieldDefinitions();
180 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
182 for(
int i = 0; i < nfields; ++i)
184 for (
int j = 0; j < FieldDef.size(); ++j)
186 FieldDef[j]->m_fields.push_back(
m_f->m_fielddef[0]->m_fields[i]);
187 m_f->m_exp[i]->AppendFieldData(FieldDef[j], FieldData[j]);
191 m_f->m_fielddef = FieldDef;
192 m_f->m_data = FieldData;