@@ -51,19 +51,25 @@ bool setFieldGeneric(const ObjId &oid, const string &fieldName,
5151 throw runtime_error (fieldName + " is not found on " + oid.path ());
5252 return false ;
5353 }
54+
5455 auto fieldType = finfo->rttiType ();
5556
57+ // Remove any space in fieldType
58+ fieldType.erase (
59+ std::remove_if (fieldType.begin (), fieldType.end (), ::isspace),
60+ fieldType.end ());
61+
5662 if (fieldType == " double" )
5763 return Field<double >::set (oid, fieldName, val.cast <double >());
5864 if (fieldType == " vector<double>" )
5965 return Field<vector<double >>::set (oid, fieldName,
6066 val.cast <vector<double >>());
6167 if (fieldType == " float" )
6268 return Field<float >::set (oid, fieldName, val.cast <float >());
63- if (fieldType == " unsigned int " )
69+ if (fieldType == " unsignedint " )
6470 return Field<unsigned int >::set (oid, fieldName,
6571 val.cast <unsigned int >());
66- if (fieldType == " unsigned long " )
72+ if (fieldType == " unsignedlong " )
6773 return Field<unsigned long >::set (oid, fieldName,
6874 val.cast <unsigned long >());
6975 if (fieldType == " int" )
@@ -86,11 +92,22 @@ bool setFieldGeneric(const ObjId &oid, const string &fieldName,
8692 // NB: Note that we cast to ObjId here and not to Id.
8793 return Field<Id>::set (oid.id , fieldName, val.cast <ObjId>());
8894 }
95+ if (fieldType == " vector<double>" ) {
96+ // NB: Note that we cast to ObjId here and not to Id.
97+ return Field<vector<double >>::set (
98+ oid.id , fieldName, val.cast <vector<double >>());
99+ }
100+ if (fieldType == " vector<vector<double>>" ) {
101+ // NB: Note that we cast to ObjId here and not to Id.
102+ return Field<vector<vector<double >>>::set (
103+ oid.id , fieldName, val.cast <vector<vector<double >>>());
104+ }
89105 if (fieldType == " Variable" )
90- return Field<Variable>::set (oid, fieldName, val.cast <Variable>());
106+ if (fieldType == " Variable" )
107+ return Field<Variable>::set (oid, fieldName, val.cast <Variable>());
91108
92- throw runtime_error (" NotImplemented::setField : " + fieldName +
93- " with value type " + fieldType);
109+ throw runtime_error (" NotImplemented::setField: ' " + fieldName +
110+ " ' with value type ' " + fieldType + " '. " );
94111 return false ;
95112}
96113
@@ -190,8 +207,10 @@ PYBIND11_MODULE(_moose, m)
190207 .def (" __eq__" , [](const Id &a, const Id &b) { return a == b; })
191208 .def (" __ne__" , [](const Id &a, const Id &b) { return a != b; });
192209
193- // I can use py::metaclass here to generate moose.Neutral etc types but
194- // lets do it in moose.py.
210+ /* *
211+ * @name ObjId. It is a base of all other moose objects.
212+ * @{ */
213+ /* * @} */
195214 py::class_<ObjId>(m, " _ObjId" )
196215 .def (py::init<>())
197216 .def (py::init<Id>())
0 commit comments