libMesh
Public Member Functions | Private Attributes | List of all members
libMesh::MatrixFillAction< ValIn, ValOut > Class Template Reference

The MatrixFillAction output functor class can be used with GenericProjector to write solution transfer coefficients into a sparse matrix. More...

Public Member Functions

 MatrixFillAction (SparseMatrix< ValOut > &target_mat)
 
void insert (dof_id_type id, const DynamicSparseNumberArray< ValIn, dof_id_type > &val)
 
void insert (const std::vector< dof_id_type > &dof_indices, const std::vector< DynamicSparseNumberArray< ValIn, dof_id_type > > &Ue)
 

Private Attributes

SparseMatrix< ValOut > & target_matrix
 

Detailed Description

template<typename ValIn, typename ValOut>
class libMesh::MatrixFillAction< ValIn, ValOut >

The MatrixFillAction output functor class can be used with GenericProjector to write solution transfer coefficients into a sparse matrix.

Author
Roy H. Stogner
Date
2017

Definition at line 803 of file system_projection.C.

Constructor & Destructor Documentation

◆ MatrixFillAction()

template<typename ValIn, typename ValOut>
libMesh::MatrixFillAction< ValIn, ValOut >::MatrixFillAction ( SparseMatrix< ValOut > &  target_mat)
inline

Definition at line 809 of file system_projection.C.

809  :
810  target_matrix(target_mat) {}

Member Function Documentation

◆ insert() [1/2]

template<typename ValIn, typename ValOut>
void libMesh::MatrixFillAction< ValIn, ValOut >::insert ( const std::vector< dof_id_type > &  dof_indices,
const std::vector< DynamicSparseNumberArray< ValIn, dof_id_type > > &  Ue 
)
inline

Definition at line 830 of file system_projection.C.

832  {
833  const numeric_index_type
834  begin_dof = target_matrix.row_start(),
835  end_dof = target_matrix.row_stop();
836 
837  unsigned int size = Ue.size();
838 
839  libmesh_assert_equal_to(size, dof_indices.size());
840 
841  // Lock the target matrix since it is shared among threads.
842  {
843  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
844 
845  for (unsigned int i = 0; i != size; ++i)
846  {
847  const dof_id_type dof_i = dof_indices[i];
848  if ((dof_i >= begin_dof) && (dof_i < end_dof))
849  {
850  const DynamicSparseNumberArray<ValIn,dof_id_type> & dnsa = Ue[i];
851  const std::size_t dnsa_size = dnsa.size();
852  for (unsigned int j = 0; j != dnsa_size; ++j)
853  {
854  const dof_id_type dof_j = dnsa.raw_index(j);
855  const ValIn dof_val = dnsa.raw_at(j);
856  target_matrix.set(dof_i, dof_j, dof_val);
857  }
858  }
859  }
860  }
861  }

References libMesh::SparseMatrix< T >::row_start(), libMesh::SparseMatrix< T >::row_stop(), libMesh::SparseMatrix< T >::set(), and libMesh::Threads::spin_mtx.

◆ insert() [2/2]

template<typename ValIn, typename ValOut>
void libMesh::MatrixFillAction< ValIn, ValOut >::insert ( dof_id_type  id,
const DynamicSparseNumberArray< ValIn, dof_id_type > &  val 
)
inline

Definition at line 812 of file system_projection.C.

814  {
815  // Lock the target matrix since it is shared among threads.
816  {
817  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
818 
819  const std::size_t dnsa_size = val.size();
820  for (unsigned int j = 0; j != dnsa_size; ++j)
821  {
822  const dof_id_type dof_j = val.raw_index(j);
823  const ValIn dof_val = val.raw_at(j);
824  target_matrix.set(id, dof_j, dof_val);
825  }
826  }
827  }

References libMesh::SparseMatrix< T >::set(), and libMesh::Threads::spin_mtx.

Member Data Documentation

◆ target_matrix

template<typename ValIn, typename ValOut>
SparseMatrix<ValOut>& libMesh::MatrixFillAction< ValIn, ValOut >::target_matrix
private

Definition at line 806 of file system_projection.C.


The documentation for this class was generated from the following file:
libMesh::dof_id_type
uint8_t dof_id_type
Definition: id_types.h:67
libMesh::Threads::spin_mtx
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:29
libMesh::MatrixFillAction::target_matrix
SparseMatrix< ValOut > & target_matrix
Definition: system_projection.C:806
libMesh::numeric_index_type
dof_id_type numeric_index_type
Definition: id_types.h:99
libMesh::SparseMatrix::row_stop
virtual numeric_index_type row_stop() const =0
libMesh::SparseMatrix::set
virtual void set(const numeric_index_type i, const numeric_index_type j, const T value)=0
Set the element (i,j) to value.
libMesh::SparseMatrix::row_start
virtual numeric_index_type row_start() const =0