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 Total, S.A
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 GEOSX_MESH_INTEROBJECTRELATION_HPP_
20 #define GEOSX_MESH_INTEROBJECTRELATION_HPP_
21 
22 
23 #include <map>
25 
26 namespace geosx
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 
55  const base_type & Base() const { return static_cast< const BASETYPE & >(*this); }
56 
61  base_type & Base() { return dynamic_cast< BASETYPE & >(*this); }
62 
67  void SetRelatedObject( ObjectManagerBase const * const relatedObject )
68  { m_relatedObject = relatedObject; }
69 
75  { return m_relatedObject; }
76 
82  { return this->m_relatedObject->localToGlobalMap(); }
83 
89  { return this->m_relatedObject->globalToLocalMap(); }
90 
91 private:
92  ObjectManagerBase const * m_relatedObject = nullptr;
93 };
94 
100 }
101 
102 #endif /* GEOSX_MESH_INTEROBJECTRELATION_HPP_ */
InterObjectRelation(ARGS &&... args)
A forwarding constructor.
unordered_map< globalIndex, localIndex > const & RelatedObjectGlobalToLocal() const
Get the GlobalToLocal mapping from the related object.
InterObjectRelation< array2d< localIndex > > FixedOneToManyRelation
A relationship from single objects to many other objects, where each object is related to the same nu...
arrayView1d< globalIndex const > RelatedObjectLocalToGlobal() const
Get the LocalToGlobal mapping from the related object.
Base template for ordered and unordered maps.
Definition: DataTypes.hpp:349
This class implements an array of arrays like object with contiguous storage.
This class serves to provide a "view" of a multidimensional array.
Definition: ArrayView.hpp:67
The ObjectManagerBase is the base object of all object managers in the mesh data hierachy.
void SetRelatedObject(ObjectManagerBase const *const relatedObject)
Set the related object.
unordered_map< globalIndex, localIndex > const & globalToLocalMap() const
Get global to local map.
base_type & Base()
Get a reference to this object cast to BASETYPE.
arrayView1d< globalIndex > localToGlobalMap()
Get local to global map.
const base_type & Base() const
Get a reference to this object cast to BASETYPE const.
const ObjectManagerBase * RelatedObject() const
Get the related object.