Loading [MathJax]/extensions/tex2jax.js
libMesh
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Types | 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 Types

typedef DynamicSparseNumberArray< ValIn, dof_id_typeInsertInput
 

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 892 of file system_projection.C.

Member Typedef Documentation

◆ InsertInput

template<typename ValIn, typename ValOut>
typedef DynamicSparseNumberArray<ValIn, dof_id_type> libMesh::MatrixFillAction< ValIn, ValOut >::InsertInput

Definition at line 895 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 900 of file system_projection.C.

900  :
901  target_matrix(target_mat) {}
SparseMatrix< ValOut > & target_matrix

Member Function Documentation

◆ insert() [1/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 903 of file system_projection.C.

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

905  {
906  // Lock the target matrix since it is shared among threads.
907  {
908  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
909 
910  const std::size_t dnsa_size = val.size();
911  for (unsigned int j = 0; j != dnsa_size; ++j)
912  {
913  const dof_id_type dof_j = val.raw_index(j);
914  const ValIn dof_val = val.raw_at(j);
915  target_matrix.set(id, dof_j, dof_val);
916  }
917  }
918  }
SparseMatrix< ValOut > & target_matrix
virtual void set(const numeric_index_type i, const numeric_index_type j, const T value)=0
Set the element (i,j) to value.
uint8_t dof_id_type
Definition: id_types.h:67
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:30

◆ insert() [2/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 921 of file system_projection.C.

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

923  {
924  const numeric_index_type
925  begin_dof = target_matrix.row_start(),
926  end_dof = target_matrix.row_stop();
927 
928  unsigned int size = Ue.size();
929 
930  libmesh_assert_equal_to(size, dof_indices.size());
931 
932  // Lock the target matrix since it is shared among threads.
933  {
934  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
935 
936  for (unsigned int i = 0; i != size; ++i)
937  {
938  const dof_id_type dof_i = dof_indices[i];
939  if ((dof_i >= begin_dof) && (dof_i < end_dof))
940  {
941  const DynamicSparseNumberArray<ValIn,dof_id_type> & dnsa = Ue[i];
942  const std::size_t dnsa_size = dnsa.size();
943  for (unsigned int j = 0; j != dnsa_size; ++j)
944  {
945  const dof_id_type dof_j = dnsa.raw_index(j);
946  const ValIn dof_val = dnsa.raw_at(j);
947  target_matrix.set(dof_i, dof_j, dof_val);
948  }
949  }
950  }
951  }
952  }
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
Set the element (i,j) to value.
dof_id_type numeric_index_type
Definition: id_types.h:99
virtual numeric_index_type row_start() const =0
uint8_t dof_id_type
Definition: id_types.h:67
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:30

Member Data Documentation

◆ target_matrix

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

Definition at line 897 of file system_projection.C.


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