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 392 of file generic_projector.h.

Member Typedef Documentation

◆ InsertInput

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

Definition at line 398 of file generic_projector.h.

Constructor & Destructor Documentation

◆ VectorSetAction()

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

Definition at line 400 of file generic_projector.h.

400  :
401  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 403 of file generic_projector.h.

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

405  {
406  // Lock the new vector since it is shared among threads.
407  {
408  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
409  target_vector.set(id, val);
410  }
411  }
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 414 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.

416  {
417  const numeric_index_type
420 
421  unsigned int size = Ue.size();
422 
423  libmesh_assert_equal_to(size, dof_indices.size());
424 
425  // Lock the new vector since it is shared among threads.
426  {
427  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
428 
429  for (unsigned int i = 0; i != size; ++i)
430  if ((dof_indices[i] >= first) && (dof_indices[i] < last))
431  target_vector.set(dof_indices[i], Ue(i));
432  }
433  }
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 395 of file generic_projector.h.

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


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