48 "add two fields together with optional scaling. Must specify fromfld and "
49 "scaling is optionally specified with input option scale.");
56 ConfigOption(
false,
"NotSet",
"Fld file form which to add field");
58 if (f->m_inputfiles.count(
"xml"))
74 string scalestr =
m_config[
"scale"].as<
string>();
78 "Need to specify fromfld=file.fld ");
79 string fromfld =
m_config[
"fromfld"].as<
string>();
81 vector<LibUtilities::FieldDefinitionsSharedPtr> fromFieldDef;
82 vector<vector<double>> fromFieldData;
87 m_f->m_graph->GetExpansionInfo();
93 if (!expansions.size())
101 for (
auto &expIt : expansions)
103 ElementGIDs[i++] = expIt.second->m_geomShPtr->GetGlobalID();
105 m_f->FieldIOForFile(fromfld)->Import(
106 fromfld, fromFieldDef, fromFieldData,
111 m_f->FieldIOForFile(fromfld)->Import(
112 fromfld, fromFieldDef, fromFieldData,
116 bool samelength =
true;
117 if (fromFieldData.size() !=
m_f->m_data.size())
123 for (
int i = 0; i < fromFieldData.size(); ++i)
125 int datalen = fromFieldData[i].size();
127 Vmath::Smul(datalen, scale, &(fromFieldData[i][0]), 1,
128 &(fromFieldData[i][0]), 1);
132 if (datalen !=
m_f->m_data[i].size())
142 "Input fields have partitions of different length and so xml "
143 "file needs to be specified");
144 for (
int i = 0; i <
m_f->m_data.size(); ++i)
146 int datalen =
m_f->m_data[i].size();
149 &(fromFieldData[i][0]), 1, &(
m_f->m_data[i][0]), 1);
155 if (
m_f->m_exp[0]->GetNumElmts() == 0)
160 int nfields =
m_f->m_variables.size();
161 int ncoeffs =
m_f->m_exp[0]->GetNcoeffs();
164 for (
int j = 0; j < nfields; ++j)
170 find(fromFieldDef[0]->m_fields.begin(),
171 fromFieldDef[0]->m_fields.end(),
m_f->m_variables[j]);
173 ASSERTL0(it != fromFieldDef[0]->m_fields.end(),
174 "Could not find field " +
m_f->m_variables[j] +
178 for (
int i = 0; i < fromFieldData.size(); ++i)
180 m_f->m_exp[j]->ExtractDataToCoeffs(
181 fromFieldDef[i], fromFieldData[i],
m_f->m_variables[j],
182 m_f->m_exp[j]->UpdateCoeffs());
186 m_f->m_exp[j]->UpdateCoeffs(), 1);
187 m_f->m_exp[j]->BwdTrans(
m_f->m_exp[j]->GetCoeffs(),
188 m_f->m_exp[j]->UpdatePhys());
#define ASSERTL0(condition, msg)
FieldSharedPtr m_f
Field object.
std::map< std::string, ConfigOption > m_config
List of configuration values.
~ProcessAddFld() override
static ModuleKey className
void v_Process(po::variables_map &vm) override
Write mesh to output file.
ProcessAddFld(FieldSharedPtr f)
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
ModulePriority m_priority
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
std::shared_ptr< Field > FieldSharedPtr
std::pair< ModuleType, std::string > ModuleKey
ModuleFactory & GetModuleFactory()
static FieldMetaDataMap NullFieldMetaDataMap
std::map< int, ExpansionInfoShPtr > ExpansionInfoMap
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
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.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Represents a command-line configuration option.