NeoPZ
tpzyctrescaregularized.h
Go to the documentation of this file.
1 
5 #ifndef TPZYCTRESCAREGULARIZED_H
6 #define TPZYCTRESCAREGULARIZED_H
7 
8 #include "TPZYCTresca.h"
9 #include "pzlog.h"
10 #include <math.h>
11 #include <iostream>
12 
18 {
19 public:
20 
21  public:
22 int ClassId() const override;
23 
24 
25  const char * Name() const
26  {
27  return "TPZYCTrescaRegularized";
28  }
29 
30  void Print(std::ostream & out) const override
31  {
32  out << Name();
33  }
34 
42  template < class T>
43  void Compute(const TPZTensor<T> & sigma, const T & A,TPZVec<T> &result, int checkForcedYield = 0) const;
44 
45 protected:
53  template <class T>
54  void GradTheta(const TPZTensor<T> & sigma,T & theta, TPZTensor<T> & gradasin) const;
55 
56 public:
64  template <class T>
65  void N(const TPZTensor<T> & sigma,const T & A, TPZVec<TPZTensor<T> > & Ndir, int checkForcedYield = 0) const;
66 
67  void Read(TPZStream& buf, void* context) override {
68 
69  }
70  void Write(TPZStream &buf, int withclassid) const override{
71 
72  }
73 
74 
76 public:
77 
79  int NumCases()
80  {
81  return 2;
82  }
83 
87  {
88  int i;
89  for(i=0; i<6; i++) gRefTension.fData[i] = state(i,0);
90  }
91 
92  void ComputeTangent(TPZFMatrix<REAL> &tangent, TPZVec<REAL> &, int icase)
93  {
94  TPZTensor<REAL> gradtheta;
95  REAL theta,A(1.e7);
96  TPZVec<REAL> phivec(1,0.);
97  TPZVec<TPZTensor<REAL> > ndir(1);
98  int i;
99  switch(icase)
100  {
101  case 0:
102  GradTheta(gRefTension,theta,gradtheta);
103  tangent.Redim(1,6);
104  for(i=0; i<6; i++) tangent(0,i) = gradtheta.fData[i];
105  break;
106  case 1:
107  N(gRefTension,A,ndir,0);
108  tangent.Redim(1,6);
109  for(i=0; i<6; i++) tangent(0,i) = ndir[0].fData[i];
110  }
111  }
112 
113  void Residual(TPZFMatrix<REAL> &res,int icase)
114  {
115  TPZTensor<REAL> gradtheta;
116  REAL theta,A(1.e7);
117  TPZVec<REAL> phivec(1,0.);
118  switch(icase)
119  {
120  case 0:
121  GradTheta(gRefTension,theta,gradtheta);
122  res.Redim(1,1);
123  res(0,0) = theta;
124  break;
125  case 1:
126  Compute(gRefTension,A,phivec,0);
127  res.Redim(1,1);
128  res(0,0) = phivec[0];
129  break;
130  }
131 
132  }
133 
134  virtual int GetNYield() const override {
135  return as_integer(NYield);
136  }
137 };
138 
139 
140 
141 template < class T>
142 void TPZYCTrescaRegularized::Compute(const TPZTensor<T> & sigma, const T & A,TPZVec<T> &result, int checkForcedYield) const
143 {
144 #ifdef LOG4CXX_PLASTICITY
145  LoggerPtr logger(Logger::getLogger("plasticity.yctresca"));
146 #endif
147 
148  // result[0] = sqrt(sigma.J2()) - A;
149 
150  // return;
151  const REAL tol = 1.e-4;
152  T invangle = InverseAngle(sigma);
153  TPZTensor <T> s;
154  sigma.S(s);
155  REAL aux = (1. - tol);
156  if (fabs(TPZExtractVal::val(invangle)) < aux)
157  {
158 #ifdef LOG4CXX_PLASTICITY
159  std::stringstream sout;
160  sout << __PRETTY_FUNCTION__ << " O angulo nao corresponde " << invangle;
161  LOGPZ_DEBUG(logger,sout.str().c_str());
162 #endif
163  TPZYCTresca::Compute(sigma,A,result,checkForcedYield);
164  } else
165  {
166  if (fabs(TPZExtractVal::val(invangle)) > 1.) invangle = 1.;
167  REAL asineps = asin(1. - tol);
168  T tayext = ((T)fabs(TPZExtractVal::val(invangle)) - T(1.-tol))*T(1./(sqrt(1.- (1. - tol)*(1. - tol))));
169  invangle = (tayext + T(asineps)) / 3.;
170  //invangle = alpha * (1./3.) * (asin(1. - 1.e-6) + ( fabs(alpha)-(1.-1.e-6))*(1./(sqrt(1.-(1.-1.e-6)*(1.-1.e-6)))));
171 #ifdef LOG4CXX_PLASTICITY
172  std::stringstream sout;
173  T small = cos(invangle)*2.-T(sqrt(3.));
174 
175  sout << __PRETTY_FUNCTION__ << "2.*cos(invangle)-sqrt(3.) " << small;
176  sout << " invangle " << invangle;
177  LOGPZ_DEBUG(logger,sout.str().c_str());
178 #endif
179  result[0] = sqrt(sigma.J2())*cos(invangle)*2. - A;
180  //result[0] = sqrt(3.)* sqrt(sigma.J2()) - A;
181  }
182 }
183 
184 template <class T>
185 void TPZYCTrescaRegularized::GradTheta(const TPZTensor<T> & sigma,T & theta, TPZTensor<T> & gradtheta) const
186 {
187 #ifdef LOG4CXX_PLASTICITY
188  LoggerPtr logger(Logger::getLogger("plasticity.yctresca"));
189 #endif
190 
191  const REAL tol = 1.e-4;
192 
193  T invangle = InverseAngle(sigma);
194 
195  {
196  /* std::stringstream sout;
197  sout << "GradTheta:Invangle " << invangle;
198  LOGPZ_DEBUG(logger,sout.str().c_str());*/
199  }
200 
201  if (fabs(TPZExtractVal::val(invangle)) < (1. - 1.e-6))
202  {
203 #ifdef LOG4CXX_PLASTICITY
204  {
205  std::stringstream sout;
206  sout << "calling GradTheta from father... invangle " << invangle;
207  LOGPZ_DEBUG(logger,sout.str().c_str());
208  }
209 #endif
210 
211  TPZYCTresca::GradTheta(sigma,theta,gradtheta);
212 #ifdef LOG4CXX_PLASTICITY
213  {
214  std::stringstream sout;
215  sout << "sigma " << sigma << std::endl;
216  sout << "theta " << theta << std::endl;
217  sout << "gratheta " << gradtheta << std::endl;
218  LOGPZ_DEBUG(logger,sout.str().c_str());
219  }
220 #endif
221 
222 
223  } else
224  {
225  //double alpha;
226  //if (fabs(invangle) > 1.)
227  // alpha = (invangle > 0.) ? 1. : -1.;
228  // theta = (alpha/3.)* (asin(1. - 1.e-6) + (fabs(alpha) - (1.-1.e-6))*(1./(sqrt(1.-(1.-1.e-6)*(1.-1.e-6)))));
229  // GradInverseAngle(sigma,gradtheta);
230  // T derivasin = 1./sqrt(1.-(1. - 1.e-6)*(1. - 1.e-6));
231  // gradtheta.Multiply(derivasin,1./3.);
232  REAL alpha = (TPZExtractVal::val(invangle) > 0.) ? 1. : -1.;
233  if (fabs(TPZExtractVal::val(invangle) ) > 1.) invangle = 1.;
234  REAL asineps = asin(1. - tol);
235  T tayext = ((T)fabs(TPZExtractVal::val(invangle)) - T(1.- tol))*T(1./(sqrt(1.- (1. - tol)*(1. - tol))));
236  theta = (tayext + T(asineps)) * T(alpha / 3.);
237  GradInverseAngle(sigma,gradtheta);
238  REAL derivasin = 1./sqrt(1.-(1. - tol)*(1. - tol));
239  gradtheta.Multiply(T(derivasin),T(1./3.));
240  {
241  /* std::stringstream sout;
242  sout << "Invangle " << invangle << std::endl;
243  sout << "alpha " << alpha << std::endl;
244  sout << "asineps " << asineps << std::endl;
245  sout << "tayext " << tayext << std::endl;
246  sout << "theta " << theta << std::endl;
247  sout << "gradtheta" << gradtheta << std::endl;
248  sout << "derivsin " << derivasin << std::endl;
249  sout << "gradtheta" << gradtheta << std::endl;
250  LOGPZ_DEBUG(logger,sout.str().c_str());*/
251  }
252  }
253 }
254 
255 template <class T>
256 void TPZYCTrescaRegularized::N(const TPZTensor<T> & sigma,const T & A, TPZVec<TPZTensor<T> > & Ndir, int checkForcedYield) const
257 {
258 #ifdef LOG4CXX_PLASTICITY
259  LoggerPtr logger(Logger::getLogger("plasticity.yctresca"));
260 #endif
261 
262  // sigma.dJ2(Ndir[0]);
263  // Ndir[0].Multiply(sqrt(3.)*0.5*(1./sqrt(sigma.J2())),1.);
264  // return;
265 
266 
267 
268  /* T invangle = InverseAngle(sigma);
269  T theta = (1./3.)*asin(invangle);
270  TPZTensor<T> gradinvangle;
271  GradInverseAngle(sigma,gradinvangle);
272  T derivasin = 1./sqrt(1.-invangle*invangle);*/
273  // T invangle;
274  T theta;
275  TPZTensor<T> gradtheta;
276  //T derivasin;
277  //GradASinInvAngle (sigma,invangle,theta,gradinvangle,derivasin);
278  {
279  /* std::stringstream sout;
280  sout << "A " << A << " N: sigma " << sigma;
281  LOGPZ_DEBUG(logger,sout.str().c_str());*/
282  }
283 
284  GradTheta<T> (sigma,theta,gradtheta);
285 
286  {
287  /* std::stringstream sout;
288  sout << "N: theta " << theta;
289  sout << "gradtheta " << gradtheta;
290  LOGPZ_DEBUG(logger,sout.str().c_str());*/
291  }
292 
293  T sqj2 = sqrt(sigma.J2());
294  TPZTensor<T> dj2;
295  sigma.dJ2(dj2);
296 
297  TPZTensor<T> resultdtheta(gradtheta);
298  resultdtheta.Multiply(sqj2*sin(theta),-2.);
299  TPZTensor<T> resultdj2(dj2);
300  resultdj2.Multiply(cos(theta)/sqj2,1.);
301  TPZTensor<T> result(resultdj2);
302  // result.Add(resultdtheta,1.);
303 
304  // resultdj2.Multiply(1./sqj2,sqrt(3.)/2.);
305 
306 
307  {
308  /* std::stringstream sout;
309  sout << "sqj2 " << sqj2;
310  sout << " theta" << theta;
311  T coco = sin (theta);
312  sout << " sintheta " << coco;
313  sout << "dj2" << dj2;
314  sout << "N: resultdtheta " << theta;
315  LOGPZ_DEBUG(logger,sout.str().c_str());*/
316  }
317  {
318  /* std::stringstream sout;
319  sout << "gradtheta " << gradtheta;
320  sout << "Result N = " << result;
321  LOGPZ_DEBUG(logger,sout.str().c_str());*/
322  }
323 
324  Ndir[0] = result;
325  // Ndir[0] = resultdj2;
326 }
327 
328 
329 
330 
331 #endif
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_ expr_ expr_ expr_ expr_ fabs
Definition: tfadfunc.h:140
const char * Name() const
void Multiply(const T1 &multipl, const T2 &constant)
Definition: TPZTensor.h:766
int NumCases()
Number of types of residuals.
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 Residual(TPZFMatrix< REAL > &res, int icase)
std::underlying_type< Enumeration >::type as_integer(const Enumeration value)
Definition: pzreal.h:37
void GradTheta(const TPZTensor< T > &sigma, T &theta, TPZTensor< T > &gradasin) const
Compute the inverse angle of the tresca yield criterium formula and the related data.
This class implements a simple vector storage scheme for a templated class T. Utility.
Definition: pzgeopoint.h:19
void LoadState(TPZFMatrix< REAL > &state)
LoadState will keep a given state as static variable of the class.
void Read(TPZStream &buf, void *context) override
read objects from the stream
static TPZTensor< REAL > gRefTension
void Print(std::ostream &out) const override
sin
Definition: fadfunc.h:63
static const double tol
Definition: pzgeoprism.cpp:23
void Compute(const TPZTensor< T > &sigma, const T &A, TPZVec< T > &result, int checkForcedYield=0) const
Calculo do criterio de plastificacao.
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
Definition: pzlog.h:87
void dJ2(TPZTensor< T > &Tangent) const
Definition: TPZTensor.h:935
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
virtual int GetNYield() const override
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
This class implements a tresca yield criteria whrere the gradient of the inverse angle is regularized...
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
void N(const TPZTensor< T > &sigma, const T &A, TPZVec< TPZTensor< T > > &Ndir, int checkForcedYield=0) const
Derivada da funcao de plastificacao.
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
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
void ComputeTangent(TPZFMatrix< REAL > &tangent, TPZVec< REAL > &, int icase)
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
void S(TPZTensor< T > &s) const
Definition: TPZTensor.h:894
int ClassId() const override
Define the class id associated with the class.