24#ifndef _GEMA_PLUGIN_FEM_LOCKER_H_
25#define _GEMA_PLUGIN_FEM_LOCKER_H_
51 assert(npart && numdof);
54 if(npart + 1 > _lockList.size())
56 _lockList.resize(npart + 1);
57 for(
int i = _npart; i < npart + 1; i++)
61 _psize = (numdof+npart-1) / npart;
69 void lockDof(
int dofIndex) { _lockList[dofToLockIndex(dofIndex)]->lock(); }
72 void unlockDof(
int dofIndex) { _lockList[dofToLockIndex(dofIndex)]->unlock(); }
78 int dofToLockIndex(
int dofIndex)
80 assert(_psize && _npart);
81 assert(_npart <= _lockList.size());
82 int r = (dofIndex < 0) ? 0 : (dofIndex / _psize) + 1;
83 assert(r >= 0 && r < _npart);
static bool inMainThread()
A lock manager to be used by GmpFemAssemblerMatrixAdder and GmpFemAssemblerVectorAdder objects when w...
Definition gmpFemLocker.h:39
int _psize
The number of dofs in each partition.
Definition gmpFemLocker.h:87
int numPartitions() const
Returns the number of configured partitions.
Definition gmpFemLocker.h:66
QVector< GmSpinLock * > _lockList
The set of available locks.
Definition gmpFemLocker.h:89
void setNumPartitions(int numdof, int npart)
Adjusts the number of locks according to the number of degrees of freedom and partitions.
Definition gmpFemLocker.h:48
void unlockDof(int dofIndex)
Releases the lock protecting the given dof index.
Definition gmpFemLocker.h:72
int _npart
The number of partitions (including the extra partition for negative numbers)
Definition gmpFemLocker.h:88
~GmpFemLocker()
Destructor.
Definition gmpFemLocker.h:45
GmpFemLocker()
Constructor.
Definition gmpFemLocker.h:42
void lockDof(int dofIndex)
Aquires the lock protecting the given dof index.
Definition gmpFemLocker.h:69
Declaration of useful configuration definitions for the plugin library.