50 ModuleKey ProcessInnerProduct::className =
53 ProcessInnerProduct::create,
54 "take inner product between two fields and return value.");
59 false,
"NotSet",
"Fld file form which to interpolate field");
61 ConfigOption(
false,
"All",
"field id's to be used in inner product");
63 false,
"NotSet",
"Take inner product of multiple field fields with "
64 "ids given in string. i.e. file_0.chk file_1.chk ...");
66 ConfigOption(
true,
"NotSet",
"Take inner product between all fromflds, "
67 "requires multifldids to be set");
78 if (
m_f->m_comm->TreatAsRankZero())
80 cout <<
"ProcessInnerProduct: Evaluating inner product..." << endl;
84 ASSERTL0(
m_f->m_exp.size() != 0,
"input xml file needs to be specified");
85 ASSERTL0(
m_f->m_data.size() != 0,
"No input data has been defined");
87 string fromfld =
m_config[
"fromfld"].as<
string>();
91 "The config parameter "
92 "fromfld needs to be defined");
96 for (
int i = 0; i <
m_f->m_exp[0]->GetExpSize(); ++i)
98 ElementGIDs[i] =
m_f->m_exp[0]->GetExp(i)->GetGeom()->GetGlobalID();
101 int nfields =
m_f->m_fielddef[0]->m_fields.size();
102 int nphys =
m_f->m_exp[0]->GetTotPoints();
104 string fields =
m_config[
"fields"].as<
string>();
105 vector<unsigned int> processFields;
106 string multifldidsstr =
m_config[
"multifldids"].as<
string>();
107 vector<unsigned int> multiFldIds;
108 vector<string> fromfiles;
109 bool allfromflds =
m_config[
"allfromflds"].m_beenSet;
111 if (fields.compare(
"All") == 0)
113 for (
int i = 0; i < nfields; ++i)
115 processFields.push_back(i);
121 "Failed to interpret field string in module innerproduct");
124 if (multifldidsstr.compare(
"NotSet") == 0)
126 fromfiles.push_back(fromfld);
132 "Failed to interpret multifldids string in module innerproduct");
133 int end = fromfld.find_first_of(
'.', 0);
134 string endstr = fromfld.substr(end, fromfld.size());
135 string bodystr = fromfld.substr(0, end);
136 for (
int i = 0; i < multiFldIds.size(); ++i)
138 string infile = bodystr +
"_" +
139 boost::lexical_cast<
string>(multiFldIds[i]) +
141 fromfiles.push_back(infile);
146 for (
int j = 0; j < processFields.size(); ++j)
148 int fid = processFields[j];
150 m_f->m_exp[fid]->BwdTrans(
m_f->m_exp[fid]->GetCoeffs(), SaveFld[j]);
153 if (allfromflds ==
false)
156 for (
int f = 0; f < fromfiles.size(); ++f)
158 m_f->FieldIOForFile(fromfiles[f])->Import(
159 fromfiles[f], fromField->m_fielddef, fromField->m_data,
162 totiprod =
IProduct(processFields, fromField, SaveFld);
164 if (
m_f->m_comm->GetRank() == 0)
166 cout <<
"Inner Product WRT " << fromfiles[f] <<
" : "
177 for (
int i = 0; i < fromfiles.size(); ++i)
179 allFromField[i] = boost::shared_ptr<Field>(
new Field());
181 m_f->FieldIOForFile(fromfiles[i])->Import(
182 fromfiles[i], allFromField[i]->m_fielddef,
187 for (
int g = 0; g < fromfiles.size(); ++g)
189 for (
int j = 0; j < processFields.size(); ++j)
191 int fid = processFields[j];
194 for (
int i = 0; i < allFromField[g]->m_data.size(); ++i)
196 m_f->m_exp[fid]->ExtractDataToCoeffs(
197 allFromField[g]->m_fielddef[i],
198 allFromField[g]->m_data[i],
199 allFromField[g]->m_fielddef[i]->m_fields[fid],
200 m_f->m_exp[fid]->UpdateCoeffs());
203 m_f->m_exp[fid]->BwdTrans(
m_f->m_exp[fid]->GetCoeffs(),
208 for (
int f = g; f < fromfiles.size(); ++f)
210 totiprod =
IProduct(processFields, allFromField[f], SaveFld);
212 if (
m_f->m_comm->GetRank() == 0)
214 cout <<
"Inner Product of " << fromfiles[g] <<
" WRT "
215 << fromfiles[f] <<
" : " << totiprod << endl;
223 vector<unsigned int> &processFields,
227 int nphys =
m_f->m_exp[0]->GetTotPoints();
230 for (
int j = 0; j < processFields.size(); ++j)
232 int fid = processFields[j];
235 for (
int i = 0; i < fromField->m_data.size(); ++i)
237 m_f->m_exp[fid]->ExtractDataToCoeffs(
238 fromField->m_fielddef[i], fromField->m_data[i],
239 fromField->m_fielddef[i]->m_fields[fid],
240 m_f->m_exp[fid]->UpdateCoeffs());
243 m_f->m_exp[fid]->BwdTrans(
m_f->m_exp[fid]->GetCoeffs(),
244 m_f->m_exp[fid]->UpdatePhys());
247 m_f->m_exp[fid]->UpdatePhys(), 1);
250 m_f->m_exp[fid]->PhysIntegral(
m_f->m_exp[fid]->UpdatePhys());
map< string, ConfigOption > m_config
List of configuration values.
#define ASSERTL0(condition, msg)
virtual void Process(po::variables_map &vm)
Write mesh to output file.
Represents a command-line configuration option.
pair< ModuleType, string > ModuleKey
virtual ~ProcessInnerProduct()
static bool GenerateSeqVector(const char *const str, std::vector< unsigned int > &vec)
boost::shared_ptr< Field > FieldSharedPtr
NekDouble IProduct(vector< unsigned int > &processFields, FieldSharedPtr &fromField, Array< OneD, const Array< OneD, NekDouble > > &SaveFld)
Abstract base class for processing modules.
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.
ModuleFactory & GetModuleFactory()
FieldSharedPtr m_f
Field object.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.