NeoPZ
TPZCompElLagrange.h
Go to the documentation of this file.
1 //
2 // TPZCompElLagrange.h
3 // PZ
4 //
5 // Created by Philippe Devloo on 11/2/13.
6 //
7 //
8 
9 #ifndef __PZ__TPZCompElLagrange__
10 #define __PZ__TPZCompElLagrange__
11 
12 #include <iostream>
13 
14 #include "pzcompel.h"
15 #include "pzcmesh.h"
16 
18 {
19 
20 public:
21 
22  struct TLagrange
23  {
25  int64_t fConnect[2];
27  int fIdf[2];
28 
30  {
31  fConnect[0] = -1;
32  fConnect[1] = -1;
33  fIdf[0] = -1;
34  fIdf[1] = -1;
35  }
36  };
37 
38 private:
39 
41 
42 public:
43 
45  TPZCompEl(), fDef()
46  {
47  }
48 
50  TPZCompEl(copy)
51  {
52  fDef = copy.fDef;
53 
54  }
55 
56  TPZCompElLagrange(TPZCompMesh &mesh, int64_t connect1, int idf1, int64_t connect2, int idf2, int64_t &index) : TPZRegisterClassId(&TPZCompElLagrange::ClassId),
57  TPZCompEl(mesh,0,index), fDef(1)
58  {
59  fDef[0].fConnect[0] = connect1;
60  fDef[0].fConnect[1] = connect2;
61  fDef[0].fIdf[0] = idf1;
62  fDef[0].fIdf[1] = idf2;
63  mesh.ConnectVec()[connect1].IncrementElConnected();
64  mesh.ConnectVec()[connect2].IncrementElConnected();
65 #ifdef PZDEBUG
66  TPZConnect &c1 = mesh.ConnectVec()[connect1];
67  TPZConnect &c2 = mesh.ConnectVec()[connect2];
68  if (idf1 >= c1.NShape()*c1.NState()) {
69  DebugStop();
70  }
71  if (idf2 >= c2.NShape()*c2.NState()) {
72  DebugStop();
73  }
74 #endif
75  }
76 
78  TPZCompEl(mesh,0,index), fDef(Dependencies)
79  {
80  }
81 
84  TPZCompEl(mesh,copy)
85  {
86  const TPZCompElLagrange *lcop = dynamic_cast<const TPZCompElLagrange *>(&copy);
87  if (!lcop) {
88  DebugStop();
89  }
90  fDef = lcop->fDef;
91  }
92 
94  TPZCompElLagrange(TPZCompMesh &mesh, const TPZCompEl &copy, std::map<int64_t,int64_t> &gl2lcElMap) : TPZRegisterClassId(&TPZCompElLagrange::ClassId),
95  TPZCompEl(mesh,copy,gl2lcElMap)
96  {
97  const TPZCompElLagrange *lcop = dynamic_cast<const TPZCompElLagrange *>(&copy);
98  if (!lcop) {
99  DebugStop();
100  }
101  fDef = lcop->fDef;
102 
103  }
104 
107  TPZCompEl(mesh,copy,index)
108  {
109  const TPZCompElLagrange *lcop = dynamic_cast<const TPZCompElLagrange *>(&copy);
110  if (!lcop) {
111  DebugStop();
112  }
113  fDef = lcop->fDef;
114 
115  }
116 
117  virtual ~TPZCompElLagrange();
118 
120  virtual TPZCompEl *Clone(TPZCompMesh &mesh) const override
121  {
122  return new TPZCompElLagrange(mesh,*this);
123  }
124 
136  virtual TPZCompEl *ClonePatchEl(TPZCompMesh &mesh,
137  std::map<int64_t,int64_t> & gl2lcConMap,
138  std::map<int64_t,int64_t> & gl2lcElMap) const override;
139 
141  virtual int NConnects() const override
142  {
143  return 2*fDef.size();
144  }
145 
150  virtual int64_t ConnectIndex(int i) const override
151  {
152  if (i>=0 && i < 2*fDef.size()) {
153  return fDef[i/2].fConnect[i%2];
154  }
155  DebugStop();
156  return -1;
157  }
158 
160  virtual int Dimension() const override
161  {
162  return 0;
163  }
164 
165  void CreateGraphicalElement(TPZGraphMesh &, int) override
166  {
167  }
168 
169  void EvaluateError(std::function<void(const TPZVec<REAL> &loc,TPZVec<STATE> &val,TPZFMatrix<STATE> &deriv)> fp,
170  TPZVec<REAL> &/*errors*/, bool store_error) override {
171  return;
172  }
173 
174 
175 
177  virtual void BuildCornerConnectList(std::set<int64_t> &connectindexes) const override
178  {
179  for (int64_t i=0; i<fDef.size(); i++) {
180  connectindexes.insert(fDef[i].fConnect[0]);
181  connectindexes.insert(fDef[i].fConnect[1]);
182  }
183  }
184 
190  virtual void SetConnectIndex(int inode, int64_t index) override
191  {
192  if (inode >= 0 && inode < 2*fDef.size()) {
193  fDef[inode/2].fConnect[inode%2] = index;
194  }
195  else
196  {
197  DebugStop();
198  }
199  }
200 
206  virtual void CalcStiff(TPZElementMatrix &ek,TPZElementMatrix &ef) override;
207 
212  //virtual void CalcResidual(TPZElementMatrix &ef);
213 
215  public:
216 int ClassId() const override;
217 
218 
219 };
220 
221 #endif /* defined(__PZ__TPZCompElLagrange__) */
Represents a graphical mesh used for post processing purposes. Post processing.
Definition: pzgraphmesh.h:34
Represents a set of shape functions associated with a computational element/side. Computational Eleme...
Definition: pzconnect.h:30
Implements a vector class which allows to use external storage provided by the user. Utility.
Definition: pzquad.h:16
Contains declaration of TPZCompEl class which defines the interface of a computational element...
virtual int64_t ConnectIndex(int i) const override
Returns the index of the ith connectivity of the element.
virtual void CalcStiff(TPZElementMatrix &ek, TPZElementMatrix &ef) override
Computes the element stifness matrix and right hand side.
int ClassId() const override
Define the class id associated with the class.
This class implements a simple vector storage scheme for a templated class T. Utility.
Definition: pzgeopoint.h:19
REAL val(STATE &number)
Returns value of the variable.
Definition: pzartdiff.h:23
virtual int Dimension() const override
Dimension of the element.
virtual TPZCompEl * Clone(TPZCompMesh &mesh) const override
Method for creating a copy of the element.
TPZCompElLagrange(TPZCompMesh &mesh, int64_t connect1, int idf1, int64_t connect2, int idf2, int64_t &index)
TPZCompElLagrange(TPZCompMesh &mesh, const TPZCompEl &copy, std::map< int64_t, int64_t > &gl2lcElMap)
Put a copy of the element in the patch mesh.
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.
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
virtual int NConnects() const override
Returns the number of nodes of the element.
unsigned int NShape() const
Definition: pzconnect.h:151
TPZAdmChunkVector< TPZConnect > & ConnectVec()
Return a reference to the connect pointers vector.
Definition: pzcmesh.h:198
Contains declaration of TPZCompMesh class which is a repository for computational elements...
unsigned char NState() const
Number of state variables associated with the connect.
Definition: pzconnect.h:146
TPZCompElLagrange(TPZCompMesh &mesh, const TPZCompEl &copy, int64_t &index)
Copy of the element in the new mesh with alocated index.
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.
TPZCompElLagrange(const TPZCompElLagrange &copy)
TPZManVector< TLagrange, 3 > fDef
TPZCompElLagrange(TPZCompMesh &mesh, const TPZVec< TLagrange > &Dependencies, int64_t &index)
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
TPZCompElLagrange(TPZCompMesh &mesh, const TPZCompEl &copy)
Put a copy of the element in the referred mesh.
int fIdf[2]
Degree of freedom which is connected.
void InitializeElementMatrix(TPZElementMatrix &ek, TPZElementMatrix &ef)
Computes the element right hand side.
void EvaluateError(std::function< void(const TPZVec< REAL > &loc, TPZVec< STATE > &val, TPZFMatrix< STATE > &deriv)> fp, TPZVec< REAL > &, bool store_error) override
Performs an error estimate on the elemen.
virtual void BuildCornerConnectList(std::set< int64_t > &connectindexes) const override
adds the connect indexes associated with base shape functions to the set
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
int64_t fConnect[2]
Which connects are linked by a Lagrange multiplier.
void CreateGraphicalElement(TPZGraphMesh &, int) override
Creates corresponding graphical element(s) if the dimension matches graphical elements are used to ge...