GEOSX
InterObjectRelation.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2020 TotalEnergies
8  * Copyright (c) 2019- GEOSX Contributors
9  * All rights reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
19 #ifndef GEOS_MESH_INTEROBJECTRELATION_HPP_
20 #define GEOS_MESH_INTEROBJECTRELATION_HPP_
21 
22 
23 #include <map>
25 
26 namespace geos
27 {
28 
33 template< typename BASETYPE >
34 class InterObjectRelation : public BASETYPE
35 {
36 public:
37 
39  using base_type = BASETYPE;
40 
46  template< typename ... ARGS >
47  InterObjectRelation( ARGS && ... args ):
48  BASETYPE( std::forward< ARGS >( args )... )
49  {}
50 
58  {
59  base_type::operator=( rhs.base() );
60  m_relatedObject = rhs.m_relatedObject;
61  return *this;
62  }
63 
68  const base_type & base() const { return static_cast< const BASETYPE & >(*this); }
69 
74  base_type & base() { return dynamic_cast< BASETYPE & >(*this); }
75 
81  { m_relatedObject = &relatedObject; }
82 
88  { return m_relatedObject; }
89 
95  { return this->m_relatedObject->localToGlobalMap(); }
96 
102  { return this->m_relatedObject->globalToLocalMap(); }
103 
104 private:
105  ObjectManagerBase const * m_relatedObject = nullptr;
106 };
107 
113 }
114 
115 #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:369
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:220
InterObjectRelation< array2d< localIndex > > FixedOneToManyRelation
A relationship from single objects to many other objects, where each object is related to the same nu...