NeoPZ
TPZTracerFlow.cpp
Go to the documentation of this file.
1 
2 #include "TPZTracerFlow.h"
3 
4 
6 
7 }
8 
11 
12  m_mat_id = matid;
14  m_mass_matrix_Q = false;
15  m_dt = 0.0;
16  m_phi = 0.0;
17  m_fracture_epsilon = 0.0;
18 
19 }
20 
23  m_mat_id = other.m_mat_id;
24  m_dimension = other.m_dimension;
26  m_dt = other.m_dt;
27  m_phi = other.m_phi;
29 }
30 
32  if (this != & other) // prevent self-assignment
33  {
35  m_mat_id = other.m_mat_id;
36  m_dimension = other.m_dimension;
38  m_dt = other.m_dt;
39  m_phi = other.m_phi;
40  }
41  return *this;
42 }
43 
46 
47 }
48 
51  int ndata = datavec.size();
52  for (int idata=0; idata < ndata ; idata++) {
53  datavec[idata].SetAllRequirements(false);
54  datavec[idata].fNeedsSol = true;
55  }
56 }
57 
60  int ndata = datavec.size();
61  for (int idata=0; idata < ndata ; idata++) {
62  datavec[idata].SetAllRequirements(false);
63  datavec[idata].fNeedsSol = true;
64  datavec[idata].fNeedsNormal = true;
65  }
66 }
67 
69  data.SetAllRequirements(false);
70  data.fNeedsSol = true;
71  data.fNeedsNormal = true;
72  if(fLinearContext == false){
73  data.fNeedsNeighborSol = true;
74  }
75 }
76 
78 {
79 
80  data.SetAllRequirements(false);
81  data.fNeedsSol = true;
82  data.fNeedsNormal = true;
83  int nref_left = datavec_left.size();
84  for(int iref = 0; iref<nref_left; iref++){
85  datavec_left[iref].SetAllRequirements(false);
86  datavec_left[iref].fNeedsSol = true;
87  datavec_left[iref].fNeedsNormal = true;
88  }
89  int nref_right = datavec_right.size();
90  for(int iref = 0; iref<nref_right; iref++){
91  datavec_right[iref].SetAllRequirements(false);
92  datavec_right[iref].fNeedsSol = true;
93  }
94 
95 }
96 
97 
99 void TPZTracerFlow::Print(std::ostream &out){
100  out << "\t Base class print:\n";
101  out << " name of material : " << this->Name() << "\n";
102  TPZMaterial::Print(out);
103 }
104 
106 int TPZTracerFlow::VariableIndex(const std::string &name){
107 
108  if (!strcmp("Sw", name.c_str())) return 0;
109  if (!strcmp("So", name.c_str())) return 1;
110 
111  return TPZMaterial::VariableIndex(name);
112 }
113 
116  switch(var) {
117  case 0:
118  return 1; // Scalar
119  case 1:
120  return 1; // Scalar
121 
122  }
124 }
125 
126 
127 
128 // Contribute Methods being used
131 
132  int s_b = 2;
133  REAL sw = datavec[s_b].sol[0][0];
134 
135  Solout.Resize(this->NSolutionVariables(var));
136 
137  switch(var) {
138  case 0:
139  {
140  Solout[0] = sw;
141  }
142  break;
143  case 1:
144  {
145  Solout[0] = 1.0-sw;
146  }
147  break;
148  }
149 
150 
151 }
152 
154  REAL alpha = 1.0;
155  int dim = data.axes.Rows();
156  switch (dim) {
157  case 0:
159  break;
160  case 1:
161  alpha = m_fracture_epsilon*m_fracture_epsilon;
162  break;
163  case 2:
164  alpha = m_fracture_epsilon;
165  break;
166  default:
167  break;
168  }
169  return alpha;
170 }
171 
173 
174 #ifdef PZDEBUG
175  int nref = datavec.size();
176  if (nref != 3 ) {
177  std::cout << " Erro. The size of the datavec is different from 3 \n";
178  DebugStop();
179  }
180 #endif
181 
182  int s_b = 2;
183 
184  REAL alpha = FractureFactor(datavec[s_b]);
185  alpha =1.0;
186  // Setting the phis
187  TPZFMatrix<REAL> &phiS = datavec[s_b].phi;
188  REAL s = datavec[s_b].sol[0][0];
189  int n_phi_s = phiS.Rows();
190 
191  int firsts_s = 0;
192 
193  for (int is = 0; is < n_phi_s; is++)
194  {
195  ef(is + firsts_s) += 1.0 * alpha * weight * m_phi * s * phiS(is,0); //es necesario¿?
196 
197  for (int js = 0; js < n_phi_s; js++)
198  {
199  ek(is + firsts_s, js + firsts_s) += alpha * weight * m_phi * (phiS(js,0) )* phiS(is,0);
200  }
201  }
202 
203 }
204 
206  TPZFMatrix<STATE> ek_fake(ef.Rows(),ef.Rows());
207  this->Contribute(datavec, weight, ek_fake, ef);
208 
209 }
210 
211 
216  DebugStop();
217  return -1942;
218 }
219 
223 void TPZTracerFlow::Write(TPZStream &buf, int withclassid){
224  DebugStop();
225 }
226 
230 void TPZTracerFlow::Read(TPZStream &buf, void *context){
231  DebugStop();
232 }
233 
235 
236  std::cout<<"el valor de m_mass_matrix_Q es: "<<m_mass_matrix_Q<<std::endl;
237  if (m_mass_matrix_Q) {
238  return;
239  }
240 
241  int q_b = 0;
242  int s_b = 2;
243 
244  // Getting phis and solution for left material data
245  TPZFMatrix<REAL> &phiS_l = datavecleft[s_b].phi;
246  int n_phi_s_l = phiS_l.Rows();
247  REAL s_l = datavecleft[s_b].sol[0][0];
248  int firsts_s_l = 0;
249 
250  // Getting phis and solution for right material data
251  TPZFMatrix<REAL> &phiS_r = datavecright[s_b].phi;
252  int n_phi_s_r = phiS_r.Rows();
253  REAL s_r = datavecright[s_b].sol[0][0];
254  int firsts_s_r = n_phi_s_l;
255 
256  TPZManVector<REAL,3> n = data.normal;
257  TPZManVector<STATE,3> q_l = datavecleft[q_b].sol[0];
258  REAL qn = 0.0;
259  for (int i = 0; i < 3; i++) {
260  qn += q_l[i]*n[i];
261  }
262 
263  REAL beta = 0.0;
264  // upwinding
265  if (qn > 0.0) {
266  beta = 1.0;
267  }
268 
269  for (int is = 0; is < n_phi_s_l; is++) {
270 
271  ef(is + firsts_s_l) += +1.0 * m_dt * weight * (beta*s_l + (1.0-beta)*s_r)*phiS_l(is,0)*qn;
272 
273  for (int js = 0; js < n_phi_s_l; js++) {
274  ek(is + firsts_s_l, js + firsts_s_l) += +1.0* m_dt * weight * beta * phiS_l(js,0) * phiS_l(is,0)*qn;
275  }
276 
277  for (int js = 0; js < n_phi_s_r; js++) {
278  ek(is + firsts_s_l, js + firsts_s_r) += +1.0* m_dt * weight * (1.0-beta) * phiS_r(js,0) * phiS_l(is,0)*qn;
279  }
280 
281  }
282 
283  for (int is = 0; is < n_phi_s_r; is++) {
284 
285  ef(is + firsts_s_r) += -1.0* m_dt * weight * (beta*s_l + (1.0-beta)*s_r)*phiS_r(is,0)*qn;
286 
287  for (int js = 0; js < n_phi_s_l; js++) {
288  ek(is + firsts_s_r, js + firsts_s_l) += -1.0* m_dt * weight * beta * phiS_l(js,0) * phiS_r(is,0)*qn;
289  }
290 
291  for (int js = 0; js < n_phi_s_r; js++) {
292  ek(is + firsts_s_r, js + firsts_s_r) += -1.0* m_dt * weight * (1.0-beta) * phiS_r(js,0) * phiS_r(is,0)*qn;
293  }
294 
295  }
296 
297 
298 
299 }
300 
302  TPZFMatrix<STATE> ek_fake(ef.Rows(),ef.Rows());
303  this->ContributeInterface(data,datavecleft,datavecright, weight, ek_fake, ef);
304 
305 }
306 
308 
309  if (m_mass_matrix_Q) {
310  return;
311  }
312 
313  int q_b = 0;
314  int s_b = 2;
315 
316  // Getting phis and solution for left material data
317  TPZFMatrix<REAL> &phiS_l = datavecleft[s_b].phi;
318  int n_phi_s_l = phiS_l.Rows();
319  REAL s_l = datavecleft[s_b].sol[0][0];
320  int firsts_s_l = 0;
321 
322 
323  TPZManVector<REAL,3> n = data.normal;
324  TPZManVector<STATE,3> q_l = datavecleft[q_b].sol[0];
325  REAL qn = 0.0;
326  for (int i = 0; i < 3; i++) {
327  qn += q_l[i]*n[i];
328  }
329 
330  switch (bc.Type()) {
331 
332  case 0 : // BC inlet
333  {
334  REAL s_inlet = bc.Val2()(0,0);
335  if (qn > 0.0 || IsZero(qn)) {
336  std::cout << "TPZTracerFlow:: Outlet flux in inlet boundary condition qn = " << qn << std::endl;
337  }
338  for (int is = 0; is < n_phi_s_l; is++) {
339  ef(is + firsts_s_l) += +1.0* m_dt * weight * s_inlet * phiS_l(is,0)*qn;
340  }
341 
342  }
343  break;
344 
345  case 1 : // BC outlet
346  {
347 
348  if (qn > 0.0 || IsZero(qn)) {
349  for (int is = 0; is < n_phi_s_l; is++) {
350 
351  ef(is + firsts_s_l) += +1.0* m_dt * weight * s_l*phiS_l(is,0)*qn;
352 
353  for (int js = 0; js < n_phi_s_l; js++) {
354  ek(is + firsts_s_l, js + firsts_s_l) += +1.0* m_dt * weight * phiS_l(js,0) * phiS_l(is,0)*qn;
355  }
356  }
357  }else{
358  // std::cout << "TPZTracerFlow:: Inlet flux on outlet boundary condition qn = " << qn << std::endl;
359  }
360 
361 
362  }
363  break;
364 
365  default: std::cout << "This BC doesn't exist." << std::endl;
366  {
367 
368  DebugStop();
369  }
370  break;
371  }
372 
373  return;
374 
375 }
376 
378  TPZFMatrix<STATE> ek_fake(ef.Rows(),ef.Rows());
379  this->ContributeBCInterface(data,datavecleft, weight, ek_fake, ef, bc);
380 }
Defines the interface which material objects need to implement for discontinuous Galerkin formulation...
Definition: pzdiscgal.h:20
bool fLinearContext
Defines whether the equation context is linear solver or non linear.
Definition: TPZMaterial.h:70
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...
Definition: TPZTracerFlow.h:92
REAL m_dt
Regular time step size.
Definition: TPZTracerFlow.h:26
int ClassId() const override
TPZManVector< REAL, 3 > normal
normal to the element at the integration point
void ContributeBCInterface(TPZMaterialData &data, TPZMaterialData &dataleft, REAL weight, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
It computes a contribution to residual vector at one BC integration point.
Definition: TPZTracerFlow.h:93
bool IsZero(long double a)
Returns if the value a is close Zero as the allowable tolerance.
Definition: pzreal.h:668
virtual void FillDataRequirementsInterface(TPZMaterialData &data) override
Fill material data parameter with necessary requirements for the ContributeInterface method...
clarg::argBool bc("-bc", "binary checkpoints", false)
REAL m_phi
Porosity.
Definition: TPZTracerFlow.h:29
clarg::argInt dimension("-d", "Matrices dimension M x M", 1000)
int Type()
Definition: pzbndcond.h:249
TPZMaterial & operator=(const TPZMaterial &copy)
operator =
Definition: TPZMaterial.cpp:62
int m_mat_id
material dimension
Definition: TPZTracerFlow.h:20
virtual int VariableIndex(const std::string &name)
Returns the variable index associated with the name.
void SetAllRequirements(bool set)
Set all flags at once.
int NSolutionVariables(int var) override
Returns the number of variables associated with varindex.
int VariableIndex(const std::string &name) override
Returns the variable index associated with the name.
virtual void FillBoundaryConditionDataRequirement(int type, TPZVec< TPZMaterialData > &datavec) override
Set the required data at each integration point.
This class implements a simple vector storage scheme for a templated class T. Utility.
Definition: pzgeopoint.h:19
virtual void FillDataRequirements(TPZVec< TPZMaterialData > &datavec) override
Set the required data at each integration point.
bool m_mass_matrix_Q
Directive that stands for Mass matrix assembly.
Definition: TPZTracerFlow.h:23
TPZFMatrix< STATE > & Val2(int loadcase=0)
Definition: pzbndcond.h:255
void Print(std::ostream &out=std::cout) override
Print out the data associated with the material.
void Write(TPZStream &buf, int withclassid)
virtual void Print(std::ostream &out=std::cout)
Prints out the data associated with the material.
REAL m_fracture_epsilon
Definition: TPZTracerFlow.h:31
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object reallocating the necessary storage, copying the existing objects to the new...
Definition: pzvec.h:373
int m_dimension
material dimension
Definition: TPZTracerFlow.h:17
TPZTracerFlow & operator=(const TPZTracerFlow &other)
Assignment operator.
~TPZTracerFlow()
Default destructor.
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
virtual std::string Name() override
Returns the name of the material.
Definition: TPZTracerFlow.h:61
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
TPZFNMatrix< 9, REAL > axes
axes indicating the directions of the derivatives of the shapefunctions
void Read(TPZStream &buf, void *context) override
void Solution(TPZVec< TPZMaterialData > &datavec, int var, TPZVec< REAL > &Solout) override
Returns the solution associated with the var index.
virtual int NSolutionVariables(int var)
Returns the number of variables associated with the variable indexed by var.
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
TPZTracerFlow()
Default constructor.
REAL FractureFactor(TPZMaterialData &data)
void Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override
Not used contribute methods.
Definition: TPZTracerFlow.h:90