Skip to content

Commit

Permalink
Adding ExplicitDifference to Tcl
Browse files Browse the repository at this point in the history
  • Loading branch information
mhscott committed Jul 3, 2021
1 parent da3f841 commit 6720040
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 41 deletions.
64 changes: 32 additions & 32 deletions SRC/analysis/integrator/ExplicitDifference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
#define OPS_Export


void* OPS_Explicitdifference(void)
void* OPS_ExplicitDifference(void)
{
TransientIntegrator *theIntegrator = 0;
theIntegrator = new Explicitdifference();
theIntegrator = new ExplicitDifference();

if (theIntegrator == 0)
opserr << "WARNING - out of memory creating Explicitdifference integrator\n";
opserr << "WARNING - out of memory creating ExplicitDifference integrator\n";

return theIntegrator;
}


Explicitdifference::Explicitdifference()
ExplicitDifference::ExplicitDifference()
: TransientIntegrator(INTEGRATOR_TAGS_ExplicitDifference),
deltaT(0.0),
alphaM(0.0), betaK(0.0), betaKi(0.0), betaKc(0.0),
Expand All @@ -37,7 +37,7 @@ Explicitdifference::Explicitdifference()
}


Explicitdifference::Explicitdifference(
ExplicitDifference::ExplicitDifference(
double _alphaM, double _betaK, double _betaKi, double _betaKc)
: TransientIntegrator(INTEGRATOR_TAGS_ExplicitDifference),
deltaT(0.0),
Expand All @@ -50,7 +50,7 @@ Explicitdifference::Explicitdifference(
}


Explicitdifference::~Explicitdifference()
ExplicitDifference::~ExplicitDifference()
{
// clean up the memory created

Expand All @@ -72,14 +72,14 @@ Explicitdifference::~Explicitdifference()
}


int Explicitdifference::newStep(double _deltaT)
int ExplicitDifference::newStep(double _deltaT)
{
updateCount = 0;

deltaT = _deltaT;

if (deltaT <= 0.0) {
opserr << "Explicitdifference::newStep() - error in variable\n";
opserr << "ExplicitDifference::newStep() - error in variable\n";
opserr << "dT = " << deltaT << endln;
return -1;
}
Expand All @@ -94,7 +94,7 @@ int Explicitdifference::newStep(double _deltaT)
int size = Utdotdot->Size();

if (Ut == 0) {
opserr << "Explicitdifference::newStep() - domainChange() failed or hasn't been called\n";
opserr << "ExplicitDifference::newStep() - domainChange() failed or hasn't been called\n";
return -2;
}

Expand All @@ -109,7 +109,7 @@ int Explicitdifference::newStep(double _deltaT)
// increment the time to t and apply the load
double time = theModel->getCurrentDomainTime();
if (theModel->updateDomain(time, deltaT) < 0) {
opserr << "Explicitdifference::newStep() - failed to update the domain\n";
opserr << "ExplicitDifference::newStep() - failed to update the domain\n";
return -3;
}

Expand All @@ -120,7 +120,7 @@ int Explicitdifference::newStep(double _deltaT)
}


int Explicitdifference::formEleTangent(FE_Element *theEle)
int ExplicitDifference::formEleTangent(FE_Element *theEle)
{
theEle->zeroTangent();

Expand All @@ -130,7 +130,7 @@ int Explicitdifference::formEleTangent(FE_Element *theEle)
}


int Explicitdifference::formNodTangent(DOF_Group *theDof)
int ExplicitDifference::formNodTangent(DOF_Group *theDof)
{
theDof->zeroTangent();

Expand All @@ -140,7 +140,7 @@ int Explicitdifference::formNodTangent(DOF_Group *theDof)
}


int Explicitdifference::domainChanged()
int ExplicitDifference::domainChanged()
{

AnalysisModel *theModel = this->getAnalysisModel();
Expand Down Expand Up @@ -195,7 +195,7 @@ int Explicitdifference::domainChanged()
Utdot1 == 0 || Utdot1->Size() != size
) {

opserr << "Explicitdifference::domainChanged - ran out of memory\n";
opserr << "ExplicitDifference::domainChanged - ran out of memory\n";

// delete the old

Expand Down Expand Up @@ -261,36 +261,36 @@ int Explicitdifference::domainChanged()
}
}

