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");
65 "Take inner product of multiple field fields with "
66 "ids given in string. i.e. file_0.chk file_1.chk ...");
70 "Take inner product between all fromflds, "
71 "requires multifldids to be set");
82 cout <<
"ProcessInnerProduct: Evaluating inner product" << endl;
85 ASSERTL0(
m_f->m_exp.size() != 0,
"input xml file needs to be specified");
86 ASSERTL0(
m_f->m_data.size() != 0,
"No input data has been defined");
88 string fromfld =
m_config[
"fromfld"].as<
string>();
92 "The config parameter "
93 "fromfld needs to be defined");
97 for (
int i = 0; i <
m_f->m_exp[0]->GetExpSize(); ++i)
99 ElementGIDs[i] =
m_f->m_exp[0]->GetExp(i)->GetGeom()->GetGlobalID();
102 int nfields =
m_f->m_fielddef[0]->m_fields.size();
103 int nphys =
m_f->m_exp[0]->GetTotPoints();
105 string fields =
m_config[
"fields"].as<
string>();
106 vector<unsigned int> processFields;
107 string multifldidsstr =
m_config[
"multifldids"].as<
string>();
108 vector<unsigned int> multiFldIds;
109 vector<string> fromfiles;
110 bool allfromflds =
m_config[
"allfromflds"].m_beenSet;
112 if (fields.compare(
"All") == 0)
114 for (
int i = 0; i < nfields; ++i)
116 processFields.push_back(i);
122 "Failed to interpret field string in module innerproduct");
125 if (multifldidsstr.compare(
"NotSet") == 0)
127 fromfiles.push_back(fromfld);
133 "Failed to interpret multifldids string in module innerproduct");
134 int end = fromfld.find_first_of(
'.', 0);
135 string endstr = fromfld.substr(end, fromfld.size());
136 string bodystr = fromfld.substr(0, end);
137 for (
int i = 0; i < multiFldIds.size(); ++i)
139 string infile = bodystr +
"_" +
140 boost::lexical_cast<
string>(multiFldIds[i]) +
142 fromfiles.push_back(infile);
147 for (
int j = 0; j < processFields.size(); ++j)
149 int fid = processFields[j];
151 m_f->m_exp[fid]->BwdTrans(
m_f->m_exp[fid]->GetCoeffs(), SaveFld[j]);
154 if (allfromflds ==
false)
157 for (
int f = 0; f < fromfiles.size(); ++f)
159 m_f->m_fld->Import(fromfiles[f],
160 fromField->m_fielddef,
165 totiprod =
IProduct(processFields, fromField, SaveFld);
167 if (
m_f->m_comm->GetRank() == 0)
169 cout <<
"Inner Product WRT " << fromfiles[f] <<
" : "
180 for (
int i = 0; i < fromfiles.size(); ++i)
182 allFromField[i] = boost::shared_ptr<Field>(
new Field());
183 m_f->m_fld->Import(fromfiles[i],
184 allFromField[i]->m_fielddef,
185 allFromField[i]->m_data,
190 for (
int g = 0; g < fromfiles.size(); ++g)
192 for (
int j = 0; j < processFields.size(); ++j)
194 int fid = processFields[j];
197 for (
int i = 0; i < allFromField[g]->m_data.size(); ++i)
199 m_f->m_exp[fid]->ExtractDataToCoeffs(
200 allFromField[g]->m_fielddef[i],
201 allFromField[g]->m_data[i],
202 allFromField[g]->m_fielddef[i]->m_fields[fid],
203 m_f->m_exp[fid]->UpdateCoeffs());
206 m_f->m_exp[fid]->BwdTrans(
m_f->m_exp[fid]->GetCoeffs(),
211 for (
int f = g; f < fromfiles.size(); ++f)
213 totiprod =
IProduct(processFields, allFromField[f], SaveFld);
215 if (
m_f->m_comm->GetRank() == 0)
217 cout <<
"Inner Product of " << fromfiles[g] <<
" WRT "
218 << fromfiles[f] <<
" : " << totiprod << endl;
226 vector<unsigned int> &processFields,
230 int nphys =
m_f->m_exp[0]->GetTotPoints();
233 for (
int j = 0; j < processFields.size(); ++j)
235 int fid = processFields[j];
238 for (
int i = 0; i < fromField->m_data.size(); ++i)
240 m_f->m_exp[fid]->ExtractDataToCoeffs(
241 fromField->m_fielddef[i],
242 fromField->m_data[i],
243 fromField->m_fielddef[i]->m_fields[fid],
244 m_f->m_exp[fid]->UpdateCoeffs());
247 m_f->m_exp[fid]->BwdTrans(
m_f->m_exp[fid]->GetCoeffs(),
248 m_f->m_exp[fid]->UpdatePhys());
253 m_f->m_exp[fid]->GetPhys(),
255 m_f->m_exp[fid]->UpdatePhys(),
259 m_f->m_exp[fid]->PhysIntegral(
m_f->m_exp[fid]->UpdatePhys());
#define ASSERTL0(condition, msg)
pair< ModuleType, string > ModuleKey
map< string, ConfigOption > m_config
List of configuration values.
NekDouble IProduct(vector< unsigned int > &processFields, FieldSharedPtr &fromField, Array< OneD, const Array< OneD, NekDouble > > &SaveFld)
static bool GenerateSeqVector(const char *const str, std::vector< unsigned int > &vec)
FieldSharedPtr m_f
Field object.
boost::shared_ptr< Field > FieldSharedPtr
Represents a command-line configuration option.
virtual ~ProcessInnerProduct()
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()
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.