DataTransferKit - Multiphysics Solution Transfer Services  2.0
DTK_BasicGeometryLocalMap.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 "DTK_BasicGeometryLocalMap.hpp"
43 #include "DTK_BasicGeometryExtraData.hpp"
44 #include "DTK_DBC.hpp"
45 
46 namespace DataTransferKit
47 {
48 //---------------------------------------------------------------------------//
49 // Constructor.
51  : d_inclusion_tol( 1.0e-6 )
52 { /* ... */
53 }
54 
55 //---------------------------------------------------------------------------//
56 // Set parameters for mapping.
57 void BasicGeometryLocalMap::setParameters(
58  const Teuchos::ParameterList &parameters )
59 {
60  if ( parameters.isParameter( "Point Inclusion Tolerance" ) )
61  {
62  d_inclusion_tol = parameters.get<double>( "Point Inclusion Tolerance" );
63  }
64 }
65 
66 //---------------------------------------------------------------------------//
67 // Return the entity measure with respect to the parameteric dimension (volume
68 // for a 3D entity, area for 2D, and length for 1D).
69 double BasicGeometryLocalMap::measure( const Entity &entity ) const
70 {
71  return Teuchos::rcp_dynamic_cast<BasicGeometryExtraData>(
72  entity.extraData() )
73  ->implementationConstPtr()
74  ->measure();
75 }
76 
77 //---------------------------------------------------------------------------//
78 // Return the centroid of the entity.
80  const Entity &entity, const Teuchos::ArrayView<double> &centroid ) const
81 {
82  Teuchos::rcp_dynamic_cast<BasicGeometryExtraData>( entity.extraData() )
83  ->implementationConstPtr()
84  ->centroid( centroid );
85 }
86 
87 //---------------------------------------------------------------------------//
88 // Map a point to the reference space of an entity. Return the parameterized
89 // point.
91  const Entity &entity,
92  const Teuchos::ArrayView<const double> &physical_point,
93  const Teuchos::ArrayView<double> &reference_point ) const
94 {
95  return Teuchos::rcp_dynamic_cast<BasicGeometryExtraData>(
96  entity.extraData() )
97  ->implementationConstPtr()
98  ->mapToReferenceFrame( physical_point, reference_point );
99 }
100 
101 //---------------------------------------------------------------------------//
102 // Determine if a reference point is in the parameterized space of an entity.
104  const Entity &entity,
105  const Teuchos::ArrayView<const double> &reference_point ) const
106 {
107  return Teuchos::rcp_dynamic_cast<BasicGeometryExtraData>(
108  entity.extraData() )
109  ->implementationConstPtr()
110  ->checkPointInclusion( d_inclusion_tol, reference_point );
111 }
112 
113 //---------------------------------------------------------------------------//
114 // Map a reference point to the physical space of an entity.
116  const Entity &entity,
117  const Teuchos::ArrayView<const double> &reference_point,
118  const Teuchos::ArrayView<double> &physical_point ) const
119 {
120  Teuchos::rcp_dynamic_cast<BasicGeometryExtraData>( entity.extraData() )
121  ->implementationConstPtr()
122  ->mapToPhysicalFrame( reference_point, physical_point );
123 }
124 
125 //---------------------------------------------------------------------------//
126 
127 } // end namespace DataTransferKit
128 
129 //---------------------------------------------------------------------------//
130 // end DTK_BasicGeometryLocalMap.cpp
131 //---------------------------------------------------------------------------//
Geometric entity interface definition.
Definition: DTK_Entity.hpp:61
void mapToPhysicalFrame(const Entity &entity, const Teuchos::ArrayView< const double > &reference_point, const Teuchos::ArrayView< double > &physical_point) const override
(Forward Map) Map a reference point to the physical space of an entity.
void centroid(const Entity &entity, const Teuchos::ArrayView< double > &centroid) const override
Return the centroid of the entity.
double measure(const Entity &entity) const override
Return the entity measure with respect to the parameteric dimension (volume for a 3D entity...
bool mapToReferenceFrame(const Entity &entity, const Teuchos::ArrayView< const double > &physical_point, const Teuchos::ArrayView< double > &reference_point) const override
(Reverse Map) Map a point to the reference space of an entity. Return the parameterized point...
BasicGeometryEntity declaration.
Assertions and Design-by-Contract for error handling.
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
A base class for setting extra data with entities.
bool checkPointInclusion(const Entity &entity, const Teuchos::ArrayView< const double > &reference_point) const override
Determine if a reference point is in the parameterized space of an entity.
DTK_BasicEntitySet.cpp.