NeoPZ
TPZElasticity2dHybrid.cpp
Go to the documentation of this file.
1 
7 #include "pzelmat.h"
8 #include "pzbndcond.h"
9 #include "pzmatrix.h"
10 #include "pzfmatrix.h"
11 #include "pzerror.h"
12 #include <math.h>
13 
14 #include "pzlog.h"
15 #ifdef LOG4CXX
16 static LoggerPtr logdata(Logger::getLogger("pz.material.elasticity.data"));
17 #endif
18 
19 #include <fstream>
20 using namespace std;
21 
24 }
25 
28 }
29 
30 TPZElasticity2DHybrid::TPZElasticity2DHybrid(int num, REAL E, REAL nu, REAL fx, REAL fy, int plainstress)
32 }
33 
35 }
36 
38 
39  TPZMaterialData::MShapeFunctionType shapetype = data[0].fShapeType;
40  if(shapetype==data[0].EVecShape){
41  DebugStop();
42  return;
43  }
44  TPZFMatrix<REAL> &dphi = data[0].dphix;
45  TPZFMatrix<REAL> &phi = data[0].phi;
46  TPZFMatrix<REAL> &axes=data[0].axes;
47 
48  TPZFMatrix<REAL> &phirigidbodymode = data[1].phi;
49 
50  int phc,phr,dphc,dphr,efr,efc,ekr,ekc;
51  phc = phi.Cols();
52  phr = phi.Rows();
53  int phr_rigid = phirigidbodymode.Rows();
54  dphc = dphi.Cols();
55  dphr = dphi.Rows();
56  efr = ef.Rows();
57  efc = ef.Cols();
58  ekr = ek.Rows();
59  ekc = ek.Cols();
60  if(phc != 1 || dphr != 2 || phr != dphc || 2*phr+2*phr_rigid != ekr){
61  PZError << "\nTPZElasticityMaterial.contr, inconsistent input data : \n" <<
62  "phi.Cols() = " << phi.Cols() << " dphi.Cols() = " << dphi.Cols() <<
63  " phi.Rows = " << phi.Rows() << " dphi.Rows = " <<
64  dphi.Rows() << "\nek.Rows() = " << ek.Rows() << " ek.Cols() = "
65  << ek.Cols() <<
66  "\nef.Rows() = " << ef.Rows() << " ef.Cols() = "
67  << ef.Cols() << "\n";
68  DebugStop();
69  return;
70  // PZError.show();
71  }
72  TPZManVector<STATE,3> locforce(ff);
73  if(fForcingFunction) { // phi(in, 0) : node in associated forcing function
75  fForcingFunction->Execute(data[0].x,res);
76  locforce = res;
77  }
78 
79  REAL E(fE_def), nu(fnu_def);
80 
81  if (fElasticity) {
82  TPZManVector<STATE,2> result(2);
83  TPZFNMatrix<4,STATE> Dres(0,0);
84  fElasticity->Execute(data[0].x, result, Dres);
85  E = result[0];
86  nu = result[1];
87  }
88 
89  REAL Eover1MinNu2 = E/(1-nu*nu);
90  REAL Eover21PlusNu = E/(2.*(1+nu));
91 
92 
93  TPZFNMatrix<4,STATE> du(2,2);
94  /*
95  * Plane strain materials values
96  */
97  REAL nu1 = 1. - nu;//(1-nu)
98  REAL nu2 = (1.-2.*nu)/2.;
99  REAL F = E/((1.+nu)*(1.-2.*nu));
100  STATE epsx, epsy,epsxy,epsz = 0.;
101  TPZFNMatrix<9,STATE> DSolxy(2,2);
102  // dudx - dudy
103  DSolxy(0,0) = data[0].dsol[0](0,0)*axes(0,0)+data[0].dsol[0](1,0)*axes(1,0);
104  DSolxy(1,0) = data[0].dsol[0](0,0)*axes(0,1)+data[0].dsol[0](1,0)*axes(1,1);
105  // dvdx - dvdy
106  DSolxy(0,1) = data[0].dsol[0](0,1)*axes(0,0)+data[0].dsol[0](1,1)*axes(1,0);
107  DSolxy(1,1) = data[0].dsol[0](0,1)*axes(0,1)+data[0].dsol[0](1,1)*axes(1,1);
108  epsx = DSolxy(0,0);// du/dx
109  epsy = DSolxy(1,1);// dv/dy
110  epsxy = 0.5*(DSolxy(1,0)+DSolxy(0,1));
111  REAL lambda = GetLambda(E,nu);
112  REAL mu = GetMU(E,nu);
113  if (fPlaneStress) {
114  epsz = -lambda*(epsx+epsy)/(lambda+2.*mu);
115  }
116  else
117  {
118  epsz = 0.;
119  }
120  // epsz = data[1].sol[0][0];
121  STATE SigX = lambda*(epsx+epsy+epsz)+2.*mu*epsx + fPreStressXX;
122  STATE SigY = lambda*(epsx+epsy+epsz)+2.*mu*epsy + fPreStressYY;
123 
124  STATE SigZ = lambda*(epsx+epsy+epsz)+2.*mu*epsz;
125  STATE TauXY = 2*mu*epsxy+fPreStressXY;
126 
127 
128  for( int in = 0; in < phr; in++ ) {
129  du(0,0) = dphi(0,in)*axes(0,0)+dphi(1,in)*axes(1,0);//dvx
130  du(1,0) = dphi(0,in)*axes(0,1)+dphi(1,in)*axes(1,1);//dvy
131 
132 
133  for (int col = 0; col < efc; col++)
134  {
135  ef(2*in, col) += weight * (locforce[0]*phi(in,0) - du(0,0)*(SigX) - du(1,0)*(TauXY)); // direcao x
136  ef(2*in+1, col) += weight * (locforce[1]*phi(in,0) - du(0,0)*(TauXY) - du(1,0)*(SigY)); // direcao y <<<----
137  }
138  for( int jn = 0; jn < phr; jn++ ) {
139  du(0,1) = dphi(0,jn)*axes(0,0)+dphi(1,jn)*axes(1,0);//dux
140  du(1,1) = dphi(0,jn)*axes(0,1)+dphi(1,jn)*axes(1,1);//duy
141 
142 
143  if (fPlaneStress != 1){
144  /* Plane Strain State */
145  ek(2*in,2*jn) += weight * (
146  nu1 * du(0,0)*du(0,1)+ nu2 * du(1,0)*du(1,1)
147  ) * F;
148 
149  ek(2*in,2*jn+1) += weight * (
150  nu*du(0,0)*du(1,1)+ nu2*du(1,0)*du(0,1)
151  ) * F;
152 
153  ek(2*in+1,2*jn) += weight * (
154  nu*du(1,0)*du(0,1)+ nu2*du(0,0)*du(1,1)
155  ) * F;
156 
157  ek(2*in+1,2*jn+1) += weight * (
158  nu1*du(1,0)*du(1,1)+ nu2*du(0,0)*du(0,1)
159  ) * F;
160  }
161  else{
162  DebugStop();
163  /* Plain stress state */
164  ek(2*in,2*jn) += weight * (
165  Eover1MinNu2 * du(0,0)*du(0,1)+ Eover21PlusNu * du(1,0)*du(1,1)
166  );
167 
168  ek(2*in,2*jn+1) += weight * (
169  Eover1MinNu2*nu*du(0,0)*du(1,1)+ Eover21PlusNu*du(1,0)*du(0,1)
170  );
171 
172  ek(2*in+1,2*jn) += weight * (
173  Eover1MinNu2*nu*du(1,0)*du(0,1)+ Eover21PlusNu*du(0,0)*du(1,1)
174  );
175 
176  ek(2*in+1,2*jn+1) += weight * (
177  Eover1MinNu2*du(1,0)*du(1,1)+ Eover21PlusNu*du(0,0)*du(0,1)
178  );
179  }
180  }
181  }
182  //constantes 1
183  for (int in=0; in<phr; in++) {
184  ek(2*phr,2*in) -= (STATE)phi(in,0)*weight;
185  ek(2*phr+1,2*in+1) -= (STATE)phi(in,0)*weight;
186  ek(2*in,2*phr) -= phi(in,0)*weight;
187  ek(2*in+1,2*phr+1) -= phi(in,0)*weight;
188  // u*(x-x0)-v*(y-y0)
189  ek(2*phr+2,2*in) -= (phi(in,0)*phirigidbodymode(1))*weight;
190  ek(2*phr+2,2*in+1) -= (-phi(in,0)*phirigidbodymode(0))*weight;
191  ek(2*in,2*phr+2) -= (phi(in,0)*phirigidbodymode(1))*weight;
192  ek(2*in+1,2*phr+2) -= (-phi(in,0)*phirigidbodymode(0))*weight;
193  }
194 
195  //constante 2
196  ek(2*phr+3,2*phr) += weight;
197  ek(2*phr,2*phr+3) += weight;
198  ek(2*phr+4,2*phr+1) += weight;
199  ek(2*phr+1,2*phr+4) += weight;
200  ek(2*phr+5,2*phr+2) += weight;
201  ek(2*phr+2,2*phr+5) += weight;
202  //ek(phr,phr) -= 1.*(STATE)weight;
203 
204 }
205 
206 //void TPZElasticity2DHybrid::Solution(TPZVec<TPZMaterialData> &datavec, int var, TPZVec<STATE> &Solout){
207 // TPZElasticityMaterial::Solution(datavec[0],var,Solout);
208 //}
209 
210 
211 
214 
215 
217  if(shapetype==data.EVecShape){
218  ContributeVecShapeBC(data,weight,ek, ef,bc);
219  return;
220  }
221 
222  TPZManVector<STATE,3> val2(2,0.);
223  val2[0] = bc.Val2()(0,0);
224  val2[1] = bc.Val2()(1,0);
225  if(bc.HasForcingFunction())
226  {
227  TPZManVector<STATE,3> result(3,0.);
228  TPZFNMatrix<9,STATE> resval1(2,2,0.);
229  bc.ForcingFunction()->Execute(data.x, result, resval1);
230  val2[0] = result[0];
231  val2[1] = result[1];
232  }
233  TPZFMatrix<REAL> &phi = data.phi;
234  int dim = Dimension();
235 
236  const REAL BIGNUMBER = TPZMaterial::gBigNumber;
237 
238  int phr = phi.Rows();
239  short in,jn;
240 
241  if (ef.Cols() != bc.NumLoadCases()) {
242  DebugStop();
243  }
244 
245 // In general when the problem is needed to stablish any convention for ContributeBC implementations
246 
247 // REAL v2[2];
248 // v2[0] = bc.Val2()(0,0);
249 // v2[1] = bc.Val2()(1,0);
250  int nstate = NStateVariables();
251 
252  TPZFMatrix<STATE> &v1 = bc.Val1();
253 
254 
255  switch (bc.Type()) {
256  case 1 : // Neumann condition
257  {
258  for(in = 0 ; in < phr; in++) {
259  for (int il = 0; il<NumLoadCases(); il++)
260  {
261  REAL v2[2];
262  v2[0] = val2[0];
263  v2[1] = val2[0];
264  ef(2*in,il) += BIGNUMBER * v2[0] * phi(in,0) * weight; // forced v2 displacement
265  ef(2*in+1,il) += BIGNUMBER * v2[1] * phi(in,0) * weight; // forced v2 displacement
266  }
267  for (jn = 0 ; jn < phi.Rows(); jn++)
268  {
269  ek(2*in,2*jn) += BIGNUMBER * phi(in,0) *phi(jn,0) * weight;
270  ek(2*in+1,2*jn+1) += BIGNUMBER * phi(in,0) *phi(jn,0) * weight;
271  }
272  }
273  }
274  break;
275 
276  case 0 : // Dirichlet condition
277  {
278  for (in = 0; in < phr; in++)
279  {
280  for (int il = 0; il <fNumLoadCases; il++)
281  {
282  ef(2*in,il) += -val2[0] * phi(in,0) * weight; // force in x direction
283  ef(2*in+1,il) += -val2[1] * phi(in,0) * weight; // force in y direction
284  }
285  }
286  }
287  break;
288 
289  case 2 : // Mixed Condition
290  {
291  DebugStop();
292  for(in = 0 ; in < phi.Rows(); in++)
293  {
294  for (int il = 0; il <fNumLoadCases; il++)
295  {
296  TPZFNMatrix<2,STATE> v2 = bc.Val2(il);
297  ef(2*in,il) += v2(0,0) * phi(in,0) * weight; // force in x direction
298  ef(2*in+1,il) += v2(1,0) * phi(in,0) * weight; // forced in y direction
299  }
300 #ifdef PZDEBUG
301  if(bc.Val1()(0,1) != 0. || bc.Val1()(1,0) != 0.) DebugStop();
302 #endif
303  for (jn = 0 ; jn < phi.Rows(); jn++) {
304  ek(2*in,2*jn) += 1./bc.Val1()(0,0) * phi(in,0) * phi(jn,0) * weight; // peso de contorno => integral de contorno
305  ek(2*in+1,2*jn) += bc.Val1()(1,0) * phi(in,0) * phi(jn,0) * weight;
306  ek(2*in+1,2*jn+1) += 1./bc.Val1()(1,1) * phi(in,0) * phi(jn,0) * weight;
307  ek(2*in,2*jn+1) += bc.Val1()(0,1) * phi(in,0) * phi(jn,0) * weight;
308  }
309  } // este caso pode reproduzir o caso 0 quando o deslocamento
310 
311  break;
312 
313  }
314  }
315 }
316 
317 //void TPZElasticity2DHybrid::ContributeBC(TPZVec<TPZMaterialData> &datavec, REAL weight, TPZFMatrix<STATE> &ek,
318 // TPZFMatrix<STATE> &ef, TPZBndCond &bc){
319 // bc.Contribute(datavec[0],weight,ek,ef);
320 // ContributeBC(datavec[0],weight,ek,ef,bc);
321 //}
322 
325 {
326 }
327 
328 
330  return Hash("TPZElasticity2DHybrid") ^ TPZElasticityMaterial::ClassId() << 1;
331 }
332 
334 
335 void TPZElasticity2DHybrid::Read(TPZStream &buf, void *context)
336 {
337  TPZElasticityMaterial::Read(buf,context);
338 
339 }
340 
341 void TPZElasticity2DHybrid::Write(TPZStream &buf, int withclassid) const
342 {
343  TPZElasticityMaterial::Write(buf,withclassid);
344 
345 }
346 
void Read(TPZStream &buf, void *context) override
Reads the element data from a stream.
virtual void Execute(const TPZVec< REAL > &x, TPZVec< TVar > &f, TPZFMatrix< TVar > &df)
Performs function computation.
Definition: pzfunction.h:38
int fPlaneStress
Uses plain stress.
Definition: pzelasmat.h:270
STATE GetMU(REAL E, REAL nu) const
Definition: pzelasmat.h:186
int fNumLoadCases
Defines the number of load cases generated by this material.
Definition: TPZMaterial.h:76
TPZElasticity2DHybrid()
Default constructor.
Contains definitions to LOGPZ_DEBUG, LOGPZ_INFO, LOGPZ_WARN, LOGPZ_ERROR and LOGPZ_FATAL, and the implementation of the inline InitializePZLOG(string) function using log4cxx library or not. It must to be called out of "#ifdef LOG4CXX" scope.
TPZManVector< REAL, 3 > x
value of the coordinate at the integration point
REAL fPreStressYY
Pre Stress Tensor - Sigma YY.
Definition: pzelasmat.h:261
clarg::argBool bc("-bc", "binary checkpoints", false)
int Type()
Definition: pzbndcond.h:249
Defines PZError.
REAL fPreStressXY
Pre Stress Tensor - Sigma XY.
Definition: pzelasmat.h:264
MShapeFunctionType fShapeType
This class implements a simple vector storage scheme for a templated class T. Utility.
Definition: pzgeopoint.h:19
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)
void Write(TPZStream &buf, int withclassid) const override
Saves the element data to a stream.
Contains declaration of TPZElementMatrix struct which associates an element matrix with the coeficien...
Contains the TPZBndCond class which implements a boundary condition for TPZMaterial objects...
void ContributeVecShapeBC(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc)
Definition: pzelasmat.cpp:700
TPZAutoPointer< TPZFunction< STATE > > & ForcingFunction()
Returns a procedure as source function for the material.
Definition: TPZMaterial.h:397
int ClassId() const override
Returns the solution associated with the var index based on the finite element approximation.
virtual int ClassId() const override
Unique identifier for serialization purposes.
Definition: pzelasmat.cpp:1253
virtual void Read(TPZStream &buf, void *context) override
Reads the element data from a stream.
Definition: pzelasmat.cpp:1261
virtual void ContributeBC(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
Applies the element boundary conditions.
Contains TPZMatrixclass which implements full matrix (using column major representation).
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
Contains the TPZElasticityMaterial class which implements a two dimensional elastic material in plane...
This class defines the boundary condition for TPZMaterial objects.
Definition: pzbndcond.h:29
virtual ~TPZElasticity2DHybrid()
Default destructor.
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
TPZAutoPointer< TPZFunction< STATE > > fElasticity
Definition: pzelasmat.h:246
string res
Definition: test.py:151
TPZFMatrix< STATE > & Val1()
Definition: pzbndcond.h:253
REAL E()
Returns the elasticity modulus E.
Definition: pzelasmat.h:220
TPZManVector< STATE, 3 > ff
Forcing vector.
Definition: pzelasmat.h:249
virtual int HasForcingFunction()
Directive that gives true if the material has a forcing function.
Definition: TPZMaterial.h:472
virtual void Contribute(TPZVec< TPZMaterialData > &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override
Calculates the element stiffness matrix - simulate compaction as aditional variable.
virtual void Write(TPZStream &buf, int withclassid) const override
Saves the element data to a stream.
Definition: pzelasmat.cpp:1277
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
Contains TPZMatrix<TVar>class, root matrix class.
STATE GetLambda(REAL E, REAL nu) const
Definition: pzelasmat.h:180
TPZAutoPointer< TPZFunction< STATE > > fForcingFunction
Pointer to forcing function, it is the right member at differential equation.
Definition: TPZMaterial.h:47
This class implements a two dimensional elastic material in plane stress or strain.
Definition: pzelasmat.h:19
int NumLoadCases()
returns the number of load cases for this material object
Definition: TPZMaterial.h:186
int Dimension() const override
Returns the model dimension.
Definition: pzelasmat.h:81
int64_t Cols() const
Returns number of cols.
Definition: pzmatrix.h:809
This class implements a two dimensional elastic material in plane stress or strain.
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
REAL fPreStressXX
Pre Stress Tensor - Sigma XX.
Definition: pzelasmat.h:258
REAL fnu_def
Poison coeficient.
Definition: pzelasmat.h:243
REAL fE_def
Elasticity modulus.
Definition: pzelasmat.h:240
Implements an interface to register a class id and a restore function. Persistence.
Definition: TPZSavable.h:150
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
Definition: pzfmatrix.h:716
virtual int NStateVariables() const override
Returns the number of state variables associated with the material.
Definition: pzelasmat.cpp:88
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15