LifeV
MeshEntityContainer< DataType, Allocator > Class Template Reference

#include <MeshEntityContainer.hpp>

+ Inheritance diagram for MeshEntityContainer< DataType, Allocator >:
+ Collaboration diagram for MeshEntityContainer< DataType, Allocator >:

Public Member Functions

template<typename Policy >
UInt countElementsWithMarkerID (const markerID_Type &markerID, const Policy &policy=std::equal_to< markerID_Type >()) const
 It counts all elements with a markerID. More...
 

Public Types

typedef DataType data_Type
 
typedef std::vector< DataType, Allocator > vector_Type
 
typedef vector_Type::size_type size_type
 
typedef vector_Type::value_type value_type
 
typedef vector_Type::reference reference
 
typedef vector_Type::const_reference const_reference
 
typedef vector_Type::iterator iterator
 
typedef vector_Type::const_iterator const_iterator
 
typedef vector_Type::const_reverse_iterator const_reverse_iterator
 
typedef vector_Type::pointer pointer
 
typedef vector_Type::const_pointer const_pointer
 
typedef vector_Type::reverse_iterator reverse_iterator
 
typedef vector_Type::allocator_type allocator_type
 

Constructor & Destructor

 MeshEntityContainer ()
 Empty Constructor. More...
 
 MeshEntityContainer (size_type vectorSize)
 Constructor. More...
 
 MeshEntityContainer (const MeshEntityContainer< DataType, Allocator > &vector)
 Copy constructor. More...
 
 MeshEntityContainer (const vector_Type &vector)
 Constructor. More...
 
 ~MeshEntityContainer ()
 Destructor. More...
 

Operators

MeshEntityContainer< DataType, Allocator > & operator= (const MeshEntityContainer< DataType, Allocator > &vector)
 Assignment operator. More...
 
reference operator() (size_type const i)
 Access operator. More...
 
const_reference operator() (size_type const i) const
 Const access operator. More...
 

Methods

void destroyData ()
 Completely clear out the container, returning memory to the system. More...
 
void trim ()
 trims the container so that capacity almost equals size More...
 
bool setMaxNumItems (UInt size)
 It sets the capacity of the container It returns a bool to allow to test whether the container data pool has changed since in this case pointers to the container elements are invalidated It does not change the value of the elements currently stored, nor the container size. More...
 

Extractors

Utilities to extract from the SimpleVector.

They rely on std::algorithms

template<typename Predicate >
std::vector< DataType const * > extractAccordingToPredicate (Predicate const &p) const
 General extractor. More...
 
template<typename Predicate >
std::vector< DataType * > extractAccordingToPredicateNonConstElement (Predicate const &p, std::vector< UInt > &indexes)
 
template<typename Predicate >
UInt countAccordingToPredicate (Predicate const &p) const
 Entity Counter. More...
 
template<typename Policy >
std::vector< DataType const * > extractElementsWithFlag (const flag_Type &refFlag, Policy const &policy=&Flag::testOneSet) const
 It extracts all elements that satisfy a condition on the flag. More...
 
template<typename Policy >
UInt countElementsWithFlag (const flag_Type &refFlag, Policy const &policy=&Flag::testOneSet) const
 It counts all elements that satisfy a condition on the flag. More...
 

Changers

Utilities that change the elements according to policies

template<typename Policy >
std::pair< UInt, std::vector< ID > > reorderAccordingToFlag (const flag_Type &refFlag, Policy const &policy=&Flag::testOneSet, UInt offset=0)
 Set element with certain flag set first. More...
 
template<typename Functor >
void changeAccordingToFunctor (Functor const &fun)
 Changes content according to a given functor. More...
 
std::vector< UIntresetId ()
 Resets the id of the mesh entities so that it matches the position in the container. More...
 

Detailed Description

template<typename DataType, class Allocator = std::allocator<DataType>>
class LifeV::MeshEntityContainer< DataType, Allocator >

Author
Luca Formaggia

The class is a wrap up of Standard Library vector class. Its role is to held meshEntities. Its old name VectorSimple has been changed to MeshEntityContainer Any other use of class is deprecated and it should be replaced by std::vector<T>

Definition at line 228 of file MeshEntityContainer.hpp.

Member Typedef Documentation

◆ data_Type

typedef DataType data_Type

Definition at line 235 of file MeshEntityContainer.hpp.

◆ vector_Type

typedef std::vector<DataType, Allocator> vector_Type

Definition at line 236 of file MeshEntityContainer.hpp.

◆ size_type

typedef vector_Type::size_type size_type

Definition at line 237 of file MeshEntityContainer.hpp.

◆ value_type

typedef vector_Type::value_type value_type

Definition at line 238 of file MeshEntityContainer.hpp.

◆ reference

typedef vector_Type::reference reference

Definition at line 239 of file MeshEntityContainer.hpp.

