MoReFEM
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Data Fields | Private Member Functions | Static Private Member Functions | Private Attributes
MoReFEM::Coords Class Referencefinal

Define a SpatialPoint in a specific mesh. More...

#include <Coords.hpp>

Inheritance diagram for MoReFEM::Coords:
Collaboration diagram for MoReFEM::Coords:

Public Types

using self = Coords
 Alias to the type of the class.
 
using parent = SpatialPoint
 Alias to parent.
 
using shared_ptr = std::shared_ptr<self>
 Smart pointers used to store objects in Mesh.
 
using vector_shared_ptr = std::vector<shared_ptr>
 Vector of shared_ptr.
 
using unique_ptr = std::unique_ptr<self>
 Convenient smart pointer.
 
using vector_unique_ptr = std::vector<unique_ptr>
 Vector of unique_ptr.
 

Public Member Functions

CoordsNS::index_from_mesh_file GetIndexFromMeshFile () const noexcept
 Index of the Coords as defined in the input mesh.
 
CoordsNS::processor_wise_position GetProcessorWisePosition () const noexcept
 Get the position in the enclosing mesh list (should be in [0; Ncoords - 1] by design.
 
CoordsNS::program_wise_position GetProgramWisePosition () const noexcept
 Get the program-wise position of a Coords.
 
template<CoordsNS::index_enum TypeT>
CoordsNS::index_type< TypeT > GetIndex () const noexcept
 Returns the proper index related to the Coords such as mandated by the template parameter.
 
void SetIndexFromMeshFile (::MoReFEM::CoordsNS::index_from_mesh_file index, bool do_allow_second_call=false) noexcept
 
void SetMeshLabel (const MeshLabel::const_shared_ptr &label)
 
MeshLabel::const_shared_ptr GetMeshLabelPtr () const
 Get the label.
 
void ExtendedPrint (std::ostream &stream) const
 
void AddDomainContainingCoords (DomainNS::unique_id domain_unique_id)
 Add a new Domain that contains the Coords.
 
bool IsInDomain (DomainNS::unique_id domain_unique_id) const
 Whether the given Coords belongs to the domain or not.
 
bool IsInDomain (const Domain &domain) const
 Whether the given Coords belongs to the domain or not.
 
bool IsLowestProcessorRank () const noexcept
 Whether the current processor is the lowest-ranked one to feature current Coords as a processor-wise one.
 
const std::set< DomainNS::unique_id > & GetDomainList () const noexcept
 Get all Domain containing the current Coords.
 
double x () const
 Return the first component of the point.
 
double y () const
 Return the second component of the point (if relevant; if not an exception is thrown).
 
double z () const
 Return the third component of the point (if relevant; if not an exception is thrown).
 
double operator[] (std::size_t i) const
 Constant accessor to the i -th element of the object.
 
double & GetNonCstValue (std::size_t index)
 Non constant access to the value for component.
 
void Print (std::ostream &stream) const
 
const std::array< double, 3 > & GetCoordinateList () const noexcept
 Get the position as a std::array.
 
void Reset ()
 Reset the coords to 0.
 

Static Public Member Functions

static void SetCreateDomainListForCoords ()
 Indicates we should keep track of the Domain to which the Coords belongs.
 
static create_domain_list_for_coords GetCreateDomainListForCoords ()
 Constant accessor on global variable create_domain_list_for_coords.
 
static std::size_t Nobjects ()
 Returns the number of Coords objects in existence. For debug purposes only.
 

Data Fields

friend Mesh
 Friendship to Mesh so that it can update position index.
 

Private Member Functions

template<Internal::CoordsNS::DoCheckFirstCall DoCheckFirstCallT = Internal::CoordsNS::DoCheckFirstCall::yes>
void SetProgramWisePosition (CoordsNS::program_wise_position position) noexcept
 Set the position in the enclosing mesh list.
 
template<Internal::CoordsNS::DoCheckFirstCall DoCheckFirstCallT = Internal::CoordsNS::DoCheckFirstCall::yes>
void SetProcessorWisePosition (CoordsNS::processor_wise_position position) noexcept
 Set the processor-wise position in the enclosing mesh list.
 
const Internal::CoordsNS::CoordIndexesGetCoordIndexes () const noexcept
 Accessor to the object that stores the Coords indexes.
 
Internal::CoordsNS::CoordIndexesGetNonCstCoordIndexes () noexcept
 Non constant accessor to the object that stores the Coords indexes.
 
void SetIsLowestProcessor (bool value)
 

Static Private Member Functions

static create_domain_list_for_coordsGetNonCstCreateDomainListForCoords ()
 Non constant accessor on global variable create_domain_list_for_coords.
 
static std::size_t & GetNonCstNobjects ()
 Returns a reference to the number of Coords objects in existence. For debug purposes only.
 

Private Attributes

Internal::CoordsNS::CoordIndexes coord_indexes_
 Several indexes might be relevant for a given Coords; a struct has therefore been created to group them together and provide explanations about theirs differences.
 
MeshLabel::const_shared_ptr mesh_label_ = nullptr
 Label to which the point belongs to.
 
std::set< DomainNS::unique_iddomain_list_
 List of all Domain containing the current Coords.
 
bool is_lowest_processor_ = true
 Whether current processor is the lowest ranked one that features this Coords as processor-wise.
 
std::array< double, 3 > coordinate_list_
 List of coordinates.
 

Special member functions.

 Coords ()
 Default constructor; all coordinates are set to 0.
 
 Coords (double x, double y, double z, const double space_unit)
 Constructor from components.
 
template<typename T >
 Coords (T &&value, const double space_unit)
 Constructor from an array.
 
 Coords (std::size_t Ncoor, std::istream &stream, const double space_unit)
 Constructor from a input stream.
 
 Coords (const Coords &rhs)=delete
 The copy constructor.
 
 Coords (Coords &&rhs)=delete
 The move constructor.
 
Coordsoperator= (const Coords &rhs)=delete
 The (copy) operator=.
 
Coordsoperator= (Coords &&rhs)=delete
 The (move) operator=.
 
 ~Coords ()
 Destructor.
 

Detailed Description

Define a SpatialPoint in a specific mesh.

Todo
#887 Should probably be advanced, but currently FindCoordsOfGlobalVector requires public and casual access to it. However this class was avoided in Poromechanics; I'll have to check whether the new mechanism would work in CardiacMechanics where FindCoordsOfGlobalVector is applied (the priority of this task is not very high, and I have to retrieve what I did in Poromechanics).

Member Typedef Documentation

◆ self

Alias to the type of the class.

◆ shared_ptr

using MoReFEM::Coords::shared_ptr = std::shared_ptr<self>

Smart pointers used to store objects in Mesh.

By design all Coords object should be stored there.

Constructor & Destructor Documentation

◆ Coords() [1/5]

MoReFEM::Coords::Coords ( double x,
double y,
double z,
const double space_unit )
explicitprivate

Constructor from components.

Parameters
[in]xFirst component.
[in]ySecond component.
[in]zThird component.
Parameters
[in]space_unitThe unit of the mesh, in meters.

◆ Coords() [2/5]

template<typename T >
MoReFEM::Coords::Coords ( T && value,
const double space_unit )
explicitprivate

Constructor from an array.

Template Parameters
TMust be std::array<Floating-point type, 3>.
Parameters
[in]valueValue of the array to set.
Parameters
[in]space_unitThe unit of the mesh, in meters.

◆ Coords() [3/5]

MoReFEM::Coords::Coords ( std::size_t Ncoor,
std::istream & stream,
const double space_unit )
explicitprivate

Constructor from a input stream.

Parameters
[in]NcoorNumber of coordinates to be read. Expected to be at most 3.
[in,out]streamStream from which the point is read. Coordinates are expected to be separated by tabs or spaces. Stream is read until failbit is met; then it is put back at the position just before that failure.
Parameters
[in]space_unitThe unit of the mesh, in meters.

◆ Coords() [4/5]

MoReFEM::Coords::Coords ( const Coords & rhs)
privatedelete

The copy constructor.

Parameters
[in]rhsThe object from which the construction occurs.

◆ Coords() [5/5]

MoReFEM::Coords::Coords ( Coords && rhs)
privatedelete

The move constructor.

Parameters
[in]rhsThe object from which the construction occurs.

Member Function Documentation

◆ operator=() [1/2]

Coords & MoReFEM::Coords::operator= ( const Coords & rhs)
privatedelete

The (copy) operator=.

Parameters
[in]rhsThe object from which the affectation occurs.
Returns
Reference to the object (to enable chained affectation).

◆ operator=() [2/2]

Coords & MoReFEM::Coords::operator= ( Coords && rhs)
privatedelete

The (move) operator=.

Parameters
[in]rhsThe object from which the affectation occurs.
Returns
Reference to the object (to enable chained affectation).

◆ GetIndexFromMeshFile()

CoordsNS::index_from_mesh_file MoReFEM::Coords::GetIndexFromMeshFile ( ) const
noexcept

Index of the Coords as defined in the input mesh.

This index:

  • Stems directly from the input mesh. For instance, Medit ones begins at 1 and are then incremented.
  • Is defined at the program-wise level.
  • Provides no guarantee about contiguousness.

It is fine to identify a Coords uniquely but should not be used for direct access to a Coords in a Coords list.

Remember anyway than MoReFEM strongly suggest to use objects (or pointers to objects) rather than such indexes; this functionality is there for internal use and for interface with output formats.

Returns
The index as it was defined in the original mesh file.

◆ GetProcessorWisePosition()

CoordsNS::processor_wise_position MoReFEM::Coords::GetProcessorWisePosition ( ) const
noexcept

Get the position in the enclosing mesh list (should be in [0; Ncoords - 1] by design.

This method is what should be used to find a Coords in a Mesh container (or in the mesh methods Mesh::GetCoord()).

Remember anyway than MoReFEM strongly suggest to use objects (or pointers to objects) rather than such indexes; this functionality is mostly there for internal use.

Returns
Position of the Coords in the mesh list for processor-wise position.

◆ GetProgramWisePosition()

CoordsNS::program_wise_position MoReFEM::Coords::GetProgramWisePosition ( ) const
noexcept

Get the program-wise position of a Coords.

More precisely, this is the position the Coords had before we proceed to the reduction to processor-wise and ghost Coords.

This is probably not what you sought; most of the time you should use processor-wise one (or even better something that returns an object rather thamn an index).

Returns
Position of the Coords in the mesh list for program-wise position.

◆ GetIndex()

template<CoordsNS::index_enum TypeT>
CoordsNS::index_type< TypeT > MoReFEM::Coords::GetIndex ( ) const
noexcept

Returns the proper index related to the Coords such as mandated by the template parameter.

Returns
The TypeT index related to the Coords.

◆ SetIndexFromMeshFile()

void MoReFEM::Coords::SetIndexFromMeshFile ( ::MoReFEM::CoordsNS::index_from_mesh_file index,
bool do_allow_second_call = false )
noexcept

Set the index used in the initial mesh file (the one from which Mesh object was built).

Parameters
[in]indexNew value of the index.
[in]do_allow_second_callFalse is the default value: the method is expected to be called once per Coords, and it's there checked through an assert. However, when reloading pre- partitioned data we need a second call; only for this specific call this argument should be set to true (this skips the assert).

◆ SetMeshLabel()

void MoReFEM::Coords::SetMeshLabel ( const MeshLabel::const_shared_ptr & label)

Set the label.

Parameters
[in]labelMeshLabel associated to the object.

◆ ExtendedPrint()

void MoReFEM::Coords::ExtendedPrint ( std::ostream & stream) const

Extended Print function: display the coordinates and the index.

Parameters
[in,out]streamStream upon which object information are written.

◆ AddDomainContainingCoords()

void MoReFEM::Coords::AddDomainContainingCoords ( DomainNS::unique_id domain_unique_id)

Add a new Domain that contains the Coords.

Parameters
[in]domain_unique_idUnique id of the Domain to be added.

This method makes sense only if SetCreateDomainListForCoordsToYes() was called.

◆ IsInDomain() [1/2]

bool MoReFEM::Coords::IsInDomain ( DomainNS::unique_id domain_unique_id) const

Whether the given Coords belongs to the domain or not.

Parameters
[in]domain_unique_idA Domain unique ID.

This method makes sense only if SetCreateDomainListForCoordsToYes() was called.

Returns
A boolean.

◆ IsInDomain() [2/2]

bool MoReFEM::Coords::IsInDomain ( const Domain & domain) const

Whether the given Coords belongs to the domain or not.

Parameters
[in]domainDomain for which the test is done.

This method makes sense only if SetCreateDomainListForCoordsToYes() was called.

Returns
A boolean.

◆ SetCreateDomainListForCoords()

static void MoReFEM::Coords::SetCreateDomainListForCoords ( )
static

Indicates we should keep track of the Domain to which the Coords belongs.

This public method should be called only in the base Model class; you shouldn't have to call it directly!

◆ IsLowestProcessorRank()

bool MoReFEM::Coords::IsLowestProcessorRank ( ) const
noexcept

Whether the current processor is the lowest-ranked one to feature current Coords as a processor-wise one.

Despite its public status, this should not be used as it is for low-level usage.

Returns
True if no lowest rank consider current Coords as a processor-wise one. False if the Coords is related only to ghosts.

◆ SetProgramWisePosition()

template<Internal::CoordsNS::DoCheckFirstCall DoCheckFirstCallT = Internal::CoordsNS::DoCheckFirstCall::yes>
void MoReFEM::Coords::SetProgramWisePosition ( CoordsNS::program_wise_position position)
privatenoexcept

Set the position in the enclosing mesh list.

Template Parameters
DoCheckFirstCallTBoolean value which is true by default - false is needed only in the specific case of loading from prepartitioned data.
Parameters
[in]positionPosition of the Coords in the mesh list before any partitioning occurred.

◆ SetProcessorWisePosition()

template<Internal::CoordsNS::DoCheckFirstCall DoCheckFirstCallT = Internal::CoordsNS::DoCheckFirstCall::yes>
void MoReFEM::Coords::SetProcessorWisePosition ( CoordsNS::processor_wise_position position)
privatenoexcept

Set the processor-wise position in the enclosing mesh list.

Template Parameters
DoCheckFirstCallTBoolean value which is true by default - false is needed only in the specific case of loading from prepartitioned data.
Parameters
[in]positionPosition of the Coords in the mesh list processor-wise.

By convention the method may also be called for a ghost - in this case the position in the dedicated Mesh::ghost_coords_list_ is the position given here minus the number of processor-wise Coords (said differently, the numbering is done so that the first ghost Coords is given the index immediately after the last processor-wise Coords.

◆ SetIsLowestProcessor()

void MoReFEM::Coords::SetIsLowestProcessor ( bool value)
private

Internal mutator to the lowest processor that features this Coords as processor-wise.

Parameters
[in]valueWhether current processor is the lowest one or not.

◆ operator[]()

double MoReFEM::SpatialPoint::operator[] ( std::size_t i) const
inherited

Constant accessor to the i -th element of the object.

Parameters
[in]iIndex for of the sought value.
Returns
Value of the i -th element of the object.

i might be 0 (for 'x' component), 1 (for 'y') or 2 (for 'z').

◆ GetNonCstValue()

double & MoReFEM::SpatialPoint::GetNonCstValue ( std::size_t index)
inherited

Non constant access to the value for component.

Parameters
[in]indexIndex of the sought component: 0 for x, 1 for y and 2 for z.

◆ Print()

void MoReFEM::SpatialPoint::Print ( std::ostream & stream) const
inherited

Print function: display the coordinates.

Parameters
[in,out]streamStream upon which object information are written.

Field Documentation

◆ mesh_label_

MeshLabel::const_shared_ptr MoReFEM::Coords::mesh_label_ = nullptr
private

Label to which the point belongs to.

This is optional at the moment: only medit format provides this information. (and it's not entirely clear for me what happens to a point that belongs to two labels).

◆ is_lowest_processor_

bool MoReFEM::Coords::is_lowest_processor_ = true
private

Whether current processor is the lowest ranked one that features this Coords as processor-wise.

This is a purely internal quantity, very useful to make sure for instance Coords aren't counted twice if they are processor-wise on two different processors (might happen if for example related to both a P1 and a P0 shape function in two different NumberingSubset).

'Lowest' here refer to the integer rank; so if a Coords is both on processor 3 and 7, both of them should set this value to 3.


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