ElasticIsotropic plainstrain material

For developers writing C++, Fortran, Java, code who have questions or comments to make.

Moderators: silvia, selimgunay, Moderators

Post Reply
debasismpt
Posts: 10
Joined: Mon May 13, 2013 7:48 am
Location: IIT ROORKEE

ElasticIsotropic plainstrain material

Post by debasismpt »

i have written a code for ElasticIsotropic ND-material for plain-strain element as given below. But the result i am getting is not matching with ElasticIsotropic material found in opensees. Can anybody tell me what is the reason behind it.



#include <elementAPI.h>
#include "soilE.h"
#include <Vector.h>
#include <Channel.h>
#include <OPS_Globals.h>
#include <Channel.h>
#include <Information.h>
#include <Parameter.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#ifdef _USRDLL
#define OPS_Export extern "C" _declspec(dllexport)
#elif _MACOSX
#define OPS_Export extern "C" __attribute__((visibility("default")))
#else
#define OPS_Export extern "C"
#endif

Vector soilE::sigma(3);
Matrix soilE::D(3,3);
//reading data from command and store these in a array
OPS_Export void *
OPS_soilE()
{ NDMaterial *theMaterial = 0;
int numArgs = OPS_GetNumRemainingInputArgs();
if (numArgs < 4) {
opserr << "Want: nDMaterial soilE $tag $E $nu $rho" << endln;
return 0;
}
int iData[1];
double dData[3];
int numData = 1;
if (OPS_GetInt(&numData, iData) != 0) {
opserr << "WARNING invalid integer tag: nDMaterial soilE\n";
return 0;
}
numData=3;
if (OPS_GetDouble(&numData, dData) != 0) {
opserr << "WARNING invalid data: nDMaterial soilE : " << iData[0] <<"\n";
return 0;
}

theMaterial = new soilE(iData[0], dData[0], dData[1], dData[2]);
return theMaterial;
}

//null constructor
soilE::soilE()
:NDMaterial(0,0),strain_n(3), strain_nplus1(3)
{ strain_n.Zero();
strain_nplus1.Zero();
}

//full constructor
soilE::soilE(int tag, double e, double n, double r)
:NDMaterial(tag,0),strain_n(3),strain_nplus1(3)
{
//initialize variables
strain_n.Zero();
strain_nplus1.Zero();

E=e;
nu=n;
rho=r;

}


soilE::~soilE()
{
//destructor
}


NDMaterial *soilE::getCopy(void) {

soilE *theCopy = new soilE(*this);
theCopy->strain_nplus1 = strain_nplus1;
theCopy->strain_n = strain_n;
return theCopy;
};


NDMaterial * soilE::getCopy(const char *code) {
if (strcmp(code,this->getType()) == 0) {
soilE *copy = new soilE(*this);
copy->strain_nplus1 = strain_nplus1;
copy->strain_n = strain_n;
return copy;
}
return 0;}

const char*
soilE::getType (void) const
{
return "PlaneStrain";
}
double
soilE::getRho()
{
return rho ;
}

int
soilE::commitState(void)
{
strain_n=strain_nplus1;
return 0;
}

int
soilE::revertToLastCommit (void)
{
strain_nplus1=strain_n;
return 0;
}

int
soilE::revertToStart (void)
{
strain_n.Zero();
strain_nplus1.Zero();
return 0;
}


int
soilE::setTrialStrain (const Vector &v)
{
strain_nplus1 = v;
return 0;
}

const Matrix&
soilE::getTangent (void)
{
double mu2 = E/(1.0+nu);
double lam = nu*mu2/(1.0-2.0*nu);
double mu = 0.50*mu2;
mu2 += lam;

D(0,0) = D(1,1) = mu2;
D(0,1) = D(1,0) = lam;
D(2,2) = mu;

return D;
}

const Matrix&
soilE::getInitialTangent (void)
{
double mu2 = E/(1.0+nu);
double lam = nu*mu2/(1.0-2.0*nu);
double mu = 0.50*mu2;
mu2 += lam;

D(0,0) = D(1,1) = mu2;
D(0,1) = D(1,0) = lam;
D(2,2) = mu;

return D;

}
const Vector&
soilE::getStrain (void)
{
return strain_nplus1;
}

const Vector&
soilE::getStress (void)
{
double mu2 = E/(1.0+nu);
double lam = nu*mu2/(1.0-2.0*nu);
double mu = 0.50*mu2;

double eps0 = strain_nplus1(0);
double eps1 = strain_nplus1(1);

mu2 += lam;

//sigma = D*epsilon;
sigma(0) = mu2*eps0 + lam*eps1;
sigma(1) = lam*eps0 + mu2*eps1;
sigma(2) = mu*strain_nplus1(2);

return sigma;
}

int
soilE::sendSelf(int commitTag, Channel &theChannel)
{

static Vector data(7);
data(0) = this->getTag();
data(1) = E;
data(2) = nu;
data(3) = rho;

data(4) =strain_nplus1(0);
data(5) =strain_nplus1(1);
data(6) =strain_nplus1(2);

int res = theChannel.sendVector(this->getDbTag(), commitTag, data);
if (res < 0) {
opserr << "soilE::sendSelf -- could not send Vector\n";
return res;
}

return res;
}

int
soilE::recvSelf(int commitTag, Channel &theChannel,
FEM_ObjectBroker &theBroker)
{
static Vector data(7);

int res = theChannel.recvVector(this->getDbTag(), commitTag, data);
if (res < 0) {
opserr << "soilE::sendSelf -- could not send Vector\n";
return res;
}

this->setTag((int)data(0));
E = data(1);
nu = data(2);
rho = data(3);

strain_nplus1(0)=data(4);
strain_nplus1(1)=data(5);
strain_nplus1(2)=data(6);

return res;
}

void
soilE::Print(OPS_Stream &s, int flag)
{

s << " E: " << E << endln;
s << " nu: " << nu << endln;
s << " rho:" << rho<< endln;

}
Post Reply