NeoPZ
TPZCompElLagrange.cpp
Go to the documentation of this file.
1 //
2 // TPZCompElLagrange.cpp
3 // PZ
4 //
5 // Created by Philippe Devloo on 11/2/13.
6 //
7 //
8 
9 #include "TPZCompElLagrange.h"
10 #include "TPZMaterial.h"
11 #include "pzelmat.h"
12 
14 {
15 
16 }
17 
30  std::map<int64_t,int64_t> & gl2lcConMap,
31  std::map<int64_t,int64_t> & gl2lcElMap) const
32 {
33  TPZCompElLagrange *newel = new TPZCompElLagrange(mesh,*this,gl2lcElMap);
34  for (int64_t l=0; l<fDef.size(); l++) {
35  for (int i=0; i<2; i++) {
36  newel->fDef[l].fIdf[i] = fDef[l].fIdf[i];
37  std::map<int64_t,int64_t>::iterator it = gl2lcConMap.find(fDef[l].fConnect[i]);
38  if (it != gl2lcConMap.end()) {
39  newel->fDef[l].fConnect[i] = it->second;
40  }
41  else
42  {
43  DebugStop();
44  }
45  }
46  }
47  return newel;
48 }
49 
56 {
58 #ifdef PZDEBUG
59  if (ef.fMat.Cols() != 1) {
60  DebugStop();
61  }
62 #endif
63  int64_t nlagrange = fDef.size();
64  int64_t count = 0;
65  for (int64_t l=0; l<nlagrange; l++)
66  {
67  TPZConnect &c0 = Connect(2*l);
68  int blsize0 = c0.NShape()*c0.NState();
69  TPZConnect &c1 = Connect(2*l+1);
70  int blsize1 = c1.NShape()*c1.NState();
71  ek.fMat(count+fDef[l].fIdf[0],count+fDef[l].fIdf[0]) = 1.;
72  ek.fMat(count+fDef[l].fIdf[0],count+blsize0+fDef[l].fIdf[1]) = -1.;
73  ek.fMat(count+blsize0+fDef[l].fIdf[1],count+fDef[l].fIdf[0]) = -1.;
74  ek.fMat(count+blsize0+fDef[l].fIdf[1],count+blsize0+fDef[l].fIdf[1]) = 1.;
75  const TPZBlock<STATE> &bl = Mesh()->Block();
76  STATE diff = bl(c0.SequenceNumber(),0,fDef[l].fIdf[0],0)-bl(c1.SequenceNumber(),0,fDef[l].fIdf[1],0);
77  ef.fMat(count+fDef[l].fIdf[0],0) = -diff;
78  ef.fMat(count+blsize0+fDef[l].fIdf[1],0) = diff;
79  count += blsize0+blsize1;
80  }
81 }
82 
87 //void TPZCompElLagrange::CalcResidual(TPZElementMatrix &ef)
88 //{
89 //
90 //}
91 
93  int numloadcases = 1;
94  int numdof = 1;
95  TPZMaterial *mat = this->Material();
96  if (mat)
97  {
98  numloadcases = mat->NumLoadCases();
99  }
100  const int ncon = this->NConnects();
101 
102  ek.fMesh = Mesh();
104  ef.fMesh = Mesh();
106 
107  ek.fBlock.SetNBlocks(ncon);
108  ef.fBlock.SetNBlocks(ncon);
109  int i;
110  int numeq=0;
111  for(i=0; i<ncon; i++){
112  TPZConnect &c = Connect(i);
113  int nshape = c.NShape();
114  int nstate = c.NState();
115 
116  ek.fBlock.Set(i,nshape*nstate);
117  ef.fBlock.Set(i,nshape*nstate);
118  numeq += nshape*nstate;
119  }
120  ek.fMat.Redim(numeq,numeq);
121  ef.fMat.Redim(numeq,numloadcases);
122  ek.fConnect.Resize(ncon);
123  ef.fConnect.Resize(ncon);
124  for(i=0; i<ncon; i++){
125  (ef.fConnect)[i] = ConnectIndex(i);
126  (ek.fConnect)[i] = ConnectIndex(i);
127  }
128 }//void
129 
130 
131 
133  return Hash("TPZCompElLagrange") ^ TPZCompEl::ClassId() << 1;
134 }
int Set(const int index, const int dim, const int pos=-1)
Modifies existing block dimensions or creates a new block with given index.
Definition: pzblock.cpp:104
Represents a set of shape functions associated with a computational element/side. Computational Eleme...
Definition: pzconnect.h:30
TPZStack< int64_t > fConnect
Vector of pointers to TPZConnect objects.
Definition: pzelmat.h:39
TPZFNMatrix< 1000, STATE > fMat
Pointer to a blocked matrix object.
Definition: pzelmat.h:41
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.
TPZBlock< STATE > fBlock
Block structure associated with fMat.
Definition: pzelmat.h:43
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
Definition: pzmanvector.h:426
virtual int ClassId() const override
Define the class id associated with the class.
Definition: pzcompel.cpp:1129
This abstract class defines the behaviour which each derived class needs to implement.
Definition: TPZMaterial.h:39
Contains declaration of TPZElementMatrix struct which associates an element matrix with the coeficien...
virtual TPZMaterial * Material() const
Identify the material object associated with the element.
Definition: pzcompel.cpp:959
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 SequenceNumber() const
Returns the Sequence number of the connect object.
Definition: pzconnect.h:158
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
TPZCompMesh * Mesh() const
Return a pointer to the grid of the element.
Definition: pzcompel.cpp:288
virtual int NConnects() const override
Returns the number of nodes of the element.
unsigned int NShape() const
Definition: pzconnect.h:151
const TPZBlock< STATE > & Block() const
Access the block structure of the solution vector.
Definition: pzcmesh.h:213
TPZCompMesh * fMesh
Definition: pzelmat.h:36
int SetNBlocks(const int num_of_blocks)
Sets number of blocks on diagonal matrix.
Definition: pzblock.cpp:91
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
Definition: pzfmatrix.h:616
virtual TPZConnect & Connect(int i) const
Returns a pointer to the ith node.
Definition: pzcompel.cpp:298
unsigned char NState() const
Number of state variables associated with the connect.
Definition: pzconnect.h:146
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
This class associates an element matrix with the coeficients of its contribution in the global stiffn...
Definition: pzelmat.h:30
TPZManVector< TLagrange, 3 > fDef
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
int NumLoadCases()
returns the number of load cases for this material object
Definition: TPZMaterial.h:186
int64_t Cols() const
Returns number of cols.
Definition: pzmatrix.h:809
void InitializeElementMatrix(TPZElementMatrix &ek, TPZElementMatrix &ef)
Computes the element right hand side.
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59