NeoPZ
tpzpairstructmatrix.h
Go to the documentation of this file.
1 
6 #ifndef PAIRSTRUCTMATRIX
7 #define PAIRSTRUCTMATRIX
8 
9 #include "pzcmesh.h"
10 #include "pzvec.h"
11 #include "tpzautopointer.h"
12 #include "pzmatrix.h"
13 #include "TPZGuiInterface.h"
14 #include "pzelmat.h"
15 #include "TPZSemaphore.h"
16 #include "pzstrmatrix.h"
17 
18 //class TPZStructMatrix;
19 
25 {
28 
29  void PermuteScatter(TPZVec<int> &index);
30  void PermuteScatter(TPZVec<int64_t> &index);
31 
32 public:
33 
34  static int gNumThreads;
35 
36  TPZPairStructMatrix(TPZCompMesh *mesh, TPZVec<int> &permutescatter);
37 
39  {
40 
41  }
42 
44  {
45  fStrMatrix.SetNumThreads(numthreads);
46  }
47 
49  void SetMaterialIds(const std::set<int> &materialids);
50 
52  void TBBAssemble(TPZMatrix<STATE> *first,
53  TPZMatrix<STATE> *second, TPZFMatrix<STATE> &rhs);
54 
56 
58 
60  struct ThreadData
61  {
65  ~ThreadData();
69  pthread_mutex_t fAccessElement;
83  std::map<int, std::pair< TPZAutoPointer<TPZElementMatrix>, TPZAutoPointer<TPZElementMatrix> > > fSubmitted1;
85  std::map<int, TPZAutoPointer<TPZElementMatrix> > fSubmitted2;
87  std::set<int> fProcessed1;
89  std::set<int> fProcessed2;
93  int NextElement();
97  static void *ThreadWork(void *threaddata);
99  static void *ThreadAssembly1(void *threaddata);
101  static void *ThreadAssembly2(void *threaddata);
102 
104  bool ShouldCompute(int matid)
105  {
106  return fStrMatrix->ShouldCompute(matid);
107  }
108  void PermuteScatter(TPZVec<int> &index);
109  void PermuteScatter(TPZVec<int64_t> &index);
110 
111  };
112 
113 };
114 
115 #endif
Contains declaration of the TPZSemaphore class which implements semaphore to threads.
TPZSemaphore fAssembly2
Semaphore (to wake up the second assembly thread)
Implements semaphore to threads. Utility.
Definition: TPZSemaphore.h:15
~ThreadData()
Destroy the mutex semaphores and others.
pthread_mutex_t fAccessElement
Mutexes (to choose which element is next)
Contains the thread data for matrices divided in sub structures.
TPZPairStructMatrix(TPZCompMesh *mesh, TPZVec< int > &permutescatter)
void TBBAssemble(TPZMatrix< STATE > *first, TPZMatrix< STATE > *second, TPZFMatrix< STATE > &rhs)
static void * ThreadWork(void *threaddata)
The function which will compute the matrices.
Templated vector implementation.
Contains declaration of TPZGuiInterface class.
std::set< int > fProcessed2
Elements which are being processed maintained by the second global matrix.
TPZMatrix< STATE > * fGlobMatrix2
Global matrix2.
ThreadData(TPZStructMatrix *strmatrix, TPZMatrix< STATE > &mat1, TPZMatrix< STATE > &mat2, TPZFMatrix< STATE > &rhs)
Initialize the mutex semaphores and others.
Contains the TPZStructMatrixOR class which responsible for a interface among Matrix and Finite Elemen...
void PermuteScatter(TPZVec< int > &index)
static void * ThreadAssembly2(void *threaddata)
The function which will compute the assembly.
std::map< int, TPZAutoPointer< TPZElementMatrix > > fSubmitted2
List of computed element matrices (autopointers?)
Refines geometrical mesh (all the elements) num times.
Definition: pzstrmatrix.h:35
Contains declaration of TPZElementMatrix struct which associates an element matrix with the coeficien...
TPZFMatrix< STATE > * fGlobRhs
Global rhs.
virtual void SetNumThreads(int n)
TPZVec< int > fPermuteScatter
void MultiThread_Assemble(TPZMatrix< STATE > *first, TPZMatrix< STATE > *second, TPZFMatrix< STATE > &rhs)
Contains declaration of the TPZAutoPointer class which has Increment and Decrement actions are mutexe...
TPZVec< int > fPermuteScatter
Vector which defines the permutation of all equations to internal equations.
virtual bool ShouldCompute(int matid) const
Establish whether the element should be computed.
Contains declaration of TPZCompMesh class which is a repository for computational elements...
TPZMatrix< STATE > * fGlobMatrix1
Global matrix1.
TPZStructMatrix fStrMatrix
void PermuteScatter(TPZVec< int > &index)
std::set< int > fProcessed1
Elements which are being processed maintained by the first global matrix.
Contains TPZMatrix<TVar>class, root matrix class.
void SerialAssemble(TPZMatrix< STATE > *first, TPZMatrix< STATE > *second, TPZFMatrix< STATE > &rhs)
.. . Sub Structure
void Assemble(TPZMatrix< STATE > *first, TPZMatrix< STATE > *second, TPZFMatrix< STATE > &rhs)
bool ShouldCompute(int matid)
Establish whether the element should be computed.
void SetNumThreads(int numthreads)
int NextElement()
Look for an element index which needs to be computed and put it on the stack.
void SetMaterialIds(const std::set< int > &materialids)
Set the set of material ids which will be considered when assembling the system.
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
TPZSemaphore fAssembly1
Semaphore (to wake up the first assembly thread)
static void * ThreadAssembly1(void *threaddata)
The function which will compute the assembly.
TPZStructMatrix * fStrMatrix
Current structmatrix object.
std::map< int, std::pair< TPZAutoPointer< TPZElementMatrix >, TPZAutoPointer< TPZElementMatrix > > > fSubmitted1
List of computed element matrices (autopointers?)
void ComputedElementMatrix(int iel, TPZAutoPointer< TPZElementMatrix > &ek, TPZAutoPointer< TPZElementMatrix > &ef)
Put the computed element matrices in the map.
This class implements a reference counter mechanism to administer a dynamically allocated object...