NeoPZ
TPZPlasticStep.h
Go to the documentation of this file.
1 
5 #ifndef TPZPLASTICSTEP_H
6 #define TPZPLASTICSTEP_H
7 
8 #include "TPZTensor.h"
9 #include "pzreal.h"
10 #include "pzfmatrix.h"
11 #include "TPZPlasticState.h"
12 #include "TPZPlasticIntegrMem.h"
13 #include "TPZElasticResponse.h"
14 
15 #include "pzlog.h"
16 #include "TPZPlasticBase.h"
17 
18 #include <set>
19 #include <ostream>
20 
22 {
23  EAuto = 0,
26 };
27 
31 template <class YC_t, class TF_t, class ER_t>
33 {
34 public:
35 
36 virtual int ClassId() const override;
43  TPZPlasticStep(REAL alpha=0.):fYC(), fTFA(), fER(), fResTol(1.e-12),
44  fIntegrTol(1.e-4), fMaxNewton(30), fMinLambda(1.),
45  fMinStepSize(1.e-3), fN(), fPlasticMem(),
47  { fN.m_hardening = alpha; }
48 
50  {
51  fYC = source.fYC;
52  fTFA = source.fTFA;
53  fER = source.fER;
54  fResTol = source.fResTol;
55  fIntegrTol = source.fIntegrTol;
56  fMaxNewton = source.fMaxNewton;
57  fMinLambda = source.fMinLambda;
58  fMinStepSize= source.fMinStepSize;
59  fN = source.fN;
60  fPlasticMem = source.fPlasticMem;
63  }
64 
66  {
67  fYC = source.fYC;
68  fTFA = source.fTFA;
69  fER = source.fER;
70  fResTol = source.fResTol;
71  fIntegrTol = source.fIntegrTol;
72  fMaxNewton = source.fMaxNewton;
73  fMinLambda = source.fMinLambda;
74  fMinStepSize= source.fMinStepSize;
75  fN = source.fN;
76  fPlasticMem = source.fPlasticMem;
79  return *this;
80  }
81 
82  virtual const char *Name() const override
83  {
84  return "TPZPlasticStep generic class";
85  }
86 
87  virtual void Print(std::ostream & out) const override
88  {
89  out << "\n" << this->Name();
90  out << "\n YC_t:";
91  fYC.Print(out);
92  out << "\n TF_t:";
93  fTFA.Print(out);
94  out << "\n ER_t:";
95  fER.Print(out);
96  out << "\nTPZPlasticStep Internal members:";
97  out << "\n fResTol = " << fResTol;
98  out << "\n fMaxNewton = " << fMaxNewton;
99  out << "\n fMinLambda = " << fMinLambda;
100  out << "\n fPlasticMem.NElements() = " << fPlasticMem.NElements();
101  out << "\n fN = ";
102  fN.Print(out);
103  }
104 
110  virtual void ApplyStrain(const TPZTensor<REAL> &epsTotal) override;
111 
112 
113  void SetOutFile(string outfile);
114 
115  typedef YC_t fNYields;
116 
123  virtual void ApplyStrainComputeSigma(const TPZTensor<REAL> &epsTotal, TPZTensor<REAL> &sigma, TPZFMatrix<REAL> * tangent = NULL) override;
124 
133  virtual void ApplyStrainComputeDep(const TPZTensor<REAL> &epsTotal, TPZTensor<REAL> &sigma, TPZFMatrix<REAL> &Dep) override;
134 
144  virtual void ApplyLoad(const TPZTensor<REAL> & sigma, TPZTensor<REAL> &epsTotal) override;
145 
150  {
151  fPlasticMem.Resize(0);
152  }
153 
159  void SetTensionSign(int s);
160 
162  int SignCorrection()const;
163 
165  return fYC;
166  }
167 
168 
169 protected:
170 
176  void ApplyStrain_Internal(const TPZTensor<REAL> &epsTotal);
177 
188 
206  {
207  ApplyStrain_Internal(epsTotal);
208 
209  REAL A;
210 
211  int n = fPlasticMem.NElements();
212 
213  ComputePlasticVars(fPlasticMem[n-1].m_elastoplastic_state, sigma, A);
214  }
215 
226  void ApplyLoad_Internal(const TPZTensor<REAL> & sigma, TPZTensor<REAL> &epsTotal);
227 
228 
229 public:
235  virtual void Phi(const TPZTensor<REAL> &epsTotal, TPZVec<REAL> &phi) const override;
236 
237 
238 public:
239 
246  virtual void Phi_Internal(const TPZTensor<REAL> &epsTotal, TPZVec<REAL> &phi) const;
247 
252  bool IsStrainElastic(const TPZPlasticState<REAL> &state)const;
253 
255  virtual void SetElasticResponse(TPZElasticResponse &ER) override;
256 
257  virtual TPZElasticResponse GetElasticResponse() const override;
262  virtual void SetState(const TPZPlasticState<REAL> &state) override;
263 
268  virtual void SetUp(const TPZTensor<REAL> & epsTotal);
269 
271  virtual TPZPlasticState<REAL> GetState()const override;
272 
274  virtual int IntegrationSteps()const override;
275 
277  virtual void SetIntegrTol(REAL integrTol)
278  {
279  fIntegrTol = integrTol;
280  }
281 
283  virtual void SetMinStepSize(REAL minStepSize)
284  {
285  fMinStepSize = minStepSize;
286  }
287 
300  virtual REAL IntegrationOverview(TPZVec<REAL> & plastifLen);
301 
302 protected:
303 
308  virtual void SetState_Internal(const TPZPlasticState<REAL> &state);
309 
310 public:
313 
314 protected:
315 
323  virtual void ProcessStrain(const TPZTensor<REAL> &epsTotal, const EElastoPlastic ep = EAuto);
324 
331  virtual void ProcessStrainNoSubIncrement(const TPZTensor<REAL> &epsTotal, const EElastoPlastic ep = EAuto);
332 
340  virtual void ProcessLoad(const TPZTensor<REAL> &sigma, const EElastoPlastic ep = EAuto);
341 
348  virtual void ComputeDep(TPZTensor<REAL> & sigma, TPZFMatrix<REAL> &Dep);
349 // virtual void ComputeDep2(TPZTensor<REAL> & sigma, TPZFMatrix<REAL> &Dep);
350 
359  template<class T>
360  void ComputePlasticVars(const TPZPlasticState<T> & state_T,
361  TPZTensor<T> & sigma_T,
362  T& A_T)const;
363 
372  REAL FindPointAtYield(const TPZTensor<REAL>& epsTotalNp1,
373  TPZPlasticState<REAL> & stateAtYield)const ;
374 
386  template <class T1, class T2>
387  void PlasticResidual(const TPZPlasticState<T1> &N_T1,
388  TPZPlasticState<T2> &Np1_T2,
389  const TPZVec<T2> &delGamma_T2,
390  TPZVec<T2> &res_T2,
391  REAL &normEpsPErr,
392  int silent = 0)const;
393 
394 
405  template <class T1, class T2>
406  void PlasticResidualRK(
407  const TPZPlasticState<T1> &N_T1,
408  TPZPlasticState<T2> &Np1_T2,
409  const TPZVec<T2> &delGamma_T2,
410  TPZVec<T2> &res_T2,
411  REAL &normEpsPErr,
412  int silent=0)const;
413 
426  template<class T1, class T2, class TVECTOR>
427  REAL UpdatePlasticVars(const TPZPlasticState<T1> &N_T1,
428  TPZPlasticState<T2> &Np1_T2,
429  TPZVec<T2> &delGamma_T2,
430  TPZVec<T2> &res_T2,
431  TVECTOR & Sol_TVECTOR,
432  TPZVec<int> & validEqs,
433  int updateVars = 1)const;
434 
447  template<class T>
448  void InitializePlasticFAD(const TPZPlasticState<REAL> & state, const TPZVec<REAL> &delGamma,
449  TPZPlasticState<T> &state_T, TPZVec<T> &delGamma_T,
450  const int nVars = 7 + YC_t::NYield)const;
451 
457  template <class T>
458  int InitializeValidEqs(TPZVec<T> &res_T, TPZVec<int> & validEqs);
459 
466  template <class T>
467  int RemoveInvalidEqs(TPZVec<T> & delGamma_T, TPZVec<T> & res_T, TPZVec<int> &validEqs);
468 
478  void InitialGuess(
479  const TPZPlasticState<REAL> &N,
481  TPZVec<REAL> &delGamma,
482  TPZVec<int> &validEqs
483  );
496  int PlasticLoop(const TPZPlasticState<REAL> &N,
498  TPZVec<REAL> &delGamma,
499  REAL &normEpsPErr,
500  REAL &lambda,
501  TPZVec<int> & validEqs);
502 
512  int PlasticIntegrate(
513  const TPZPlasticState<REAL> &N,
515  const REAL &TolEpsPErr);
516 
517 
529  template<class T1, class T_VECTOR, class T_MATRIX>//T1:input residual fad type (FAD FAD or FAD), T_MATRIX: output matrix &vector of type (FAD or REAL, respectvly)
530  void ExtractTangent(
531  const TPZVec<T1> & epsRes_FAD,
532  T_VECTOR & ResVal, //TPZFMatrix<REAL> for the T1=fad<real> type
533  REAL & resnorm, // REAL
534  T_MATRIX & tangent, // TPZFMatrix<REAL> for T1=fad<real> type
535  TPZVec<int> & validEqs,
536  TPZVec<REAL> &pivots,
537  const int precond = 1,
538  const int resetInvalidEqs = 1);
539 
550  template <int N>
551  void PushPlasticMem(const TPZPlasticState<REAL> & state,
552  const REAL & k,
553  const REAL & lambda,
554  const TPZManVector<REAL,N> & delGamma,
555  const TPZVec<int> & validEqs,
556  const int forceYield);
557 
558 public:
559  void SetMaterialElasticOrPlastic(int choice=1/*plastic*/);
560 
562  {
563  fResTol = tol;
564  }
565 
566  void Write(TPZStream& buf, int withclassid) const override;
567  void Read(TPZStream& buf, void* context) override;
568 public:
569 
571  YC_t fYC;
573  TF_t fTFA;
575  ER_t fER;
576 
577 
578 protected:
579 
581  REAL fResTol;
582 
583 public:
586 
589 
595 
604 
605 protected:
606 
609 
616 
619 
622 
623 
624 
625  //ofstream fOutfile(string &str);
626 
627 public:
628 
630 
632  int NumCases()
633  {
634  return 1;
635  }
636 
638 
641  {
642  int i;
643  for(i=0; i<6; i++) gRefDeform[i] = state(i,0);
644  }
645 
646  void ComputeTangent(TPZFMatrix<REAL> &tangent, TPZVec<REAL> &coefs, int icase)
647  {
648 #ifdef LOG4CXX_PLASTICITY
649  LoggerPtr logger(Logger::getLogger("plasticity.plasticstep"));
650 #endif
651  TPZTensor<REAL> sigma;
652  switch(icase)
653  {
654  case 0:
655  TPZTensor<REAL> sig;
656  tangent.Redim(6,6);
657  {
658  ProcessStrain(gRefDeform);
659  ComputeDep(sig, tangent);
660  }
661  //Sigma(gRefDeform,sig,tangent);
662 #ifdef LOG4CXX_PLASTICITY
663  std::stringstream sout;
664  sout << "matriz tangent for checkconv " << tangent;
665  LOGPZ_DEBUG(logger,sout.str().c_str());
666 #endif
667  break;
668  }
669  }
670 
671  void Residual(TPZFMatrix<REAL> &res,int icase)
672  {
673 #ifdef LOG4CXX_PLASTICITY
674  LoggerPtr logger(Logger::getLogger("plasticity.plasticstep"));
675 #endif
676  TPZTensor<REAL> sigma;
677  switch(icase)
678  {
679  case 0:
680  TPZTensor<REAL> sig;
681  TPZFMatrix<REAL> tangent(6,6);
682  res.Redim(6,1);
683  {
684  ProcessStrain(gRefDeform);
685  ComputeDep(sig, tangent);
686  }
687  //Sigma(gRefDeform,sig,tangent);
688 #ifdef LOG4CXX_PLASTICITY
689  std::stringstream sout;
690  sout << "sigma for residual " << sig;
691  LOGPZ_DEBUG(logger,sout.str().c_str());
692 #endif
693  int i;
694  for(i=0; i<6; i++)
695  {
696  res(i,0) = sig[i];
697  }
698  break;
699  }
700  }
701 
703 
704 };
705 
706 template <class YC_t, class TF_t, class ER_t>
708  return Hash("TPZPlasticStep") ^ TPZPlasticBase::ClassId() << 1 ^ YC_t().ClassId() << 2 ^ TF_t().ClassId() << 3 ^ ER_t().ClassId() << 4;
709 }
710 
711 #endif //TPZPLASTICSTEP_H
Classe que efetua avanco de um passo de plastificacao utilizando o metodo de Newton.
virtual void Phi_Internal(const TPZTensor< REAL > &epsTotal, TPZVec< REAL > &phi) const
Return the value of the yield functions for the given strain Internal Method.
virtual void SetUp(const TPZTensor< REAL > &epsTotal)
Overwrite the current total strain only.
virtual void SetMinStepSize(REAL minStepSize)
Sets the minimum loading substep size in the plastic integration.
YC_t fYC
Object which represents the yield criterium.
void ApplyLoad_Internal(const TPZTensor< REAL > &sigma, TPZTensor< REAL > &epsTotal)
Attempts to compute an epsTotal value in order to reach an imposed stress state sigma. This methid should be used only for test purposes because it isn&#39;t fully robust. Some materials, specially those perfectly plastic and with softening, may fail when applying the Newton Method on ProcessLoad. Internal Method.
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.
TPZStack< TPZPlasticIntegrMem< REAL, YC_t::NYield > > fPlasticMem
Stores the plastic evolution in the last evaluated PlasticIntegration call, It includes the N-1 data...
void Print(std::ostream &Out, int fadDerivatives=1) const
More complete then Operator << because it allows derivatives supression.
virtual void ProcessStrainNoSubIncrement(const TPZTensor< REAL > &epsTotal, const EElastoPlastic ep=EAuto)
Imposes the specified strain tensor and performs plastic integration when necessary. This function DO NOT calls PlasticIntegrate.
T m_hardening
Plastic volumetric hardeing variable.
TPZPlasticStep & operator=(const TPZPlasticStep &source)
TPZPlasticCriterion & GetYC() override
void InitializePlasticFAD(const TPZPlasticState< REAL > &state, const TPZVec< REAL > &delGamma, TPZPlasticState< T > &state_T, TPZVec< T > &delGamma_T, const int nVars=7+YC_t::NYield) const
This method copies the REAL variables into FAD variables and intializes the derivatives The nVars var...
virtual int ClassId() const override
Define the class id associated with the class.
void ApplyStrain_Internal(const TPZTensor< REAL > &epsTotal)
Imposes the specified strain tensor, evaluating the plastic integration if necessary. Internal Method.
int RemoveInvalidEqs(TPZVec< T > &delGamma_T, TPZVec< T > &res_T, TPZVec< int > &validEqs)
After a complete plasticLoop, plsatic surface equations related to negative plastic multipliers are d...
void ExtractTangent(const TPZVec< T1 > &epsRes_FAD, T_VECTOR &ResVal, REAL &resnorm, T_MATRIX &tangent, TPZVec< int > &validEqs, TPZVec< REAL > &pivots, const int precond=1, const int resetInvalidEqs=1)
Extracts the tangent matrix and residual vector from the FAD variables and according to the precondit...
void ApplyStrainComputeSigma_Internal(const TPZTensor< REAL > &epsTotal, TPZTensor< REAL > &sigma)
Imposes the specified strain tensor and returns the correspondent stress state. Internal Method...
virtual REAL IntegrationOverview(TPZVec< REAL > &plastifLen)
Similar to IntegrationSteps, it returns the plastic parcel of the last loading. 1.0 means that the whole step was plastic, 0.0 means the whole step was elastic.
bool IsStrainElastic(const TPZPlasticState< REAL > &state) const
Verifies if the proposed epsTotalNp1 is still in the elastic range.
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
Definition: pzmanvector.h:426
int InitializeValidEqs(TPZVec< T > &res_T, TPZVec< int > &validEqs)
Initializes the fValidEqs booleans indication whether to consider the plastic surfaces.
int SignCorrection() const
Indicates whether or not to correct Stress/Strain sign.
void Read(TPZStream &buf, void *context) override
read objects from the stream
void LoadState(TPZFMatrix< REAL > &state)
LoadState will keep a given state as static variable of the class.
ER_t fER
Object representing the elastic response.
void ApplyStrainComputeDep_Internal(const TPZTensor< REAL > &epsTotal, TPZTensor< REAL > &sigma, TPZFMatrix< REAL > &Dep)
Imposes the specified strain tensor and returns the corresp. stress state and tangent stiffness matri...
static const double tol
Definition: pzgeoprism.cpp:23
TPZPlasticState< REAL > fN
Plastic State Variables (EpsT, EpsP, Alpha) at the current time step.
virtual void ApplyStrain(const TPZTensor< REAL > &epsTotal) override
Contains TPZMatrixclass which implements full matrix (using column major representation).
REAL fResTol
Residual tolerance accepted in the plastic loop processes.
void InitialGuess(const TPZPlasticState< REAL > &N, TPZPlasticState< REAL > &Np1, TPZVec< REAL > &delGamma, TPZVec< int > &validEqs)
Proposes an update to the plastic variables and estimates the relative error comitted in this update...
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
Definition: pzlog.h:87
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
int PlasticLoop(const TPZPlasticState< REAL > &N, TPZPlasticState< REAL > &Np1, TPZVec< REAL > &delGamma, REAL &normEpsPErr, REAL &lambda, TPZVec< int > &validEqs)
Proposes an update to the plastic variables and estimates the relative error comitted in this update...
virtual void Phi(const TPZTensor< REAL > &epsTotal, TPZVec< REAL > &phi) const override
Return the value of the yield functions for the given strain.
TF_t fTFA
Object representing the thermodynamical force.
REAL FindPointAtYield(const TPZTensor< REAL > &epsTotalNp1, TPZPlasticState< REAL > &stateAtYield) const
Finds the strain point in the linear path from epsTotalN and towards epsTotalNp1 that matches the yie...
int NumCases()
Number of types of residuals.
int fMaterialTensionSign
The tension sign in the convention used in the implementation of the material.
void PlasticResidualRK(const TPZPlasticState< T1 > &N_T1, TPZPlasticState< T2 > &Np1_T2, const TPZVec< T2 > &delGamma_T2, TPZVec< T2 > &res_T2, REAL &normEpsPErr, int silent=0) const
Evaluates the residual vector for the plasticity problem RK.
REAL UpdatePlasticVars(const TPZPlasticState< T1 > &N_T1, TPZPlasticState< T2 > &Np1_T2, TPZVec< T2 > &delGamma_T2, TPZVec< T2 > &res_T2, TVECTOR &Sol_TVECTOR, TPZVec< int > &validEqs, int updateVars=1) const
Updates the N+1 plastic state variables based on the solution of a Newton&#39;s scheme. A very simple line search is performed in order to attempt to guarantee residual drop.
void SetTensionSign(int s)
TPZPlasticStep(const TPZPlasticStep &source)
string res
Definition: test.py:151
virtual TPZPlasticState< REAL > GetState() const override
Retrieve the plastic state variables.
static TPZTensor< REAL > gRefDeform
virtual void ProcessStrain(const TPZTensor< REAL > &epsTotal, const EElastoPlastic ep=EAuto)
Imposes the specified strain tensor and performs plastic integration when necessary. This function creates a new plastic integration history epserimenting the proposed epsTotal. It does not update the current plastic state.
void PushPlasticMem(const TPZPlasticState< REAL > &state, const REAL &k, const REAL &lambda, const TPZManVector< REAL, N > &delGamma, const TPZVec< int > &validEqs, const int forceYield)
Stores the whole content of a plastic integration step in order to allow its further reevaluation...
int fMaxNewton
Maximum number of Newton interations allowed in the nonlinear solvers.
void ComputeTangent(TPZFMatrix< REAL > &tangent, TPZVec< REAL > &coefs, int icase)
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
Definition: pzfmatrix.h:616
void ResetPlasticMem()
Reset the plastic memory.
void PlasticResidual(const TPZPlasticState< T1 > &N_T1, TPZPlasticState< T2 > &Np1_T2, const TPZVec< T2 > &delGamma_T2, TPZVec< T2 > &res_T2, REAL &normEpsPErr, int silent=0) const
virtual void Print(std::ostream &out) const override
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
virtual void ApplyLoad(const TPZTensor< REAL > &sigma, TPZTensor< REAL > &epsTotal) override
virtual void SetIntegrTol(REAL integrTol)
Sets the tolerance allowed in the pde integration.
EElastoPlastic
virtual void SetElasticResponse(TPZElasticResponse &ER) override
modify the elastic response. Needs to be reimplemented for each instantiation
virtual TPZElasticResponse GetElasticResponse() const override
void SetOutFile(string outfile)
virtual const char * Name() const override
int fInterfaceTensionSign
The tension sign in the convention defined by the external user.
virtual void ApplyStrainComputeDep(const TPZTensor< REAL > &epsTotal, TPZTensor< REAL > &sigma, TPZFMatrix< REAL > &Dep) override
TPZPlasticStep(REAL alpha=0.)
This class implements a stack object. Utility.
Definition: pzcheckmesh.h:14
void ComputePlasticVars(const TPZPlasticState< T > &state_T, TPZTensor< T > &sigma_T, T &A_T) const
Evaluates the sigma stress tensor and the thermoForceA for use in several pieces of this code...
REAL fIntegrTol
Tolerance desired in the Plastic integration processes.
void SetMaterialElasticOrPlastic(int choice=1)
virtual void ApplyStrainComputeSigma(const TPZTensor< REAL > &epsTotal, TPZTensor< REAL > &sigma, TPZFMatrix< REAL > *tangent=NULL) override
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
Contains the declaration of TPZFlopCounter class and TPZCounter struct.
void SetResidualTolerance(STATE tol)
virtual TPZPlasticState< REAL > GetState_Internal() const
Retrieves the plastic state variables - makes no interface sign checks.
int ClassId() const override
Define the class id associated with the class.
REAL fMinStepSize
Minimum fraction of the full load substep proposed accepted in the plastic integration. Too low values may lead to extremely slow integration in some cases while values as high as 1.0 may prevent the plastic integrator error control from adjusting the advisable plastic substeps. Values between 1.e-3 and 1.e-2 are advisable.
virtual void ComputeDep(TPZTensor< REAL > &sigma, TPZFMatrix< REAL > &Dep)
Evaluates the constitutive matrix (DSigma/DEpsT) based on the data from the plastic integration histo...
virtual void SetState(const TPZPlasticState< REAL > &state) override
Update the damage values.
int PlasticIntegrate(const TPZPlasticState< REAL > &N, TPZPlasticState< REAL > &Np1, const REAL &TolEpsPErr)
Proposes an update to the plastic variables respecting an integration with error control. Neither internal variable are used nor changed. In the Np1 variables, EpsT is imposed [input] and the Alpha and EpsP are evaluated.
virtual void SetState_Internal(const TPZPlasticState< REAL > &state)
Updates the damage values - makes no interface sign checks.
virtual void ProcessLoad(const TPZTensor< REAL > &sigma, const EElastoPlastic ep=EAuto)
Imposes the specified stress tensor and performs plastic integration when necessary. This function evaluates a newton&#39;s method on ProcessStrain until the stress state matches. It does not update the current plastic state.
REAL fMinLambda
Minimum multiplicaton in the Plastic Loop line search. 1.0 avoids line searching; Very Small values d...
virtual int IntegrationSteps() const override
Return the number of plastic steps in the last load step. Zero indicates elastic loading.
void Residual(TPZFMatrix< REAL > &res, int icase)