◆ const_reference

typedef vector_Type::const_reference const_reference

Definition at line 240 of file MeshEntityContainer.hpp.

◆ iterator

typedef vector_Type::iterator iterator

Definition at line 241 of file MeshEntityContainer.hpp.

◆ const_iterator

typedef vector_Type::const_iterator const_iterator

Definition at line 242 of file MeshEntityContainer.hpp.

◆ const_reverse_iterator

typedef vector_Type::const_reverse_iterator const_reverse_iterator

Definition at line 243 of file MeshEntityContainer.hpp.

◆ pointer

typedef vector_Type::pointer pointer

Definition at line 244 of file MeshEntityContainer.hpp.

◆ const_pointer

typedef vector_Type::const_pointer const_pointer

Definition at line 245 of file MeshEntityContainer.hpp.

◆ reverse_iterator

typedef vector_Type::reverse_iterator reverse_iterator

Definition at line 246 of file MeshEntityContainer.hpp.

◆ allocator_type

typedef vector_Type::allocator_type allocator_type

Definition at line 247 of file MeshEntityContainer.hpp.

Constructor & Destructor Documentation

◆ MeshEntityContainer() [1/4]

MeshEntityContainer ( )
inline

Empty Constructor.

Definition at line 254 of file MeshEntityContainer.hpp.

◆ MeshEntityContainer() [2/4]

MeshEntityContainer ( size_type  vectorSize)
inlineexplicit

Constructor.

Parameters
vectorSizesize of the vector

Definition at line 260 of file MeshEntityContainer.hpp.

◆ MeshEntityContainer() [3/4]

MeshEntityContainer ( const MeshEntityContainer< DataType, Allocator > &  vector)

Copy constructor.

Parameters
vectorMeshEntityContainer vector to copy

Definition at line 639 of file MeshEntityContainer.hpp.

◆ MeshEntityContainer() [4/4]

MeshEntityContainer ( const vector_Type vector)
explicit

Constructor.

Construct by copying a Standard Library vector

Parameters
vectorStandard Library vector

◆ ~MeshEntityContainer()

~MeshEntityContainer ( )
inline

Destructor.

Definition at line 276 of file MeshEntityContainer.hpp.

Member Function Documentation

◆ operator=()

MeshEntityContainer< DataType, Allocator > & operator= ( const MeshEntityContainer< DataType, Allocator > &  vector)

Assignment operator.

Copies source MeshEntityContainer vector into "this"

Parameters
vectorMeshEntityContainer vector
Returns
Reference to a new MeshEntityContainer vector with the same content of MeshEntityContainer vector

Definition at line 649 of file MeshEntityContainer.hpp.

◆ operator()() [1/2]

reference operator() ( size_type const  i)
inline

Access operator.

Example: a(10)=90; // a[10] will contain 90.0

Parameters
iindex of the element of the MeshEntityContainer vector
Returns
a vector reference
Note
deprecated
Todo:
Eliminate!

Definition at line 301 of file MeshEntityContainer.hpp.

◆ operator()() [2/2]

const_reference operator() ( size_type const  i) const
inline

Const access operator.

Example: a(10)=90; // a[10] will contain 90.0

Parameters
iindex of the element of the MeshEntityContainer vector
Returns
a vector const reference
Note
deprecated
Todo:
Eliminate!

Definition at line 314 of file MeshEntityContainer.hpp.

◆ destroyData()

void destroyData ( )
inline

Completely clear out the container, returning memory to the system.

Definition at line 661 of file MeshEntityContainer.hpp.

◆ trim()

void trim ( )
inline

trims the container so that capacity almost equals size

Definition at line 329 of file MeshEntityContainer.hpp.

◆ setMaxNumItems()

bool setMaxNumItems ( UInt  size)

It sets the capacity of the container It returns a bool to allow to test whether the container data pool has changed since in this case pointers to the container elements are invalidated It does not change the value of the elements currently stored, nor the container size.

Parameters
sizethe new capacity of the container
Returns
a bool which is true if the data pool has changed

Definition at line 668 of file MeshEntityContainer.hpp.

◆ extractAccordingToPredicate()

std::vector< DataType const * > extractAccordingToPredicate ( Predicate const &  p) const

General extractor.

It extracts the a vector of pointers to the stored entities for which a predicate: i.e. a pointer to function with signature

bool predicate(DataType const &)

or functor object with

bool operator()(DataType const &)

returns true

The template parameter is the Predicate type (automatically deduced)

aPredicate p; // A certain predicate
vector<face_Type *> theList=mesh.faceList.extractIdAccordingToPredicate(p);
Parameters
pThe predicate
Returns
A vector of pointers to constant mesh entities of the same type of those in the container

Definition at line 678 of file MeshEntityContainer.hpp.

◆ extractAccordingToPredicateNonConstElement()

