45 #include "DTK_PointImpl.hpp" 51 PointImpl::PointImpl() { }
55 PointImpl::PointImpl(
const EntityId global_id,
const int owner_rank,
56 const Teuchos::Array<double> &coordinates,
57 const Teuchos::Array<int> &block_ids,
58 const Teuchos::Array<int> &boundary_ids )
59 : d_global_id( global_id )
60 , d_owner_rank( owner_rank )
61 , d_block_ids( block_ids )
62 , d_boundary_ids( boundary_ids )
63 , d_coordinates( coordinates )
65 std::sort( d_block_ids.begin(), d_block_ids.end() );
66 std::sort( d_boundary_ids.begin(), d_boundary_ids.end() );
71 void PointImpl::getCoordinates(
72 const Teuchos::ArrayView<double> &coordinates )
const 74 coordinates.assign( d_coordinates );
79 EntityId PointImpl::id()
const {
return d_global_id; }
83 int PointImpl::ownerRank()
const {
return d_owner_rank; }
87 int PointImpl::topologicalDimension()
const {
return 0; }
91 int PointImpl::physicalDimension()
const {
return d_coordinates.size(); }
95 void PointImpl::boundingBox( Teuchos::Tuple<double, 6> &bounds )
const 97 Teuchos::Array<double> coordinates( this->physicalDimension() );
98 this->getCoordinates( coordinates );
99 double max = std::numeric_limits<double>::max();
100 int space_dim = coordinates.size();
101 if ( 1 == space_dim )
103 bounds = Teuchos::tuple( coordinates[0], -max, -max, coordinates[0],
106 else if ( 2 == space_dim )
108 bounds = Teuchos::tuple( coordinates[0], coordinates[1], -max,
109 coordinates[0], coordinates[1], max );
111 else if ( 3 == space_dim )
114 Teuchos::tuple( coordinates[0], coordinates[1], coordinates[2],
115 coordinates[0], coordinates[1], coordinates[2] );
121 bool PointImpl::inBlock(
const int block_id )
const 123 return std::binary_search( d_block_ids.begin(), d_block_ids.end(),
129 bool PointImpl::onBoundary(
const int boundary_id )
const 131 return std::binary_search( d_boundary_ids.begin(), d_boundary_ids.end(),
136 void PointImpl::describe( Teuchos::FancyOStream &out,
137 const Teuchos::EVerbosityLevel )
const 139 int space_dim = this->physicalDimension();
140 Teuchos::Array<double> coordinates( space_dim );
141 this->getCoordinates( coordinates() );
143 out <<
"---" << std::endl;
144 out << description() << std::endl;
145 out <<
"Id: " << id() << std::endl;
146 out <<
"Owner rank: " << ownerRank() << std::endl;
147 out <<
"Block ids: " << d_block_ids << std::endl;
148 out <<
"Boundary ids: " << d_boundary_ids << std::endl;
149 out <<
"Coordinates:";
150 for (
int d = 0; d < space_dim; ++d )
152 out <<
" " << coordinates[d];
155 out <<
"---" << std::endl;
164 double PointImpl::measure()
const {
return 0.0; }
172 void PointImpl::centroid(
const Teuchos::ArrayView<double> ¢roid )
const 174 this->getCoordinates( centroid );
181 bool PointImpl::mapToReferenceFrame(
182 const Teuchos::ArrayView<const double> &point,
183 const Teuchos::ArrayView<double> &reference_point )
const 185 reference_point.assign( point );
195 bool PointImpl::checkPointInclusion(
196 const double tolerance,
197 const Teuchos::ArrayView<const double> &reference_point )
const 199 int space_dim = this->physicalDimension();
200 Teuchos::Array<double> coords( space_dim );
201 this->getCoordinates( coords() );
202 double distance = 0.0;
203 double local_dist = 0.0;
204 for (
int d = 0; d < space_dim; ++d )
206 local_dist = coords[d] - reference_point[d];
207 distance += local_dist * local_dist;
209 return ( distance < tolerance * tolerance );
216 void PointImpl::mapToPhysicalFrame(
217 const Teuchos::ArrayView<const double> &reference_point,
218 const Teuchos::ArrayView<double> &point )
const 220 point.assign( reference_point );
Assertions and Design-by-Contract for error handling.
unsigned long int EntityId
Entity id type.