NeoPZ
pzpoisson3d.h
Go to the documentation of this file.
1 
6 #ifndef MATPOISSON3DH
7 #define MATPOISSON3DH
8 
9 #include <iostream>
10 #include "pzdiscgal.h"
11 #include "pzfmatrix.h"
12 
13 
14 #ifdef _AUTODIFF
15 #include "fadType.h"
16 #endif
17 
18 
27 
28  protected :
29 
31  STATE fXf;
32 
34  int fDim;
35 
37  STATE fK;
38 
40  REAL fC;
41 
43  REAL fConvDir[3];
44 
50  REAL fSymmetry;
51 
53  STATE fSD;
54 
57 
60 
61  bool fShapeHdiv;
62 
63 
64 public:
65 
68 
70  void SetNoPenalty(){ this->fPenaltyType = ENoPenalty;}
71 
73  void SetFluxPenalty(){ this->fPenaltyType = EFluxPenalty; }
74 
76  void SetSolutionPenalty(){ this->fPenaltyType = ESolutionPenalty; }
77 
79  void SetBothPenalty(){ this->fPenaltyType = EBoth; }
80 
82  static STATE gAlfa;
84  bool fNeumann;
85 
86  TPZMatPoisson3d(int nummat, int dim);
87 
89  TPZDiscontinuousGalerkin(matid), fXf(0.), fDim(-1), fK(0.), fC(0.), fSymmetry(0.), fSD(0.)
90  ,fPenaltyType(ENoPenalty)
91  {
92 
93  }
94 
96 
97  TPZMatPoisson3d(const TPZMatPoisson3d &copy);
98 
99  virtual ~TPZMatPoisson3d();
100 
102 
104  void SetSymmetric(){
105  this->fSymmetry = -1.0;
106  }
108  fShapeHdiv=true;
109  }
110 
112  fNeumann=true;
113  }
114 
115 
118  this->fSymmetry = +1.0;
119  }
120 
121  bool IsSymetric(){
122  if (fSymmetry == -1.0) return true;
123  if (fSymmetry == +1.0) return false;
124  PZError << __PRETTY_FUNCTION__ << "\n Comparacao de numeros reais da errado\n";
125  return false;
126  }
127 
128  virtual TPZMaterial * NewMaterial() override {
129  return new TPZMatPoisson3d(*this);
130  }
131 
140  virtual void FillDataRequirements(TPZMaterialData &data) override
141  {
142  data.SetAllRequirements(false);
143  }
144 
146  virtual void FillBoundaryConditionDataRequirement(int type,TPZMaterialData &data) override
147  {
148  data.SetAllRequirements(false);
149  if (type == 50) {
150  data.fNeedsSol = true;
151  }
152  if (type == 3) {
153  data.fNeedsNormal = true;
154  }
155  }
156 
157 
158  int Dimension() const override{ return fDim;}
159 
161  virtual int NStateVariables() const override
162  {
163  return 1;
164  }
165 
166  virtual void SetParameters(STATE diff, REAL conv, TPZVec<REAL> &convdir);
167 
168  void GetParameters(STATE &diff, REAL &conv, TPZVec<REAL> &convdir);
169 
170  void SetDimension(int dim)
171  {
172  if(dim<0 || dim >3)
173  {
174  DebugStop();
175  }
176  fDim = dim;
177  }
178 
179  void SetInternalFlux(STATE flux)
180  {
181  fXf = flux;
182  }
183 
184  void SetSD(STATE sd)
185  {
186  fSD = sd;
187  }
188 
189 
190  virtual void Print(std::ostream & out) override;
191 
192  virtual std::string Name() override { return "TPZMatPoisson3d"; }
193 
199  virtual void Contribute(TPZMaterialData &data,REAL weight,TPZFMatrix<STATE> &ef) override {
200  TPZDiscontinuousGalerkin::Contribute(data,weight,ef);
201  }
202  virtual void Contribute(TPZMaterialData &data,REAL weight,TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef) override;
203  virtual void Contribute(TPZVec<TPZMaterialData> &datavec, REAL weight, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef) override {
204  TPZDiscontinuousGalerkin::Contribute(datavec,weight,ek,ef);
205  }
206 
207  virtual void ContributeBC(TPZVec<TPZMaterialData> &datavec, REAL weight, TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef,TPZBndCond &bc) override {
208  TPZDiscontinuousGalerkin::ContributeBC(datavec,weight,ek,ef,bc);
209  }
210 
211 
212  virtual void ContributeBCHDiv(TPZMaterialData &data,REAL weight,
214  virtual void ContributeHDiv(TPZMaterialData &data,REAL weight,TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef);
215  virtual void LocalNeumanContribute(TPZMaterialData &data,REAL weight,TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef);
216 
217 #ifdef _AUTODIFF
218 
219  void ContributeEnergy(TPZVec<REAL> &x,
220  TPZVec<FADFADREAL> &sol,
221  TPZVec<FADFADREAL> &dsol,
222  FADFADREAL &U,
223  REAL weight);
224 #endif
225 
226  virtual void ContributeBC(TPZMaterialData &data,REAL weight,TPZFMatrix<STATE> &ef,TPZBndCond &bc) override {
227  TPZDiscontinuousGalerkin::ContributeBC(data,weight,ef,bc);
228  }
229  virtual void ContributeBC(TPZMaterialData &data,REAL weight,
230  TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef,TPZBndCond &bc) override;
231 
232 
233  virtual void ContributeBCInterface(TPZMaterialData &data, TPZMaterialData &dataleft, REAL weight,TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef,TPZBndCond &bc) override;
234 
235  virtual void ContributeInterface(TPZMaterialData &data, TPZMaterialData &dataleft, TPZMaterialData &dataright, REAL weight,
236  TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef) override;
237 
238  virtual void ContributeBCInterface(TPZMaterialData &data,TPZMaterialData &dataleft,REAL weight,TPZFMatrix<STATE> &ef,TPZBndCond &bc) override
239  {
240  TPZDiscontinuousGalerkin::ContributeBCInterface(data,dataleft,weight,ef,bc);
241  }
242 
243  virtual void ContributeInterface(TPZMaterialData &data,TPZMaterialData &dataleft,TPZMaterialData &dataright,REAL weight,
244  TPZFMatrix<STATE> &ef) override
245  {
246  TPZDiscontinuousGalerkin::ContributeInterface(data,dataleft,dataright,weight,ef);
247  }
248 
249 #ifdef _AUTODIFF
250  virtual void ContributeBCEnergy(TPZVec<REAL> &x,TPZVec<FADFADREAL> &sol, FADFADREAL &U,
251  REAL weight, TPZBndCond &bc);
252 #endif
253 
257  virtual int VariableIndex(const std::string &name) override;
258 
259  virtual int NSolutionVariables(int var) override;
260 
261  virtual int NFluxes() override { return 3;}
262 
263 protected:
264  virtual void Solution(TPZVec<TPZMaterialData> &datavec, int var, TPZVec<STATE> &Solout) override {
265  TPZDiscontinuousGalerkin::Solution(datavec,var,Solout);
266  }
267 
268  virtual void FillDataRequirements(TPZVec<TPZMaterialData > &datavec) override {
270  }
271 
272  virtual void Solution(TPZVec<STATE> &Sol,TPZFMatrix<STATE> &DSol,TPZFMatrix<REAL> &axes,int var,TPZVec<STATE> &Solout) override;
273 public:
274 
275  virtual void Solution(TPZMaterialData &data, int var, TPZVec<STATE> &Solout) override;
276 
277  virtual void Flux(TPZVec<REAL> &x, TPZVec<STATE> &Sol, TPZFMatrix<STATE> &DSol, TPZFMatrix<REAL> &axes, TPZVec<STATE> &flux) override;
278 
279  virtual void Errors(TPZVec<REAL> &x,TPZVec<STATE> &u,
281  TPZVec<STATE> &u_exact,TPZFMatrix<STATE> &du_exact,TPZVec<REAL> &values) override;
282 
283  virtual void Errors(TPZVec<TPZMaterialData> &data, TPZVec<STATE> &u_exact, TPZFMatrix<STATE> &du_exact, TPZVec<REAL> &errors) override {
284  TPZDiscontinuousGalerkin::Errors(data,u_exact,du_exact,errors);
285  }
286 
287  void ErrorsHdiv(TPZMaterialData &data,TPZVec<STATE> &u_exact,TPZFMatrix<STATE> &du_exact,TPZVec<REAL> &values) override;
288 
289 
290  virtual int NEvalErrors() override {return 6;}
291 
298  virtual REAL ComputeSquareResidual(TPZVec<REAL>& X, TPZVec<STATE> &sol, TPZFMatrix<STATE> &dsol) override;
299 
300 
301  void InterfaceErrors(TPZVec<REAL> &/*x*/,
302  TPZVec<STATE> &leftu, TPZFMatrix<STATE> &leftdudx, /* TPZFMatrix<REAL> &leftaxes,*/
303  TPZVec<STATE> &rightu, TPZFMatrix<STATE> &rightdudx, /* TPZFMatrix<REAL> &rightaxes,*/
304  TPZVec<STATE> &/*flux*/,
305  TPZVec<STATE> &u_exact,TPZFMatrix<STATE> &du_exact,TPZVec<REAL> &values,
306  TPZVec<STATE> normal, STATE elsize);
307 
313  virtual void BCInterfaceJump(TPZVec<REAL> &x, TPZSolVec &leftu,TPZBndCond &bc,TPZSolVec & jump) override;
314 
315  virtual int IsInterfaceConservative() override { return 1;}
316 
317  public:
318 virtual int ClassId() const override;
319 
320 
321  virtual void Write(TPZStream &buf, int withclassid) const override;
322 
323  virtual void Read(TPZStream &buf, void *context) override;
324 
325 };
326 
327 #endif
Defines the interface which material objects need to implement for discontinuous Galerkin formulation...
Definition: pzdiscgal.h:20
virtual void Solution(TPZMaterialData &data, int var, TPZVec< STATE > &Solout)
Returns the solution associated with the var index based on the finite element approximation.
void SetSymmetric()
Set material elliptic term as the global element method, i.e. the symmetrical formulation.
Definition: pzpoisson3d.h:104
virtual void Write(TPZStream &buf, int withclassid) const override
Saves the element data to a stream.
virtual REAL ComputeSquareResidual(TPZVec< REAL > &X, TPZVec< STATE > &sol, TPZFMatrix< STATE > &dsol) override
Compute square of residual of the differential equation at one integration point. ...
virtual void Read(TPZStream &buf, void *context) override
Reads the element data from a stream.
virtual void ContributeBCHDiv(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc)
virtual void ContributeBC(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
It computes a contribution to the stiffness matrix and load vector at one BC integration point...
Definition: pzpoisson3d.h:226
clarg::argBool bc("-bc", "binary checkpoints", false)
STATE fSD
Multiplication value for the streamline diffusion term.
Definition: pzpoisson3d.h:53
virtual void Errors(TPZVec< REAL > &x, TPZVec< STATE > &u, TPZFMatrix< STATE > &dudx, TPZFMatrix< REAL > &axes, TPZVec< STATE > &flux, TPZVec< STATE > &u_exact, TPZFMatrix< STATE > &du_exact, TPZVec< REAL > &values) override
Computes the error due to the difference between the interpolated flux and the flux computed based o...
Definition: pzdiscgal.h:228
REAL fPenaltyConstant
Constant multiplyer of penalty term, when required is set.
Definition: pzpoisson3d.h:67
int Dimension() const override
Returns the integrable dimension of the material.
Definition: pzpoisson3d.h:158
virtual void ContributeInterface(TPZMaterialData &data, TPZMaterialData &dataleft, TPZMaterialData &dataright, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override
It computes a contribution to stiffness matrix and load vector at one integration point...
void SetDimension(int dim)
Definition: pzpoisson3d.h:170
virtual void FillDataRequirements(TPZMaterialData &data) override
Fill material data parameter with necessary requirements for the.
Definition: pzpoisson3d.h:140
virtual void Errors(TPZVec< TPZMaterialData > &data, TPZVec< STATE > &u_exact, TPZFMatrix< STATE > &du_exact, TPZVec< REAL > &errors) override
Definition: pzpoisson3d.h:283
void GetParameters(STATE &diff, REAL &conv, TPZVec< REAL > &convdir)
Definition: pzpoisson3d.cpp:85
void SetAllRequirements(bool set)
Set all flags at once.
virtual int NEvalErrors() override
Returns the number of norm errors. Default is 3: energy, L2 and H1.
Definition: pzpoisson3d.h:290
virtual ~TPZMatPoisson3d()
Definition: pzpoisson3d.cpp:92
virtual void Flux(TPZVec< REAL > &x, TPZVec< STATE > &Sol, TPZFMatrix< STATE > &DSol, TPZFMatrix< REAL > &axes, TPZVec< STATE > &flux) override
Computes the value of the flux function to be used by ZZ error estimator.
void SetBothPenalty()
Defines solution and flux penalty terms in ContributeInterface.
Definition: pzpoisson3d.h:79
REAL fC
Variable which multiplies the convection term of the equation.
Definition: pzpoisson3d.h:40
virtual int ClassId() const override
Unique identifier for serialization purposes.
virtual int IsInterfaceConservative() override
Dicontinuous galerkin materials implement contribution of discontinuous elements and interfaces...
Definition: pzpoisson3d.h:315
This abstract class defines the behaviour which each derived class needs to implement.
Definition: TPZMaterial.h:39
virtual void Contribute(TPZVec< TPZMaterialData > &datavec, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override
It computes a contribution to the stiffness matrix and load vector at one integration point to multip...
Definition: pzpoisson3d.h:203
STATE fXf
Forcing function value.
Definition: pzpoisson3d.h:31
virtual void FillDataRequirements(TPZVec< TPZMaterialData > &datavec) override
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.
Definition: pzpoisson3d.h:268
virtual void Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ef) override
It computes a contribution to the residual vector at one integration point.
Definition: pzpoisson3d.h:199
virtual void ContributeBCInterface(TPZMaterialData &data, TPZMaterialData &dataleft, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
STATE fK
Coeficient which multiplies the Laplacian operator.
Definition: pzpoisson3d.h:37
virtual void SetParameters(STATE diff, REAL conv, TPZVec< REAL > &convdir)
Definition: pzpoisson3d.cpp:78
virtual void ContributeHDiv(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef)
Compute the contribution at an integration point to the stiffness matrix of the HDiv formulation...
void SetSolutionPenalty()
Defines solution penalty terms in ContributeInterface.
Definition: pzpoisson3d.h:76
virtual void ContributeBC(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override=0
It computes a contribution to the stiffness matrix and load vector at one BC integration point...
void InterfaceErrors(TPZVec< REAL > &, TPZVec< STATE > &leftu, TPZFMatrix< STATE > &leftdudx, TPZVec< STATE > &rightu, TPZFMatrix< STATE > &rightdudx, TPZVec< STATE > &, TPZVec< STATE > &u_exact, TPZFMatrix< STATE > &du_exact, TPZVec< REAL > &values, TPZVec< STATE > normal, STATE elsize)
Contains TPZMatrixclass which implements full matrix (using column major representation).
virtual void FillDataRequirements(TPZMaterialData &data)
Fill material data parameter with necessary requirements for the.
Definition: TPZMaterial.cpp:81
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
void ErrorsHdiv(TPZMaterialData &data, TPZVec< STATE > &u_exact, TPZFMatrix< STATE > &du_exact, TPZVec< REAL > &values) override
EPenaltyType
Enumerate for penalty term definitions.
Definition: pzpoisson3d.h:56
This class defines the boundary condition for TPZMaterial objects.
Definition: pzbndcond.h:29
virtual void ContributeInterface(TPZMaterialData &data, TPZMaterialData &dataleft, TPZMaterialData &dataright, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef)
It computes a contribution to stiffness matrix and load vector at one integration point...
Definition: pzdiscgal.cpp:30
virtual void LocalNeumanContribute(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef)
void SetNoPenalty()
Defines no penalty terms in ContributeInterface.
Definition: pzpoisson3d.h:70
virtual int NFluxes() override
Returns the number of components which form the flux function.
Definition: pzpoisson3d.h:261
virtual int VariableIndex(const std::string &name) override
virtual void ContributeBCInterface(TPZMaterialData &data, TPZMaterialData &dataleft, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc)=0
It computes a contribution to stiffness matrix and load vector at one BC integration point...
virtual void ContributeBC(TPZVec< TPZMaterialData > &datavec, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
It computes a contribution to the stiffness matrix and load vector at one BC integration point to mul...
Definition: pzpoisson3d.h:207
virtual void Solution(TPZVec< TPZMaterialData > &datavec, int var, TPZVec< STATE > &Solout) override
Returns the solution associated with the var index based on the finite element approximation.
Definition: pzpoisson3d.h:264
static STATE gAlfa
Using in InterfaceErrors.
Definition: pzpoisson3d.h:82
EPenaltyType fPenaltyType
Penalty term definition.
Definition: pzpoisson3d.h:59
virtual void BCInterfaceJump(TPZVec< REAL > &x, TPZSolVec &leftu, TPZBndCond &bc, TPZSolVec &jump) override
Computes interface jump from element to Dirichlet boundary condition.
virtual int NSolutionVariables(int var) override
Returns the number of variables associated with the variable indexed by var.
DESCRIBE PLEASE.
Definition: pzpoisson3d.h:26
void SetSD(STATE sd)
Definition: pzpoisson3d.h:184
virtual void Errors(TPZVec< REAL > &x, TPZVec< STATE > &u, TPZFMatrix< STATE > &dudx, TPZFMatrix< REAL > &axes, TPZVec< STATE > &flux, TPZVec< STATE > &u_exact, TPZFMatrix< STATE > &du_exact, TPZVec< REAL > &values) override
Computes the error due to the difference between the interpolated flux and the flux computed based o...
void SetNonSymmetric()
Set material elliptic term as the Baumann&#39;s formulation, i.e. the non-symmetrical formulation...
Definition: pzpoisson3d.h:117
virtual void Print(std::ostream &out) override
Prints out the data associated with the material.
Definition: pzpoisson3d.cpp:99
REAL fConvDir[3]
Direction of the convection operator.
Definition: pzpoisson3d.h:43
virtual void ContributeBCInterface(TPZMaterialData &data, TPZMaterialData &dataleft, REAL weight, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
It computes a contribution to residual vector at one BC integration point.
Definition: pzpoisson3d.h:238
TPZMatPoisson3d(int matid)
Definition: pzpoisson3d.h:88
virtual TPZMaterial * NewMaterial() override
To create another material of the same type.
Definition: pzpoisson3d.h:128
virtual void ContributeInterface(TPZMaterialData &data, TPZMaterialData &dataleft, TPZMaterialData &dataright, REAL weight, TPZFMatrix< STATE > &ef) override
It computes a contribution to residual vector at one integration point.
Definition: pzpoisson3d.h:243
int fDim
Problem dimension.
Definition: pzpoisson3d.h:34
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
TPZMatPoisson3d & operator=(const TPZMatPoisson3d &copy)
Definition: pzpoisson3d.cpp:63
void SetInternalFlux(STATE flux)
Definition: pzpoisson3d.h:179
def values
Definition: rdt.py:119
virtual int NStateVariables() const override
Returns the number of state variables associated with the material.
Definition: pzpoisson3d.h:161
void SetFluxPenalty()
Defines flux penalty terms in ContributeInterface.
Definition: pzpoisson3d.h:73
Contains the TPZDiscontinuousGalerkin class which implements the interface for discontinuous Galerkin...
void SetTrueFShapeHdiv()
Definition: pzpoisson3d.h:107
REAL fSymmetry
Symmetry coefficient of elliptic term.
Definition: pzpoisson3d.h:50
virtual void Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override=0
It computes a contribution to the stiffness matrix and load vector at one integration point...
void SetNeumannProblem()
Definition: pzpoisson3d.h:111
virtual void FillBoundaryConditionDataRequirement(int type, TPZMaterialData &data) override
This method defines which parameters need to be initialized in order to compute the contribution of t...
Definition: pzpoisson3d.h:146
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15
virtual std::string Name() override
Returns the name of the material.
Definition: pzpoisson3d.h:192