NeoPZ
pzelementgroup.h
Go to the documentation of this file.
1 
6 #ifndef TPZElementGroupH
7 #define TPZElementGroupH
8 
9 #include "pzcompel.h"
10 #include "pzmatred.h"
11 #include "pzmanvector.h"
12 #include "pzelmat.h"
13 #include "TPZOneShapeRestraint.h"
14 
20 class TPZElementGroup : public TPZCompEl
21 {
22 
23 protected:
26  std::map<int64_t,TPZOneShapeRestraint> fRestraints;
27 
28 public:
29 
31 
33  TPZCompEl(mesh,0,index), fElGroup(), fConnectIndexes()
34  {
35 
36  }
37 
39  TPZElementGroup(TPZCompMesh &mesh, const TPZElementGroup &copy);
40 
41  virtual ~TPZElementGroup();
42 
45  virtual void AddElement(TPZCompEl *cel);
46 
51  virtual void Print(std::ostream &out = std::cout) const override
52  {
53  out << __PRETTY_FUNCTION__ << std::endl;
54  TPZCompEl::Print(out);
55  out << "comp and geom indexes :";
56  int nel = fElGroup.size();
57  for (int el=0; el<nel; el++) {
58  int64_t cindex = fElGroup[el]->Index();
59  TPZGeoEl *gel = fElGroup[el]->Reference();
60  int64_t gindex = -1;
61  if(gel) gindex = gel->Index();
62  out << " " << cindex << "|" << gindex;
63 // fElGroup[el]->Print(out);
64  }
65  out << std::endl;
66  out << "End of " << __PRETTY_FUNCTION__ << std::endl;
67  }
68 
70  void Unwrap();
71 
73  virtual int Dimension() const override
74  {
75  int dimension = -1;
76  int nel = fElGroup.size();
77  for (int el = 0; el<nel; el++) {
78  int eldim = fElGroup[el]->Dimension();
79  dimension = dimension < eldim ? eldim : dimension;
80  }
81  return dimension;
82  }
83 
85  bool NeedsComputing(const std::set<int> &matids) override;
86 
87 
89  return fElGroup;
90  }
91 
93  virtual int NConnects() const override
94  {
95  return fConnectIndexes.size();
96  }
97 
99  virtual void BuildCornerConnectList(std::set<int64_t> &connectindexes) const override
100  {
101  int nel = fElGroup.size();
102  for (int el=0; el<nel; el++) {
103  fElGroup[el]->BuildCornerConnectList(connectindexes);
104  }
105  }
106 
107 
112  virtual int64_t ConnectIndex(int i) const override
113  {
114  return fConnectIndexes[i];
115  }
116 
118  virtual TPZCompEl *Clone(TPZCompMesh &mesh) const override
119  {
120  return new TPZElementGroup(mesh,*this);
121  }
122 
128  virtual void SetConnectIndex(int inode, int64_t index) override;
129 
130 
136  virtual void LoadSolution() override
137  {
138  int nel = fElGroup.size();
139  for (int el=0; el<nel; el++) {
140  fElGroup[el]->LoadSolution();
141  }
142  }
143 
144  virtual void LoadElementReference() override
145  {
146  int nel = fElGroup.size();
147  for (int el=0; el<nel; el++) {
148  fElGroup[el]->LoadElementReference();
149  }
150 
151  }
155  TPZVec<STATE> IntegrateSolution(const std::string &varname, const std::set<int> &matids) override
156  {
157  TPZManVector<STATE,3> result;
158  int nel = fElGroup.size();
159  for (int el=0; el<nel; el++) {
160  TPZManVector<STATE,3> locres;
161  locres = fElGroup[el]->IntegrateSolution(varname, matids);
162  if (!result.size()) {
163  result = locres;
164  } else if(result.size() && result.size() == locres.size())
165  {
166  int nvar = result.size();
167  for (int iv = 0; iv<nvar; iv++) {
168  result[iv] += locres[iv];
169  }
170  }
171  else if(result.size() && locres.size() && result.size() != locres.size())
172  {
173  DebugStop();
174  }
175  }
176  return result;
177  }
178 
182  virtual TPZVec<STATE> IntegrateSolution(int var) const override
183  {
184  TPZManVector<STATE,3> result;
185  int nel = fElGroup.size();
186  for (int el=0; el<nel; el++) {
187  TPZManVector<STATE,3> locres;
188  locres = fElGroup[el]->IntegrateSolution(var);
189  if (!result.size()) {
190  result = locres;
191  } else if(result.size() && result.size() == locres.size())
192  {
193  int nvar = result.size();
194  for (int iv = 0; iv<nvar; iv++) {
195  result[iv] += locres[iv];
196  }
197  }
198  else if(result.size() && locres.size() && result.size() != locres.size())
199  {
200  DebugStop();
201  }
202  }
203  return result;
204  }
205 
206 
207  virtual void TransferMultiphysicsElementSolution() override
208  {
209  int nel = fElGroup.size();
210  for (int el=0; el<nel; el++) {
211  fElGroup[el]->TransferMultiphysicsElementSolution();
212  }
213  }
214 
215 
227  virtual TPZCompEl *ClonePatchEl(TPZCompMesh &mesh,
228  std::map<int64_t,int64_t> & gl2lcConMap,
229  std::map<int64_t,int64_t> & gl2lcElMap) const override;
230 
231 public:
232 
239  virtual void CreateGraphicalElement(TPZGraphMesh & graphmesh, int dimension) override
240  {
241  int nel = fElGroup.size();
242  for (int el=0; el<nel; el++) {
243  fElGroup[el]->CreateGraphicalElement(graphmesh,dimension);
244  }
245  }
246 
248  virtual void Integrate(int variable, TPZVec<STATE> & value) override{
249  int nel = fElGroup.size();
250  for (int el=0; el<nel; el++) {
251  fElGroup[el]->Integrate(variable,value);
252  }
253  }
254 
255 
261  virtual void CalcStiff(TPZElementMatrix &ek,TPZElementMatrix &ef) override;
262 
269  virtual void EvaluateError(std::function<void (const TPZVec<REAL> &loc,TPZVec<STATE> &val,TPZFMatrix<STATE> &deriv)> func,
270  TPZVec<REAL> &errors, bool store_error) override;
271 
273  virtual bool HasMaterial(const std::set<int> &materialids) const override;
274 
279  virtual void CalcResidual(TPZElementMatrix &ef) override;
280 
281  int ComputeIntegrationOrder() const override {
282  std::cout << "This method should not be called. " << __PRETTY_FUNCTION__ << std::endl;
283  DebugStop();
284  return 0;
285  }
286 
287  public:
288 virtual int ClassId() const override;
289 
290 protected:
291 
294 
297 
298 };
299 
300 #endif
Represents a graphical mesh used for post processing purposes. Post processing.
Definition: pzgraphmesh.h:34
TPZStack< TPZCompEl *, 5 > GetElGroup()
virtual void Integrate(int variable, TPZVec< STATE > &value) override
Integrates a variable over the element.
virtual int64_t ConnectIndex(int i) const override
Returns the index of the ith connectivity of the element.
void Unwrap()
put the elements in the element group back in the mesh and delete the element group ...
TPZVec< STATE > IntegrateSolution(const std::string &varname, const std::set< int > &matids) override
Compute the integral of a variable defined by the string if the material id is included in matids...
TPZStack< TPZCompEl *, 5 > fElGroup
virtual int NConnects() const override
Returns the number of nodes of the element.
virtual void EvaluateError(std::function< void(const TPZVec< REAL > &loc, TPZVec< STATE > &val, TPZFMatrix< STATE > &deriv)> func, TPZVec< REAL > &errors, bool store_error) override
Performs an error estimate on the elemen.
clarg::argInt dimension("-d", "Matrices dimension M x M", 1000)
TPZManVector< int64_t, 27 > fConnectIndexes
Contains declaration of TPZCompEl class which defines the interface of a computational element...
virtual void CalcResidual(TPZElementMatrix &ef) override
Computes the element right hand side.
Class which groups elements to characterize dense matrices.
REAL val(STATE &number)
Returns value of the variable.
Definition: pzartdiff.h:23
Contains TPZMatRed class which implements a simple substructuring of a linear system of equations...
virtual void TransferMultiphysicsElementSolution() override
virtual ~TPZElementGroup()
virtual TPZCompEl * Clone(TPZCompMesh &mesh) const override
Method for creating a copy of the element.
int ComputeIntegrationOrder() const override
Contains declaration of TPZElementMatrix struct which associates an element matrix with the coeficien...
virtual void LoadElementReference() override
Loads the geometric element reference.
virtual void BuildCornerConnectList(std::set< int64_t > &connectindexes) const override
adds the connect indexes associated with base shape functions to the set
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
TPZElementGroup(TPZCompMesh &mesh, int64_t &index)
virtual TPZVec< STATE > IntegrateSolution(int var) const override
Compute the integral of a variable defined by the string if the material id is included in matids...
virtual int Dimension() const override
Dimension of the element.
virtual TPZCompEl * ClonePatchEl(TPZCompMesh &mesh, std::map< int64_t, int64_t > &gl2lcConMap, std::map< int64_t, int64_t > &gl2lcElMap) const override
Method for creating a copy of the element in a patch mesh.
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
int64_t Index() const
Returns the index of the element within the element vector of the mesh.
Definition: pzgeoel.h:730
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
Free store vector implementation.
This class associates an element matrix with the coeficients of its contribution in the global stiffn...
Definition: pzelmat.h:30
virtual void SetConnectIndex(int inode, int64_t index) override
Set the index i to node inode.
virtual void CreateGraphicalElement(TPZGraphMesh &graphmesh, int dimension) override
Creates corresponding graphical element(s) if the dimension matches graphical elements are used to ge...
virtual void CalcStiff(TPZElementMatrix &ek, TPZElementMatrix &ef) override
Computes the element stifness matrix and right hand side.
virtual void LoadSolution() override
Loads the solution within the internal data structure of the element.
virtual int ClassId() const override
Define the class id associated with the class.
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
virtual void Print(std::ostream &out=std::cout) const
Prints element data.
Definition: pzcompel.cpp:322
void InitializeElementMatrix(TPZElementMatrix &ek, TPZElementMatrix &ef) const
Initialize the datastructure of ek and ef based on the connect information.
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
virtual void AddElement(TPZCompEl *cel)
add an element to the element group
bool NeedsComputing(const std::set< int > &matids) override
Verifies if any element needs to be computed corresponding to the material ids.
virtual bool HasMaterial(const std::set< int > &materialids) const override
Verifies if the material associated with the element is contained in the set.
std::map< int64_t, TPZOneShapeRestraint > fRestraints