NeoPZ
pzporoanalysis.cpp
Go to the documentation of this file.
1 //$Id: pzporoanalysis.cpp,v 1.7 2009-10-05 03:49:58 erick Exp $
2 #include "pzporoanalysis.h"
3 
4 #include "pzlog.h"
5 #include "TPZMatTemporal.h"
6 #include "pzsolve.h"
7 
8 #ifdef LOG4CXX
9 static LoggerPtr PoroAnalysisLogger(Logger::getLogger("analysis.poro"));
10 #endif
11 
12 using namespace std;
13 
14 
16  TPZElastoPlasticAnalysis(), fPorousMaterialIds(), fRhsLast()
17 {
19 }
20 
23 {
24  int numeq = fCompMesh->NEquations();
25  fRhsLast.Redim(numeq,1);
26 
28 }
29 
31 {
32 #ifdef LOG4CXX
33 {
34  std::stringstream sout;
35  sout << "<<< TPZPoroElastoPlasticAnalysis::~TPZPoroElastoPlasticAnalysis() *** Killing Object\n";
36  LOGPZ_INFO(PoroAnalysisLogger,sout.str().c_str());
37 }
38 #endif
39 }
40 
41 /*
42 REAL TPZPoroElastoPlasticAnalysis::LocalAssemble(int precond)
43 {
44  TPZElastoPlasticAnalysis::LocalAssemble(precond);
45 
46  REAL norm = Norm(fRhs);
47 
48  #ifdef LOG4CXX
49  {
50  std::stringstream sout;
51  sout << "<<< TPZPoroElastoPlasticAnalysis::LocalAssemble() *** "
52  << " with Norm(Rhs) = " << norm;
53  LOGPZ_INFO(PoroAnalysisLogger,sout.str().c_str());
54  }
55  #endif
56 
57 
58 int i;
59  for(i = 0; i < 4; i++)cout << "\t" << fSolution(i,0);
60  cout << endl;
61  for(i = 0; i < 4; i++)cout << "\t" << fRhs(i,0);
62  cout << endl;
63 
64  return norm;
65 }
66 */
68 {
71 }
72 
74 {
77 }
78 
80 {
81  int i, n = fPorousMaterialIds.NElements();
82 
83  for(i = 0; i < n; i++)
84  {
86  TPZMatTemporal * pMatTemp = dynamic_cast<TPZMatTemporal *>(pMat);
87  if(pMatTemp)pMatTemp->SetContributionTime(time);
88  }
89 }
90 
92 {
93  int i, n = fPorousMaterialIds.NElements();
94 
95  for(i = 0; i < n; i++)
96  {
98  TPZMatTemporal * pMatTemp = dynamic_cast<TPZMatTemporal *>(pMat);
99  if(pMatTemp)pMatTemp->SetDeltaT(deltaT);
100  }
101 }
102 
104 {
106  int i, n = fCompMesh->NMaterials();
107 
108  for(i = 0; i < n; i++)
109  {
110  TPZMaterial * pMat = fCompMesh->MaterialVec()[i];
111  TPZMatTemporal * pMatTemp = dynamic_cast<TPZMatTemporal *>(pMat);
112  if(pMatTemp)fPorousMaterialIds.Push(pMat->Id() );
113  }
114 
115  return fPorousMaterialIds.NElements();
116 }
117 
118 void TPZPoroElastoPlasticAnalysis::Run(std::ostream &out,REAL tol ,int numiter,
119  TPZPostProcAnalysis * ppAnalysis, int res)
120 {
121 #ifdef LOG4CXX
122 {
123  std::stringstream sout;
124  sout << ">>> TPZPoroElastoPlasticAnalysis::Run() ***";
125  LOGPZ_INFO(PoroAnalysisLogger,sout.str().c_str());
126 }
127 #endif
128 
129  bool linesearch = false;
130  bool checkconv = false;
131  bool convordiv;
132  IterativeProcess(out, tol, numiter,linesearch,checkconv,convordiv);
133 
134  #ifdef LOG4CXX
135  {
136  std::stringstream sout;
137  sout << "*** TPZPoroElastoPlasticAnalysis::Run() *** IterativeProcess() completed";
138  LOGPZ_INFO(PoroAnalysisLogger,sout.str().c_str());
139  }
140  #endif
141 
142  AcceptSolution();
143 
144  if(ppAnalysis)
145  {
146  #ifdef LOG4CXX
147  {
148  std::stringstream sout;
149  sout << "*** TPZPoroElastoPlasticAnalysis::Run() *** PostProcessing ";
150  LOGPZ_INFO(PoroAnalysisLogger,sout.str().c_str());
151  }
152  #endif
153  TransferSolution(*ppAnalysis);
154  ppAnalysis->PostProcess(res);
155  }
156 
157  #ifdef LOG4CXX
158  {
159  std::stringstream sout;
160  sout << "<<< TPZPoroElastoPlasticAnalysis::ManageIterativeProcess() *** Exiting";
161  LOGPZ_INFO(PoroAnalysisLogger,sout.str().c_str());
162  }
163  #endif
164 }
165 
166 
167 REAL TPZPoroElastoPlasticAnalysis::AcceptSolution(const int ResetOutputDisplacements)
168 {
169 
170  int i, n = fPorousMaterialIds.NElements();
171  int nstate = 0;
172 
173  for(i = 0; i < n; i++)
174  {
176  if(pMat->NStateVariables() > nstate)
177  nstate = pMat->NStateVariables();
178  }
179 
180  n = fSolution.Rows();
181 
182  if(ResetOutputDisplacements)
183  {
184  fCumSol.Zero();
185  }else{
186  fCumSol += fSolution;
187  }
188 
189  #ifdef LOG4CXX
190  {
191  std::stringstream sout;
192  sout << ">>> TPZPoroElastoPlasticAnalysis::AcceptSolution *** "
193  << " with Norm(fCumSol) = " << Norm(fCumSol);
194  LOGPZ_INFO(PoroAnalysisLogger,sout.str().c_str());
195  }
196  #endif
197 
198  this->SetUpdateMem(true);
199 
200  fRhs.Zero();
201 
202  Assemble();
203  REAL norm = Norm(Rhs());
204 
205  this->SetUpdateMem(false);
206 
207  fSolution.Zero();
208 
210 
211  return norm;
212 }
void SetUpdateMem(int update)
Forces the materials with memory to update the internal plastic memory during the subsequent assemble...
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.
TPZFMatrix< STATE > fSolution
Solution vector.
Definition: pzanalysis.h:50
virtual void SetDeltaT(const REAL deltaT)
int64_t NEquations()
This computes the number of equations associated with non-restrained nodes.
Definition: pzcmesh.cpp:721
TPZCompMesh * fCompMesh
Computational mesh.
Definition: pzanalysis.h:44
virtual void Assemble()
Assemble the stiffness matrix and load vector.
Definition: pzanalysis.cpp:304
virtual int NStateVariables() const =0
Returns the number of state variables associated with the material.
size_t NMaterials() const
Number of materials.
Definition: pzcmesh.h:172
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
Definition: pzmanvector.h:426
void TransferSolution(TPZPostProcAnalysis &ppanalysis)
void SetContributionTime(TPZContributeTime time)
Informs the Analysis class the time at which the current solution in the computational mesh belongs...
This abstract class defines the behaviour which each derived class needs to implement.
Definition: TPZMaterial.h:39
int Zero() override
Makes Zero all the elements.
Definition: pzfmatrix.h:651
void LoadSolution(const TPZFMatrix< STATE > &sol)
Given the solution of the global system of equations, computes and stores the solution for the restri...
Definition: pzcmesh.cpp:441
static const double tol
Definition: pzgeoprism.cpp:23
void Push(const T object)
Pushes a copy of the object on the stack.
Definition: pzstack.h:80
#define LOGPZ_INFO(A, B)
Define log for informations.
Definition: pzlog.h:89
virtual void LoadSolution()
Load the solution into the computable grid.
Definition: pzanalysis.cpp:441
virtual void SetDeltaT(const REAL deltaT)
Informs the pertinent poroelastoplastic materials the current timestep.
TVar Norm(const TPZFMatrix< TVar > &A)
Returns the norm of the matrix A.
void SetAdvancedState()
Sets the solution vector to be the one representing the Advanced State or the advanced implicit solut...
virtual void IterativeProcess(std::ostream &out, REAL tol, int numiter, int niter_update_jac, bool linesearch)
Iterative process using the linear elastic material as tangent matrix.
TPZMaterial * FindMaterial(int id)
Find the material with identity id.
Definition: pzcmesh.cpp:297
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
string res
Definition: test.py:151
void SetLastState()
Sets the solution vector to be the one representing the Current State or the last explicit solution...
virtual void PostProcess(int resolution)
Draw solution over mesh for all dimensions.
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
Definition: pzfmatrix.h:616
TPZStack< int > fPorousMaterialIds
Stores a list of Ids of all porous materials in the computational mehs.
std::map< int,TPZMaterial *> & MaterialVec()
Returns a reference to the material pointers vector.
Definition: pzcmesh.h:203
virtual void SetContributionTime(TPZContributeTime time)
TPZFMatrix< REAL > fRhsLast
Stores the last state RHS assembled state, sparing computational time by avoiding evaluating the same...
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
Contains TPZSolver class which defines a abstract class of solvers which will be used by matrix class...
int Id() const
Definition: TPZMaterial.h:170
int FindPorousMaterials()
Searches in the computational mesh for all the porous material instantiations.
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
TPZFMatrix< STATE > & Rhs()
Returns the load vector.
Definition: pzanalysis.h:174
TPZFMatrix< STATE > fRhs
Load vector.
Definition: pzanalysis.h:48
TPZContributeTime
Indicates which term is put in the right hand side and tangent matrix.
Definition: pzconslaw.h:47
virtual void Run(std::ostream &out, REAL tol, int numiter, TPZPostProcAnalysis *ppAnalysis, int res)
virtual REAL AcceptSolution(const int ResetOutputDisplacements=0)
Reimplemented in order to manage the different kinds of varibles. Displacements are incremental and p...