NeoPZ
TPZLadeKimThermoForceA.h
Go to the documentation of this file.
1 // $Id: TPZLadeKimThermoForceA.h,v 1.10 2009-06-08 03:19:34 erick Exp $
2 
3 #ifndef TPZLADEKIMTHERMOFORCEA_H
4 #define TPZLADEKIMTHERMOFORCEA_H
5 
6 #include "pzvec.h"
7 #include "pzreal.h"
8 
9 #ifndef CHECKCONV
10 #define CHECKCONV
11 #include "checkconv.h"
12 #endif
13 
18 public:
19 
20  public:
21 int ClassId() const override;
22 
24  {
25  }
26 
28  {
29  fRho = source.fRho;
30  fD = source.fD;
31  fPa = source.fPa;
32  }
33 
35  {
36  fRho = source.fRho;
37  fD = source.fD;
38  fPa = source.fPa;
39  return *this;
40  }
41 
42  void Write(TPZStream &buf, int withclassid) const override{
43  buf.Write(&fRho);
44  buf.Write(&fD);
45  buf.Write(&fPa);
46  }
47 
48  void Read(TPZStream& buf, void* context) override {
49  buf.Read(&fRho);
50  buf.Read(&fD);
51  buf.Read(&fPa);
52  }
53 
54  const char * Name() const
55  {
56  return "TPZLadeKimThermoForceA";
57  }
58 
59  void Print(std::ostream & out) const
60  {
61  out << "\n" << this->Name();
62  out << "\n fRho = " << fRho;
63  out << "\n fD = " << fD;
64  out << "\n fPa = " << fPa;
65  }
66 
67 
68 
69  void SetUp(REAL ksi1, REAL p, REAL h, REAL C, REAL pa)
70  {
71  fRho = p / h;
72  fD = C / pow( 27. * ksi1 + 3., fRho);
73  fPa = pa;
74  }
75 
76 
80  template <class T>
81  T Compute(const T & alpha) const;
82 
86  REAL Compute(const REAL & alpha) const;
87 
91  template <class T>
92  T ComputeTangent(const T & alpha) const;
93 
94 public:
95 
105  REAL fRho;
106 
116  REAL fD;
117 
121  REAL fPa;
122 
123 
124 public:
126 
130  int NumCases()
131  {
132  return 1;
133  }
134 
135  static REAL gRefThermoForce;
140  {
141  #ifdef LOG4CXX_PLASTICITY
142  LoggerPtr logger(Logger::getLogger("plasticity.ladekimthermoforce"));
143  #endif
144  gRefThermoForce = state(0,0);
145  #ifdef LOG4CXX_PLASTICITY
146  std::stringstream sout;
147  sout << "Plastic Work " << state;
148  LOGPZ_DEBUG(logger,sout.str().c_str());
149  #endif
150  }
151 
152  void ComputeTangent(TPZFMatrix<REAL> &tangent, TPZVec<REAL> &, int icase)
153  {
154  #ifdef LOG4CXX_PLASTICITY
155  LoggerPtr logger(Logger::getLogger("plasticity.ladekimthermoforce"));
156  #endif
157 
158  switch(icase)
159  {
160  case 0:
161  //Compute
162  tangent.Redim(1,1);
163  tangent(0,0) = ComputeTangent(gRefThermoForce);
164  break;
165 
166  break;
167  }
168  #ifdef LOG4CXX_PLASTICITY
169  std::stringstream sout;
170  sout << "Matriz tangent " << tangent;
171  LOGPZ_DEBUG(logger,sout.str().c_str());
172  #endif
173  }
174 
175  void Residual(TPZFMatrix<REAL> &res,int icase)
176  {
177  #ifdef LOG4CXX_PLASTICITY
178  LoggerPtr logger(Logger::getLogger("plasticity.ladekimthermoforce"));
179  #endif
180  switch(icase)
181  {
182  case 0:
183  //Compute
184  res.Redim(1,1);
185  res(0,0) = Compute(gRefThermoForce);
186  break;
187 
188  }
189  #ifdef LOG4CXX_PLASTICITY
190  std::stringstream sout;
191  sout << "Residual vector " << res;
192  LOGPZ_DEBUG(logger,sout.str().c_str());
193  #endif
194  }
195 
196 static void CheckConv()
197 {
198  // Creating the LadeNelsonElasticResponse obejct
199  TPZLadeKimThermoForceA TFALadeNelson;
200  // setup with data from Sacramento River Sand
201  // Lade, Poul V., Kim, Moon K. Single Hardening Constitutive Model
202  // for soil, Rock and Concrete. Int. J. Solids Structures, vol32
203  // No14 pp 1963-1978,1995
204  REAL m = 0.093,
205  p = 1.82,
206  h = 0.765,
207  C = 0.396e-4,
208  pa = 14.7;
209  REAL ksi1 = 0.00155 * pow(m, -1.27);
210  TFALadeNelson.SetUp(ksi1, p, h, C, pa);
211  TPZFNMatrix<1> Alpha(1, 1, 1.7);
212  TPZFNMatrix<1> Range(1, 1, Alpha(0,0)*(1./19.));
213  TPZVec< REAL > Coefs(1,1.);
214  CheckConvergence(TFALadeNelson, Alpha, Range, Coefs);
215 }
216 
218 
219 };
220 
221 
222 template < class T >
223 inline T TPZLadeKimThermoForceA::Compute(const T & alpha) const
224 {
225  T localAlpha(alpha);
226  //if(fabs(TPZExtractVal::val(localAlpha) ) < 1.e-60)localAlpha.val()+=1.e-60;
227  if(TPZExtractVal::val(localAlpha) < 1.e-60)localAlpha.val() = 1.e-60;
228  REAL invRho = 1./fRho;
229  //return T( pow( fD, - invRho ) ) * pow( localAlpha / T(fPa), invRho );
230  return T( pow( fD, - invRho ) ) * exp( T(invRho) * log( localAlpha / T(fPa) ) );
231 }
232 
233 inline REAL TPZLadeKimThermoForceA::Compute(const REAL & alpha) const
234 {
235  REAL localAlpha = alpha;
236  //if(fabs(localAlpha) < 1.e-60)localAlpha+=1.e-60;
237  if( localAlpha < 1.e-60)localAlpha = 1.e-60;
238  //if(fabs(alpha) < 1.e-12) return 0.;
239  REAL invRho = 1./fRho;
240  return pow( fD, - invRho ) * pow( alpha / fPa, invRho );
241 }
242 
243 template < class T >
244 inline T TPZLadeKimThermoForceA::ComputeTangent(const T & alpha) const
245 {
246  REAL invRho = 1./fRho;
247  return T( pow( fD, - invRho ) * invRho / fPa ) * pow( alpha / fPa, invRho-1.);
248 }
249 
250 #endif //TPZTHERMOFORCEA_H
void CheckConvergence(TConv &obj, TPZFMatrix< STATE > &state, TPZFMatrix< STATE > &range, TPZVec< REAL > &coefs)
Implements a general procedure to check whether the class TConv implements a consistente tangent matr...
Definition: checkconv.h:23
void LoadState(TPZFMatrix< REAL > &state)
Templated vector implementation.
void ComputeTangent(TPZFMatrix< REAL > &tangent, TPZVec< REAL > &, int icase)
clarg::argBool h("-h", "help message", false)
void Read(TPZStream &buf, void *context) override
read objects from the stream
void Residual(TPZFMatrix< REAL > &res, int icase)
virtual void Write(const bool val)
Definition: TPZStream.cpp:8
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
Definition: pzlog.h:87
T Compute(const T &alpha) const
string res
Definition: test.py:151
int ClassId() const override
Define the class id associated with the class.
static REAL val(const int number)
Definition: pzextractval.h:21
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
Definition: pzfmatrix.h:616
T ComputeTangent(const T &alpha) const
TPZLadeKimThermoForceA & operator=(const TPZLadeKimThermoForceA &source)
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
TPZFlopCounter pow(const TPZFlopCounter &orig, const TPZFlopCounter &xp)
Returns the power and increments the counter of the power.
Definition: pzreal.h:487
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ log
Definition: tfadfunc.h:130
const char * Name() const
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ exp
Definition: tfadfunc.h:125
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
Contains the declaration of TPZFlopCounter class and TPZCounter struct.
clarg::argString m("-m", "input matrix file name (text format)", "matrix.txt")
Contains the implementation of the CheckConvergence function.
This class defines the interface to save and restore objects from TPZStream objects. Persistency.
Definition: TPZSavable.h:67
void SetUp(REAL ksi1, REAL p, REAL h, REAL C, REAL pa)
void Print(std::ostream &out) const
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
Definition: pzfmatrix.h:716
TPZLadeKimThermoForceA(const TPZLadeKimThermoForceA &source)
virtual void Read(bool &val)
Definition: TPZStream.cpp:91