NeoPZ
pzconnect.h
Go to the documentation of this file.
1 
6 #ifndef PZCONNECTH
7 #define PZCONNECTH
8 
9 #include "pzfmatrix.h"
10 #include "pzstack.h"
11 #include "pzlog.h"
12 #include <iostream>
13 #include <set>
14 
15 
16 class TPZBndCond;
17 class TPZCompMesh;
18 template<class TVar>
19 class TPZBlock;
20 
30 class TPZConnect : public TPZSavable {
31 public:
32  enum EConnectType {ENone = 0, EPressure = 1, ECondensed = 2};
34  int64_t fSequenceNumber;
35 
38 
44  union
45  {
46  unsigned int fFlags;
47  struct
48  {
50  unsigned char fOrder;
52  unsigned char fNState;
56  unsigned char fLagrangeMultiplier;
59  } fCompose;
60  };
62  unsigned int fNShape;
63 
64 
65 public:
67  class TPZDepend : public TPZSavable {
68  public :
72 
73  TPZDepend();
74  TPZDepend(int64_t DepConnectIndex,TPZFMatrix<REAL> &depmat,int64_t ipos,int64_t jpos, int isize, int jsize);
75 
76  TPZDepend(const TPZDepend &copy);
77  TPZDepend(int64_t connectindex);
78 
79  ~TPZDepend();
80  TPZDepend *HasDepend(int64_t DepConnectIndex);
82  int ClassId() const override;
83  void Read(TPZStream &buf, void *context) override;
84  void Write(TPZStream &buf, int withclassid) const override;
90  void CopyFrom(TPZDepend *orig , std::map<int64_t,int64_t>& gl2lcIdx);
91  };
92 
93 private:
96 
97 public:
99  TPZConnect();
100 
102  TPZConnect(const TPZConnect &copy);
104  ~TPZConnect();
105 
106  TPZConnect &operator=(const TPZConnect &con);
107 
108  virtual int ClassId() const override{
109  return Hash("TPZConnect");
110  }
111 
113  void Reset()
114  {
115  if (fDependList) {
116  DebugStop();
117  delete fDependList;
118  fDependList = 0;
119  }
120  SetSequenceNumber(-1);
121  SetNState(0);
122  SetOrder(0,-1);
123  SetNShape(0);
125  SetCondensed(false);
127  }
132  int NDof(TPZCompMesh &mesh);
133 
138  int NDof() const
139  {
140  return fNShape*fCompose.fNState;
141  }
142 
146  unsigned char NState() const
147  {
148  return fCompose.fNState;
149  }
150 
151  unsigned int NShape() const
152  {
153  return fNShape;
154  }
155 
158  int64_t SequenceNumber() const
159  {
160  return fSequenceNumber;
161  }
162 
165  void SetSequenceNumber(int64_t i) {fSequenceNumber = i;}
166 
168  void SetOrder(int order, int64_t index) {
169 #ifdef PZDEBUG
170  if(order < 0 || order > 255)
171  {
172  DebugStop();
173  }
174 // int64_t crit[] = {5004,5005,4978,5170,5516,5515,5544,5555,4997,4973,4966,4965,5520,5519,5546,5556,5523,5549,5557,5558,4962,5527,5552,5559,5560,5561,5562};
175 // static std::set<int64_t> critical;
176 // static int once = 1;
177 // if (once)
178 // {
179 // once = 0;
180 // for (int i=0; i<27; i++) {
181 // critical.insert(crit[i]);
182 // }
183 // }
184 // if (critical.find(index) != critical.end()) {
185 // std::cout << "Connect index " << index << " set to order " << order << std::endl;
186 // if(order == 5)
187 // {
188 // StopError();
189 // }
190 // }
191 #endif
192  fCompose.fOrder = order;
193  }
194 
196  void SetNState(int nstate)
197  {
198  if(nstate<0 || nstate > 255)
199  {
200  DebugStop();
201  }
202  fCompose.fNState = nstate;
203  }
205  void SetNShape(int nshape)
206  {
207 #ifdef PZDEBUG
208  if(nshape < 0 )
209  {
210  DebugStop();
211  }
212 #endif
213  fNShape = nshape;
214  }
215 
217  unsigned char Order() const {
218  return fCompose.fOrder;
219  }
220 
223  bool IsCondensed() const
224  {
225  return fCompose.fIsCondensed;
226  }
227 
230  unsigned char LagrangeMultiplier() const
231  {
232  return fCompose.fLagrangeMultiplier;
233  }
234 
236  void SetLagrangeMultiplier(unsigned char mult)
237  {
238  fCompose.fLagrangeMultiplier = mult;
239  }
240 
242  void SetCondensed(bool flag)
243  {
244  fCompose.fIsCondensed = flag;
245  }
246 
252  void Print(const TPZCompMesh &mesh, std::ostream & out = std::cout);
253 
255  void Print(TPZCompMesh &mesh, TPZVec<REAL> &cp, std::ostream & out = std::cout);
256 
258  void ResetElConnected() { fNElConnected = 0; }
260  void IncrementElConnected() { fNElConnected++; }
262  void DecrementElConnected() { fNElConnected--; }
264  int NElConnected() const { return fNElConnected; }
265 
273  TPZDepend *AddDependency(int64_t myindex, int64_t dependindex,TPZFMatrix<REAL> &depmat,int64_t ipos,int64_t jpos, int isize, int jsize);
274 
280  void RemoveDepend(int64_t myindex, int64_t dependindex);
281 
283  void RemoveDepend();
284 
286  int DependencyDepth(TPZCompMesh &mesh);
287 
289  int NumDepend() const;
290 
292  int HasDependency()const { return fDependList != 0; }
293 
294  int CheckDependency(int nshape, TPZCompMesh *mesh, int nstate);
295 
297 
299  void AddToList(int64_t myindex, TPZCompMesh &mesh, TPZStack<int64_t> &connectlist);
300 
302  void AddToList(int64_t myindex, TPZCompMesh &mesh, std::set<int64_t> &connectlist);
303 
304  void SetDependenceOrder(int64_t myindex, TPZCompMesh &mesh, int CurrentOrder,TPZVec<int64_t> &connectlist,TPZVec<int> &DependenceOrder);
305 
306  void ExpandShape(int64_t cind, TPZVec<int64_t> &connectlist, TPZVec<int> &blocksize, TPZFMatrix<REAL> &phi, TPZFMatrix<REAL> &dphi);
307 
309  void Write(TPZStream &buf, int withclassid) const override;
310 
312  void Read(TPZStream &buf, void *context) override;
313 
319  void CopyFrom(TPZConnect &orig,std::map<int64_t,int64_t> & gl2lcIdx);
320 
331  void BuildConnectList(int64_t index, std::set<int64_t> &indepconnectlist, std::set<int64_t> &depconnectlist, TPZCompMesh &mesh);
332 
342  static void BuildConnectList(TPZStack<int64_t> &connectlist, TPZVec<int64_t> &ConnectIndex, TPZCompMesh &mesh);
343 
353  static void BuildConnectList(std::set<int64_t> &connectlist, std::set<int64_t> &additional, TPZCompMesh &mesh);
354 
360  static void BuildDependencyOrder(TPZVec<int64_t> &connectlist, TPZVec<int> &DependenceOrder, TPZCompMesh &mesh);
361 
362 };
363 
366 inline std::ostream & operator<<(std::ostream &out,TPZConnect &con)
367 {
368  out << "seq num: " << con.SequenceNumber()
369  << " nel con: " << con.NElConnected()
370  << " order: " << con.Order()
371  << " is condensed " << con.IsCondensed()
372  << " hasdepend: " << con.HasDependency();
373  return out;
374 }
375 
376 #endif
377 
int ClassId() const override
Define the class id associated with the class.
Definition: pzconnect.cpp:406
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Definition: pzconnect.cpp:410
unsigned int fNShape
Number of shape functions associated with the connect.
Definition: pzconnect.h:62
int64_t fSequenceNumber
Node block number.
Definition: pzconnect.h:34
void IncrementElConnected()
Increment fNElConnected.
Definition: pzconnect.h:260
Represents a set of shape functions associated with a computational element/side. Computational Eleme...
Definition: pzconnect.h:30
Contains definitions to LOGPZ_DEBUG, LOGPZ_INFO, LOGPZ_WARN, LOGPZ_ERROR and LOGPZ_FATAL, and the implementation of the inline InitializePZLOG(string) function using log4cxx library or not. It must to be called out of "#ifdef LOG4CXX" scope.
void DecrementElConnected()
Decrement fNElConnected.
Definition: pzconnect.h:262
void SetOrder(int order, int64_t index)
Set the order of the shapefunction associated with the connect.
Definition: pzconnect.h:168
unsigned int fFlags
Definition: pzconnect.h:46
unsigned char fOrder
Interpolation order of the associated shape functions.
Definition: pzconnect.h:50
void SetLagrangeMultiplier(unsigned char mult)
Set the connect as a pressure connect or not.
Definition: pzconnect.h:236
TPZDepend * AddDependency(int64_t myindex, int64_t dependindex, TPZFMatrix< REAL > &depmat, int64_t ipos, int64_t jpos, int isize, int jsize)
Add dependency between connects.
Definition: pzconnect.cpp:130
struct TPZConnect::@47::@49 fCompose
int CheckDependency(int nshape, TPZCompMesh *mesh, int nstate)
Definition: pzconnect.cpp:326
void Read(TPZStream &buf, void *context) override
read objects from the stream
Definition: pzconnect.cpp:416
int DependencyDepth(TPZCompMesh &mesh)
the maximum number of recursive dependencies
Definition: pzconnect.cpp:184
TPZDepend * fDependList
Dependency list of the connect (NULL if the connect is not constrained)
Definition: pzconnect.h:95
unsigned char LagrangeMultiplier() const
Access method to return the indication whether the connect is associated with a pressure lagrange mul...
Definition: pzconnect.h:230
int NumDepend() const
size of the dependency list
Definition: pzconnect.cpp:201
unsigned char Order() const
Access function to return the order associated with the connect.
Definition: pzconnect.h:217
int64_t SequenceNumber() const
Returns the Sequence number of the connect object.
Definition: pzconnect.h:158
void Reset()
Reset the data of the connect.
Definition: pzconnect.h:113
int64_t fDepConnectIndex
Definition: pzconnect.h:69
Structure to reference dependency.
Definition: pzconnect.h:67
TPZConnect()
Default constructor.
Definition: pzconnect.cpp:21
Contains TPZMatrixclass which implements full matrix (using column major representation).
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
bool fIsCondensed
Whether the equations associated with the connect should be/are condensed.
Definition: pzconnect.h:58
void SetSequenceNumber(int64_t i)
Set the sequence number for the global system of equations of the connect object. ...
Definition: pzconnect.h:165
This class defines the boundary condition for TPZMaterial objects.
Definition: pzbndcond.h:29
void SetNState(int nstate)
Set the number of state variables.
Definition: pzconnect.h:196
unsigned int NShape() const
Definition: pzconnect.h:151
void SetNShape(int nshape)
Set the number of shape functions associated with the connect.
Definition: pzconnect.h:205
int HasDependency() const
Returns whether exist dependecy information.
Definition: pzconnect.h:292
TPZDepend * fNext
Definition: pzconnect.h:71
void BuildConnectList(int64_t index, std::set< int64_t > &indepconnectlist, std::set< int64_t > &depconnectlist, TPZCompMesh &mesh)
Builds the list of all connectivities related to ConnectIndex including the connects pointed to by de...
Definition: pzconnect.cpp:509
void SetCondensed(bool flag)
Set the connect as a condensed connect or not.
Definition: pzconnect.h:242
unsigned char NState() const
Number of state variables associated with the connect.
Definition: pzconnect.h:146
A simple stack.
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
void AddToList(int64_t myindex, TPZCompMesh &mesh, TPZStack< int64_t > &connectlist)
Adds itself and the connects from which it depends to the list.
Definition: pzconnect.cpp:221
unsigned char fLagrangeMultiplier
Whether the connnect is associated with a lagrange multiplier, indicating the level level n multiplie...
Definition: pzconnect.h:56
unsigned char fNState
Number of state variables associated with each shape function.
Definition: pzconnect.h:52
TPZFNMatrix< 50, REAL > fDepMatrix
Definition: pzconnect.h:70
TPZConnect & operator=(const TPZConnect &con)
Definition: pzconnect.cpp:51
TPZDepend * HasDepend(int64_t DepConnectIndex)
Definition: pzconnect.cpp:292
int fNElConnected
Number of element connected.
Definition: pzconnect.h:37
Implements block matrices. Matrix utility.
void ResetElConnected()
Initialize with zero fNElConnected.
Definition: pzconnect.h:258
TPZDepend * FirstDepend()
Definition: pzconnect.h:296
virtual int ClassId() const override
Define the class id associated with the class.
Definition: pzconnect.h:108
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
int NDof() const
Number of degrees of freedom associated with the object.
Definition: pzconnect.h:138
static void BuildDependencyOrder(TPZVec< int64_t > &connectlist, TPZVec< int > &DependenceOrder, TPZCompMesh &mesh)
This method builds the vector DependenceOrder which indicates in which order constrained nodes need t...
Definition: pzconnect.cpp:556
int NElConnected() const
Returns fNElConnected.
Definition: pzconnect.h:264
~TPZConnect()
Default destructor.
Definition: pzconnect.cpp:25
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
void SetDependenceOrder(int64_t myindex, TPZCompMesh &mesh, int CurrentOrder, TPZVec< int64_t > &connectlist, TPZVec< int > &DependenceOrder)
Definition: pzconnect.cpp:245
void Print(const TPZCompMesh &mesh, std::ostream &out=std::cout)
Print the information for the connect element.
Definition: pzconnect.cpp:67
void CopyFrom(TPZDepend *orig, std::map< int64_t, int64_t > &gl2lcIdx)
Copy a depend data structure to a clone depend in a clone mesh.
Definition: pzconnect.cpp:475
This class defines the interface to save and restore objects from TPZStream objects. Persistency.
Definition: TPZSavable.h:67
bool IsCondensed() const
Access method to return the indication whether the connect is condensed or not.
Definition: pzconnect.h:223
std::ostream & operator<<(std::ostream &out, TPZConnect &con)
Overload operator << to write node connect data.
Definition: pzconnect.h:366
TPZDepend * RemoveDepend(TPZDepend *Ptr)
Definition: pzconnect.cpp:298
void ExpandShape(int64_t cind, TPZVec< int64_t > &connectlist, TPZVec< int > &blocksize, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphi)
Definition: pzconnect.cpp:353