NeoPZ
TPZSBFemVolume.h
Go to the documentation of this file.
1 //
2 // TPZSBFemVolume.hpp
3 // PZ
4 //
5 // Created by Philippe Devloo on 4/4/16.
6 //
7 //
8 
9 #ifndef TPZSBFemVolume_hpp
10 #define TPZSBFemVolume_hpp
11 
12 #include <stdio.h>
13 #include "pzcompel.h"
14 #include "pzelmat.h"
15 #include "pzinterpolationspace.h"
16 
18 {
19 
21  int64_t fElementGroupIndex = -1;
22 
25 
27  int64_t fSkeleton = -1;
28 
31 
34 
37 
40 
43 
46 
48  REAL fDensity = 1.;
49 
51  void AdjustAxes3D(const TPZFMatrix<REAL> &axes2D, TPZFMatrix<REAL> &axes3D, TPZFMatrix<REAL> &jac3D, TPZFMatrix<REAL> &jacinv3D, REAL detjac);
52 public:
53 
54  TPZSBFemVolume(TPZCompMesh &mesh, TPZGeoEl *gel, int64_t &index);
55 
56  virtual ~TPZSBFemVolume()
57  {
59  }
60 
63 
65  void SetSkeleton(int64_t skeleton);
66 
67  int64_t SkeletonIndex()
68  {
69  return fSkeleton;
70  }
71 
76  virtual void InitMaterialData(TPZMaterialData &data);
77 
79  void SetElementGroupIndex(int64_t index);
80 
82  virtual TPZCompEl *Clone(TPZCompMesh &mesh) const
83  {
84  // till I remember how this works
85  DebugStop();
86  return 0;
87  }
88 
89  int64_t ElementGroupIndex() const
90  {
91  return fElementGroupIndex;
92  }
105  std::map<int64_t,int64_t> & gl2lcConMap,
106  std::map<int64_t,int64_t> & gl2lcElMap) const
107  {
108  // till I remember how this works
109  DebugStop();
110  return 0;
111  }
112 
114  virtual int NConnects() const
115  {
116  if (fElementGroup == 0) {
117  return 0;
118  }
119  return fElementGroup->NConnects();
120  }
121 
126  virtual int64_t ConnectIndex(int i) const
127  {
128  if (fElementGroup == 0) {
129  DebugStop();
130  }
131  return fElementGroup->ConnectIndex(i);
132  }
134  virtual int Dimension() const
135  {
136  TPZGeoEl *reference = Reference();
137  return reference->Dimension();
138  }
139 
141  REAL Density()
142  {
143  return fDensity;
144  }
145 
147  void SetDensity(REAL density)
148  {
149 #ifdef PZDEBUG
150  if(density <= 0.) DebugStop();
151 #endif
152  fDensity = density;
153  }
154 
156  virtual void BuildCornerConnectList(std::set<int64_t> &connectindexes) const;
157 
163  virtual void SetConnectIndex(int inode, int64_t index)
164  {
165  DebugStop();
166  }
168  virtual int NSideConnects(int iside) const
169  {
170  DebugStop();
171  return 0;
172  }
173 
179  virtual int SideConnectLocId(int icon,int is) const
180  {
181  DebugStop();
182  return 0;
183  }
184 
186  virtual int NShapeF() const
187  {
188  int nc = NConnects();
189  int nshape = 0;
190  for (int ic=0; ic<nc; ic++) {
191  TPZConnect &c = Connect(ic);
192  nshape += c.NShape();
193  }
194  return nshape;
195  }
196 
198  virtual int NConnectShapeF(int icon, int order) const
199  {
200  TPZConnect &c = Connect(icon);
201  return c.NShape();
202  }
203 
205  {
206  if (fIntRule) {
207  DebugStop();
208  }
209  int nsides = Reference()->NSides();
210  fIntRule = Reference()->CreateSideIntegrationRule(nsides-1, 1);
211  }
212 
213  virtual void SetIntegrationRule(int order);
214 
216  virtual const TPZIntPoints &GetIntegrationRule() const
217  {
218  if(!fIntRule) DebugStop();
219 
220  return *fIntRule;
221  }
222 
225  {
226  if(!fIntRule) InitializeIntegrationRule();
227  return *fIntRule;
228  }
229 
235  virtual void PRefine ( int order );
236 
238  virtual void SetPreferredOrder ( int order );
239 
240 
241 
243  void SetPhiEigVal(TPZFMatrix<std::complex<double> > &phi, TPZManVector<std::complex<double> > &eigval);
244 
246  {
247  return fPhi;
248  }
249 
251  {
252  return fEigenvalues;
253  }
254 
256  {
257  return fCoeficients;
258  }
259 
261  {
262  int64_t rows = fPhi.Rows(),cols = fPhi.Cols();
263  TPZFMatrix<double> phireal(rows,cols);
264  for(int64_t i=0; i<rows; i++)
265  {
266  for(int64_t j=0; j<cols; j++)
267  {
268  phireal(i,j) = fPhi(i,j).real();
269  }
270  }
271  return phireal;
272  }
273 
275  {
276  int64_t nel = fEigenvalues.NElements();
277  TPZManVector<double> eig(nel);
278  for(int64_t el=0; el<nel; el++)
279  {
280  eig[el] = fEigenvalues[el].real();
281  }
282  return eig;
283  }
284 
286  {
287  int64_t rows = fCoeficients.Rows(),cols = fCoeficients.Cols();
288  TPZFMatrix<double> coefreal(rows,cols);
289  for(int64_t i=0; i<rows; i++)
290  {
291  for(int64_t j=0; j<cols; j++)
292  {
293  coefreal(i,j) = fCoeficients(i,j).real();
294  }
295  }
296  return coefreal;
297  }
298 
304  virtual void LoadCoef(TPZFMatrix<std::complex<double> > &coef);
305 
313  virtual void ComputeSolution(TPZVec<REAL> &qsi,
314  TPZSolVec &sol, TPZGradSolVec &dsol,TPZFMatrix<REAL> &axes);
315 
316  void EvaluateError(std::function<void(const TPZVec<REAL> &loc,TPZVec<STATE> &val,TPZFMatrix<STATE> &deriv)> fp,
317  TPZVec<REAL> &errors,bool store_error);
318 
329  virtual void Shape(TPZVec<REAL> &qsi,TPZFMatrix<REAL> &phi,TPZFMatrix<REAL> &dphidxi);
330 
332  virtual void ComputeShape(TPZVec<REAL> &intpoint, TPZVec<REAL> &X, TPZFMatrix<REAL> &jacobian, TPZFMatrix<REAL> &axes,
333  REAL &detjac, TPZFMatrix<REAL> &jacinv, TPZFMatrix<REAL> &phi, TPZFMatrix<REAL> &dphi, TPZFMatrix<REAL> &dphidx);
334 
335 
338  virtual void ComputeSolution(TPZVec<REAL> &qsi, TPZMaterialData &data) {
339  ComputeSolution(qsi, data.sol, data.dsol, data.axes);
340  }
341 
350  virtual void Solution(TPZVec<REAL> &qsi,int var,TPZVec<STATE> &sol);
351 
352 
357  virtual void Print(std::ostream &out = std::cout) const
358  {
359  out << "Printing " << __PRETTY_FUNCTION__ << std::endl;
360  TPZCompEl::Print(out);
361  out << "Group Element Index " << fElementGroupIndex << std::endl;
362  out << "Skeleton Element Index " << fSkeleton << std::endl;
363  out << "Local Indices " << fLocalIndices << std::endl;
364  fCoeficients.Print("Coef =",out,EMathematicaInput);
365  fPhi.Print("Phi = ",out,EMathematicaInput);
366  if (fCoeficients.Rows())
367  {
368  TPZManVector<std::complex<double>,5> prod(fPhi.Rows(),0.);
369  for (int i=0; i<fPhi.Rows(); i++) {
370  for (int j=0; j<fPhi.Cols(); j++) {
371  prod[i] += fPhi.GetVal(i,j)*fCoeficients.GetVal(j,0);
372  }
373  }
374  out << "Values at border " << prod << std::endl;
375  }
376  for (int i=0; i<NConnects(); i++) {
377  Connect(i).Print(*Mesh(),out);
378  }
379  }
380 
382 
383 };
384 
385 
386 TPZCompEl * CreateSBFemCompEl(TPZGeoEl *gel,TPZCompMesh &mesh,int64_t &index);
387 
388 
389 
390 #endif /* TPZSBFemVolume_hpp */
TPZManVector< std::complex< double > > Eigenvalues()
int64_t fElementGroupIndex
index of element group
Represents a graphical mesh used for post processing purposes. Post processing.
Definition: pzgraphmesh.h:34
virtual int NSideConnects(int iside) const
Returns the number of dof nodes along side iside.
virtual void ComputeSolution(TPZVec< REAL > &qsi, TPZMaterialData &data)
Compute the solution at the integration point and store in the data structure.
Represents a set of shape functions associated with a computational element/side. Computational Eleme...
Definition: pzconnect.h:30
virtual void Shape(TPZVec< REAL > &qsi, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphidxi)
Computes the shape function set at the point x.
Implements a vector class which allows to use external storage provided by the user. Utility.
Definition: pzquad.h:16
virtual void ComputeShape(TPZVec< REAL > &intpoint, TPZVec< REAL > &X, TPZFMatrix< REAL > &jacobian, TPZFMatrix< REAL > &axes, REAL &detjac, TPZFMatrix< REAL > &jacinv, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphi, TPZFMatrix< REAL > &dphidx)
Compute shape functions based on master element in the classical FEM manner.
void CreateGraphicalElement(TPZGraphMesh &, int)
Creates corresponding graphical element(s) if the dimension matches graphical elements are used to ge...
void ExtendShapeFunctions(TPZMaterialData &data1d, TPZMaterialData &data2d)
extend the border shape functions for SBFem computations
TPZManVector< double > EigenvaluesReal()
TPZFMatrix< double > PhiReal()
TPZFNMatrix< 30, std::complex< double > > fPhi
Section of the phi vector associated with this volume element.
TPZFMatrix< double > CoeficientsReal()
int64_t fSkeleton
index of the skeleton element
virtual int NConnects() const
Returns the number of nodes of the element.
Contains declaration of TPZCompEl class which defines the interface of a computational element...
virtual int NShapeF() const
It returns the shapes number of the element.
TPZCompEl * CreateSBFemCompEl(TPZGeoEl *gel, TPZCompMesh &mesh, int64_t &index)
int64_t SkeletonIndex()
TPZFMatrix< std::complex< double > > Phi()
void SetPhiEigVal(TPZFMatrix< std::complex< double > > &phi, TPZManVector< std::complex< double > > &eigval)
initialize the data structures of the eigenvectors and eigenvalues associated with this volume elemen...
Contains declaration of TPZInterpolationSpace class which implements the interface for interpolated c...
TPZManVector< std::complex< double > > fEigenvalues
Eigenvlues associated with the internal shape functions.
TPZGradSolVec dsol
vector of the derivatives of the solution at the integration point
virtual int SideConnectLocId(int icon, int is) const
Returns the local node number of icon along is.
virtual void Print(std::ostream &out=std::cout) const
Prints element data.
REAL val(STATE &number)
Returns value of the variable.
Definition: pzartdiff.h:23
virtual TPZCompEl * Clone(TPZCompMesh &mesh) const
Method for creating a copy of the element.
virtual int NSides() const =0
Returns the number of connectivities of the element.
virtual void InitMaterialData(TPZMaterialData &data)
Initialize a material data and its attributes based on element dimension, number of state variables a...
virtual const TPZIntPoints & GetIntegrationRule() const
Returns a reference to an integration rule suitable for integrating the interior of the element...
TPZCompEl * fElementGroup
pointer to the element group computational element
Abstract class defining integration rules. Numerical Integration.
Definition: tpzintpoints.h:19
virtual void SetPreferredOrder(int order)
Defines the desired order for entire element.
Contains declaration of TPZElementMatrix struct which associates an element matrix with the coeficien...
virtual TPZIntPoints * CreateSideIntegrationRule(int side, int order)=0
Creates an integration rule for the topology of the corresponding side and able to integrate a polyno...
void SetDensity(REAL density)
assign a different density
virtual void BuildCornerConnectList(std::set< int64_t > &connectindexes) const
adds the connect indexes associated with base shape functions to the set
virtual int NConnectShapeF(int icon, int order) const
Returns the number of shapefunctions associated with a connect.
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
virtual ~TPZSBFemVolume()
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
virtual void LoadCoef(TPZFMatrix< std::complex< double > > &coef)
Loads the solution within the internal data structure of the element.
TPZCompMesh * Mesh() const
Return a pointer to the grid of the element.
Definition: pzcompel.cpp:288
virtual void Solution(TPZVec< REAL > &qsi, int var, TPZVec< STATE > &sol)
Calculates the solution - sol - for the variable var at point qsi, where qsi is expressed in terms of...
unsigned int NShape() const
Definition: pzconnect.h:151
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
void AdjustAxes3D(const TPZFMatrix< REAL > &axes2D, TPZFMatrix< REAL > &axes3D, TPZFMatrix< REAL > &jac3D, TPZFMatrix< REAL > &jacinv3D, REAL detjac)
adjust the axes and jacobian of the 3D element
TPZFNMatrix< 9, REAL > axes
axes indicating the directions of the derivatives of the shapefunctions
virtual void PRefine(int order)
Change the preferred order for the element and proceed the adjust of the aproximation space taking ...
TPZFMatrix< std::complex< double > > Coeficients()
REAL Density()
return the density associated with the element
virtual TPZConnect & Connect(int i) const
Returns a pointer to the ith node.
Definition: pzcompel.cpp:298
virtual TPZIntPoints & GetIntegrationRule()
Returns a reference to an integration rule suitable for integrating the interior of the element...
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
Implements the interfaces for TPZCompElDisc, TPZInterfaceElement and TPZInterpolatedElement. Computational element.
virtual int NConnects() const =0
Returns the number of nodes of the element.
virtual void SetIntegrationRule(int order)
virtual int Dimension() const
Dimension of the element.
int64_t ElementGroupIndex() const
virtual int Dimension() const =0
Returns the dimension of the element.
void SetSkeleton(int64_t skeleton)
Data structure initialization.
TPZGeoEl * Reference() const
Return a pointer to the corresponding geometric element if such exists, return 0 otherwise.
Definition: pzcompel.cpp:1137
void ComputeKMatrices(TPZElementMatrix &E0, TPZElementMatrix &E1, TPZElementMatrix &E2, TPZElementMatrix &M0)
Compute the E0, E1 and E2 matrices.
void ResetReference()
Reset the element referenced by the geometric element to NULL.
Definition: pzgeoel.h:431
void EvaluateError(std::function< void(const TPZVec< REAL > &loc, TPZVec< STATE > &val, TPZFMatrix< STATE > &deriv)> fp, TPZVec< REAL > &errors, bool store_error)
Performs an error estimate on the elemen.
TPZFNMatrix< 30, std::complex< double > > fCoeficients
Multiplier coeficients associated with the solution.
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
virtual void SetConnectIndex(int inode, int64_t index)
Set the index i to node inode.
virtual void Print(std::ostream &out=std::cout) const
Prints element data.
Definition: pzcompel.cpp:322
REAL fDensity
Density associated with the mass matrix.
TPZSBFemVolume(TPZCompMesh &mesh, TPZGeoEl *gel, int64_t &index)
int64_t Cols() const
Returns number of cols.
Definition: pzmatrix.h:809
virtual void Print(std::ostream &out) const
Definition: pzmatrix.h:253
virtual TPZCompEl * ClonePatchEl(TPZCompMesh &mesh, std::map< int64_t, int64_t > &gl2lcConMap, std::map< int64_t, int64_t > &gl2lcElMap) const
Method for creating a copy of the element in a patch mesh.
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
void SetElementGroupIndex(int64_t index)
Initialize the data structure indicating the group index.
TPZManVector< int64_t > fLocalIndices
vector of local indices of multipliers in the group
TPZIntPoints * fIntRule
pointer to the integration rule
virtual int64_t ConnectIndex(int i) const
Returns the index of the ith connectivity of the element.
void Print(const TPZCompMesh &mesh, std::ostream &out=std::cout)
Print the information for the connect element.
Definition: pzconnect.cpp:67
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
virtual void ComputeSolution(TPZVec< REAL > &qsi, TPZSolVec &sol, TPZGradSolVec &dsol, TPZFMatrix< REAL > &axes)
Computes solution and its derivatives in the local coordinate qsi.
TPZSolVec sol
vector of the solutions at the integration point
const TVar & GetVal(const int64_t row, const int64_t col) const override
Get values without bounds checking This method is faster than "Get" if DEBUG is defined.
Definition: pzfmatrix.h:566
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
Definition: pzfmatrix.h:716
void InitializeIntegrationRule()