50 "take inner product between two fields and return value.");
55 false,
"NotSet",
"Fld file form which to interpolate field");
57 ConfigOption(
false,
"All",
"field id's to be used in inner product");
60 "Take inner product of multiple field fields with "
61 "ids given in string. i.e. file_0.chk file_1.chk ...");
64 "Take inner product between all fromflds, "
65 "requires multifldids to be set");
77 if (
m_f->m_exp[0]->GetNumElmts() == 0)
82 string fromfld =
m_config[
"fromfld"].as<
string>();
86 "The config parameter "
87 "fromfld needs to be defined");
91 for (
int i = 0; i <
m_f->m_exp[0]->GetExpSize(); ++i)
93 ElementGIDs[i] =
m_f->m_exp[0]->GetExp(i)->GetGeom()->GetGlobalID();
96 int nfields =
m_f->m_variables.size();
97 int nphys =
m_f->m_exp[0]->GetTotPoints();
99 string fields =
m_config[
"fields"].as<
string>();
100 vector<unsigned int> processFields;
101 string multifldidsstr =
m_config[
"multifldids"].as<
string>();
102 vector<unsigned int> multiFldIds;
103 vector<string> fromfiles;
104 bool allfromflds =
m_config[
"allfromflds"].as<
bool>();
106 if (fields.compare(
"All") == 0)
108 for (
int i = 0; i < nfields; ++i)
110 processFields.push_back(i);
116 "Failed to interpret field string in module innerproduct");
119 if (multifldidsstr.compare(
"NotSet") == 0)
121 fromfiles.push_back(fromfld);
127 "Failed to interpret multifldids string in module innerproduct");
128 int end = fromfld.find_first_of(
'.', 0);
129 string endstr = fromfld.substr(end, fromfld.size());
130 string bodystr = fromfld.substr(0, end);
131 for (
int i = 0; i < multiFldIds.size(); ++i)
133 string infile = bodystr +
"_" +
134 boost::lexical_cast<string>(multiFldIds[i]) +
136 fromfiles.push_back(infile);
141 for (
int j = 0; j < processFields.size(); ++j)
143 int fid = processFields[j];
145 m_f->m_exp[fid]->BwdTrans(
m_f->m_exp[fid]->GetCoeffs(), SaveFld[j]);
148 if (allfromflds ==
false)
151 for (
int f = 0; f < fromfiles.size(); ++f)
153 m_f->FieldIOForFile(fromfiles[f])
154 ->Import(fromfiles[f], fromField->m_fielddef, fromField->m_data,
157 totiprod =
IProduct(processFields, fromField, SaveFld);
159 if (
m_f->m_comm->GetSpaceComm()->GetRank() == 0)
161 cout <<
"Inner Product WRT " << fromfiles[f] <<
" : "
172 for (
int i = 0; i < fromfiles.size(); ++i)
174 allFromField[i] = std::shared_ptr<Field>(
new Field());
176 m_f->FieldIOForFile(fromfiles[i])
177 ->Import(fromfiles[i], allFromField[i]->m_fielddef,
178 allFromField[i]->m_data,
182 for (
int g = 0; g < fromfiles.size(); ++g)
184 for (
int j = 0; j < processFields.size(); ++j)
186 int fid = processFields[j];
189 for (
int i = 0; i < allFromField[g]->m_data.size(); ++i)
191 m_f->m_exp[fid]->ExtractDataToCoeffs(
192 allFromField[g]->m_fielddef[i],
193 allFromField[g]->m_data[i],
m_f->m_variables[fid],
197 m_f->m_exp[fid]->BwdTrans(coeffs, SaveFld[j]);
201 for (
int f = g; f < fromfiles.size(); ++f)
203 totiprod =
IProduct(processFields, allFromField[f], SaveFld);
205 if (
m_f->m_comm->GetSpaceComm()->GetRank() == 0)
207 cout <<
"Inner Product of " << fromfiles[g] <<
" WRT "
208 << fromfiles[f] <<
" : " << totiprod << endl;
219 int nphys =
m_f->m_exp[0]->GetTotPoints();
222 for (
int j = 0; j < processFields.size(); ++j)
224 int fid = processFields[j];
230 for (
int i = 0; i < fromField->m_data.size(); ++i)
232 m_f->m_exp[fid]->ExtractDataToCoeffs(fromField->m_fielddef[i],
233 fromField->m_data[i],
234 m_f->m_variables[fid], coeffs);
237 m_f->m_exp[fid]->BwdTrans(coeffs, phys);
239 Vmath::Vmul(nphys, SaveFld[j], 1, phys, 1, phys, 1);
#define ASSERTL0(condition, msg)
FieldSharedPtr m_f
Field object.
std::map< std::string, ConfigOption > m_config
List of configuration values.
ProcessInnerProduct(FieldSharedPtr f)
~ProcessInnerProduct() override
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
static ModuleKey className
NekDouble IProduct(std::vector< unsigned int > &processFields, FieldSharedPtr &fromField, Array< OneD, const Array< OneD, NekDouble > > &SaveFld)
void v_Process(po::variables_map &vm) override
Write mesh to output file.
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
static bool GenerateSeqVector(const std::string &str, std::vector< unsigned int > &out)
Takes a comma-separated compressed string and converts it to entries in a vector.
std::shared_ptr< Field > FieldSharedPtr
std::pair< ModuleType, std::string > ModuleKey
ModuleFactory & GetModuleFactory()
static FieldMetaDataMap NullFieldMetaDataMap
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Represents a command-line configuration option.