NeoPZ
pzcoupledtransportdarcy.cpp
Go to the documentation of this file.
1 
8 #include "pzelmat.h"
9 #include "pzbndcond.h"
10 #include "pzmatrix.h"
11 #include "pzfmatrix.h"
12 #include "pzerror.h"
13 #include "pzmanvector.h"
14 #include <math.h>
15 
16 using namespace std;
18 
20  if (i == 0 || i == 1) TPZCoupledTransportDarcy::gCurrentEq = i;
21  else PZError << "Error! - " << __PRETTY_FUNCTION__ << endl;
22 }
23 
25 
26 TPZCoupledTransportDarcy::TPZCoupledTransportDarcy(int nummat, int nummat0, int nummat1, int dim) :
28 TPZDiscontinuousGalerkin(nummat), fAlpha(1.) {
29  this->fMaterials[0] = new TPZMatPoisson3d(nummat0, dim);
30  fMaterialRefs[0] = fMaterials[0];
31  this->fMaterials[1] = new TPZMatPoisson3d(nummat1, dim);
32  fMaterialRefs[1] = fMaterials[1];
33 }
34 
36  this->fAlpha = alpha;
37 }
38 
40 }
41 
43  return this->GetCurrentMaterial()->NStateVariables();
44 }
45 
46 void TPZCoupledTransportDarcy::Print(std::ostream &out) {
47  out << "name of material : " << Name() << "\n";
48  out << "Base Class properties : \n";
49  TPZMaterial::Print(out);
50 }
51 
53  REAL weight,
55  TPZFMatrix<STATE> &ef){
56  int numbersol = dataleft.dsol.size();
57  if (numbersol != 1) {
58  DebugStop();
59  }
60  this->UpdateConvectionDirInterface(dataleft.dsol[0], dataright.dsol[0]);
61  this->GetCurrentMaterial()->ContributeInterface(data, dataleft, dataright, weight, ek, ef);
62 }
63 
65  REAL weight,
68  TPZBndCond &bc){
69  int numbersol = dataleft.dsol.size();
70  if (numbersol != 1) {
71  DebugStop();
72  }
73  this->UpdateConvectionDir(dataleft.dsol[0]);
74  this->GetCurrentMaterial()->ContributeBCInterface( data, dataleft, weight, ek, ef, bc );
75 }
76 
78  REAL weight,
80  int numbersol = data.dsol.size();
81  if (numbersol != 1) {
82  DebugStop();
83  }
84  this->UpdateConvectionDir(data.dsol[0]);
85  this->GetCurrentMaterial()->Contribute(data, weight, ek, ef);
86 }
87 
88 
90  REAL weight,
92  TPZBndCond &bc) {
93  this->GetCurrentMaterial()->ContributeBC(data, weight, ek, ef, bc);
94 }
95 
97 int TPZCoupledTransportDarcy::VariableIndex(const std::string &name){
98  return this->GetCurrentMaterial()->VariableIndex(name);
99 }
100 
102  return this->GetCurrentMaterial()->NSolutionVariables(var);
103 }
104 
106  int var,TPZVec<STATE> &Solout){
107  TPZMaterialData data;
108  data.sol.Resize(1);
109  data.dsol.Resize(1);
110  data.sol[0] = Sol;
111  data.dsol[0] = DSol;
112  data.axes = axes;
113  return this->GetCurrentMaterial()->Solution(data, var, Solout);
114 }//method
115 
117  //Flux(TPZVec<REAL> &x, TPZVec<REAL> &Sol, TPZFMatrix<REAL> &DSol, TPZFMatrix<REAL> &axes, TPZVec<REAL> &flux)
118 }
119 
122  TPZVec<STATE> &u_exact,TPZFMatrix<STATE> &du_exact,TPZVec<REAL> &values) {
123  this->GetCurrentMaterial()->Errors(x, u, dudx, axes, flux, u_exact, du_exact, values);
124 }
125 
126 
128  return new TPZCoupledTransportDarcyBC(this, id);
129 }
130 
133  //It is necessary to set Beta1 = alpha * (-K0 Grad[p] )
134  STATE K;
135  REAL C;
136  const int dim = this->Dimension();
137  TPZManVector<REAL, 3> dir(dim);
138  this->GetMaterial(0)->GetParameters(K, C, dir);
139  const REAL K0 = K;
140  this->GetMaterial(1)->GetParameters(K, C, dir);
141 
142  int i;
143  for(i = 0; i < dim; i++){
144  dir[i] = dsol(i,0);
145  dir[i] *= -1. * K0 * this->fAlpha;
146  }
147 
148  this->GetMaterial(1)->SetParameters(K, 1., dir);
149  }
150 }
151 
154  int i, j;
155  int nrows = dsolL.Rows();
156  int ncols = dsolL.Cols();
157  TPZFNMatrix<100,STATE> dsol(nrows, ncols);
158  for(i = 0; i < nrows; i++) for(j = 0; j < ncols; j++) dsol(i,j) = 0.5 * ( dsolL(i,j) + dsolR(i,j) );
159  this->UpdateConvectionDir(dsol);
160  }
161 }
162 
164  return Hash("TPZCoupledTransportDarcy") ^ TPZDiscontinuousGalerkin::ClassId() << 1;
165 }
Defines the interface which material objects need to implement for discontinuous Galerkin formulation...
Definition: pzdiscgal.h:20
Contains the TPZCoupledTransportDarcyBC class.
TPZMatPoisson3d * GetCurrentMaterial() const
int ClassId() const override
Unique identifier for serialization purposes.
Definition: pzdiscgal.cpp:110
virtual void ContributeBCInterface(TPZMaterialData &data, TPZMaterialData &dataleft, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
It computes a contribution to stiffness matrix and load vector at one BC integration point...
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...
clarg::argBool bc("-bc", "binary checkpoints", false)
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 void Flux(TPZVec< REAL > &x, TPZVec< STATE > &Sol, TPZFMatrix< STATE > &DSol, TPZFMatrix< REAL > &axes, TPZVec< STATE > &flux) override
Compute the value of the flux function to be used by ZZ error estimator.
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...
TPZMatPoisson3d * GetMaterial(int eq)
void GetParameters(STATE &diff, REAL &conv, TPZVec< REAL > &convdir)
Definition: pzpoisson3d.cpp:85
virtual std::string Name() override
Returns the name of the material.
Defines PZError.
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...
TPZMatPoisson3d * fMaterials[2]
void UpdateConvectionDir(TPZFMatrix< STATE > &dsol)
virtual int NSolutionVariables(int var) override
Returns the number of variables associated with the variable indexed by var.
static void SetCurrentMaterial(const int i)
TPZGradSolVec dsol
vector of the derivatives of the solution at the integration point
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
Definition: pzmanvector.h:426
virtual int VariableIndex(const std::string &name) override
virtual void Print(std::ostream &out=std::cout)
Prints out the data associated with the material.
Contains declaration of TPZElementMatrix struct which associates an element matrix with the coeficien...
Contains the TPZBndCond class which implements a boundary condition for TPZMaterial objects...
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
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 int NStateVariables() const override
Returns the number of state variables associated with the material.
virtual void ContributeBCInterface(TPZMaterialData &data, TPZMaterialData &dataleft, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
virtual void SetParameters(STATE diff, REAL conv, TPZVec< REAL > &convdir)
Definition: pzpoisson3d.cpp:78
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
Free store vector implementation.
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
void UpdateConvectionDirInterface(TPZFMatrix< STATE > &dsolL, TPZFMatrix< STATE > &dsolR)
TPZFNMatrix< 9, REAL > axes
axes indicating the directions of the derivatives of the shapefunctions
virtual int VariableIndex(const std::string &name) override
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 int Dimension() const override
Returns the integrable dimension of the material.
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
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
Implements two equations where the second one requires the solution of the first. ...
Contains TPZMatrix<TVar>class, root matrix class.
virtual int NSolutionVariables(int var) override
Returns the number of variables associated with the variable indexed by var.
DESCRIBE PLEASE.
Definition: pzpoisson3d.h:26
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...
TPZCoupledTransportDarcyBC * CreateBC2(int id)
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...
TPZCoupledTransportDarcy(int nummat, int nummat0, int nummat1, int dim)
int64_t Cols() const
Returns number of cols.
Definition: pzmatrix.h:809
Contains the TPZCoupledTransportDarcy class which implements two equations to transport problem...
virtual int ClassId() const override
Unique identifier for serialization purposes.
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
virtual void Print(std::ostream &out) override
Prints out the data associated with the material.
virtual void Solution(TPZVec< STATE > &Sol, TPZFMatrix< STATE > &DSol, TPZFMatrix< REAL > &axes, int var, TPZVec< STATE > &Solout) override
REAL fAlpha
In second equation: . Here alpha is stored.
TPZSolVec sol
vector of the solutions at the integration point
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
Definition: pzfmatrix.h:716
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15