NeoPZ
TPZMixedPoissonParabolic.cpp
Go to the documentation of this file.
1 
9 #include "pzlog.h"
10 #include "pzbndcond.h"
11 #include "pzfmatrix.h"
12 #include "pzaxestools.h"
13 
14 
15 #include <iostream>
16 
17 #ifdef LOG4CXX
18 static LoggerPtr logdata(Logger::getLogger("pz.mixedpoisson.data"));
19 static LoggerPtr logerror(Logger::getLogger("pz.mixedpoisson.error"));
20 #endif
21 
23 {
24 }
25 
27 {
28 }
29 
31 }
32 
34 {
35 }
36 
39  fRho = copy.fRho;
40  fDeltaT = copy.fDeltaT;
41  return *this;
42 }
43 
44 
45 void TPZMixedPoissonParabolic::Print(std::ostream &out) {
46  out << "name of material : " << Name() << "\n";
48  out << "rho = " << fRho << std::endl;
49  out << "delta t = " << fDeltaT << fDeltaT << std::endl;
50 }
51 
53 
54 #ifdef PZDEBUG
55  int nref = datavec.size();
56  if (nref != 2 ) {
57  std::cout << " Erro. The size of the datavec is different from 2 \n";
58  DebugStop();
59  }
61  {
62  DebugStop();
63  }
64 #endif
65 
66  STATE force = ff;
67  if(fForcingFunction) {
69  fForcingFunction->Execute(datavec[1].x,res);
70  force = res[0];
71  }
72 
73  STATE pressureN = datavec[1].sol[0][0];
74 
75  TPZFNMatrix<9,REAL> PermTensor = fTensorK;
76  TPZFNMatrix<9,REAL> InvPermTensor = fInvK;
77  //int rtens = 2*fDim;
79  PermTensor.Zero();
80  InvPermTensor.Zero();
81  TPZFNMatrix<18,STATE> resultMat(2*fDim,fDim,0.);
83  fPermeabilityFunction->Execute(datavec[1].x,res,resultMat);
84 
85  for(int id=0; id<fDim; id++){
86  for(int jd=0; jd<fDim; jd++){
87 
88  PermTensor(id,jd) = resultMat(id,jd);
89  InvPermTensor(id,jd) = resultMat(id+fDim,jd);
90  }
91  }
92  }
93 
94  // Setting the phis
95  TPZFMatrix<REAL> &phiQ = datavec[0].phi;
96  TPZFMatrix<REAL> &phip = datavec[1].phi;
97  TPZFMatrix<REAL> &dphiQ = datavec[0].dphix;
98  TPZFMatrix<REAL> &dphiP = datavec[1].dphix;
99 
100 
101  int phrq, phrp;
102  phrp = phip.Rows();
103  phrq = datavec[0].fVecShapeIndex.NElements();
104 
105 #ifdef PZDEBUG
106  if(phrp+phrq != ek.Rows())
107  {
108  DebugStop();
109  }
110 #endif
111  //Calculate the matrix contribution for flux. Matrix A
112  for(int iq=0; iq<phrq; iq++)
113  {
114  //ef(iq, 0) += 0.;
115  int ivecind = datavec[0].fVecShapeIndex[iq].first;
116  int ishapeind = datavec[0].fVecShapeIndex[iq].second;
117  TPZFNMatrix<3,REAL> ivec(3,1,0.);
118  for(int id=0; id<3; id++){
119  ivec(id,0) = datavec[0].fNormalVec(id,ivecind);
120  //ivec(1,0) = datavec[0].fNormalVec(1,ivecind);
121  //ivec(2,0) = datavec[0].fNormalVec(2,ivecind);
122  }
123 
124 
125  TPZFNMatrix<3,REAL> ivecZ(3,1,0.);
126  TPZFNMatrix<3,REAL> jvecZ(3,1,0.);
127  for (int jq=0; jq<phrq; jq++)
128  {
129  TPZFNMatrix<3,REAL> jvec(3,1,0.);
130  int jvecind = datavec[0].fVecShapeIndex[jq].first;
131  int jshapeind = datavec[0].fVecShapeIndex[jq].second;
132 
133  for(int id=0; id<3; id++){
134  jvec(id,0) = datavec[0].fNormalVec(id,jvecind);
135  }
136 
137  //dot product between Kinv[u]v
138  jvecZ.Zero();
139  for(int id=0; id<3; id++){
140  for(int jd=0; jd<3; jd++){
141  jvecZ(id,0) += InvPermTensor(id,jd)*jvec(jd,0);
142  }
143  }
144  //jvecZ.Print("mat1 = ");
145  REAL prod1 = ivec(0,0)*jvecZ(0,0) + ivec(1,0)*jvecZ(1,0) + ivec(2,0)*jvecZ(2,0);
146  ek(iq,jq) += fvisc*weight*phiQ(ishapeind,0)*phiQ(jshapeind,0)*prod1;
147  }
148  }
149 
150 
151  // Coupling terms between flux and pressure. Matrix B
152  for(int iq=0; iq<phrq; iq++)
153  {
154  int ivecind = datavec[0].fVecShapeIndex[iq].first;
155  int ishapeind = datavec[0].fVecShapeIndex[iq].second;
156 
157  TPZFNMatrix<3,REAL> ivec(3,1,0.);
158  for(int id=0; id<3; id++){
159  ivec(id,0) = datavec[0].fNormalVec(id,ivecind);
160  }
161  TPZFNMatrix<3,REAL> axesvec(3,1,0.);
162  datavec[0].axes.Multiply(ivec,axesvec);
163 
164  REAL divwq = 0.;
165  for(int iloc=0; iloc<fDim; iloc++)
166  {
167  divwq += axesvec(iloc,0)*dphiQ(iloc,ishapeind);
168  }
169  for (int jp=0; jp<phrp; jp++) {
170 
171  REAL fact = (-1.)*weight*phip(jp,0)*divwq;
172  // Matrix B
173  ek(iq, phrq+jp) += fact;
174 
175  // Matrix B^T
176  ek(phrq+jp,iq) += fact;
177 
178  }
179  }
180 
181  for (int ip=0; ip<phrp; ip++) {
182  for (int jp=0; jp < phrp; jp++) {
183  ek(phrq+ip,phrq+jp) += (-1.)*weight*phip(ip,0)*phip(jp,0)*fRho/fDeltaT;
184  }
185  }
186 
187  //termo fonte referente a equacao da pressao
188  for(int ip=0; ip<phrp; ip++){
189  ef(phrq+ip,0) += (-1.)*weight*fRho*pressureN/fDeltaT*phip(ip,0);
190  }
191 
192 
193 }
194 
196 
197 
198 #ifdef PZDEBUG
199  int nref = datavec.size();
200  if (nref != 2 ) {
201  std::cout << " Erro. The size of the datavec is different from 2 \n";
202  DebugStop();
203  }
204  if(fIsStabilized || fUseHdois)
205  {
206  DebugStop();
207  }
208 #endif
209  TPZFMatrix<REAL> &phip = datavec[1].phi;
210 
211  int phrq, phrp;
212  phrp = phip.Rows();
213  phrq = datavec[0].fVecShapeIndex.NElements();
214 
215  STATE pressureN = datavec[1].sol[0][0];
216 
217  //termo fonte referente a equacao da pressao
218  for(int ip=0; ip<phrp; ip++){
219  ef(phrq+ip,0) += (-1.)*weight*fRho*pressureN/fDeltaT*phip(ip,0);
220  }
221 
222 
223 }
225 
226 #ifdef PZDEBUG
227  int nref = datavec.size();
228  if (nref != 2 ) {
229  std::cout << " Erro.!! datavec tem que ser de tamanho 2 \n";
230  DebugStop();
231  }
232  if (bc.Type() > 2 ) {
233  std::cout << " Erro.!! Neste material utiliza-se apenas condicoes de Neumann e Dirichlet\n";
234  DebugStop();
235  }
236 #endif
237 
238  TPZFMatrix<REAL> &phiQ = datavec[0].phi;
239  int phrq = phiQ.Rows();
240 
241  REAL v2;
242  if(bc.HasForcingFunction())
243  {
245  TPZFNMatrix<9,STATE> gradu(Dimension(),1);
246  bc.ForcingFunction()->Execute(datavec[0].x,res,gradu);
247  v2 = res[0];
248  }else
249  {
250  v2 = bc.Val2()(0,0);
251  }
252 
253  switch (bc.Type()) {
254  case 0 : // Dirichlet condition
255  //primeira equacao
256  for(int iq=0; iq<phrq; iq++)
257  {
258  //the contribution of the Dirichlet boundary condition appears in the flow equation
259  ef(iq,0) += (-1.)*v2*phiQ(iq,0)*weight;
260  }
261  break;
262 
263  case 1 : // Neumann condition
264  //primeira equacao
265  for(int iq=0; iq<phrq; iq++)
266  {
267  ef(iq,0)+= gBigNumber*v2*phiQ(iq,0)*weight;
268  for (int jq=0; jq<phrq; jq++) {
269 
270  ek(iq,jq)+= gBigNumber*phiQ(iq,0)*phiQ(jq,0)*weight;
271  }
272  }
273  break;
274 
275  case 2 : // mixed condition
276  for(int iq = 0; iq < phrq; iq++) {
277 
278  ef(iq,0) += v2*phiQ(iq,0)*weight;
279  for (int jq = 0; jq < phrq; jq++) {
280  ek(iq,jq) += weight*bc.Val1()(0,0)*phiQ(iq,0)*phiQ(jq,0);
281  }
282  }
283 
284  break;
285  }
286 
287 }
288 
289 
291 {
292  int nref = datavec.size();
293  for(int i = 0; i<nref; i++ )
294  {
295  datavec[i].SetAllRequirements(false);
296  datavec[i].fNeedsNeighborSol = false;
297  datavec[i].fNeedsNeighborCenter = false;
298  datavec[i].fNeedsNormal = false;
299  datavec[i].fNeedsHSize = false;
300  }
301  datavec[1].fNeedsSol = true;
302 }
303 
304 
virtual void Execute(const TPZVec< REAL > &x, TPZVec< TVar > &f, TPZFMatrix< TVar > &df)
Performs function computation.
Definition: pzfunction.h:38
TPZFNMatrix< 9, REAL > fInvK
inverse of the permeability tensor.
Definition: mixedpoisson.h:44
REAL fvisc
fluid viscosity
Definition: mixedpoisson.h:47
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.
Implements a vector class which allows to use external storage provided by the user. Utility.
Definition: pzquad.h:16
virtual void ContributeBC(TPZVec< TPZMaterialData > &datavec, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc)
It computes a contribution to the stiffness matrix and load vector at one BC integration point to mul...
virtual std::string Name()
Returns the name of the material.
clarg::argBool bc("-bc", "binary checkpoints", false)
int Dimension() const override
Returns the integrable dimension of the material.
Definition: pzpoisson3d.h:158
int Type()
Definition: pzbndcond.h:249
This class implements a simple vector storage scheme for a templated class T. Utility.
Definition: pzgeopoint.h:19
virtual void Print(std::ostream &out)
Prints out the data associated with the material.
TPZFMatrix< STATE > & Val2(int loadcase=0)
Definition: pzbndcond.h:255
Contains the TPZBndCond class which implements a boundary condition for TPZMaterial objects...
TPZAutoPointer< TPZFunction< STATE > > & ForcingFunction()
Returns a procedure as source function for the material.
Definition: TPZMaterial.h:397
int Zero() override
Makes Zero all the elements.
Definition: pzfmatrix.h:651
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
Contains TPZMatrixclass which implements full matrix (using column major representation).
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
This class defines the boundary condition for TPZMaterial objects.
Definition: pzbndcond.h:29
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
void FillDataRequirements(TPZVec< TPZMaterialData > &datavec)
Fill material data parameter with necessary requirements for the Contribute method. Here, in base class, all requirements are considered as necessary. Each derived class may optimize performance by selecting only the necessary data.
string res
Definition: test.py:151
TPZFMatrix< STATE > & Val1()
Definition: pzbndcond.h:253
REAL ff
Forcing function value.
Definition: mixedpoisson.h:38
virtual int HasForcingFunction()
Directive that gives true if the material has a forcing function.
Definition: TPZMaterial.h:472
static REAL gBigNumber
Big number to penalization method, used for Dirichlet conditions.
Definition: TPZMaterial.h:83
Material to solve a mixed poisson problem 2d by multiphysics simulation.
Definition: mixedpoisson.h:34
virtual void Contribute(TPZVec< TPZMaterialData > &datavec, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef)
It computes a contribution to the stiffness matrix and load vector at one integration point to multip...
TPZFNMatrix< 9, REAL > fTensorK
permeability tensor. Coeficient which multiplies the gradient operator
Definition: mixedpoisson.h:41
TPZAutoPointer< TPZFunction< STATE > > fPermeabilityFunction
post-processing procedure for error estimation as Ainsworth
Definition: mixedpoisson.h:63
TPZAutoPointer< TPZFunction< STATE > > fForcingFunction
Pointer to forcing function, it is the right member at differential equation.
Definition: TPZMaterial.h:47
Contains declaration of the TPZAxesTools class which implements verifications over axes...
int fDim
Problem dimension.
Definition: pzpoisson3d.h:34
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
virtual void Print(std::ostream &out) override
Prints out the data associated with the material.
Material to solve a mixed time dependent poisson problem 2d by multiphysics simulation.
bool fIsStabilized
Choose Stabilized method.
Definition: mixedpoisson.h:50
TPZMixedPoissonParabolic & operator=(const TPZMixedPoissonParabolic &copy)
TPZMixedPoisson & operator=(const TPZMixedPoisson &copy)