53 ProcessAddFld::create,
"add two fields together with optional scaling. Must specify fromfld and scaling is optionally specified with input option scale.");
60 "Fld file form which to add field");
63 "Need to specify fromfld=file.fld ");
75 if(
m_f->m_comm->TreatAsRankZero())
77 cout <<
"ProcessAddFld: Adding new fld to input fld..." << endl;
81 ASSERTL0(
m_f->m_data.size() != 0,
"No input data defined");
83 string scalestr =
m_config[
"scale"].as<
string>();
86 string fromfld =
m_config[
"fromfld"].as<
string>();
93 for (
int i = 0; i <
m_f->m_exp[0]->GetExpSize(); ++i)
95 ElementGIDs[i] =
m_f->m_exp[0]->GetExp(i)->GetGeom()->GetGlobalID();
97 m_f->m_fld->Import(fromfld,
98 fromField->m_fielddef,
105 m_f->m_fld->Import(fromfld,
106 fromField->m_fielddef,
111 bool samelength =
true;
112 if(fromField->m_data.size() !=
m_f->m_data.size())
118 for(
int i = 0; i < fromField->m_data.size(); ++i)
120 int datalen = fromField->m_data[i].size();
122 Vmath::Smul(datalen, scale, &(fromField->m_data[i][0]), 1,
123 &(fromField->m_data[i][0]), 1);
127 if(datalen !=
m_f->m_data[i].size())
134 if(samelength ==
true)
136 for(
int i = 0; i <
m_f->m_data.size(); ++i)
138 int datalen =
m_f->m_data[i].size();
141 &(fromField->m_data[i][0]), 1,
142 &(
m_f->m_data[i][0]), 1);
148 "Input fields have partitions of different length and so xml "
149 "file needs to be specified");
151 int nfields =
m_f->m_fielddef[0]->m_fields.size();
152 int ncoeffs =
m_f->m_exp[0]->GetNcoeffs();
155 for (
int j = 0; j < nfields; ++j)
162 for (nfield = 0; nfield < fromField->m_fielddef[0]->m_fields.size(); ++nfield)
164 if(fromField->m_fielddef[0]->m_fields[nfield] ==
165 m_f->m_fielddef[0]->m_fields[j])
171 ASSERTL0(nfield != fromField->m_fielddef[0]->m_fields.size(),
172 "Could not find field " +
m_f->m_fielddef[0]->m_fields[j] +
" in from field");
175 for (
int i = 0; i < fromField->m_data.size(); ++i)
177 m_f->m_exp[j]->ExtractDataToCoeffs(
178 fromField->m_fielddef[i],
179 fromField->m_data[i],
180 fromField->m_fielddef[i]->m_fields[nfield],
181 m_f->m_exp[j]->UpdateCoeffs());
186 m_f->m_exp[j]->UpdateCoeffs(), 1);
189 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
190 =
m_f->m_exp[0]->GetFieldDefinitions();
191 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
193 for(
int i = 0; i < nfields; ++i)
195 for (
int j = 0; j < FieldDef.size(); ++j)
197 FieldDef[j]->m_fields.push_back(
m_f->m_fielddef[0]->m_fields[i]);
198 m_f->m_exp[i]->AppendFieldData(FieldDef[j], FieldData[j]);
202 m_f->m_fielddef = FieldDef;
203 m_f->m_data = FieldData;
#define ASSERTL0(condition, msg)
pair< ModuleType, string > ModuleKey
map< string, ConfigOption > m_config
List of configuration values.
FieldSharedPtr m_f
Field object.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
boost::shared_ptr< Field > FieldSharedPtr
Represents a command-line configuration option.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
static FieldMetaDataMap NullFieldMetaDataMap
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
ModuleFactory & GetModuleFactory()
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.