DOLFIN
DOLFIN C++ interface
Public Member Functions | List of all members
dolfin::MeshValueCollection< T > Class Template Reference

#include <MeshValueCollection.h>

Inheritance diagram for dolfin::MeshValueCollection< T >:
Inheritance graph
[legend]
Collaboration diagram for dolfin::MeshValueCollection< T >:
Collaboration graph
[legend]

Public Member Functions

 MeshValueCollection ()
 
 MeshValueCollection (std::shared_ptr< const Mesh > mesh)
 
 MeshValueCollection (const MeshFunction< T > &mesh_function)
 
 MeshValueCollection (std::shared_ptr< const Mesh > mesh, std::size_t dim)
 
 MeshValueCollection (std::shared_ptr< const Mesh > mesh, const std::string filename)
 
 ~MeshValueCollection ()
 Destructor.
 
MeshValueCollection< T > & operator= (const MeshFunction< T > &mesh_function)
 
MeshValueCollection< T > & operator= (const MeshValueCollection< T > &mesh_value_collection)
 
void init (std::shared_ptr< const Mesh > mesh, std::size_t dim)
 
void init (std::size_t dim)
 
std::size_t dim () const
 
std::shared_ptr< const Meshmesh () const
 
bool empty () const
 
std::size_t size () const
 
bool set_value (std::size_t cell_index, std::size_t local_entity, const T &value)
 
bool set_value (std::size_t entity_index, const T &value)
 
get_value (std::size_t cell_index, std::size_t local_entity)
 
std::map< std::pair< std::size_t, std::size_t >, T > & values ()
 
const std::map< std::pair< std::size_t, std::size_t >, T > & values () const
 
void clear ()
 Clear all values.
 
std::string str (bool verbose) const
 
- Public Member Functions inherited from dolfin::Variable
 Variable ()
 Create unnamed variable.
 
 Variable (const std::string name, const std::string label)
 Create variable with given name and label.
 
 Variable (const Variable &variable)
 Copy constructor.
 
virtual ~Variable ()
 Destructor.
 
const Variableoperator= (const Variable &variable)
 Assignment operator.
 
void rename (const std::string name, const std::string label)
 Rename variable.
 
std::string name () const
 Return name.
 
std::string label () const
 Return label (description)
 
std::size_t id () const
 

Additional Inherited Members

- Public Attributes inherited from dolfin::Variable
Parameters parameters
 Parameters.
 

Detailed Description

template<typename T>
class dolfin::MeshValueCollection< T >

The MeshValueCollection class can be used to store data associated with a subset of the entities of a mesh of a given topological dimension. It differs from the MeshFunction class in two ways. First, data does not need to be associated with all entities (only a subset). Second, data is associated with entities through the corresponding cell index and local entity number (relative to the cell), not by global entity index, which means that data may be stored robustly to file.

Constructor & Destructor Documentation

◆ MeshValueCollection() [1/5]

template<typename T >
dolfin::MeshValueCollection< T >::MeshValueCollection ( )

Create empty mesh value collection

◆ MeshValueCollection() [2/5]

template<typename T >
dolfin::MeshValueCollection< T >::MeshValueCollection ( std::shared_ptr< const Mesh mesh)
explicit

Create an empty mesh value collection on a given mesh

Parameters
mesh(Mesh) The mesh.

◆ MeshValueCollection() [3/5]

template<typename T >
dolfin::MeshValueCollection< T >::MeshValueCollection ( const MeshFunction< T > &  mesh_function)
explicit

Create a mesh value collection from a MeshFunction

Parameters
mesh_function(MeshFunction<T>) The mesh function for creating a MeshValueCollection.

◆ MeshValueCollection() [4/5]

template<typename T >
dolfin::MeshValueCollection< T >::MeshValueCollection ( std::shared_ptr< const Mesh mesh,
std::size_t  dim 
)

Create a mesh value collection of entities of given dimension on a given mesh

Parameters
mesh(Mesh) The mesh associated with the collection.
dim(std::size_t) The mesh entity dimension for the mesh value collection.

◆ MeshValueCollection() [5/5]

template<typename T >
dolfin::MeshValueCollection< T >::MeshValueCollection ( std::shared_ptr< const Mesh mesh,
const std::string  filename 
)

Create a mesh value collection from a file.

