Discovering Opensees: Surfing The Waves of Opensees: Adding Your Code To Opensees
Discovering Opensees: Surfing The Waves of Opensees: Adding Your Code To Opensees
Information Technology
Database, Visualization, Frameworks,
Parallel & Grid/Network libraries
Building Blocks for Modern Simulation
OpenSees Goals
To use modern software techniques to evolve an extensible
finite element software platform for earthquake engineering that
would encompass both structural & geotechnical engineering
and be able to change with the rapidly changing hardware
resources.
Output
OpenSees Abstract Classes
Parallel&Distributed
Output
To Add a New Class you must:
1) Provide Code that meets the Interface
of the appropriate super-class
2) you must BUILD THE LIBRARY
3) make it accessible to the program.
svn://opensees.berkeley.edu/usr/local/svn/OpenSees/trunk/DEVELOPER
TortoiseSVN for Windows Users
your
Source Code Tree in
DEVELOPER
Makefile
WindowsInstructions
UnixInstructions
Trapezoidal.h
Trapezoidal.cpp cpp c fortran cpp c fortran
int commitState(void);
int revertToLastCommit(void);
int revertToStart(void);
UniaxialMaterial *getCopy(void);
int sendSelf(int commitTag, Channel &theChannel);
int recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker);
void Print(OPS_Stream &s, int flag = 0);
private: data unique to
double fyp, fyn; // pos & neg yield stress
double ezero, E,ep; // init strain, elastic mod
material includes:
double ep; // plastic strain at last commit Material parameters,
double trialStrain, trialStress, trialTangent; & State variables
double commitStrain, commitStress, commitTangent;
};
ElasticPPcpp::ElasticPPcpp(int tag, double e, double eyp)
:UniaxialMaterial(tag, 0),
ezero(0), E(e), ep(0.0) trialStrain(0.0),trialStress(0.0),trialTangent(e),
commitStreain(0.0),commitStress(0.0),commitTangent(e)
{
fyp=E*eyp;
fyn = -fyp;
}
ElasticPPcpp::ElasticPPcpp()
:UniaxialMaterial(tag, 0)
fyp(0),fyn(0),ezero(0), E(0),ep(0),
trialStrain(0.0),trialStress(0.0),trialTangent(0),
commitStrain(0.0),commitStress(0.0),commitTangent(e){
}
ElasticPPcpp::~ElasticPPcpp
{
// does nothing .. No memory to clean up
}
UniaxialMaterial *ElasticPPcpp::getCopy(void)
{
ElasticPPcpp *theCopy = new ElasticPPcpp(this->getTag(), E, fyp/E);
return theCopy;
};
Hardest Method to Write
ElasticPPcpp::setTrialStrain(double strain, double strainRate)
{
if (fabs(trialStrain - strain) < DBL_EPSILON)
return 0;
trialStrain = strain;
double sigtrial; // trial stress
double f; // yield function
// compute trial stress
sigtrial = E * ( trialStrain - ezero - ep );
// evaluate yield function
if ( sigtrial >= 0.0 )
f = sigtrial - fyp;
else
f = -sigtrial + fyn;
double fYieldSurface = - E * DBL_EPSILON;
if ( f <= fYieldSurface ) {
// elastic
trialStress = sigtrial;
trialTangent = E;
} else {
// plastic
if ( sigtrial > 0.0 ) {
trialStress = fyp;
} else {
trialStress = fyn;
}
trialTangent = 0.0;
}
return 0;
}
double
ElasticPPcpp::getStrain(void)
{
return trialStrain;
}
double
ElasticPPcpp::getStress(void)
{
return trialStress;
}
double
ElasticPPcpp::getTangent(void)
{
return trialTangent;
}
int
ElasticPPcpp::revertToLastCommit(void)
{
trialStrain = commitStrain;
trialTangent = commitTangent;
trialStress = commitStress;
return 0;
}
OPS_Export void * Interpreter looking for this function in lib
OPS_ElasticPPcpp()
{ You can give yourself some
if (numElasticPPcpp == 0) {
opserr << "ElasticPPcpp unaxialKUDOS, e.g.byplease
material - Written reference
fmk UC Berkeley\n;
}
numElasticPPcpp =1; if you used this
// Pointer to a uniaxial material that will be returned
UniaxialMaterial *theMaterial = 0;
int iData[1];
double dData[2];
int numData; parse the script for
three material parameters
numData = 1;
if (OPS_GetIntInput(&numData, iData) != 0) {
opserr << "WARNING invalid uniaxialMaterial ElasticPP tag" << endln;
return 0;
}
numData = 2;
if (OPS_GetDoubleInput(&numData, dData) != 0) {
opserr << "WARNING invalid E & ep\n";
return 0;
} Function returns new material
theMaterial = new ElasticPPcpp(iData[0], dData[0], dData[1]);
return theMaterial;
}
C & Fortran Procedural
Languages Can Also Be Used
OPS_Export void
elasticPPc (matObj *thisObj, SUBROUTINE ELASTICPPF(matObj,model,strain,tang,stress,isw,err
modelState *model,
double *strain, !DEC$ IF DEFINED (_DLL)
double *tang, !DEC$ ATTRIBUTES DLLEXPORT :: ELASTICPPF
double *stress, !DEC$ END IF
int *isw, use materialTypes
int *result) use materialAPI
{ implicit none
*result = 0; IF (isw.eq.ISW_INIT) THEN
1)File>New>Project
4.SelectWin32Project
3.SelectWin32
1.GiveDLLnameElasAcPPcpp
5.SelectOK
2.GiveLocaAon
SelectApplicaAonSeGngs
1.SelectDLL
2.SelectDLL
3.SelectFinish
Add Files To Project
1. RightClickonSourceFiles
2. SelectAddExisAng
3. NavigatetoDEVELOPER/material/cppdirectory
4. SelecttheElasAcPPcpp.cppand.hle
5. SelectAdd
1)SelectBuild>SoluAon
1. RightClickonElasAcPPcppProject
2. SelectProperAes
3. SelectC/C++
IT FAILS!
4.IncludecoreinaddiAonalincludedirectories
3.SelectAllConguaraAonsfromPullDownMenu
1. SelectC/C++
2. SelectGeneral
1)SelectBuild>SoluAon
IT FAILS!
1. RightClickonSourceFiles
2. SelectAddExisAng
3. NavigatetoDEVELOPER/coredirectory
4. SelecttheAll.cppand.hle
5. SelectAdd
1.SelectBuildSoluAon
Copy ElasticPPcpp.dll from
location into current directory
2. cd DEVELOPER/material/cpp
3. type make
if you type ls you should see the .so and you
Can test it using >OpenSees example1.tcl