libMesh
Public Types | Public Member Functions | Private Attributes | List of all members
libMesh::VectorSetAction< Val > Class Template Reference

The VectorSetAction output functor class can be used with a GenericProjector to set projection values (which must be of type Val) as coefficients of the given NumericVector. More...

#include <generic_projector.h>

Public Types

typedef Val InsertInput
 

Public Member Functions

 VectorSetAction (NumericVector< Val > &target_vec)
 
void insert (dof_id_type id, Val val)
 
void insert (const std::vector< dof_id_type > &dof_indices, const DenseVector< Val > &Ue)
 

Private Attributes

NumericVector< Val > & target_vector
 

Detailed Description

template<typename Val>
class libMesh::VectorSetAction< Val >

The VectorSetAction output functor class can be used with a GenericProjector to set projection values (which must be of type Val) as coefficients of the given NumericVector.

Author
Roy H. Stogner
Date
2016

Definition at line 405 of file generic_projector.h.

Member Typedef Documentation

◆ InsertInput

template<typename Val>
typedef Val libMesh::VectorSetAction< Val >::InsertInput

Definition at line 411 of file generic_projector.h.

Constructor & Destructor Documentation

◆ VectorSetAction()

template<typename Val>
libMesh::VectorSetAction< Val >::VectorSetAction ( NumericVector< Val > &  target_vec)
inline

Definition at line 413 of file generic_projector.h.

413  :
414  target_vector(target_vec) {}
NumericVector< Val > & target_vector

Member Function Documentation

◆ insert() [1/2]

template<typename Val>
void libMesh::VectorSetAction< Val >::insert ( dof_id_type  id,
Val  val 
)
inline

Definition at line 416 of file generic_projector.h.

References libMesh::NumericVector< T >::set(), libMesh::Threads::spin_mtx, and libMesh::VectorSetAction< Val >::target_vector.

418  {
419  // Lock the new vector since it is shared among threads.
420  {
421  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
422  target_vector.set(id, val);
423  }
424  }
NumericVector< Val > & target_vector
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
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 Val>
void libMesh::VectorSetAction< Val >::insert ( const std::vector< dof_id_type > &  dof_indices,
const DenseVector< Val > &  Ue 
)
inline

Definition at line 427 of file generic_projector.h.

References libMesh::NumericVector< T >::first_local_index(), libMesh::NumericVector< T >::last_local_index(), libMesh::NumericVector< T >::set(), libMesh::DenseVector< T >::size(), libMesh::Threads::spin_mtx, and libMesh::VectorSetAction< Val >::target_vector.

429  {
430  const numeric_index_type
433 
434  unsigned int size = Ue.size();
435 
436  libmesh_assert_equal_to(size, dof_indices.size());
437 
438  // Lock the new vector since it is shared among threads.
439  {
440  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
441 
442  for (unsigned int i = 0; i != size; ++i)
443  if ((dof_indices[i] >= first) && (dof_indices[i] < last))
444  target_vector.set(dof_indices[i], Ue(i));
445  }
446  }
NumericVector< Val > & target_vector
dof_id_type numeric_index_type
Definition: id_types.h:99
virtual numeric_index_type first_local_index() const =0
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
virtual numeric_index_type last_local_index() const =0
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:30

Member Data Documentation

◆ target_vector

template<typename Val>
NumericVector<Val>& libMesh::VectorSetAction< Val >::target_vector
private

Definition at line 408 of file generic_projector.h.

Referenced by libMesh::VectorSetAction< Val >::insert().


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