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 cout <<
"ProcessAddFld: Adding new fld to input fld" << endl;
78 ASSERTL0(
m_f->m_data.size() != 0,
"No input data defined");
80 string scalestr =
m_config[
"scale"].as<
string>();
83 string fromfld =
m_config[
"fromfld"].as<
string>();
90 for (
int i = 0; i <
m_f->m_exp[0]->GetExpSize(); ++i)
92 ElementGIDs[i] =
m_f->m_exp[0]->GetExp(i)->GetGeom()->GetGlobalID();
94 m_f->m_fld->Import(fromfld,
95 fromField->m_fielddef,
102 m_f->m_fld->Import(fromfld,
103 fromField->m_fielddef,
108 bool samelength =
true;
109 if(fromField->m_data.size() !=
m_f->m_data.size())
115 for(
int i = 0; i < fromField->m_data.size(); ++i)
117 int datalen = fromField->m_data[i].size();
119 Vmath::Smul(datalen, scale, &(fromField->m_data[i][0]), 1,
120 &(fromField->m_data[i][0]), 1);
124 if(datalen !=
m_f->m_data[i].size())
131 if(samelength ==
true)
133 for(
int i = 0; i <
m_f->m_data.size(); ++i)
135 int datalen =
m_f->m_data[i].size();
138 &(fromField->m_data[i][0]), 1,
139 &(
m_f->m_data[i][0]), 1);
145 "Input fields have partitions of different length and so xml "
146 "file needs to be specified");
148 int nfields =
m_f->m_fielddef[0]->m_fields.size();
149 int ncoeffs =
m_f->m_exp[0]->GetNcoeffs();
152 for (
int j = 0; j < nfields; ++j)
159 for (nfield = 0; nfield < fromField->m_fielddef[0]->m_fields.size(); ++nfield)
161 if(fromField->m_fielddef[0]->m_fields[nfield] ==
162 m_f->m_fielddef[0]->m_fields[j])
168 ASSERTL0(nfield != fromField->m_fielddef[0]->m_fields.size(),
169 "Could not find field " +
m_f->m_fielddef[0]->m_fields[j] +
" in from field");
172 for (
int i = 0; i < fromField->m_data.size(); ++i)
174 m_f->m_exp[j]->ExtractDataToCoeffs(
175 fromField->m_fielddef[i],
176 fromField->m_data[i],
177 fromField->m_fielddef[i]->m_fields[nfield],
178 m_f->m_exp[j]->UpdateCoeffs());
183 m_f->m_exp[j]->UpdateCoeffs(), 1);
186 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
187 =
m_f->m_exp[0]->GetFieldDefinitions();
188 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
190 for(
int i = 0; i < nfields; ++i)
192 for (
int j = 0; j < FieldDef.size(); ++j)
194 FieldDef[j]->m_fields.push_back(
m_f->m_fielddef[0]->m_fields[i]);
195 m_f->m_exp[i]->AppendFieldData(FieldDef[j], FieldData[j]);
199 m_f->m_fielddef = FieldDef;
200 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.