NeoPZ
TPZYCTresca.h
Go to the documentation of this file.
1 
5 #ifndef TPZYCTRESCA_H
6 #define TPZYCTRESCA_H
7 
8 #include "TPZTensor.h"
9 #include "pzlog.h"
10 #include "TPZSavable.h"
11 #include "TPZPlasticCriterion.h"
12 
13 
15 
16 public:
17 
18  enum {NYield = 1};
19 
20  public:
21 virtual int ClassId() const override;
22 
23 
24  const char * Name() const
25  {
26  return "TPZYCTresca";
27  }
28 
29  void Print(std::ostream & out) const override
30  {
31  out << Name();
32  }
33 
35  {
36  return 0; // nothing to be done in this yield criterium
37  }
38 
39  void SetForceYield(const int forceYield)
40  {
41  // nothing to be done in this yield criterium
42  }
43 
51  void SetYieldStatusMode(const TPZTensor<REAL> & sigma, const REAL & A)
52  {
53  // nothing to be done in this yield criterium
54  }
55 
63  template < class T>
64  void Compute(const TPZTensor<T> & sigma, const T & A, TPZVec<T> &result, int checkForcedYield = 0) const;
65 
73  template <class T>
74  void N(const TPZTensor<T> & sigma,const T & A, TPZVec<TPZTensor<T> > & Ndir, int checkForcedYield = 0) const;
75 
83  template <class T>
84  void H(const TPZTensor<T> & sigma,const T & A, TPZVec<T> & h, int checkForcedYield = 0) const
85  {
86  h[0] = 1.;
87  }
88 
92  template <class T>
93  void AlphaMultiplier(const T &A, T &multiplier) const
94  {
95  multiplier = T(1.);
96  }
97 
98  void Read(TPZStream& buf, void* context) override {
99 
100  }
101 
102  void Write(TPZStream& buf, int withclassid) const override {
103 
104  }
105  void YieldFunction(const TPZVec<STATE>& sigma, STATE kprev, TPZVec<STATE>& yield) const override{
106  TPZTensor<STATE> sigmaTensor;
107  sigmaTensor.XX() = sigma[0];
108  sigmaTensor.YY() = sigma[1];
109  sigmaTensor.ZZ() = sigma[2];
110  Compute(sigmaTensor, kprev, yield, 0);
111  }
112 
113  virtual int GetNYield() const override {
114  return as_integer(NYield);
115  }
116 
117 
118 
119 protected:
126  template <class T>
127  void GradTheta(const TPZTensor<T> & sigma,T & theta,TPZTensor<T> & gradtheta) const;
128 
130  template <class T>
131  T InverseAngle(const TPZTensor<T> &deviatoric) const;
132 
134  template <class T>
135  void GradInverseAngle(const TPZTensor<T> &sigma, TPZTensor<T> &grad) const;
136 
137  public:
138 
140 
142  int NumCases()
143  {
144  return 5;
145  }
147 
150  {
151  int i;
152  for(i=0; i<6; i++) gRefTension.fData[i] = state(i,0);
153  }
154  void ComputeTangent(TPZFMatrix<REAL> &tangent, TPZVec<REAL> &coefs, int icase)
155  {
156  switch(icase)
157  {
158  case 0:
159  {
160  TPZTensor<REAL> grad;
161  this->gRefTension.dJ2(grad);
162  tangent.Redim(1,6);
163  int i;
164  for(i=0; i<6; i++)
165  {
166  tangent(0,i) = grad.fData[i];
167  }
168  }
169  break;
170  case 1:
171  {
172  TPZTensor<REAL> grad;
173  this->gRefTension.dJ3(grad);
174  tangent.Redim(1,6);
175  int i;
176  for(i=0; i<6; i++)
177  {
178  tangent(0,i) = grad.fData[i];
179  }
180  }
181  break;
182  case 2:
183  {
184  TPZTensor<REAL> grad;
185  this->GradInverseAngle(gRefTension,grad);
186  tangent.Redim(1,6);
187  int i;
188  for(i=0; i<6; i++)
189  {
190  tangent(0,i) = grad.fData[i];
191  }
192  }
193  break;
194  case 3:
195  {
196  REAL theta;
197  TPZTensor<REAL> grad;
198  this->GradTheta<REAL>(gRefTension,theta,grad);
199  tangent.Redim(1,6);
200  int i;
201  for(i=0; i<6; i++)
202  {
203  tangent(0,i) = grad.fData[i];
204  }
205  }
206  break;
207  case 4:
208  {
209  REAL yield = 1.e6;
210  TPZVec<TPZTensor<REAL> > grad(1);
211  this->N<REAL>(gRefTension,yield,grad,0);
212  tangent.Redim(1,6);
213  int i;
214  for(i=0; i<6; i++)
215  {
216  tangent(0,i) = grad[0].fData[i];
217  }
218  }
219  }
220  }
221 
222  void Residual(TPZFMatrix<REAL> &res,int icase)
223  {
224  REAL inv = this->InverseAngle(gRefTension);
225  res.Redim(1,1);
226  TPZTensor<REAL> grad;
227  switch(icase)
228  {
229  case 0:
230  res(0,0) = gRefTension.J2();
231  break;
232  case 1:
233  res(0,0) = gRefTension.J3();
234  break;
235  case 2:
236  res(0,0) = inv;
237  break;
238  case 3:
239  REAL theta;
240  GradTheta<REAL>(gRefTension,theta,grad);
241  res(0,0) = theta;
242  break;
243  case 4:
244  TPZVec<REAL> phi(1);
245  REAL yield = 1.e6;
246  this->Compute(gRefTension,yield,phi,0);
247  res(0,0) = phi[0];
248  break;
249  }
250  }
251 
253 public:
254 
255 
256 };
257 
258 
259 template < class T>
260 void TPZYCTresca::Compute(const TPZTensor<T> & sigma, const T & A,TPZVec<T> &result, int checkForcedYield) const
261 {
262  T inverseangle = InverseAngle(sigma);
263  T theta = asin(inverseangle)*(1./3.);
264  result[0] = sqrt(sigma.J2())*cos(theta)*2.-A;
265 }
266 
267 template <class T>
268 void TPZYCTresca::N(const TPZTensor<T> & sigma,const T & A, TPZVec<TPZTensor<T> > & Ndir, int checkForcedYield) const
269 {
270 #ifdef LOG4CXX_PLASTICITY
271  LoggerPtr logger(Logger::getLogger("plasticity.yctresca"));
272 #endif
273 
274 /* T invangle = InverseAngle(sigma);
275  T theta = (1./3.)*asin(invangle);
276  TPZTensor<T> gradinvangle;
277  GradInverseAngle(sigma,gradinvangle);
278  T derivasin = 1./sqrt(1.-invangle*invangle);*/
279 // T invangle;
280  T theta;
281  TPZTensor<T> gradtheta;
282  //T derivasin;
283  //GradASinInvAngle (sigma,invangle,theta,gradinvangle,derivasin);
284 #ifdef LOG4CXX_PLASTICITY
285  {
286  std::stringstream sout;
287  sout << "A " << A << " N: sigma " << sigma;
288  LOGPZ_DEBUG(logger,sout.str().c_str());
289  }
290 #endif
291  GradTheta<T> (sigma,theta,gradtheta);
292 #ifdef LOG4CXX_PLASTICITY
293  {
294  std::stringstream sout;
295  sout << "N: theta " << theta;
296  sout << "gradtheta " << gradtheta;
297  LOGPZ_DEBUG(logger,sout.str().c_str());
298  }
299 #endif
300 
301  T sqj2 = sqrt(sigma.J2());
302  TPZTensor<T> dj2;
303  sigma.dJ2(dj2);
304 
305  TPZTensor<T> resultdtheta(gradtheta);
306  resultdtheta.Multiply(sqj2*sin(theta),T(-2.));
307  TPZTensor<T> resultdj2(dj2);
308  resultdj2.Multiply(cos(theta)/sqj2,T(1.));
309  TPZTensor<T> result(resultdtheta);
310  result.Add(resultdj2,1.);
311 #ifdef LOG4CXX_PLASTICITY
312  {
313  std::stringstream sout;
314  sout << "sqj2 " << sqj2;
315  sout << " theta" << theta;
316  T coco = sin (theta);
317  sout << " sintheta " << coco;
318  sout << "dj2" << dj2;
319  sout << "N: resultdtheta " << theta;
320  LOGPZ_DEBUG(logger,sout.str().c_str());
321  }
322  {
323  std::stringstream sout;
324  sout << __PRETTY_FUNCTION__ << std::endl;
325  sout << "gradtheta " << gradtheta << std::endl;
326  sout << "Result " << result;
327  LOGPZ_DEBUG(logger,sout.str().c_str());
328  }
329 #endif
330  Ndir[0] = result;
331 }
332 
333 template <class T>
334 T TPZYCTresca::InverseAngle(const TPZTensor<T> &deviatoric) const
335 {
336  T j2 = deviatoric.J2();
337  T j3 = deviatoric.J3();
338  if(TPZExtractVal::val(j2) < 1.e-6) return T(0.);
339  return j3/j2/sqrt(j2)*(-3.*sqrt(3.)/2.);
340 }
341 
342 template <class T>
344 {
345  T j2 = sigma.J2();
346  if(TPZExtractVal::val(j2) < 1.e-6) return;
347  T j3 = sigma.J3();
348  TPZTensor<T> dj2,dj3;
349  sigma.dJ2(dj2);
350  sigma.dJ3(dj3);
351  //if(j2 < 1.e-6) return;
352  dj3.Multiply(1./(j2*sqrt(j2)),-3.*sqrt(3.)/2.);
353  dj2.Multiply(j3/(j2*j2*sqrt(j2)),(9./4.)*sqrt(3.));
354  dj2.Add(dj3,1.);
355  grad = dj2;
356  return;
357 }
358 
359 template <class T>
360 void TPZYCTresca::GradTheta(const TPZTensor<T> & sigma,T & theta, TPZTensor<T> & gradtheta) const
361 {
362 
363 #ifdef LOG4CXX_PLASTICITY
364  LoggerPtr logger(Logger::getLogger("plasticity.yctresca"));
365 
366  {
367  LOGPZ_DEBUG(logger,__PRETTY_FUNCTION__);
368  }
369 #endif
370  T invangle = InverseAngle(sigma);
371  theta = (1./3.)*asin(invangle);
372  GradInverseAngle(sigma,gradtheta);
373  T derivasin = 1./sqrt(1.-invangle*invangle);
374  gradtheta.Multiply(derivasin,1./3.);
375 }
376 
377 #endif //TPZYCTRESCA_H
Contains declaration of the TPZSavable class which defines the interface to save and restore objects ...
void Add(const TPZTensor< T1 > &tensor, const T2 &constant)
Definition: TPZTensor.h:757
void Multiply(const T1 &multipl, const T2 &constant)
Definition: TPZTensor.h:766
void Read(TPZStream &buf, void *context) override
read objects from the stream
Definition: TPZYCTresca.h:98
void Compute(const TPZTensor< T > &sigma, const T &A, TPZVec< T > &result, int checkForcedYield=0) const
Definition: TPZYCTresca.h:260
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.
TPZManVector< T, 6 > fData
Definition: TPZTensor.h:652
void YieldFunction(const TPZVec< STATE > &sigma, STATE kprev, TPZVec< STATE > &yield) const override
Definition: TPZYCTresca.h:105
static TPZTensor< REAL > gRefTension
Definition: TPZYCTresca.h:146
std::underlying_type< Enumeration >::type as_integer(const Enumeration value)
Definition: pzreal.h:37
T & YY() const
Definition: TPZTensor.h:578
void AlphaMultiplier(const T &A, T &multiplier) const
Definition: TPZYCTresca.h:93
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 ComputeTangent(TPZFMatrix< REAL > &tangent, TPZVec< REAL > &coefs, int icase)
Definition: TPZYCTresca.h:154
void N(const TPZTensor< T > &sigma, const T &A, TPZVec< TPZTensor< T > > &Ndir, int checkForcedYield=0) const
Definition: TPZYCTresca.h:268
virtual int ClassId() const override
Define the class id associated with the class.
Definition: TPZYCTresca.cpp:5
void Print(std::ostream &out) const override
Definition: TPZYCTresca.h:29
int NumCases()
number of types of residuals
Definition: TPZYCTresca.h:142
sin
Definition: fadfunc.h:63
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
Definition: pzlog.h:87
void SetYieldStatusMode(const TPZTensor< REAL > &sigma, const REAL &A)
Definition: TPZYCTresca.h:51
void dJ3(TPZTensor< T > &deriv) const
Definition: TPZTensor.h:956
void dJ2(TPZTensor< T > &Tangent) const
Definition: TPZTensor.h:935
void Residual(TPZFMatrix< REAL > &res, int icase)
Definition: TPZYCTresca.h:222
T InverseAngle(const TPZTensor< T > &deviatoric) const
Computes the inverse angle of the tresca yield criterium formula.
Definition: TPZYCTresca.h:334
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sqrt
Definition: tfadfunc.h:120
string res
Definition: test.py:151
T J2() const
Definition: TPZTensor.h:927
int GetForceYield()
Definition: TPZYCTresca.h:34
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Definition: TPZYCTresca.h:102
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 & XX() const
Definition: TPZTensor.h:566
void GradTheta(const TPZTensor< T > &sigma, T &theta, TPZTensor< T > &gradtheta) const
Compute the inverse angle of the tresca yield criterium formula and the related data.
Definition: TPZYCTresca.h:360
expr_ expr_ expr_ expr_ expr_ expr_ asin
Definition: tfadfunc.h:80
const char * Name() const
Definition: TPZYCTresca.h:24
T & ZZ() const
Definition: TPZTensor.h:586
virtual int GetNYield() const override
Definition: TPZYCTresca.h:113
void H(const TPZTensor< T > &sigma, const T &A, TPZVec< T > &h, int checkForcedYield=0) const
Definition: TPZYCTresca.h:84
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
void LoadState(TPZFMatrix< REAL > &state)
LoadState will keep a given state as static variable of the class.
Definition: TPZYCTresca.h:149
void SetForceYield(const int forceYield)
Definition: TPZYCTresca.h:39
void GradInverseAngle(const TPZTensor< T > &sigma, TPZTensor< T > &grad) const
Computes the derivative of the inverse angle of the tresca yield criterium formula.
Definition: TPZYCTresca.h:343
TPZFlopCounter cos(const TPZFlopCounter &orig)
Returns the cosine in radians and increments the counter of the Cosine.
Definition: pzreal.h:514
T J3() const
Definition: TPZTensor.h:946