NeoPZ
pzconslaw.h
Go to the documentation of this file.
1 
6 #ifndef PZCONSLAW_H
7 #define PZCONSLAW_H
8 
9 #include <iostream>
10 #include "TPZMaterial.h"
11 #include "pzfmatrix.h"
12 #include "pzvec.h"
13 #include "pzdiscgal.h"
14 #include "Hash/TPZHash.h"
15 
35 {
36  None_TD = -1,
41 };
42 
48 {
49  None_CT = -1,
50  Last_CT = 0,
52 };
53 
59 {
60  None_RT = -1,
62  Flux_RT = 1
63 };
64 
72 {
73 public:
75  TPZConservationLaw(int nummat,REAL timeStep,int dim);
80  {
81  }
82 
84  virtual ~TPZConservationLaw();
85 
91  int Dimension() const override;
92 
94  REAL TimeStep();
95 
100  void SetTimeStep(REAL timeStep);
101 
109  virtual REAL SetTimeStep(REAL maxveloc,REAL deltax,int degree)=0;
110 
112  REAL CFL();
113 
118  void SetCFL(REAL CFL);
119 
121  REAL Gamma();
122 
127  void SetGamma(int gamma);
128 
131 
133  void SetResidualType(TPZResidualType type);
134 
136  virtual int NStateVariables() const override = 0;
137 
142  virtual STATE Pressure(TPZVec<STATE> &U)=0;
143 
148  virtual void Print(std::ostream & out) override;
149 
151  virtual std::string Name() override = 0;
152 
157  virtual int VariableIndex(const std::string &name) override = 0;
158 
159  virtual int NSolutionVariables(int var) override = 0;
160 
162  virtual int NFluxes() override;
163 
169 protected:
170  virtual void Solution(TPZVec<STATE> &Sol,TPZFMatrix<STATE> &DSol,
171  TPZFMatrix<REAL> &axes,int var,
172  TPZVec<STATE> &Solout) override = 0;
173 public:
181  virtual void Solution(TPZMaterialData &data, int var, TPZVec<STATE> &Solout) override
182  {
183  TPZDiscontinuousGalerkin::Solution(data,var,Solout);
184  }
185 
192  virtual void Contribute(TPZMaterialData &data,
193  REAL weight,
194  TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef) override = 0;
195 
197  virtual void Contribute(TPZMaterialData &data,
198  REAL weight,
199  TPZFMatrix<STATE> &ef) override
200  {
201  TPZDiscontinuousGalerkin::Contribute(data,weight,ef);
202  }
204  virtual void ContributeInterface(TPZMaterialData &data,TPZMaterialData &dataleft,TPZMaterialData &dataright,
205  REAL weight,
206  TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef) override = 0;
208  virtual void ContributeInterface(TPZMaterialData &data,TPZMaterialData &dataleft,TPZMaterialData &dataright,
209  REAL weight,
210  TPZFMatrix<STATE> &ef) override
211  {
212  TPZDiscontinuousGalerkin::ContributeInterface(data,dataleft,dataright,weight,ef);
213  }
215  virtual void ContributeBC(TPZMaterialData &data,
216  REAL weight,
218  TPZBndCond &bc) override = 0;
220  virtual void ContributeBC(TPZMaterialData &data,
221  REAL weight,
222  TPZFMatrix<STATE> &ef,
223  TPZBndCond &bc) override
224  {
225  TPZDiscontinuousGalerkin::ContributeBC(data,weight,ef,bc);
226  }
227 
230  int ClassId() const override{
231  return Hash("TPZConservationLaw") ^ TPZDiscontinuousGalerkin::ClassId() << 1;
232  }
233 
235  void Write(TPZStream &buf, int withclassid) const override;
236 
238  void Read(TPZStream &buf, void *context) override;
239 
240 protected:
241 
243  int fDim;
244 
246  REAL fTimeStep;
247 
249  REAL fCFL;
250 
255  REAL fGamma;
256 
262 
269 
270 };
271 
277 {
278  return fDim;
279 }
280 
282 {
283  return fCFL;
284 }
285 
287 {
288  //if(CFL > 1e3) CFL = 1e3;
289  fCFL = CFL;
290 }
291 
293 {
294  fGamma = gamma;
295 }
296 
298 {
299  return fGamma;
300 }
301 
302 inline void TPZConservationLaw::SetTimeStep(REAL timeStep)
303 {
304  fTimeStep = timeStep;
305 }
306 
308 {
309  if(fResidualType == Residual_RT)return fTimeStep;
310  return 1.;
311 }
313 {
314  return 1;
315 }
316 
318 {
319  fContributionTime = time;
320 }
321 
322 
324 {
325  fResidualType = type;
326 }
327 
328 #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 Read(TPZStream &buf, void *context) override
Read the element data from a stream.
Definition: pzconslaw.cpp:83
virtual int NStateVariables() const override=0
Number of state variables according to the dimension.
TPZResidualType fResidualType
Variable to indicate the type of residual to be computed by Assemble.
Definition: pzconslaw.h:268
int ClassId() const override
Unique identifier for serialization purposes.
Definition: pzdiscgal.cpp:110
virtual void ContributeBC(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
Contributes to the residual vector the boundary conditions.
Definition: pzconslaw.h:220
TPZConservationLaw(const TPZConservationLaw &cp)
Copy constructor.
Definition: pzconslaw.h:77
void SetTimeStep(REAL timeStep)
Sets the time step used for time integration.
Definition: pzconslaw.h:302
clarg::argBool bc("-bc", "binary checkpoints", false)
void SetContributionTime(TPZContributeTime time)
Sets whether the contribution is advanced or referring to the last state.
Definition: pzconslaw.h:317
Templated vector implementation.
No time discretization.
Definition: pzconslaw.h:36
Semi implicit time discretization.
Definition: pzconslaw.h:38
void SetGamma(int gamma)
Sets the value of Gamma (constant of gas)
Definition: pzconslaw.h:292
int Dimension() const override
Returns the dimension of the problem.
Definition: pzconslaw.h:276
void degree(int root, int adj_num, int adj_row[], int adj[], int mask[], int deg[], int *iccsze, int ls[], int node_num)
Definition: rcm.cpp:875
virtual int NFluxes() override
Returns the number of fluxes associated to this material.
Definition: pzconslaw.h:312
virtual void ContributeInterface(TPZMaterialData &data, TPZMaterialData &dataleft, TPZMaterialData &dataright, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override=0
Contributes to the residual vector and tangent matrix the face-based quantities.
TPZTimeDiscr
Indicates the type of time discretization.
Definition: pzconslaw.h:34
virtual void Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ef) override
Contributes to the residual vector and tangent matrix the volume-based quantities.
Definition: pzconslaw.h:197
virtual STATE Pressure(TPZVec< STATE > &U)=0
Thermodynamic pressure determined by the law of an ideal gas.
virtual int NSolutionVariables(int var) override=0
Returns the number of variables associated with the variable indexed by var.
REAL TimeStep()
Returns the value of the time step.
Definition: pzconslaw.h:307
int fDim
Dimension of the problem.
Definition: pzconslaw.h:243
void SetCFL(REAL CFL)
Sets the CFL number.
Definition: pzconslaw.h:286
TPZResidualType
Which terms are being contributed.
Definition: pzconslaw.h:58
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...
Contains TPZMatrixclass which implements full matrix (using column major representation).
virtual void Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override=0
Contributes to the residual vector and tangent matrix the volume-based quantities.
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
TPZConservationLaw(int nummat, REAL timeStep, int dim)
Simple constructor with material id, time step (dt) and dimension of the spatial domain.
Definition: pzconslaw.cpp:17
virtual void ContributeInterface(TPZMaterialData &data, TPZMaterialData &dataleft, TPZMaterialData &dataright, REAL weight, TPZFMatrix< STATE > &ef) override
Contributes to the residual vector and tangent matrix the face-based quantities.
Definition: pzconslaw.h:208
virtual void ContributeBC(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override=0
Contributes to the residual vector the boundary conditions.
virtual void Solution(TPZMaterialData &data, int var, TPZVec< STATE > &Solout) override
Returns the solution associated with the var index based on the finite element approximation.
Definition: pzconslaw.h:181
virtual ~TPZConservationLaw()
Default destructor.
Definition: pzconslaw.cpp:45
REAL fCFL
CFL number.
Definition: pzconslaw.h:249
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
long double gamma(unsigned int n)
Evaluate the factorial of a integer.
Implements the interface for conservation laws, keeping track of the timestep as well.
Definition: pzconslaw.h:71
virtual std::string Name() override=0
Returns the material name.
void Write(TPZStream &buf, int withclassid) const override
Save the element data to a stream.
Definition: pzconslaw.cpp:74
virtual void Solution(TPZVec< STATE > &Sol, TPZFMatrix< STATE > &DSol, TPZFMatrix< REAL > &axes, int var, TPZVec< STATE > &Solout) override=0
REAL fTimeStep
Time step used for time integration.
Definition: pzconslaw.h:246
REAL CFL()
Returns the CFL number.
Definition: pzconslaw.h:281
REAL fGamma
Ratio between specific heat is constant and the specific heat the constant volume of a polytropic gas...
Definition: pzconslaw.h:255
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
Implicit time discretization.
Definition: pzconslaw.h:39
int ClassId() const override
Define the class id associated with the class.
Definition: pzconslaw.h:230
Unknown time discretization.
Definition: pzconslaw.h:40
Contains the TPZDiscontinuousGalerkin class which implements the interface for discontinuous Galerkin...
virtual int VariableIndex(const std::string &name) override=0
Returns the relative index of a variable according to its name.
TPZContributeTime fContributionTime
Variable indicating the context of the solution.
Definition: pzconslaw.h:261
TPZContributeTime
Indicates which term is put in the right hand side and tangent matrix.
Definition: pzconslaw.h:47
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 SetResidualType(TPZResidualType type)
Residual_RT for calculations and Flux_RT for convergence check.
Definition: pzconslaw.h:323
virtual void Print(std::ostream &out) override
Prints the state of internal variables.
Definition: pzconslaw.cpp:49
REAL Gamma()
Returns the value of Gamma (constant of gas)
Definition: pzconslaw.h:297
Explicit time discretization. Can to be Euler method, Runge Kutta method, etc.
Definition: pzconslaw.h:37