GEOS
InterObjectRelation.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 TotalEnergies
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
20 #ifndef GEOS_MESH_INTEROBJECTRELATION_HPP_
21 #define GEOS_MESH_INTEROBJECTRELATION_HPP_
22 
23 
24 #include <map>
26 
27 namespace geos
28 {
29 
34 template< typename BASETYPE >
35 class InterObjectRelation : public BASETYPE
36 {
37 public:
38 
40  using base_type = BASETYPE;
41 
47  template< typename ... ARGS >
48  InterObjectRelation( ARGS && ... args ):
49  BASETYPE( std::forward< ARGS >( args )... )
50  {}
51 
59  {
60  base_type::operator=( rhs.base() );
61  m_relatedObject = rhs.m_relatedObject;
62  return *this;
63  }
64 
69  const base_type & base() const { return static_cast< const BASETYPE & >(*this); }
70 
75  base_type & base() { return dynamic_cast< BASETYPE & >(*this); }
76 
82  { m_relatedObject = &relatedObject; }
83 
89  { return m_relatedObject; }
90 
96  { return this->m_relatedObject->localToGlobalMap(); }
97 
103  { return this->m_relatedObject->globalToLocalMap(); }
104 
105 private:
106  ObjectManagerBase const * m_relatedObject = nullptr;
107 };
108 
114 }
115 
116 #endif /* GEOS_MESH_INTEROBJECTRELATION_HPP_ */
arrayView1d< globalIndex const > relatedObjectLocalToGlobal() const
Get the LocalToGlobal mapping from the related object.
const base_type & base() const
Get a reference to this object cast to BASETYPE const.
const ObjectManagerBase * relatedObject() const
Get the related object.
void setRelatedObject(ObjectManagerBase const &relatedObject)
Set the related object.
base_type & base()
Get a reference to this object cast to BASETYPE.
InterObjectRelation< BASETYPE > & operator=(InterObjectRelation< BASETYPE > const &rhs)
copy assignement operator
BASETYPE base_type
The type of the base class.
unordered_map< globalIndex, localIndex > const & relatedObjectGlobalToLocal() const
Get the GlobalToLocal mapping from the related object.
InterObjectRelation(ARGS &&... args)
A forwarding constructor.
The ObjectManagerBase is the base object of all object managers in the mesh data hierachy.
arrayView1d< globalIndex > localToGlobalMap()
Get local to global map.
unordered_map< globalIndex, localIndex > const & globalToLocalMap() const
Get global to local map.
Base template for ordered and unordered maps.
Definition: DataTypes.hpp:329
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:180
InterObjectRelation< array2d< localIndex > > FixedOneToManyRelation
A relationship from single objects to many other objects, where each object is related to the same nu...