NeoPZ
tpzmultcamada.cpp
Go to the documentation of this file.
1 
6 #include "tpzmultcamada.h"
7 #include "pzmatplaca2.h"
8 
10 
11  if(var == 2) {
12  Solout.Resize(3);
13  Solout[0] = Sol[0];
14  Solout[1] = Sol[1];
15  Solout[2] = Sol[2];
16  return;
17  }
18  if(var == 4) {
19  Solout.Resize(1);
20  Solout[0] = Sol[2];
21  return;
22  }
23  int i, j, idf;
24  if (var >= 50 && var <= 57) {
25  TPZVec < STATE > SoloutAcc(3, 0.);
26  REAL Ma[3];
27  REAL aut1,aut2;
28  Solout.Resize(3);
29  for (j = 0; j < 3; j++) Ma[j] = 0.;
30  TPZMaterialData data;
31  data.sol[0] = Sol;
32  data.dsol[0] = DSol;
33  data.axes = axes;
34  for (i = 0; i < fCamadas.NElements(); i++) {
35  if(var < 54) fCamadas[i]->Solution(data, 50, SoloutAcc);
36  else fCamadas[i]->Solution(data, 54, SoloutAcc);
37  for (j = 0; j < 3; j++) {
38  Ma[j] += SoloutAcc[j];
39  SoloutAcc[j] = 0.;
40  }
41  }
42  REAL sqrtval = sqrt((Ma[0]-Ma[1])*(Ma[0]-Ma[1])+Ma[2]*Ma[2]*4);
43  REAL vec1[2],vec2[2],vecnorm1,vecnorm2;
44  aut1 = (Ma[0]+Ma[1]-sqrtval)*0.5;
45  aut2 = (Ma[0]+Ma[1]+sqrtval)*0.5;
46  vec1[0] = Ma[0]-Ma[1]-sqrtval;
47  vec1[1] = 2*Ma[2];
48  vecnorm1 = sqrt(vec1[0]*vec1[0]+vec1[1]*vec1[1]);
49  if(vecnorm1 >= 1.e-8) {
50  vec1[0] /= vecnorm1;
51  vec1[1] /= vecnorm1;
52  } else {
53  vec1[0] = 0.;
54  vec1[1] = 1.;
55  }
56  vec2[0] = Ma[0]-Ma[1]+sqrtval;
57  vec2[1] = 2.*Ma[2];
58  vecnorm2 = sqrt(vec2[0]*vec2[0]+vec2[1]*vec2[1]);
59  if(vecnorm2 >= 1.e-8) {
60  vec2[0] /= vecnorm2;
61  vec2[1] /= vecnorm2;
62  } else {
63  vec2[0] = 0.;
64  vec2[1] = 1.;
65  }
66 
67  // E preciso calcular os valores principais que encontram=se em SoloutLocal e orientar pelos vetores axes
68  if(var == 50 || var == 54) {
69  Solout.Resize(3);
70  for(idf=0; idf<3; idf++) Solout[idf] = vec1[0] * axes(0,idf) + vec1[1]*axes(1,idf);
71  return;
72  }
73  if(var == 51 || var ==55) {
74  Solout.Resize(3);
75  for(idf=0; idf<3; idf++) Solout[idf] = vec2[0] * axes(0,idf) + vec2[1]*axes(1,idf);
76  return;
77  }
78 
79  if(var == 52 || var == 53 || var == 56 || var == 57) {
80  Solout.Resize(1);
81  Solout[0] = (var == 52 || var == 56) ? aut1 : aut2;
82  return;
83  }
84 
85  }
86  TPZMaterial::Solution(Sol,DSol,axes,var,Solout);
87 }
88 
90  REAL weight,
92  TPZFMatrix<STATE> &ef) {
93 
94  int i;
95  for (i = 0; i < fCamadas.NElements(); i++)
96  fCamadas[i]->Contribute(data,weight,ek,ef);
97 }
98 
100  REAL weight,
101  TPZFMatrix<STATE> &ek,
102  TPZFMatrix<STATE> &ef,
103  TPZBndCond &bc){
104  if(fCamadas.NElements()) fCamadas[0]->ContributeBC(data,weight,ek,ef,bc);
105 }
106 
107 int TPZMultCamada::VariableIndex(const std::string &name) {
108  if(!strcmp(name.c_str(),"Displacement")) return 2;
109  if(!strcmp(name.c_str(),"Deslocz")) return 4;
110  if(!strcmp(name.c_str(),"M1Vec")) return 50;// Momento na direcao do primeiro eixo principal
111  if(!strcmp(name.c_str(),"M2Vec")) return 51;// Momento na direcao do segundo eixo principal
112  if(!strcmp(name.c_str(),"M1Scal")) return 52;// Valor do primeiro momento principal
113  if(!strcmp(name.c_str(),"M2Scal")) return 53;// Valor do segundo momento principal
114  if(!strcmp(name.c_str(),"N1Vec")) return 54;// Momento na direcao do primeiro eixo principal
115  if(!strcmp(name.c_str(),"N2Vec")) return 55;// Momento na direcao do segundo eixo principal
116  if(!strcmp(name.c_str(),"N1Scal")) return 56;// Valor do primeiro momento principal
117  if(!strcmp(name.c_str(),"N2Scal")) return 57;// Valor do segundo momento principal
118 
119  return TPZMaterial::VariableIndex(name);
120 }
121 
123  if(var == 2) return 3;
124  if(var == 4) return 1;
125  if(var == 50 || var == 51 || var == 54 || var == 55) return 3;
126  if(var == 52 || var == 53 || var == 56 || var == 57) return 1;
128 }
129 
131  if(fCamadas.NElements()) return fCamadas[0]->NStateVariables();
132  return 0;
133 }
134 
135 
137  return Hash("TPZMultCamada") ^ TPZMaterial::ClassId() << 1;
138 }
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 Solution(TPZVec< STATE > &Sol, TPZFMatrix< STATE > &DSol, TPZFMatrix< REAL > &axes, int var, TPZVec< STATE > &Solout) override
Returns the solution associated with the var index based on the finite element approximation.
TPZStack< TPZMatPlaca2 *> fCamadas
Vector of layers.
Definition: tpzmultcamada.h:90
clarg::argBool bc("-bc", "binary checkpoints", false)
virtual void Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override
Computes contribution to the stiffness matrix and right hand side at an integration point...
virtual int VariableIndex(const std::string &name)
Returns the variable index associated with the name.
TPZGradSolVec dsol
vector of the derivatives of the solution at the integration point
Contains the TPZMatPlaca2 class.
virtual int NSolutionVariables(int var) override
Returns the number of variables associated with the variable indexed by var.
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 int VariableIndex(const std::string &name) override
Returns the variable index associated with the name.
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...
This class defines the boundary condition for TPZMaterial objects.
Definition: pzbndcond.h:29
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 ClassId() const override
Define the class id associated with the class.
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
int ClassId() const override
Unique identifier for serialization purposes.
static int idf[6]
Contains the TPZMultCamada class.
virtual int NSolutionVariables(int var)
Returns the number of variables associated with the variable indexed by var.
virtual int NStateVariables() const override
Returns the number of state variables associated with the material.
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
TPZSolVec sol
vector of the solutions at the integration point