NeoPZ
pztransientmat.cpp
Go to the documentation of this file.
1 
6 #include "pztransientmat.h"
7 
8 template<class TBASEMAT>
10  return Hash("TPZTransientMaterial") ^ TBASEMAT::ClassId() << 1;
11 }
12 template<class TBASEMAT>
14  this->fTemporalIntegrator = EExplicit;
15 }
16 template<class TBASEMAT>
18  this->fTemporalIntegrator = EImplicit;
19 }
20 
21 template<class TBASEMAT>
23 TBASEMAT(nummat, dim) {
24  this->SetTimeStep(TimeStep);
25 }
26 
27 template<class TBASEMAT>
29 TBASEMAT(cp) {
31  this->fStep = cp.fStep;
32  this->fTimeStep = cp.fTimeStep;
33 }
34 
35 template<class TBASEMAT>
37  //NOTHING TO BE DONE
38 }
39 
40 template<class TBASEMAT>
42  REAL weight,
44  TPZFMatrix<STATE> &ef) {
45 
46  // Mostly for implicit
47  int numbersol = data.sol.size();
48  if (numbersol != 1) {
49  DebugStop();
50  }
51 
52  if (this->fStep == ECurrent){
53  TBASEMAT::Contribute(data,weight,ek,ef);
54  ContributeSolutionRhs(data.sol[0], data.phi, weight, ef);
55  ContributeTangent(data.sol[0], data.phi, weight, ek);
56  return;
57  }
58 
59  if (this->fStep == ELast){
60  this->ContributeSolutionRhs(data.sol[0], data.phi, weight, ef);
61  return;
62  }
63 
64  // Mostly for explicit
65  if (this->fStep == EMassMatrix){
66  this->ContributeTangent(data.sol[0], data.phi, weight, ek);
67  return;
68  }
69 
70  if (this->fStep == EFluxOnly){ //Calcula ef = F-ku
71  TBASEMAT::Contribute(data,weight,ek,ef);
72  return;
73  }
74 
75 
76  PZError << "ERROR! " << __PRETTY_FUNCTION__ << " at LINE " << __LINE__ << std::endl;
77 
78 }
79 
80 template<class TBASEMAT>
82  REAL weight,
85  TPZBndCond &bc) {
86  // Mostly for implicit
87  if (this->fStep == ECurrent){
88  TBASEMAT::ContributeBC(data,weight,ek,ef,bc);
89  return;
90  }
91 
92  if (this->fStep == ELast){
93  return;
94  }
95 
96 
97  // Mostly for explicit
98  if (this->fStep == EMassMatrix){
99  TPZFNMatrix<1000,STATE> fakeef(ek.Rows(),1,0.);
100  TBASEMAT::ContributeBC(data,weight,ek,fakeef,bc);
101  return;
102  }
103  if (this->fStep == EFluxOnly){ //Calcula ef = F-ku
104  TPZFNMatrix<1000> fakeef(ef.Rows(),ef.Rows(),0.);
105  TBASEMAT::ContributeBC(data,weight,ek,ef,bc);
106  return;
107  }
108 
109 
110  PZError << "ERROR! " << __PRETTY_FUNCTION__ << " at LINE " << __LINE__ << std::endl;
111 }
112 
113 template<class TBASEMAT>
115  REAL weight,
116  TPZFMatrix<STATE> &ek,
117  TPZFMatrix<STATE> &ef) {
118 
119  // Mostly for implicit
120  if (this->fStep == ECurrent){
121  TBASEMAT::ContributeInterface(data,dataleft,dataright, weight, ek, ef);
122  return;
123  }
124 
125  if (this->fStep == ELast){
126  return;
127  }
128 
129  // Mostly for explicit
130  if (this->fStep == EMassMatrix){
131  return;
132  }
133  if (this->fStep == EFluxOnly){ //Calcula ef = F-ku
134  TBASEMAT::ContributeInterface(data,dataleft,dataright, weight, ek, ef);
135  return;
136  }
137 
138 
139  PZError << "ERROR! " << __PRETTY_FUNCTION__ << " at LINE " << __LINE__ << std::endl;
140 
141 }
142 
143 template<class TBASEMAT>
145  REAL weight,
146  TPZFMatrix<STATE> &ek,
147  TPZFMatrix<STATE> &ef,
148  TPZBndCond &bc) {
149  // Mostly for implicit
150  if (this->fStep == ECurrent){
151  TBASEMAT::ContributeBCInterface(data,dataleft, weight,ek, ef, bc);
152  return;
153  }
154 
155  if (this->fStep == ELast){
156  return;
157  }
158 
159 
160  // Mostly for explicit
161  if (this->fStep == EMassMatrix){
162  return;
163  }
164  if (this->fStep == EFluxOnly){ //Calcula ef = F-ku
165  TBASEMAT::ContributeBCInterface(data, dataleft, weight, ek, ef, bc);
166  return;
167  }
168 
169 
170  PZError << "ERROR! " << __PRETTY_FUNCTION__ << " at LINE " << __LINE__ << std::endl;
171 
172 }
173 
174 template<class TBASEMAT>
176  REAL Mult = +1.;
177  //Last solution is added to residual
178  if (this->fStep == ECurrent) Mult = -1.;
179  //Current solution is subtracted from residual
180  const int phr = phi.Rows();
181  const int nstate = this->NStateVariables();
182  const REAL DeltaT = this->TimeStep();
183  int i, k;
184  for(i = 0; i < phr; i++) {
185  for(k = 0; k < nstate; k++){
186  ef(i*nstate+k, 0) += (STATE)(Mult * weight) * sol[k] * (STATE)(phi(i,0) / DeltaT);
187  }//k
188  }//i
189 }//method
190 
191 template<class TBASEMAT>
193  const int phr = phi.Rows();
194  const int nstate = this->NStateVariables();
195  const REAL DeltaT = this->TimeStep();
196  int i, j, k;
197  for(i = 0; i < phr; i++) {
198  for(j = 0; j < phr; j++){
199  for(k = 0; k < nstate; k++){
200  ek(i*nstate+k, j*nstate+k) += weight * phi(i,0) * phi(j,0) / DeltaT;
201  }//k
202  }//j
203  }//i
204 }//method
205 
206 #ifndef STATE_COMPLEX
207 #include "pzpoisson3d.h"
209 
210 #include "pznonlinearpoisson3d.h"
212 
213 #include "pzburger.h"
214 template class TPZTransientMaterial< TPZBurger >;
215 
221 }
222 
223 #endif
Contains the TPZNonLinearPoisson3d class.
clarg::argBool bc("-bc", "binary checkpoints", false)
Contains the TPZTransientMaterial class which implements an implicit Euler time integrator.
void SetTimeStep(REAL TimeStep)
Define time step DeltaT.
virtual void ContributeInterface(TPZMaterialData &data, TPZMaterialData &dataleft, TPZMaterialData &dataright, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override
virtual void ContributeTangent(TPZVec< STATE > &sol, TPZFMatrix< REAL > &phi, REAL weight, TPZFMatrix< STATE > &ek)
TPZTransientMaterial(int nummat, int dim, REAL TimeStep)
Class constructor.
Contains the TPZMatPoisson3d class.
TPZFNMatrix< 220, REAL > phi
vector of shapefunctions (format is dependent on the value of shapetype)
virtual void Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override
int ClassId() const override
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
#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
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
Implements an implicit Euler time integrator. The Material Classes Material.
Contains the TPZBurger class which implements a linear convection equation using a burger flux...
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
ETemporalScheme fTemporalIntegrator
~TPZTransientMaterial()
Default destructor.
void SetExplicit()
Sets integral scheme as an explicit Euler.
virtual void ContributeBCInterface(TPZMaterialData &data, TPZMaterialData &dataleft, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
virtual void ContributeBC(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
TPZSolVec sol
vector of the solutions at the integration point
virtual void ContributeSolutionRhs(TPZVec< STATE > &sol, TPZFMatrix< REAL > &phi, REAL weight, TPZFMatrix< STATE > &ef)
void TestInstantiations()
Instantiations to TPZMatPoisson3d, TPZNonLinearPoisson3d and TPZBurger.
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15
REAL TimeStep()
Returns time step value.