52 ProcessAddFld::create,
53 "add two fields together with optional scaling. Must specify fromfld and "
54 "scaling is optionally specified with input option scale.");
61 ConfigOption(
false,
"NotSet",
"Fld file form which to add field");
64 "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>();
89 if (
m_f->m_exp.size())
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->FieldIOForFile(fromfld)->Import(
98 fromfld, fromField->m_fielddef, fromField->m_data,
103 m_f->FieldIOForFile(fromfld)->Import(
104 fromfld, fromField->m_fielddef, fromField->m_data,
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, &(
m_f->m_data[i][0]), 1);
144 "Input fields have partitions of different length and so xml "
145 "file needs to be specified");
147 int nfields =
m_f->m_fielddef[0]->m_fields.size();
148 int ncoeffs =
m_f->m_exp[0]->GetNcoeffs();
151 for (
int j = 0; j < nfields; ++j)
158 for (nfield = 0; nfield < fromField->m_fielddef[0]->m_fields.size();
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] +
173 for (
int i = 0; i < fromField->m_data.size(); ++i)
175 m_f->m_exp[j]->ExtractDataToCoeffs(
176 fromField->m_fielddef[i], fromField->m_data[i],
177 fromField->m_fielddef[i]->m_fields[nfield],
178 m_f->m_exp[j]->UpdateCoeffs());
182 m_f->m_exp[j]->UpdateCoeffs(), 1);
185 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
186 m_f->m_exp[0]->GetFieldDefinitions();
187 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
189 for (
int i = 0; i < nfields; ++i)
191 for (
int j = 0; j < FieldDef.size(); ++j)
193 FieldDef[j]->m_fields.push_back(
194 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;
map< string, ConfigOption > m_config
List of configuration values.
#define ASSERTL0(condition, msg)
Represents a command-line configuration option.
pair< ModuleType, string > ModuleKey
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
Abstract base class for processing modules.
virtual void Process(po::variables_map &vm)
Write mesh to output file.
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()
FieldSharedPtr m_f
Field object.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.