NeoPZ
pzbdstrmatrix.cpp
Go to the documentation of this file.
1 
6 #include "pzbdstrmatrix.h"
7 #include "pzblockdiag.h"
8 #include "pzvec.h"
9 #include "pzadmchunk.h"
10 #include "pzconnect.h"
11 #include "pzcmesh.h"
12 #include "pzskylmat.h"
13 #include "pzsubcmesh.h"
14 #include "pzgmesh.h"
15 #include "pzsolve.h"
16 #include "pzstepsolver.h"
17 
18 using namespace std;
19 
21 
22 }
23 
25 
26  TPZVec<int> blocksizes;
27  BlockSizes(blocksizes);
28  block.Initialize(blocksizes);
29  int nblock = blocksizes.NElements();
30  TPZAdmChunkVector<TPZCompEl *> &elementvec = fMesh->ElementVec();
31  TPZAdmChunkVector<TPZConnect> &connectvec = fMesh->ConnectVec();
32  TPZStack<int64_t> connectlist;
34  int64_t numel = elementvec.NElements();
35  int64_t el;
36  for(el=0; el<numel; el++) {
37  TPZCompEl *cel = elementvec[el];
38  if(!cel) continue;
40  cel->CalcBlockDiagonal(connectlist,elblock);
41  // elblock.Print("Element block diagonal");
42  int64_t ncon = connectlist.NElements();
43  int64_t c,seqnum;
44  for(c=0; c<ncon; c++) {
45  TPZConnect &con = connectvec[connectlist[c]];
46  seqnum = con.SequenceNumber();
47  int64_t eqnum = fMesh->Block().Position(seqnum);
48  if(seqnum <0 || seqnum >= nblock) continue;
49  int bsize = blocksizes[seqnum];
50  int64_t numactive = fEquationFilter.NumActive(eqnum, eqnum+bsize);
51  if (!numactive) {
52  continue;
53  }
54  if (numactive != bsize) {
55  // Please implement me
56  DebugStop();
57  }
58  if(con.NDof(*fMesh) != bsize ) {
59  cout << "TPZBlockDiagonalStructMatrix::AssembleBlockDiagonal wrong data structure\n";
60  continue;
61  }
62  TPZFMatrix<STATE> temp(bsize,bsize);
63  elblock.GetBlock(c,temp);
64  block.AddBlock(seqnum,temp);
65  }
66  }
67 }
68 
70 
71  if(fMesh->FatherMesh() != 0) {
72  TPZSubCompMesh *mesh = (TPZSubCompMesh *) fMesh;
74  }
75  int nblocks = 0;
76  TPZAdmChunkVector<TPZConnect> &connectvec = fMesh->ConnectVec();
77  int64_t nc = connectvec.NElements();
78  int64_t c;
79  for(c=0; c<nc; c++) {
80  TPZConnect &con = connectvec[c];
81  if(con.HasDependency() || con.IsCondensed() || con.SequenceNumber() < 0) continue;
82  nblocks++;
83  }
84  blocksizes.Resize(nblocks);
85  int64_t bl,blsize;
86  for(c=0; c<nc; c++) {
87  TPZConnect &con = connectvec[c];
88  if(con.HasDependency() || con.IsCondensed() || con.SequenceNumber() < 0) continue;
89  bl = con.SequenceNumber();
90  blsize = con.NDof(*fMesh);
91  int64_t blpos = fMesh->Block().Position(bl);
92  int64_t numactiv = fEquationFilter.NumActive(blpos, blpos+blsize);
93  if (numactiv && numactiv != blsize) {
94  DebugStop();
95  }
96  if(!numactiv)
97  {
98  blocksizes[bl] = 0;
99  }
100  else
101  {
102  blocksizes[bl] = blsize;
103  }
104  }
105 }
106 
108  return new TPZBlockDiagonalStructMatrix(*this);
109 }
111  int64_t neq = fMesh->NEquations();
113  rhs.Redim(neq,1);
114  Assemble(rhs,guiInterface);
115  AssembleBlockDiagonal(*block);
116  return block;
117 }
119  TPZVec<int> blocksize;
120  BlockSizes(blocksize);
121  return new TPZBlockDiagonal<STATE>(blocksize);
122 }
124 TPZRegisterClassId(&TPZBlockDiagonalStructMatrix::ClassId), TPZStructMatrix(mesh),fBlockStructure(EVertexBased),fOverlap(0)
125 {
126 }
127 
130 {
131 }
132 
134  return Hash("TPZBlockDiagonalStructMatrix") ^ TPZStructMatrix::ClassId() << 1;
135 }
int ClassId() const override
Define the class id associated with the class.
const int64_t numel
Number of elements to test.
Definition: pzsubcmesh.cpp:47
Represents a set of shape functions associated with a computational element/side. Computational Eleme...
Definition: pzconnect.h:30
Implements Block Diagonal Structural Matrices. Structural Matrix.
Definition: pzbdstrmatrix.h:21
virtual TPZMatrix< STATE > * CreateAssemble(TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface) override
Templated vector implementation.
MBlockStructure fBlockStructure
Definition: pzbdstrmatrix.h:55
virtual TPZMatrix< STATE > * Create() override
Creates a sparse blockdiagonal matrix, overlapping should be assumed.
Declarates the TPZBlock<REAL>class which implements block matrices.
int64_t NElements() const
Access method to query the number of elements of the vector.
int NDof(TPZCompMesh &mesh)
Number of degrees of freedom associated with the object.
Definition: pzconnect.cpp:317
Implements a chunk vector with free store administration. Utility.
Definition: TPZStream.h:39
Contains TPZBlockDiagonal class which defines block diagonal matrices.
virtual void CalcBlockDiagonal(TPZStack< int64_t > &connectlist, TPZBlockDiagonal< STATE > &block)
Calculates the diagonal block.
Definition: pzcompel.cpp:51
void BlockSizes(TPZVec< int > &blocksizes)
Refines geometrical mesh (all the elements) num times.
Definition: pzstrmatrix.h:35
Contains the TPZBlockDiagonalStructMatrix class which implements Block Diagonal Structural Matrices...
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object reallocating the necessary storage, copying the existing objects to the new...
Definition: pzvec.h:373
Contains declaration of TPZMesh class which defines a geometrical mesh and contains a corresponding l...
int64_t SequenceNumber() const
Returns the Sequence number of the connect object.
Definition: pzconnect.h:158
Implements a group of computational elements as a mesh and an element. Computational Mesh...
Definition: pzsubcmesh.h:36
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
Contains declaration of TPZConnect class which represents a set of shape functions associated with a ...
int HasDependency() const
Returns whether exist dependecy information.
Definition: pzconnect.h:292
Contains TPZSkyline class which implements a skyline storage format.
void AddBlock(int64_t i, TPZFMatrix< TVar > &block)
Adds a block to current matrix.
Definition: pzblockdiag.cpp:25
Contains declaration of TPZCompMesh class which is a repository for computational elements...
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
Definition: pzfmatrix.h:616
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
void PermuteExternalConnects()
Optimizes the connections positions on block.
void Initialize(const TPZVec< int > &blocksize)
Initializes current matrix based on blocksize.
Definition: pzblockdiag.cpp:64
Contains declaration of TPZSubCompMesh class which implements a group of computational elements as a ...
int ClassId() const override
Define the class id associated with the class.
void GetBlock(int64_t i, TPZFMatrix< TVar > &block)
Gets a block from current matrix.
Definition: pzblockdiag.cpp:52
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
Contains TPZSolver class which defines a abstract class of solvers which will be used by matrix class...
Contains TPZStepSolver class which defines step solvers class.
virtual TPZStructMatrix * Clone() override
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
void AssembleBlockDiagonal(TPZBlockDiagonal< STATE > &block)
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
bool IsCondensed() const
Access method to return the indication whether the connect is condensed or not.
Definition: pzconnect.h:223