opserr << "WARNING: Explicitdifference::domainChanged() - assuming Ut-1 = Ut\n";
opserr << "WARNING: ExplicitDifference::domainChanged() - assuming Ut-1 = Ut\n";

return 0;
}


int Explicitdifference::update(const Vector &Udotdot)
int ExplicitDifference::update(const Vector &Udotdot)
{
updateCount++;
if (updateCount > 2) {
opserr << "WARNING Explicitdifference::update() - called more than once -";
opserr << " Explicitdifference integration scheme requires a LINEAR solution algorithm\n";
opserr << "WARNING ExplicitDifference::update() - called more than once -";
opserr << " ExplicitDifference integration scheme requires a LINEAR solution algorithm\n";
return -1;
}

AnalysisModel *theModel = this->getAnalysisModel();
if (theModel == 0) {
opserr << "WARNING Explicitdifference::update() - no souAnalysisModel set\n";
opserr << "WARNING ExplicitDifference::update() - no souAnalysisModel set\n";
return -2;
}

// check domainChanged() has been called, i.e. Ut will not be zero
if (Ut == 0) {
opserr << "WARNING Explicitdifference::update() - domainChange() failed or not called\n";
opserr << "WARNING ExplicitDifference::update() - domainChange() failed or not called\n";
return -3;
}

// check Udotdot is of correct size
if (Udotdot.Size() != Utdotdot->Size()) {
opserr << "WARNING Explicitdifference::update() - Vectors of incompatible size ";
opserr << "WARNING ExplicitDifference::update() - Vectors of incompatible size ";
opserr << " expecting " << Utdotdot->Size() << " obtained " << Udotdot.Size() << endln;
return -4;
}
Expand All @@ -312,7 +312,7 @@ int Explicitdifference::update(const Vector &Udotdot)
theModel->setResponse(*Ut, *Utdot1, Udotdot);

if (theModel->updateDomain() < 0) {
opserr << "Explicitdifference::update() - failed to update the domain\n";
opserr << "ExplicitDifference::update() - failed to update the domain\n";
return -5;
}

Expand All @@ -330,11 +330,11 @@ int Explicitdifference::update(const Vector &Udotdot)
}


int Explicitdifference::commit(void)
int ExplicitDifference::commit(void)
{
AnalysisModel *theModel = this->getAnalysisModel();
if (theModel == 0) {
opserr << "WARNING Explicitdifference::commit() - no AnalysisModel set\n";
opserr << "WARNING ExplicitDifference::commit() - no AnalysisModel set\n";
return -1;
}

Expand All @@ -347,7 +347,7 @@ int Explicitdifference::commit(void)
}


int Explicitdifference::sendSelf(int cTag, Channel &theChannel)
int ExplicitDifference::sendSelf(int cTag, Channel &theChannel)
{
Vector data(4);
data(0) = alphaM;
Expand All @@ -356,19 +356,19 @@ int Explicitdifference::sendSelf(int cTag, Channel &theChannel)
data(3) = betaKc;

if (theChannel.sendVector(this->getDbTag(), cTag, data) < 0) {
opserr << "WARNING Explicitdifference::sendSelf() - could not send data\n";
opserr << "WARNING ExplicitDifference::sendSelf() - could not send data\n";
return -1;
}

return 0;
}


