From fd53d045eb880fecade5eccefe227ffc17c82dd8 Mon Sep 17 00:00:00 2001 From: mhscott Date: Sun, 25 Oct 2020 17:54:20 -0700 Subject: [PATCH 001/193] Adding OPS command for Simpson beam integration --- .../SimpsonBeamIntegration.cpp | 197 ++++++++++-------- 1 file changed, 112 insertions(+), 85 deletions(-) diff --git a/SRC/element/forceBeamColumn/SimpsonBeamIntegration.cpp b/SRC/element/forceBeamColumn/SimpsonBeamIntegration.cpp index fe9e8ee87..8bcc9323d 100644 --- a/SRC/element/forceBeamColumn/SimpsonBeamIntegration.cpp +++ b/SRC/element/forceBeamColumn/SimpsonBeamIntegration.cpp @@ -1,85 +1,112 @@ -/* ****************************************************************** ** -** OpenSees - Open System for Earthquake Engineering Simulation ** -** Pacific Earthquake Engineering Research Center ** -** ** -** ** -** (C) Copyright 1999, The Regents of the University of California ** -** All Rights Reserved. ** -** ** -** Commercial use of this program without express permission of the ** -** University of California, Berkeley, is strictly prohibited. See ** -** file 'COPYRIGHT' in main directory for information on usage and ** -** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. ** -** ** -** Developed by: ** -** Frank McKenna (fmckenna@ce.berkeley.edu) ** -** Gregory L. Fenves (fenves@ce.berkeley.edu) ** -** Filip C. Filippou (filippou@ce.berkeley.edu) ** -** ** -** ****************************************************************** */ - -/* Created: 7/19 -** Written by: Mohammad Salehi (mohammad.salehi@tamu.edu) -*/ - -#include - -SimpsonBeamIntegration::SimpsonBeamIntegration() : -BeamIntegration(BEAM_INTEGRATION_TAG_Simpson) -{ - // Nothing to do -} - -SimpsonBeamIntegration::~SimpsonBeamIntegration() -{ - // Nothing to do -} - -BeamIntegration* -SimpsonBeamIntegration::getCopy(void) -{ - return new SimpsonBeamIntegration(); -} - -void -SimpsonBeamIntegration::getSectionLocations(int numSections, double L, -double *xi) -{ - if (numSections > 1) { - xi[0] = -1.0; - xi[numSections - 1] = 1.0; - - double dxi = 2.0 / (numSections - 1); - - for (int i = 1; i < numSections - 1; i++) - xi[i] = -1.0 + dxi*i; - } - - for (int i = 0; i < numSections; i++) - xi[i] = 0.5*(xi[i] + 1.0); -} - -void -SimpsonBeamIntegration::getSectionWeights(int numSections, double L, -double *wt) -{ - if (numSections > 1) { - wt[0] = 1.0 / 6.0; - wt[numSections - 1] = 1.0 / 6.0; - - for (int i = 1; i < numSections; i += 2) - wt[i] = 2.0 / 3.0; - - for (int i = 2; i < (numSections - 1); i += 2) - wt[i] = 1.0 / 3.0; - - for (int i = 0; i < numSections; i++) - wt[i] /= ((numSections - 1.0) / 2.0); - } -} - -void -SimpsonBeamIntegration::Print(OPS_Stream &s, int flag) -{ - s << "Simpson" << endln; -} +/* ****************************************************************** ** +** OpenSees - Open System for Earthquake Engineering Simulation ** +** Pacific Earthquake Engineering Research Center ** +** ** +** ** +** (C) Copyright 1999, The Regents of the University of California ** +** All Rights Reserved. ** +** ** +** Commercial use of this program without express permission of the ** +** University of California, Berkeley, is strictly prohibited. See ** +** file 'COPYRIGHT' in main directory for information on usage and ** +** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. ** +** ** +** Developed by: ** +** Frank McKenna (fmckenna@ce.berkeley.edu) ** +** Gregory L. Fenves (fenves@ce.berkeley.edu) ** +** Filip C. Filippou (filippou@ce.berkeley.edu) ** +** ** +** ****************************************************************** */ + +/* Created: 7/19 +** Written by: Mohammad Salehi (mohammad.salehi@tamu.edu) +*/ + +#include +#include +#include + +void* OPS_SimpsonBeamIntegration(int& integrationTag, ID& secTags) +{ + if(OPS_GetNumRemainingInputArgs() < 3) { + opserr<<"insufficient arguments:integrationTag,secTag,N\n"; + return 0; + } + + // inputs: integrationTag,secTag,N + int iData[3]; + int numData = 3; + if(OPS_GetIntInput(&numData,&iData[0]) < 0) return 0; + + integrationTag = iData[0]; + if(iData[2] > 0) { + secTags.resize(iData[2]); + } else { + secTags = ID(); + } + for(int i=0; i 1) { + xi[0] = -1.0; + xi[numSections - 1] = 1.0; + + double dxi = 2.0 / (numSections - 1); + + for (int i = 1; i < numSections - 1; i++) + xi[i] = -1.0 + dxi*i; + } + + for (int i = 0; i < numSections; i++) + xi[i] = 0.5*(xi[i] + 1.0); +} + +void +SimpsonBeamIntegration::getSectionWeights(int numSections, double L, +double *wt) +{ + if (numSections > 1) { + wt[0] = 1.0 / 6.0; + wt[numSections - 1] = 1.0 / 6.0; + + for (int i = 1; i < numSections; i += 2) + wt[i] = 2.0 / 3.0; + + for (int i = 2; i < (numSections - 1); i += 2) + wt[i] = 1.0 / 3.0; + + for (int i = 0; i < numSections; i++) + wt[i] /= ((numSections - 1.0) / 2.0); + } +} + +void +SimpsonBeamIntegration::Print(OPS_Stream &s, int flag) +{ + s << "Simpson" << endln; +} From ebffb776a3f15bd5402eb2744b78903836a3ddf4 Mon Sep 17 00:00:00 2001 From: mhscott Date: Sun, 25 Oct 2020 17:55:01 -0700 Subject: [PATCH 002/193] Modifying OPS command for gradientInelasticBC 2d and 3d --- .../GradientInelasticBeamColumn2d.cpp | 20 +++++++++++-------- .../GradientInelasticBeamColumn3d.cpp | 19 ++++++++++-------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/SRC/element/gradientInelasticBeamColumn/GradientInelasticBeamColumn2d.cpp b/SRC/element/gradientInelasticBeamColumn/GradientInelasticBeamColumn2d.cpp index e76b82b76..b0b87d04a 100644 --- a/SRC/element/gradientInelasticBeamColumn/GradientInelasticBeamColumn2d.cpp +++ b/SRC/element/gradientInelasticBeamColumn/GradientInelasticBeamColumn2d.cpp @@ -61,9 +61,9 @@ void* OPS_GradientInelasticBeamColumn2d() { // Necessary Arguments - if (OPS_GetNumRemainingInputArgs() < 11) { + if (OPS_GetNumRemainingInputArgs() < 8) { opserr << "WARNING! gradientInelasticBeamColumn2d - insufficient arguments\n" << - " Want: eleTag? iNode? jNode? transfTag? integrationTag? lc?\n" << + " Want: eleTag? iNode? jNode? transfTag? integrationTag? lambda1? lambda2? lc?\n" << " <-constH> <-iter maxIter? minTol? maxTol?> <-corControl maxEpsInc? maxPhiInc?>\n"; return 0; } @@ -89,13 +89,17 @@ void* OPS_GradientInelasticBeamColumn2d() int transfTag = iData[3]; int integrTag = iData[4]; - double LC; - numData = 1; - if (OPS_GetDoubleInput(&numData, &LC) < 0) { - opserr << "WARNING! gradientInelasticBeamColumn2d - invalid lc\n"; + double ddata[3]; + numData = 3; + if (OPS_GetDoubleInput(&numData, ddata) < 0) { + opserr << "WARNING! gradientInelasticBeamColumn2d - invalid double input\n"; return 0; } + double lam1 = ddata[0]; + double lam2 = ddata[1]; + double lc = ddata[2]; + // Optional Arguments int maxIter = 50; double minTol = 1E-10, maxTol = 1E-8; @@ -173,7 +177,7 @@ void* OPS_GradientInelasticBeamColumn2d() int numIntegrPoints = secTags.Size(); for (int i = 2; i < numIntegrPoints; i++) { - if (secTags(i) == secTags(i - 1)) { + if (secTags(i) != secTags(i - 1)) { opserr << "WARNING! gradientInelasticBeamColumn2d - internal integration points should have identical tags\n" << "continued using section tag of integration point 2 for all internal integration points\n"; return 0; @@ -199,7 +203,7 @@ void* OPS_GradientInelasticBeamColumn2d() } Element* theEle = new GradientInelasticBeamColumn2d(eleTag, nodeTagI, nodeTagJ, numIntegrPoints, &endSection1, &intSection, &endSection2, - 0.01, 0.01, *beamIntegr, *theTransf, LC, minTol, maxTol, maxIter, constH, correctionControl, maxEpsInc, maxPhiInc); + lam1, lam2, *beamIntegr, *theTransf, lc, minTol, maxTol, maxIter, constH, correctionControl, maxEpsInc, maxPhiInc); return theEle; } diff --git a/SRC/element/gradientInelasticBeamColumn/GradientInelasticBeamColumn3d.cpp b/SRC/element/gradientInelasticBeamColumn/GradientInelasticBeamColumn3d.cpp index 13fac7695..49da58e1d 100644 --- a/SRC/element/gradientInelasticBeamColumn/GradientInelasticBeamColumn3d.cpp +++ b/SRC/element/gradientInelasticBeamColumn/GradientInelasticBeamColumn3d.cpp @@ -61,9 +61,9 @@ void* OPS_GradientInelasticBeamColumn3d() { // Necessary Arguments - if (OPS_GetNumRemainingInputArgs() < 11) { + if (OPS_GetNumRemainingInputArgs() < 8) { opserr << "WARNING! gradientInelasticBeamColumn3d - insufficient arguments\n" << - " Want: eleTag? iNode? jNode? transfTag? integrationTag? lc?\n" << + " Want: eleTag? iNode? jNode? transfTag? integrationTag? lambda1? lambda2? lc?\n" << " <-constH> <-iter maxIter? minTol? maxTol?> <-corControl maxEpsInc? maxPhiInc?>\n"; return 0; } @@ -89,13 +89,16 @@ void* OPS_GradientInelasticBeamColumn3d() int transfTag = iData[3]; int integrTag = iData[4]; - double LC; - numData = 1; - if (OPS_GetDoubleInput(&numData, &LC) < 0) { + double ddata[3]; + numData = 3; + if (OPS_GetDoubleInput(&numData, ddata) < 0) { opserr << "WARNING! gradientInelasticBeamColumn3d - invalid lc\n"; return 0; } - + double lam1 = ddata[0]; + double lam2 = ddata[1]; + double lc = ddata[2]; + // Optional Arguments int maxIter = 50; double minTol = 1E-10, maxTol = 1E-8; @@ -173,7 +176,7 @@ void* OPS_GradientInelasticBeamColumn3d() int numIntegrPoints = secTags.Size(); for (int i = 2; i < numIntegrPoints; i++) { - if (secTags(i) == secTags(i - 1)) { + if (secTags(i) != secTags(i - 1)) { opserr << "WARNING! gradientInelasticBeamColumn3d - internal integration points should have identical tags\n" << "continued using section tag of integration point 2 for all internal integration points\n"; return 0; @@ -199,7 +202,7 @@ void* OPS_GradientInelasticBeamColumn3d() } Element* theEle = new GradientInelasticBeamColumn3d(eleTag, nodeTagI, nodeTagJ, numIntegrPoints, &endSection1, &intSection, &endSection2, - 0.01, 0.01, *beamIntegr, *theTransf, LC, minTol, maxTol, maxIter, constH, correctionControl, maxEpsInc, maxPhiInc); + lam1, lam2, *beamIntegr, *theTransf, lc, minTol, maxTol, maxIter, constH, correctionControl, maxEpsInc, maxPhiInc); return theEle; } From 7dcc82bbf9a9f8152c06a7823fb5e71b26744b1d Mon Sep 17 00:00:00 2001 From: mhscott Date: Sun, 25 Oct 2020 17:55:49 -0700 Subject: [PATCH 003/193] Adding Simpson integration to beam integration command --- SRC/interpreter/OpenSeesBeamIntegrationCommands.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SRC/interpreter/OpenSeesBeamIntegrationCommands.cpp b/SRC/interpreter/OpenSeesBeamIntegrationCommands.cpp index 3cec41720..6055a6516 100644 --- a/SRC/interpreter/OpenSeesBeamIntegrationCommands.cpp +++ b/SRC/interpreter/OpenSeesBeamIntegrationCommands.cpp @@ -51,6 +51,7 @@ void* OPS_NewtonCotesBeamIntegration(int&,ID&); void* OPS_RadauBeamIntegration(int&,ID&); void* OPS_TrapezoidalBeamIntegration(int&,ID&); void* OPS_CompositeSimpsonBeamIntegration(int&,ID&); +void* OPS_SimpsonBeamIntegration(int&,ID&); void* OPS_UserDefinedBeamIntegration(int&,ID&); void* OPS_FixedLocationBeamIntegration(int&,ID&); void* OPS_LowOrderBeamIntegration(int&,ID&); @@ -81,6 +82,7 @@ namespace { functionMap.insert(std::make_pair("Radau", &OPS_RadauBeamIntegration)); functionMap.insert(std::make_pair("Trapezoidal", &OPS_TrapezoidalBeamIntegration)); functionMap.insert(std::make_pair("CompositeSimpson", &OPS_CompositeSimpsonBeamIntegration)); + functionMap.insert(std::make_pair("Simpson", &OPS_SimpsonBeamIntegration)); functionMap.insert(std::make_pair("UserDefined", &OPS_UserDefinedBeamIntegration)); functionMap.insert(std::make_pair("FixedLocation", &OPS_FixedLocationBeamIntegration)); functionMap.insert(std::make_pair("LowOrder", &OPS_LowOrderBeamIntegration)); From 72526834fa71ecb21d11b1aac385175569f8b535 Mon Sep 17 00:00:00 2001 From: mhscott Date: Mon, 22 Feb 2021 11:54:23 -0800 Subject: [PATCH 004/193] Adding Chebyshev integration to Makefiles and Python interpreter --- SRC/Makefile | 1 + SRC/element/forceBeamColumn/Makefile | 1 + SRC/interpreter/OpenSeesBeamIntegrationCommands.cpp | 2 ++ 3 files changed, 4 insertions(+) diff --git a/SRC/Makefile b/SRC/Makefile index 0088363d5..87e9f595b 100644 --- a/SRC/Makefile +++ b/SRC/Makefile @@ -240,6 +240,7 @@ REMO_LIBS = $(FE)/element/nonlinearBeamColumn/matrixutil/MatrixUtil.o \ $(FE)/element/forceBeamColumn/TrapezoidalBeamIntegration.o \ $(FE)/element/forceBeamColumn/FixedLocationBeamIntegration.o \ $(FE)/element/forceBeamColumn/LowOrderBeamIntegration.o \ + $(FE)/element/forceBeamColumn/ChebyshevBeamIntegration.o \ $(FE)/coordTransformation/CrdTransf.o \ $(FE)/coordTransformation/LinearCrdTransf2d.o \ $(FE)/coordTransformation/PDeltaCrdTransf2d.o \ diff --git a/SRC/element/forceBeamColumn/Makefile b/SRC/element/forceBeamColumn/Makefile index 2ff640614..5a3a0c687 100644 --- a/SRC/element/forceBeamColumn/Makefile +++ b/SRC/element/forceBeamColumn/Makefile @@ -27,6 +27,7 @@ OBJS = ForceBeamColumn2d.o ForceBeamColumn3d.o \ LowOrderBeamIntegration.o \ MidDistanceBeamIntegration.o \ GaussQBeamIntegration.o \ + ChebyshevBeamIntegration.o \ gaussq.o d1mach.o # Compilation control diff --git a/SRC/interpreter/OpenSeesBeamIntegrationCommands.cpp b/SRC/interpreter/OpenSeesBeamIntegrationCommands.cpp index 3cec41720..728f6313c 100644 --- a/SRC/interpreter/OpenSeesBeamIntegrationCommands.cpp +++ b/SRC/interpreter/OpenSeesBeamIntegrationCommands.cpp @@ -55,6 +55,7 @@ void* OPS_UserDefinedBeamIntegration(int&,ID&); void* OPS_FixedLocationBeamIntegration(int&,ID&); void* OPS_LowOrderBeamIntegration(int&,ID&); void* OPS_MidDistanceBeamIntegration(int&,ID&); +void* OPS_ChebyshevBeamIntegration(int&,ID&); void* OPS_UserHingeBeamIntegration(int&,ID&); void* OPS_HingeMidpointBeamIntegration(int&,ID&); void* OPS_HingeRadauBeamIntegration(int&,ID&); @@ -77,6 +78,7 @@ namespace { int setUpFunctions(void) { functionMap.insert(std::make_pair("Lobatto", &OPS_LobattoBeamIntegration)); functionMap.insert(std::make_pair("Legendre", &OPS_LegendreBeamIntegration)); + functionMap.insert(std::make_pair("Chebyshev", &OPS_ChebyshevBeamIntegration)); functionMap.insert(std::make_pair("NewtonCotes", &OPS_NewtonCotesBeamIntegration)); functionMap.insert(std::make_pair("Radau", &OPS_RadauBeamIntegration)); functionMap.insert(std::make_pair("Trapezoidal", &OPS_TrapezoidalBeamIntegration)); From 600f00d2da87143ac142f99615dedc30479ff48d Mon Sep 17 00:00:00 2001 From: Seweryn Kokot Date: Fri, 5 Feb 2021 08:12:54 +0100 Subject: [PATCH 005/193] add getNumEles, getEleLoadClassTags/Tags/Data commands --- SRC/interpreter/OpenSeesCommands.h | 4 + SRC/interpreter/OpenSeesOutputCommands.cpp | 143 +++++++++++++++++++++ SRC/interpreter/PythonWrapper.cpp | 52 ++++++++ SRC/interpreter/TclWrapper.cpp | 40 ++++++ 4 files changed, 239 insertions(+) diff --git a/SRC/interpreter/OpenSeesCommands.h b/SRC/interpreter/OpenSeesCommands.h index a389deb76..929992680 100644 --- a/SRC/interpreter/OpenSeesCommands.h +++ b/SRC/interpreter/OpenSeesCommands.h @@ -281,6 +281,10 @@ int OPS_sensNodeAccel(); int OPS_sensLambda(); int OPS_sensSectionForce(); int OPS_sensNodePressure(); +int OPS_getNumElements(); +int OPS_getEleLoadClassTags(); +int OPS_getEleLoadTags(); +int OPS_getEleLoadData(); // Sensitivity:END ///////////////////////////////////////////// /* OpenSeesMiscCommands.cpp */ diff --git a/SRC/interpreter/OpenSeesOutputCommands.cpp b/SRC/interpreter/OpenSeesOutputCommands.cpp index 00dd89bd4..12d4c1173 100644 --- a/SRC/interpreter/OpenSeesOutputCommands.cpp +++ b/SRC/interpreter/OpenSeesOutputCommands.cpp @@ -47,6 +47,12 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS. #include #include #include +// #include +// #include +// #include +// #include +#include +#include #include #include #include @@ -3103,4 +3109,141 @@ int OPS_sensNodePressure() return 0; } +int OPS_getEleLoadClassTags() +{ + Domain* theDomain = OPS_GetDomain(); + if (theDomain == 0) return -1; + + int numdata = OPS_GetNumRemainingInputArgs(); + if (numdata < 1) { + opserr << "WARNING want - getEleLoadTags patternTag?\n"; + return -1; + } + + int patternTag; + numdata = 1; + if (OPS_GetIntInput(&numdata, &patternTag) < 0) { + opserr << "could not read patternTag\n"; + return -1; + } + + LoadPattern *thePattern = theDomain->getLoadPattern(patternTag); + ElementalLoadIter theEleLoads = thePattern->getElementalLoads(); + ElementalLoad* theLoad; + + std::vector data; + + while ((theLoad = theEleLoads()) != 0) { + data.push_back(theLoad->getClassTag()); + } + + int size = data.size(); + + if (OPS_SetIntOutput(&size, data.data(), false) < 0) { + opserr << "WARNING failed to set output\n"; + return -1; + } + + return 0; +} + +int OPS_getEleLoadTags() +{ + Domain* theDomain = OPS_GetDomain(); + if (theDomain == 0) return -1; + + int numdata = OPS_GetNumRemainingInputArgs(); + if (numdata < 1) { + opserr << "WARNING want - getEleLoadTags patternTag?\n"; + return -1; + } + + int patternTag; + numdata = 1; + if (OPS_GetIntInput(&numdata, &patternTag) < 0) { + opserr << "could not read patternTag\n"; + return -1; + } + + LoadPattern* thePattern = theDomain->getLoadPattern(patternTag); + ElementalLoadIter& theEleLoads = thePattern->getElementalLoads(); + ElementalLoad* theLoad; + + std::vector data; + + while ((theLoad = theEleLoads()) != 0) { + data.push_back(theLoad->getElementTag()); + } + + int size = data.size(); + + if (OPS_SetIntOutput(&size, data.data(), false) < 0) { + opserr << "WARNING failed to set output\n"; + return -1; + } + + return 0; +} + +int OPS_getEleLoadData() +{ + Domain* theDomain = OPS_GetDomain(); + if (theDomain == 0) return -1; + + int numdata = OPS_GetNumRemainingInputArgs(); + if (numdata < 1) { + opserr << "WARNING want - getEleLoadData patternTag?\n"; + return -1; + } + + int patternTag; + numdata = 1; + if (OPS_GetIntInput(&numdata, &patternTag) < 0) { + opserr << "could not read patternTag\n"; + return -1; + } + + LoadPattern* thePattern = theDomain->getLoadPattern(patternTag); + ElementalLoadIter& theEleLoads = thePattern->getElementalLoads(); + ElementalLoad* theLoad; + + std::vector data; + + int typeEL; + + while ((theLoad = theEleLoads()) != 0) { + const Vector &eleLoadData = theLoad->getData(typeEL, 1.0); + + int eleLoadDataSize = eleLoadData.Size(); + for (int i = 0; i < eleLoadDataSize; i++) { + data.push_back(eleLoadData(i)); + } + } + + int size = data.size(); + + if (OPS_SetDoubleOutput(&size, data.data(), false) < 0) { + opserr << "WARNING failed to set output\n"; + return -1; + } + + return 0; +} + +int OPS_getNumElements() +{ + Domain* theDomain = OPS_GetDomain(); + if (theDomain == 0) return -1; + + int nEles = theDomain->getNumElements(); + int size = 1; + + if (OPS_SetIntOutput(&size, &nEles, false) < 0) { + opserr << "WARNING failed to set output\n"; + return -1; + } + + return 0; +} + // Sensitivity:END ///////////////////////////////////////////// diff --git a/SRC/interpreter/PythonWrapper.cpp b/SRC/interpreter/PythonWrapper.cpp index aacce860b..1c1d6d613 100644 --- a/SRC/interpreter/PythonWrapper.cpp +++ b/SRC/interpreter/PythonWrapper.cpp @@ -1992,6 +1992,54 @@ static PyObject *Py_ops_sensNodePressure(PyObject *self, PyObject *args) return wrapper->getResults(); } +static PyObject *Py_ops_getNumElements(PyObject *self, PyObject *args) +{ + wrapper->resetCommandLine(PyTuple_Size(args), 1, args); + + if (OPS_getNumElements() < 0) { + opserr<<(void*)0; + return NULL; + } + + return wrapper->getResults(); +} + +static PyObject *Py_ops_getEleLoadClassTags(PyObject *self, PyObject *args) +{ + wrapper->resetCommandLine(PyTuple_Size(args), 1, args); + + if (OPS_getEleLoadClassTags() < 0) { + opserr<<(void*)0; + return NULL; + } + + return wrapper->getResults(); +} + +static PyObject *Py_ops_getEleLoadTags(PyObject *self, PyObject *args) +{ + wrapper->resetCommandLine(PyTuple_Size(args), 1, args); + + if (OPS_getEleLoadTags() < 0) { + opserr<<(void*)0; + return NULL; + } + + return wrapper->getResults(); +} + +static PyObject *Py_ops_getEleLoadData(PyObject *self, PyObject *args) +{ + wrapper->resetCommandLine(PyTuple_Size(args), 1, args); + + if (OPS_getEleLoadData() < 0) { + opserr<<(void*)0; + return NULL; + } + + return wrapper->getResults(); +} + static PyObject *Py_ops_randomVariable(PyObject *self, PyObject *args) { wrapper->resetCommandLine(PyTuple_Size(args), 1, args); @@ -2381,6 +2429,10 @@ PythonWrapper::addOpenSeesCommands() addCommand("sensLambda", &Py_ops_sensLambda); addCommand("sensSectionForce", &Py_ops_sensSectionForce); addCommand("sensNodePressure", &Py_ops_sensNodePressure); + addCommand("getNumElements", &Py_ops_getNumElements); + addCommand("getEleLoadClassTags", &Py_ops_getEleLoadClassTags); + addCommand("getEleLoadTags", &Py_ops_getEleLoadTags); + addCommand("getEleLoadData", &Py_ops_getEleLoadData); addCommand("randomVariable", &Py_ops_randomVariable); addCommand("getRVTags", &Py_ops_getRVTags); addCommand("getMean", &Py_ops_getRVMean); diff --git a/SRC/interpreter/TclWrapper.cpp b/SRC/interpreter/TclWrapper.cpp index 99ca5b278..4cbd26acc 100644 --- a/SRC/interpreter/TclWrapper.cpp +++ b/SRC/interpreter/TclWrapper.cpp @@ -1308,6 +1308,42 @@ static int Tcl_ops_sensNodePressure(ClientData clientData, Tcl_Interp *interp, i return TCL_OK; } +static int Tcl_ops_getNumElements(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) +{ + wrapper->resetCommandLine(argc, 1, argv); + + if (OPS_getNumElements() < 0) return TCL_ERROR; + + return TCL_OK; +} + +static int Tcl_ops_getEleLoadClassTags(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) +{ + wrapper->resetCommandLine(argc, 1, argv); + + if (OPS_getEleLoadClassTags() < 0) return TCL_ERROR; + + return TCL_OK; +} + +static int Tcl_ops_getEleLoadTags(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) +{ + wrapper->resetCommandLine(argc, 1, argv); + + if (OPS_getEleLoadTags() < 0) return TCL_ERROR; + + return TCL_OK; +} + +static int Tcl_ops_getEleLoadData(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) +{ + wrapper->resetCommandLine(argc, 1, argv); + + if (OPS_getEleLoadData() < 0) return TCL_ERROR; + + return TCL_OK; +} + static int Tcl_ops_randomVariable(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) { wrapper->resetCommandLine(argc, 1, argv); @@ -1653,6 +1689,10 @@ TclWrapper::addOpenSeesCommands(Tcl_Interp* interp) addCommand(interp,"sensLambda", &Tcl_ops_sensLambda); addCommand(interp,"sensSectionForce", &Tcl_ops_sensSectionForce); addCommand(interp,"sensNodePressure", &Tcl_ops_sensNodePressure); + addCommand(interp,"getNumElements", &Tcl_ops_getNumElements); + addCommand(interp,"getEleLoadClassTags", &Tcl_ops_getEleLoadClassTags); + addCommand(interp,"getEleLoadTags", &Tcl_ops_getEleLoadTags); + addCommand(interp,"getEleLoadData", &Tcl_ops_getEleLoadData); addCommand(interp,"randomVariable", &Tcl_ops_randomVariable); addCommand(interp,"getRVTags", &Tcl_ops_getRVTags); addCommand(interp,"getMean", &Tcl_ops_getRVMean); From 7b6af5ef90806b754ef860a30350cbd66b6fb8df Mon Sep 17 00:00:00 2001 From: Seweryn Kokot Date: Tue, 30 Mar 2021 10:36:39 +0200 Subject: [PATCH 006/193] add getEleClassTags utility command --- SRC/interpreter/OpenSeesCommands.h | 1 + SRC/interpreter/OpenSeesOutputCommands.cpp | 48 +++++++++++++++++++++- SRC/interpreter/PythonWrapper.cpp | 13 ++++++ SRC/interpreter/TclWrapper.cpp | 10 +++++ 4 files changed, 71 insertions(+), 1 deletion(-) diff --git a/SRC/interpreter/OpenSeesCommands.h b/SRC/interpreter/OpenSeesCommands.h index 929992680..a8a5972fc 100644 --- a/SRC/interpreter/OpenSeesCommands.h +++ b/SRC/interpreter/OpenSeesCommands.h @@ -282,6 +282,7 @@ int OPS_sensLambda(); int OPS_sensSectionForce(); int OPS_sensNodePressure(); int OPS_getNumElements(); +int OPS_getEleClassTags(); int OPS_getEleLoadClassTags(); int OPS_getEleLoadTags(); int OPS_getEleLoadData(); diff --git a/SRC/interpreter/OpenSeesOutputCommands.cpp b/SRC/interpreter/OpenSeesOutputCommands.cpp index 12d4c1173..076fb1e1e 100644 --- a/SRC/interpreter/OpenSeesOutputCommands.cpp +++ b/SRC/interpreter/OpenSeesOutputCommands.cpp @@ -3109,6 +3109,52 @@ int OPS_sensNodePressure() return 0; } +int OPS_getEleClassTags() +{ + Domain* theDomain = OPS_GetDomain(); + if (theDomain == 0) return -1; + + int numdata = OPS_GetNumRemainingInputArgs(); + + std::vector data; + + // all element tags + if (numdata < 1) { + Element *theEle; + ElementIter &theEles = theDomain->getElements(); + + while ((theEle = theEles()) != 0) { + data.push_back(theEle->getClassTag()); + } + + // specific element tag + } else if (numdata == 1) { + int eleTag; + + if (OPS_GetIntInput(&numdata, &eleTag) < 0) { + opserr << "could not read eleTag\n"; + return -1; + } + + Element *theEle = theDomain->getElement(eleTag); + + data.push_back(theEle->getClassTag()); + + } else { + opserr << "WARNING want - getEleClassTags \n"; + return -1; + } + + int size = data.size(); + + if (OPS_SetIntOutput(&size, data.data(), false) < 0) { + opserr << "WARNING failed to set output\n"; + return -1; + } + + return 0; +} + int OPS_getEleLoadClassTags() { Domain* theDomain = OPS_GetDomain(); @@ -3116,7 +3162,7 @@ int OPS_getEleLoadClassTags() int numdata = OPS_GetNumRemainingInputArgs(); if (numdata < 1) { - opserr << "WARNING want - getEleLoadTags patternTag?\n"; + opserr << "WARNING want - getEleLoadClassTags patternTag?\n"; return -1; } diff --git a/SRC/interpreter/PythonWrapper.cpp b/SRC/interpreter/PythonWrapper.cpp index 1c1d6d613..d8e200e35 100644 --- a/SRC/interpreter/PythonWrapper.cpp +++ b/SRC/interpreter/PythonWrapper.cpp @@ -2004,6 +2004,18 @@ static PyObject *Py_ops_getNumElements(PyObject *self, PyObject *args) return wrapper->getResults(); } +static PyObject *Py_ops_getEleClassTags(PyObject *self, PyObject *args) +{ + wrapper->resetCommandLine(PyTuple_Size(args), 1, args); + + if (OPS_getEleClassTags() < 0) { + opserr<<(void*)0; + return NULL; + } + + return wrapper->getResults(); +} + static PyObject *Py_ops_getEleLoadClassTags(PyObject *self, PyObject *args) { wrapper->resetCommandLine(PyTuple_Size(args), 1, args); @@ -2430,6 +2442,7 @@ PythonWrapper::addOpenSeesCommands() addCommand("sensSectionForce", &Py_ops_sensSectionForce); addCommand("sensNodePressure", &Py_ops_sensNodePressure); addCommand("getNumElements", &Py_ops_getNumElements); + addCommand("getEleClassTags", &Py_ops_getEleClassTags); addCommand("getEleLoadClassTags", &Py_ops_getEleLoadClassTags); addCommand("getEleLoadTags", &Py_ops_getEleLoadTags); addCommand("getEleLoadData", &Py_ops_getEleLoadData); diff --git a/SRC/interpreter/TclWrapper.cpp b/SRC/interpreter/TclWrapper.cpp index 4cbd26acc..b75503e03 100644 --- a/SRC/interpreter/TclWrapper.cpp +++ b/SRC/interpreter/TclWrapper.cpp @@ -1317,6 +1317,15 @@ static int Tcl_ops_getNumElements(ClientData clientData, Tcl_Interp *interp, int return TCL_OK; } +static int Tcl_ops_getEleClassTags(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) +{ + wrapper->resetCommandLine(argc, 1, argv); + + if (OPS_getEleClassTags() < 0) return TCL_ERROR; + + return TCL_OK; +} + static int Tcl_ops_getEleLoadClassTags(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) { wrapper->resetCommandLine(argc, 1, argv); @@ -1690,6 +1699,7 @@ TclWrapper::addOpenSeesCommands(Tcl_Interp* interp) addCommand(interp,"sensSectionForce", &Tcl_ops_sensSectionForce); addCommand(interp,"sensNodePressure", &Tcl_ops_sensNodePressure); addCommand(interp,"getNumElements", &Tcl_ops_getNumElements); + addCommand(interp,"getEleClassTags", &Tcl_ops_getEleClassTags); addCommand(interp,"getEleLoadClassTags", &Tcl_ops_getEleLoadClassTags); addCommand(interp,"getEleLoadTags", &Tcl_ops_getEleLoadTags); addCommand(interp,"getEleLoadData", &Tcl_ops_getEleLoadData); From c64203a8b151efc29fa82638d9d84fefe7188606 Mon Sep 17 00:00:00 2001 From: Seweryn Kokot Date: Tue, 30 Mar 2021 12:58:58 +0200 Subject: [PATCH 007/193] Element load output commands: no pattern tag means all pattern tags --- SRC/interpreter/OpenSeesOutputCommands.cpp | 160 ++++++++++++++------- 1 file changed, 108 insertions(+), 52 deletions(-) diff --git a/SRC/interpreter/OpenSeesOutputCommands.cpp b/SRC/interpreter/OpenSeesOutputCommands.cpp index 076fb1e1e..be90e1354 100644 --- a/SRC/interpreter/OpenSeesOutputCommands.cpp +++ b/SRC/interpreter/OpenSeesOutputCommands.cpp @@ -45,6 +45,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS. #include #include #include +#include #include #include // #include @@ -3161,27 +3162,44 @@ int OPS_getEleLoadClassTags() if (theDomain == 0) return -1; int numdata = OPS_GetNumRemainingInputArgs(); + + std::vector data; + if (numdata < 1) { - opserr << "WARNING want - getEleLoadClassTags patternTag?\n"; - return -1; - } + LoadPattern *thePattern; + LoadPatternIter &thePatterns = theDomain->getLoadPatterns(); - int patternTag; - numdata = 1; - if (OPS_GetIntInput(&numdata, &patternTag) < 0) { - opserr << "could not read patternTag\n"; - return -1; - } + while ((thePattern = thePatterns()) != 0) { + ElementalLoadIter theEleLoads = thePattern->getElementalLoads(); + ElementalLoad* theLoad; - LoadPattern *thePattern = theDomain->getLoadPattern(patternTag); - ElementalLoadIter theEleLoads = thePattern->getElementalLoads(); - ElementalLoad* theLoad; + while ((theLoad = theEleLoads()) != 0) { + data.push_back(theLoad->getClassTag()); + } - std::vector data; + } + + } else if (numdata == 1) { + + int patternTag; + if (OPS_GetIntInput(&numdata, &patternTag) < 0) { + opserr << "could not read patternTag\n"; + return -1; + } + + LoadPattern *thePattern = theDomain->getLoadPattern(patternTag); + ElementalLoadIter theEleLoads = thePattern->getElementalLoads(); + ElementalLoad* theLoad; + + while ((theLoad = theEleLoads()) != 0) { + data.push_back(theLoad->getClassTag()); + } + + } else { + opserr << "WARNING want - getEleLoadClassTags \n"; + return -1; + } - while ((theLoad = theEleLoads()) != 0) { - data.push_back(theLoad->getClassTag()); - } int size = data.size(); @@ -3199,27 +3217,43 @@ int OPS_getEleLoadTags() if (theDomain == 0) return -1; int numdata = OPS_GetNumRemainingInputArgs(); + + std::vector data; + if (numdata < 1) { - opserr << "WARNING want - getEleLoadTags patternTag?\n"; - return -1; - } + LoadPattern *thePattern; + LoadPatternIter &thePatterns = theDomain->getLoadPatterns(); - int patternTag; - numdata = 1; - if (OPS_GetIntInput(&numdata, &patternTag) < 0) { - opserr << "could not read patternTag\n"; - return -1; - } + while ((thePattern = thePatterns()) != 0) { + ElementalLoadIter theEleLoads = thePattern->getElementalLoads(); + ElementalLoad* theLoad; + + while ((theLoad = theEleLoads()) != 0) { + data.push_back(theLoad->getElementTag()); + } - LoadPattern* thePattern = theDomain->getLoadPattern(patternTag); - ElementalLoadIter& theEleLoads = thePattern->getElementalLoads(); - ElementalLoad* theLoad; + } - std::vector data; + } else if (numdata == 1) { - while ((theLoad = theEleLoads()) != 0) { - data.push_back(theLoad->getElementTag()); - } + int patternTag; + if (OPS_GetIntInput(&numdata, &patternTag) < 0) { + opserr << "could not read patternTag\n"; + return -1; + } + + LoadPattern* thePattern = theDomain->getLoadPattern(patternTag); + ElementalLoadIter& theEleLoads = thePattern->getElementalLoads(); + ElementalLoad* theLoad; + + while ((theLoad = theEleLoads()) != 0) { + data.push_back(theLoad->getElementTag()); + } + + } else { + opserr << "WARNING want - getEleLoadTags \n"; + return -1; + } int size = data.size(); @@ -3237,34 +3271,56 @@ int OPS_getEleLoadData() if (theDomain == 0) return -1; int numdata = OPS_GetNumRemainingInputArgs(); + + std::vector data; + if (numdata < 1) { - opserr << "WARNING want - getEleLoadData patternTag?\n"; - return -1; - } + LoadPattern *thePattern; + LoadPatternIter &thePatterns = theDomain->getLoadPatterns(); + + int typeEL; + + while ((thePattern = thePatterns()) != 0) { + ElementalLoadIter &theEleLoads = thePattern->getElementalLoads(); + ElementalLoad* theLoad; + + while ((theLoad = theEleLoads()) != 0) { + const Vector &eleLoadData = theLoad->getData(typeEL, 1.0); + + int eleLoadDataSize = eleLoadData.Size(); + for (int i = 0; i < eleLoadDataSize; i++) { + data.push_back(eleLoadData(i)); + } + } + } - int patternTag; - numdata = 1; - if (OPS_GetIntInput(&numdata, &patternTag) < 0) { - opserr << "could not read patternTag\n"; - return -1; - } + } else if (numdata == 1) { - LoadPattern* thePattern = theDomain->getLoadPattern(patternTag); - ElementalLoadIter& theEleLoads = thePattern->getElementalLoads(); - ElementalLoad* theLoad; + int patternTag; + if (OPS_GetIntInput(&numdata, &patternTag) < 0) { + opserr << "could not read patternTag\n"; + return -1; + } - std::vector data; + LoadPattern* thePattern = theDomain->getLoadPattern(patternTag); + ElementalLoadIter& theEleLoads = thePattern->getElementalLoads(); + ElementalLoad* theLoad; - int typeEL; + int typeEL; - while ((theLoad = theEleLoads()) != 0) { - const Vector &eleLoadData = theLoad->getData(typeEL, 1.0); + while ((theLoad = theEleLoads()) != 0) { + const Vector &eleLoadData = theLoad->getData(typeEL, 1.0); - int eleLoadDataSize = eleLoadData.Size(); - for (int i = 0; i < eleLoadDataSize; i++) { - data.push_back(eleLoadData(i)); + int eleLoadDataSize = eleLoadData.Size(); + for (int i = 0; i < eleLoadDataSize; i++) { + data.push_back(eleLoadData(i)); + } } - } + + } else { + opserr << "WARNING want - getEleLoadData \n"; + return -1; + } int size = data.size(); From cc40c4b1ed4e32a1fd44d6a32c180e067fc0ee89 Mon Sep 17 00:00:00 2001 From: Seweryn Kokot Date: Thu, 1 Apr 2021 07:16:40 +0200 Subject: [PATCH 008/193] add the output commands to the Tcl interpreter --- SRC/tcl/commands.cpp | 216 +++++++++++++++++++++++++++++++++++++++++++ SRC/tcl/commands.h | 14 +++ 2 files changed, 230 insertions(+) diff --git a/SRC/tcl/commands.cpp b/SRC/tcl/commands.cpp index 3c5a1ca6f..3a6cb68ad 100644 --- a/SRC/tcl/commands.cpp +++ b/SRC/tcl/commands.cpp @@ -990,6 +990,17 @@ int OpenSeesAppInit(Tcl_Interp *interp) { Tcl_CreateCommand(interp, "getParamValue", &getParamValue, (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); + Tcl_CreateCommand(interp, "getNumElements", &getNumElements, + (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); + Tcl_CreateCommand(interp, "getEleClassTags", &getEleClassTags, + (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); + Tcl_CreateCommand(interp, "getEleLoadClassTags", &getEleLoadClassTags, + (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); + Tcl_CreateCommand(interp, "getEleLoadTags", &getEleLoadTags, + (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); + Tcl_CreateCommand(interp, "getEleLoadData", &getEleLoadData, + (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); + Tcl_CreateCommand(interp, "sdfResponse", &sdfResponse, (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); @@ -8459,6 +8470,211 @@ getNP(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) return TCL_OK; } +// sewi +int +getNumElements(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) +{ + char buffer[20]; + + sprintf(buffer, "%d ", theDomain.getNumElements()); + Tcl_AppendResult(interp, buffer, NULL); + + return TCL_OK; +} + +// sewi +int +getEleClassTags(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) +{ + + if (argc == 1) { + Element *theEle; + ElementIter &eleIter = theDomain.getElements(); + + char buffer[20]; + + while ((theEle = eleIter()) != 0) { + sprintf(buffer, "%d ", theEle->getClassTag()); + Tcl_AppendResult(interp, buffer, NULL); + } + } else if (argc == 2) { + int eleTag; + + if (Tcl_GetInt(interp, argv[1], &eleTag) != TCL_OK) { + opserr << "WARNING getParamValue -- could not read paramTag \n"; + return TCL_ERROR; + } + + Element *theEle = theDomain.getElement(eleTag); + + char buffer[20]; + + sprintf(buffer, "%d ", theEle->getClassTag()); + Tcl_AppendResult(interp, buffer, NULL); + + } else { + opserr << "WARNING want - getEleClassTags \n" << endln; + return TCL_ERROR; + } + + return TCL_OK; +} + +int +getEleLoadClassTags(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) +{ + + if (argc == 1) { + LoadPattern *thePattern; + LoadPatternIter &thePatterns = theDomain.getLoadPatterns(); + + char buffer[20]; + + while ((thePattern = thePatterns()) != 0) { + ElementalLoadIter theEleLoads = thePattern->getElementalLoads(); + ElementalLoad *theLoad; + + while ((theLoad = theEleLoads()) != 0) { + sprintf(buffer, "%d ", theLoad->getClassTag()); + Tcl_AppendResult(interp, buffer, NULL); + } + } + + } else if (argc == 2) { + int patternTag; + + if (Tcl_GetInt(interp, argv[1], &patternTag) != TCL_OK) { + opserr << "WARNING getParamValue -- could not read paramTag \n"; + return TCL_ERROR; + } + + LoadPattern *thePattern = theDomain.getLoadPattern(patternTag); + ElementalLoadIter theEleLoads = thePattern->getElementalLoads(); + ElementalLoad* theLoad; + + char buffer[20]; + + while ((theLoad = theEleLoads()) != 0) { + sprintf(buffer, "%d ", theLoad->getClassTag()); + Tcl_AppendResult(interp, buffer, NULL); + } + + } else { + opserr << "WARNING want - getEleLoadClassTags \n" << endln; + return TCL_ERROR; + } + + return TCL_OK; +} + +int +getEleLoadTags(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) +{ + + if (argc == 1) { + LoadPattern *thePattern; + LoadPatternIter &thePatterns = theDomain.getLoadPatterns(); + + char buffer[20]; + + while ((thePattern = thePatterns()) != 0) { + ElementalLoadIter theEleLoads = thePattern->getElementalLoads(); + ElementalLoad *theLoad; + + while ((theLoad = theEleLoads()) != 0) { + sprintf(buffer, "%d ", theLoad->getElementTag()); + Tcl_AppendResult(interp, buffer, NULL); + } + } + + } else if (argc == 2) { + int patternTag; + + if (Tcl_GetInt(interp, argv[1], &patternTag) != TCL_OK) { + opserr << "WARNING getParamValue -- could not read paramTag \n"; + return TCL_ERROR; + } + + LoadPattern *thePattern = theDomain.getLoadPattern(patternTag); + ElementalLoadIter theEleLoads = thePattern->getElementalLoads(); + ElementalLoad* theLoad; + + char buffer[20]; + + while ((theLoad = theEleLoads()) != 0) { + sprintf(buffer, "%d ", theLoad->getElementTag()); + Tcl_AppendResult(interp, buffer, NULL); + } + + } else { + opserr << "WARNING want - getEleLoadTags \n" << endln; + return TCL_ERROR; + } + + return TCL_OK; +} + +int +getEleLoadData(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) +{ + + if (argc == 1) { + LoadPattern *thePattern; + LoadPatternIter &thePatterns = theDomain.getLoadPatterns(); + + char buffer[40]; + int typeEL; + + while ((thePattern = thePatterns()) != 0) { + ElementalLoadIter &theEleLoads = thePattern->getElementalLoads(); + ElementalLoad *theLoad; + + while ((theLoad = theEleLoads()) != 0) { + const Vector &eleLoadData = theLoad->getData(typeEL, 1.0); + + int eleLoadDataSize = eleLoadData.Size(); + opserr << "eleLoadDataSize: "<< eleLoadDataSize << "\n"; + for (int i = 0; i < eleLoadDataSize; i++) { + sprintf(buffer, "%35.20f ", eleLoadData(i)); + Tcl_AppendResult(interp, buffer, NULL); + } + } + } + + } else if (argc == 2) { + int patternTag; + + if (Tcl_GetInt(interp, argv[1], &patternTag) != TCL_OK) { + opserr << "WARNING getParamValue -- could not read paramTag \n"; + return TCL_ERROR; + } + + LoadPattern *thePattern = theDomain.getLoadPattern(patternTag); + ElementalLoadIter theEleLoads = thePattern->getElementalLoads(); + ElementalLoad* theLoad; + + int typeEL; + char buffer[40]; + + while ((theLoad = theEleLoads()) != 0) { + const Vector &eleLoadData = theLoad->getData(typeEL, 1.0); + + int eleLoadDataSize = eleLoadData.Size(); + for (int i = 0; i < eleLoadDataSize; i++) { + sprintf(buffer, "%35.20f ", eleLoadData(i)); + Tcl_AppendResult(interp, buffer, NULL); + } + + } + + } else { + opserr << "WARNING want - getEleLoadTags \n" << endln; + return TCL_ERROR; + } + + return TCL_OK; +} + int getEleTags(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) { diff --git a/SRC/tcl/commands.h b/SRC/tcl/commands.h index 89539c806..c4e7b2341 100644 --- a/SRC/tcl/commands.h +++ b/SRC/tcl/commands.h @@ -254,6 +254,20 @@ int sensitivityIntegrator(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); // AddingSensitivity:END /////////////////////////////////////////////////// +int +getNumElements(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); + +int +getEleClassTags(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); + +int +getEleLoadClassTags(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); + +int +getEleLoadTags(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); + +int +getEleLoadData(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); int startTimer(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); From a2976e4a8c4b825e682aa766491021222b7ce2cb Mon Sep 17 00:00:00 2001 From: Seweryn Kokot Date: Fri, 2 Apr 2021 08:57:31 +0200 Subject: [PATCH 009/193] add error messages when the patternTag does not exist, minor fixes --- SRC/interpreter/OpenSeesOutputCommands.cpp | 18 +++++++++++++----- SRC/tcl/commands.cpp | 21 ++++++++++++++++++--- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/SRC/interpreter/OpenSeesOutputCommands.cpp b/SRC/interpreter/OpenSeesOutputCommands.cpp index be90e1354..6cbefb682 100644 --- a/SRC/interpreter/OpenSeesOutputCommands.cpp +++ b/SRC/interpreter/OpenSeesOutputCommands.cpp @@ -48,10 +48,6 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS. #include #include #include -// #include -// #include -// #include -// #include #include #include #include @@ -3188,6 +3184,10 @@ int OPS_getEleLoadClassTags() } LoadPattern *thePattern = theDomain->getLoadPattern(patternTag); + if (thePattern == nullptr) { + opserr << "ERROR load pattern with tag " << patternTag << " not found in domain -- getEleLoadClassTags\n"; + return -1; + } ElementalLoadIter theEleLoads = thePattern->getElementalLoads(); ElementalLoad* theLoad; @@ -3243,6 +3243,10 @@ int OPS_getEleLoadTags() } LoadPattern* thePattern = theDomain->getLoadPattern(patternTag); + if (thePattern == nullptr) { + opserr << "ERROR load pattern with tag " << patternTag << " not found in domain -- getEleLoadTags\n"; + return -1; + } ElementalLoadIter& theEleLoads = thePattern->getElementalLoads(); ElementalLoad* theLoad; @@ -3279,7 +3283,7 @@ int OPS_getEleLoadData() LoadPatternIter &thePatterns = theDomain->getLoadPatterns(); int typeEL; - + while ((thePattern = thePatterns()) != 0) { ElementalLoadIter &theEleLoads = thePattern->getElementalLoads(); ElementalLoad* theLoad; @@ -3303,6 +3307,10 @@ int OPS_getEleLoadData() } LoadPattern* thePattern = theDomain->getLoadPattern(patternTag); + if (thePattern == nullptr) { + opserr << "ERROR load pattern with tag " << patternTag << " not found in domain -- getEleLoadData\n"; + return -1; + } ElementalLoadIter& theEleLoads = thePattern->getElementalLoads(); ElementalLoad* theLoad; diff --git a/SRC/tcl/commands.cpp b/SRC/tcl/commands.cpp index 3a6cb68ad..35ae786b0 100644 --- a/SRC/tcl/commands.cpp +++ b/SRC/tcl/commands.cpp @@ -8544,11 +8544,16 @@ getEleLoadClassTags(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Cha int patternTag; if (Tcl_GetInt(interp, argv[1], &patternTag) != TCL_OK) { - opserr << "WARNING getParamValue -- could not read paramTag \n"; + opserr << "WARNING getEleLoadClassTags -- could not read patternTag\n"; return TCL_ERROR; } LoadPattern *thePattern = theDomain.getLoadPattern(patternTag); + if (thePattern == nullptr) { + opserr << "ERROR load pattern with tag " << patternTag << " not found in domain -- getEleLoadClassTags\n"; + return TCL_ERROR; + } + ElementalLoadIter theEleLoads = thePattern->getElementalLoads(); ElementalLoad* theLoad; @@ -8591,11 +8596,16 @@ getEleLoadTags(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **a int patternTag; if (Tcl_GetInt(interp, argv[1], &patternTag) != TCL_OK) { - opserr << "WARNING getParamValue -- could not read paramTag \n"; + opserr << "WARNING getEleLoadTags -- could not read patternTag \n"; return TCL_ERROR; } LoadPattern *thePattern = theDomain.getLoadPattern(patternTag); + if (thePattern == nullptr) { + opserr << "ERROR load pattern with tag " << patternTag << " not found in domain -- getEleLoadTags\n"; + return TCL_ERROR; + } + ElementalLoadIter theEleLoads = thePattern->getElementalLoads(); ElementalLoad* theLoad; @@ -8645,11 +8655,16 @@ getEleLoadData(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **a int patternTag; if (Tcl_GetInt(interp, argv[1], &patternTag) != TCL_OK) { - opserr << "WARNING getParamValue -- could not read paramTag \n"; + opserr << "WARNING getEleLoadData -- could not read patternTag \n"; return TCL_ERROR; } LoadPattern *thePattern = theDomain.getLoadPattern(patternTag); + if (thePattern == nullptr) { + opserr << "ERROR load pattern with tag " << patternTag << " not found in domain -- getEleLoadData\n"; + return TCL_ERROR; + } + ElementalLoadIter theEleLoads = thePattern->getElementalLoads(); ElementalLoad* theLoad; From 78c5d230799f2ca9d0e5466e7033c8cb9015eb6f Mon Sep 17 00:00:00 2001 From: ambaker1 Date: Sun, 18 Apr 2021 18:20:42 -0400 Subject: [PATCH 010/193] Create MaterialTest.cpp Created MaterialTest Design intent is to be a combination of uniaxial material, ND material, and section testers. Main commands: testUniaxialMaterial testNDMaterial testSection Each of the main test commands will define the test type (1 for uniaxial, 2 for ND, 3 for section), and set the static object to the corresponding material/section. The other commands will each have a switch based on test type (0, 1, 2, and 3). 0 is the default, and will throw an error The other commands are taken from the uniaxial material test commands in the python interpreter, with the exception that setTrialStrain, commitStrain, and getResponse will be added. --- SRC/material/MaterialTest.cpp | 276 ++++++++++++++++++++++++++++++++++ 1 file changed, 276 insertions(+) create mode 100644 SRC/material/MaterialTest.cpp diff --git a/SRC/material/MaterialTest.cpp b/SRC/material/MaterialTest.cpp new file mode 100644 index 000000000..1265bfc73 --- /dev/null +++ b/SRC/material/MaterialTest.cpp @@ -0,0 +1,276 @@ +/* ***************************************************************************** +Copyright (c) 2015-2017, The Regents of the University of California (Regents). +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those +of the authors and should not be interpreted as representing official policies, +either expressed or implied, of the FreeBSD Project. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS +PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, +UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +*************************************************************************** */ + +// Written: Alex Baker +// Created: 04/21 +// +// Description: This file contains the material testing commands + +#include +#include +#include +#include +#include + +static int testType = 0; +static UniaxialMaterial* theTestingUniaxialMaterial = 0; +static NDMaterial* theTestingNDMaterial = 0; +static SectionForceDeformation* theTestingSection = 0; + +int OPS_testUniaxialMaterial() +{ + if (OPS_GetNumRemainingInputArgs() != 1) { + opserr << "testUniaxialMaterial - You must provide a material tag.\n"; + return -1; + } + + int tag; + int numData = 1; + if (OPS_GetIntInput(&numData, &tag) < 0) { + opserr << "invalid int value\n"; + return -1; + } + + UniaxialMaterial* mat = OPS_getUniaxialMaterial(tag); + + if (mat == 0) { + opserr << "testUniaxialMaterial - Material Not Found.\n"; + return -1; + } + + theTestingUniaxialMaterial = mat; + testType = 1; + + return 0; +} + +int OPS_testNDMaterial() +{ + if (OPS_GetNumRemainingInputArgs() != 1) { + opserr << "testNDMaterial - You must provide a material tag.\n"; + return -1; + } + + int tag; + int numData = 1; + if (OPS_GetIntInput(&numData, &tag) < 0) { + opserr << "invalid int value\n"; + return -1; + } + + NDMaterial* mat = OPS_getNDMaterial(tag); + + if (mat == 0) { + opserr << "testNDMaterial - Material Not Found.\n"; + return -1; + } + + theTestingNDMaterial = mat; + testType = 2; + + return 0; +} + +int OPS_testSection() +{ + if (OPS_GetNumRemainingInputArgs() != 1) { + opserr << "testSection - You must provide a section tag.\n"; + return -1; + } + + int tag; + int numData = 1; + if (OPS_GetIntInput(&numData, &tag) < 0) { + opserr << "invalid int value\n"; + return -1; + } + + SectionForceDeformation* mat = OPS_getNDMaterial(tag); + + if (mat == 0) { + opserr << "testSection - Section Not Found.\n"; + return -1; + } + + theTestingSection = mat; + testType = 3; + + return 0; +} + +int OPS_setStrain() +{ + if (testType == 0) { + opserr << "setStrain WARNING no active test\n"; + return -1; + } + OPS_setTrialStrain() + OPS_commitStrain() +} + +int OPS_setTrialStrain() +{ + if (testType == 0) { + opserr << "setTrialStrain WARNING no active test\n"; + return -1; + } + else if (testType == 1) { + if (OPS_GetNumRemainingInputArgs() != 1) { + opserr << "testUniaxialMaterial - You must provide a strain value.\n"; + return -1; + } + double strain; + int numData = 1; + if (OPS_GetDoubleInput(&numData, &strain) < 0) { + opserr << "invalid double value\n"; + return -1; + } + theTestingUniaxialMaterial->setTrialStrain(strain); + } + else if (testType == 2) { + opserr << "nDMaterial test - not implemented yet\n"; + } + else if (testType == 3) { + opserr << "section test - not implemented yet\n"; + } + + return 0; +} + +int OPS_commitStrain() +{ + if (testType == 0) { + opserr << "commitStrain WARNING no active test\n"; + return -1; + } + else if (testType == 1) { + theTestingUniaxialMaterial->commitState(); + } + else if (testType == 2) { + theTestingNDMaterial->commitState(); + } + else if (testType == 3) { + theTestingSection->commitState(); + } +} + +int OPS_getStrain() +{ + if (testType == 0) { + opserr << "getStrain WARNING no active test\n"; + return -1; + } + else if (testType == 1) { + double strain = theTestingUniaxialMaterial->getStrain(); + } + else if (testType == 2) { + double strain = theTestingNDMaterial->getStrain(); + } + else if (testType == 3) { + double strain = theTestingSection->getStrain(); + } + + double strain = material->getStrain(); + + int numData = 1; + + if (OPS_SetDoubleOutput(&numData, &strain, true) < 0) { + opserr << "failed to set strain\n"; + return -1; + } + + return 0; +} + +int OPS_getStress() +{ + UniaxialMaterial* material = theTestingUniaxialMaterial; + if (material == 0) { + opserr << "getStrain WARNING no active UniaxialMaterial - use testUniaxialMaterial command.\n"; + return -1; + } + + double stress = material->getStress(); + + int numData = 1; + + if (OPS_SetDoubleOutput(&numData, &stress, true) < 0) { + opserr << "failed to set stress\n"; + return -1; + } + + return 0; +} + +int OPS_getTangent() +{ + UniaxialMaterial* material = theTestingUniaxialMaterial; + if (material == 0) { + opserr << "getStrain WARNING no active UniaxialMaterial - use testUniaxialMaterial command.\n"; + return -1; + } + + double tangent = material->getTangent(); + + int numData = 1; + + if (OPS_SetDoubleOutput(&numData, &tangent, true) < 0) { + opserr << "failed to set tangent\n"; + return -1; + } + + return 0; +} + +int OPS_getDampTangent() +{ + UniaxialMaterial* material = theTestingUniaxialMaterial; + if (material == 0) { + opserr << "getStrain WARNING no active UniaxialMaterial - use testUniaxialMaterial command.\n"; + return -1; + } + + double tangent = material->getDampTangent(); + + int numData = 1; + + if (OPS_SetDoubleOutput(&numData, &tangent, true) < 0) { + opserr << "failed to set damp tangent\n"; + return -1; + } + + return 0; +} \ No newline at end of file From 770aab4362fb0414fd6ac0b4534dec858ae28faa Mon Sep 17 00:00:00 2001 From: ambaker1 Date: Sun, 18 Apr 2021 22:28:46 -0400 Subject: [PATCH 011/193] Update MaterialTest.cpp Rough draft. Does not compile yet. Each set/get function switches for test type. Some require dynamic arrays. Not sure how to implement into OpenSees from here. --- SRC/material/MaterialTest.cpp | 221 +++++++++++++++++++++++++--------- 1 file changed, 163 insertions(+), 58 deletions(-) diff --git a/SRC/material/MaterialTest.cpp b/SRC/material/MaterialTest.cpp index 1265bfc73..1607e138b 100644 --- a/SRC/material/MaterialTest.cpp +++ b/SRC/material/MaterialTest.cpp @@ -118,7 +118,7 @@ int OPS_testSection() return -1; } - SectionForceDeformation* mat = OPS_getNDMaterial(tag); + SectionForceDeformation* mat = OPS_getSectionForceDeformation(tag); if (mat == 0) { opserr << "testSection - Section Not Found.\n"; @@ -133,38 +133,53 @@ int OPS_testSection() int OPS_setStrain() { + // check if test is active if (testType == 0) { opserr << "setStrain WARNING no active test\n"; return -1; } - OPS_setTrialStrain() - OPS_commitStrain() + // check if any input values + if (OPS_GetNumRemainingInputArgs() == 0) { + opserr << "setStrain WARNING must provide strain values.\n"; + return -1; + } + // call sub-routines + OPS_setTrialStrain(); + OPS_commitStrain(); } int OPS_setTrialStrain() { + // check if test is active if (testType == 0) { opserr << "setTrialStrain WARNING no active test\n"; return -1; } - else if (testType == 1) { - if (OPS_GetNumRemainingInputArgs() != 1) { - opserr << "testUniaxialMaterial - You must provide a strain value.\n"; - return -1; - } - double strain; - int numData = 1; - if (OPS_GetDoubleInput(&numData, &strain) < 0) { - opserr << "invalid double value\n"; + // check if any input values + if (OPS_GetNumRemainingInputArgs() == 0) { + opserr << "setTrialStrain WARNING must provide strain values.\n"; + return -1; + } + // get strain values from input + double strain; + int numData = OPS_GetNumRemainingInputArgs(); + if (OPS_GetDoubleInput(&numData, &strain) < 0) { + opserr << "invalid double value\n"; + return -1; + } + // switch for test type + if (testType == 1) { + if (numData != 1) { + opserr << "setTrialStrain WARNING wrong number of arguments.\n"; return -1; } theTestingUniaxialMaterial->setTrialStrain(strain); } else if (testType == 2) { - opserr << "nDMaterial test - not implemented yet\n"; + theTestingNDMaterial->setTrialStrain(strain); } else if (testType == 3) { - opserr << "section test - not implemented yet\n"; + theTestingSection->setTrialSectionDeformation(strain); } return 0; @@ -172,6 +187,7 @@ int OPS_setTrialStrain() int OPS_commitStrain() { + // switch for test type if (testType == 0) { opserr << "commitStrain WARNING no active test\n"; return -1; @@ -189,27 +205,47 @@ int OPS_commitStrain() int OPS_getStrain() { + // switch for test type if (testType == 0) { opserr << "getStrain WARNING no active test\n"; return -1; } else if (testType == 1) { double strain = theTestingUniaxialMaterial->getStrain(); + int numData = 1; + // set output + if (OPS_SetDoubleOutput(&numData, &strain, true) < 0) { + opserr << "failed to get strain\n"; + return -1; + } } else if (testType == 2) { - double strain = theTestingNDMaterial->getStrain(); + const Vector& strain = theTestingNDMaterial->getStrain(); + int numData = strain.Size(); + // convert to double + double* data = new double[numData]; + for (int i = 0; i < numData; i++) + data[i] = strain(i); + // set output + if (OPS_SetDoubleOutput(&numData, data, true) < 0) { + opserr << "failed to get strain\n"; + return -1; + } + delete[] data; } else if (testType == 3) { - double strain = theTestingSection->getStrain(); - } - - double strain = material->getStrain(); - - int numData = 1; - - if (OPS_SetDoubleOutput(&numData, &strain, true) < 0) { - opserr << "failed to set strain\n"; - return -1; + const Vector& strain = theTestingSection->getSectionDeformation(); + int numData = strain.Size(); + // convert to double + double* data = new double[numData]; + for (int i = 0; i < numData; i++) + data[i] = strain(i); + // set output + if (OPS_SetDoubleOutput(&numData, data, true) < 0) { + opserr << "failed to get strain\n"; + return -1; + } + delete[] data; } return 0; @@ -217,19 +253,47 @@ int OPS_getStrain() int OPS_getStress() { - UniaxialMaterial* material = theTestingUniaxialMaterial; - if (material == 0) { - opserr << "getStrain WARNING no active UniaxialMaterial - use testUniaxialMaterial command.\n"; + // switch for test type + if (testType == 0) { + opserr << "getStress WARNING no active test\n"; return -1; } - - double stress = material->getStress(); - - int numData = 1; - - if (OPS_SetDoubleOutput(&numData, &stress, true) < 0) { - opserr << "failed to set stress\n"; - return -1; + else if (testType == 1) { + double stress = theTestingUniaxialMaterial->getStress(); + int numData = 1; + // set output + if (OPS_SetDoubleOutput(&numData, &stress, true) < 0) { + opserr << "failed to get stress\n"; + return -1; + } + } + else if (testType == 2) { + const Vector& stress = theTestingNDMaterial->getStress(); + int numData = stress.Size(); + // convert to double + double* data = new double[numData]; + for (int i = 0; i < numData; i++) + data[i] = stress(i); + // set output + if (OPS_SetDoubleOutput(&numData, data, true) < 0) { + opserr << "failed to get stress\n"; + return -1; + } + delete[] data; + } + else if (testType == 3) { + const Vector& stress = theTestingSection->getStressResultant(); + int numData = stress.Size(); + // convert to double + double* data = new double[numData]; + for (int i = 0; i < numData; i++) + data[i] = stress(i); + // set output + if (OPS_SetDoubleOutput(&numData, data, true) < 0) { + opserr << "failed to get stress\n"; + return -1; + } + delete[] data; } return 0; @@ -237,19 +301,55 @@ int OPS_getStress() int OPS_getTangent() { - UniaxialMaterial* material = theTestingUniaxialMaterial; - if (material == 0) { - opserr << "getStrain WARNING no active UniaxialMaterial - use testUniaxialMaterial command.\n"; + // switch for test type + if (testType == 0) { + opserr << "getTangent WARNING no active test\n"; return -1; } - - double tangent = material->getTangent(); - - int numData = 1; - - if (OPS_SetDoubleOutput(&numData, &tangent, true) < 0) { - opserr << "failed to set tangent\n"; - return -1; + else if (testType == 1) { + double tangent = theTestingUniaxialMaterial->getTangent(); + int numData = 1; + // set output + if (OPS_SetDoubleOutput(&numData, &tangent, true) < 0) { + opserr << "failed to get tangent\n"; + return -1; + } + } + else if (testType == 2) { + const Matrix& tangent = theTestingNDMaterial->getTangent(); + int numData = tangent.noCols() * tangent.noRows(); + // convert to double + double* data = new double[numData]; + int k = 0; + for (int i = 0; i < tangent.noRows(); i++) + for (int j = 0; j < tangent.noCols(); j++) { + data[k] = tangent(i, j); + k++; + } + // set output + if (OPS_SetDoubleOutput(&numData, data, true) < 0) { + opserr << "failed to get tangent\n"; + return -1; + } + delete[] data; + } + else if (testType == 3) { + const Matrix& tangent = theTestingSection->getSectionTangent(); + int numData = tangent.noCols() * tangent.noRows(); + // convert to double + double* data = new double[numData]; + int k = 0; + for (int i = 0; i < tangent.noRows(); i++) + for (int j = 0; j < tangent.noCols(); j++) { + data[k] = tangent(i, j); + k++; + } + // set output + if (OPS_SetDoubleOutput(&numData, data, true) < 0) { + opserr << "failed to get tangent\n"; + return -1; + } + delete[] data; } return 0; @@ -257,19 +357,24 @@ int OPS_getTangent() int OPS_getDampTangent() { - UniaxialMaterial* material = theTestingUniaxialMaterial; - if (material == 0) { - opserr << "getStrain WARNING no active UniaxialMaterial - use testUniaxialMaterial command.\n"; + // switch for test type + if (testType == 0) { + opserr << "getDampTangent WARNING no active test\n"; return -1; } - - double tangent = material->getDampTangent(); - - int numData = 1; - - if (OPS_SetDoubleOutput(&numData, &tangent, true) < 0) { - opserr << "failed to set damp tangent\n"; - return -1; + else if (testType == 1) { + double dampTangent = theTestingUniaxialMaterial->getDampTangent(); + int numData = 1; + if (OPS_SetDoubleOutput(&numData, &dampTangent, true) < 0) { + opserr << "failed to get damping tangent\n"; + return -1; + } + } + else if (testType == 2) { + opserr << "damping tangent not implemented for nDMaterials\n"; + } + else if (testType == 3) { + opserr << "damping tangent not implemented for sections\n"; } return 0; From 2acc27bcd53207444fcf5e2aec9a24d51de43c08 Mon Sep 17 00:00:00 2001 From: ambaker1 Date: Sun, 18 Apr 2021 22:43:36 -0400 Subject: [PATCH 012/193] Moved file to SRC/interpreter Maybe better suited here. Need to figure out how the interpreter cpp files add commands to Tcl. (they currently don't) --- .../OpenSeesMaterialTestCommands.cpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename SRC/{material/MaterialTest.cpp => interpreter/OpenSeesMaterialTestCommands.cpp} (100%) diff --git a/SRC/material/MaterialTest.cpp b/SRC/interpreter/OpenSeesMaterialTestCommands.cpp similarity index 100% rename from SRC/material/MaterialTest.cpp rename to SRC/interpreter/OpenSeesMaterialTestCommands.cpp From 4954ba2371c74cb7bde341445fad77a0d353be69 Mon Sep 17 00:00:00 2001 From: Seweryn Kokot Date: Tue, 27 Apr 2021 09:54:22 +0200 Subject: [PATCH 013/193] fix commands.cpp due to CRLF issue - stage 1 --- SRC/tcl/commands.cpp | 20779 +++++++++++++++++++++-------------------- 1 file changed, 10482 insertions(+), 10297 deletions(-) diff --git a/SRC/tcl/commands.cpp b/SRC/tcl/commands.cpp index 35ae786b0..d22be31f9 100644 --- a/SRC/tcl/commands.cpp +++ b/SRC/tcl/commands.cpp @@ -1,10297 +1,10482 @@ -/* ****************************************************************** ** -** OpenSees System for Earthquake Engineering Simulation ** -** Pacific Earthquake Engineering Research Center ** -** ** -** ** -** (C) Copyright 1999, The Regents of the University of California ** -** All Rights Reserved. ** -** ** -** Commercial use of this program without express permission of the ** -** University of California, Berkeley, is strictly prohibited. See ** -** file 'COPYRIGHT' in main directory for information on usage and ** -** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. ** -** ** -** Developed by: ** -** Frank McKenna (fmckenna@ce.berkeley.edu) ** -** Gregory L. Fenves (fenves@ce.berkeley.edu) ** -** Filip C. Filippou (filippou@ce.berkeley.edu) ** -** ** -** ****************************************************************** */ - -// $Revision$ -// $Date$ -// $URL$ - - -// Written: fmk -// Created: 04/98 -// -// Description: This file contains the functions that will be called by -// the interpreter when the appropriate command name is specified, -// see tkAppInit.C for command names. - -#include - -#include - -#ifdef _PARALLEL_PROCESSING -#include -#elif _PARALLEL_INTERPRETERS -#include -#endif - -extern "C" { -#include -} - -#include -#include -#include - -extern void OPS_clearAllUniaxialMaterial(void); -extern void OPS_clearAllNDMaterial(void); -extern void OPS_clearAllSectionForceDeformation(void); - -extern void OPS_clearAllHystereticBackbone(void); -extern void OPS_clearAllStiffnessDegradation(void); -extern void OPS_clearAllStrengthDegradation(void); -extern void OPS_clearAllUnloadingRule(void); - -// the following is a little kludgy but it works! -#ifdef _USING_STL_STREAMS - -#include -using std::ios; -#include -using std::ofstream; - -#else - -#include -#include -#include - -bool OPS_suppressOpenSeesOutput = false; -StandardStream sserr; -OPS_Stream *opserrPtr = &sserr; - -#endif - - -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include "commands.h" - -// domain - #ifdef _PARALLEL_PROCESSING -#include -#else -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include //Joey UC Davis -#include //Joey UC Davis -#include -#include -#include -#include -#include - -// analysis model -#include - -// convergence tests -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// soln algorithms -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// accelerators -#include -#include -#include -#include -#include -#include -//#include - -// line searches -#include -#include -#include -#include - -// constraint handlers -#include -#include -//#include -#include -#include - -// numberers -#include -#include - -// integrators -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include //Abbas - -// recorders -#include //SAJalali - -extern void *OPS_NewtonRaphsonAlgorithm(void); -extern void *OPS_ModifiedNewton(void); -extern void *OPS_NewtonHallM(void); - -extern void *OPS_Newmark(void); -extern void *OPS_StagedNewmark(void); -extern void *OPS_GimmeMCK(void); -extern void *OPS_AlphaOS(void); -extern void *OPS_AlphaOS_TP(void); -extern void *OPS_AlphaOSGeneralized(void); -extern void *OPS_AlphaOSGeneralized_TP(void); -extern void *OPS_CentralDifference(void); -extern void *OPS_CentralDifferenceAlternative(void); -extern void *OPS_CentralDifferenceNoDamping(void); -extern void *OPS_Collocation(void); -extern void *OPS_CollocationHSFixedNumIter(void); -extern void *OPS_CollocationHSIncrLimit(void); -extern void *OPS_CollocationHSIncrReduct(void); -extern void *OPS_GeneralizedAlpha(void); -extern void *OPS_HHT(void); -extern void *OPS_HHT_TP(void); -extern void *OPS_HHTExplicit(void); -extern void *OPS_HHTExplicit_TP(void); -extern void *OPS_HHTGeneralized(void); -extern void *OPS_HHTGeneralized_TP(void); -extern void *OPS_HHTGeneralizedExplicit(void); -extern void *OPS_HHTGeneralizedExplicit_TP(void); -extern void *OPS_HHTHSFixedNumIter(void); -extern void *OPS_HHTHSFixedNumIter_TP(void); -extern void *OPS_HHTHSIncrLimit(void); -extern void *OPS_HHTHSIncrLimit_TP(void); -extern void *OPS_HHTHSIncrReduct(void); -extern void *OPS_HHTHSIncrReduct_TP(void); -extern void *OPS_KRAlphaExplicit(void); -extern void *OPS_KRAlphaExplicit_TP(void); -extern void *OPS_NewmarkExplicit(void); -extern void *OPS_NewmarkHSFixedNumIter(void); -extern void *OPS_NewmarkHSIncrLimit(void); -extern void *OPS_NewmarkHSIncrReduct(void); -extern void *OPS_WilsonTheta(void); - -// for response spectrum analysis -extern void OPS_DomainModalProperties(void); -extern void OPS_ResponseSpectrumAnalysis(void); - -#include -#include -#include -#include -#include -#include -#include -#include - -// analysis -#include -#include -#include -#include - -// system of eqn and solvers -#include -#include - -#include -#include - -#include - -#ifdef _ITPACK -//#include -//#include -#endif - -#include -#include - -#include -#include -#include -#include - -#include -#include - -// #include -// #include -// #include -// #include - -#include -#include -#include -#include -#include -#include -#ifdef _MUMPS -#include -#include -#endif - -#ifdef _THREADS -#include -#else -#include -#endif - -#ifdef _CUSP -#include -#endif - -#ifdef _CULAS4 -#include -#endif - -#ifdef _CULAS5 -#include -#endif - -#ifdef _MUMPS -#ifdef _PARALLEL_PROCESSING -#include -#include -#elif _PARALLEL_INTERPRETERS -#include -#include -#else -#include -#include -#endif -#endif - -#ifdef _PETSC -#include -#include -#include -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _CUDA -#include -#include -#endif - - -// graph -#include -#include - -#include -#include - -#ifdef _NOGRAPHICS - -#else -#include -#endif - -#include - -#ifdef _RELIABILITY -// AddingSensitivity:BEGIN ///////////////////////////////////////////////// -#include -#include -// #include -// #include -//#include -// #include -// #include -// #include -// #include -//#include -//#include -//#include -//#include -// AddingSensitivity:END ///////////////////////////////////////////////// -#include - -int reliability(ClientData, Tcl_Interp *, int, TCL_Char **); -int wipeReliability(ClientData, Tcl_Interp *, int, TCL_Char **); -int optimization(ClientData, Tcl_Interp *, int, TCL_Char **); //Quan (2) - -#endif - -const char * getInterpPWD(Tcl_Interp *interp); - -#include - - -#include - -ModelBuilder *theBuilder =0; - -// some global variables -#ifdef _PARALLEL_PROCESSING - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// parallel analysis -#include -#include -#include - -// parallel soe & solvers -#include -#include -#include -#include -#include -#include - -#define MPIPP_H -#include -#include - -//MachineBroker *theMachineBroker = 0; -PartitionedDomain theDomain; -int OPS_PARALLEL_PROCESSING =0; -int OPS_NUM_SUBDOMAINS =0; -bool OPS_PARTITIONED =false; -bool OPS_USING_MAIN_DOMAIN = false; -int OPS_MAIN_DOMAIN_PARTITION_ID =0; - -DomainPartitioner *OPS_DOMAIN_PARTITIONER =0; -GraphPartitioner *OPS_GRAPH_PARTITIONER =0; -LoadBalancer *OPS_BALANCER = 0; -FEM_ObjectBroker *OPS_OBJECT_BROKER =0; -MachineBroker *OPS_MACHINE =0; -Channel **OPS_theChannels = 0; - -bool setMPIDSOEFlag = false; - -#elif _PARALLEL_INTERPRETERS - -bool setMPIDSOEFlag = false; - -// parallel analysis -#include -#include - -// parallel soe & solvers -#include -#include -#include - - -#include -#include -#include -#include -#include -#define MPIPP_H -#include -#include - -Domain theDomain; - -#else - -Domain theDomain; - -#endif - -#include - -MachineBroker *theMachineBroker =0; -Channel **theChannels =0; -int numChannels =0; -int OPS_rank =0; -int OPS_np =0; - - -typedef struct parameterValues { - char *value; - struct parameterValues *next; -} OpenSeesTcl_ParameterValues; - - -typedef struct parameter { - char *name; - OpenSeesTcl_ParameterValues *values; - struct parameter *next; -} OpenSeesTcl_Parameter; - - -static OpenSeesTcl_Parameter *theParameters = NULL; -static OpenSeesTcl_Parameter *endParameters = NULL; - -static int numParam = 0; -static char **paramNames =0; -static char **paramValues =0; - -AnalysisModel *theAnalysisModel =0; -EquiSolnAlgo *theAlgorithm =0; -ConstraintHandler *theHandler =0; -DOF_Numberer *theNumberer =0; -LinearSOE *theSOE =0; -EigenSOE *theEigenSOE =0; -StaticAnalysis *theStaticAnalysis = 0; -DirectIntegrationAnalysis *theTransientAnalysis = 0; -VariableTimeStepDirectIntegrationAnalysis *theVariableTimeStepTransientAnalysis = 0; -int numEigen = 0; - -static PFEMAnalysis* thePFEMAnalysis = 0; - -// AddingSensitivity:BEGIN ///////////////////////////////////////////// -#ifdef _RELIABILITY -static TclReliabilityBuilder *theReliabilityBuilder = 0; - -Integrator *theSensitivityAlgorithm = 0; -Integrator *theSensitivityIntegrator = 0; -//FMK RELIABILITY ReliabilityStaticAnalysis *theReliabilityStaticAnalysis = 0; -//FMK RELIABILITY ReliabilityDirectIntegrationAnalysis *theReliabilityTransientAnalysis = 0; - -// static NewmarkSensitivityIntegrator *theNSI = 0; -// static NewNewmarkSensitivityIntegrator *theNNSI = 0; -// static PFEMSensitivityIntegrator* thePFEMSI = 0; - -//static SensitivityIntegrator *theSensitivityIntegrator = 0; -//static NewmarkSensitivityIntegrator *theNSI = 0; - -#include -static TclOptimizationBuilder *theOptimizationBuilder = 0; // Quan March 2010 (3) - -#endif -// AddingSensitivity:END /////////////////////////////////////////////// - - -StaticIntegrator *theStaticIntegrator =0; -TransientIntegrator *theTransientIntegrator =0; -ConvergenceTest *theTest =0; -bool builtModel = false; - -static char *resDataPtr = 0; -static int resDataSize = 0; -static Timer *theTimer = 0; - -#include -#include -SimulationInformation simulationInfo; -SimulationInformation *theSimulationInfoPtr = 0; - -char *simulationInfoOutputFilename = 0; - - -FE_Datastore *theDatabase =0; -FEM_ObjectBrokerAllClasses theBroker; - -// init the global variabled defined in OPS_Globals.h -// double ops_Dt = 1.0; -// Element *ops_TheActiveElement = 0; -// bool ops_InitialStateAnalysis = false; // McGann, U.Washington - -#ifdef _NOGRAPHICS - -#else -TclVideoPlayer *theTclVideoPlayer =0; -#endif - -// g3AppInit() is the method called by tkAppInit() when the -// interpreter is being set up .. this is where all the -// commands defined in this file are registered with the interpreter. - - -int -printModelGID(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -int -printA(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -int -printB(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -int -setPrecision(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -int -logFile(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -int -version(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -int -getPID(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -int -getNP(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -int -opsBarrier(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -int -domainChange(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -int -record(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -int -opsSend(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -int -opsRecv(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -int -opsPartition(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - - -int -peerNGA(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -int -defaultUnits(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -int -stripOpenSeesXML(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -int -setParameter(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -//extern -int OpenSeesExit(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -extern int myCommands(Tcl_Interp *interp); - -//extern "C" int Tcl_InterpObjCmd(ClientData clientData, -// Tcl_Interp *interp, -// int objc, -// Tcl_Obj *const objv[]); - -int -convertBinaryToText(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -int -convertTextToBinary(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - -int -maxOpenFiles(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv); - - - -// pointer for old putsCommand - -static Tcl_ObjCmdProc *Tcl_putsCommand = 0; - -// -// revised puts command to send to cerr! -// - -int OpenSees_putsCommand(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) -{ - Tcl_Channel chan; /* The channel to puts on. */ - Tcl_Obj *string; /* String to write. */ - Tcl_Obj *chanObjPtr = NULL; /* channel object. */ - int newline; /* Add a newline at end? */ - - switch (objc) { - case 2: /* [puts $x] */ - string = objv[1]; - newline = 1; - break; - - case 3: /* [puts -nonewline $x] or [puts $chan $x] */ - if (strcmp(Tcl_GetString(objv[1]), "-nonewline") == 0) { - newline = 0; - } else { - newline = 1; - chanObjPtr = objv[1]; - } - string = objv[2]; - break; - - case 4: /* [puts -nonewline $chan $x] or [puts $chan $x nonewline] */ - newline = 0; - if (strcmp(Tcl_GetString(objv[1]), "-nonewline") == 0) { - chanObjPtr = objv[2]; - string = objv[3]; - break; - } else if (strcmp(Tcl_GetString(objv[3]), "nonewline") == 0) { - /* - * The code below provides backwards compatibility with an old - * form of the command that is no longer recommended or - * documented. See also [Bug #3151675]. Will be removed in Tcl 9, - * maybe even earlier. - */ - - chanObjPtr = objv[1]; - string = objv[2]; - break; - } - /* Fall through */ - default: - /* [puts] or [puts some bad number of arguments...] */ - Tcl_WrongNumArgs(interp, 1, objv, "?-nonewline? ?channelId? string"); - return TCL_ERROR; - } - - if (chanObjPtr == NULL) { - if (newline == 0) - opserr << Tcl_GetString(string); - else - opserr << Tcl_GetString(string) << endln; - return TCL_OK; - } else { - if (Tcl_putsCommand != 0) { - return Tcl_putsCommand(dummy, interp, objc, objv); - } else { - std::cerr << "MEARD! commands.cpp .. old puts command not found or set!\n"; - return TCL_ERROR; - } - return TCL_OK; - } -} - - -int Tcl_InterpOpenSeesObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) -{ - int index; - static TCL_Char *options[] = { - "alias", "aliases", "create", "delete", - "eval", "exists", "expose", "hide", - "hidden", "issafe", "invokehidden", "marktrusted", - "recursionlimit", "slaves", "share", - "target", "transfer", - NULL - }; - enum option { - OPT_ALIAS, OPT_ALIASES, OPT_CREATE, OPT_DELETE, - OPT_EVAL, OPT_EXISTS, OPT_EXPOSE, OPT_HIDE, - OPT_HIDDEN, OPT_ISSAFE, OPT_INVOKEHID, OPT_MARKTRUSTED, - OPT_RECLIMIT, OPT_SLAVES, OPT_SHARE, - OPT_TARGET, OPT_TRANSFER - }; - - int ok = TCL_OK; - //int ok = Tcl_InterpObjCmd(clientData, interp, objc, objv); - //if (ok != TCL_OK) - //return ok; - - if (Tcl_GetIndexFromObj(interp, objv[1], options, "option", 0, &index) != TCL_OK) { - return TCL_ERROR; - } - - switch ((enum option) index) { - case OPT_CREATE: { - TCL_Char *theInterpreterName = Tcl_GetStringResult(interp); - Tcl_Interp *secondaryInterp = Tcl_GetSlave(interp, theInterpreterName); - ok = OpenSeesAppInit(secondaryInterp); - return ok; - break; - } - default: - return ok; - } - - return ok; -} - - -int OpenSeesAppInit(Tcl_Interp *interp) { - - ops_TheActiveDomain = &theDomain; - - // - // redo puts command so we can capture puts into std:cerr - // - - if (OPS_suppressOpenSeesOutput == false) { - // get a handle on puts procedure - Tcl_CmdInfo putsCommandInfo; - Tcl_GetCommandInfo(interp, "puts", &putsCommandInfo); - Tcl_putsCommand = putsCommandInfo.objProc; - // if handle, use ouur procedure as opposed to theirs - if (Tcl_putsCommand != 0) { - Tcl_CreateObjCommand(interp, "oldputs", Tcl_putsCommand, NULL, NULL); - Tcl_CreateObjCommand(interp, "puts", OpenSees_putsCommand, NULL, NULL); - } - } - - theSimulationInfoPtr = &simulationInfo; - -#ifndef _LINUX - opserr.setFloatField(SCIENTIFIC); - opserr.setFloatField(FIXEDD); -#endif - - //Tcl_CreateObjCommand(interp, "interp", Tcl_InterpOpenSeesObjCmd, NULL, NULL); - - Tcl_CreateCommand(interp, "recorderValue", &OPS_recorderValue, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); //by SAJalali - - Tcl_CreateObjCommand(interp, "pset", &OPS_SetObjCmd, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - - Tcl_CreateObjCommand(interp, "source", &OPS_SourceCmd, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - - Tcl_CreateCommand(interp, "wipe", &wipeModel, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - - Tcl_CreateCommand(interp, "wipeAnalysis", &wipeAnalysis, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "reset", &resetModel, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - - Tcl_CreateCommand(interp, "initialize", &initializeAnalysis, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "loadConst", &setLoadConst, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - - Tcl_CreateCommand(interp, "setCreep", &setCreep, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "setTime", &setTime, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "getTime", &getTime, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "getLoadFactor", &getLoadFactor, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - - Tcl_CreateCommand(interp, "build", &buildModel, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "analyze", &analyzeModel, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "print", &printModel, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "printModel", &printModel, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "printA", &printA, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "printB", &printB, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - // Talledo Start - Tcl_CreateCommand(interp, "printGID", &printModelGID, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - // Talledo End - Tcl_CreateCommand(interp, "analysis", &specifyAnalysis, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "system", &specifySOE, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "numberer", &specifyNumberer, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "constraints", &specifyConstraintHandler, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "algorithm", &specifyAlgorithm, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "test", &specifyCTest, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "testNorms", &getCTestNorms, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "testIter", &getCTestIter, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - - Tcl_CreateCommand(interp, "integrator", &specifyIntegrator, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "recorder", &addRecorder, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "algorithmRecorder", &addAlgoRecorder, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "database", &addDatabase, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "eigen", &eigenAnalysis, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "modalProperties", &modalProperties, - (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); - Tcl_CreateCommand(interp, "responseSpectrum", &responseSpectrum, - (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); - Tcl_CreateCommand(interp, "video", &videoPlayer, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "remove", &removeObject, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - - Tcl_CreateCommand(interp, "eleForce", &eleForce, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "localForce", &localForce, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "eleDynamicalForce", &eleDynamicalForce, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "eleResponse", &eleResponse, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "nodeDisp", &nodeDisp, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "setNodeDisp", &setNodeDisp, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "nodeReaction", &nodeReaction, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "nodeUnbalance", &nodeUnbalance, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "nodeEigenvector", &nodeEigenvector, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "nodeVel", &nodeVel, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "setNodeVel", &setNodeVel, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "nodeAccel", &nodeAccel, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "setNodeAccel", &setNodeAccel, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "nodeResponse", &nodeResponse, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "reactions", &calculateNodalReactions, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "nodeDOFs", &nodeDOFs, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "nodeCoord", &nodeCoord, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "setNodeCoord", &setNodeCoord, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "updateElementDomain", &updateElementDomain, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "eleNodes", &eleNodes, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "nodeMass", &nodeMass, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "nodePressure", &nodePressure, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "nodeBounds", &nodeBounds, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "start", &startTimer, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "stop", &stopTimer, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "rayleigh", &rayleighDamping, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "modalDamping", &modalDamping, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "modalDampingQ", &modalDampingQ, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "setElementRayleighDampingFactors", - &setElementRayleighDampingFactors, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "region", &addRegion, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "logFile", &logFile, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "setPrecision", &setPrecision, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "exit", &OpenSeesExit, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "quit", &OpenSeesExit, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "findNodeWithID", &findID, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - - Tcl_CreateCommand(interp, "getNP", &getNP, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "getPID", &getPID, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "barrier", &opsBarrier, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "send", &opsSend, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "recv", &opsRecv, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "partition", &opsPartition, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "searchPeerNGA", &peerNGA, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - - Tcl_CreateCommand(interp, "domainChange", &domainChange,(ClientData)NULL, NULL); - - Tcl_CreateCommand(interp, "record", &record,(ClientData)NULL, NULL); - - Tcl_CreateCommand(interp, "defaultUnits", &defaultUnits,(ClientData)NULL, NULL); - Tcl_CreateCommand(interp, "stripXML", &stripOpenSeesXML,(ClientData)NULL, NULL); - Tcl_CreateCommand(interp, "convertBinaryToText", &convertBinaryToText,(ClientData)NULL, NULL); - Tcl_CreateCommand(interp, "convertTextToBinary", &convertTextToBinary,(ClientData)NULL, NULL); - - Tcl_CreateCommand(interp, "getEleTags", &getEleTags, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "getNodeTags", &getNodeTags, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "getParamTags", &getParamTags, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "getParamValue", &getParamValue, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - - Tcl_CreateCommand(interp, "getNumElements", &getNumElements, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "getEleClassTags", &getEleClassTags, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "getEleLoadClassTags", &getEleLoadClassTags, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "getEleLoadTags", &getEleLoadTags, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "getEleLoadData", &getEleLoadData, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - - Tcl_CreateCommand(interp, "sdfResponse", &sdfResponse, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - - Tcl_CreateCommand(interp, "sectionForce", §ionForce, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "sectionDeformation", §ionDeformation, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "sectionStiffness", §ionStiffness, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "sectionFlexibility", §ionFlexibility, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "sectionLocation", §ionLocation, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "sectionWeight", §ionWeight, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "basicDeformation", &basicDeformation, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "basicForce", &basicForce, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "basicStiffness", &basicStiffness, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - - // command added for initial state analysis for nDMaterials - // Chris McGann, U.Washington - Tcl_CreateCommand(interp, "InitialStateAnalysis", &InitialStateAnalysis, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - - Tcl_CreateCommand(interp, "totalCPU", &totalCPU, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "solveCPU", &solveCPU, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "accelCPU", &accelCPU, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "numFact", &numFact, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "numIter", &numIter, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "systemSize", &systemSize, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "version", &version, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - - Tcl_CreateCommand(interp, "setParameter", &setParameter, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - - Tcl_CreateCommand(interp, "setMaxOpenFiles", &maxOpenFiles, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - -#ifdef _RELIABILITY - Tcl_CreateCommand(interp, "wipeReliability", wipeReliability, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "reliability", reliability, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - theReliabilityBuilder = 0; -// AddingSensitivity:BEGIN ////////////////////////////////// - Tcl_CreateCommand(interp, "computeGradients", &computeGradients, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "sensitivityAlgorithm", &sensitivityAlgorithm, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "sensitivityIntegrator", &sensitivityIntegrator, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "sensNodeDisp", &sensNodeDisp, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "sensLambda", &sensLambda, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); //Abbas - Tcl_CreateCommand(interp, "sensNodeVel", &sensNodeVel, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "sensNodeAccel", &sensNodeAccel, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "sensSectionForce", &sensSectionForce, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - Tcl_CreateCommand(interp, "sensNodePressure", &sensNodePressure, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - - - theSensitivityAlgorithm =0; - theSensitivityIntegrator =0; - //FMK RELIABILITY theReliabilityStaticAnalysis =0; - //FMK RELIABILITY theReliabilityTransientAnalysis =0; - // AddingSensitivity:END ////////////////////////////////// - - theOptimizationBuilder = 0; - - // --- Quan March 2010 (4) - Tcl_CreateCommand(interp, "optimization", &optimization, - (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); -#endif - - theAlgorithm =0; - theHandler =0; - theNumberer =0; - theAnalysisModel =0; - theSOE =0; - theStaticIntegrator =0; - theTransientIntegrator =0; - theStaticAnalysis =0; - theTransientAnalysis =0; - theVariableTimeStepTransientAnalysis =0; - theTest = 0; - - // create an error handler - -#ifdef _NOGRAPHICS - -#else - theTclVideoPlayer = 0; -#endif - - return myCommands(interp); -} - - - -int -OPS_SetObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[]) -{ - - if (objc > 2) - simulationInfo.addParameter(Tcl_GetString(objv[1]), Tcl_GetString(objv[2])); - - Tcl_Obj *varValueObj; - - if (objc == 2) { - varValueObj = Tcl_ObjGetVar2(interp, objv[1], NULL,TCL_LEAVE_ERR_MSG); - if (varValueObj == NULL) { - return TCL_ERROR; - } - Tcl_SetObjResult(interp, varValueObj); - return TCL_OK; - } else if (objc == 3) { - varValueObj = Tcl_ObjSetVar2(interp, objv[1], NULL, objv[2], - TCL_LEAVE_ERR_MSG); - if (varValueObj == NULL) { - return TCL_ERROR; - } - Tcl_SetObjResult(interp, varValueObj); - return TCL_OK; - } else { - Tcl_WrongNumArgs(interp, 1, objv, "varName ?newValue?"); - return TCL_ERROR; - } - - // Tcl_SetObjCmd(clientData, interp, objc, objv); - return 0; -} - -int -OPS_SourceCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int objc, /* Number of arguments. */ - Tcl_Obj *CONST objv[]) /* Argument objects. */ -{ - CONST char *encodingName = NULL; - Tcl_Obj *fileName; - - if (objc != 2 && objc !=4) { - Tcl_WrongNumArgs(interp, 1, objv, "?-encoding name? fileName"); - return TCL_ERROR; - } - - fileName = objv[objc-1]; - - if (objc == 4) { - static CONST char *options[] = { - "-encoding", NULL - }; - int index; - - if (TCL_ERROR == Tcl_GetIndexFromObj(interp, objv[1], options, - "option", TCL_EXACT, &index)) { - return TCL_ERROR; - } - encodingName = Tcl_GetString(objv[2]); - } - - const char *pwd = getInterpPWD(interp); - const char *fileN = Tcl_GetString(fileName); - - simulationInfo.addInputFile(fileN, pwd); - -#ifndef _TCL85 - return Tcl_EvalFile(interp, fileN); -#else - return Tcl_FSEvalFileEx(interp, fileName, encodingName); -#endif -} - -#ifdef _RELIABILITY - -// -- optimization Quan March 2010 (5) -int -optimization(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - - if (theOptimizationBuilder == 0) { - - theOptimizationBuilder = new TclOptimizationBuilder(theDomain , interp); - - - return TCL_OK; - } - else - return TCL_ERROR; -} - - -int -reliability(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - if (theReliabilityBuilder == 0) { - - theReliabilityBuilder = new TclReliabilityBuilder(theDomain,interp); - return TCL_OK; - } - else - return TCL_ERROR; -} - - - - -int -wipeReliability(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - if (theReliabilityBuilder != 0) { - delete theReliabilityBuilder; - theReliabilityBuilder = 0; - } - return TCL_OK; - -} - -int -sensitivityIntegrator(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - // Does nothing, but keeping command for backward compatibility - return TCL_OK; -} - -int -sensitivityAlgorithm(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - bool withRespectToRVs = true; - bool newalgorithm = false; - int analysisTypeTag = 1; - if(theStaticIntegrator != 0) { - theSensitivityIntegrator = theStaticIntegrator; - } else if(theTransientIntegrator != 0) { - theSensitivityIntegrator = theTransientIntegrator; - } - // 1: compute at each step (default); 2: compute by command - - if (argc < 2) { - opserr << "ERROR: Wrong number of parameters to sensitivity algorithm." << endln; - return TCL_ERROR; - } - if (theReliabilityBuilder == 0) { - opserr << "The command 'reliability' needs to be issued before " << endln - << " the sensitivity algorithm can be created." << endln; - return TCL_ERROR; - } - else if (theSensitivityIntegrator == 0) { - opserr << "The sensitivity integrator needs to be instantiated before " << endln - << " the sensitivity algorithm can be created." << endln; - return TCL_ERROR; - } - - if (strcmp(argv[1],"-computeAtEachStep") == 0) - analysisTypeTag = 1; - else if (strcmp(argv[1],"-computeByCommand") == 0) - analysisTypeTag = 2; - else { - opserr << "Unknown sensitivity algorithm option: " << argv[1] << endln; - return TCL_ERROR; - } - - ReliabilityDomain *theReliabilityDomain; - theReliabilityDomain = theReliabilityBuilder->getReliabilityDomain(); - if(newalgorithm){ - // theSensitivityAlgorithm = new - // NewSensitivityAlgorithm(theReliabilityDomain, - // &theDomain, - // theAlgorithm, - // theSensitivityIntegrator, - // analysisTypeTag); - } else { - // theSensitivityAlgorithm = new - // SensitivityAlgorithm(&theDomain, - // theAlgorithm, - // theSensitivityIntegrator, - // analysisTypeTag); - - - IncrementalIntegrator *theIntegrator = 0; - - if (theStaticAnalysis != 0 && theStaticIntegrator != 0) { - theIntegrator = theStaticIntegrator; - - theIntegrator->setComputeType(analysisTypeTag); - theIntegrator->activateSensitivityKey(); - - } else if (theTransientAnalysis != 0 && theTransientIntegrator != 0) { - - theIntegrator = theTransientIntegrator; - theIntegrator->setComputeType(analysisTypeTag); - theIntegrator->activateSensitivityKey(); - - } - - if (theIntegrator == 0) { - opserr << "ERROR: Could not create theSensitivityAlgorithm. " << endln; - return TCL_ERROR; - } - // ---- by Quan 2009 for recover the previous framework --- - - if (theIntegrator->shouldComputeAtEachStep()) { - - //if (theStaticAnalysis !=0) - //theStaticAnalysis->setSensitivityAlgorithm(theIntegrator); - //else if (theTransientAnalysis !=0) - //theTransientAnalysis->setSensitivityAlgorithm(theIntegrator); - //else if (theVariableTimeStepTransientAnalysis !=0) - //theVariableTimeStepTransientAnalysis->setSensitivityAlgorithm(theIntegrator); - // else { - // // do nothing - // } - - - } - } - - return TCL_OK; -} - -// AddingSensitivity:END ///////////////////////////////////////////////// - -#endif - - -int -wipeModel(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - wipeAnalysis(clientData, interp, argc, argv); - - /* - // to build the model make sure the ModelBuilder has been constructed - // and that the model has not already been constructed - if (theBuilder != 0) { - delete theBuilder; - builtModel = false; - theBuilder = 0; - } - - if (theStaticAnalysis != 0) { - theStaticAnalysis->clearAll(); - delete theStaticAnalysis; - } - - if (theTransientAnalysis != 0) { - theTransientAnalysis->clearAll(); - delete theTransientAnalysis; - } - */ - - // NOTE : DON'T do the above on theVariableTimeStepAnalysis - // as it and theTansientAnalysis are one in the same - if (theDatabase != 0) - delete theDatabase; - - theDomain.clearAll(); - OPS_clearAllUniaxialMaterial(); - OPS_clearAllNDMaterial(); - OPS_clearAllSectionForceDeformation(); - - OPS_clearAllHystereticBackbone(); - OPS_clearAllStiffnessDegradation(); - OPS_clearAllStrengthDegradation(); - OPS_clearAllUnloadingRule(); - - ops_Dt = 0.0; - - -#ifdef _PARALLEL_PROCESSING - OPS_PARTITIONED = false; -#endif - -#ifdef _NOGRAPHICS - -#else - if (theTclVideoPlayer != 0) { - delete theTclVideoPlayer; - theTclVideoPlayer = 0; - } -#endif - - theAlgorithm =0; - theHandler =0; - theNumberer =0; - theAnalysisModel =0; - theSOE =0; - theStaticIntegrator =0; - theTransientIntegrator =0; - theStaticAnalysis =0; - theTransientAnalysis =0; - theVariableTimeStepTransientAnalysis =0; - - theTest = 0; - theDatabase = 0; - -// AddingSensitivity:BEGIN ///////////////////////////////////////////////// -#ifdef _RELIABILITY - //theSensitivityAlgorithm =0; - theSensitivityIntegrator =0; -#endif -// AddingSensitivity:END ///////////////////////////////////////////////// - - // the domain deletes the record objects, - // just have to delete the private array - return TCL_OK; -} - -int -wipeAnalysis(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - -#ifdef _PARALLEL_PROCESSING - if (OPS_PARTITIONED == true && OPS_NUM_SUBDOMAINS > 1) { - SubdomainIter &theSubdomains = theDomain.getSubdomains(); - Subdomain *theSub =0; - - // create the appropriate domain decomposition analysis - while ((theSub = theSubdomains()) != 0) - theSub->wipeAnalysis(); - } -#endif - - if (theStaticAnalysis != 0) { - theStaticAnalysis->clearAll(); - delete theStaticAnalysis; - } - - if (theTransientAnalysis != 0) { - theTransientAnalysis->clearAll(); - delete theTransientAnalysis; - } - - // NOTE : DON'T do the above on theVariableTimeStepAnalysis - // as it and theTansientAnalysis are one in the same - - theAlgorithm =0; - theHandler =0; - theNumberer =0; - theAnalysisModel =0; - theSOE =0; - theEigenSOE =0; - theStaticIntegrator =0; - theTransientIntegrator =0; - theStaticAnalysis =0; - theTransientAnalysis =0; - theVariableTimeStepTransientAnalysis =0; - // theSensitivityAlgorithm=0; - thePFEMAnalysis = 0; - theTest = 0; - -// AddingSensitivity:BEGIN ///////////////////////////////////////////////// -#ifdef _RELIABILITY - theSensitivityAlgorithm =0; - theSensitivityIntegrator =0; -#endif -// AddingSensitivity:END ///////////////////////////////////////////////// - // the domain deletes the record objects, - // just have to delete the private array - - return TCL_OK; -} - -// by SAJalali -int OPS_recorderValue(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - // make sure at least one other argument to contain type of system - - // clmnID starts from 1 - if (argc < 3) { - opserr << "WARNING want - recorderValue recorderTag clmnID <-reset>\n"; - return TCL_ERROR; - } - - int tag, rowOffset; - int dof = -1; - - if (Tcl_GetInt(interp, argv[1], &tag) != TCL_OK) { - opserr << "WARNING recorderValue recorderTag? clmnID <-reset> could not read recorderTag \n"; - return TCL_ERROR; - } - - if (Tcl_GetInt(interp, argv[2], &dof) != TCL_OK) { - opserr << "WARNING recorderValue recorderTag? clmnID - could not read clmnID \n"; - return TCL_ERROR; - } - dof--; - rowOffset = 0; - int curArg = 3; - if (argc > curArg) - { - if (Tcl_GetInt(interp, argv[curArg], &rowOffset) != TCL_OK) { - opserr << "WARNING recorderValue recorderTag? clmnID <-reset> could not read rowOffset \n"; - return TCL_ERROR; - } - curArg++; - } - bool reset = false; - if (argc > curArg) - { - if (strcmp(argv[curArg], "-reset") == 0) - reset = true; - curArg++; - } - Recorder* theRecorder = theDomain.getRecorder(tag); - double res = theRecorder->getRecordedValue(dof, rowOffset, reset); - // now we copy the value to the tcl string that is returned - //sprintf(interp->result, "%35.8f ", res); - char buffer [40]; - sprintf(buffer,"%35.8f", res); - Tcl_SetResult(interp, buffer, TCL_VOLATILE); - - return TCL_OK; -} - -int -resetModel(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - theDomain.revertToStart(); - - if (theTransientIntegrator != 0) { - theTransientIntegrator->revertToStart(); - } - - return TCL_OK; -} - -int -initializeAnalysis(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - if (theTransientAnalysis != 0) - theTransientAnalysis->initialize(); - else if (theStaticAnalysis != 0) - theStaticAnalysis->initialize(); - - theDomain.initialize(); - - return TCL_OK; -} - - -int -setLoadConst(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - theDomain.setLoadConstant(); - if (argc == 3) { - if( strcmp(argv[1],"-time") == 0) { - double newTime; - if (Tcl_GetDouble(interp, argv[2], &newTime) != TCL_OK) { - opserr << "WARNING readingvalue - loadConst -time value \n"; - return TCL_ERROR; - } else { - theDomain.setCurrentTime(newTime); - theDomain.setCommittedTime(newTime); - } - } - } - - return TCL_OK; -} - -int -setCreep(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - if (argc < 2) { - opserr << "WARNING illegal command - setCreep value? \n"; - return TCL_ERROR; - } - int newFlag; - if (Tcl_GetInt(interp, argv[1], &newFlag) != TCL_OK) { - opserr << "WARNING reading creep value - setCreep newFlag? \n"; - return TCL_ERROR; - } else { - theDomain.setCreep(newFlag); - } - return TCL_OK; -} - -int -setTime(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - if (argc < 2) { - opserr << "WARNING illegal command - time pseudoTime? \n"; - return TCL_ERROR; - } - double newTime; - if (Tcl_GetDouble(interp, argv[1], &newTime) != TCL_OK) { - opserr << "WARNING reading time value - time pseudoTime? \n"; - return TCL_ERROR; - } else { - theDomain.setCurrentTime(newTime); - theDomain.setCommittedTime(newTime); - } - return TCL_OK; -} - -int -getTime(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - double time = theDomain.getCurrentTime(); - - // get the display format - char format[80]; - if (argc == 1) { - // strcpy(format,"%f"); - sprintf(format,"%f",time); - } else if (argc == 2) { - // strcpy(format,argv[1]); - sprintf(format,argv[1],time); - } - - // now we copy the value to the tcl string that is returned - // sprintf(interp->result,format,time); - Tcl_SetResult(interp, format, TCL_VOLATILE); - return TCL_OK; -} - -int -getLoadFactor(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - if (argc < 2) { - opserr << "WARNING no load pattern supplied -- getLoadFactor\n"; - return TCL_ERROR; - } - - int pattern; - if (Tcl_GetInt(interp, argv[1], &pattern) != TCL_OK) { - opserr << "ERROR reading load pattern tag -- getLoadFactor\n"; - return TCL_ERROR; - } - - LoadPattern *thePattern = theDomain.getLoadPattern(pattern); - if (thePattern == 0) { - opserr << "ERROR load pattern with tag " << pattern << " not found in domain -- getLoadFactor\n"; - return TCL_ERROR; - } - - double factor = thePattern->getLoadFactor(); - - // sprintf(interp->result,"%f",factor); - - char buffer [40]; - sprintf(buffer,"%35.20f", factor); - Tcl_SetResult(interp, buffer, TCL_VOLATILE); - - return TCL_OK; -} - -////////////////////////////////////////////////Abbas////////////////////////////// - -int -sensLambda(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv ) -{ - if (argc < 3) { - opserr << "WARNING no load pattern supplied -- getLoadFactor\n"; - return TCL_ERROR; - } - - int pattern, paramTag; - if (Tcl_GetInt(interp, argv[1], &pattern) != TCL_OK) { - opserr << "ERROR reading load pattern tag -- getLoadFactor\n"; - return TCL_ERROR; - } - - LoadPattern *thePattern = theDomain.getLoadPattern(pattern); - if (thePattern == 0) { - opserr << "ERROR load pattern with tag " << pattern << " not found in domain -- getLoadFactor\n"; - return TCL_ERROR; - } - if (Tcl_GetInt(interp, argv[2], ¶mTag) != TCL_OK) { - opserr << "WARNING sensLambda patternTag? paramTag?- could not read paramTag? "; - return TCL_ERROR; - } - Parameter *theParam = theDomain.getParameter(paramTag); - if (theParam == 0) { - opserr << "sensLambda: parameter " << paramTag << " not found" << endln; - return TCL_ERROR; - } - - IncrementalIntegrator *theIntegrator = 0; - - if (theStaticAnalysis != 0 && theStaticIntegrator != 0) { - theIntegrator = theStaticIntegrator; - // opserr<<" commands.cpp: calling static integrator"<getGradIndex(); - // double factor = thePattern->getSensLambda(theIntegrator); - //double factor = theIntegrator->dLambdadh(gradIndex); - double factor = thePattern->getLoadFactorSensitivity(gradIndex); - - char buffer[40]; - sprintf(buffer,"%35.20f",factor); - - Tcl_SetResult(interp, buffer, TCL_VOLATILE); - - return TCL_OK; -} - - - -//////////////////////////////////////////////Abbas/////////////////////////////////////// - - -// command invoked to build the model, i.e. to invoke buildFE_Model() -// on the ModelBuilder - -int -buildModel(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - // to build the model make sure the ModelBuilder has been constructed - // and that the model has not already been constructed - if (theBuilder != 0 && builtModel == false) { - builtModel = true; - return theBuilder->buildFE_Model(); - } else if (theBuilder != 0 && builtModel == true) { - opserr << "WARNING Model has already been built - not built again \n"; - return TCL_ERROR; - } - else { - opserr << "WARNING No ModelBuilder type has been specified \n"; - return TCL_ERROR; - } -} - - - - -#ifdef _PARALLEL_PROCESSING - -int -partitionModel(int eleTag) -{ - if (OPS_PARTITIONED == true) - return 0; - - int result = 0; - - if (OPS_theChannels != 0) - delete [] OPS_theChannels; - - OPS_theChannels = new Channel *[OPS_NUM_SUBDOMAINS]; - - // create some subdomains - for (int i=1; i<=OPS_NUM_SUBDOMAINS; i++) { - if (i != OPS_MAIN_DOMAIN_PARTITION_ID) { - ShadowSubdomain *theSubdomain = new ShadowSubdomain(i, *OPS_MACHINE, *OPS_OBJECT_BROKER); - theDomain.addSubdomain(theSubdomain); - OPS_theChannels[i-1] = theSubdomain->getChannelPtr(); - } - } - - // create a partitioner & partition the domain - if (OPS_DOMAIN_PARTITIONER == 0) { - // OPS_BALANCER = new ShedHeaviest(); - OPS_GRAPH_PARTITIONER = new Metis; - //OPS_DOMAIN_PARTITIONER = new DomainPartitioner(*OPS_GRAPH_PARTITIONER, *OPS_BALANCER); - OPS_DOMAIN_PARTITIONER = new DomainPartitioner(*OPS_GRAPH_PARTITIONER); - theDomain.setPartitioner(OPS_DOMAIN_PARTITIONER); - } - - // opserr << "commands.cpp - partition numPartitions: " << OPS_NUM_SUBDOMAINS << endln; - - result = theDomain.partition(OPS_NUM_SUBDOMAINS, OPS_USING_MAIN_DOMAIN, OPS_MAIN_DOMAIN_PARTITION_ID, eleTag); - - if (result < 0) - return result; - - OPS_PARTITIONED = true; - - DomainDecompositionAnalysis *theSubAnalysis; - SubdomainIter &theSubdomains = theDomain.getSubdomains(); - Subdomain *theSub =0; - - // create the appropriate domain decomposition analysis - while ((theSub = theSubdomains()) != 0) { - if (theStaticAnalysis != 0) { - theSubAnalysis = new StaticDomainDecompositionAnalysis(*theSub, - *theHandler, - *theNumberer, - *theAnalysisModel, - *theAlgorithm, - *theSOE, - *theStaticIntegrator, - theTest, - false); - - } else { - theSubAnalysis = new TransientDomainDecompositionAnalysis(*theSub, - *theHandler, - *theNumberer, - *theAnalysisModel, - *theAlgorithm, - *theSOE, - *theTransientIntegrator, - theTest, - false); - } - theSub->setDomainDecompAnalysis(*theSubAnalysis); - // delete theSubAnalysis; - } - - return result; -} - -#endif - - -int -opsPartition(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ -#ifdef _PARALLEL_PROCESSING - int eleTag; - if (argc == 2) { - if (Tcl_GetInt(interp, argv[1], &eleTag) != TCL_OK) { - ; - } - } - partitionModel(eleTag); -#endif - return TCL_OK; -} - -// -// command invoked to build the model, i.e. to invoke analyze() -// on the Analysis object -// -int -analyzeModel(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - int result = 0; - -#ifdef _PARALLEL_PROCESSING - if (OPS_PARTITIONED == false && OPS_NUM_SUBDOMAINS > 1) { - if (partitionModel(0) < 0) { - opserr << "WARNING before analysis; partition failed - too few elements\n"; - OpenSeesExit(clientData, interp, argc, argv); - return TCL_ERROR; - } - } -#endif - - if (theStaticAnalysis != 0) { - if (argc < 2) { - opserr << "WARNING static analysis: analysis numIncr?\n"; - return TCL_ERROR; - } - int numIncr; - - if (Tcl_GetInt(interp, argv[1], &numIncr) != TCL_OK) - return TCL_ERROR; - - result = theStaticAnalysis->analyze(numIncr); - - } else if(thePFEMAnalysis != 0) { - result = thePFEMAnalysis->analyze(); - - } else if (theTransientAnalysis != 0) { - if (argc < 3) { - opserr << "WARNING transient analysis: analysis numIncr? deltaT?\n"; - return TCL_ERROR; - } - int numIncr; - if (Tcl_GetInt(interp, argv[1], &numIncr) != TCL_OK) - return TCL_ERROR; - double dT; - if (Tcl_GetDouble(interp, argv[2], &dT) != TCL_OK) - return TCL_ERROR; - - // Set global timestep variable - ops_Dt = dT; - - if (argc == 6) { - int Jd; - double dtMin, dtMax; - if (Tcl_GetDouble(interp, argv[3], &dtMin) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[4], &dtMax) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[5], &Jd) != TCL_OK) - return TCL_ERROR; - - if (theVariableTimeStepTransientAnalysis != 0) - result = theVariableTimeStepTransientAnalysis->analyze(numIncr, dT, dtMin, dtMax, Jd); - else { - opserr << "WARNING analyze - no variable time step transient analysis object constructed\n"; - return TCL_ERROR; - } - - } else { - result = theTransientAnalysis->analyze(numIncr, dT); - } - - } else { - opserr << "WARNING No Analysis type has been specified \n"; - return TCL_ERROR; - } - - if (result < 0) { - opserr << "OpenSees > analyze failed, returned: " << result << " error flag\n"; - } - - char buffer [10]; - sprintf(buffer,"%d", result); - Tcl_SetResult(interp, buffer, TCL_VOLATILE); - - // sprintf(interp->result,"%d",result); - - return TCL_OK; - -} - -int -printElement(ClientData clientData, Tcl_Interp *interp, int argc, - TCL_Char **argv, OPS_Stream &output); - - -int -printNode(ClientData clientData, Tcl_Interp *interp, int argc, - TCL_Char **argv, OPS_Stream &output); - -int -printIntegrator(ClientData clientData, Tcl_Interp *interp, int argc, - TCL_Char **argv, OPS_Stream &output); - -int -printAlgorithm(ClientData clientData, Tcl_Interp *interp, int argc, - TCL_Char **argv, OPS_Stream &output); - - -int -printModel(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - int currentArg = 1; - int res = 0; - - int flag = OPS_PRINT_CURRENTSTATE; - - FileStream outputFile; - OPS_Stream *output = &opserr; - bool done = false; - - // if just 'print' then print out the entire domain - if (argc == currentArg) { - opserr << theDomain; - return TCL_OK; - } - - while(done == false) { - // if 'print ele i j k..' print out some elements - if ((strcmp(argv[currentArg],"-ele") == 0) || (strcmp(argv[currentArg],"ele") == 0)) { - currentArg++; - res = printElement(clientData, interp, argc-currentArg, argv+currentArg, *output); - done = true; - } - // if 'print node i j k ..' print out some nodes - else if ((strcmp(argv[currentArg],"-node") == 0) || (strcmp(argv[currentArg],"node") == 0)) { - currentArg++; - res = printNode(clientData, interp, argc-currentArg, argv+currentArg, *output); - done = true; - } - - // if 'print integrator flag' print out the integrator - else if ((strcmp(argv[currentArg],"integrator") == 0) || - (strcmp(argv[currentArg],"-integrator") == 0)) { - currentArg++; - res = printIntegrator(clientData, interp, argc-currentArg, argv+currentArg, *output); - done = true; - } - - // if 'print algorithm flag' print out the algorithm - else if ((strcmp(argv[currentArg],"algorithm") == 0) || - (strcmp(argv[currentArg],"-algorithm") == 0)) { - currentArg++; - res = printAlgorithm(clientData, interp, argc-currentArg, argv+currentArg, *output); - done = true; - } - - else if ((strcmp(argv[currentArg],"-JSON") == 0)) { - currentArg++; - flag = OPS_PRINT_PRINTMODEL_JSON; - } - - else { - - if ((strcmp(argv[currentArg],"file") == 0) || - (strcmp(argv[currentArg],"-file") == 0)) - currentArg++; - - openMode mode = APPEND; - if (flag == OPS_PRINT_PRINTMODEL_JSON) - mode = OVERWRITE; - if (outputFile.setFile(argv[currentArg], mode) != 0) { - opserr << "print .. - failed to open file: " << argv[currentArg] << endln; - return TCL_ERROR; - } - currentArg++; - - // if just 'print ' then print out the entire domain to eof - if (argc == currentArg) { - if (flag == OPS_PRINT_PRINTMODEL_JSON) - simulationInfo.Print(outputFile, flag); - - theDomain.Print(outputFile, flag); - return TCL_OK; - } - - output = &outputFile; - - } - } - - // close the output file - outputFile.close(); - return res; -} - - - -// printNode(): -// function to print out the nodal information conatined in line -// print node -// input: nodeArg: integer equal to arg count to node plus 1 -// output: output stream to which the results are sent -// -int -printNode(ClientData clientData, Tcl_Interp *interp, int argc, - TCL_Char **argv, OPS_Stream &output) -{ - int flag = 0; // default flag sent to a nodes Print() method - int nodeArg = 0; - - // if just 'print node' print all the nodes - no flag - if (argc == 0) { - NodeIter &theNodes = theDomain.getNodes(); - Node *theNode; - while ((theNode = theNodes()) != 0) - theNode->Print(output); - return TCL_OK; - } - - // if 'print node flag int ' get the flag - if ((strcmp(argv[0],"flag") == 0) || - (strcmp(argv[0],"-flag") == 0)) { - // get the specified flag - if (argc <= nodeArg) { - opserr << "WARNING print node no int specified \n"; - return TCL_ERROR; - } - if (Tcl_GetInt(interp, argv[1], &flag) != TCL_OK) { - opserr << "WARNING print node failed to get integer flag: \n"; - opserr << argv[nodeArg] << endln; - return TCL_ERROR; - } - nodeArg += 2; - } - - // now print the nodes with the specified flag, 0 by default - - // if 'print node flag' - // print out all the nodes in the domain with flag - if (nodeArg == argc) { - NodeIter &theNodes = theDomain.getNodes(); - Node *theNode; - while ((theNode = theNodes()) != 0) - theNode->Print(output, flag); - return TCL_OK; - } else { - // otherwise print out the specified nodes i j k .. with flag - int numNodes = argc-nodeArg; - ID *theNodes = new ID(numNodes); - for (int i= 0; i node' print all the nodes - no flag - if (argc == 0) { - ElementIter &theElements = theDomain.getElements(); - Element *theElement; - while ((theElement = theElements()) != 0) - theElement->Print(output); - return TCL_OK; - } - - // if 'print Element flag int ' get the flag - if ((strcmp(argv[0],"flag") == 0) || - (strcmp(argv[0],"-flag")) == 0) { // get the specified flag - if (argc < 2) { - opserr << "WARNING print ele no int specified \n"; - return TCL_ERROR; - } - if (Tcl_GetInt(interp, argv[1], &flag) != TCL_OK) { - opserr << "WARNING print ele failed to get integer flag: \n"; - opserr << argv[eleArg] << endln; - return TCL_ERROR; - } - eleArg += 2; - } - - // now print the Elements with the specified flag, 0 by default - if (argc == eleArg) { - ElementIter &theElements = theDomain.getElements(); - Element *theElement; - while ((theElement = theElements()) != 0) - theElement->Print(output, flag); - return TCL_OK; - } else { - - // otherwise print out the specified nodes i j k .. with flag - int numEle = argc-eleArg; - ID *theEle = new ID(numEle); - for (int i= 0; i algorithm'- no flag - if (argc == 0) { - theAlgorithm->Print(output); - return TCL_OK; - } - - // if 'print Algorithm flag' get the flag - int flag; - if (Tcl_GetInt(interp, argv[eleArg], &flag) != TCL_OK) { - opserr << "WARNING print algorithm failed to get integer flag: \n"; - opserr << argv[eleArg] << endln; - return TCL_ERROR; - } - theAlgorithm->Print(output,flag); - return TCL_OK; -} - - -int -printIntegrator(ClientData clientData, Tcl_Interp *interp, int argc, - TCL_Char **argv, OPS_Stream &output) -{ - int eleArg = 0; - if (theStaticIntegrator == 0 && theTransientIntegrator == 0) - return TCL_OK; - - IncrementalIntegrator *theIntegrator; - if (theStaticIntegrator != 0) - theIntegrator = theStaticIntegrator; - else - theIntegrator = theTransientIntegrator; - - // if just 'print algorithm'- no flag - if (argc == 0) { - theIntegrator->Print(output); - return TCL_OK; - } - - // if 'print Algorithm flag' get the flag - int flag; - if (Tcl_GetInt(interp, argv[eleArg], &flag) != TCL_OK) { - opserr << "WARNING print algorithm failed to get integer flag: \n"; - opserr << argv[eleArg] << endln; - return TCL_ERROR; - } - theIntegrator->Print(output,flag); - return TCL_OK; -} - - -int -printA(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - int res = 0; - - FileStream outputFile; - OPS_Stream *output = &opserr; - - int currentArg = 1; - - if (argc > 2) { - if ((strcmp(argv[currentArg],"file") == 0) || - (strcmp(argv[currentArg],"-file") == 0)) { - currentArg++; - - if (outputFile.setFile(argv[currentArg]) != 0) { - opserr << "print .. - failed to open file: " << argv[currentArg] << endln; - return TCL_ERROR; - } - output = &outputFile; - } - } - if (theSOE != 0) { - if (theStaticIntegrator != 0) - theStaticIntegrator->formTangent(); - else if (theTransientIntegrator != 0) - theTransientIntegrator->formTangent(0); - - const Matrix *A = theSOE->getA(); - if (A != 0) { - *output << *A; - } - } - - // close the output file - outputFile.close(); - - return res; -} - -int -printB(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - int res = 0; - - FileStream outputFile; - OPS_Stream *output = &opserr; - // bool done = false; - - int currentArg = 1; - - if (argc > 2) { - if ((strcmp(argv[currentArg],"file") == 0) || - (strcmp(argv[currentArg],"-file") == 0)) { - currentArg++; - - if (outputFile.setFile(argv[currentArg]) != 0) { - opserr << "print .. - failed to open file: " << argv[currentArg] << endln; - return TCL_ERROR; - } - output = &outputFile; - } - } - if (theSOE != 0) { - if (theStaticIntegrator != 0) - theStaticIntegrator->formUnbalance(); - else if (theTransientIntegrator != 0) - theTransientIntegrator->formUnbalance(); - - const Vector &b = theSOE->getB(); - *output << b; - } - - // close the output file - outputFile.close(); - - return res; -} - -// -// command invoked to allow the Analysis object to be built -// -int -specifyAnalysis(ClientData clientData, Tcl_Interp *interp, int argc, - TCL_Char **argv) -{ - // make sure at least one other argument to contain type of system - if (argc < 2) { - opserr << "WARNING need to specify an analysis type (Static, Transient)\n"; - return TCL_ERROR; - } - - // - // do nothing if request is for the same analysis type! - // - - if ((strcmp(argv[1],"Static") == 0) && (theStaticAnalysis != 0)) - return TCL_OK; - - if (((strcmp(argv[1],"VariableTimeStepTransient") == 0) || - (strcmp(argv[1],"TransientWithVariableTimeStep") == 0) || - (strcmp(argv[1],"VariableTransient") == 0)) && - (theVariableTimeStepTransientAnalysis != 0)) - return TCL_OK; - - if ((strcmp(argv[1],"Transient") == 0) && (theTransientAnalysis != 0)) - return TCL_OK; - - // - // analysis changing .. delete the old analysis - // - - if (theStaticAnalysis != 0) { - delete theStaticAnalysis; - theStaticAnalysis = 0; - opserr << "WARNING: analysis .. StaticAnalysis already exists => wipeAnalysis not invoked, problems may arise\n"; - } - - if (theTransientAnalysis != 0) { - delete theTransientAnalysis; - theTransientAnalysis = 0; - theVariableTimeStepTransientAnalysis = 0; - opserr << "WARNING: analysis .. TransientAnalysis already exists => wipeAnalysis not invoked, problems may arise\n"; - } - - // check argv[1] for type of SOE and create it - if (strcmp(argv[1],"Static") == 0) { - // make sure all the components have been built, - // otherwise print a warning and use some defaults - if (theAnalysisModel == 0) - theAnalysisModel = new AnalysisModel(); - - if (theTest == 0) - theTest = new CTestNormUnbalance(1.0e-6,25,0); - - if (theAlgorithm == 0) { - opserr << "WARNING analysis Static - no Algorithm yet specified, \n"; - opserr << " NewtonRaphson default will be used\n"; - - theAlgorithm = new NewtonRaphson(*theTest); - } - if (theHandler == 0) { - opserr << "WARNING analysis Static - no ConstraintHandler yet specified, \n"; - opserr << " PlainHandler default will be used\n"; - theHandler = new PlainHandler(); - } - if (theNumberer == 0) { - opserr << "WARNING analysis Static - no Numberer specified, \n"; - opserr << " RCM default will be used\n"; - RCM *theRCM = new RCM(false); - theNumberer = new DOF_Numberer(*theRCM); - } - if (theStaticIntegrator == 0) { - opserr << "WARNING analysis Static - no Integrator specified, \n"; - opserr << " StaticIntegrator default will be used\n"; - theStaticIntegrator = new LoadControl(1, 1, 1, 1); - } - if (theSOE == 0) { - opserr << "WARNING analysis Static - no LinearSOE specified, \n"; - opserr << " ProfileSPDLinSOE default will be used\n"; - ProfileSPDLinSolver *theSolver; - theSolver = new ProfileSPDLinDirectSolver(); -#ifdef _PARALLEL_PROCESSING - theSOE = new DistributedProfileSPDLinSOE(*theSolver); -#else - theSOE = new ProfileSPDLinSOE(*theSolver); -#endif - } - - theStaticAnalysis = new StaticAnalysis(theDomain, - *theHandler, - *theNumberer, - *theAnalysisModel, - *theAlgorithm, - *theSOE, - *theStaticIntegrator, - theTest); - - #ifdef _PARALLEL_INTERPRETERS - if (setMPIDSOEFlag) { - ((MPIDiagonalSOE*) theSOE)->setAnalysisModel(*theAnalysisModel); - } -#endif - -// AddingSensitivity:BEGIN /////////////////////////////// -#ifdef _RELIABILITY - if (theSensitivityAlgorithm != 0 && theSensitivityAlgorithm->shouldComputeAtEachStep()) { - //theStaticAnalysis->setSensitivityAlgorithm(theSensitivityAlgorithm); - } -#endif -// AddingSensitivity:END ///////////////////////////////// - } else if(strcmp(argv[1], "PFEM") == 0) { - - if(argc < 5) { - opserr<<"WARNING: wrong no of args -- analysis PFEM dtmax dtmin gravity \n"; - return TCL_ERROR; - } - double dtmax, dtmin, gravity, ratio=0.5; - if(Tcl_GetDouble(interp, argv[2], &dtmax) != TCL_OK) { - opserr<<"WARNING: invalid dtmax "< 5) { - if(Tcl_GetDouble(interp, argv[5], &ratio) != TCL_OK) { - opserr<<"WARNING: invalid ratio "<setAnalysisModel(*theAnalysisModel); - } -#endif - -// AddingSensitivity:BEGIN /////////////////////////////// -#ifdef _RELIABILITY - if (theSensitivityAlgorithm != 0 && theSensitivityAlgorithm->shouldComputeAtEachStep()) { - - /* This if-statement cannot possibly stay in the code -- MHS - if(theSensitivityAlgorithm->newAlgorithm()){ - opserr << "WARNING original sensitivity algorothm needs to be specified \n"; - opserr << "for static analysis \n"; - return TCL_ERROR; - } - */ - - //theTransientAnalysis->setSensitivityAlgorithm(theSensitivityAlgorithm); - } -#endif -// AddingSensitivity:END ///////////////////////////////// - - } else if ((strcmp(argv[1],"VariableTimeStepTransient") == 0) || - (strcmp(argv[1],"TransientWithVariableTimeStep") == 0) || - (strcmp(argv[1],"VariableTransient") == 0)) { - // make sure all the components have been built, - // otherwise print a warning and use some defaults - if (theAnalysisModel == 0) - theAnalysisModel = new AnalysisModel(); - - if (theTest == 0) - theTest = new CTestNormUnbalance(1.0e-6,25,0); - - if (theAlgorithm == 0) { - opserr << "WARNING analysis Transient - no Algorithm yet specified, \n"; - opserr << " NewtonRaphson default will be used\n"; - theAlgorithm = new NewtonRaphson(*theTest); - } - - if (theHandler == 0) { - opserr << "WARNING analysis Transient dt tFinal - no ConstraintHandler\n"; - opserr << " yet specified, PlainHandler default will be used\n"; - theHandler = new PlainHandler(); - } - - if (theNumberer == 0) { - opserr << "WARNING analysis Transient dt tFinal - no Numberer specified, \n"; - opserr << " RCM default will be used\n"; - RCM *theRCM = new RCM(false); - theNumberer = new DOF_Numberer(*theRCM); - } - - if (theTransientIntegrator == 0) { - opserr << "WARNING analysis Transient dt tFinal - no Integrator specified, \n"; - opserr << " Newmark(.5,.25) default will be used\n"; - theTransientIntegrator = new Newmark(0.5,0.25); - } - - if (theSOE == 0) { - opserr << "WARNING analysis Transient dt tFinal - no LinearSOE specified, \n"; - opserr << " ProfileSPDLinSOE default will be used\n"; - ProfileSPDLinSolver *theSolver; - theSolver = new ProfileSPDLinDirectSolver(); -#ifdef _PARALLEL_PROCESSING - theSOE = new DistributedProfileSPDLinSOE(*theSolver); -#else - theSOE = new ProfileSPDLinSOE(*theSolver); -#endif - } - - theVariableTimeStepTransientAnalysis = new VariableTimeStepDirectIntegrationAnalysis - (theDomain, - *theHandler, - *theNumberer, - *theAnalysisModel, - *theAlgorithm, - *theSOE, - *theTransientIntegrator, - theTest); - - // set the pointer for variabble time step analysis - theTransientAnalysis = theVariableTimeStepTransientAnalysis; - - #ifdef _RELIABILITY - - ////////////////////////////////// - ////// added by K Fujimura /////// - - //FMK RELIABILITY - /* - } else if (strcmp(argv[1],"ReliabilityStatic") == 0) { - // make sure all the components have been built, - // otherwise print a warning and use some defaults - if (theAnalysisModel == 0) - theAnalysisModel = new AnalysisModel(); - if (theTest == 0) - theTest = new CTestNormUnbalance(1.0e-6,25,0); - if (theAlgorithm == 0) { - opserr << "WARNING analysis Static - no Algorithm yet specified, \n"; - opserr << " NewtonRaphson default will be used\n"; - theAlgorithm = new NewtonRaphson(*theTest); } - if (theHandler == 0) { - opserr << "WARNING analysis Static - no ConstraintHandler yet specified, \n"; - opserr << " PlainHandler default will be used\n"; - theHandler = new PlainHandler(); } - if (theNumberer == 0) { - opserr << "WARNING analysis Static - no Numberer specified, \n"; - opserr << " RCM default will be used\n"; - RCM *theRCM = new RCM(false); - theNumberer = new DOF_Numberer(*theRCM); } - if (theStaticIntegrator == 0) { - opserr << "Fatal ! theStaticIntegrator must be defined before defining\n"; - opserr << "ReliabilityStaticAnalysis by NewStaticSensitivity\n"; - return TCL_ERROR; - } - if (theSOE == 0) { - opserr << "WARNING analysis Static - no LinearSOE specified, \n"; - opserr << " ProfileSPDLinSOE default will be used\n"; - ProfileSPDLinSolver *theSolver; - theSolver = new ProfileSPDLinDirectSolver(); - theSOE = new ProfileSPDLinSOE(*theSolver); } - - theReliabilityStaticAnalysis = new ReliabilityStaticAnalysis(theDomain, - *theHandler, - *theNumberer, - *theAnalysisModel, - *theAlgorithm, - *theSOE, - *theStaticIntegrator, - theTest); - - if (theSensitivityAlgorithm != 0 && theSensitivityAlgorithm->shouldComputeAtEachStep()) { - - //This if-statement cannot stay -- MHS - //if(!theSensitivityAlgorithm->newAlgorithm()){ - // opserr << "WARNING new sensitivity algorothm needs to be specified \n"; - // opserr << "for reliability static analysis \n"; - // return TCL_ERROR; - //} - - - //theStaticAnalysis->setSensitivityAlgorithm(theSensitivityAlgorithm); - } else { - opserr << "Faltal SensitivityAlgorithm must be definde before defining \n"; - opserr << "ReliabilityStaticAnalysis with computeateachstep\n"; - return TCL_ERROR; - } - - } else if (strcmp(argv[1],"ReliabilityTransient") == 0) { - // make sure all the components have been built, - // otherwise print a warning and use some defaults - if (theAnalysisModel == 0) - theAnalysisModel = new AnalysisModel(); - if (theTest == 0) - theTest = new CTestNormUnbalance(1.0e-6,25,0); - if (theAlgorithm == 0) { - opserr << "WARNING analysis Transient - no Algorithm yet specified, \n"; - opserr << " NewtonRaphson default will be used\n"; - theAlgorithm = new NewtonRaphson(*theTest); - } - if (theHandler == 0) { - opserr << "WARNING analysis Transient dt tFinal - no ConstraintHandler\n"; - opserr << " yet specified, PlainHandler default will be used\n"; - theHandler = new PlainHandler(); - } - if (theNumberer == 0) { - opserr << "WARNING analysis Transient dt tFinal - no Numberer specified, \n"; - opserr << " RCM default will be used\n"; - RCM *theRCM = new RCM(false); - theNumberer = new DOF_Numberer(*theRCM); - } - if (theTransientIntegrator == 0) { - opserr << "Fatal ! theTransientIntegrator must be defined before defining\n"; - opserr << "ReliabilityTransientAnalysis by NewNewmarkWithSensitivity\n"; - return TCL_ERROR; - } - if (theSOE == 0) { - opserr << "WARNING analysis Transient dt tFinal - no LinearSOE specified, \n"; - opserr << " ProfileSPDLinSOE default will be used\n"; - ProfileSPDLinSolver *theSolver; - theSolver = new ProfileSPDLinDirectSolver(); - theSOE = new ProfileSPDLinSOE(*theSolver); - } - - theReliabilityTransientAnalysis = new ReliabilityDirectIntegrationAnalysis(theDomain, - *theHandler, - *theNumberer, - *theAnalysisModel, - *theAlgorithm, - *theSOE, - *theTransientIntegrator, - theTest); - - if (theSensitivityAlgorithm != 0 && theSensitivityAlgorithm->shouldComputeAtEachStep()) { - - //This if-statement must go -- MHS - //if(!theSensitivityAlgorithm->newAlgorithm()){ - // opserr << "WARNING new sensitivity algorothm needs to be specified \n"; - // opserr << "for reliability static analysis \n"; - // return TCL_ERROR; - //} - - - theReliabilityTransientAnalysis->setSensitivityAlgorithm(theSensitivityAlgorithm); - }else{ - opserr << "Faltal SensitivityAlgorithm must be definde before defining \n"; - opserr << "ReliabilityStaticAnalysis with computeateachstep\n"; - return TCL_ERROR; - } - FMK RELIABILITY - *************************/ -// AddingSensitivity:END ///////////////////////////////// -#endif - - } else { - opserr << "WARNING No Analysis type exists (Static Transient only) \n"; - return TCL_ERROR; - } - - -#ifdef _PARALLEL_PROCESSING - if (OPS_PARTITIONED == true && OPS_NUM_SUBDOMAINS > 1) { - DomainDecompositionAnalysis *theSubAnalysis; - SubdomainIter &theSubdomains = theDomain.getSubdomains(); - Subdomain *theSub =0; - // create the appropriate domain decomposition analysis - while ((theSub = theSubdomains()) != 0) { - if (theStaticAnalysis != 0) { - theSubAnalysis = new StaticDomainDecompositionAnalysis(*theSub, - *theHandler, - *theNumberer, - *theAnalysisModel, - *theAlgorithm, - *theSOE, - *theStaticIntegrator, - theTest, - false); - - } else { - theSubAnalysis = new TransientDomainDecompositionAnalysis(*theSub, - *theHandler, - *theNumberer, - *theAnalysisModel, - *theAlgorithm, - *theSOE, - *theTransientIntegrator, - theTest, - false); - } - - theSub->setDomainDecompAnalysis(*theSubAnalysis); - // delete theSubAnalysis; - } - } -#endif - - if (theEigenSOE != 0) { - if (theStaticAnalysis != 0) { - theStaticAnalysis->setEigenSOE(*theEigenSOE); - } else if (theTransientAnalysis != 0) { - theTransientAnalysis->setEigenSOE(*theEigenSOE); - } - } - - - return TCL_OK; -} - - -typedef struct externalClassFunction { - char *funcName; - void *(*funcPtr)(); - struct externalClassFunction *next; -} ExternalClassFunction; - -static ExternalClassFunction *theExternalSolverCommands = NULL; -static ExternalClassFunction *theExternalStaticIntegratorCommands = NULL; -static ExternalClassFunction *theExternalTransientIntegratorCommands = NULL; -static ExternalClassFunction *theExternalAlgorithmCommands = NULL; - -int -specifySOE(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - // make sure at least one other argument to contain type of system - if (argc < 2) { - opserr << "WARNING need to specify a model type \n"; - return TCL_ERROR; - } - - // check argv[1] for type of SOE and create it - // BAND GENERAL SOE & SOLVER - if ((strcmp(argv[1],"BandGeneral") == 0) || (strcmp(argv[1],"BandGEN") == 0) - || (strcmp(argv[1],"BandGen") == 0)){ - BandGenLinSolver *theSolver = new BandGenLinLapackSolver(); -#ifdef _PARALLEL_PROCESSING - theSOE = new DistributedBandGenLinSOE(*theSolver); -#else - theSOE = new BandGenLinSOE(*theSolver); -#endif - } - -#ifdef _CUDA - else if ((strcmp(argv[1],"BandGeneral_Single") == 0) || (strcmp(argv[1],"BandGEN_Single") == 0) - || (strcmp(argv[1],"BandGen_Single") == 0)){ - BandGenLinLapackSolver_Single *theSolver = new BandGenLinLapackSolver_Single(); - theSOE = new BandGenLinSOE_Single(*theSolver); - } -#endif - - // BAND SPD SOE & SOLVER - else if (strcmp(argv[1],"BandSPD") == 0) { - BandSPDLinSolver *theSolver = new BandSPDLinLapackSolver(); -#ifdef _PARALLEL_PROCESSING - theSOE = new DistributedBandSPDLinSOE(*theSolver); -#else - theSOE = new BandSPDLinSOE(*theSolver); -#endif - - } - - // Diagonal SOE & SOLVER - else if (strcmp(argv[1],"Diagonal") == 0) { -#ifdef _PARALLEL_PROCESSING - DistributedDiagonalSolver *theSolver = new DistributedDiagonalSolver(); - theSOE = new DistributedDiagonalSOE(*theSolver); -#else - DiagonalSolver *theSolver = new DiagonalDirectSolver(); - theSOE = new DiagonalSOE(*theSolver); -#endif - - - } - // Diagonal SOE & SOLVER - else if (strcmp(argv[1],"MPIDiagonal") == 0) { -#ifdef _PARALLEL_INTERPRETERS - MPIDiagonalSolver *theSolver = new MPIDiagonalSolver(); - theSOE = new MPIDiagonalSOE(*theSolver); - setMPIDSOEFlag = true; -#else - DiagonalSolver *theSolver = new DiagonalDirectSolver(); - theSOE = new DiagonalSOE(*theSolver); -#endif - } - - - // PROFILE SPD SOE * SOLVER - else if (strcmp(argv[1],"SProfileSPD") == 0) { - // now must determine the type of solver to create from rest of args - SProfileSPDLinSolver *theSolver = new SProfileSPDLinSolver(); - theSOE = new SProfileSPDLinSOE(*theSolver); - } - - else if (strcmp(argv[1],"ProfileSPD") == 0) { - // now must determine the type of solver to create from rest of args - ProfileSPDLinSolver *theSolver = new ProfileSPDLinDirectSolver(); - - /* *********** Some misc solvers i play with ****************** - else if (strcmp(argv[2],"Normal") == 0) { - theSolver = new ProfileSPDLinDirectSolver(); - } - - else if (strcmp(argv[2],"Block") == 0) { - int blockSize = 4; - if (argc == 4) { - if (Tcl_GetInt(interp, argv[3], &blockSize) != TCL_OK) - return TCL_ERROR; - } - theSolver = theSolver = new ProfileSPDLinDirectBlockSolver(1.0e-12,blockSize); - } - - - int blockSize = 4; - int numThreads = 1; - if (argc == 5) { - if (Tcl_GetInt(interp, argv[3], &blockSize) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[4], &numThreads) != TCL_OK) - return TCL_ERROR; - } - theSolver = new ProfileSPDLinDirectThreadSolver(numThreads,blockSize,1.0e-12); - } else if (strcmp(argv[2],"Thread") == 0) { - int blockSize = 4; - int numThreads = 1; - if (argc == 5) { - if (Tcl_GetInt(interp, argv[3], &blockSize) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[4], &numThreads) != TCL_OK) - return TCL_ERROR; - } - theSolver = new ProfileSPDLinDirectThreadSolver(numThreads,blockSize,1.0e-12); - } - else if (strcmp(argv[2],"Skypack") == 0) { - if (argc == 5) { - int mCols, mRows; - if (Tcl_GetInt(interp, argv[3], &mCols) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[4], &mRows) != TCL_OK) - return TCL_ERROR; - theSolver = new ProfileSPDLinDirectSkypackSolver(mCols, mRows); - } else - theSolver = new ProfileSPDLinDirectSkypackSolver(); - } - else - theSolver = new ProfileSPDLinDirectSolver(); - *************************************************************** */ - -#ifdef _PARALLEL_PROCESSING - theSOE = new DistributedProfileSPDLinSOE(*theSolver); -#else - theSOE = new ProfileSPDLinSOE(*theSolver); -#endif - } - -#ifdef _PARALLEL_INTERPRETERS - else if (strcmp(argv[1],"ParallelProfileSPD") == 0) { - ProfileSPDLinSolver *theSolver = new ProfileSPDLinDirectSolver(); - DistributedProfileSPDLinSOE *theParallelSOE = new DistributedProfileSPDLinSOE(*theSolver); - theSOE = theParallelSOE; - theParallelSOE->setProcessID(OPS_rank); - theParallelSOE->setChannels(numChannels, theChannels); - } -#endif - - else if(strcmp(argv[1], "PFEM") == 0) { - if(argc <= 2) { - PFEMSolver* theSolver = new PFEMSolver(); - theSOE = new PFEMLinSOE(*theSolver); - } else if(strcmp(argv[2], "-quasi") == 0) { - PFEMCompressibleSolver* theSolver = new PFEMCompressibleSolver(); - theSOE = new PFEMCompressibleLinSOE(*theSolver); - } else if (strcmp(argv[2],"-mumps") ==0) { -#ifdef _PARALLEL_INTERPRETERS - int relax = 20; - if (argc > 3) { - if (Tcl_GetInt(interp, argv[3], &relax) != TCL_OK) { - opserr<<"WARNING: failed to read relax\n"; - return TCL_ERROR; - } - } - PFEMSolver_Mumps* theSolver = new PFEMSolver_Mumps(relax,0,0,0); - theSOE = new PFEMLinSOE(*theSolver); -#endif - } else if (strcmp(argv[2],"-quasi-mumps")==0) { -#ifdef _PARALLEL_INTERPRETERS - int relax = 20; - if (argc > 3) { - if (Tcl_GetInt(interp, argv[3], &relax) != TCL_OK) { - opserr<<"WARNING: failed to read relax\n"; - return TCL_ERROR; - } - } - PFEMCompressibleSolver_Mumps* theSolver = new PFEMCompressibleSolver_Mumps(relax,0,0); - theSOE = new PFEMCompressibleLinSOE(*theSolver); -#endif - } - } - -#ifdef _CUSP - else if ((_stricmp(argv[1],"CuSP")==0)) { - - - double relTol=1e-6; - int maxInteration=100000; - int preCond=1; //diagonal - int solver=0; //Bicg - int count = 2; - - - while (count < argc) { - - if (_stricmp(argv[count],"-rTol") == 0) { - count++; - if (count < argc) - if (Tcl_GetDouble(interp, argv[count], &relTol) != TCL_OK) - return TCL_ERROR; - } - else if ((_stricmp(argv[count],"-mInt") == 0) ) { - count++; - if (count < argc) - if (Tcl_GetInt(interp, argv[count], &maxInteration) != TCL_OK) - return TCL_ERROR; - } - else if ((_stricmp(argv[count],"-pre") == 0) ) { - count++; - if (count < argc) - if ((_stricmp(argv[count],"none") == 0)) - preCond=0; - else if ((_stricmp(argv[count],"diagonal") == 0)) - preCond=1; - else if ((_stricmp(argv[count],"ainv") == 0)) - preCond=2; - else - return TCL_ERROR; - } else if ((_stricmp(argv[count],"-solver") == 0)) { - count++; - if (count < argc) - if ((_stricmp(argv[count],"bicg") == 0)) - solver=0; - else if ((_stricmp(argv[count],"bicgstab") == 0)) - solver=1; - else if ((_stricmp(argv[count],"cg") == 0)) - solver=2; - else if ((_stricmp(argv[count],"gmres") == 0)) - solver=3; - else - return TCL_ERROR; - } - count++; - } - - CuSPSolver* theSolver = new CuSPSolver(maxInteration,relTol,preCond,solver); - theSOE = new SparseGenRowLinSOE(* theSolver); - - } -#endif - -#if defined(_CULAS4) || defined(_CULAS5) - // CULA SPARSE - else if ((strcmp(argv[1],"CulaSparse")==0)) - { - double absTol = 1.0e-6; - double relTol=1e-6; - - int maxInteration=100000; - - int preCond=5; //fainv -#ifdef _CULAS4 - preCond = 1; -#endif - int solver=0; //cg - int count = 2; - int single=0; - int host=0; - - while (count < argc) { - - if (strcmp(argv[count],"-rTol") == 0) { - count++; - if (count < argc) - if (Tcl_GetDouble(interp, argv[count], &relTol) != TCL_OK) - return TCL_ERROR; - } - else if ((strcmp(argv[count],"-mInt") == 0) ) { - count++; - if (count < argc) - if (Tcl_GetInt(interp, argv[count], &maxInteration) != TCL_OK) - return TCL_ERROR; - } - else if ((strcmp(argv[count],"-pre") == 0) ) { - count++; - if (count < argc) - if ((strcmp(argv[count],"none") == 0)) - preCond=0; - else if ((strcmp(argv[count],"jacobi") == 0)) - preCond=1; - else if ((strcmp(argv[count],"blockjacobi") == 0)) - preCond=2; - else if ((strcmp(argv[count],"ilu0") == 0)) - preCond=3; - else if ((strcmp(argv[count],"ainv") == 0)) - preCond=4; - else if ((strcmp(argv[count],"fainv") == 0)) - preCond=5; - else - return TCL_ERROR; - } else if ((strcmp(argv[count],"-solver") == 0)) { - count++; - if (count < argc) - if ((strcmp(argv[count],"cg") == 0)) - solver=0; - else if ((strcmp(argv[count],"bicg") == 0)) - solver=1; - else if ((strcmp(argv[count],"blockstab") == 0)) - solver=2; - else if ((strcmp(argv[count],"blockstabl") == 0)) - solver=3; - else if ((strcmp(argv[count],"gmres") == 0)) - solver=4; - else if ((strcmp(argv[count],"minres") == 0)) - solver=5; - else - return TCL_ERROR; - } - else if ((strcmp(argv[count],"-single") == 0)) { - single=1; - } - else if ((strcmp(argv[count],"-host") == 0)) { - host=1; - } - count++; - } - -#ifdef _CULAS5 - CulaSparseSolverS5* theSolver = new CulaSparseSolverS5(relTol, - maxInteration, - preCond, - solver, - single, - host); -#else - CulaSparseSolverS4* theSolver = new CulaSparseSolverS4(relTol, - maxInteration, - preCond, - solver); -#endif - - theSOE = new SparseGenRowLinSOE(*theSolver); - - } -#endif - - // SPARSE GENERAL SOE * SOLVER - else if ((strcmp(argv[1],"SparseGeneral") == 0) || (strcmp(argv[1],"SuperLU") == 0) || - (strcmp(argv[1],"SparseGEN") == 0)) { - - SparseGenColLinSolver *theSolver =0; - int count = 2; - double thresh = 0.0; - int npRow = 1; - int npCol = 1; - int np = 1; - - // defaults for threaded SuperLU - - while (count < argc) { - - if ((strcmp(argv[count],"p") == 0) || (strcmp(argv[count],"piv") == 0)|| - (strcmp(argv[count],"-piv") == 0)) { - thresh = 1.0; - } - else if ((strcmp(argv[count],"-np") == 0) || (strcmp(argv[count],"np") == 0)) { - count++; - if (count < argc) - if (Tcl_GetInt(interp, argv[count], &np) != TCL_OK) - return TCL_ERROR; - } - else if ((strcmp(argv[count],"npRow") == 0) || (strcmp(argv[count],"-npRow") ==0)) { - count++; - if (count < argc) - if (Tcl_GetInt(interp, argv[count], &npRow) != TCL_OK) - return TCL_ERROR; - } else if ((strcmp(argv[count],"npCol") == 0) || (strcmp(argv[count],"-npCol") ==0)) { - count++; - if (count < argc) - if (Tcl_GetInt(interp, argv[count], &npCol) != TCL_OK) - return TCL_ERROR; - } - count++; - } - - int permSpec = 0; - int panelSize = 6; - int relax = 6; - - -#ifdef _THREADS - if (np != 0) - theSolver = new ThreadedSuperLU(np, permSpec, panelSize, relax, thresh); -#endif - -#ifdef _PARALLEL_PROCESSING - if (theSolver != 0) - delete theSolver; - theSolver = 0; - - if (npRow != 0 && npCol != 0) { - theSolver = new DistributedSuperLU(npRow, npCol); - opserr << "commands.cpp: DistributedSuperLU\n"; - } -#else - - char symmetric = 'N'; - double drop_tol = 0.0; - - while (count < argc) { - if (strcmp(argv[count],"s") == 0 || strcmp(argv[count],"symmetric") || - strcmp(argv[count],"-symm")) { - symmetric = 'Y'; - } - count++; - } - - theSolver = new SuperLU(permSpec, drop_tol, panelSize, relax, symmetric); - -#endif - -#ifdef _PARALLEL_PROCESSING - opserr << "commands.cpp: DistributedSparseGenColLinSOE\n"; - - theSOE = new DistributedSparseGenColLinSOE(*theSolver); -#else - theSOE = new SparseGenColLinSOE(*theSolver); -#endif - } - - - else if ((strcmp(argv[1],"SparseSPD") == 0) || (strcmp(argv[1],"SparseSYM") == 0)) { - // now must determine the type of solver to create from rest of args - - // now determine ordering scheme - // 1 -- MMD - // 2 -- ND - // 3 -- RCM - int lSparse = 1; - if (argc == 3) { - if (Tcl_GetInt(interp, argv[2], &lSparse) != TCL_OK) - return TCL_ERROR; - } - - SymSparseLinSolver *theSolver = new SymSparseLinSolver(); - theSOE = new SymSparseLinSOE(*theSolver, lSparse); - } - - else if ((strcmp(argv[1],"UmfPack") == 0) || (strcmp(argv[1],"Umfpack") == 0)) { - - // now must determine the type of solver to create from rest of args - int factLVALUE = 10; - int factorOnce=0; - int printTime = 0; - int count = 2; - - while (count < argc) { - if ((strcmp(argv[count],"-lValueFact") == 0) || (strcmp(argv[count],"-lvalueFact") == 0) || (strcmp(argv[count],"-LVALUE") == 0)) { - if (Tcl_GetInt(interp, argv[count+1], &factLVALUE) != TCL_OK) - return TCL_ERROR; - count++; - } else if ((strcmp(argv[count],"-factorOnce") == 0) || (strcmp(argv[count],"-FactorOnce") ==0 )) { - factorOnce = 1; - } else if ((strcmp(argv[count],"-printTime") == 0) || (strcmp(argv[count],"-time") ==0 )) { - printTime = 1; - } - count++; - } - - UmfpackGenLinSolver *theSolver = new UmfpackGenLinSolver(); - // theSOE = new UmfpackGenLinSOE(*theSolver, factLVALUE, factorOnce, printTime); - theSOE = new UmfpackGenLinSOE(*theSolver); - } - -#ifdef _ITPACK -// else if (strcmp(argv[1],"Itpack") == 0) { -// -// // now must determine the type of solver to create from rest of args -// int method = 1; -// if (argc == 3) { -// if (Tcl_GetInt(interp, argv[2], &method) != TCL_OK) -// return TCL_ERROR; -// } -// ItpackLinSolver *theSolver = new ItpackLinSolver(method); -// theSOE = new ItpackLinSOE(*theSolver); -// } -#endif - else if (strcmp(argv[1],"FullGeneral") == 0) { - // now must determine the type of solver to create from rest of args - FullGenLinLapackSolver *theSolver = new FullGenLinLapackSolver(); - theSOE = new FullGenLinSOE(*theSolver); - } - -#ifdef _PETSC - - else if (strcmp(argv[1],"Petsc") == 0) { - // now must determine the type of solver to create from rest of args - KSPType method = KSPCG; // KSPCG KSPGMRES - PCType preconditioner = PCJACOBI; // PCJACOBI PCILU PCBJACOBI - int matType = 0; - - double rTol = 1.0e-5; - double aTol = 1.0e-50; - double dTol = 1.0e5; - int maxIts = 100000; - int count = 2; - while (count < argc-1) { - if (strcmp(argv[count],"-matrixType") == 0 || strcmp(argv[count],"-matrix")){ - if (strcmp(argv[count+1],"sparse") == 0) - matType = 1; - } - else if (strcmp(argv[count],"-rTol") == 0 || strcmp(argv[count],"-relTol") || - strcmp(argv[count],"-relativeTolerance")) { - if (Tcl_GetDouble(interp, argv[count+1], &rTol) != TCL_OK) - return TCL_ERROR; - } else if (strcmp(argv[count],"-aTol") == 0 || strcmp(argv[count],"-absTol") || - strcmp(argv[count],"-absoluteTolerance")) { - if (Tcl_GetDouble(interp, argv[count+1], &aTol) != TCL_OK) - return TCL_ERROR; - } else if (strcmp(argv[count],"-dTol") == 0 || strcmp(argv[count],"-divTol") || - strcmp(argv[count],"-divergenceTolerance")) { - if (Tcl_GetDouble(interp, argv[count+1], &dTol) != TCL_OK) - return TCL_ERROR; - } else if (strcmp(argv[count],"-mIts") == 0 || strcmp(argv[count],"-maxIts") || - strcmp(argv[count],"-maxIterations")) { - if (Tcl_GetInt(interp, argv[count+1], &maxIts) != TCL_OK) - return TCL_ERROR; - } else if (strcmp(argv[count],"-KSP") == 0 || strcmp(argv[count],"-KSPType")){ - if (strcmp(argv[count+1],"KSPCG") == 0) - method = KSPCG; - else if (strcmp(argv[count+1],"KSPBICG") == 0) - method = KSPBICG; - else if (strcmp(argv[count+1],"KSPRICHARDSON") == 0) - method = KSPRICHARDSON; - else if (strcmp(argv[count+1],"KSPCHEBYSHEV") == 0) - method = KSPCHEBYSHEV; - else if (strcmp(argv[count+1],"KSPGMRES") == 0) - method = KSPGMRES; - } else if (strcmp(argv[count],"-PC") == 0 || strcmp(argv[count],"-PCType")){ - if ((strcmp(argv[count+1],"PCJACOBI") == 0) || (strcmp(argv[count+1],"JACOBI") == 0)) - preconditioner = PCJACOBI; - else if ((strcmp(argv[count+1],"PCILU") == 0) || (strcmp(argv[count+1],"ILU") == 0)) - preconditioner = PCILU; - else if ((strcmp(argv[count+1],"PCICC") == 0) || (strcmp(argv[count+1],"ICC") == 0)) - preconditioner = PCICC; - else if ((strcmp(argv[count+1],"PCBJACOBI") == 0) || (strcmp(argv[count+1],"BIJACOBI") == 0)) - preconditioner = PCBJACOBI; - else if ((strcmp(argv[count+1],"PCNONE") == 0) || (strcmp(argv[count+1],"NONE") == 0)) - preconditioner = PCNONE; - } - count+=2; - } - - - if (matType == 0) { - // PetscSolver *theSolver = new PetscSolver(method, preconditioner, rTol, aTol, dTol, maxIts); - PetscSolver *theSolver = new PetscSolver(method, preconditioner, rTol, aTol, dTol, maxIts); - theSOE = new PetscSOE(*theSolver); - } else { - // PetscSparseSeqSolver *theSolver = new PetscSparseSeqSolver(method, preconditioner, rTol, aTol, dTol, maxIts); - PetscSparseSeqSolver *theSolver = 0; - theSOE = new SparseGenRowLinSOE(*theSolver); - } - } - - -#endif - - -#ifdef _MUMPS - - else if (strcmp(argv[1],"Mumps") == 0) { - - int icntl14 = 20; - int icntl7 = 7; - int matType = 0; // 0: unsymmetric, 1: symmetric positive definite, 2: symmetric general - - int currentArg = 2; - while (currentArg < argc) { - if (argc > 2) { - if (strcmp(argv[currentArg],"-ICNTL14") == 0) { - if (Tcl_GetInt(interp, argv[currentArg+1], &icntl14) != TCL_OK) - ; - currentArg += 2; - } else if (strcmp(argv[currentArg],"-ICNTL7") == 0) { - if (Tcl_GetInt(interp, argv[currentArg+1], &icntl7) != TCL_OK) - ; - currentArg += 2; - } else if (strcmp(argv[currentArg],"-matrixType") == 0) { - if (Tcl_GetInt(interp, argv[currentArg+1], &matType) != TCL_OK) - opserr << "Mumps Warning: failed to get -matrixType. Unsymmetric matrix assumed\n"; - if (matType < 0 || matType > 2) { - opserr << "Mumps Warning: wrong -matrixType value (" << matType << "). Unsymmetric matrix assumed\n"; - matType = 0; - } - currentArg += 2; - } else - currentArg++; - } - } - -#ifdef _PARALLEL_PROCESSING - MumpsParallelSolver *theSolver = new MumpsParallelSolver(icntl7, icntl14); - theSOE = new MumpsParallelSOE(*theSolver); -#elif _PARALLEL_INTERPRETERS - MumpsParallelSolver *theSolver = new MumpsParallelSolver(icntl7, icntl14); - MumpsParallelSOE *theParallelSOE = new MumpsParallelSOE(*theSolver, matType); - theParallelSOE->setProcessID(OPS_rank); - theParallelSOE->setChannels(numChannels, theChannels); - theSOE = theParallelSOE; -#else - MumpsSolver *theSolver = new MumpsSolver(icntl7, icntl14); - theSOE = new MumpsSOE(*theSolver, matType); -#endif - - } - -#endif - - - else { - - // - // maybe a package - // - - // try existing loaded packages - ExternalClassFunction *solverCommands = theExternalSolverCommands; - bool found = false; - // int result = TCL_ERROR; - while (solverCommands != NULL && found == false) { - - if (strcmp(argv[1], solverCommands->funcName) == 0) { - - OPS_ResetInputNoBuilder(clientData, interp, 2, argc, argv, &theDomain); - void *theRes = (*(solverCommands->funcPtr))(); - if (theRes != 0) { - - theSOE = (LinearSOE *)theRes; - found = true; - } - } else - solverCommands = solverCommands->next; - } - - // - // if not there try loading package - // - - if (found == false) { - - void *libHandle; - void *(*funcPtr)(); - int solverNameLength = strlen(argv[1]); - char *tclFuncName = new char[solverNameLength+5]; - strcpy(tclFuncName, "OPS_"); - strcpy(&tclFuncName[4], argv[1]); - - int res = getLibraryFunction(argv[1], tclFuncName, &libHandle, (void **)&funcPtr); - - delete [] tclFuncName; - - if (res == 0) { - - char *solverName = new char[solverNameLength+1]; - strcpy(solverName, argv[1]); - ExternalClassFunction *theSolverCommand = new ExternalClassFunction; - theSolverCommand->funcPtr = funcPtr; - theSolverCommand->funcName = solverName; - theSolverCommand->next = theExternalSolverCommands; - theExternalSolverCommands = theSolverCommand; - - OPS_ResetInputNoBuilder(clientData, interp, 2, argc, argv, &theDomain); - - void *theRes = (*funcPtr)(); - if (theRes != 0) { - theSOE = (LinearSOE *)theRes; - } - } - } - } - - // if the analysis exists - we want to change the SOEif - - if (theSOE != 0) { - if (theStaticAnalysis != 0) - theStaticAnalysis->setLinearSOE(*theSOE); - if (theTransientAnalysis != 0) - theTransientAnalysis->setLinearSOE(*theSOE); - -#ifdef _PARALLEL_PROCESSING - if (theStaticAnalysis != 0 || theTransientAnalysis != 0) { - SubdomainIter &theSubdomains = theDomain.getSubdomains(); - Subdomain *theSub; - while ((theSub = theSubdomains()) != 0) { - theSub->setAnalysisLinearSOE(*theSOE); - } - } -#endif - - return TCL_OK; - } - - return TCL_ERROR; -} - - - -// -// command invoked to allow the Numberer objects to be built -// -int -specifyNumberer(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv) -{ - // make sure at least one other argument to contain numberer - if (argc < 2) { - opserr << "WARNING need to specify a Nemberer type \n"; - return TCL_ERROR; - } - -#ifdef _PARALLEL_PROCESSING - // check argv[1] for type of Numberer and create the object - if (strcmp(argv[1],"Plain") == 0) { - theNumberer = new ParallelNumberer(); - } else if (strcmp(argv[1],"RCM") == 0) { - RCM *theRCM = new RCM(false); - theNumberer = new ParallelNumberer(*theRCM); - } else { - opserr << "WARNING No Numberer type exists (Plain, RCM only) \n"; - return TCL_ERROR; - } - -#else - - // check argv[1] for type of Numberer and create the object - if (strcmp(argv[1],"Plain") == 0) { - theNumberer = new PlainNumberer(); - } else if (strcmp(argv[1],"RCM") == 0) { - RCM *theRCM = new RCM(false); - theNumberer = new DOF_Numberer(*theRCM); - } else if (strcmp(argv[1],"AMD") == 0) { - AMD *theAMD = new AMD(); - theNumberer = new DOF_Numberer(*theAMD); - } - -#ifdef _PARALLEL_INTERPRETERS - - else if ((strcmp(argv[1],"ParallelPlain") == 0) || (strcmp(argv[1],"Parallel") == 0)) { - ParallelNumberer *theParallelNumberer = new ParallelNumberer; - theNumberer = theParallelNumberer; - theParallelNumberer->setProcessID(OPS_rank); - theParallelNumberer->setChannels(numChannels, theChannels); - } else if (strcmp(argv[1],"ParallelRCM") == 0) { - RCM *theRCM = new RCM(false); - ParallelNumberer *theParallelNumberer = new ParallelNumberer(*theRCM); - theNumberer = theParallelNumberer; - theParallelNumberer->setProcessID(OPS_rank); - theParallelNumberer->setChannels(numChannels, theChannels); - } - -#endif - - else { - opserr << "WARNING No Numberer type exists (Plain, RCM only) \n"; - return TCL_ERROR; - } -#endif - - return TCL_OK; -} - - - - -// -// command invoked to allow the ConstraintHandler object to be built -// -int -specifyConstraintHandler(ClientData clientData, Tcl_Interp *interp, int argc, - TCL_Char **argv) -{ - // make sure at least one other argument to contain numberer - if (argc < 2) { - opserr << "WARNING need to specify a Nemberer type \n"; - return TCL_ERROR; - } - - // check argv[1] for type of Numberer and create the object - if (strcmp(argv[1],"Plain") == 0) - theHandler = new PlainHandler(); - - else if (strcmp(argv[1],"Penalty") == 0) { - if (argc < 4) { - opserr << "WARNING: need to specify alpha: handler Penalty alpha \n"; - return TCL_ERROR; - } - double alpha1, alpha2; - if (Tcl_GetDouble(interp, argv[2], &alpha1) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[3], &alpha2) != TCL_OK) - return TCL_ERROR; - theHandler = new PenaltyConstraintHandler(alpha1, alpha2); - } - - /****** adding later - else if (strcmp(argv[1],"PenaltyNoHomoSPMultipliers") == 0) { - if (argc < 4) { - opserr << "WARNING: need to specify alpha: handler Penalty alpha \n"; - return TCL_ERROR; - } - double alpha1, alpha2; - if (Tcl_GetDouble(interp, argv[2], &alpha1) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[3], &alpha2) != TCL_OK) - return TCL_ERROR; - theHandler = new PenaltyHandlerNoHomoSPMultipliers(alpha1, alpha2); - } - ***********************/ - else if (strcmp(argv[1],"Lagrange") == 0) { - double alpha1 = 1.0; - double alpha2 = 1.0; - if (argc == 4) { - if (Tcl_GetDouble(interp, argv[2], &alpha1) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[3], &alpha2) != TCL_OK) - return TCL_ERROR; - } - theHandler = new LagrangeConstraintHandler(alpha1, alpha2); - } - - else if (strcmp(argv[1],"Transformation") == 0) { - theHandler = new TransformationConstraintHandler(); - } - - else { - opserr << "WARNING No ConstraintHandler type exists (Plain, Penalty,\n"; - opserr << " Lagrange, Transformation) only\n"; - return TCL_ERROR; - } - return TCL_OK; -} - - - -// -// command invoked to allow the SolnAlgorithm object to be built -// -int -specifyAlgorithm(ClientData clientData, Tcl_Interp *interp, int argc, - TCL_Char **argv) -{ - // make sure at least one other argument to contain numberer - if (argc < 2) { - opserr << "WARNING need to specify an Algorithm type \n"; - return TCL_ERROR; - } - EquiSolnAlgo *theNewAlgo = 0; - OPS_ResetInputNoBuilder(clientData, interp, 2, argc, argv, &theDomain); - - // check argv[1] for type of Algorithm and create the object - if (strcmp(argv[1],"Linear") == 0) { - int formTangent = CURRENT_TANGENT; - int factorOnce = 0; - int count = 2; - while (count < argc) { - if ((strcmp(argv[count],"-secant") == 0) || (strcmp(argv[count],"-Secant") == 0)) { - formTangent = CURRENT_SECANT; - } else if ((strcmp(argv[count],"-initial") == 0) || (strcmp(argv[count],"-Initial") == 0)) { - formTangent = INITIAL_TANGENT; - } else if ((strcmp(argv[count],"-factorOnce") == 0) || (strcmp(argv[count],"-FactorOnce") ==0 )) { - factorOnce = 1; - } - count++; - } - theNewAlgo = new Linear(formTangent, factorOnce); - } - - else if (strcmp(argv[1],"Newton") == 0) { - void *theNewtonAlgo = OPS_NewtonRaphsonAlgorithm(); - if (theNewtonAlgo == 0) - return TCL_ERROR; - - theNewAlgo = (EquiSolnAlgo *)theNewtonAlgo; - if (theTest != 0) - theNewAlgo->setConvergenceTest(theTest); - } - - else if ((strcmp(argv[1],"NewtonHallM") == 0) || (strcmp(argv[1],"NewtonHall") == 0)) { - void *theNewtonAlgo = OPS_NewtonHallM(); - if (theNewtonAlgo == 0) - return TCL_ERROR; - - theNewAlgo = (EquiSolnAlgo *)theNewtonAlgo; - if (theTest != 0) - theNewAlgo->setConvergenceTest(theTest); - } - - else if (strcmp(argv[1],"ModifiedNewton") == 0) { - void *theNewtonAlgo = OPS_ModifiedNewton(); - if (theNewtonAlgo == 0) - return TCL_ERROR; - - theNewAlgo = (EquiSolnAlgo *)theNewtonAlgo; - if (theTest != 0) - theNewAlgo->setConvergenceTest(theTest); - } - - else if (strcmp(argv[1],"KrylovNewton") == 0) { - int incrementTangent = CURRENT_TANGENT; - int iterateTangent = CURRENT_TANGENT; - int maxDim = 3; - for (int i = 2; i < argc; i++) { - if (strcmp(argv[i],"-iterate") == 0 && i+1 < argc) { - i++; - if (strcmp(argv[i],"current") == 0) - iterateTangent = CURRENT_TANGENT; - if (strcmp(argv[i],"initial") == 0) - iterateTangent = INITIAL_TANGENT; - if (strcmp(argv[i],"noTangent") == 0) - iterateTangent = NO_TANGENT; - } - else if (strcmp(argv[i],"-increment") == 0 && i+1 < argc) { - i++; - if (strcmp(argv[i],"current") == 0) - incrementTangent = CURRENT_TANGENT; - if (strcmp(argv[i],"initial") == 0) - incrementTangent = INITIAL_TANGENT; - if (strcmp(argv[i],"noTangent") == 0) - incrementTangent = NO_TANGENT; - } - else if (strcmp(argv[i],"-maxDim") == 0 && i+1 < argc) { - i++; - maxDim = atoi(argv[i]); - } - } - - if (theTest == 0) { - opserr << "ERROR: No ConvergenceTest yet specified\n"; - return TCL_ERROR; - } - - Accelerator *theAccel; - theAccel = new KrylovAccelerator(maxDim, iterateTangent); - - theNewAlgo = new AcceleratedNewton(*theTest, theAccel, incrementTangent); - } - - else if (strcmp(argv[1],"RaphsonNewton") == 0) { - int incrementTangent = CURRENT_TANGENT; - int iterateTangent = CURRENT_TANGENT; - for (int i = 2; i < argc; i++) { - if (strcmp(argv[i],"-iterate") == 0 && i+1 < argc) { - i++; - if (strcmp(argv[i],"current") == 0) - iterateTangent = CURRENT_TANGENT; - if (strcmp(argv[i],"initial") == 0) - iterateTangent = INITIAL_TANGENT; - if (strcmp(argv[i],"noTangent") == 0) - iterateTangent = NO_TANGENT; - } - else if (strcmp(argv[i],"-increment") == 0 && i+1 < argc) { - i++; - if (strcmp(argv[i],"current") == 0) - incrementTangent = CURRENT_TANGENT; - if (strcmp(argv[i],"initial") == 0) - incrementTangent = INITIAL_TANGENT; - if (strcmp(argv[i],"noTangent") == 0) - incrementTangent = NO_TANGENT; - } - } - - if (theTest == 0) { - opserr << "ERROR: No ConvergenceTest yet specified\n"; - return TCL_ERROR; - } - - Accelerator *theAccel; - theAccel = new RaphsonAccelerator(iterateTangent); - - theNewAlgo = new AcceleratedNewton(*theTest, theAccel, incrementTangent); - } - - else if (strcmp(argv[1],"MillerNewton") == 0) { - int incrementTangent = CURRENT_TANGENT; - int iterateTangent = CURRENT_TANGENT; - int maxDim = 3; - - for (int i = 2; i < argc; i++) { - if (strcmp(argv[i],"-iterate") == 0 && i+1 < argc) { - i++; - if (strcmp(argv[i],"current") == 0) - iterateTangent = CURRENT_TANGENT; - if (strcmp(argv[i],"initial") == 0) - iterateTangent = INITIAL_TANGENT; - if (strcmp(argv[i],"noTangent") == 0) - iterateTangent = NO_TANGENT; - } - else if (strcmp(argv[i],"-increment") == 0 && i+1 < argc) { - i++; - if (strcmp(argv[i],"current") == 0) - incrementTangent = CURRENT_TANGENT; - if (strcmp(argv[i],"initial") == 0) - incrementTangent = INITIAL_TANGENT; - if (strcmp(argv[i],"noTangent") == 0) - incrementTangent = NO_TANGENT; - } - else if (strcmp(argv[i],"-maxDim") == 0 && i+1 < argc) { - i++; - maxDim = atoi(argv[i]); - } - } - - if (theTest == 0) { - opserr << "ERROR: No ConvergenceTest yet specified\n"; - return TCL_ERROR; - } - - Accelerator *theAccel = 0; - //theAccel = new MillerAccelerator(maxDim, 0.01, iterateTangent); - - theNewAlgo = new AcceleratedNewton(*theTest, theAccel, incrementTangent); - } - - else if (strcmp(argv[1],"SecantNewton") == 0) { - int incrementTangent = CURRENT_TANGENT; - int iterateTangent = CURRENT_TANGENT; - int maxDim = 3; - for (int i = 2; i < argc; i++) { - if (strcmp(argv[i],"-iterate") == 0 && i+1 < argc) { - i++; - if (strcmp(argv[i],"current") == 0) - iterateTangent = CURRENT_TANGENT; - if (strcmp(argv[i],"initial") == 0) - iterateTangent = INITIAL_TANGENT; - if (strcmp(argv[i],"noTangent") == 0) - iterateTangent = NO_TANGENT; - } - else if (strcmp(argv[i],"-increment") == 0 && i+1 < argc) { - i++; - if (strcmp(argv[i],"current") == 0) - incrementTangent = CURRENT_TANGENT; - if (strcmp(argv[i],"initial") == 0) - incrementTangent = INITIAL_TANGENT; - if (strcmp(argv[i],"noTangent") == 0) - incrementTangent = NO_TANGENT; - } - else if (strcmp(argv[i],"-maxDim") == 0 && i+1 < argc) { - i++; - maxDim = atoi(argv[i]); - } - } - - if (theTest == 0) { - opserr << "ERROR: No ConvergenceTest yet specified\n"; - return TCL_ERROR; - } - - Accelerator *theAccel; - theAccel = new SecantAccelerator2(maxDim, iterateTangent); - - theNewAlgo = new AcceleratedNewton(*theTest, theAccel, incrementTangent); - } - - else if (strcmp(argv[1],"PeriodicNewton") == 0) { - int incrementTangent = CURRENT_TANGENT; - int iterateTangent = CURRENT_TANGENT; - int maxDim = 3; - for (int i = 2; i < argc; i++) { - if (strcmp(argv[i],"-iterate") == 0 && i+1 < argc) { - i++; - if (strcmp(argv[i],"current") == 0) - iterateTangent = CURRENT_TANGENT; - if (strcmp(argv[i],"initial") == 0) - iterateTangent = INITIAL_TANGENT; - if (strcmp(argv[i],"noTangent") == 0) - iterateTangent = NO_TANGENT; - } - else if (strcmp(argv[i],"-increment") == 0 && i+1 < argc) { - i++; - if (strcmp(argv[i],"current") == 0) - incrementTangent = CURRENT_TANGENT; - if (strcmp(argv[i],"initial") == 0) - incrementTangent = INITIAL_TANGENT; - if (strcmp(argv[i],"noTangent") == 0) - incrementTangent = NO_TANGENT; - } - else if (strcmp(argv[i],"-maxDim") == 0 && i+1 < argc) { - i++; - maxDim = atoi(argv[i]); - } - } - - if (theTest == 0) { - opserr << "ERROR: No ConvergenceTest yet specified\n"; - return TCL_ERROR; - } - - Accelerator *theAccel; - theAccel = new PeriodicAccelerator(maxDim, iterateTangent); - - theNewAlgo = new AcceleratedNewton(*theTest, theAccel, incrementTangent); - } - - else if (strcmp(argv[1],"Broyden") == 0) { - int formTangent = CURRENT_TANGENT; - int count = -1; - - if (theTest == 0) { - opserr << "ERROR: No ConvergenceTest yet specified\n"; - return TCL_ERROR; - } - for (int i = 2; i < argc; i++) { - if (strcmp(argv[i],"-secant") == 0) { - formTangent = CURRENT_SECANT; - } else if (strcmp(argv[i],"-initial") == 0) { - formTangent = INITIAL_TANGENT; - } else if (strcmp(argv[i++],"-count") == 0 && i < argc) { - count = atoi(argv[i]); - } - } - - if (count == -1) - theNewAlgo = new Broyden(*theTest, formTangent); - else - theNewAlgo = new Broyden(*theTest, formTangent, count); - } - - else if (strcmp(argv[1],"BFGS") == 0) { - int formTangent = CURRENT_TANGENT; - int count = -1; - for (int i = 2; i < argc; i++) { - if (strcmp(argv[i],"-secant") == 0) { - formTangent = CURRENT_SECANT; - } else if (strcmp(argv[i],"-initial") == 0) { - formTangent = INITIAL_TANGENT; - } else if (strcmp(argv[i++],"-count") == 0 && i < argc) { - count = atoi(argv[i]); - } - } - - if (theTest == 0) { - opserr << "ERROR: No ConvergenceTest yet specified\n"; - return TCL_ERROR; - } - - if (count == -1) - theNewAlgo = new BFGS(*theTest, formTangent); - else - theNewAlgo = new BFGS(*theTest, formTangent, count); - } - - else if (strcmp(argv[1],"NewtonLineSearch") == 0) { - if (theTest == 0) { - opserr << "ERROR: No ConvergenceTest yet specified\n"; - return TCL_ERROR; - } - - int count = 2; - - // set some default variable - double tol = 0.8; - int maxIter = 10; - double maxEta = 10.0; - double minEta = 0.1; - int pFlag = 1; - int typeSearch = 0; - - while (count < argc) { - if (strcmp(argv[count], "-tol") == 0) { - count++; - if (Tcl_GetDouble(interp, argv[count], &tol) != TCL_OK) - return TCL_ERROR; - count++; - } else if (strcmp(argv[count], "-maxIter") == 0) { - count++; - if (Tcl_GetInt(interp, argv[count], &maxIter) != TCL_OK) - return TCL_ERROR; - count++; - } else if (strcmp(argv[count], "-pFlag") == 0) { - count++; - if (Tcl_GetInt(interp, argv[count], &pFlag) != TCL_OK) - return TCL_ERROR; - count++; - } else if (strcmp(argv[count], "-minEta") == 0) { - count++; - if (Tcl_GetDouble(interp, argv[count], &minEta) != TCL_OK) - return TCL_ERROR; - count++; - } else if (strcmp(argv[count], "-maxEta") == 0) { - count++; - if (Tcl_GetDouble(interp, argv[count], &maxEta) != TCL_OK) - return TCL_ERROR; - count++; - } else if (strcmp(argv[count], "-type") == 0) { - count++; - if (strcmp(argv[count], "Bisection") == 0) - typeSearch = 1; - else if (strcmp(argv[count], "Secant") == 0) - typeSearch = 2; - else if (strcmp(argv[count], "RegulaFalsi") == 0) - typeSearch = 3; - else if (strcmp(argv[count], "LinearInterpolated") == 0) - typeSearch = 3; - else if (strcmp(argv[count], "InitialInterpolated") == 0) - typeSearch = 0; - count++; - } else - count++; - } - - LineSearch *theLineSearch = 0; - if (typeSearch == 0) - theLineSearch = new InitialInterpolatedLineSearch(tol, maxIter, minEta, maxEta, pFlag); - - else if (typeSearch == 1) - theLineSearch = new BisectionLineSearch(tol, maxIter, minEta, maxEta, pFlag); - else if (typeSearch == 2) - theLineSearch = new SecantLineSearch(tol, maxIter, minEta, maxEta, pFlag); - else if (typeSearch == 3) - theLineSearch = new RegulaFalsiLineSearch(tol, maxIter, minEta, maxEta, pFlag); - - theNewAlgo = new NewtonLineSearch(*theTest, theLineSearch); - } - - else if (strcmp(argv[1],"ExpressNewton") == 0) { - int nIter = 2, factorOnce = 0, formTangent = CURRENT_TANGENT; - double kMultiplier = 1.0; - if (argc >= 3 && Tcl_GetInt(interp, argv[2], &nIter) != TCL_OK) - return TCL_ERROR; - if (argc >= 4 && Tcl_GetDouble(interp, argv[3], &kMultiplier) != TCL_OK) - return TCL_ERROR; - int count = 4; - while (argc > count) { - if ((strcmp(argv[count],"-initialTangent") == 0) || (strcmp(argv[count],"-InitialTangent") == 0)) { - formTangent = INITIAL_TANGENT; - } else if ((strcmp(argv[count],"-currentTangent") == 0) || (strcmp(argv[count],"-CurrentTangent") ==0 )) { - formTangent = CURRENT_TANGENT; - } else if ((strcmp(argv[count],"-factorOnce") == 0) || (strcmp(argv[count],"-FactorOnce") ==0 )) { - factorOnce = 1; - } - count++; - } - theNewAlgo = new ExpressNewton(nIter,kMultiplier,formTangent,factorOnce); - } - - else { - opserr << "WARNING No EquiSolnAlgo type " << argv[1] << " exists\n"; - return TCL_ERROR; - } - - - if (theNewAlgo != 0) { - theAlgorithm = theNewAlgo; - - // if the analysis exists - we want to change the SOE - if (theStaticAnalysis != 0) - theStaticAnalysis->setAlgorithm(*theAlgorithm); - else if (theTransientAnalysis != 0) - theTransientAnalysis->setAlgorithm(*theAlgorithm); - -#ifdef _PARALLEL_PROCESSING - if (theStaticAnalysis != 0 || theTransientAnalysis != 0) { - SubdomainIter &theSubdomains = theDomain.getSubdomains(); - Subdomain *theSub; - while ((theSub = theSubdomains()) != 0) { - theSub->setAnalysisAlgorithm(*theAlgorithm); - } - } -#endif - } - - return TCL_OK; -} - - -// -// command invoked to allow the SolnAlgorithm object to be built -// -int -specifyCTest(ClientData clientData, Tcl_Interp *interp, int argc, - TCL_Char **argv) -{ - // make sure at least one other argument to contain numberer - if (argc < 2) { - opserr << "WARNING need to specify a ConvergenceTest Type type \n"; - return TCL_ERROR; - } - - // get the tolerence first - double tol = 0.0; - double tol2 = 0.0; - double tolp = 0.0; - double tolp2 = 0.0; - double tolrel = 0.0; - double tolprel = 0.0; - double maxTol = OPS_MAXTOL; - - int numIter = 0; - int printIt = 0; - int normType = 2; - int maxIncr = -1; - - if ((strcmp(argv[1],"NormDispAndUnbalance") == 0) || - (strcmp(argv[1],"NormDispOrUnbalance") == 0)) { - if (argc == 5) { - if (Tcl_GetDouble(interp, argv[2], &tol) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[3], &tol2) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[4], &numIter) != TCL_OK) - return TCL_ERROR; - } else if (argc == 6) { - if (Tcl_GetDouble(interp, argv[2], &tol) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[3], &tol2) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[4], &numIter) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[5], &printIt) != TCL_OK) - return TCL_ERROR; - } else if (argc == 7) { - if (Tcl_GetDouble(interp, argv[2], &tol) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[3], &tol2) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[4], &numIter) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[5], &printIt) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[6], &normType) != TCL_OK) - return TCL_ERROR; - } else if (argc == 8) { - if (Tcl_GetDouble(interp, argv[2], &tol) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[3], &tol2) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[4], &numIter) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[5], &printIt) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[6], &normType) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[7], &maxIncr) != TCL_OK) - return TCL_ERROR; - } - - } else if (strcmp(argv[1],"PFEM") == 0) { - if(argc > 8) { - if(Tcl_GetDouble(interp, argv[2], &tol) != TCL_OK) - return TCL_ERROR; - if(Tcl_GetDouble(interp, argv[3], &tolp) != TCL_OK) - return TCL_ERROR; - if(Tcl_GetDouble(interp, argv[4], &tol2) != TCL_OK) - return TCL_ERROR; - if(Tcl_GetDouble(interp, argv[5], &tolp2) != TCL_OK) - return TCL_ERROR; - if(Tcl_GetDouble(interp, argv[6], &tolrel) != TCL_OK) - return TCL_ERROR; - if(Tcl_GetDouble(interp, argv[7], &tolprel) != TCL_OK) - return TCL_ERROR; - if(Tcl_GetInt(interp, argv[8], &numIter) != TCL_OK) - return TCL_ERROR; - } - if(argc > 9) { - if(Tcl_GetInt(interp, argv[9], &maxIncr) != TCL_OK) - return TCL_ERROR; - } - if(argc > 10) { - if(Tcl_GetInt(interp, argv[10], &printIt) != TCL_OK) - return TCL_ERROR; - } - if(argc > 11) { - if(Tcl_GetInt(interp, argv[11], &normType) != TCL_OK) - return TCL_ERROR; - } - - } else if (strcmp(argv[1],"FixedNumIter") == 0) { - - if (argc == 3) { - if (Tcl_GetInt(interp, argv[2], &numIter) != TCL_OK) - return TCL_ERROR; - } else if (argc == 4) { - if (Tcl_GetInt(interp, argv[2], &numIter) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[3], &printIt) != TCL_OK) - return TCL_ERROR; - } else if (argc == 5) { - if (Tcl_GetInt(interp, argv[2], &numIter) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[3], &printIt) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[4], &normType) != TCL_OK) - return TCL_ERROR; - } else if (argc == 6) { - if (Tcl_GetInt(interp, argv[2], &numIter) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[3], &printIt) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[4], &normType) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[5], &maxTol) != TCL_OK) - return TCL_ERROR; - } - - } else { - if (argc == 4) { - if (Tcl_GetDouble(interp, argv[2], &tol) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[3], &numIter) != TCL_OK) - return TCL_ERROR; - } else if (argc == 5) { - if (Tcl_GetDouble(interp, argv[2], &tol) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[3], &numIter) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[4], &printIt) != TCL_OK) - return TCL_ERROR; - } else if (argc == 6) { - if (Tcl_GetDouble(interp, argv[2], &tol) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[3], &numIter) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[4], &printIt) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[5], &normType) != TCL_OK) - return TCL_ERROR; - } else if (argc == 7) { - if (Tcl_GetDouble(interp, argv[2], &tol) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[3], &numIter) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[4], &printIt) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[5], &normType) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[6], &maxTol) != TCL_OK) - return TCL_ERROR; - } - } - - - ConvergenceTest *theNewTest = 0; - - if (numIter == 0) { - opserr << "ERROR: no numIter specified in test command\n"; - return TCL_ERROR; - } - - if (strcmp(argv[1],"FixedNumIter") == 0) - theNewTest = new CTestFixedNumIter(numIter,printIt,normType); - else { - if (tol == 0.0) { - opserr << "ERROR: no tolerance specified in test command\n"; - return TCL_ERROR; - } - if (strcmp(argv[1],"NormUnbalance") == 0) - theNewTest = new CTestNormUnbalance(tol,numIter,printIt,normType,maxIncr, maxTol); - else if (strcmp(argv[1],"NormDispIncr") == 0) - theNewTest = new CTestNormDispIncr(tol,numIter,printIt,normType, maxTol); - else if (strcmp(argv[1],"NormDispAndUnbalance") == 0) - theNewTest = new NormDispAndUnbalance(tol,tol2, numIter,printIt,normType,maxIncr); - else if (strcmp(argv[1],"NormDispOrUnbalance") == 0) - theNewTest = new NormDispOrUnbalance(tol,tol2, numIter,printIt,normType,maxIncr); - else if (strcmp(argv[1],"EnergyIncr") == 0) - theNewTest = new CTestEnergyIncr(tol,numIter,printIt,normType, maxTol); - else if (strcmp(argv[1],"RelativeNormUnbalance") == 0) - theNewTest = new CTestRelativeNormUnbalance(tol,numIter,printIt,normType); - else if (strcmp(argv[1],"RelativeNormDispIncr") == 0) - theNewTest = new CTestRelativeNormDispIncr(tol,numIter,printIt,normType); - else if (strcmp(argv[1],"RelativeEnergyIncr") == 0) - theNewTest = new CTestRelativeEnergyIncr(tol,numIter,printIt,normType); - else if (strcmp(argv[1],"RelativeTotalNormDispIncr") == 0) - theNewTest = new CTestRelativeTotalNormDispIncr(tol,numIter,printIt,normType); - else if (strcmp(argv[1],"PFEM") == 0) - theNewTest = new CTestPFEM(tol,tolp,tol2,tolp2,tolrel,tolprel,numIter,maxIncr,printIt,normType); - else { - opserr << "WARNING No ConvergenceTest type (NormUnbalance, NormDispIncr, EnergyIncr, \n"; - opserr << "RelativeNormUnbalance, RelativeNormDispIncr, RelativeEnergyIncr, \n"; - opserr << "RelativeTotalNormDispIncr, FixedNumIter)\n"; - return TCL_ERROR; - } - } - - if (theNewTest != 0) { - theTest = theNewTest; - - // if the analysis exists - we want to change the Test - if (theStaticAnalysis != 0) - theStaticAnalysis->setConvergenceTest(*theTest); - - else if (theTransientAnalysis != 0) - theTransientAnalysis->setConvergenceTest(*theTest); - -#ifdef _PARALLEL_PROCESSING - if (theStaticAnalysis != 0 || theTransientAnalysis != 0) { - SubdomainIter &theSubdomains = theDomain.getSubdomains(); - Subdomain *theSub; - while ((theSub = theSubdomains()) != 0) { - theSub->setAnalysisConvergenceTest(*theTest);; - } - } -#endif - } - - return TCL_OK; -} - - - -// -// command invoked to allow the Integrator object to be built -// -int -specifyIntegrator(ClientData clientData, Tcl_Interp *interp, int argc, - TCL_Char **argv) -{ - - OPS_ResetInputNoBuilder(clientData, interp, 2, argc, argv, &theDomain); - - // make sure at least one other argument to contain integrator - if (argc < 2) { - opserr << "WARNING need to specify an Integrator type \n"; - return TCL_ERROR; - } - - // check argv[1] for type of Numberer and create the object - if (strcmp(argv[1],"LoadControl") == 0) { - double dLambda; - double minIncr, maxIncr; - int numIter; - if (argc < 3) { - opserr << "WARNING incorrect # args - integrator LoadControl dlam \n"; - return TCL_ERROR; - } - if (Tcl_GetDouble(interp, argv[2], &dLambda) != TCL_OK) - return TCL_ERROR; - if (argc > 5) { - if (Tcl_GetInt(interp, argv[3], &numIter) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[4], &minIncr) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[5], &maxIncr) != TCL_OK) - return TCL_ERROR; - } - else { - minIncr = dLambda; - maxIncr = dLambda; - numIter = 1; - } - theStaticIntegrator = new LoadControl(dLambda, numIter, minIncr, maxIncr); - - // if the analysis exists - we want to change the Integrator - if (theStaticAnalysis != 0) - theStaticAnalysis->setIntegrator(*theStaticIntegrator); - } else if (strcmp(argv[1],"StagedLoadControl") == 0) { - double dLambda; - double minIncr, maxIncr; - int numIter; - if (argc < 3) { - opserr << "WARNING incorrect # args - integrator StagedLoadControl dlam \n"; - return TCL_ERROR; - } - if (Tcl_GetDouble(interp, argv[2], &dLambda) != TCL_OK) - return TCL_ERROR; - if (argc > 5) { - if (Tcl_GetInt(interp, argv[3], &numIter) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[4], &minIncr) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[5], &maxIncr) != TCL_OK) - return TCL_ERROR; - } - else { - minIncr = dLambda; - maxIncr = dLambda; - numIter = 1; - } - theStaticIntegrator = new StagedLoadControl(dLambda, numIter, minIncr, maxIncr); - - - if (theStaticAnalysis != 0) - theStaticAnalysis->setIntegrator(*theStaticIntegrator); - } - - else if (strcmp(argv[1],"ArcLength") == 0) { - double arcLength; - double alpha; - if (argc != 4) { - opserr << "WARNING integrator ArcLength arcLength alpha \n"; - return TCL_ERROR; - } - if (Tcl_GetDouble(interp, argv[2], &arcLength) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[3], &alpha) != TCL_OK) - return TCL_ERROR; - theStaticIntegrator = new ArcLength(arcLength,alpha); - - // if the analysis exists - we want to change the Integrator - if (theStaticAnalysis != 0) - theStaticAnalysis->setIntegrator(*theStaticIntegrator); - } - - else if (strcmp(argv[1],"ArcLength1") == 0) { - double arcLength; - double alpha; - if (argc != 4) { - opserr << "WARNING integrator ArcLength1 arcLength alpha \n"; - return TCL_ERROR; - } - if (Tcl_GetDouble(interp, argv[2], &arcLength) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[3], &alpha) != TCL_OK) - return TCL_ERROR; - theStaticIntegrator = new ArcLength1(arcLength,alpha); - - // if the analysis exists - we want to change the Integrator - if (theStaticAnalysis != 0) - theStaticAnalysis->setIntegrator(*theStaticIntegrator); - } - /************************added for HSConstraint*************************************/ - - else if (strcmp(argv[1],"HSConstraint") == 0) { - double arcLength; - double psi_u; - double psi_f; - double u_ref; - if (argc < 3) { - opserr << "WARNING integrator HSConstraint \n"; - return TCL_ERROR; - } - if (argc >= 3 && Tcl_GetDouble(interp, argv[2], &arcLength) != TCL_OK) - return TCL_ERROR; - if (argc>=4 && Tcl_GetDouble(interp, argv[3], &psi_u) != TCL_OK) - return TCL_ERROR; - if (argc>=5 && Tcl_GetDouble(interp, argv[4], &psi_f) != TCL_OK) - return TCL_ERROR; - if (argc==6 && Tcl_GetDouble(interp, argv[5], &u_ref) != TCL_OK) - return TCL_ERROR; - - switch(argc) - { - case 3: - theStaticIntegrator = new HSConstraint(arcLength); - case 4: - theStaticIntegrator = new HSConstraint(arcLength, psi_u); - case 5: - theStaticIntegrator = new HSConstraint(arcLength, psi_u, psi_f); - case 6: - theStaticIntegrator = new HSConstraint(arcLength, psi_u, psi_f, u_ref); - } - // if the analysis exists - we want to change the Integrator - if (theStaticAnalysis != 0) - theStaticAnalysis->setIntegrator(*theStaticIntegrator); - } - /*********************************************************************************/ - - else if (strcmp(argv[1],"MinUnbalDispNorm") == 0) { - double lambda11, minlambda, maxlambda; - int numIter; - if (argc < 3) { - opserr << "WARNING integrator MinUnbalDispNorm lambda11 \n"; - return TCL_ERROR; - } - if (Tcl_GetDouble(interp, argv[2], &lambda11) != TCL_OK) - return TCL_ERROR; - if (argc > 5) { - if (Tcl_GetInt(interp, argv[3], &numIter) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[4], &minlambda) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[5], &maxlambda) != TCL_OK) - return TCL_ERROR; - } - else { - minlambda = lambda11; - maxlambda = lambda11; - numIter = 1; - argc += 3; - } - - int signFirstStepMethod = SIGN_LAST_STEP; - if (argc == 7) - if ((strcmp(argv[argc-1],"-determinant") == 0) || - (strcmp(argv[argc-1],"-det") == 0)) - signFirstStepMethod = CHANGE_DETERMINANT; - - theStaticIntegrator = new MinUnbalDispNorm(lambda11,numIter,minlambda,maxlambda,signFirstStepMethod); - - // if the analysis exists - we want to change the Integrator - if (theStaticAnalysis != 0) - theStaticAnalysis->setIntegrator(*theStaticIntegrator); - } - - else if (strcmp(argv[1], "EQPath") == 0) { - double arcLength; - int type; - int numIter; - if (argc != 4) { - opserr << "WARNING integrator EQPath $arc_length $type \n"; - opserr << "REFS : \n"; - opserr << " https://doi.org/10.12989/sem.2013.48.6.849 \n"; - opserr << " https://doi.org/10.12989/sem.2013.48.6.879 \n"; - return TCL_ERROR; - } - - if (Tcl_GetDouble(interp, argv[2], &arcLength) != TCL_OK) - { - opserr << "WARNING integrator EQPath $arc_length $type \n"; - opserr << " https://doi.org/10.12989/sem.2013.48.6.849 \n"; - opserr << " https://doi.org/10.12989/sem.2013.48.6.879 \n"; - return TCL_ERROR; - return TCL_ERROR; - } - - if (Tcl_GetInt(interp, argv[3], &type) != TCL_OK) - { - opserr << "WARNING integrator $arc_length $type \n"; - opserr << "$type = 1 Minimum Residual Displacement \n"; - opserr << "$type = 2 Normal Plain \n"; - opserr << "$type = 3 Update Normal Plain \n"; - opserr << "$type = 4 Cylindrical Arc-Length \n"; - - return TCL_ERROR; - } - - theStaticIntegrator = new EQPath(arcLength, type); - - // if the analysis exists - we want to change the Integrator - if (theStaticAnalysis != 0) - theStaticAnalysis->setIntegrator(*theStaticIntegrator); - } - - else if (strcmp(argv[1],"DisplacementControl") == 0) { - int node; - int dof; - double increment, minIncr, maxIncr; - int numIter; - if (argc < 5) { - opserr << "WARNING integrator DisplacementControl node dof dU \n"; - opserr << "\n"; - return TCL_ERROR; - } - int tangFlag = 0; - - if (Tcl_GetInt(interp, argv[2], &node) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[3], &dof) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[4], &increment) != TCL_OK) - return TCL_ERROR; - - if (argc == 6 || argc == 9) - if (argc == 6) { - if (strcmp(argv[5],"-initial") == 0) - tangFlag = 1; - } else if (strcmp(argv[8],"-initial") == 0) - tangFlag = 1; - - if (argc > 6) { - if (Tcl_GetInt(interp, argv[5], &numIter) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[6], &minIncr) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[7], &maxIncr) != TCL_OK) - return TCL_ERROR; - } - else { - minIncr = increment; - maxIncr = increment; - numIter = 1; - } - - - -#ifdef _PARALLEL_PROCESSING - - theStaticIntegrator = new DistributedDisplacementControl(node,dof-1,increment, - numIter, minIncr, maxIncr); -#else - Node *theNode = theDomain.getNode(node); - if (theNode == 0) { - opserr << "WARNING integrator DisplacementControl node dof dU : Node does not exist\n"; - return TCL_ERROR; - } - - - int numDOF = theNode->getNumberDOF(); - if (dof <= 0 || dof > numDOF) { - opserr << "WARNING integrator DisplacementControl node dof dU : invalid dof given\n"; - return TCL_ERROR; - } - - theStaticIntegrator = new DisplacementControl(node, dof-1, increment, &theDomain, - numIter, minIncr, maxIncr, tangFlag); -#endif - - // if the analysis exists - we want to change the Integrator - if (theStaticAnalysis != 0) - theStaticAnalysis->setIntegrator(*theStaticIntegrator); - } - - -#ifdef _PARALLEL_INTERPRETERS - - else if ((strcmp(argv[1],"ParallelDisplacementControl") == 0) || (strcmp(argv[1],"ParallelDisplacementControl") == 0)) { - int node; - int dof; - double increment, minIncr, maxIncr; - int numIter; - if (argc < 5) { - opserr << "WARNING integrator DisplacementControl node dof dU \n"; - opserr << "\n"; - return TCL_ERROR; - } - if (Tcl_GetInt(interp, argv[2], &node) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetInt(interp, argv[3], &dof) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[4], &increment) != TCL_OK) - return TCL_ERROR; - if (argc > 7) { - if (Tcl_GetInt(interp, argv[5], &numIter) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[6], &minIncr) != TCL_OK) - return TCL_ERROR; - if (Tcl_GetDouble(interp, argv[7], &maxIncr) != TCL_OK) - return TCL_ERROR; - } - else { - minIncr = increment; - maxIncr = increment; - numIter = 1; - } - - - DistributedDisplacementControl *theDDC = new DistributedDisplacementControl(node,dof-1,increment, - numIter, minIncr, maxIncr); - - theDDC->setProcessID(OPS_rank); - theDDC->setChannels(numChannels, theChannels); - theStaticIntegrator = theDDC; - - // if the analysis exists - we want to change the Integrator - if (theStaticAnalysis != 0) - theStaticAnalysis->setIntegrator(*theStaticIntegrator); - } -#endif - - else if ((strcmp(argv[1],"TRBDF2") == 0) || (strcmp(argv[1],"Bathe") == 0)) { - theTransientIntegrator = new TRBDF2(); - } - - else if ((strcmp(argv[1],"TRBDF3") == 0) || (strcmp(argv[1],"Bathe3") == 0)) { - theTransientIntegrator = new TRBDF3(); - } - - else if (strcmp(argv[1],"Houbolt") == 0) { - theTransientIntegrator = new Houbolt(); - } - - /*else if (strcmp(argv[1],"ParkLMS3") == 0) { - theTransientIntegrator = new ParkLMS3(); - }*/ - - else if (strcmp(argv[1],"BackwardEuler") == 0) { - int optn = 0; - if (argc == 3) { - if (Tcl_GetInt(interp, argv[2], &optn) != TCL_OK) { - opserr << "WARNING integrator BackwardEuler