NeoPZ
TPZYCMohrCoulomb.h
Go to the documentation of this file.
1 /* Generated by Together */// $Id: TPZYCMohrCoulomb.h,v 1.9 2010-12-13 19:34:58 diogo Exp $
2 
3 #ifndef TPZYCMOHRCOULOMB_H
4 #define TPZYCMOHRCOULOMB_H
5 
6 #include "TPZTensor.h"
7 #include "pzlog.h"
8 #include "TPZPlasticCriterion.h"
9 #ifndef WIN32
10 #include <fenv.h>//NAN DETECTOR
11 #endif
12 
13 #ifdef LOG4CXX_PLASTICITY
14 static LoggerPtr logMohr(Logger::getLogger("TPZYCMohrOriginal"));
15 #endif
16 
18 
19 public:
20 
21  enum {NYield=3};
22 
23  virtual int ClassId() const override;
24 
25 
26  const char * Name() const
27  {
28  return "TPZYCMohrCoulomb";
29  }
30 
31  void Print(std::ostream & out) const override
32  {
33  out << Name();
34  }
35 
37  {
38  return 0; // nothing to be done in this yield criterium
39  }
40 
41  void SetForceYield(const int forceYield)
42  {
43  // nothing to be done in this yield criterium
44  }
45 
53  void SetYieldStatusMode(const TPZTensor<REAL> & sigma, const REAL & A)
54  {
55  // nothing to be done in this yield criterium
56  }
57 
58 
66  void SetUp(const REAL & phi)
67  {
68  fPhi = phi;
69  }
70 
71 
79  template < class T>
80  void Compute(const TPZTensor<T> & sigma, const T & A, TPZVec<T> &result, int checkForcedYield = 0) const;
81 
89  template <class T>
90  void N(const TPZTensor<T> & sigma,const T & A, TPZVec<TPZTensor<T> > & Ndir, int checkForcedYield = 0) const;
91 
99  template <class T>
100  void H(const TPZTensor<T> & sigma,const T & A, TPZVec<T> & h, int checkForcedYield = 0) const;
101 
105  template <class T>
106  void AlphaMultiplier(const T &A, T &multiplier) const
107  {
108  multiplier = T(1.);
109  }
110 
111  void Write(TPZStream& buf, int withclassid) const override {
112  buf.Write(&fPhi);
113  }
114 
115  void Read(TPZStream& buf, void* context) override {
116  buf.Read(&fPhi);
117  }
118 
119  void YieldFunction(const TPZVec<STATE>& sigma, STATE kprev, TPZVec<STATE>& yield) const override{
120  TPZTensor<STATE> sigmaTensor;
121  sigmaTensor.XX() = sigma[0];
122  sigmaTensor.YY() = sigma[1];
123  sigmaTensor.ZZ() = sigma[2];
124  Compute(sigmaTensor, kprev, yield, 0);
125  }
126 
127  virtual int GetNYield() const override {
128  return as_integer(NYield);
129  }
130 
131 public:
132 
133  REAL fPhi;
134 
135 public:
137 
139  int NumCases()
140  {
141  return 3;
142  }
144 
147  {
148  int i;
149  for(i=0; i<6; i++) gRefTension.fData[i] = state(i,0);
150  }
151  void ComputeTangent(TPZFMatrix<REAL> &tangent, TPZVec<REAL> &coefs, int icase)
152  {
153  switch(icase)
154  {
155  case 0:
156  {
157  TPZVec<TPZTensor<REAL> > Ndir(3);
158  REAL yield = 1.e6;
159  this->N<REAL>(gRefTension,yield, Ndir, 0);
160  tangent.Redim(1,9);
161  tangent(0,0)=Ndir[0].XX();tangent(0,1)=Ndir[0].XY();tangent(0,2)=Ndir[0].XZ();
162  tangent(1,0)=Ndir[0].XY();tangent(1,1)=Ndir[0].YY();tangent(1,2)=Ndir[0].YZ();
163  tangent(2,0)=Ndir[0].XZ();tangent(2,1)=Ndir[0].YZ();tangent(2,2)=Ndir[0].ZZ();
164 
165  break;
166  }
167  case 1:
168  {
169  TPZVec<TPZTensor<REAL> > Ndir(3);
170  REAL yield = 1.e6;
171  this->N<REAL>(gRefTension,yield, Ndir, 0);
172  tangent.Redim(1,9);
173  tangent(0,0)=Ndir[0].XX();tangent(0,1)=Ndir[0].XY();tangent(0,2)=Ndir[0].XZ();
174  tangent(1,0)=Ndir[0].XY();tangent(1,1)=Ndir[0].YY();tangent(1,2)=Ndir[0].YZ();
175  tangent(2,0)=Ndir[0].XZ();tangent(2,1)=Ndir[0].YZ();tangent(2,2)=Ndir[0].ZZ();
176  break;
177  }
178  case 2:
179  {
180  TPZVec<TPZTensor<REAL> > Ndir(3);
181  REAL yield = 1.e6;
182  this->N<REAL>(gRefTension,yield, Ndir, 0);
183  tangent.Redim(1,9);
184  tangent(0,0)=Ndir[0].XX();tangent(0,1)=Ndir[0].XY();tangent(0,2)=Ndir[0].XZ();
185  tangent(1,0)=Ndir[0].XY();tangent(1,1)=Ndir[0].YY();tangent(1,2)=Ndir[0].YZ();
186  tangent(2,0)=Ndir[0].XZ();tangent(2,1)=Ndir[0].YZ();tangent(2,2)=Ndir[0].ZZ();
187  break;
188  }
189 
190  }
191  }
192 
193  void Residual(TPZFMatrix<REAL> &res,int icase)
194  {
195 
196  res.Redim(1,1);
197  TPZTensor<REAL> grad;
198 
199  switch(icase)
200  {
201 
202  case 0:
203  {
204  TPZVec<REAL> phi(3);
205  REAL yield = 1.e6;
206  this->Compute(gRefTension,yield,phi,0);
207  res(0,0) = phi[0];
208  break;
209  }
210  case 1:
211  {
212  TPZVec<REAL> phi(3);
213  REAL yield = 1.e6;
214  this->Compute(gRefTension,yield,phi,0);
215  res(0,0) = phi[1];
216  break;
217  }
218  case 2:
219  {
220  TPZVec<REAL> phi(3);
221  REAL yield = 1.e6;
222  this->Compute(gRefTension,yield,phi,0);
223  res(0,0) = phi[2];
224  break;
225  }
226  }
227 
228  }
229 
230 
231 
232 
233 
234 
235 };
236 
237 template < class T>
238 void TPZYCMohrCoulomb::Compute(const TPZTensor<T> & sigma, const T & A,TPZVec<T> &res, int checkForcedYield) const
239 {
240 
241  TPZTensor<T> EigenValues,EigenVec1,EigenVec2,EigenVec3;
242  // sigma.EigenSytem(EigenValues,EigenVec1,EigenVec2,EigenVec3);
243  T sigma1,sigma2,sigma3;
244  sigma1 = EigenValues.XX();
245  sigma2 = EigenValues.YY();
246  sigma3 = EigenValues.ZZ();
247 
248  T res1,res2,res6;
249 
250  res1=(sigma1 - sigma3) + (sigma1 + sigma3)*sin(fPhi) - T(2.)*A*cos(fPhi);//1 3
251  res6=(sigma1 - sigma2) + (sigma1 + sigma2)*sin(fPhi) - T(2.)*A*cos(fPhi);// 1 2
252  res2=(sigma2 - sigma3) + (sigma2 + sigma3)*sin(fPhi) - T(2.)*A*cos(fPhi);// 2 3
253 
254  res[0]=res1;
255  res[1]=res6;
256  res[2]=res2;
257 
258 // cout << "res[0] = " << res[0]<< endl;
259 // cout << "res[0] = " << res[1]<< endl;
260 // cout << "res[0] = " << res[2]<< endl;
261 
262 }
263 
264 template <class T>
265 void TPZYCMohrCoulomb::N(const TPZTensor<T> & sigma,const T & A, TPZVec<TPZTensor<T> > & Ndir, int checkForcedYield) const
266 {
267 
268  TPZTensor<T> EigenValues, EigenVec1,EigenVec2,EigenVec3;
269  // sigma.EigenSytem(EigenValues,EigenVec1,EigenVec2,EigenVec3);
270 
271  T umplussin,umminsin;
272  TPZTensor<T> e1(EigenVec1),e3(EigenVec3),e1b(EigenVec1),e2b(EigenVec2),e2c(EigenVec2),e3c(EigenVec3);
273  umplussin = 1.+sin(fPhi);
274  umminsin = 1.-sin(fPhi);
275 
276  //phi1 = 0
277  //( 1 + sin(phi) )* e1 x e1 - ( 1 - sin(phi) )* e3 x e3
278  e1*=umplussin;
279  e3*=umminsin;
280  e1-=e3;
281  Ndir[0]=e1;
282 
283  //phi6 =0 right
284  //( 1 + sin(phi) )* e1 x e1 - ( 1 - sin(phi) )* e2 x e2
285  e1b*=umplussin;
286  e2b*=umminsin;
287  e1b-=e2b;
288  Ndir[1]=e1b;
289 
290 
291  //phi2 = 0 left
292  //( 1 + sin(phi) )* e2 x e2 - ( 1 - sin(phi) )* e3 x e3
293  e2c*=umplussin;
294  e3c*=umminsin;
295  e2c-=e3c;
296  Ndir[2]=e2c;
297 
298 // cout << "NDIR 0 = "<< Ndir[0]<< endl;
299 // cout << "NDIR 1 = "<< Ndir[1]<< endl;
300 // cout << "NDIR 2 = "<< Ndir[2]<< endl;
301 
302 
303 }
304 
305 template <class T>
306 void TPZYCMohrCoulomb::H(const TPZTensor<T> & sigma,const T & A, TPZVec<T> & h, int checkForcedYield) const
307 {
308 
309  h[0]=2*cos(fPhi);
310  h[1]=2*cos(fPhi);
311  h[2]=2*cos(fPhi);
312 
313 
314 }
315 
316 #endif
virtual int GetNYield() const override
Contains definitions to LOGPZ_DEBUG, LOGPZ_INFO, LOGPZ_WARN, LOGPZ_ERROR and LOGPZ_FATAL, and the implementation of the inline InitializePZLOG(string) function using log4cxx library or not. It must to be called out of "#ifdef LOG4CXX" scope.
void Compute(const TPZTensor< T > &sigma, const T &A, TPZVec< T > &result, int checkForcedYield=0) const
TPZManVector< T, 6 > fData
Definition: TPZTensor.h:652
void Residual(TPZFMatrix< REAL > &res, int icase)
void LoadState(TPZFMatrix< REAL > &state)
LoadState will keep a given state as static variable of the class.
std::underlying_type< Enumeration >::type as_integer(const Enumeration value)
Definition: pzreal.h:37
T & YY() const
Definition: TPZTensor.h:578
void SetForceYield(const int forceYield)
void AlphaMultiplier(const T &A, T &multiplier) const
clarg::argBool h("-h", "help message", false)
This class implements a simple vector storage scheme for a templated class T. Utility.
Definition: pzgeopoint.h:19
void Read(TPZStream &buf, void *context) override
read objects from the stream
void SetUp(const REAL &phi)
void Print(std::ostream &out) const override
sin
Definition: fadfunc.h:63
virtual void Write(const bool val)
Definition: TPZStream.cpp:8
TPZTensor< REAL > gRefTension
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
string res
Definition: test.py:151
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
Definition: pzfmatrix.h:616
const char * Name() const
void SetYieldStatusMode(const TPZTensor< REAL > &sigma, const REAL &A)
T & XX() const
Definition: TPZTensor.h:566
T & ZZ() const
Definition: TPZTensor.h:586
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
void YieldFunction(const TPZVec< STATE > &sigma, STATE kprev, TPZVec< STATE > &yield) const override
void ComputeTangent(TPZFMatrix< REAL > &tangent, TPZVec< REAL > &coefs, int icase)
int NumCases()
Number of types of residuals.
virtual int ClassId() const override
Define the class id associated with the class.
void H(const TPZTensor< T > &sigma, const T &A, TPZVec< T > &h, int checkForcedYield=0) const
TPZFlopCounter cos(const TPZFlopCounter &orig)
Returns the cosine in radians and increments the counter of the Cosine.
Definition: pzreal.h:514
void N(const TPZTensor< T > &sigma, const T &A, TPZVec< TPZTensor< T > > &Ndir, int checkForcedYield=0) const
virtual void Read(bool &val)
Definition: TPZStream.cpp:91