NeoPZ
pzdohrstructmatrix.h
Go to the documentation of this file.
1 
6 #ifndef PZDOHRSTRUCTMATRIX
7 #define PZDOHRSTRUCTMATRIX
8 
9 #include "pzstrmatrix.h"
10 #include "tpzdohrassembly.h"
11 #include "pzsubcmesh.h"
12 
13 template<class TVar>
15 
23 {
24 
25 public:
26 
29 
32 
33  virtual ~TPZDohrStructMatrix();
34 
36  void SubStructure(int nsub);
37 
39  virtual TPZMatrix<STATE> * Create() override;
40 
46  {
48  //fDohrPrecond = 0; Essa linha me ferra pois nao posso pegar as subestruturas depois
49  return result;
50  }
51 
54  unsigned numthreads_assemble, unsigned numthreads_decompose) override;
55 
59  virtual void Assemble(TPZMatrix<STATE> & mat, TPZFMatrix<STATE> & rhs, TPZAutoPointer<TPZGuiInterface> guiInterface,
60  unsigned numthreads_assemble, unsigned numthreads_decompose) override;
61 
63 
67  virtual void Assemble(TPZFMatrix<STATE> & rhs, TPZAutoPointer<TPZGuiInterface> guiInterface) override;
68 
70  virtual TPZStructMatrix * Clone() override
71  {
72  return new TPZDohrStructMatrix(*this);
73  }
74 
76  int NumberCornerEqs() const
77  {
78  return fCornerEqs.size();
79  }
80 
81  // FOR DEBUG PURPOSES
83  return fDohrAssembly;
84  }
85 
93  int SeparateUnconnected(TPZVec<int> &domain_index, int nsub, int connectdimension);
94 
99  int ClusterIslands(TPZVec<int> &domain_index,int nsub,int connectdimension);
100 
101  void Write(TPZStream &str, int withclassid) const override;
102 
103  void Read(TPZStream &str, void *context) override;
104 
105 
106 protected:
107 
109 
111 
112  /* @brief Get the global equation numbers of a substructure (and their inverse) */
113  void IdentifyEqNumbers(TPZSubCompMesh *sub, std::map<int,int> &global, std::map<int,int> &globinv);
114 
118  TPZVec<int> &scatterpermute, TPZVec<int> &gatherpermute);
119 
121  void IdentifySubCornerEqs(std::map<int,int> &globaltolocal, TPZVec<int> &cornereqs,
122  TPZVec<int> &coarseindex);
123 
125  void CorrectNeighbourDomainIndex(TPZCompMesh *cmesh, TPZVec<int> &domainindex);
126 
127 public:
130 
131 private:
133 
135  void IdentifyCornerNodes();
136 
139 
141  std::set<int> fCornerEqs;
142 
144  pthread_mutex_t fAccessElement;
145 
146  friend struct ThreadDohrmanAssembly<STATE>;
147 
149 
150 };
151 
153 
158 template<class TVar>
159 struct ThreadDohrmanAssembly {
160 
161  enum MTask {ENone, EComputeMatrix, EDecomposeInternal, EDecomposeBig};
162 
168 
171  fTask(ENone), fMesh(mesh), fSubMeshIndex(submesh), fSubstruct(substruct), fAssembly(assembly)
172  {
173 
174  }
175 
176  ThreadDohrmanAssembly(const ThreadDohrmanAssembly &copy) : fTask(copy.fTask), fMesh(copy.fMesh), fSubMeshIndex(copy.fSubMeshIndex),
177  fSubstruct(copy.fSubstruct),fAssembly(copy.fAssembly)
178  {
179  }
180 
181  ThreadDohrmanAssembly(TPZAutoPointer<ThreadDohrmanAssembly> copy) : fTask(copy->fTask), fMesh(copy->fMesh), fSubMeshIndex(copy->fSubMeshIndex),
182  fSubstruct(copy->fSubstruct),fAssembly(copy->fAssembly)
183  {
184  }
185 
187  {
188  fTask = copy.fTask;
189  fMesh = copy.fMesh;
190  fSubMeshIndex = copy.fSubMeshIndex;
191  fSubstruct = copy.fSubstruct;
192  fAssembly = copy.fAssembly;
193  return *this;
194  }
195 
196  void AssembleMatrices(pthread_mutex_t &testthread, int numa_node);
197 };
198 
203 template<class TVar>
205 
208 
210 
211  std::list<TPZAutoPointer<ThreadDohrmanAssembly<TVar> > > fList;
212 
214 
217 
218  static void *ThreadWork(void *voidptr);
219 
221  pthread_mutex_t fAccessElement;
222 
224  pthread_mutex_t fTestThreads;
225 };
226 
227 #endif
void IdentifySubCornerEqs(std::map< int, int > &globaltolocal, TPZVec< int > &cornereqs, TPZVec< int > &coarseindex)
Identify the corner equations associated with a substructure.
Assembling using Dohrmann algorithm. Sub structure.
void ComputeInternalEquationPermutation(TPZSubCompMesh *sub, TPZVec< int > &scatterpermute, TPZVec< int > &gatherpermute)
Computes the permutation vectors from the subcompmesh ordening to the "internal first" ordering...
void CorrectNeighbourDomainIndex(TPZCompMesh *cmesh, TPZVec< int > &domainindex)
Set the domain index of the lower dimension elements equal to the domain index of their neighbour...
TPZAutoPointer< TPZDohrAssembly< STATE > > fDohrAssembly
void Append(TPZVec< TVar > &u1, TPZVec< TVar > &u2, TPZVec< TVar > &u12)
Append u2 vector after u1 vector in u12 vector.
clarg::argInt nsub("-nsub", "number of substructs", 4)
TPZAutoPointer< TPZDohrAssembly< TVar > > fAssembly
TPZAutoPointer< TPZCompMesh > fMesh
TPZAutoPointer< TPZDohrAssembly< STATE > > Assembly()
Implements assembling by Dohrman algorithm.
void IdentifyCornerNodes()
Identify cornernodes.
Contains the TPZStructMatrixOR class which responsible for a interface among Matrix and Finite Elemen...
Contains the TPZDohrAssembly class which implements assembling using Dohrmann algorithm.
pthread_mutex_t fAccessElement
Mutexes (to choose which submesh is next)
std::set< int > fCornerEqs
The global equations defining the coarse matrix.
void IdentifyEqNumbers(TPZSubCompMesh *sub, std::map< int, int > &global, std::map< int, int > &globinv)
Refines geometrical mesh (all the elements) num times.
Definition: pzstrmatrix.h:35
ThreadDohrmanAssembly(TPZAutoPointer< ThreadDohrmanAssembly > copy)
int NumberCornerEqs() const
Return the number of cornereqs.
TPZAutoPointer< TPZMatrix< STATE > > Preconditioner()
This will return the pointer to the preconditioner AND abandon the pointer.
void AssembleTBB(TPZMatrix< STATE > &mat, TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface)
void Write(TPZStream &str, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
TPZAutoPointer< TPZMatrix< STATE > > fDohrPrecond
To condense matrix divided in sub structures. Sub Structure.
Implements a group of computational elements as a mesh and an element. Computational Mesh...
Definition: pzsubcmesh.h:36
int ClusterIslands(TPZVec< int > &domain_index, int nsub, int connectdimension)
Eliminates subdomains who are embedded in other subdomains.
virtual void Assemble(TPZMatrix< STATE > &mat, TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface, unsigned numthreads_assemble, unsigned numthreads_decompose) override
Assemble the global system of equations into the matrix which has already been created.
ThreadDohrmanAssembly(const ThreadDohrmanAssembly &copy)
virtual TPZMatrix< STATE > * Create() override
This will create a DohrMatrix.
Contains the TPZDohrSubstructCondense class which condenses matrix divided in sub structures...
void IdentifyExternalConnectIndexes()
Identify the external connects.
virtual TPZStructMatrix * Clone() override
Creates a copy of itself.
pthread_mutex_t fAccessElement
Mutexes (to choose which submesh is next)
static void AssembleMatrices(TPZSubCompMesh *submesh, TPZAutoPointer< TPZDohrSubstructCondense< STATE > > substruct, TPZAutoPointer< TPZDohrAssembly< STATE > > dohrassembly, pthread_mutex_t *TestThread)
Contains declaration of TPZSubCompMesh class which implements a group of computational elements as a ...
ThreadDohrmanAssembly & operator=(const ThreadDohrmanAssembly &copy)
TPZManVector< int > fExternalConnectIndexes
The connect indexes which are external.
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
pthread_mutex_t fTestThreads
mutex to debug the assembly process
TPZAutoPointer< TPZDohrSubstructCondense< TVar > > fSubstruct
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
int SeparateUnconnected(TPZVec< int > &domain_index, int nsub, int connectdimension)
Verifies if the subdomains are connected by sides of connectdimension and separate them if not...
Implements a list of Dohrman assembling and control thread and semaphores.
virtual TPZMatrix< STATE > * CreateAssemble(TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface, unsigned numthreads_assemble, unsigned numthreads_decompose) override
This will create a DohrMatrix and compute its matrices.
std::list< TPZAutoPointer< ThreadDohrmanAssembly< TVar > > > fList
ThreadDohrmanAssembly(TPZAutoPointer< TPZCompMesh > mesh, int submesh, TPZAutoPointer< TPZDohrSubstructCondense< TVar > > substruct, TPZAutoPointer< TPZDohrAssembly< TVar > > assembly)
void Read(TPZStream &str, void *context) override
read objects from the stream
void SubStructure(int nsub)
Partition the mesh in submeshes.
Implements structural matrix divided in sub structures. Structural Matrix Sub structure.