libMesh::MatrixFillAction< ValIn, ValOut > Class Template Reference

Public Member Functions

 MatrixFillAction (SparseMatrix< ValOut > &target_mat)
 
void insert (const FEMContext &c, unsigned int var_num, const DenseVector< 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 677 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 683 of file system_projection.C.

683  :
684  target_matrix(target_mat) {}
SparseMatrix< ValOut > & target_matrix

Member Function Documentation

◆ insert()

template<typename ValIn, typename ValOut>
void libMesh::MatrixFillAction< ValIn, ValOut >::insert ( const FEMContext c,
unsigned int  var_num,
const DenseVector< DynamicSparseNumberArray< ValIn, dof_id_type > > &  Ue 
)
inline

Definition at line 686 of file system_projection.C.

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

689  {
690  const numeric_index_type
691  begin_dof = target_matrix.row_start(),
692  end_dof = target_matrix.row_stop();
693 
694  const std::vector<dof_id_type> & dof_indices =
695  c.get_dof_indices(var_num);
696 
697  unsigned int size = Ue.size();
698 
699  libmesh_assert_equal_to(size, dof_indices.size());
700 
701  // Lock the target matrix since it is shared among threads.
702  {
703  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
704 
705  for (unsigned int i = 0; i != size; ++i)
706  {
707  const dof_id_type dof_i = dof_indices[i];
708  if ((dof_i >= begin_dof) && (dof_i < end_dof))
709  {
710  const DynamicSparseNumberArray<ValIn,dof_id_type> & dnsa = Ue(i);
711  const std::size_t dnsa_size = dnsa.size();
712  for (unsigned int j = 0; j != dnsa_size; ++j)
713  {
714  const dof_id_type dof_j = dnsa.raw_index(j);
715  const ValIn dof_val = dnsa.raw_at(j);
716  target_matrix.set(dof_i, dof_j, dof_val);
717  }
718  }
719  }
720  }
721  }
SparseMatrix< ValOut > & target_matrix
virtual numeric_index_type row_stop() const =0
virtual void set(const numeric_index_type i, const numeric_index_type j, const T value)=0
spin_mutex spin_mtx
Definition: threads.C:29
dof_id_type numeric_index_type
Definition: id_types.h:92
virtual numeric_index_type row_start() const =0
uint8_t dof_id_type
Definition: id_types.h:64

Member Data Documentation

◆ target_matrix

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

Definition at line 680 of file system_projection.C.


The documentation for this class was generated from the following file: