libMesh::VectorSetAction< Val > Class Template Reference

#include <generic_projector.h>

Public Member Functions

 VectorSetAction (NumericVector< Val > &target_vec)
 
void insert (const FEMContext &c, unsigned int var_num, 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 110 of file generic_projector.h.

Constructor & Destructor Documentation

◆ VectorSetAction()

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

Definition at line 116 of file generic_projector.h.

116  :
117  target_vector(target_vec) {}
NumericVector< Val > & target_vector

Member Function Documentation

◆ insert()

template<typename Val>
void libMesh::VectorSetAction< Val >::insert ( const FEMContext c,
unsigned int  var_num,
const DenseVector< Val > &  Ue 
)
inline

Definition at line 119 of file generic_projector.h.

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

122  {
123  const numeric_index_type
126 
127  const std::vector<dof_id_type> & dof_indices =
128  c.get_dof_indices(var_num);
129 
130  unsigned int size = Ue.size();
131 
132  libmesh_assert_equal_to(size, dof_indices.size());
133 
134  // Lock the new vector since it is shared among threads.
135  {
136  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
137 
138  for (unsigned int i = 0; i != size; ++i)
139  if ((dof_indices[i] >= first) && (dof_indices[i] < last))
140  target_vector.set(dof_indices[i], Ue(i));
141  }
142  }
NumericVector< Val > & target_vector
spin_mutex spin_mtx
Definition: threads.C:29
dof_id_type numeric_index_type
Definition: id_types.h:92
virtual numeric_index_type first_local_index() const =0
virtual void set(const numeric_index_type i, const T value)=0
virtual numeric_index_type last_local_index() const =0

Member Data Documentation

◆ target_vector

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

Definition at line 113 of file generic_projector.h.

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


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