Skip to content

Commit f0efd21

Browse files
author
Dilawar Singh
committed
Removed a broken test and renamed one. The namedvars tests is moved to
fixme (not supported).
1 parent cd3dc5a commit f0efd21

File tree

7 files changed

+55
-283
lines changed

7 files changed

+55
-283
lines changed

pybind11/helper.cpp

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ ObjId createIdFromPath(string path, string type, unsigned int numData)
106106
if (pos != string::npos) {
107107
name = trimmed_path.substr(pos + 1);
108108
parent_path = trimmed_path.substr(0, pos);
109-
}
110-
else {
109+
} else {
111110
name = trimmed_path;
112111
}
113112
// handle relative path
@@ -117,8 +116,7 @@ ObjId createIdFromPath(string path, string type, unsigned int numData)
117116
parent_path = current_path + "/" + parent_path;
118117
else
119118
parent_path = current_path + parent_path;
120-
}
121-
else if (parent_path.empty())
119+
} else if (parent_path.empty())
122120
parent_path = "/";
123121

124122
ObjId parent_id(parent_path);
@@ -167,8 +165,7 @@ ObjId loadModelInternal(const string& fname, const string& modelpath,
167165
Id model;
168166
if (solverclass.empty()) {
169167
model = getShellPtr()->doLoadModel(fname, modelpath);
170-
}
171-
else {
168+
} else {
172169
model = getShellPtr()->doLoadModel(fname, modelpath, solverclass);
173170
}
174171

@@ -205,8 +202,8 @@ ObjId getElementFieldItem(const ObjId& objid, const string& fname,
205202
index += len;
206203
}
207204
if (index < 0) {
208-
throw runtime_error(
209-
"ElementField.getItem: invalid index: " + to_string(index) + ".");
205+
throw runtime_error("ElementField.getItem: invalid index: " +
206+
to_string(index) + ".");
210207
return ObjId();
211208
}
212209
return ObjId(oid.id, oid.dataIndex, index);
@@ -230,14 +227,20 @@ ObjId shellConnect(const ObjId& src, const string& srcField, const ObjId& tgt,
230227
// // return src.connect(srcField, tgt, tgtField, msgType);
231228
//}
232229

233-
bool mooseDelete(const ObjId& oid) { return getShellPtr()->doDelete(oid); }
230+
bool mooseDelete(const ObjId& oid)
231+
{
232+
return getShellPtr()->doDelete(oid);
233+
}
234234

235235
bool mooseDelete(const string& path)
236236
{
237237
return getShellPtr()->doDelete(ObjId(path));
238238
}
239239

240-
void mooseMoveId(const Id& a, const ObjId& b) { getShellPtr()->doMove(a, b); }
240+
void mooseMoveId(const Id& a, const ObjId& b)
241+
{
242+
getShellPtr()->doMove(a, b);
243+
}
241244

242245
void mooseMoveObjId(const ObjId& a, const ObjId& b)
243246
{
@@ -270,7 +273,15 @@ void mooseUseClock(size_t tick, const string& path, const string& field)
270273
* @Returns cwe.
271274
*/
272275
/* ----------------------------------------------------------------------------*/
273-
py::object mooseGetCwe() { return py::cast(getShellPtr()->getCwe()); }
276+
py::object mooseGetCwe()
277+
{
278+
return py::cast(getShellPtr()->getCwe());
279+
}
280+
281+
void mooseSetCwe(const ObjId& oid)
282+
{
283+
return getShellPtr()->setCwe(oid);
284+
}
274285

275286
map<string, string> mooseGetFieldDict(const string& className,
276287
const string& finfoType = "")
@@ -295,33 +306,28 @@ map<string, string> mooseGetFieldDict(const string& className,
295306
auto* finfo = cinfo->getValueFinfo(ii);
296307
fieldDict[finfo->name()] = finfo->rttiType();
297308
}
298-
}
299-
else if (finfoType == "srcFinfo" || finfoType == "src") {
309+
} else if (finfoType == "srcFinfo" || finfoType == "src") {
300310
for (unsigned int ii = 0; ii < cinfo->getNumSrcFinfo(); ++ii) {
301311
auto* finfo = cinfo->getSrcFinfo(ii);
302312
fieldDict[finfo->name()] = finfo->rttiType();
303313
}
304-
}
305-
else if (finfoType == "destFinfo" || finfoType == "dest") {
314+
} else if (finfoType == "destFinfo" || finfoType == "dest") {
306315
for (unsigned int ii = 0; ii < cinfo->getNumDestFinfo(); ++ii) {
307316
auto* finfo = cinfo->getDestFinfo(ii);
308317
fieldDict[finfo->name()] = finfo->rttiType();
309318
}
310-
}
311-
else if (finfoType == "lookupFinfo" || finfoType == "lookup") {
319+
} else if (finfoType == "lookupFinfo" || finfoType == "lookup") {
312320
for (unsigned int ii = 0; ii < cinfo->getNumLookupFinfo(); ++ii) {
313321
auto* finfo = cinfo->getLookupFinfo(ii);
314322
fieldDict[finfo->name()] = finfo->rttiType();
315323
}
316-
}
317-
else if (finfoType == "sharedFinfo" || finfoType == "shared") {
324+
} else if (finfoType == "sharedFinfo" || finfoType == "shared") {
318325
for (unsigned int ii = 0; ii < cinfo->getNumSrcFinfo(); ++ii) {
319326
auto* finfo = cinfo->getSrcFinfo(ii);
320327
fieldDict[finfo->name()] = finfo->rttiType();
321328
}
322-
}
323-
else if (finfoType == "fieldElementFinfo" || finfoType == "field" ||
324-
finfoType == "fieldElement") {
329+
} else if (finfoType == "fieldElementFinfo" || finfoType == "field" ||
330+
finfoType == "fieldElement") {
325331
for (unsigned int ii = 0; ii < cinfo->getNumFieldElementFinfo(); ++ii) {
326332
auto* finfo = cinfo->getFieldElementFinfo(ii);
327333
fieldDict[finfo->name()] = finfo->rttiType();
@@ -330,13 +336,21 @@ map<string, string> mooseGetFieldDict(const string& className,
330336
return fieldDict;
331337
}
332338

333-
void mooseReinit() { getShellPtr()->doReinit(); }
339+
void mooseReinit()
340+
{
341+
getShellPtr()->doReinit();
342+
}
334343

335344
void mooseStart(double runtime, bool notify = false)
336345
{
337346
getShellPtr()->doStart(runtime, notify);
338347
}
339348

349+
void mooseStop()
350+
{
351+
getShellPtr()->doStop();
352+
}
353+
340354
ObjId mooseCopy(const py::object& elem, ObjId newParent, string newName,
341355
unsigned int n = 1, bool toGlobal = false,
342356
bool copyExtMsgs = false)
@@ -346,15 +360,15 @@ ObjId mooseCopy(const py::object& elem, ObjId newParent, string newName,
346360
copyExtMsgs));
347361
}
348362

349-
#if 0
350363
/**
351364
Return a vector of field names of specified finfo type. This is from Subha.
352365
*/
353-
vector<string> mooseGetFieldNames(string className, string finfoType)
366+
vector<string> mooseGetFieldNames(const string& className,
367+
const string& finfoType)
354368
{
355369
vector<string> ret;
356370
const Cinfo* cinfo = Cinfo::find(className);
357-
if (cinfo == NULL) {
371+
if (!cinfo) {
358372
cerr << "Invalid class name." << endl;
359373
return ret;
360374
}
@@ -364,38 +378,32 @@ vector<string> mooseGetFieldNames(string className, string finfoType)
364378
Finfo* finfo = cinfo->getValueFinfo(ii);
365379
ret.push_back(finfo->name());
366380
}
367-
}
368-
else if (finfoType == "srcFinfo" || finfoType == "src") {
381+
} else if (finfoType == "srcFinfo" || finfoType == "src") {
369382
for (unsigned int ii = 0; ii < cinfo->getNumSrcFinfo(); ++ii) {
370383
Finfo* finfo = cinfo->getSrcFinfo(ii);
371384
ret.push_back(finfo->name());
372385
}
373-
}
374-
else if (finfoType == "destFinfo" || finfoType == "dest") {
386+
} else if (finfoType == "destFinfo" || finfoType == "dest") {
375387
for (unsigned int ii = 0; ii < cinfo->getNumDestFinfo(); ++ii) {
376388
Finfo* finfo = cinfo->getDestFinfo(ii);
377389
ret.push_back(finfo->name());
378390
}
379-
}
380-
else if (finfoType == "lookupFinfo" || finfoType == "lookup") {
391+
} else if (finfoType == "lookupFinfo" || finfoType == "lookup") {
381392
for (unsigned int ii = 0; ii < cinfo->getNumLookupFinfo(); ++ii) {
382393
Finfo* finfo = cinfo->getLookupFinfo(ii);
383394
ret.push_back(finfo->name());
384395
}
385-
}
386-
else if (finfoType == "sharedFinfo" || finfoType == "shared") {
396+
} else if (finfoType == "sharedFinfo" || finfoType == "shared") {
387397
for (unsigned int ii = 0; ii < cinfo->getNumSrcFinfo(); ++ii) {
388398
Finfo* finfo = cinfo->getSrcFinfo(ii);
389399
ret.push_back(finfo->name());
390400
}
391-
}
392-
else if (finfoType == "fieldElementFinfo" || finfoType == "fieldElement") {
401+
} else if (finfoType == "fieldElementFinfo" ||
402+
finfoType == "fieldElement") {
393403
for (unsigned int ii = 0; ii < cinfo->getNumFieldElementFinfo(); ++ii) {
394404
Finfo* finfo = cinfo->getFieldElementFinfo(ii);
395405
ret.push_back(finfo->name());
396406
}
397407
}
398408
return ret;
399409
}
400-
401-
#endif

pybind11/helper.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,23 @@ ObjId mooseCopy(const py::object& orig, ObjId newParent, string newName,
5757
unsigned int n, bool toGlobal, bool copyExtMsgs);
5858

5959
py::object mooseGetCwe();
60+
void mooseSetCwe(const ObjId& oid);
6061

6162
void mooseSetClock(const unsigned int clockId, double dt);
6263

6364
void mooseUseClock(size_t tick, const string& path, const string& field);
6465

65-
// vector<string> mooseGetFieldNames(const string& className, const string& finfoType);
66-
6766
map<string, string> mooseGetFieldDict(const string& className,
6867
const string& finfoType);
6968

7069
void mooseReinit();
70+
7171
void mooseStart(double runtime, bool notify);
7272

73+
void mooseStop();
74+
7375
py::cpp_function getPropertyDestFinfo(const ObjId& oid, const Finfo* finfo);
7476

77+
vector<string> mooseGetFieldNames(const string& className, const string& finfoType);
78+
7579
#endif /* end of include guard: HELPER_H */

pybind11/pymoose.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,13 +325,15 @@ PYBIND11_MODULE(_cmoose, m)
325325
m.def("move", &mooseMoveObjId);
326326
m.def("reinit", &mooseReinit);
327327
m.def("start", &mooseStart, "runtime"_a, "notify"_a = false);
328+
m.def("stop", &mooseStop);
328329
m.def("objid", &mooseElement);
329330
m.def("exists", &mooseExists);
330331
m.def("getCwe", &mooseGetCwe);
332+
m.def("setCwe", &mooseSetCwe);
331333
m.def("setClock", &mooseSetClock);
332334
m.def("useClock", &mooseUseClock);
333335
m.def("loadModelInternal", &loadModelInternal);
334-
// m.def("getFieldNames", &mooseGetFieldNames);
336+
m.def("getFieldNames", &mooseGetFieldNames);
335337
m.def("getField",
336338
[](const ObjId &oid, const string &fieldName, const string &ftype) {
337339
// ftype is not needed anymore.

0 commit comments

Comments
 (0)