NeoPZ
TPZFVHybrid.cpp
Go to the documentation of this file.
1 
5 #include "TPZFVHybrid.h"
6 
7 #include "pzbndcond.h"
8 
9 #include "pzfmatrix.h"
10 #include "pzerror.h"
11 #include <math.h>
12 
13 using namespace std;
14 
15 TPZMatHybrid::TPZMatHybrid(int nummat) : TPZMaterial(nummat), fXf(1,1,0.) {
16 
17  fNumMat = nummat;//material id
18 }
19 
21 }
22 
24  return 1;
25 }
26 
27 void TPZMatHybrid::Print(std::ostream &out) {
28  out << "name of material : " << Name() << "\n";
29  out << "properties : \n";
30  out << "Material id = " << fNumMat << endl;
31 }
32 
34  REAL weight,
36  TPZFMatrix<STATE> &ef) {
37 
38  TPZFMatrix<REAL> &dphi = data.dphix;
39  // TPZFMatrix<REAL> &dphiL = data.dphixl;
40  // TPZFMatrix<REAL> &dphiR = data.dphixr;
41  TPZFMatrix<REAL> &phi = data.phi;
42  // TPZFMatrix<REAL> &phiL = data.phil;
43  // TPZFMatrix<REAL> &phiR = data.phir;
44  // TPZManVector<REAL,3> &normal = data.normal;
45  TPZManVector<REAL,3> &x = data.x;
46  // int &POrder=data.p;
47  // int &LeftPOrder=data.leftp;
48  // int &RightPOrder=data.rightp;
49  // TPZVec<REAL> &sol=data.sol;
50  // TPZVec<REAL> &solL=data.soll;
51  // TPZVec<REAL> &solR=data.solr;
52  // TPZFMatrix<REAL> &dsol=data.dsol;
53  // TPZFMatrix<REAL> &dsolL=data.dsoll;
54  // TPZFMatrix<REAL> &dsolR=data.dsolr;
55  // REAL &faceSize=data.HSize;
56  // TPZFMatrix<REAL> &daxesdksi=data.daxesdksi;
57  TPZFMatrix<REAL> &axes=data.axes;
58 
59 
60  int phr = phi.Rows();
61  int dim = phi.Cols();
62  int k;
63  if(fForcingFunction) { // phi(in, 0) : fun�o de forma associada ao n�in
65  fForcingFunction->Execute(x,res); // dphi(i,j) : derivada c/r a xi da fun�o de forma j
66  fXf(0,0) = res[0];
67  }
68 
69  TPZVec<REAL> normal(3);
70  for(k=0;k<3;k++) normal[k] = axes(0,k);//primeira linha de axes
71 
72  for( int in = 0; in < phr; in++ ) {
73  ef(in, 0) += weight * fXf(0,0) * phi(in, 0) ;
74  for( int jn = 0; jn < phr; jn++ ) {
75  REAL sum = 0.0;
76  for(k=0;k<dim;k++) sum +=dphi(k,in) * dphi(k,jn);
77  ek(in,jn) += weight * sum;
78  }
79  }
80 }
81 
83  REAL weight,
86  TPZBndCond &bc) {
87 
88  // TPZFMatrix<REAL> &dphi = data.dphix;
89  // TPZFMatrix<REAL> &dphiL = data.dphixl;
90  // TPZFMatrix<REAL> &dphiR = data.dphixr;
91  TPZFMatrix<REAL> &phi = data.phi;
92  // TPZFMatrix<REAL> &phiL = data.phil;
93  // TPZFMatrix<REAL> &phiR = data.phir;
94  // TPZManVector<REAL,3> &normal = data.normal;
95  // TPZManVector<REAL,3> &x = data.x;
96  // int &POrder=data.p;
97  // int &LeftPOrder=data.leftp;
98  // int &RightPOrder=data.rightp;
99  // TPZVec<REAL> &sol=data.sol;
100  // TPZVec<REAL> &solL=data.soll;
101  // TPZVec<REAL> &solR=data.solr;
102  // TPZFMatrix<REAL> &dsol=data.dsol;
103  // TPZFMatrix<REAL> &dsolL=data.dsoll;
104  // TPZFMatrix<REAL> &dsolR=data.dsolr;
105  // REAL &faceSize=data.HSize;
106  // TPZFMatrix<REAL> &daxesdksi=data.daxesdksi;
107  // TPZFMatrix<REAL> &axes=data.axes;
108 
109  if(bc.Material() != this){
110  PZError << "TPZMat1dLin.apply_bc warning : this material didn't create the boundary condition!\n";
111  }
112 
113  if(bc.Type() < 0 && bc.Type() > 2){
114  PZError << "TPZMat1dLin.aplybc, unknown boundary condition type :" <<
115  bc.Type() << " boundary condition ignored\n";
116  }
117 
118 
119  int numdof = NStateVariables();
120  int numnod = ek.Rows()/numdof;
121  int r = numdof;
122 
123  int idf,jdf,in,jn;
124  switch(bc.Type()){
125 
126  case 0:
127  for(in=0 ; in<numnod ; ++in){
128  for(idf = 0;idf<r;idf++) {
129  (ef)(in*r+idf,0) += gBigNumber*phi(in,0)*bc.Val2()(idf,0)*weight;
130  }
131  for(jn=0 ; jn<numnod ; ++jn) {
132  for(idf = 0;idf<r;idf++) {
133  ek(in*r+idf,jn*r+idf) += gBigNumber*phi(in,0)*phi(jn,0)*weight;
134  }
135  }
136  }
137  break;
138 
139  case 1:
140  for(in=0 ; in<numnod ; ++in){
141  for(idf = 0;idf<r;idf++) {
142  (ef)(in*r+idf,0) += phi(in,0)*bc.Val2()(idf,0)*weight;
143  }
144  }
145  break;
146 
147  case 2:
148  for(in=0 ; in<numnod ; ++in){
149  for(idf = 0;idf<r;idf++) {
150  (ef)(in*r+idf,0) += phi(in,0)*bc.Val2()(idf,0)*weight;
151  }
152  for(jn=0 ; jn<numnod ; ++jn) {
153  for(idf = 0;idf<r;idf++) {
154  for(jdf = 0;jdf<r;jdf++) {
155  ek(in*r+idf,jn*r+jdf) += bc.Val1()(idf,jdf)*phi(in,0)*phi(jn,0)*weight;
156  }
157  }
158  }
159  }//fim switch
160  }
161 }
162 
164 int TPZMatHybrid::VariableIndex(const std::string &name){
165  if(!strcmp("Pressao",name.c_str())) return 0;
166  if(!strcmp("Solution",name.c_str())) return 1;
167 
168  return TPZMaterial::VariableIndex(name);
169 }
170 
172 
173  if(var == 0 || var == 1 || var == 2) return 1;
175 }
176 
178 
179  if(var == 1) {
180  cout << "TPZMatHybrid::Solution implementar Pressao\n";
181  return;
182  }
183  if(var == 1) {
184  Solout[0] = Sol[0];
185  return;
186  }
187 
188  TPZMaterial::Solution(Sol,DSol,axes,var,Solout);
189 }
190 
192  if(fabs(axes(2,0)) >= 1.e-6 || fabs(axes(2,1)) >= 1.e-6) {
193  cout << "TPZMatHybrid::Flux only serves for xy configuration\n";
194  axes.Print("axes");
195  }
196 }
197 //ofstream arq1("Simetria.dat");
199  TPZVec<STATE> &u_exact,TPZFMatrix<STATE> &du_exact,TPZVec<REAL> &values) {
200 
201  TPZVec<STATE> sol(1),dsol(2);
202  Solution(u,dudx,axes,1,sol);
203  Solution(u,dudx,axes,2,dsol);
204  for (int i = 0; i < 3; i++)
205  values[i] = 0.0;
206  //values[0] : norma energia do erro
207  values[0] = (dsol[0] - du_exact(0,0))*(dsol[0] - du_exact(0,0));
208  values[0] += (dsol[1] - du_exact(1,0))*(dsol[1] - du_exact(1,0));
209  //values[1] -> norma energia da solucao Uhp (aproximada)
210  values[1] = (dsol[0])*(dsol[0]);
211  values[1] += (dsol[1])*(dsol[1]);
212  //values[2] -> morma enaergia da solucao U (exata)
213  values[2] = (du_exact(0,0))*(du_exact(0,0));
214  values[2] += (du_exact(1,0))*(du_exact(1,0));
215 }
216 
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 Execute(const TPZVec< REAL > &x, TPZVec< TVar > &f, TPZFMatrix< TVar > &df)
Performs function computation.
Definition: pzfunction.h:38
virtual std::string Name() override
Returns the name of the material.
Definition: TPZFVHybrid.h:35
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ fabs
Definition: tfadfunc.h:140
TPZManVector< REAL, 3 > x
value of the coordinate at the integration point
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.
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)
virtual void Flux(TPZVec< REAL > &x, TPZVec< STATE > &Sol, TPZFMatrix< STATE > &DSol, TPZFMatrix< REAL > &axes, TPZVec< STATE > &flux) override
Computes the value of the flux function to be used by ZZ error estimator.
TPZFNMatrix< 660, REAL > dphix
values of the derivative of the shape functions
virtual void Print(std::ostream &out) override
Prints out the data associated with the material.
Definition: TPZFVHybrid.cpp:27
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 int NSolutionVariables(int var) override
Returns the number of variables associated with the variable indexed by var.
Contains TPZMatrixclass which implements full matrix (using column major representation).
virtual int NStateVariables() const override
Returns the number of state variables associated with the material.
Definition: TPZFVHybrid.cpp:23
Contains the TPZMatHybrid class.
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
string res
Definition: test.py:151
TPZFMatrix< STATE > & Val1()
Definition: pzbndcond.h:253
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...
Definition: TPZFVHybrid.cpp:33
static REAL gBigNumber
Big number to penalization method, used for Dirichlet conditions.
Definition: TPZMaterial.h:83
virtual int VariableIndex(const std::string &name) override
TPZFMatrix< STATE > fXf
Definition: TPZFVHybrid.h:19
static int idf[6]
virtual int NSolutionVariables(int var)
Returns the number of variables associated with the variable indexed by var.
virtual void Solution(TPZVec< STATE > &Sol, TPZFMatrix< STATE > &DSol, TPZFMatrix< REAL > &axes, int var, TPZVec< STATE > &Solout) override
TPZAutoPointer< TPZFunction< STATE > > fForcingFunction
Pointer to forcing function, it is the right member at differential equation.
Definition: TPZMaterial.h:47
int64_t Cols() const
Returns number of cols.
Definition: pzmatrix.h:809
virtual void Print(std::ostream &out) const
Definition: pzmatrix.h:253
def values
Definition: rdt.py:119
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...
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...
Definition: TPZFVHybrid.cpp:82
virtual ~TPZMatHybrid()
Definition: TPZFVHybrid.cpp:20
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15
TPZMaterial * Material() const
Definition: pzbndcond.h:263
TPZMatHybrid(int nummat)
Definition: TPZFVHybrid.cpp:15