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

Constructor & Destructor Documentation

◆ VectorSetAction()

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

Definition at line 370 of file generic_projector.h.

370  :
371  target_vector(target_vec) {}

Member Function Documentation

◆ insert() [1/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 384 of file generic_projector.h.

386  {
387  const numeric_index_type
390 
391  unsigned int size = Ue.size();
392 
393  libmesh_assert_equal_to(size, dof_indices.size());
394 
395  // Lock the new vector since it is shared among threads.
396  {
397  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
398 
399  for (unsigned int i = 0; i != size; ++i)
400  if ((dof_indices[i] >= first) && (dof_indices[i] < last))
401  target_vector.set(dof_indices[i], Ue(i));
402  }
403  }

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.

◆ insert() [2/2]

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

Definition at line 373 of file generic_projector.h.

375  {
376  // Lock the new vector since it is shared among threads.
377  {
378  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
379  target_vector.set(id, val);
380  }
381  }

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

Member Data Documentation

◆ target_vector

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

Definition at line 367 of file generic_projector.h.

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


The documentation for this class was generated from the following file:
libMesh::VectorSetAction::target_vector
NumericVector< Val > & target_vector
Definition: generic_projector.h:367
libMesh::NumericVector::last_local_index
virtual numeric_index_type last_local_index() const =0
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::numeric_index_type
dof_id_type numeric_index_type
Definition: id_types.h:99
libMesh::NumericVector::set
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
libMesh::NumericVector::first_local_index
virtual numeric_index_type first_local_index() const =0