@@ -44,37 +44,44 @@ void mooseMoveId(const Id& a, const ObjId& b);
4444void mooseMoveObjId(const ObjId& a, const ObjId& b);
4545#endif
4646
47- template <typename P= ObjId, typename Q= ObjId>
47+ template <typename P = ObjId, typename Q = ObjId>
4848inline void mooseMove (const P& src, const Q& tgt)
4949{
5050 getShellPtr ()->doMove (Id (src), ObjId (tgt));
5151}
5252
53-
54- inline MooseVec mooseObjIdPath (const string& p)
53+ inline ObjId mooseObjIdPath (const string& p)
5554{
5655 // handle relative path.
5756 string path (p);
58- if (p[0 ] != ' /' )
59- path = mooseGetCweId ().path () + ' /' + path;
57+
58+ // If path is a relative path.
59+ if (p[0 ] != ' /' )
60+ {
61+ string cwepath (mooseGetCweId ().path ());
62+ if (cwepath.back () != ' /' )
63+ cwepath.push_back (' /' );
64+ path = cwepath + p;
65+ }
6066 ObjId oid (path);
6167 if (oid.bad ()) {
62- cerr << " moose_element : " << path << " does not exist!" << endl;
68+ cerr << " moose.element : " << path << " does not exist!" << endl;
6369 }
64- return MooseVec ( oid) ;
70+ return oid;
6571}
6672
67- inline MooseVec mooseObjIdObj (const ObjId& obj)
73+ inline ObjId mooseObjIdObj (const ObjId& obj)
6874{
69- return MooseVec ( obj) ;
75+ return obj;
7076}
7177
72- inline MooseVec mooseObjIdId (const Id& id)
78+ inline ObjId mooseObjIdId (const Id& id)
7379{
74- return MooseVec (id);
80+ return ObjId (id);
7581}
7682
77- inline ObjId mooseCreateFromPath (const string type, const string& p, unsigned int numdata)
83+ inline ObjId mooseCreateFromPath (const string type, const string& p,
84+ unsigned int numdata)
7885{
7986
8087#if 0
@@ -85,39 +92,40 @@ inline ObjId mooseCreateFromPath(const string type, const string& p, unsigned in
8592
8693 // relative path.
8794 string path (p);
88- if (path[0 ] != ' /' )
89- path = mooseGetCweId ().path ()+ ' /' + path;
95+ if (path[0 ] != ' /' )
96+ path = mooseGetCweId ().path () + ' /' + path;
9097
9198 // If path exists and user is asking for the same type then return the
9299 // object else raise exception.
93- if (mooseExists (path)) {
100+ if (mooseExists (path)) {
94101 auto oid = ObjId (path);
95- if (oid.element ()->cinfo ()->name () == type)
102+ if (oid.element ()->cinfo ()->name () == type)
96103 return oid;
97104 }
98105
99106 // Split into dirname and basename component.
100107 auto pp = moose::splitPath (path);
101108
102109 // Name must not end with [\d*] etc. normalizePath takes care of it if
103- // enabled.
110+ // enabled.
104111 string name (pp.second );
105- if (name.back () == ' ]' )
112+ if (name.back () == ' ]' )
106113 name = name.substr (0 , name.find_last_of (' [' ));
107114 return getShellPtr ()->doCreate2 (type, ObjId (pp.first ), name, numdata);
108115}
109116
110- inline ObjId mooseCreateFromObjId (const string& type, const ObjId& oid, unsigned int numData)
117+ inline ObjId mooseCreateFromObjId (const string& type, const ObjId& oid,
118+ unsigned int numData)
111119{
112120 return oid;
113121}
114122
115- inline ObjId mooseCreateFromId (const string& type, const Id& id, unsigned int numData)
123+ inline ObjId mooseCreateFromId (const string& type, const Id& id,
124+ unsigned int numData)
116125{
117126 return ObjId (id);
118127}
119128
120-
121129ObjId loadModelInternal (const string& fname, const string& modelpath,
122130 const string& solverclass);
123131
@@ -130,8 +138,9 @@ ObjId getElementFieldItem(const ObjId& objid, const string& fname,
130138ObjId shellConnect (const ObjId& src, const string& srcField, const ObjId& tgt,
131139 const string& tgtField, const string& msgType);
132140
133- ObjId shellConnectToVec (const ObjId& src, const string& srcField, const MooseVec& tgt,
134- const string& tgtField, const string& msgType);
141+ ObjId shellConnectToVec (const ObjId& src, const string& srcField,
142+ const MooseVec& tgt, const string& tgtField,
143+ const string& msgType);
135144
136145inline bool mooseDeleteObj (const ObjId& oid)
137146{
@@ -143,14 +152,13 @@ inline bool mooseDeleteStr(const string& path)
143152 return getShellPtr ()->doDelete (ObjId (path));
144153}
145154
155+ MooseVec mooseCopy (const py::object& orig, const py::object& newParent,
156+ string newName, unsigned int n, bool toGlobal,
157+ bool copyExtMsgs);
146158
147159ObjId mooseCreate (const string type, const string& path,
148160 unsigned int numdata = 1 );
149161
150- MooseVec mooseCopy (const py::object& orig, ObjId newParent, string newName,
151- unsigned int n, bool toGlobal, bool copyExtMsgs);
152-
153-
154162void mooseSetClock (const unsigned int clockId, double dt);
155163
156164void mooseUseClock (size_t tick, const string& path, const string& field);
@@ -166,6 +174,7 @@ void mooseStop();
166174
167175py::cpp_function getPropertyDestFinfo (const ObjId& oid, const Finfo* finfo);
168176
169- vector<string> mooseGetFieldNames (const string& className, const string& finfoType);
177+ vector<string> mooseGetFieldNames (const string& className,
178+ const string& finfoType);
170179
171180#endif /* end of include guard: HELPER_H */
0 commit comments