DataTransferKit - Multiphysics Solution Transfer Services  2.0
DTK_Entity.cpp
1 //---------------------------------------------------------------------------//
2 /*
3  Copyright (c) 2012, Stuart R. Slattery
4  All rights reserved.
5 
6  Redistribution and use in source and binary forms, with or without
7  modification, are permitted provided that the following conditions are
8  met:
9 
10  *: Redistributions of source code must retain the above copyright
11  notice, this list of conditions and the following disclaimer.
12 
13  *: Redistributions in binary form must reproduce the above copyright
14  notice, this list of conditions and the following disclaimer in the
15  documentation and/or other materials provided with the distribution.
16 
17  *: Neither the name of the University of Wisconsin - Madison nor the
18  names of its contributors may be used to endorse or promote products
19  derived from this software without specific prior written permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33 //---------------------------------------------------------------------------//
39 //---------------------------------------------------------------------------//
40 
41 #include <sstream>
42 
43 #include "DTK_DBC.hpp"
44 #include "DTK_Entity.hpp"
45 
46 namespace DataTransferKit
47 {
48 //---------------------------------------------------------------------------//
49 // Constructor.
50 Entity::Entity() { /* ... */}
51 
52 //---------------------------------------------------------------------------//
53 // Copy constructor.
54 Entity::Entity( const Entity &rhs ) { b_entity_impl = rhs.b_entity_impl; }
55 
56 //---------------------------------------------------------------------------//
57 // Copy assignment operator.
59 {
60  b_entity_impl = rhs.b_entity_impl;
61  return *this;
62 }
63 
64 //---------------------------------------------------------------------------//
65 // Move constructor.
66 Entity::Entity( Entity &&rhs ) { b_entity_impl = rhs.b_entity_impl; }
67 
68 //---------------------------------------------------------------------------//
69 // Move assignment operator.
71 {
72  b_entity_impl = rhs.b_entity_impl;
73  return *this;
74 }
75 
76 //---------------------------------------------------------------------------//
77 // brief Destructor.
78 Entity::~Entity() { /* ... */}
79 
80 //---------------------------------------------------------------------------//
81 // Get the unique global identifier for the entity.
83 {
84  DTK_REQUIRE( Teuchos::nonnull( b_entity_impl ) );
85  return b_entity_impl->id();
86 }
87 
88 //---------------------------------------------------------------------------//
89 // Get the parallel rank that owns the entity.
90 int Entity::ownerRank() const
91 {
92  DTK_REQUIRE( Teuchos::nonnull( b_entity_impl ) );
93  return b_entity_impl->ownerRank();
94 }
95 
96 //---------------------------------------------------------------------------//
97 // Return the topological dimension of the entity.
99 {
100  DTK_REQUIRE( Teuchos::nonnull( b_entity_impl ) );
101  return b_entity_impl->topologicalDimension();
102 }
103 
104 //---------------------------------------------------------------------------//
105 // Return the physical dimension of the entity.
107 {
108  DTK_REQUIRE( Teuchos::nonnull( b_entity_impl ) );
109  return b_entity_impl->physicalDimension();
110 }
111 
112 //---------------------------------------------------------------------------//
113 // Return the Cartesian bounding box around an entity.
114 void Entity::boundingBox( Teuchos::Tuple<double, 6> &bounds ) const
115 {
116  DTK_REQUIRE( Teuchos::nonnull( b_entity_impl ) );
117  b_entity_impl->boundingBox( bounds );
118 }
119 
120 //---------------------------------------------------------------------------//
121 // Determine if an entity is in the block with the given id.
122 bool Entity::inBlock( const int block_id ) const
123 {
124  DTK_REQUIRE( Teuchos::nonnull( b_entity_impl ) );
125  return b_entity_impl->inBlock( block_id );
126 }
127 
128 //---------------------------------------------------------------------------//
129 // Determine if an entity is on the boundary with the given id.
130 bool Entity::onBoundary( const int boundary_id ) const
131 {
132  DTK_REQUIRE( Teuchos::nonnull( b_entity_impl ) );
133  return b_entity_impl->onBoundary( boundary_id );
134 }
135 
136 //---------------------------------------------------------------------------//
137 // Get the extra data on the entity.
138 Teuchos::RCP<EntityExtraData> Entity::extraData() const
139 {
140  DTK_REQUIRE( Teuchos::nonnull( b_entity_impl ) );
141  return b_entity_impl->extraData();
142 }
143 
144 //---------------------------------------------------------------------------//
145 // Provide a one line description of the object.
146 std::string Entity::description() const
147 {
148  DTK_REQUIRE( Teuchos::nonnull( b_entity_impl ) );
149  std::stringstream d;
150  d << " Id = " << id() << ", OwnerRank = " << ownerRank()
151  << ", TopologicalDimension = " << topologicalDimension()
152  << ", PhysicalDimension = " << physicalDimension();
153  return b_entity_impl->description() + d.str();
154 }
155 
156 //---------------------------------------------------------------------------//
157 // Provide a verbose description of the object.
158 void Entity::describe( Teuchos::FancyOStream &out,
159  const Teuchos::EVerbosityLevel verb_level ) const
160 {
161  DTK_REQUIRE( Teuchos::nonnull( b_entity_impl ) );
162  return b_entity_impl->describe( out, verb_level );
163 }
164 
165 //---------------------------------------------------------------------------//
166 
167 } // end namespace DataTransferKit
168 
169 //---------------------------------------------------------------------------//
170 // end DTK_Entity.cpp
171 //---------------------------------------------------------------------------//
Entity & operator=(const Entity &rhs)
Copy assignment operator.
Definition: DTK_Entity.cpp:58
Geometric entity interface definition.
Definition: DTK_Entity.hpp:61
virtual ~Entity()
Destructor.
Definition: DTK_Entity.cpp:78
Entity()
Constructor.
Definition: DTK_Entity.cpp:50
void boundingBox(Teuchos::Tuple< double, 6 > &bounds) const
Return the Cartesian bounding box around an entity.
Definition: DTK_Entity.cpp:114
int ownerRank() const
Get the parallel rank that owns the entity.
Definition: DTK_Entity.cpp:90
bool inBlock(const int block_id) const
Determine if an entity is in the block with the given id.
Definition: DTK_Entity.cpp:122
Assertions and Design-by-Contract for error handling.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verb_level=Teuchos::Describable::verbLevel_default) const override
Provide a verbose description of the object.
Definition: DTK_Entity.cpp:158
Teuchos::RCP< EntityExtraData > extraData() const
Get the extra data on the entity. This is a convenient helper for implementing the other interfaces...
Definition: DTK_Entity.cpp:138
int physicalDimension() const
Return the physical dimension of the entity.
Definition: DTK_Entity.cpp:106
unsigned long int EntityId
Entity id type.
Definition: DTK_Types.hpp:50
int topologicalDimension() const
Return the topological dimension of the entity.
Definition: DTK_Entity.cpp:98
DTK_BasicEntitySet.cpp.
std::string description() const override
Teuchos::Describable interface.
Definition: DTK_Entity.cpp:146
bool onBoundary(const int boundary_id) const
Determine if an entity is on the boundary with the given id.
Definition: DTK_Entity.cpp:130
EntityId id() const
Client interface.
Definition: DTK_Entity.cpp:82