libMesh::SumShellMatrix< T > Class Template Reference

#include <sum_shell_matrix.h>

Inheritance diagram for libMesh::SumShellMatrix< T >:

List of all members.

Public Member Functions

 SumShellMatrix (void)
 SumShellMatrix (const std::vector< ShellMatrix< T > * > &mat)
virtual ~SumShellMatrix ()
virtual numeric_index_type m () const
virtual numeric_index_type n () const
virtual void vector_mult (NumericVector< T > &dest, const NumericVector< T > &arg) const
virtual void vector_mult_add (NumericVector< T > &dest, const NumericVector< T > &arg) const
virtual void get_diagonal (NumericVector< T > &dest) const

Static Public Member Functions

static std::string get_info ()
static void print_info (std::ostream &out=libMesh::out)
static unsigned int n_objects ()
static void enable_print_counter_info ()
static void disable_print_counter_info ()

Public Attributes

std::vector< ShellMatrix< T > * > matrices

Protected Types

typedef std::map< std::string,
std::pair< unsigned int,
unsigned int > > 
Counts

Protected Member Functions

void increment_constructor_count (const std::string &name)
void increment_destructor_count (const std::string &name)

Static Protected Attributes

static Counts _counts
static Threads::atomic
< unsigned int > 
_n_objects
static Threads::spin_mutex _mutex
static bool _enable_print_counter = true

Detailed Description

template<typename T>
class libMesh::SumShellMatrix< T >

This class combines any number of shell matrices to a single shell matrix, acting as the sum of the matrices.

Author:
Tim Kroeger, 2008

Definition at line 45 of file sum_shell_matrix.h.


Member Typedef Documentation

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts [protected, inherited]

Data structure to log the information. The log is identified by the class name.

Definition at line 113 of file reference_counter.h.


Constructor & Destructor Documentation

template<typename T >
libMesh::SumShellMatrix< T >::SumShellMatrix ( void   )  [inline]

Constructor; initializes an empty sum. Note that an empty sum is not a valid object in that a call to m() or n() will result in an error. However, an empty sum is allowed to be multiplied with a vector and will give the expected result.

Definition at line 110 of file sum_shell_matrix.h.

00110                                       :
00111   ShellMatrix<T>(),
00112   matrices()
00113 {}

template<typename T >
libMesh::SumShellMatrix< T >::SumShellMatrix ( const std::vector< ShellMatrix< T > * > &  mat  )  [inline, explicit]

Constructor that passes a vector of shell matrices.

Definition at line 119 of file sum_shell_matrix.h.

00119                                                                        :
00120   ShellMatrix<T>(),
00121   matrices(mat)
00122 {}

template<typename T >
libMesh::SumShellMatrix< T >::~SumShellMatrix (  )  [inline, virtual]

Destructor.

Definition at line 128 of file sum_shell_matrix.h.

00129 {}


Member Function Documentation

void libMesh::ReferenceCounter::disable_print_counter_info (  )  [static, inherited]

Definition at line 106 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

00107 {
00108   _enable_print_counter = false;
00109   return;
00110 }

void libMesh::ReferenceCounter::enable_print_counter_info (  )  [static, inherited]

Methods to enable/disable the reference counter output from print_info()

Definition at line 100 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

00101 {
00102   _enable_print_counter = true;
00103   return;
00104 }

template<typename T >
void libMesh::SumShellMatrix< T >::get_diagonal ( NumericVector< T > &  dest  )  const [inline, virtual]

Copies the diagonal part of the matrix into dest.

Implements libMesh::ShellMatrix< T >.

Definition at line 78 of file sum_shell_matrix.C.

References libMesh::NumericVector< T >::clone(), libMesh::SumShellMatrix< T >::matrices, and libMesh::NumericVector< T >::zero().

00079 {
00080   AutoPtr<NumericVector<T> > a = dest.clone();
00081   dest.zero();
00082   for(numeric_index_type i=matrices.size(); i-->0; )
00083     {
00084       matrices[i]->get_diagonal(*a);
00085       dest += *a;
00086     }
00087 }

std::string libMesh::ReferenceCounter::get_info (  )  [static, inherited]

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

References libMesh::ReferenceCounter::_counts, and libMesh::Quality::name().

Referenced by libMesh::ReferenceCounter::print_info().

