NeoPZ
TPZSBFemElementGroup.h
Go to the documentation of this file.
1 //
2 // TPZSBFemElementGroup.hpp
3 // PZ
4 //
5 // Created by Philippe Devloo on 4/4/16.
6 //
7 //
8 
9 #ifndef TPZSBFemElementGroup_hpp
10 #define TPZSBFemElementGroup_hpp
11 
12 #include <stdio.h>
13 
14 #include "pzelementgroup.h"
15 #include "TPZSBFemVolume.h"
16 
17 
19 {
20 
21 public:
23 
24 private:
25 
28 
31 
34 
37 
39 
41 
43  REAL fMassDensity = 1.;
44 
46  REAL fDelt = 1.;
47 
50 
51 public:
52 
54  {
55 
56  }
57 
59  TPZSBFemElementGroup(TPZCompMesh &mesh, int64_t &index) : TPZElementGroup(mesh,index)
60  {
61 
62  }
63 
66  virtual void AddElement(TPZCompEl *cel);
67 
68 
72 
78  virtual void CalcStiff(TPZElementMatrix &ek,TPZElementMatrix &ef);
79 
81  void SetDensity(REAL density)
82  {
83  fMassDensity = density;
84  }
87  {
88  if(fMassMatrix.Rows() == 0)
89  {
90  DebugStop();
91  }
92  fComputationMode = EOnlyMass;
93  }
94 
96  void SetComputeTimeDependent(REAL delt)
97  {
98  fDelt = delt;
99  fComputationMode = EMass;
100  }
101 
103  {
104  fComputationMode = EStiff;
105  }
110  virtual void Print(std::ostream &out = std::cout) const
111  {
112  out << __PRETTY_FUNCTION__ << std::endl;
114  int nel = fElGroup.size();
115  out << "Element indexes of the volume elements ";
116  for (int el=0; el<nel; el++) {
117  out << fElGroup[el]->Index() << " ";
118  }
119  out << std::endl;
120  out << "Indices of the associated computational skeleton elements\n";
121  for (int el=0; el<nel; el++) {
122  TPZCompEl *cel = fElGroup[el];
123  TPZSBFemVolume *vol = dynamic_cast<TPZSBFemVolume *>(cel);
124  if(!vol) DebugStop();
125  out << vol->SkeletonIndex() << " ";
126  }
127  out << std::endl;
128  out << "Connect indexes of the contained elements\n";
129  for (int el=0; el<nel; el++) {
130  TPZCompEl *cel = fElGroup[el];
131  int nc = cel->NConnects();
132  for (int ic=0; ic<nc; ic++) {
133  out << cel->ConnectIndex(ic) << " ";
134  }
135  out << std::endl;
136  }
137 
138 /*
139  out << "EigenVectors for displacement\n";
140  fPhi.Print("Phi = ",out,EMathematicaInput);
141  out << "Inverse EigenVectors\n";
142  fPhiInverse.Print("PhiInv = ",out,EMathematicaInput);
143  out << "EigenValues " << fEigenvalues << std::endl;
144  out << "Mass Matrix\n";
145  fMassMatrix.Print("Mass = ",out);
146  out << "Solution Coeficients\n";
147  fCoef.Print("Coef ",out);
148  for (int el=0; el<nel; el++) {
149  fElGroup[el]->Print(out);
150  }
151  */
152  out << "End of " << __PRETTY_FUNCTION__ << std::endl;
153  }
154 
155 
156 
161  virtual void CalcResidual(TPZElementMatrix &ef)
162  {
164  CalcStiff(ek,ef);
165  }
166 
167 
173  virtual void LoadSolution();
174 
176  virtual void LoadElementReference()
177  {
178  for (int64_t i = 0; i < fElGroup.size(); i++) {
179  fElGroup[i]->LoadElementReference();
180  }
181  }
182 
183 
184 
185  int64_t NumEigenValues()
186  {
187  return fEigenvalues.size();
188  }
189 
191  void LoadEigenVector(int64_t eig);
194 
196  {
197  int nel = fCoef.Rows();
198  TPZVec<STATE> result(nel,0.);
199  for (int ir=0; ir<nel; ir++) {
200  result[ir] = fCoef(ir,0).real();
201  }
202  return result;
203  }
204 
206  {
207  return fEigenvalues;
208  }
209 
211  {
212  return fPhi;
213  }
214 
216  {
217  return fPhiInverse;
218  }
219 
221  {
222  return fMassMatrix;
223  }
224 
226  {
227  return fCoef;
228  }
229 
231  {
232  int64_t rows = fPhi.Rows(),cols = fPhi.Cols();
233  TPZFMatrix<double> phireal(rows,cols);
234  for(int64_t i=0; i<rows; i++)
235  {
236  for(int64_t j=0; j<cols; j++)
237  {
238  phireal(i,j) = fPhi(i,j).real();
239  }
240  }
241  return phireal;
242  }
243 
245  {
246  int64_t nel = fEigenvalues.NElements();
247  TPZManVector<double> eig(nel);
248  for(int64_t el=0; el<nel; el++)
249  {
250  eig[el] = fEigenvalues[el].real();
251  }
252  return eig;
253  }
254 
256  {
257  int64_t rows = fCoef.Rows(),cols = fCoef.Cols();
258  TPZFMatrix<double> coefreal(rows,cols);
259  for(int64_t i=0; i<rows; i++)
260  {
261  for(int64_t j=0; j<cols; j++)
262  {
263  coefreal(i,j) = fCoef(i,j).real();
264  }
265  }
266  return coefreal;
267  }
268 
269 };
270 
271 #endif /* TPZSBFemElementGroup_hpp */
TPZFMatrix< std::complex< double > > fPhi
Matrix of eigenvectors which compose the stiffness matrix.
TPZFMatrix< double > CoeficientsReal()
virtual void LoadSolution()
Loads the solution within the internal data structure of the element.
TPZFMatrix< std::complex< double > > fCoef
Multiplying coefficients of each eigenvector.
TPZFMatrix< double > PhiReal()
Implements a vector class which allows to use external storage provided by the user. Utility.
Definition: pzquad.h:16
TPZStack< TPZCompEl *, 5 > fElGroup
TPZFMatrix< STATE > & MassMatrix()
Contains the declaration of the TPZElementGroup class, which implements an computational element whic...
int64_t SkeletonIndex()
EComputationMode fComputationMode
TPZManVector< std::complex< double > > fEigenvalues
Vector of eigenvalues of the SBFem analyis.
TPZFMatrix< std::complex< double > > Coeficients()
REAL fDelt
timestep coeficient
Class which groups elements to characterize dense matrices.
virtual void LoadElementReference()
Loads the geometric element referece.
TPZFMatrix< std::complex< double > > fPhiInverse
Inverse of the eigenvector matrix (transfers eigenvector coeficients to side shape coeficients) ...
TPZFMatrix< std::complex< double > > & PhiInverse()
void ComputeMatrices(TPZElementMatrix &E0, TPZElementMatrix &E1, TPZElementMatrix &E2, TPZElementMatrix &M0)
Computes the element stifness matrix and right hand side.
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
virtual void Print(std::ostream &out=std::cout) const
Prints element data.
void ComputeMassMatrix(TPZElementMatrix &M0)
Compute the mass matrix based on the value of M0 and the eigenvectors.
virtual void Print(std::ostream &out=std::cout) const override
Prints element data.
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
void SetDensity(REAL density)
set the density or specific heat of the material
TPZCompMesh * Mesh() const
Return a pointer to the grid of the element.
Definition: pzcompel.cpp:288
TPZFMatrix< std::complex< double > > & Phi()
void LoadEigenVector(int64_t eig)
Load the coeficients such that we visualize an eigenvector.
virtual void AddElement(TPZCompEl *cel)
add an element to the element group
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
Full matrix class. Matrix.
Definition: pzfmatrix.h:32
TPZVec< std::complex< double > > & EigenValues()
virtual int64_t ConnectIndex(int i) const =0
Returns the index of the ith connectivity of the element.
This class associates an element matrix with the coeficients of its contribution in the global stiffn...
Definition: pzelmat.h:30
virtual int NConnects() const =0
Returns the number of nodes of the element.
TPZManVector< double > EigenvaluesReal()
REAL fMassDensity
multiplier to multiply the mass matrix
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
virtual void CalcStiff(TPZElementMatrix &ek, TPZElementMatrix &ef)
Computes the element stifness matrix and right hand side.
TPZVec< STATE > MultiplyingCoeficients()
int64_t Cols() const
Returns number of cols.
Definition: pzmatrix.h:809
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
TPZSBFemElementGroup(TPZCompMesh &mesh, int64_t &index)
constructor
void SetComputeOnlyMassMatrix()
Set the element to compute the mass matrix.
TPZFMatrix< STATE > fMassMatrix
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
virtual void CalcResidual(TPZElementMatrix &ef)
Computes the element right hand side.
void SetComputeTimeDependent(REAL delt)
Set the element to compute stiffness plus mass.