Skip to content

Commit

Permalink
Add getNDM output command to OpenSeesPy
Browse files Browse the repository at this point in the history
  • Loading branch information
sewkokot committed Nov 2, 2021
1 parent 550bd43 commit e041113
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions SRC/interpreter/OpenSeesCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ int OPS_nodeCoord();
int OPS_setNodeCoord();
int OPS_updateElementDomain();
int OPS_eleNodes();
int OPS_getNDMM();
int OPS_getNDFF();
int OPS_eleType();
int OPS_nodeDOFs();
Expand Down
43 changes: 43 additions & 0 deletions SRC/interpreter/OpenSeesOutputCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1576,6 +1576,49 @@ int OPS_updateElementDomain()
return 0;
}

int OPS_getNDMM()
{

int ndm;
int numdata = 1;

if (OPS_GetNumRemainingInputArgs() > 0) {

int tag;

if (OPS_GetIntInput(&numdata, &tag) < 0) {
opserr << "WARNING getNDM nodeTag? \n";
return -1;
}

Domain* theDomain = OPS_GetDomain();
if (theDomain == 0) return -1;
Node *theNode = theDomain->getNode(tag);

if (theNode == 0) {
opserr << "WARNING node "<< tag <<" does not exist\n";
return -1;
}

const Vector& crds = theNode->getCrds();
ndm = crds.Size();

} else {

ndm = OPS_GetNDM();

}

int size = 1;

if (OPS_SetIntOutput(&size, &ndm, false) < 0) {
opserr << "WARNING failed to set output\n";
return -1;
}

return 0;
}

int OPS_getNDFF()
{

Expand Down
13 changes: 13 additions & 0 deletions SRC/interpreter/PythonWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,18 @@ static PyObject *Py_ops_updateElementDomain(PyObject *self, PyObject *args)
return wrapper->getResults();
}

static PyObject *Py_ops_getNDMM(PyObject *self, PyObject *args)
{
wrapper->resetCommandLine(PyTuple_Size(args), 1, args);

if (OPS_getNDMM() < 0) {
opserr<<(void*)0;
return NULL;
}

return wrapper->getResults();
}

static PyObject *Py_ops_getNDFF(PyObject *self, PyObject *args)
{
wrapper->resetCommandLine(PyTuple_Size(args), 1, args);
Expand Down Expand Up @@ -2460,6 +2472,7 @@ PythonWrapper::addOpenSeesCommands()
addCommand("nodeCoord", &Py_ops_nodeCoord);
addCommand("setNodeCoord", &Py_ops_setNodeCoord);
addCommand("updateElementDomain", &Py_ops_updateElementDomain);
addCommand("getNDM", &Py_ops_getNDMM);
addCommand("getNDF", &Py_ops_getNDFF);
addCommand("eleNodes", &Py_ops_eleNodes);
addCommand("eleType", &Py_ops_eleType);
Expand Down

0 comments on commit e041113

Please sign in to comment.