39#include <boost/core/ignore_unused.hpp>
52 "add two fields together with optional scaling. Must specify fromfld and "
53 "scaling is optionally specified with input option scale.");
60 ConfigOption(
false,
"NotSet",
"Fld file form which to add field");
62 if (f->m_inputfiles.count(
"xml"))
78 boost::ignore_unused(vm);
80 string scalestr =
m_config[
"scale"].as<
string>();
81 NekDouble scale = boost::lexical_cast<NekDouble>(scalestr);
84 "Need to specify fromfld=file.fld ");
85 string fromfld =
m_config[
"fromfld"].as<
string>();
87 vector<LibUtilities::FieldDefinitionsSharedPtr> fromFieldDef;
88 vector<vector<double>> fromFieldData;
93 m_f->m_graph->GetExpansionInfo();
99 if (!expansions.size())
107 for (
auto &expIt : expansions)
109 ElementGIDs[i++] = expIt.second->m_geomShPtr->GetGlobalID();
111 m_f->FieldIOForFile(fromfld)->Import(
112 fromfld, fromFieldDef, fromFieldData,
117 m_f->FieldIOForFile(fromfld)->Import(
118 fromfld, fromFieldDef, fromFieldData,
122 bool samelength =
true;
123 if (fromFieldData.size() !=
m_f->m_data.size())
129 for (
int i = 0; i < fromFieldData.size(); ++i)
131 int datalen = fromFieldData[i].size();
133 Vmath::Smul(datalen, scale, &(fromFieldData[i][0]), 1,
134 &(fromFieldData[i][0]), 1);
138 if (datalen !=
m_f->m_data[i].size())
148 "Input fields have partitions of different length and so xml "
149 "file needs to be specified");
150 for (
int i = 0; i <
m_f->m_data.size(); ++i)
152 int datalen =
m_f->m_data[i].size();
155 &(fromFieldData[i][0]), 1, &(
m_f->m_data[i][0]), 1);
161 if (
m_f->m_exp[0]->GetNumElmts() == 0)
166 int nfields =
m_f->m_variables.size();
167 int ncoeffs =
m_f->m_exp[0]->GetNcoeffs();
170 for (
int j = 0; j < nfields; ++j)
176 find(fromFieldDef[0]->m_fields.begin(),
177 fromFieldDef[0]->m_fields.end(),
m_f->m_variables[j]);
179 ASSERTL0(it != fromFieldDef[0]->m_fields.end(),
180 "Could not find field " +
m_f->m_variables[j] +
184 for (
int i = 0; i < fromFieldData.size(); ++i)
186 m_f->m_exp[j]->ExtractDataToCoeffs(
187 fromFieldDef[i], fromFieldData[i],
m_f->m_variables[j],
188 m_f->m_exp[j]->UpdateCoeffs());
192 m_f->m_exp[j]->UpdateCoeffs(), 1);
193 m_f->m_exp[j]->BwdTrans(
m_f->m_exp[j]->GetCoeffs(),
194 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.
static ModuleKey className
virtual 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)
The above copyright notice and this permission notice shall be included.
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.