hello all
i am trying to add new material to opensees.
i succeeded to build elasticppcpp according openseesdeveloper.
then i try to build Elastic-Perfectly Plastic Materi like elasticpp.
i got sources and changed the name of it to EB.
the material was build but not work
please advise me.
this is the sources
EB.cpp
-----------------
#include <EB.h>
#include <Vector.h>
#include <Channel.h>
#include <math.h>
#include <float.h>
#include <elementAPI.h>
void *
OPS_NewEB(void)
{
// Pointer to a uniaxial material that will be returned
UniaxialMaterial *theMaterial = 0;
int argc = OPS_GetNumRemainingInputArgs();
opserr << argc;
if (argc != 4 && argc != 7) {
opserr << "WARNING incoorect num args want: uniaxialMaterial EB tag E1P? E2P? eps2P? <E1N? E2N? eps2N?>" << endln;
return 0;
}
int iData[1];
double dData[6];
int numData = 1;
if (OPS_GetIntInput(&numData, iData) != 0) {
opserr << "WARNING invalid uniaxialMaterial EB tag" << endln;
return 0;
}
argc--;
numData = argc;;
if (OPS_GetDoubleInput(&numData, dData) != 0) {
opserr << "WARNING invalid double data: uniaxialMaterial EB tag E2P eps2P <E2N? eps2N?>" << endln;
return 0;
}
// Parsing was successful, allocate the material
if (argc == 3)
theMaterial = new EB(iData[0], dData[0], dData[1], dData[2]);
else
theMaterial = new EB(iData[0], dData[0], dData[1], dData[3], dData[2], dData[4], dData[5]);
if (theMaterial == 0) {
opserr << "WARNING could not create uniaxialMaterial of type EB\n";
return 0;
}
return theMaterial;
}
EB::EB()
:UniaxialMaterial(0 ,MAT_TAG_ElasticBilin),
E1P(0.0), E1N(0.0), E2P(0.0), E2N(0.0), eps2P(0.0), eps2N(0.0),
trialStrain(0.0), trialStress(0.0), trialTangent(E1P)
{
}
EB::EB(int tag, double e, double e2, double eps2)
:UniaxialMaterial(tag, MAT_TAG_ElasticBilin),
E1P(e), E1N(e), E2P(e2), E2N(e2), eps2P(eps2), eps2N(-eps2),
trialStrain(0.0), trialStress(0.0), trialTangent(E1P)
{
if (eps2 < 0.0) {
eps2P = -eps2;
eps2N = eps2;
}
}
EB::EB(int tag, double ep, double e2p, double eps2p, double en, double e2n, double eps2n)
:UniaxialMaterial(tag, MAT_TAG_ElasticBilin),
E1P(ep), E1N(en), E2P(e2p), E2N(e2n), eps2P(eps2p), eps2N(eps2n),
trialStrain(0.0), trialStress(0.0), trialTangent(E1P)
{
if (eps2p < 0.0) {
eps2P = -eps2p;
}
if (eps2n > 0.0) {
eps2N = -eps2n;
}
}
EB::~EB()
{
}
int
EB::setTrialStrain(double strain, double strainRate)
{
trialStrain = strain;
if (trialStrain > 0.0) {
if (trialStrain <= eps2P) {
trialTangent = E1P;
trialStress = E1P*trialStrain;
} else {
trialTangent = E2P;
trialStress = E1P*eps2P + (trialStrain-eps2P)*E2P;
}
} else {
if (trialStrain >= eps2N) {
trialTangent = E1N;
trialStress = E1N*trialStrain;
} else {
trialTangent = E2N;
trialStress = E1N*eps2N + (trialStrain-eps2N)*E2N;
}
}
return 0;
}
double
EB::getStrain(void)
{
return trialStrain;
}
double
EB::getStress(void)
{
return trialStress;
}
double
EB::getTangent(void)
{
return trialTangent;
}
int
EB::commitState(void)
{
return 0;
}
int
EB::revertToLastCommit(void)
{
this->setTrialStrain(commitStrain);
return 0;
}
int
EB::revertToStart(void)
{
trialStrain = 0;
trialStress = 0;
trialTangent = 0;
commitStrain = 0;
return 0;
}
UniaxialMaterial *
EB::getCopy(void)
{
EB *theCopy =
new EB(this->getTag(), E1P, E2P, eps2P, E1N, E2N, eps2N);
return theCopy;
}
int
EB::sendSelf(int cTag, Channel &theChannel)
{
int res = 0;
static Vector data(7);
data(0) = this->getTag();
data(1) = E1P;
data(2) = E1N;
data(3) = E2P;
data(4) = E2N;
data(5) = eps2P;
data(6) = eps2N;
res = theChannel.sendVector(this->getDbTag(), cTag, data);
if (res < 0)
opserr << "EB::sendSelf() - failed to send data\n";
return res;
}
int
EB::recvSelf(int cTag, Channel &theChannel,
FEM_ObjectBroker &theBroker)
{
int res = 0;
static Vector data(7);
res = theChannel.recvVector(this->getDbTag(), cTag, data);
if (res < 0)
opserr << "EB::recvSelf() - failed to recv data\n";
else {
this->setTag(data(0));
E1P = data(1);
E1N = data(2);
E2P = data(3);
E2N = data(4);
eps2P = data(5);
eps2N = data(6);
}
return res;
}
void
EB::Print(OPS_Stream &s, int flag)
{
s << "ElasticPP tag: " << this->getTag() << endln;
s << " E1P: " << E1P << " E2P: " << E2P << " eps2P: " << eps2P;
s << " E1N: " << E1N << " E2N: " << E2N << " eps2N: " << eps2N;
s << "strain: "<< trialStrain << " stress: " << trialStress << " tangent: " << trialTangent << endln;
}
--------------------
EB.h
-----------------------
#ifndef EB_h
#define EB_h
// Written: fmk
// Created: 07/98
//
// Description: This file contains the class definition for
// EB. EB provides the abstraction
// of an elastic bilinear material uniaxial material,
//
// What: "@(#) EB.h, revA"
#include <UniaxialMaterial.h>
class EB : public UniaxialMaterial
{
public:
EB(int tag, double E1, double E2, double eps2);
EB(int tag, double E1P, double E2P, double epsP, double E1N, double E2N, double eps2N);
EB();
~EB();
const char *getClassType(void) const {return "EB";};
int setTrialStrain(double strain, double strainRate = 0.0);
double getStrain(void);
double getStress(void);
double getTangent(void);
double getInitialTangent(void) {return E1P;};
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);
protected:
private:
double E1P, E1N, E2P, E2N; // elastic modulus
double eps2P; // strain at which E2P takes place
double eps2N; // strain at which E2P takes place
double trialStrain, trialStress, trialTangent, commitStrain;
};
#endif
--------------------
best regards
a problem to add element
Moderators: silvia, selimgunay, Moderators
Re: a problem to add element
2 problems at the start of the .cpp file:
1) looks like you are missing some #ifdef
2) the name of the procedure at the start should be OPS_EB not OPS_NewEB.
copy the start of the elasticspp example to get this right.
1) looks like you are missing some #ifdef
2) the name of the procedure at the start should be OPS_EB not OPS_NewEB.
copy the start of the elasticspp example to get this right.