Skip to content

Commit

Permalink
K. Mackie - adding set/updateParameter for multi-linear material
Browse files Browse the repository at this point in the history
  • Loading branch information
mhscott committed Aug 11, 2021
1 parent 1233e77 commit ce7cd4e
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 36 deletions.
76 changes: 73 additions & 3 deletions SRC/material/uniaxial/MultiLinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,20 @@
//
// What: "@(#) MultiLinear.C, revA"

#include <math.h>
#include <float.h>
#include <stdlib.h>
#include <stdio.h>

#include <MultiLinear.h>
#include <Vector.h>
#include <Matrix.h>
#include <ID.h>
#include <Channel.h>
#include <math.h>
#include <float.h>
#include <stdlib.h>
#include <Information.h>
#include <Parameter.h>

#include <OPS_Globals.h>
#include <elementAPI.h>

void*
Expand Down Expand Up @@ -380,3 +384,69 @@ MultiLinear::Print(OPS_Stream& s, int flag)
s << "tSlope: " << tSlope << "numSlope: " << numSlope << endln;
s << data;
}

// AddingSensitivity:BEGIN ///////////////////////////////////
int
MultiLinear::setParameter(const char **argv, int argc, Parameter &param)
{
// trying to make this a little more general for arbitrary numbers of points
// expecting parameters named stress1, strain1, stress3, etc.
int dindx = -1;

if (argc < 2) {
return -1;
}

dindx = atoi(argv[1]);
if (dindx < 1 || dindx > numSlope) {
return -1;
}

if (strcmp(argv[0],"stress") == 0) {
param.setValue( data(dindx-1,3) );
return param.addObject(100+dindx, this);
}
if (strcmp(argv[0],"strain") == 0) {
param.setValue( data(dindx-1,1) );
return param.addObject(200+dindx, this);
}

return -1;
}


int
MultiLinear::updateParameter(int parameterID, Information &info)
{
int dindx = 0;
double sprev = 0;
double eprev = 0;

if (parameterID == -1)
return -1;
else if (parameterID > 100 && parameterID <= 100+numSlope) {
// stress terms
dindx = parameterID-100;
data(dindx-1,2) = -1.0*info.theDouble;
data(dindx-1,3) = info.theDouble;
}
else if (parameterID > 200 && parameterID <= 200+numSlope) {
// strain terms
dindx = parameterID-200;
data(dindx-1,0) = -1.0*info.theDouble;
data(dindx-1,1) = info.theDouble;
}
else {
return -1;
}

// update slopes
if (dindx > 1) {
sprev = data(dindx-2,3);
eprev = data(dindx-2,1);
}
data(dindx-1,4) = (data(dindx-1,3) - sprev) / (data(dindx-1,1) - eprev);
data(dindx-1,5) = data(dindx-1,1) - eprev;

return 0;
}
69 changes: 36 additions & 33 deletions SRC/material/uniaxial/MultiLinear.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,44 +37,47 @@
class MultiLinear : public UniaxialMaterial
{
public:
MultiLinear(int tag, const Vector &s, const Vector &e);
MultiLinear();
virtual ~MultiLinear();

const char *getClassType(void) const {return "MultiLinear";};

int setTrialStrain(double strain, double strainRate = 0.0);
double getStrain(void);
double getStress(void);
double getTangent(void);

double getInitialTangent(void) {return data(0,4);};

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);
MultiLinear(int tag, const Vector &s, const Vector &e);
MultiLinear();
virtual ~MultiLinear();

const char *getClassType(void) const {return "MultiLinear";};

int setTrialStrain(double strain, double strainRate = 0.0);
double getStrain(void);
double getStress(void);
double getTangent(void);

double getInitialTangent(void) {return data(0,4);};

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);

int setParameter(const char **argv, int argc, Parameter &param);
int updateParameter(int parameterID, Information &info);

protected:

private:
Matrix data;
int numSlope;
int tSlope;
Matrix data;
int numSlope;
int tSlope;

double tStrain; // current t strain
double tStress; // current t stress
double tTangent; // current t tangent
double cStrain; // last ced strain
double cStress; // last ced stress
double cTangent; // last cted tangent
double tStrain; // current t strain
double tStress; // current t stress
double tTangent; // current t tangent
double cStrain; // last ced strain
double cStress; // last ced stress
double cTangent; // last cted tangent
};

#endif

0 comments on commit ce7cd4e

Please sign in to comment.