NeoPZ
pzmatmixedpoisson3d.h
Go to the documentation of this file.
1 //
2 // pzmatmixedpoisson3d.h
3 // PZ
4 //
5 // Created by Agnaldo Farias on 03/11/14.
6 //
7 //
8 
9 #ifndef __PZ__pzmatmixedpoisson3d__
10 #define __PZ__pzmatmixedpoisson3d__
11 
12 #include <stdio.h>
13 #include <iostream>
14 #include "pzdiscgal.h"
15 #include "TPZMaterial.h"
16 #include "TPZLagrangeMultiplier.h"
17 
34 
35 protected:
37  int fMatId;
38 
40  REAL fF; //fF
41 
43  int fDim;
44 
46  REAL falpha;
47 
49  REAL fvisc;
50 
53 
56 
59 
62 
63  //object to material lagrange multiplier
65 
68 
70 
71 public:
72 
74 
75  TPZMatMixedPoisson3D(int matid, int dim);
76 
77  virtual ~TPZMatMixedPoisson3D();
78 
81 
83 
84  virtual std::string Name() override { return "TPZMatMixedPoisson3D"; }
85 
86  int Dimension() const override {return fDim;}
87 
88  void SetDimension(int dim)
89  {
90 
91  fDim = dim;
92  }
93  int MatId()
94  {
95  return fMatId;
96  }
97 
98  virtual TPZMaterial * NewMaterial() override {
99  return new TPZMatMixedPoisson3D(*this);
100  }
101 
102  virtual int NStateVariables() const override;
103 
104  void SetPermeability(REAL perm) {
105 
106  fTensorK.Resize(fDim, fDim);
107  fInvK.Resize(fDim, fDim);
108  for(int i = 0; i < fDim; i++){
109  fTensorK(i,i) = perm;
110  fInvK(i,i) = 1.0/perm;
111  }
112  }
113 
114  //Set the permeability tensor and inverser tensor
116 
117 #ifdef PDDEBUG
118  if(K.Rows() != fDim || K.Cols() != fDim) DebugStop();
119  if(K.Rows()!=invK.Rows() || K.Cols()!=invK.Cols()) DebugStop();
120 #endif
121  fTensorK = K;
122  fInvK = invK;
123  }
124 
125  void SetReactionTerm(REAL alpha)
126  {
127  fReactionTerm = true;
128  falpha = alpha;
129  }
130 
131  void SetViscosity(REAL visc) {
132  fvisc = visc;
133  }
134 
135  void SetInternalFlux(REAL flux) {
136  fF = flux;
137  }
138 
140  {
141  fPermeabilityFunction = fp;
142  }
143 
145  {
146  return fPermeabilityFunction;
147  }
148 
150  {
151  fReactionTermFunction = fp;
152  }
153 
155  {
156  return fReactionTermFunction;
157  }
158 
159 
160 
162  virtual int IntegrationRuleOrder(int elPMaxOrder) const override {
163 
164  return 2*(elPMaxOrder+1);
165  }
166 
168  virtual int IntegrationRuleOrder(TPZVec<int> &elPMaxOrder) const override
169  {
170  int polorder = elPMaxOrder[0]*2;
171  int forceorder = 0;
172  if (fForcingFunction) {
173  forceorder = fForcingFunction->PolynomialOrder();
174  }
175  if (forceorder > elPMaxOrder[0]) {
176  polorder = forceorder+elPMaxOrder[0];
177  }
178  return polorder;
179  }
180 
181  void Print(std::ostream &out) override;
182 
196  virtual void Contribute(TPZVec<TPZMaterialData> &datavec, REAL weight, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef) override;
197 
200 
209  virtual void Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef) override {
210  DebugStop();
211  }
212 
222  virtual void ContributeBC(TPZVec<TPZMaterialData> &datavec, REAL weight, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef, TPZBndCond &bc) override;
223 
233  virtual void ContributeBC(TPZMaterialData &data, REAL weight, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef, TPZBndCond &bc) override {
234  DebugStop();
235  }
236 
237  // /**
238  // * @brief It computes a contribution to stiffness matrix and load vector at one BC integration point
239  // * @param datavec [in]
240  // * @param dataleft [in]
241  // * @param weight [in]
242  // * @param ek [out] is the stiffness matrix
243  // * @param ef [out] is the load vector
244  // * @param bc [in] is the boundary condition object
245  // * @since June 2, 2014
246  // */
247  // virtual void ContributeBCInterface(TPZMaterialData &data, TPZVec<TPZMaterialData> &dataleft, REAL weight, TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef,TPZBndCond &bc);
248  //
249  // /**
250  // * @brief It computes a contribution to stiffness matrix and load vector at one BC integration point
251  // * @param data [in]
252  // * @param dataleft [in]
253  // * @param weight [in]
254  // * @param ek [out] is the stiffness matrix
255  // * @param ef [out] is the load vector
256  // * @param bc [in] is the boundary condition object
257  // * @since June 2, 2014
258  // */
259  // virtual void ContributeBCInterface(TPZMaterialData &data, TPZMaterialData &dataleft, REAL weight, TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef,TPZBndCond &bc);
260  // void ContributeBCInterface(TPZMaterialData &data, TPZMaterialData &dataleft, REAL weight, TPZFMatrix<STATE> &ef,TPZBndCond &bc);
261  //
262  // /**
263  // * @brief It computes a contribution to stiffness matrix and load vector at one BC integration point
264  // * @param datavec [in]
265  // * @param dataleft [in]
266  // * @param dataright [in]
267  // * @param weight [in]
268  // * @param ek [out] is the stiffness matrix
269  // * @param ef [out] is the load vector
270  // * @since June 2, 2014
271  // */
272  // virtual void ContributeInterface(TPZMaterialData &data, TPZVec<TPZMaterialData> &dataleft, TPZVec<TPZMaterialData> &dataright, REAL weight, TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef);
273  //
274  // /**
275  // * @brief It computes a contribution to stiffness matrix and load vector at one integration point
276  // * @param data [in]
277  // * @param dataleft [in]
278  // * @param dataright [in]
279  // * @param weight [in]
280  // * @param ek [out] is the stiffness matrix
281  // * @param ef [out] is the load vector
282  // * @since June 2, 2014
283  // */
284  // virtual void ContributeInterface(TPZMaterialData &data, TPZMaterialData &dataleft, TPZMaterialData &dataright, REAL weight, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef) {DebugStop();}
285 
292  //virtual void Solution(TPZVec<TPZMaterialData> &datavec, int var, TPZVec<STATE> &Solout);
293 
294 
295  virtual void FillDataRequirements(TPZVec<TPZMaterialData > &datavec) override;
296 
297  virtual void FillBoundaryConditionDataRequirement(int type,TPZVec<TPZMaterialData > &datavec) override;
298 
299  int VariableIndex(const std::string &name) override;
300 
301  int NSolutionVariables(int var) override;
302 
303  // metodo para gerar vtk
304  void Solution(TPZVec<TPZMaterialData> &datavec, int var, TPZVec<STATE> &Solout) override;
305  // metodo para computar erros Pressao
306  void Solution(TPZVec<STATE> &Sol,TPZFMatrix<STATE> &DSol,TPZFMatrix<REAL> &axes,int var,TPZVec<STATE> &Solout) override;
307  // metodo para computar erros Hdiv
308  void Solution(TPZMaterialData &data, int var, TPZVec<STATE> &Solout) override;
309  // metodo para computar erros Pressao
310  void Errors(TPZVec<REAL> &x,TPZVec<STATE> &u,
311  TPZFMatrix<STATE> &dudx, TPZFMatrix<REAL> &axes, TPZVec<STATE> &/*flux*/,
312  TPZVec<STATE> &u_exact,TPZFMatrix<STATE> &du_exact,TPZVec<REAL> &values) override;
313  // metodo para computar erros Hdiv
314  void ErrorsHdiv(TPZMaterialData &data,TPZVec<STATE> &u_exact,TPZFMatrix<STATE> &du_exact,TPZVec<REAL> &values) override;
315 
317  fSecondIntegration=true;
318  }
319 
321  return fSecondIntegration;
322  }
323  public:
324 virtual int ClassId() const override;
325 
326 };
327 
328 #endif /* defined(__PZ__pzmatmixedpoisson3d__) */
void Print(std::ostream &out) override
Prints out the data associated with the material.
TPZMatMixedPoisson3D & operator=(const TPZMatMixedPoisson3D &copy)
Material which implements a Lagrange Multiplier.
void SetPermeabilityTensor(TPZFMatrix< REAL > K, TPZFMatrix< REAL > invK)
void ContributeWithoutSecondIntegration(TPZVec< TPZMaterialData > &datavec, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef)
This method use piola contravariant mapping for nonlinear mappings.
virtual int IntegrationRuleOrder(int elPMaxOrder) const override
Gets the order of the integration rule necessary to integrate an element with polinomial order p...
TPZFMatrix< REAL > fTensorK
permeability tensor. Coeficient which multiplies the gradient operator
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...
clarg::argBool bc("-bc", "binary checkpoints", false)
void SetPermeabilityFunction(TPZAutoPointer< TPZFunction< STATE > > fp)
void SetPermeability(REAL perm)
void SetInternalFlux(REAL flux)
TPZFMatrix< REAL > fInvK
inverse of the permeability tensor.
void SetfReactionTermFunction(TPZAutoPointer< TPZFunction< STATE > > fp)
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...
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...
virtual void FillBoundaryConditionDataRequirement(int type, TPZVec< TPZMaterialData > &datavec) override
This method defines which parameters need to be initialized in order to compute the contribution of t...
bool fSecondIntegration
Parameter to choose the second integration by parts in the variational formulation.
virtual int ClassId() const override
Define the class id associated with the class.
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...
This abstract class defines the behaviour which each derived class needs to implement.
Definition: TPZMaterial.h:39
virtual int NStateVariables() const override
Returns the number of state variables associated with the material.
virtual void FillDataRequirements(TPZVec< TPZMaterialData > &datavec) override
It computes a contribution to stiffness matrix and load vector at one BC integration point...
#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 ErrorsHdiv(TPZMaterialData &data, TPZVec< STATE > &u_exact, TPZFMatrix< STATE > &du_exact, TPZVec< REAL > &values) override
virtual std::string Name() override
Returns the name of the material.
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
TPZAutoPointer< TPZFunction< STATE > > PermeabilityFunction()
int Dimension() const override
Returns the integrable dimension of the material.
TPZAutoPointer< TPZFunction< STATE > > fPermeabilityFunction
Pointer to forcing function, it is the Permeability and its inverse.
TPZLagrangeMultiplier * fmatLagr
int VariableIndex(const std::string &name) override
virtual TPZMaterial * NewMaterial() override
To create another material of the same type.
TPZAutoPointer< TPZFunction< STATE > > ReactionTermFunction()
void Errors(TPZVec< REAL > &x, TPZVec< STATE > &u, TPZFMatrix< STATE > &dudx, TPZFMatrix< REAL > &axes, TPZVec< STATE > &, 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...
TPZAutoPointer< TPZFunction< STATE > > fForcingFunction
Pointer to forcing function, it is the right member at differential equation.
Definition: TPZMaterial.h:47
REAL fvisc
fluid viscosity
void SetViscosity(REAL visc)
int64_t Cols() const
Returns number of cols.
Definition: pzmatrix.h:809
virtual int IntegrationRuleOrder(TPZVec< int > &elPMaxOrder) const override
Gets the order of the integration rule necessary to integrate an element multiphysic.
int Resize(const int64_t newRows, const int64_t wCols) override
Redimension a matrix, but maintain your elements.
Definition: pzfmatrix.cpp:1016
def values
Definition: rdt.py:119
Contains the TPZDiscontinuousGalerkin class which implements the interface for discontinuous Galerkin...
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.
Material to solve a mixed poisson problem 3D by multiphysics simulation.
TPZAutoPointer< TPZFunction< STATE > > fReactionTermFunction
Pointer to forcing function, it is the reaction term.
virtual int PolynomialOrder() const
Polynomial order of this function. In case of non-polynomial function it can be a reasonable approxim...
Definition: pzfunction.h:66
void SetReactionTerm(REAL alpha)
This class implements a reference counter mechanism to administer a dynamically allocated object...
int NSolutionVariables(int var) override
Returns the number of variables associated with the variable indexed by var.