NeoPZ
TPZMatLaplacian.h
Go to the documentation of this file.
1 
6 #ifndef MATLAPLACDH
7 #define MATLAPLACDH
8 
9 #include <iostream>
10 #include "pzdiscgal.h"
11 #include "pzfmatrix.h"
12 
21 
22  protected :
23 
25  STATE fXf;
26 
28  int fDim;
29 
31  STATE fK;
32 
35 
41  REAL fSymmetry;
42 
45 
48 
51 
52 public:
53 
56 
58  void SetNoPenalty(){ this->fPenaltyType = ENoPenalty;}
59 
61  void SetFluxPenalty(){ this->fPenaltyType = EFluxPenalty; }
62 
64  void SetSolutionPenalty(){ this->fPenaltyType = ESolutionPenalty; }
65 
67  void SetBothPenalty(){ this->fPenaltyType = EBoth; }
68 
69  TPZMatLaplacian(int matid, int dim);
70 
71  TPZMatLaplacian(int matid)
73  TPZDiscontinuousGalerkin(matid), fXf(0.), fDim(1), fK(1.), fTensorK(1,1,1.),
74  fInvK(1,1,1.),
75  fSymmetry(0.), fPenaltyType(ENoPenalty), fPenaltyConstant(0.)
76  {
77 
78  }
79 
81 
82  TPZMatLaplacian(const TPZMatLaplacian &copy);
83 
84  virtual ~TPZMatLaplacian();
85 
87 
89  void SetSymmetric(){
90  this->fSymmetry = -1.0;
91  }
92 
94  void SetNonSymmetric() {
95  this->fSymmetry = +1.0;
96  }
97 
98  bool IsSymetric(){
99  if (fSymmetry == -1.0) return true;
100  if (fSymmetry == +1.0) return false;
101  PZError << __PRETTY_FUNCTION__ << "\n Comparacao de numeros reais da errado\n";
102  return false;
103  }
104 
105  virtual TPZMaterial * NewMaterial() override {
106  return new TPZMatLaplacian(*this);
107  }
108 
117  virtual void FillDataRequirements(TPZMaterialData &data) override;
118 
119  virtual void FillDataRequirementsInterface(TPZMaterialData &data) override;
120 
122  virtual void FillBoundaryConditionDataRequirement(int type,TPZMaterialData &data) override
123  {
124  data.SetAllRequirements(false);
125  if (type == 50) {
126  data.fNeedsSol = true;
127  }
128  if (type == 3) {
129  data.fNeedsNormal = true;
130  }
131  }
132 
133 
134  virtual int Dimension() const override { return fDim;}
135 
136  virtual int NStateVariables() const override;
137 
139  void SetParameters(STATE diff, STATE f);
140 
142  void GetParameters(STATE &diff, STATE &f) const
143  {
144  diff = fK;
145  f = fXf;
146  }
147 
148  void SetPermeability(REAL perm) {
149  fK = perm;
150  fTensorK.Zero();
151  fInvK.Zero();
152  for (int i=0; i<fDim; i++) {
153  fTensorK(i,i) = perm;
154  fInvK(i,i) = 1./perm;
155  }
156  }
157 
158  void SetValPenaltyConstant(REAL penalty)
159  {
160  fPenaltyConstant = penalty;
161  }
162  //Set the permeability tensor and inverser tensor
164  {
165  fPermeabilityFunction = fp;
166  }
167 
168 
169  //void GetParameters(STATE &diff, STATE &f);
170 
171  void SetDimension(int dim)
172  {
173  if(dim<0 || dim >3)
174  {
175  DebugStop();
176  }
177  fDim = dim;
178  fTensorK.Redim(dim,dim);
179  fInvK.Redim(dim,dim);
180  for (int i=0; i<dim; i++) {
181  fTensorK(i,i) = fK;
182  fInvK(i,i) = STATE(1.)/fK;
183  }
184  }
185 
186 
187  virtual void Print(std::ostream & out) override;
188 
189  virtual std::string Name() override { return "TPZMatLaplacian"; }
190 
196  virtual void Contribute(TPZMaterialData &data,REAL weight,TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef) override;
197 
198  virtual void Contribute(TPZMaterialData &data,REAL weight, TPZFMatrix<STATE> &ef) override;
199 
200  virtual void Contribute(TPZVec<TPZMaterialData> &datavec, REAL weight, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef) override {
201  TPZDiscontinuousGalerkin::Contribute(datavec,weight,ek,ef);
202  }
203 
204 
205  virtual void ContributeBCHDiv(TPZMaterialData &data,REAL weight,
207 
208  virtual void ContributeHDiv(TPZMaterialData &data,REAL weight,TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef);
209 
210  virtual void ContributeBC(TPZMaterialData &data,REAL weight,
211  TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef,TPZBndCond &bc) override;
212 
213  virtual void ContributeBC(TPZVec<TPZMaterialData> &datavec, REAL weight, TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef,TPZBndCond &bc) override;
214 
215  virtual void ContributeBCInterface(TPZMaterialData &data, TPZMaterialData &dataleft, REAL weight,TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef,TPZBndCond &bc) override;
216 
217  virtual void ContributeInterface(TPZMaterialData &data, TPZMaterialData &dataleft, TPZMaterialData &dataright, REAL weight,
218  TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef) override;
219 
222  virtual int VariableIndex(const std::string &name) override;
223 
224  virtual int NSolutionVariables(int var) override;
225 
226  virtual int NFluxes() override { return 3;}
227 
228 protected:
229 
230  virtual void Solution(TPZVec<STATE> &Sol,TPZFMatrix<STATE> &DSol,TPZFMatrix<REAL> &axes,int var,TPZVec<STATE> &Solout) override;
231 
232  public:
233 
234  virtual void Solution(TPZMaterialData &data, int var, TPZVec<STATE> &Solout) override;
235  virtual void Solution(TPZVec<TPZMaterialData> &datavec, int var, TPZVec<STATE> &Solout) override {
236  DebugStop();
237  }
238 
239  virtual void Flux(TPZVec<REAL> &x, TPZVec<STATE> &Sol, TPZFMatrix<STATE> &DSol, TPZFMatrix<REAL> &axes, TPZVec<STATE> &flux) override;
240 
241  virtual void Errors(TPZVec<REAL> &x,TPZVec<STATE> &u,
243  TPZVec<STATE> &u_exact,TPZFMatrix<STATE> &du_exact,TPZVec<REAL> &values) override;
244 
245  void ErrorsHdiv(TPZMaterialData &data,TPZVec<STATE> &u_exact,TPZFMatrix<STATE> &du_exact,TPZVec<REAL> &values) override;
246 
247 
248  virtual int NEvalErrors() override {return 3;}
249 
256  virtual REAL ComputeSquareResidual(TPZVec<REAL>& X, TPZVec<STATE> &sol, TPZFMatrix<STATE> &dsol) override;
257 
258 
259  void InterfaceErrors(TPZVec<REAL> &/*x*/,
260  TPZVec<STATE> &leftu, TPZFMatrix<STATE> &leftdudx, /* TPZFMatrix<REAL> &leftaxes,*/
261  TPZVec<STATE> &rightu, TPZFMatrix<STATE> &rightdudx, /* TPZFMatrix<REAL> &rightaxes,*/
262  TPZVec<STATE> &/*flux*/,
263  TPZVec<STATE> &u_exact,TPZFMatrix<STATE> &du_exact,TPZVec<REAL> &values,
264  TPZVec<STATE> normal, STATE elsize);
265 
271  virtual void BCInterfaceJump(TPZVec<REAL> &x, TPZSolVec &leftu,TPZBndCond &bc,TPZSolVec & jump) override;
272 
273  virtual int IsInterfaceConservative() override { return 1;}
274 
275  public:
276 virtual int ClassId() const override;
277 
278 
279  virtual void Write(TPZStream &buf, int withclassid) const override;
280 
281  virtual void Read(TPZStream &buf, void *context) override;
282 
283 };
284 
285 #endif
286 
Defines the interface which material objects need to implement for discontinuous Galerkin formulation...
Definition: pzdiscgal.h:20
virtual int VariableIndex(const std::string &name) override
virtual void Solution(TPZVec< STATE > &Sol, TPZFMatrix< STATE > &DSol, TPZFMatrix< REAL > &axes, int var, TPZVec< STATE > &Solout) override
virtual int NFluxes() override
Returns the number of components which form the flux function.
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.
clarg::argBool bc("-bc", "binary checkpoints", false)
void GetParameters(STATE &diff, STATE &f) const
Return the values of constant diffusion and external flux.
STATE fXf
Forcing function value.
virtual void ContributeBCInterface(TPZMaterialData &data, TPZMaterialData &dataleft, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
void SetBothPenalty()
Defines solution and flux penalty terms in ContributeInterface.
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)
void ErrorsHdiv(TPZMaterialData &data, TPZVec< STATE > &u_exact, TPZFMatrix< STATE > &du_exact, TPZVec< REAL > &values) override
void SetAllRequirements(bool set)
Set all flags at once.
virtual void Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override
It computes a contribution to the stiffness matrix and load vector at one integration point...
REAL fPenaltyConstant
Constant multiplier of penalty term, when required is set.
virtual TPZMaterial * NewMaterial() override
To create another material of the same type.
This class implements a simple vector storage scheme for a templated class T. Utility.
Definition: pzgeopoint.h:19
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.
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...
int fDim
Problem dimension.
virtual int ClassId() const override
Unique identifier for serialization purposes.
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
virtual void Write(TPZStream &buf, int withclassid) const override
Saves the element data to a stream.
void SetPermeabilityFunction(TPZAutoPointer< TPZFunction< STATE > > fp)
f
Definition: test.py:287
virtual void Read(TPZStream &buf, void *context) override
Reads the element data from 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. ...
Contains TPZMatrixclass which implements full matrix (using column major representation).
virtual int NEvalErrors() override
Returns the number of norm errors. Default is 3: energy, L2 and H1.
#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
void SetSolutionPenalty()
Defines solution penalty terms in ContributeInterface.
void SetNonSymmetric()
Set material elliptic term as the Baumann&#39;s formulation, i.e. the non-symmetrical formulation...
EPenaltyType fPenaltyType
Penalty term definition.
virtual int NStateVariables() const override
Returns the number of state variables associated with the material.
virtual void FillDataRequirements(TPZMaterialData &data) override
Fill material data parameter with necessary requirements for the.
virtual std::string Name() override
Returns the name of the material.
void SetFluxPenalty()
Defines flux penalty terms in ContributeInterface.
void SetSymmetric()
Set material elliptic term as the global element method, i.e. the symmetrical formulation.
void SetValPenaltyConstant(REAL penalty)
virtual int IsInterfaceConservative() override
Dicontinuous galerkin materials implement contribution of discontinuous elements and interfaces...
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
Definition: pzfmatrix.h:616
void SetDimension(int dim)
virtual void Print(std::ostream &out) override
Prints out the data associated with the material.
virtual void BCInterfaceJump(TPZVec< REAL > &x, TPZSolVec &leftu, TPZBndCond &bc, TPZSolVec &jump) override
Computes interface jump from element to Dirichlet boundary condition.
TPZMatLaplacian(int matid)
virtual void ContributeBC(TPZMaterialData &data, 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...
TPZMatLaplacian & operator=(const TPZMatLaplacian &copy)
virtual ~TPZMatLaplacian()
TPZFNMatrix< 9, STATE > fInvK
STATE fK
Coeficient which multiplies the Laplacian operator.
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...
void SetNoPenalty()
Defines no penalty terms in ContributeInterface.
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...
virtual int NSolutionVariables(int var) override
Returns the number of variables associated with the variable indexed by var.
TPZAutoPointer< TPZFunction< STATE > > fPermeabilityFunction
Pointer to forcing function, it is the Permeability and its inverse.
virtual int Dimension() const override
Returns the integrable dimension of the material.
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
REAL fSymmetry
Symmetry coefficient of elliptic term.
def values
Definition: rdt.py:119
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...
EPenaltyType
Enumerate for penalty term definitions.
Contains the TPZDiscontinuousGalerkin class which implements the interface for discontinuous Galerkin...
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 SetParameters(STATE diff, STATE f)
Set a uniform diffusion constant and external flux.
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...
virtual void ContributeBCHDiv(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc)
void SetPermeability(REAL perm)
TPZFNMatrix< 9, STATE > fTensorK
Tensor de permeabilidade.
virtual void FillDataRequirementsInterface(TPZMaterialData &data) override
Fill material data parameter with necessary requirements for the ContributeInterface method...
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15
This class implements a reference counter mechanism to administer a dynamically allocated object...