Parameters
mesh(Mesh) A mesh associated with the collection. The mesh is used to map collection values to the appropriate process.
filename(std::string) The XML file name.

Member Function Documentation

◆ dim()

template<typename T >
std::size_t dolfin::MeshValueCollection< T >::dim ( ) const

Return topological dimension

Returns
std::size_t The dimension.

◆ empty()

template<typename T >
bool dolfin::MeshValueCollection< T >::empty ( ) const

Return true if the subset is empty

Returns
bool True if the subset is empty.

◆ get_value()

template<typename T >
T dolfin::MeshValueCollection< T >::get_value ( std::size_t  cell_index,
std::size_t  local_entity 
)

Get marker value for given entity defined by a cell index and a local entity index

Parameters
cell_index(std::size_t) The index of the cell.
local_entity(std::size_t) The local index of the entity relative to the cell.
Returns
marker_value (T) The value of the marker.

◆ init() [1/2]

template<typename T >
void dolfin::MeshValueCollection< T >::init ( std::shared_ptr< const Mesh mesh,
std::size_t  dim 
)

Initialise MeshValueCollection with mesh and dimension

Parameters
mesh(_mesh)) The mesh on which the value collection is defined
dim(std::size_t) The mesh entity dimension for the mesh value collection.

◆ init() [2/2]

template<typename T >
void dolfin::MeshValueCollection< T >::init ( std::size_t  dim)

Set dimension. This function should not generally be used. It is for reading MeshValueCollections as the dimension is not generally known at construction.

Parameters
dim(std::size_t) The mesh entity dimension for the mesh value collection.

◆ mesh()

template<typename T >
std::shared_ptr< const Mesh > dolfin::MeshValueCollection< T >::mesh ( ) const

Return associated mesh

Returns
Mesh The mesh.

◆ operator=() [1/2]

template<typename T >
MeshValueCollection< T > & dolfin::MeshValueCollection< T >::operator= ( const MeshFunction< T > &  mesh_function)

Assignment operator

Parameters
mesh_function(MeshFunction) A MeshFunction object used to construct a MeshValueCollection.

◆ operator=() [2/2]

template<typename T >
MeshValueCollection< T > & dolfin::MeshValueCollection< T >::operator= ( const MeshValueCollection< T > &  mesh_value_collection)

Assignment operator

Parameters
mesh_value_collection(MeshValueCollection) A MeshValueCollection object used to construct a MeshValueCollection.

◆ set_value() [1/2]

template<typename T >
bool dolfin::MeshValueCollection< T >::set_value ( std::size_t  cell_index,
std::size_t  local_entity,
const T &  value 
)

Set marker value for given entity defined by a cell index and a local entity index

Parameters
cell_index(std::size_t) The index of the cell.
local_entity(std::size_t) The local index of the entity relative to the cell.
value(T) The value of the marker.
Returns
bool True is a new value is inserted, false if overwriting an existing value.

◆ set_value() [2/2]

template<typename T >
bool dolfin::MeshValueCollection< T >::set_value ( std::size_t  entity_index,
const T &  value 
)

Set value for given entity index

Parameters
entity_index(std::size_t) Index of the entity.
value(T). The value of the marker.
Returns
bool True is a new value is inserted, false if overwriting an existing value.

◆ size()

template<typename T >
std::size_t dolfin::MeshValueCollection< T >::size ( ) const

Return size (number of entities in subset)

Returns
std::size_t The size.

◆ str()

template<typename T >
std::string dolfin::MeshValueCollection< T >::str ( bool  verbose) const
virtual

Return informal string representation (pretty-print)

Parameters
verbose(bool) Flag to turn on additional output.
Returns
std::string An informal representation.

Reimplemented from dolfin::Variable.

◆ values() [1/2]

template<typename T >
std::map< std::pair< std::size_t, std::size_t >, T > & dolfin::MeshValueCollection< T >::values ( )

Get all values

Returns
std::map<std::pair<std::size_t, std::size_t>, T> A map from positions to values.

◆ values() [2/2]

template<typename T >
const std::map< std::pair< std::size_t, std::size_t >, T > & dolfin::MeshValueCollection< T >::values ( ) const

Get all values (const version)

Returns
std::map<std::pair<std::size_t, std::size_t>, T> A map from positions to values.

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