45 #include "DTK_EntityLocalMap.hpp" 62 const Entity &entity,
const Teuchos::ArrayView<const double> &point )
const 65 Teuchos::Tuple<double, 6> entity_box;
69 double tolerance = 1.0e-6;
74 double x_tol = ( entity_box[3] - entity_box[0] ) * tolerance;
75 in_x = ( ( point[0] >= ( entity_box[0] - x_tol ) ) &&
76 ( point[0] <= ( entity_box[3] + x_tol ) ) );
81 double y_tol = ( entity_box[4] - entity_box[1] ) * tolerance;
82 in_y = ( ( point[1] >= ( entity_box[1] - y_tol ) ) &&
83 ( point[1] <= ( entity_box[4] + y_tol ) ) );
88 double z_tol = ( entity_box[5] - entity_box[2] ) * tolerance;
89 in_z = ( ( point[2] >= ( entity_box[2] - z_tol ) ) &&
90 ( point[2] <= ( entity_box[5] + z_tol ) ) );
92 return ( in_x && in_y && in_z );
99 const Teuchos::ArrayView<const double> &reference_point,
100 const Teuchos::ArrayView<double> &normal )
const 104 int ref_dim = physical_dim - 1;
107 double perturbation = std::sqrt( std::numeric_limits<double>::epsilon() );
112 DTK_CHECK( 3 == reference_point.size() );
113 DTK_CHECK( 3 == normal.size() );
116 Teuchos::Array<double> ref_p1( reference_point );
117 Teuchos::Array<double> ref_p2( reference_point );
120 double p1_sign = 1.0;
121 ref_p1[0] += perturbation;
124 ref_p1[0] -= 2 * perturbation;
127 double p2_sign = 1.0;
128 ref_p2[1] += perturbation;
131 ref_p2[1] -= 2 * perturbation;
136 Teuchos::Array<double> p0( physical_dim );
138 Teuchos::Array<double> p1( physical_dim );
140 Teuchos::Array<double> p2( physical_dim );
145 Teuchos::Array<double> tan1( physical_dim );
146 Teuchos::Array<double> tan2( physical_dim );
147 for (
int d = 0; d < physical_dim; ++d )
149 tan1[d] = p1_sign * ( p1[d] - p0[d] );
150 tan2[d] = p2_sign * ( p2[d] - p0[d] );
152 normal[0] = tan1[1] * tan2[2] - tan1[2] * tan2[1];
153 normal[1] = tan1[2] * tan2[0] - tan1[0] * tan2[2];
154 normal[2] = tan1[0] * tan2[1] - tan1[1] * tan2[0];
158 else if ( 1 == ref_dim )
160 DTK_CHECK( 2 == reference_point.size() );
161 DTK_CHECK( 2 == normal.size() );
164 Teuchos::Array<double> ref_p1( reference_point );
167 double p1_sign = 1.0;
168 ref_p1[0] += perturbation;
171 ref_p1[0] -= 2 * perturbation;
176 Teuchos::Array<double> p0( physical_dim );
178 Teuchos::Array<double> p1( physical_dim );
183 Teuchos::Array<double> tan( physical_dim );
184 for (
int d = 0; d < physical_dim; ++d )
186 tan[d] = p1_sign * ( p1[d] - p0[d] );
194 for (
int d = 0; d < physical_dim; ++d )
196 norm += normal[d] * normal[d];
198 norm = std::sqrt( norm );
199 for (
int d = 0; d < physical_dim; ++d )
Geometric entity interface definition.
void boundingBox(Teuchos::Tuple< double, 6 > &bounds) const
Return the Cartesian bounding box around an entity.
virtual bool isSafeToMapToReferenceFrame(const Entity &entity, const Teuchos::ArrayView< const double > &physical_point) const
(Safeguard the reverse map) Perform a safeguard check for mapping a point to the reference space of a...
virtual bool checkPointInclusion(const Entity &entity, const Teuchos::ArrayView< const double > &reference_point) const =0
Determine if a reference point is in the parameterized space of an entity.
EntityLocalMap()
Constructor.
virtual void normalAtReferencePoint(const Entity &entity, const Entity &parent_entity, const Teuchos::ArrayView< const double > &reference_point, const Teuchos::ArrayView< double > &normal) const
Compute the normal on a face (3D) or edge (2D) at a given reference point. A default implementation i...
Assertions and Design-by-Contract for error handling.
virtual ~EntityLocalMap()
Destructor.
int physicalDimension() const
Return the physical dimension of the entity.
virtual void mapToPhysicalFrame(const Entity &entity, const Teuchos::ArrayView< const double > &reference_point, const Teuchos::ArrayView< double > &physical_point) const =0
(Forward Map) Map a reference point to the physical space of an entity.