int Explicitdifference::recvSelf(int cTag, Channel &theChannel, FEM_ObjectBroker &theBroker)
int ExplicitDifference::recvSelf(int cTag, Channel &theChannel, FEM_ObjectBroker &theBroker)
{
Vector data(4);
if (theChannel.recvVector(this->getDbTag(), cTag, data) < 0) {
opserr << "WARNING Explicitdifference::recvSelf() - could not receive data\n";
opserr << "WARNING ExplicitDifference::recvSelf() - could not receive data\n";
return -1;
}

Expand All @@ -381,24 +381,24 @@ int Explicitdifference::recvSelf(int cTag, Channel &theChannel, FEM_ObjectBroker
}


void Explicitdifference::Print(OPS_Stream &s, int flag)
void ExplicitDifference::Print(OPS_Stream &s, int flag)
{
AnalysisModel *theModel = this->getAnalysisModel();
if (theModel != 0) {
double currentTime = theModel->getCurrentDomainTime();
s << "Explicitdifference - currentTime: " << currentTime << endln;
s << "ExplicitDifference - currentTime: " << currentTime << endln;
s << " Rayleigh Damping - alphaM: " << alphaM << " betaK: " << betaK;
s << " betaKi: " << betaKi << " betaKc: " << betaKc << endln;
}
else
s << "Explicitdifference - no associated AnalysisModel\n";
s << "ExplicitDifference - no associated AnalysisModel\n";
}



//a interface to get velosity for modal damping
const Vector &
Explicitdifference::getVel()
ExplicitDifference::getVel()
{
return *Utdot;
}
Expand Down
12 changes: 6 additions & 6 deletions SRC/analysis/integrator/ExplicitDifference.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#ifndef Explicitdifference_h
#define Explicitdifference_h
#ifndef ExplicitDifference_h
#define ExplicitDifference_h


#include<TransientIntegrator.h>
Expand All @@ -9,12 +9,12 @@ class DOF_Group;
class FE_Element;
class Vector;

class Explicitdifference : public TransientIntegrator
class ExplicitDifference : public TransientIntegrator
{
public:
Explicitdifference();
Explicitdifference(double alphaM, double betaK, double betaKi, double betaKc);
~Explicitdifference(); //constructors and unconstructor
ExplicitDifference();
ExplicitDifference(double alphaM, double betaK, double betaKi, double betaKc);
~ExplicitDifference(); //constructors and unconstructor



Expand Down
2 changes: 1 addition & 1 deletion SRC/interpreter/OpenSeesCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ int OPS_Integrator()
ti = (TransientIntegrator*)OPS_CentralDifferenceNoDamping();

} else if (strcmp(type, "ExplicitDifference") == 0) {
ti = (TransientIntegrator*)OPS_Explicitdifference();
ti = (TransientIntegrator*)OPS_ExplicitDifference();

} else {
opserr<<"WARNING unknown integrator type "<<type<<"\n";
Expand Down
2 changes: 1 addition & 1 deletion SRC/interpreter/OpenSeesCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ void* OPS_WilsonTheta();
void* OPS_CentralDifference();
void* OPS_CentralDifferenceAlternative();
void* OPS_CentralDifferenceNoDamping();
void* OPS_Explicitdifference();
void* OPS_ExplicitDifference();

void* OPS_LinearAlgorithm();
void* OPS_NewtonRaphsonAlgorithm();
Expand Down
10 changes: 9 additions & 1 deletion SRC/tcl/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ 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_ExplicitDifference(void);
extern void *OPS_CentralDifference(void);
extern void *OPS_CentralDifferenceAlternative(void);
extern void *OPS_CentralDifferenceNoDamping(void);
Expand Down Expand Up @@ -5212,12 +5213,19 @@ specifyIntegrator(ClientData clientData, Tcl_Interp *interp, int argc,
theTransientAnalysis->setIntegrator(*theTransientIntegrator);
}

else if (strcmp(argv[1],"ExplicitDifference") == 0) {
theTransientIntegrator = (TransientIntegrator *)OPS_ExplicitDifference();

if (theTransientAnalysis != 0)
theTransientAnalysis->setIntegrator(*theTransientIntegrator);
}

else if (strcmp(argv[1],"CentralDifference") == 0) {
theTransientIntegrator = (TransientIntegrator *)OPS_CentralDifference();

if (theTransientAnalysis != 0)
theTransientAnalysis->setIntegrator(*theTransientIntegrator);
}
}

else if (strcmp(argv[1],"CentralDifferenceAlternative") == 0) {
theTransientIntegrator = (TransientIntegrator *)OPS_CentralDifferenceAlternative();
Expand Down

0 comments on commit 6720040

Please sign in to comment.