00048 {
00049 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
00050 
00051   std::ostringstream oss;
00052 
00053   oss << '\n'
00054       << " ---------------------------------------------------------------------------- \n"
00055       << "| Reference count information                                                |\n"
00056       << " ---------------------------------------------------------------------------- \n";
00057 
00058   for (Counts::iterator it = _counts.begin();
00059        it != _counts.end(); ++it)
00060     {
00061       const std::string name(it->first);
00062       const unsigned int creations    = it->second.first;
00063       const unsigned int destructions = it->second.second;
00064 
00065       oss << "| " << name << " reference count information:\n"
00066           << "|  Creations:    " << creations    << '\n'
00067           << "|  Destructions: " << destructions << '\n';
00068     }
00069 
00070   oss << " ---------------------------------------------------------------------------- \n";
00071 
00072   return oss.str();
00073 
00074 #else
00075 
00076   return "";
00077 
00078 #endif
00079 }

void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name  )  [inline, protected, inherited]

Increments the construction counter. Should be called in the constructor of any derived class that will be reference counted.

Definition at line 163 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

00164 {
00165   Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
00166   std::pair<unsigned int, unsigned int>& p = _counts[name];
00167 
00168   p.first++;
00169 }

void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name  )  [inline, protected, inherited]

Increments the destruction counter. Should be called in the destructor of any derived class that will be reference counted.

Definition at line 176 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

00177 {
00178   Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
00179   std::pair<unsigned int, unsigned int>& p = _counts[name];
00180 
00181   p.second++;
00182 }

template<typename T >
numeric_index_type libMesh::SumShellMatrix< T >::m (  )  const [inline, virtual]
Returns:
m, the row-dimension of the matrix where the marix is $ M \times N $.

Implements libMesh::ShellMatrix< T >.

Definition at line 28 of file sum_shell_matrix.C.

References libMesh::SumShellMatrix< T >::matrices.

00029 {
00030   libmesh_assert(!matrices.empty());
00031   const numeric_index_type result = matrices[0]->m();
00032   for(numeric_index_type i=matrices.size(); i-->1; )
00033     {
00034       libmesh_assert_equal_to (matrices[i]->m(), result);
00035     }
00036   return result;
00037 }

template<typename T >
numeric_index_type libMesh::SumShellMatrix< T >::n (  )  const [inline, virtual]
Returns:
n, the column-dimension of the matrix where the marix is $ M \times N $.

Implements libMesh::ShellMatrix< T >.

Definition at line 42 of file sum_shell_matrix.C.

References libMesh::SumShellMatrix< T >::matrices.

00043 {
00044   libmesh_assert(!matrices.empty());
00045   const numeric_index_type result = matrices[0]->n();
00046   for(numeric_index_type i=matrices.size(); i-->1; )
00047     {
00048       libmesh_assert_equal_to (matrices[i]->n(), result);
00049     }
00050   return result;
00051 }

static unsigned int libMesh::ReferenceCounter::n_objects (  )  [inline, static, inherited]

Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 79 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

00080   { return _n_objects; }

void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out  )  [static, inherited]

Prints the reference information, by default to libMesh::out.

Definition at line 88 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().

00089 {
00090   if( _enable_print_counter ) out_stream << ReferenceCounter::get_info();
00091 }

template<typename T >
void libMesh::SumShellMatrix< T >::vector_mult ( NumericVector< T > &  dest,
const NumericVector< T > &  arg 
) const [inline, virtual]

Multiplies the matrix with arg and stores the result in dest.

Implements libMesh::ShellMatrix< T >.

Definition at line 56 of file sum_shell_matrix.C.

References libMesh::SumShellMatrix< T >::vector_mult_add(), and libMesh::NumericVector< T >::zero().

00058 {
00059   dest.zero();
00060   this->vector_mult_add(dest,arg);
00061 }

template<typename T >
void libMesh::SumShellMatrix< T >::vector_mult_add ( NumericVector< T > &  dest,
const NumericVector< T > &  arg 
) const [inline, virtual]

Multiplies the matrix with arg and adds the result to dest.

Implements libMesh::ShellMatrix< T >.

Definition at line 66 of file sum_shell_matrix.C.

References libMesh::SumShellMatrix< T >::matrices.

Referenced by libMesh::SumShellMatrix< T >::vector_mult().

00068 {
00069   for(numeric_index_type i=matrices.size(); i-->0; )
00070     {
00071       matrices[i]->vector_mult_add(dest,arg);
00072     }
00073 }


Member Data Documentation

bool libMesh::ReferenceCounter::_enable_print_counter = true [static, protected, inherited]

Flag to control whether reference count information is printed when print_info is called.

Definition at line 137 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 131 of file reference_counter.h.

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects [static, protected, inherited]

The number of objects. Print the reference count information when the number returns to 0.

Definition at line 126 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().


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

Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:39 UTC

Hosted By:
SourceForge.net Logo