NeoPZ
TPZLinearConvection.cpp
Go to the documentation of this file.
1 
6 #include "TPZLinearConvection.h"
7 #include "pzbndcond.h"
8 #include "pzerror.h"
9 
10 using namespace std;
11 
14  fConvect[0] = copy.fConvect[0];
15  fConvect[1] = copy.fConvect[1];
16 }
19  fConvect[0] = conv[0];
20  fConvect[1] = conv[1];
21 }
22 
23 void TPZLinearConvection::SetData(istream &data) {
24  PZError << "TPZMaterial::SetData is called.\n";
25  data >> fConvect[0] >> fConvect[1];
26 }
28  TPZLinearConvection *result = new TPZLinearConvection(*this);
29 
30  return result;
31 }
33  TPZVec<STATE> &Solout){
34  if(var == 1) {
35  Solout.Resize(2);
36  Solout[0] = Sol[0]*fConvect[0];
37  Solout[1] = Sol[0]*fConvect[1];
38  } else TPZMaterial::Solution(Sol,DSol,axes,var,Solout);
39 }
41  if(index == 1) return 2;
42  return TPZMaterial::NSolutionVariables(index);
43 }
44 int TPZLinearConvection::VariableIndex(const std::string &name) {
45  if(!strcmp(name.c_str(),"flux")) return 1;
46  return TPZMaterial::VariableIndex(name);
47 }
48 void TPZLinearConvection::Print(std::ostream & out) {
49  TPZMaterial::Print(out);
50  out << "Convection : " << fConvect[0] << ' ' << fConvect[1] << endl;
51 }
53  return 1;
54 }
56  return 2;
57 }
60  TPZFMatrix<REAL> &dphi = data.dphix;
61  TPZFMatrix<REAL> &phi = data.phi;
62  TPZFMatrix<REAL> &daxesdksi=data.jacinv;
63  TPZFMatrix<REAL> &axes=data.axes;
64 
65  STATE convectax[2];
66  convectax[0] = fConvect[0]*axes(0,0)+fConvect[1]*axes(0,1);
67  convectax[1] = fConvect[0]*axes(1,0)+fConvect[1]*axes(1,1);
68  STATE sconvect[2] = {1.,1.};
69  if(convectax[0] < 0.) sconvect[0] = -1.;
70  if(convectax[1] < 0.) sconvect[1] = -1.;
71  // REAL convectnorm = sqrt(convectax[0]*convectax[0]+convectax[1]*convectax[1]);
72  STATE delax[2];
73  delax[0] = sqrt(daxesdksi(0,0)*daxesdksi(0,0)+daxesdksi(1,0)*daxesdksi(1,0));
74  delax[1] = sqrt(daxesdksi(0,1)*daxesdksi(0,1)+daxesdksi(1,1)*daxesdksi(1,1));
75  int nshape = phi.Rows();
76  int in,jn;
77  for(in=0; in<nshape; in++) {
78  for(jn=0; jn<nshape; jn++) {
79  ek(in,jn) += weight*(
80  delax[0]*sconvect[0]*dphi(0,in)*(convectax[0]*dphi(0,jn)+convectax[1]*dphi(1,jn))
81  +delax[1]*sconvect[1]*dphi(1,in)*(convectax[0]*dphi(0,jn)+convectax[1]*dphi(1,jn))
82  //delax[0]/convectnorm*(dphi(0,in)*convectax[0]+dphi(1,in)*convectax[1])*(dphi(0,jn)*convectax[0]+dphi(1,jn)*convectax[1])
83  -dphi(0,in)*convectax[0]*phi(jn,0)
84  -dphi(1,in)*convectax[1]*phi(jn,0)
85  );
86  }
87  }
88 }
89 
92  TPZFMatrix<REAL> &phi = data.phi;
93 
94  if(bc.Material() != this){
95  PZError << "TPZMat1dLin.apply_bc warning : this material didn't create the boundary condition!\n";
96  }
97 
98  if(bc.Type() < 0 && bc.Type() > 2){
99  PZError << "TPZMat1dLin.aplybc, unknown boundary condition type :" <<
100  bc.Type() << " boundary condition ignored\n";
101  }
102 
103  int numdof = NStateVariables();
104  int numnod = ek.Rows()/numdof;
105  int r = numdof;
106 
107  int idf,jdf,in,jn;
108  switch(bc.Type()){
109 
110  case 0:
111  for(in=0 ; in<numnod ; ++in){
112  for(idf = 0;idf<r;idf++) {
113  (ef)(in*r+idf,0) += gBigNumber*phi(in,0)*bc.Val2()(idf,0)*weight;
114  }
115  for(jn=0 ; jn<numnod ; ++jn) {
116  for(idf = 0;idf<r;idf++) {
117  ek(in*r+idf,jn*r+idf) += gBigNumber*phi(in,0)*phi(jn,0)*weight;
118  }
119  }
120  }
121  break;
122 
123  case 1:
124  for(in=0 ; in<numnod ; ++in){
125  for(idf = 0;idf<r;idf++) {
126  (ef)(in*r+idf,0) += phi(in,0)*bc.Val2()(idf,0)*weight;
127  }
128  }
129  break;
130 
131  case 2:
132  for(in=0 ; in<numnod ; ++in){
133  for(idf = 0;idf<r;idf++) {
134  (ef)(in*r+idf,0) += phi(in,0)*bc.Val2()(idf,0)*weight;
135  }
136  for(jn=0 ; jn<numnod ; ++jn) {
137  for(idf = 0;idf<r;idf++) {
138  for(jdf = 0;jdf<r;jdf++) {
139  ek(in*r+idf,jn*r+jdf) += bc.Val1()(idf,jdf)*phi(in,0)*phi(jn,0)*weight;
140  }
141  }
142  }
143  }//fim switch
144  }
145 }
146 
148  return Hash("TPZLinearConvection") ^ TPZMaterial::ClassId() << 1;
149 }
virtual void Solution(TPZMaterialData &data, int var, TPZVec< STATE > &Solout)
Returns the solution associated with the var index based on the finite element approximation.
virtual void SetData(std::istream &data) override
Reads data of the material from a istream (file data)
virtual int NStateVariables() const override
Returns the number of state variables associated with the material.
clarg::argBool bc("-bc", "binary checkpoints", false)
int Type()
Definition: pzbndcond.h:249
virtual int VariableIndex(const std::string &name)
Returns the variable index associated with the name.
Defines PZError.
TPZLinearConvection(TPZLinearConvection &copy)
Copy constructor.
TPZFNMatrix< 9, REAL > jacinv
value of the inverse of the jacobian at the integration point
virtual int Dimension() const override
Returns the integrable dimension of the material.
TPZFMatrix< STATE > & Val2(int loadcase=0)
Definition: pzbndcond.h:255
TPZFNMatrix< 220, REAL > phi
vector of shapefunctions (format is dependent on the value of shapetype)
Implements a linear scalar convection equation with modified SUPG difusion.
TPZFNMatrix< 660, REAL > dphix
values of the derivative of the shape functions
virtual int ClassId() const override
Define the class id associated with the class.
virtual void Print(std::ostream &out=std::cout)
Prints out the data associated with the material.
This abstract class defines the behaviour which each derived class needs to implement.
Definition: TPZMaterial.h:39
Contains the TPZBndCond class which implements a boundary condition for TPZMaterial objects...
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
virtual void Print(std::ostream &out=std::cout) override
Print out the data associated with the material.
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
virtual int VariableIndex(const std::string &name) override
Returns the variable index associated with the name.
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sqrt
Definition: tfadfunc.h:120
TPZFNMatrix< 9, REAL > axes
axes indicating the directions of the derivatives of the shapefunctions
virtual int NSolutionVariables(int var) override
Returns the number of variables associated with the variable indexed by var.
TPZFMatrix< STATE > & Val1()
Definition: pzbndcond.h:253
static REAL gBigNumber
Big number to penalization method, used for Dirichlet conditions.
Definition: TPZMaterial.h:83
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
int ClassId() const override
Unique identifier for serialization purposes.
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...
static int idf[6]
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 int NSolutionVariables(int var)
Returns the number of variables associated with the variable indexed by var.
Contains the TPZLinearConvection class which implements a linear scalar convection equation...
virtual void Solution(TPZVec< STATE > &Sol, TPZFMatrix< STATE > &DSol, TPZFMatrix< REAL > &axes, int var, TPZVec< STATE > &Solout) override
virtual TPZMaterial * NewMaterial() override
To create another material of the same type.
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15
TPZMaterial * Material() const
Definition: pzbndcond.h:263