DataTransferKit - Multiphysics Solution Transfer Services  2.0
DTK_CylinderGeometry.cpp
Go to the documentation of this file.
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 <cmath>
42 
43 #include "DTK_CylinderGeometry.hpp"
45 #include "DTK_DBC.hpp"
46 
47 namespace DataTransferKit
48 {
49 //---------------------------------------------------------------------------//
54 {
55  this->b_entity_impl = Teuchos::rcp( new CylinderGeometryImpl() );
56 }
57 
58 //---------------------------------------------------------------------------//
73  const int owner_rank, const int block_id,
74  const double length, const double radius,
75  const double centroid_x,
76  const double centroid_y,
77  const double centroid_z )
78 {
79  this->b_entity_impl = Teuchos::rcp( new CylinderGeometryImpl(
80  global_id, owner_rank, block_id, length, radius, centroid_x, centroid_y,
81  centroid_z ) );
82 }
83 
84 //---------------------------------------------------------------------------//
85 // Get the length of the cylinder.
87 {
88  return Teuchos::rcp_dynamic_cast<CylinderGeometryImpl>(
89  this->b_entity_impl )
90  ->length();
91 }
92 
93 //---------------------------------------------------------------------------//
94 // Get the radius of the cylinder.
96 {
97  return Teuchos::rcp_dynamic_cast<CylinderGeometryImpl>(
98  this->b_entity_impl )
99  ->radius();
100 }
101 
102 //---------------------------------------------------------------------------//
109 {
110  return Teuchos::rcp_dynamic_cast<CylinderGeometryImpl>(
111  this->b_entity_impl )
112  ->measure();
113 }
114 
115 //---------------------------------------------------------------------------//
122  const Teuchos::ArrayView<double> &centroid ) const
123 {
124  Teuchos::rcp_dynamic_cast<CylinderGeometryImpl>( this->b_entity_impl )
125  ->centroid( centroid );
126 }
127 
128 //---------------------------------------------------------------------------//
133  const Teuchos::ArrayView<const double> &point,
134  const Teuchos::ArrayView<double> &reference_point ) const
135 {
136  return Teuchos::rcp_dynamic_cast<CylinderGeometryImpl>(
137  this->b_entity_impl )
138  ->mapToReferenceFrame( point, reference_point );
139 }
140 
141 //---------------------------------------------------------------------------//
147  const double tolerance,
148  const Teuchos::ArrayView<const double> &reference_point ) const
149 {
150  return Teuchos::rcp_dynamic_cast<CylinderGeometryImpl>(
151  this->b_entity_impl )
152  ->checkPointInclusion( tolerance, reference_point );
153 }
154 
155 //---------------------------------------------------------------------------//
160  const Teuchos::ArrayView<const double> &reference_point,
161  const Teuchos::ArrayView<double> &point ) const
162 {
163  Teuchos::rcp_dynamic_cast<CylinderGeometryImpl>( this->b_entity_impl )
164  ->mapToPhysicalFrame( reference_point, point );
165 }
166 
167 //---------------------------------------------------------------------------//
173 std::ostream &operator<<( std::ostream &os,
175 {
176  Teuchos::Array<double> centroid( 3 );
177  c.centroid( centroid() );
178  os << "CylinderGeometry: length=" << c.length() << ",radius=" << c.radius()
179  << ", centroid=(" << centroid[0] << "," << centroid[1] << ","
180  << centroid[2] << ")";
181 
182  return os;
183 }
184 
185 //---------------------------------------------------------------------------//
186 
187 } // end namespace DataTransferKit
188 
189 //---------------------------------------------------------------------------//
190 // end DTK_CylinderGeometry.cpp
191 //---------------------------------------------------------------------------//
CylinderGeometry implementation.
cylinder declaration.
Z-axis-aligned Cartesian cylinder container implementation.
std::ostream & operator<<(std::ostream &os, const DataTransferKit::BoxGeometry &b)
Print the box description to an ostream.
Z-axis-aligned Cartesian cylinder container.
Assertions and Design-by-Contract for error handling.
bool mapToReferenceFrame(const Teuchos::ArrayView< const double > &point, const Teuchos::ArrayView< double > &reference_point) const override
Map a point to the reference space of an entity. Return the.
unsigned long int EntityId
Entity id type.
Definition: DTK_Types.hpp:50
void mapToPhysicalFrame(const Teuchos::ArrayView< const double > &reference_point, const Teuchos::ArrayView< double > &point) const override
Map a reference point to the physical space of an entity.
bool checkPointInclusion(const double tolerance, const Teuchos::ArrayView< const double > &reference_point) const override
Determine if a reference point is in the parameterized space of an entity.
double length() const
Get the length of the cylinder.
double measure() const override
Compute the measure of the box.
void centroid(const Teuchos::ArrayView< double > &centroid) const override
Get the centroid of the box.
DTK_BasicEntitySet.cpp.
double radius() const
Get the radius of the cylinder.