std::vector< DataType * > extractAccordingToPredicateNonConstElement ( Predicate const &  p,
std::vector< UInt > &  indexes 
)

Definition at line 695 of file MeshEntityContainer.hpp.

◆ countAccordingToPredicate()

UInt countAccordingToPredicate ( Predicate const &  p) const

Entity Counter.

It returns the number of stored entities for which a predicate returns true The template parameter is the Predicate type (automatically deduced): a function object or a pointer to function taking a constant reference to a mesh entity and returning a bool

Parameters
pThe predicate
Returns
Number of entities in the container satisfying the predicate

Definition at line 716 of file MeshEntityContainer.hpp.

◆ extractElementsWithFlag()

std::vector< DataType const * > extractElementsWithFlag ( const flag_Type refFlag,
Policy const &  policy = &Flag::testOneSet 
) const

It extracts all elements that satisfy a condition on the flag.

It operates only container elements where the method flag_Type flag() is defined. Examples:

#include "MeshEntity.hpp"
v=sv.extractElementsWithFlag(PHYSICAL_BOUNDARY,Flag::testOneSet)

will extracts all elements in the boundary

v=sv.extractElementsWithFlag(PHYSICAL_BOUNDARY|INTERNAL_INTERFACE, testOneSet)

will extracts all elements on the boundary or on an internal interface

Parameters
refFlagthe flag against which the test is made
policy.A functor/function pointer which implements bool policy(const flag_Type & inputFlag, const flag_Type & refFlag) Available policies are Flag::testOneSet and Flag::testAllSet (defined in Lifev.hpp)
Returns
a vector containing the pointers to constant mesh entities in the container whose flag is set as that of refFlag according to the given policy

Definition at line 724 of file MeshEntityContainer.hpp.

◆ countElementsWithFlag()

UInt countElementsWithFlag ( const flag_Type refFlag,
Policy const &  policy = &Flag::testOneSet 
) const

It counts all elements that satisfy a condition on the flag.

It only operates on container elements where the method flag_Type flag() is defined. Examples:

#include "MeshEntity.hpp"
Uint i=sv.countElementsWithFlag(PHYSICAL_BOUNDARY,Flag::testOneSet)

will count all elements on the boundary

Parameters
refFlagthe flag against which the test is made
policy.A functor/function pointer which implements bool policy(const flag_Type & inputFlag, const flag_Type & refFlag) Available policies testOneSet and testAllSet (defined in Lifev.hpp)
Returns
an unsigned integer

Definition at line 733 of file MeshEntityContainer.hpp.

◆ countElementsWithMarkerID()

UInt countElementsWithMarkerID ( const markerID_Type markerID,
const Policy &  policy = std::equal_to<markerID_Type>() 
) const

It counts all elements with a markerID.

Parameters
markerIDthe markerID against which the test is made
policy.A functor/function pointer which implements bool policy(const markerID_Type & inputMarkerID, const markerID_Type & refMarkerID) By default it uses std::equal_to
Returns
an unsigned integer

Definition at line 742 of file MeshEntityContainer.hpp.

◆ reorderAccordingToFlag()

std::pair< UInt, std::vector< ID > > reorderAccordingToFlag ( const flag_Type refFlag,
Policy const &  policy = &Flag::testOneSet,
UInt  offset = 0 
)

Set element with certain flag set first.

It reorders the container starting from the given offset up to the end of the container so that elements with the given flag set are first. A policy must be passed. Typically either testOneSet or testAllSet. A policy object must have a method

bool operator()(DataType const & i, DataType const & r)

which compares the boolean flag i with the reference flag r. It fixes the id of the stored entities and it returns the newToOld array in case we need to fix some related id

Parameters
refFlagthe reference flag against which comparison is made.
offsetWe reorder only elements from offset to the end of the container.
policyThe policy we use for comparing the flag of the mesh entity with the reference flag.
Returns
A pair with the new offset, i.e the starting point of the elements for which predicate was false, and a NewToOld vector with the new->old position. Entity now in position i was before in NewToOld[i].

Definition at line 752 of file MeshEntityContainer.hpp.

◆ changeAccordingToFunctor()

void changeAccordingToFunctor ( Functor const &  fun)
inline

Changes content according to a given functor.

This method is here for people which do not remember how std::for_each works. It takes as argument a functor that must have the method

void operator()(DataType & d)

and which changes d according to the user will.

Parameters
funThe functor which implements the change

Definition at line 492 of file MeshEntityContainer.hpp.

◆ resetId()

std::vector<UInt> resetId ( )
inline

Resets the id of the mesh entities so that it matches the position in the container.

After its call the id of each mesh entity matches its position in the container. The mesh entity must have the method ID & id()

Returns
a vector containing the association new->old. The entity that is now in position id was originally in position newtoold[id]

Definition at line 504 of file MeshEntityContainer.hpp.


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