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 if(
m_f->m_comm->GetRank() == 0)
84 cout <<
"ProcessInnerProduct: Evaluating inner product..." << endl;
88 ASSERTL0(
m_f->m_exp.size() != 0,
"input xml file needs to be specified");
89 ASSERTL0(
m_f->m_data.size() != 0,
"No input data has been defined");
91 string fromfld =
m_config[
"fromfld"].as<
string>();
95 "The config parameter "
96 "fromfld needs to be defined");
100 for (
int i = 0; i <
m_f->m_exp[0]->GetExpSize(); ++i)
102 ElementGIDs[i] =
m_f->m_exp[0]->GetExp(i)->GetGeom()->GetGlobalID();
105 int nfields =
m_f->m_fielddef[0]->m_fields.size();
106 int nphys =
m_f->m_exp[0]->GetTotPoints();
108 string fields =
m_config[
"fields"].as<
string>();
109 vector<unsigned int> processFields;
110 string multifldidsstr =
m_config[
"multifldids"].as<
string>();
111 vector<unsigned int> multiFldIds;
112 vector<string> fromfiles;
113 bool allfromflds =
m_config[
"allfromflds"].m_beenSet;
115 if (fields.compare(
"All") == 0)
117 for (
int i = 0; i < nfields; ++i)
119 processFields.push_back(i);
125 "Failed to interpret field string in module innerproduct");
128 if (multifldidsstr.compare(
"NotSet") == 0)
130 fromfiles.push_back(fromfld);
136 "Failed to interpret multifldids string in module innerproduct");
137 int end = fromfld.find_first_of(
'.', 0);
138 string endstr = fromfld.substr(end, fromfld.size());
139 string bodystr = fromfld.substr(0, end);
140 for (
int i = 0; i < multiFldIds.size(); ++i)
142 string infile = bodystr +
"_" +
143 boost::lexical_cast<
string>(multiFldIds[i]) +
145 fromfiles.push_back(infile);
150 for (
int j = 0; j < processFields.size(); ++j)
152 int fid = processFields[j];
154 m_f->m_exp[fid]->BwdTrans(
m_f->m_exp[fid]->GetCoeffs(), SaveFld[j]);
157 if (allfromflds ==
false)
160 for (
int f = 0; f < fromfiles.size(); ++f)
162 m_f->m_fld->Import(fromfiles[f],
163 fromField->m_fielddef,
168 totiprod =
IProduct(processFields, fromField, SaveFld);
170 if (
m_f->m_comm->GetRank() == 0)
172 cout <<
"Inner Product WRT " << fromfiles[f] <<
" : "
183 for (
int i = 0; i < fromfiles.size(); ++i)
185 allFromField[i] = boost::shared_ptr<Field>(
new Field());
186 m_f->m_fld->Import(fromfiles[i],
187 allFromField[i]->m_fielddef,
188 allFromField[i]->m_data,
193 for (
int g = 0; g < fromfiles.size(); ++g)
195 for (
int j = 0; j < processFields.size(); ++j)
197 int fid = processFields[j];
200 for (
int i = 0; i < allFromField[g]->m_data.size(); ++i)
202 m_f->m_exp[fid]->ExtractDataToCoeffs(
203 allFromField[g]->m_fielddef[i],
204 allFromField[g]->m_data[i],
205 allFromField[g]->m_fielddef[i]->m_fields[fid],
206 m_f->m_exp[fid]->UpdateCoeffs());
209 m_f->m_exp[fid]->BwdTrans(
m_f->m_exp[fid]->GetCoeffs(),
214 for (
int f = g; f < fromfiles.size(); ++f)
216 totiprod =
IProduct(processFields, allFromField[f], SaveFld);
218 if (
m_f->m_comm->GetRank() == 0)
220 cout <<
"Inner Product of " << fromfiles[g] <<
" WRT "
221 << fromfiles[f] <<
" : " << totiprod << endl;
229 vector<unsigned int> &processFields,
233 int nphys =
m_f->m_exp[0]->GetTotPoints();
236 for (
int j = 0; j < processFields.size(); ++j)
238 int fid = processFields[j];
241 for (
int i = 0; i < fromField->m_data.size(); ++i)
243 m_f->m_exp[fid]->ExtractDataToCoeffs(
244 fromField->m_fielddef[i],
245 fromField->m_data[i],
246 fromField->m_fielddef[i]->m_fields[fid],
247 m_f->m_exp[fid]->UpdateCoeffs());
250 m_f->m_exp[fid]->BwdTrans(
m_f->m_exp[fid]->GetCoeffs(),
251 m_f->m_exp[fid]->UpdatePhys());
256 m_f->m_exp[fid]->GetPhys(),
258 m_f->m_exp[fid]->UpdatePhys(),
262 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.