NeoPZ
TPZMatPorous_impl.h
Go to the documentation of this file.
1 //
2 // TPZMatPorous_impl.h
3 // pz
4 //
5 // Created by Omar DurĂ¡n on 9/8/18.
6 //
7 
8 #include "TPZMatPorous.h"
10 
11 #ifdef LOG4CXX
12 #include "pzlog.h"
13 static LoggerPtr porousLogger(Logger::getLogger("material.pzPoro"));
14 #endif
15 
16 
17 template <class T, class TMEM>
18 TPZMatPorous<T, TMEM >::TPZMatPorous() : TBASEPOROUS(T, TMEM)(), fk(0.), fMu(1.), fStorageEps(0.), m_hardening(1.), fRhof(0.)
19 {
20  fDeltaT = 1.;
22 #ifdef LOG4CXX
23  {
24  std::stringstream sout;
25  sout << ">>> TPZMatPorous<TBASEPOROUS(T, TMEM)>() constructor called ***";
26  LOGPZ_INFO(porousLogger,sout.str().c_str());
27  }
28 #endif
29 
30 }
31 
32 template <class T, class TMEM>
33 TPZMatPorous<T, TMEM >::TPZMatPorous(int id) : TBASEPOROUS(T, TMEM)(id), fk(0.), fMu(1.), fStorageEps(0.), m_hardening(1.), fRhof(0.)
34 {
35  fDeltaT = 1.;
37 #ifdef LOG4CXX
38  {
39  std::stringstream sout;
40  sout << ">>> TPZMatPorous<TBASEPOROUS(T, TMEM)>(int id) constructor called with id = " << id << " ***";
41  LOGPZ_INFO(porousLogger,sout.str().c_str());
42  }
43 #endif
44 
45 }
46 
47 template <class T, class TMEM>
49 fk(mat.fk), fMu(mat.fMu),
51 fRhof(mat.fRhof)
52 {
53  fDeltaT = mat.fDeltaT;
54  fTime = mat.fTime;
55 #ifdef LOG4CXX
56  {
57  std::stringstream sout;
58  sout << ">>> TPZMatPorous<T>() copy constructor called ***";
59  LOGPZ_INFO(porousLogger,sout.str().c_str());
60  }
61 #endif
62 }
63 
64 template <class T, class TMEM>
66 {
67 
68 }
69 
70 template <class T, class TMEM>
71 void TPZMatPorous<T, TMEM >::Print(std::ostream &out, const int memory)
72 {
73  out << this->Name();
74  out << "\n with template argurment TBASEPOROUS(T, TMEM) = " << TBASEPOROUS(T, TMEM)::Name();
75  out << "\n Delta Time: " << fDeltaT;
76  out << "\n Permeability: " << fk;
77  out << "\n Fluid viscosity: " << fMu;
78  out << "\n Porous medium constant strain Storage Coeff: " << fStorageEps;
79  out << "\n Biot-Willis alpha: " << m_hardening;
80  out << "\n Base material Data:\n";
81  TBASEPOROUS(T, TMEM)::Print(out, memory);
82 }
83 
84 template <class T, class TMEM>
85 int TPZMatPorous<T, TMEM >::VariableIndex(const std::string &name)
86 {
87  if(!strcmp("PorePressure", name.c_str()))return TPZMatPorous<T, TMEM >::EPorePressure;
88  return TBASEPOROUS(T, TMEM)::VariableIndex(name);
89 }
90 
91 template <class T, class TMEM>
93 {
94  if(var == TPZMatPorous<T, TMEM >::EPorePressure)return 1;
95 
96  return TBASEPOROUS(T, TMEM)::NSolutionVariables(var);
97 }
98 
99 template <class T, class TMEM>
101 {
103  {
104  REAL Pp;
105  TPZVec<REAL> dPp;
106  ComputePorePressure(data, Pp, dPp);
107  Solout[0] = Pp;
108  return;
109  }
110 
111  TBASEPOROUS(T, TMEM)::Solution(data, var, Solout);
112 
113  /*
114  #ifdef LOG4CXX
115  {
116  std::stringstream sout;
117  sout << "<<< TPZMatPorous<T>::Solution() *** Sol = " << Solout;
118 
119  LOGPZ_DEBUG(porousLogger,sout.str().c_str());
120  }
121  #endif
122  */
123 }
124 
125 template <class T, class TMEM>
127 {
128  int in, jn;
129  REAL val, Pp;
130  TPZVec<REAL> dPp;
131 
132  TPZFMatrix<REAL> &dphi = data.dphix, dphiXYZ;
133  TPZFMatrix<REAL> &phi = data.phi;
134  TPZFMatrix<REAL> &axes = data.axes, axesT;
135  TPZManVector<REAL,3> &x = data.x;
136 
137  const int phr = phi.Rows();
138  if(this->fForcingFunction)
139  this->fForcingFunction->Execute(x,this->m_force);
140 
141  int dim = Dimension();
142  int nstate = NStateVariables();
143 
144  ComputePorePressure(data, Pp, dPp);
145 
146  if(TBASEPOROUS(T, TMEM)::fUpdateMem)
147  UpdatePorePressure(data);
148 
149 
150 #ifdef LOG4CXX
151  {
152  std::stringstream sout;
153  sout << ">>> TPZMatPorous<T, TMEM >::Contribute ***";
154  if(fTime == Last_CT) sout << " Last State Contribution";
155  if(fTime == Advanced_CT) sout << " Advanced State Contribution";
156  LOGPZ_DEBUG(porousLogger,sout.str().c_str());
157  }
158 #endif
159 
160  // cout << "\nPp = " << Pp;
161 
162  // rotating the shape functions to the XYZ coordinates
163  axes.Transpose(&axesT);
164  axesT.Multiply(dphi,dphiXYZ);
165 
166  TPZManVector<REAL, 3> Q(3,0);
167 
168  for(in = 0; in < phr; in++) { //in: test function index
169 
170  //qh contribution
171  // m_force represents the gravity acceleration
172  val = fRhof * (fk / fMu) *
173  ( TBASEPOROUS(T, TMEM)::m_force[0] * dphiXYZ(0,in) +
174  TBASEPOROUS(T, TMEM)::m_force[1] * dphiXYZ(1,in) +
175  TBASEPOROUS(T, TMEM)::m_force[2] * dphiXYZ(2,in) )
176  * fDeltaT;
177  //qS contribution (referring to the deltaP iterative solution)
178  val -= fStorageEps * phi(in,0) * data.sol[0][dim];// / fDeltaT;
179  //qH contribution
180  val -= (fk / fMu) *
181  ( dphiXYZ(0,in)*dPp[0] +
182  dphiXYZ(1,in)*dPp[1] +
183  dphiXYZ(2,in)*dPp[2] )
184  * fDeltaT;
185  //qQT (referring to the deltaP iterative solution)
186  val -= m_hardening *
187  ( phi(in, 0) * data.dsol[0](0, 0) +
188  phi(in, 0) * data.dsol[0](1, 1) +
189  phi(in, 0) * data.dsol[0](2, 2) );// /fDeltaT
190 
191  ef(in*nstate+dim,0) += weight * val;
192 
193  //fq contributions
194  Q[0] = m_hardening * Pp * dphiXYZ(0, in);
195  Q[1] = m_hardening * Pp * dphiXYZ(1, in);
196  Q[2] = m_hardening * Pp * dphiXYZ(2, in);
197 
198  ef(in*nstate+0,0) += weight * Q[0];
199  ef(in*nstate+1,0) += weight * Q[1];
200  ef(in*nstate+2,0) += weight * Q[2];
201 
202  for( jn = 0; jn < phr; jn++ ) { //jn: trial function index
203 
204  // -Q matrix contributions
205  Q[0] = m_hardening * weight * phi(jn, 0) * dphiXYZ(0, in);
206  Q[1] = m_hardening * weight * phi(jn, 0) * dphiXYZ(1, in);
207  Q[2] = m_hardening * weight * phi(jn, 0) * dphiXYZ(2, in);
208 
209  ek(in * nstate + 0, jn * nstate + dim) -= Q[0];
210  ek(in * nstate + 1, jn * nstate + dim) -= Q[1];
211  ek(in * nstate + 2, jn * nstate + dim) -= Q[2];
212 
213  // Transpose[Q] matrix contributions
214  Q[0] = m_hardening * weight * phi(in, 0) * dphiXYZ(0, jn);
215  Q[1] = m_hardening * weight * phi(in, 0) * dphiXYZ(1, jn);
216  Q[2] = m_hardening * weight * phi(in, 0) * dphiXYZ(2, jn);
217 
218  ek(in * nstate + dim, jn * nstate + 0) += Q[0];// / fDeltaT;
219  ek(in * nstate + dim, jn * nstate + 1) += Q[1];// / fDeltaT;
220  ek(in * nstate + dim, jn * nstate + 2) += Q[2];// / fDeltaT;
221 
222  // S matrix contibution
223  val = fStorageEps * phi(in,0) * phi(jn,0);// / fDeltaT;
224 
225  // H matrix contributions
226  val += (fk / fMu) *
227  ( dphiXYZ(0,in)*dphiXYZ(0,jn) +
228  dphiXYZ(1,in)*dphiXYZ(1,jn) +
229  dphiXYZ(2,in)*dphiXYZ(2,jn) )
230  * fDeltaT;
231 
232  ek(in * nstate + dim, jn * nstate + dim) += weight * val;
233 
234  }//jn
235 
236  }//in
237 
238 #ifdef LOG4CXX
239  {
240  std::stringstream sout;
241  sout << "*** TPZMatPorous<T>::Contribute ***";
242  sout << "ek Matrix before base classe contribution: ";
243  //ek.Print("",sout,EMatlabNonZeros);
244  LOGPZ_DEBUG(porousLogger,sout.str().c_str());
245  }
246 #endif
247 
248  TBASEPOROUS(T, TMEM)::Contribute(data, weight, ek, ef);
249 
250 #ifdef LOG4CXX
251  {
252  std::stringstream sout;
253  sout << "<<< TPZMatPorous<T>::Contribute ***";
254  sout << "ek Matrix after base classe contribution: ";
255  ek.Print("",sout,EMatlabNonZeros);
256  LOGPZ_DEBUG(porousLogger,sout.str().c_str());
257  }
258 #endif
259 }
260 
261 template <class T, class TMEM>
263  REAL weight,
264  TPZFMatrix<REAL> &ek,
265  TPZFMatrix<REAL> &ef,
266  TPZBndCond &bc)
267 {
268 
269 #ifdef LOG4CXX
270  {
271  std::stringstream sout;
272  sout << ">>> TPZMatPorous<T>::ContributeBC *** with bc.Type()=" << bc.Type();
273  LOGPZ_DEBUG(porousLogger,sout.str().c_str());
274  }
275 #endif
276  TPZFMatrix<REAL> &phi = data.phi;
277 
278  const REAL BIGNUMBER = 1.e12;
279 
280  int dim = Dimension();
281  int nstate = NStateVariables();
282 
283  const int phr = phi.Rows();
284  int in,jn;
285  REAL v2, v1;
286 
287  v1 = bc.Val1()(dim, dim);
288  v2 = bc.Val2()(dim, 0);
289 
290  switch (bc.Type()) {
291  case 10: // Dirichlet Pressure condition
292  case 3: // Mechanical Directional Dirichlet condition
293  for(in = 0 ; in < phr; in++) {
294  ef(nstate * in + dim,0) += BIGNUMBER * (v1 - v1) * phi(in,0) * weight * v2;
295  for (jn = 0 ; jn < phr; jn++) {
296  ek(nstate * in + dim,nstate * jn + dim) += BIGNUMBER * phi(in,0) * phi(jn,0) * weight * v2;
297  }//jn
298  }//in
299  break;
300 
301  case 11: // Neumann condition (boundary flow condition) (qGamma)
302  for(in = 0 ; in < phi.Rows(); in++)
303  ef(nstate * in + dim,0) += - v1 * phi(in,0) * weight;
304  break;
305  default:
306  break;
307 
308 #ifdef LOG4CXX
309  {
310  std::stringstream sout;
311  sout << "<<< TPZMatPorous<T>::ContributeBC *** No Flow BC of Type " << bc.Type()
312  << " - Verifying mechanical BC Types in the parent class...";
313  LOGPZ_DEBUG(porousLogger,sout.str().c_str());
314  }
315 #endif
316 
317  }//switch
318 
319  TBASEPOROUS(T, TMEM)::ContributeBC(data, weight, ek, ef, bc);
320 
321 }
322 
323 template <class T, class TMEM>
325 {
326  TPZMaterial::Contribute(data, weight, ef);//not efficient but here to remember reimplementing it when Contribute becomes robust
327 }
328 
329 template <class T, class TMEM>
331  REAL weight,
332  TPZFMatrix<REAL> &ef,
333  TPZBndCond &bc)
334 {
335  TPZMaterial::ContributeBC(data, weight, ef, bc);//not efficient but here to remember reimplementing it when ContributeBC becomes robust
336 }
337 
338 template <class T, class TMEM>
341  TPZVec<REAL> &u_exact,TPZFMatrix<REAL> &du_exact,TPZVec<REAL> &values)
342 {
343  TBASEPOROUS(T, TMEM)::Errors(x,u,dudx, axes, flux, u_exact, du_exact, values);
344 
345 }
346 
347 
348 template <class T, class TMEM>
350 {
351  return new TPZMatPorous<T, TMEM>(*this);
352 }
353 
354 template <class T, class TMEM>
356 {
357  return "TPZMatPorous<TBASEPOROUS(T, TMEM)>";
358 }
359 
360 template <class T, class TMEM>
361 void TPZMatPorous<T, TMEM >::Write(TPZStream &buf, int withclassid) const{
362  TBASEPOROUS(T, TMEM)::Write(buf, 0);
363 
364  buf. Write(&fDeltaT, 1);
365  buf. Write(&fk, 1);
366  buf. Write(&fMu, 1);
367  buf. Write(&fStorageEps, 1);
368  buf. Write(&m_hardening, 1);
369 
370 }
371 
372 template <class T, class TMEM>
373 void TPZMatPorous<T, TMEM >::Read(TPZStream &buf, void *context)
374 {
375  // this->TPZSavable::Read(buf, context);
376 
377  TBASEPOROUS(T, TMEM)::Read(buf, context);
378 
379  buf. Read(&fDeltaT, 1);
380  buf. Read(&fk, 1);
381  buf. Read(&fMu, 1);
382  buf. Read(&fStorageEps, 1);
383  buf. Read(&m_hardening, 1);
384 }
385 
386 template <class T, class TMEM>
387 void TPZMatPorous<T, TMEM >::SetUp(const REAL &k, const REAL &Mu,
388  const REAL &StorageEps,
389  const REAL &Alpha,
390  const REAL &Rhof)
391 {
392  fk = k;
393  fMu = Mu;
394  fStorageEps = StorageEps;
395  m_hardening = Alpha;
396  fRhof = Rhof;
397 }
398 
399 template <class T, class TMEM>
401 
402  TBASEPOROUS(T, TMEM)::FillDataRequirements(data);
403 
404 }
405 
406 template <class T, class TMEM>
408 {
409  int dim = Dimension(), i;
410  int intPt = data.intGlobPtIndex;
411 
412  // Retrieving information at time n
413  Pp = TBASEPOROUS(T, TMEM)::MemItem(intPt).fPorePressure;
414  dPp = TBASEPOROUS(T, TMEM)::MemItem(intPt).fdPorePressure;
415 
416  // adding deltaP information from n+1 time
417  Pp += data.sol[0][dim];
418  for(i = 0; i < dim; i++)dPp[i] += data.dsol[0](i, dim);
419 }
420 
421 template <class T, class TMEM>
423 {
424  int dim = Dimension(), i;
425  int intPt = data.intGlobPtIndex;
426 
427  // updating n+1 information
428  TBASEPOROUS(T, TMEM)::MemItem(intPt).fPorePressure += data.sol[0][dim];
429 
430  for(i = 0; i < dim; i++)
431  {
432  TBASEPOROUS(T, TMEM)::MemItem(intPt).fdPorePressure[i] += data.dsol[0](i, dim);
433  }
434 }
435 
436 
437 template <class T, class TMEM>
439 {
440  TBASEPOROUS(T, TMEM)::fDefaultMem.fPorePressure = Pp;
441 }
442 
virtual void Execute(const TPZVec< REAL > &x, TPZVec< TVar > &f, TPZFMatrix< TVar > &df)
Performs function computation.
Definition: pzfunction.h:38
virtual int NSolutionVariables(int var) override
virtual void Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix< REAL > &ek, TPZFMatrix< REAL > &ef) 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.
TPZManVector< REAL, 3 > x
value of the coordinate at the integration point
TPZManVector< REAL, 3 > m_force
clarg::argBool bc("-bc", "binary checkpoints", false)
TPZContributeTime fTime
TPZFNMatrix< 660, REAL > dphi
values of the derivative of the shape functions over the master element
int Type()
Definition: pzbndcond.h:249
virtual void Write(TPZStream &buf, int withclassid) const override
TPZGradSolVec dsol
vector of the derivatives of the solution at the integration point
virtual std::string Name() override
virtual int VariableIndex(const std::string &name) override
REAL val(STATE &number)
Returns value of the variable.
Definition: pzartdiff.h:23
virtual void Read(TPZStream &buf, void *context) override
virtual void Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef)=0
It computes a contribution to the stiffness matrix and load vector at one integration point...
void SetPorePressure(const REAL Pp)
TPZFMatrix< STATE > & Val2(int loadcase=0)
Definition: pzbndcond.h:255
TPZFNMatrix< 220, REAL > phi
vector of shapefunctions (format is dependent on the value of shapetype)
void SetUp(const REAL &k, const REAL &Mu, const REAL &StorageEps, const REAL &Alpha, const REAL &Rhof)
Initializes the poroelastic material coefficients.
TPZFNMatrix< 660, REAL > dphix
values of the derivative of the shape functions
virtual void Solution(TPZMaterialData &data, int var, TPZVec< REAL > &Solout) override
This abstract class defines the behaviour which each derived class needs to implement.
Definition: TPZMaterial.h:39
virtual void FillDataRequirements(TPZMaterialData &data) override
Implements an porous media material to be used together with elastic elastoplastic mechanical counter...
Definition: TPZMatPorous.h:22
bool fUpdateMem
Flag to indicate whether the memory data are to be updated in an assemble loop.
void UpdatePorePressure(TPZMaterialData &data)
virtual void ContributeBC(TPZMaterialData &data, REAL weight, TPZFMatrix< REAL > &ek, TPZFMatrix< REAL > &ef, TPZBndCond &bc) override
#define LOGPZ_INFO(A, B)
Define log for informations.
Definition: pzlog.h:89
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
Definition: pzlog.h:87
This class defines the boundary condition for TPZMaterial objects.
Definition: pzbndcond.h:29
#define TBASEPOROUS(T, TMEM)
Definition: TPZMatPorous.h:15
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
TPZFNMatrix< 9, REAL > axes
axes indicating the directions of the derivatives of the shapefunctions
TPZFMatrix< STATE > & Val1()
Definition: pzbndcond.h:253
int intGlobPtIndex
global point index
virtual void ContributeBC(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc)=0
It computes a contribution to the stiffness matrix and load vector at one BC integration point...
virtual void Errors(TPZVec< REAL > &x, TPZVec< REAL > &u, TPZFMatrix< REAL > &dudx, TPZFMatrix< REAL > &axes, TPZVec< REAL > &flux, TPZVec< REAL > &u_exact, TPZFMatrix< REAL > &du_exact, TPZVec< REAL > &values) override
virtual void Print(std::ostream &out=std::cout, const int memory=0) override
virtual ~TPZMatPorous()
Default destructor.
TMEM fDefaultMem
Default memory settings.
TPZAutoPointer< TPZFunction< STATE > > fForcingFunction
Pointer to forcing function, it is the right member at differential equation.
Definition: TPZMaterial.h:47
virtual void Print(std::ostream &out) const
Definition: pzmatrix.h:253
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
def values
Definition: rdt.py:119
virtual TPZMaterial * NewMaterial() override
void ComputePorePressure(TPZMaterialData &data, REAL &Pp, TPZVec< REAL > &dPp)
virtual TMEM & MemItem(const int i) const
TPZSolVec sol
vector of the solutions at the integration point
void Transpose(TPZMatrix< TVar > *const T) const override
It makes *T the transpose of current matrix.
Definition: pzfmatrix.cpp:1073
virtual int NStateVariables() const override
Definition: TPZMatPorous.h:68
virtual int Dimension() const override
Definition: TPZMatPorous.h:65