@@ -28,21 +28,23 @@ __Finfo__::__Finfo__(const ObjId& oid, const Finfo* f, const string& finfoType)
2828 : oid_(oid), f_(f), finfoType_(finfoType)
2929{
3030 if (finfoType == " DestFinfo" )
31- func_ = [oid, f](const py::object& key) {
32- return getLookupValueFinfoItem (oid, f, key);
33- };
31+ func_ = [oid, f](const py::object& key)
32+ { return getLookupValueFinfoItem (oid, f, key); };
3433 else if (finfoType == " FieldElementFinfo" )
35- func_ = [oid, f](const py::object& index) {
34+ func_ = [oid, f](const py::object& index)
35+ {
3636 // this is essential of make this function static.
3737 return getElementFinfoItem (oid, f, py::cast<unsigned int >(index));
3838 };
3939 else if (finfoType == " LookupValueFinfo" )
40- func_ = [oid, f, this ](const py::object& key) {
40+ func_ = [oid, f, this ](const py::object& key)
41+ {
4142 // Assigning is essential or make these functions static.
4243 return this ->getLookupValueFinfoItem (oid, f, key);
4344 };
4445 else
45- func_ = [this ](const py::object& key) {
46+ func_ = [this ](const py::object& key)
47+ {
4648 throw runtime_error (" Not supported for Finfo type '" + finfoType_ +
4749 " '" );
4850 return py::none ();
@@ -69,7 +71,8 @@ bool __Finfo__::setLookupValueFinfoItem(const ObjId& oid, const py::object& key,
6971 auto srcType = srcDestType[0 ];
7072 auto destType = srcDestType[1 ];
7173
72- if (srcType == " unsigned int" ) {
74+ if (srcType == " unsigned int" )
75+ {
7376 if (destType == " double" )
7477 return LookupField<unsigned int , double >::set (
7578 oid, fieldName, py::cast<unsigned int >(key),
@@ -95,24 +98,24 @@ py::object __Finfo__::getLookupValueFinfoItem(const ObjId& oid, const Finfo* f,
9598
9699 py::object r = py::none ();
97100
98- if (srcType == " string" ) {
99- auto k = py:: cast<string>(key );
100- return getLookupValueFinfoItemInner<string>(oid, f, k, tgtType);
101- } else if (srcType == " unsigned int" ) {
102- auto k = py:: cast<unsigned int >(key );
103- return getLookupValueFinfoItemInner< unsigned int >(oid, f, k, tgtType);
104- } else if (srcType == " ObjId" ) {
105- auto k = py::cast<ObjId>(key );
106- return getLookupValueFinfoItemInner<ObjId>(oid, f, k, tgtType);
107- } else if (srcType == " Id " ) {
108- auto k = py:: cast<Id>(key );
109- return getLookupValueFinfoItemInner<Id>(oid, f, k, tgtType);
110- } else {
111- py::print ( " getLookupValueFinfoItem::NotImplemented for key: " , key,
112- " srcType: " , srcType, " and tgtType :" , tgtType, " path: " ,
113- oid. path ());
114- throw runtime_error ( " getLookupValueFinfoItem::NotImplemented error " );
115- }
101+ if (srcType == " string" )
102+ return getLookupValueFinfoItemInner<string>(oid, f, key. cast <string>(), tgtType );
103+ if (srcType == " unsigned int " )
104+ return getLookupValueFinfoItemInner< unsigned int >(
105+ oid, f, key. cast <unsigned int >(), tgtType );
106+ if (srcType == " ObjId " )
107+ return getLookupValueFinfoItemInner<ObjId>(oid, f, key. cast < ObjId>(),
108+ tgtType );
109+ if (srcType == " vector<double> " )
110+ return getLookupValueFinfoItemInner<vector< double >>(
111+ oid, f, key. cast <vector< double >>(), tgtType );
112+ if (srcType == " Id " )
113+ return getLookupValueFinfoItemInner<Id>(oid, f, key. cast <Id>(), tgtType);
114+
115+ py::print ( " getLookupValueFinfoItem::NotImplemented for key :" , key ,
116+ " srcType: " , srcType, " and tgtType: " , tgtType, " path: " ,
117+ oid. path () );
118+ throw runtime_error ( " getLookupValueFinfoItem::NotImplemented error " );
116119 return r;
117120}
118121
@@ -133,7 +136,8 @@ py::cpp_function __Finfo__::getDestFinfoSetterFunc(const ObjId& oid,
133136 vector<string> types;
134137 moose::tokenize (rttType, " ," , types);
135138
136- if (types.size () == 1 ) return getDestFinfoSetterFunc1 (oid, finfo, types[0 ]);
139+ if (types.size () == 1 )
140+ return getDestFinfoSetterFunc1 (oid, finfo, types[0 ]);
137141
138142 assert (types.size () == 2 );
139143 return getDestFinfoSetterFunc2 (oid, finfo, types[0 ], types[1 ]);
@@ -146,19 +150,20 @@ py::cpp_function __Finfo__::getDestFinfoSetterFunc2(const ObjId& oid,
146150 const string& ftype2)
147151{
148152 const auto fname = finfo->name ();
149- if (ftype1 == " double" ) {
150- if (ftype2 == " unsigned int" ) {
153+ if (ftype1 == " double" )
154+ {
155+ if (ftype2 == " unsigned int" )
156+ {
151157 std::function<bool (double , unsigned int )> func = [oid, fname](
152- const double a, const unsigned int b) {
153- return SetGet2<double , unsigned int >::set (oid, fname, a, b);
154- };
158+ const double a, const unsigned int b)
159+ { return SetGet2<double , unsigned int >::set (oid, fname, a, b); };
155160 return func;
156161 }
157- if (ftype2 == " long" ) {
162+ if (ftype2 == " long" )
163+ {
158164 std::function<bool (double , long )> func = [oid, fname](
159- const double a, const long b) {
160- return SetGet2<double , long >::set (oid, fname, a, b);
161- };
165+ const double a, const long b)
166+ { return SetGet2<double , long >::set (oid, fname, a, b); };
162167 return func;
163168 }
164169 }
@@ -173,17 +178,23 @@ py::cpp_function __Finfo__::getDestFinfoSetterFunc1(const ObjId& oid,
173178 const string& ftype)
174179{
175180 const auto fname = finfo->name ();
176- if (ftype == " void" ) {
177- std::function< bool ()> func = [oid, fname]() {
178- return SetGet0::set ( oid, fname);
179- };
181+ if (ftype == " void" )
182+ {
183+ std::function< bool ()> func = [ oid, fname]()
184+ { return SetGet0::set (oid, fname); };
180185 return func;
181186 }
182187
183- if (ftype == " double" ) return getSetGetFunc1<double >(oid, fname);
184- if (ftype == " ObjId" ) return getSetGetFunc1<ObjId>(oid, fname);
185- if (ftype == " Id" ) return getSetGetFunc1<Id>(oid, fname);
186- if (ftype == " vector<Id>" ) return getSetGetFunc1<vector<Id>>(oid, fname);
188+ if (ftype == " double" )
189+ return getSetGetFunc1<double >(oid, fname);
190+ if (ftype == " ObjId" )
191+ return getSetGetFunc1<ObjId>(oid, fname);
192+ if (ftype == " Id" )
193+ return getSetGetFunc1<Id>(oid, fname);
194+ if (ftype == " string" )
195+ return getSetGetFunc1<string>(oid, fname);
196+ if (ftype == " vector<Id>" )
197+ return getSetGetFunc1<vector<Id>>(oid, fname);
187198 if (ftype == " vector<ObjId>" )
188199 return getSetGetFunc1<vector<ObjId>>(oid, fname);
189200 if (ftype == " vector<double>" )
@@ -201,13 +212,17 @@ py::object __Finfo__::getFieldValue(const ObjId& oid, const Finfo* f)
201212
202213 if (rttType == " double" or rttType == " float" )
203214 r = pybind11::float_ (getField<double >(oid, fname));
204- else if (rttType == " vector<double>" ) {
215+ else if (rttType == " vector<double>" )
216+ {
205217 // r = py::cast(getField<vector<double>>(oid, fname));
206218 r = getFieldNumpy<double >(oid, fname);
207- } else if (rttType == " vector<unsigned int>" ) {
219+ }
220+ else if (rttType == " vector<unsigned int>" )
221+ {
208222 // r = pybind11::cast(getField<vector<unsigned int>>(oid, fname));
209223 r = getFieldNumpy<unsigned int >(oid, fname);
210- } else if (rttType == " string" )
224+ }
225+ else if (rttType == " string" )
211226 r = pybind11::str (getField<string>(oid, fname));
212227 else if (rttType == " char" )
213228 r = pybind11::int_ (getField<char >(oid, fname));
@@ -231,7 +246,8 @@ py::object __Finfo__::getFieldValue(const ObjId& oid, const Finfo* f)
231246 r = py::cast (getField<vector<ObjId>>(oid, fname));
232247 else if (rttType == " vector<string>" )
233248 r = py::cast (getField<vector<string>>(oid, fname));
234- else {
249+ else
250+ {
235251 MOOSE_WARN (" Warning: getValueFinfo:: Unsupported type '" + rttType +
236252 " '" );
237253 r = py::none ();
@@ -253,7 +269,8 @@ py::list __Finfo__::getElementFinfo(const ObjId& objid, const Finfo* f)
253269py::object __Finfo__::getElementFinfoItem (const ObjId& oid, const Finfo* f,
254270 unsigned int index)
255271{
256- if (index >= getNumFieldStatic (oid, f)) {
272+ if (index >= getNumFieldStatic (oid, f))
273+ {
257274 throw py::index_error (" Index " + to_string (index) + " out of range." );
258275 }
259276 auto o = ObjId (oid.path () + ' /' + f->name ());
0 commit comments