|
Intrepid
|
00001 // @HEADER 00002 // ************************************************************************ 00003 // 00004 // Intrepid Package 00005 // Copyright (2007) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // Redistribution and use in source and binary forms, with or without 00011 // modification, are permitted provided that the following conditions are 00012 // met: 00013 // 00014 // 1. Redistributions of source code must retain the above copyright 00015 // notice, this list of conditions and the following disclaimer. 00016 // 00017 // 2. Redistributions in binary form must reproduce the above copyright 00018 // notice, this list of conditions and the following disclaimer in the 00019 // documentation and/or other materials provided with the distribution. 00020 // 00021 // 3. Neither the name of the Corporation nor the names of the 00022 // contributors may be used to endorse or promote products derived from 00023 // this software without specific prior written permission. 00024 // 00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 // 00037 // Questions: Alejandro Mota (amota@sandia.gov) 00038 // 00039 // ************************************************************************ 00040 // @HEADER 00041 00042 #if !defined(Intrepid_MiniTensor_Geometry_h) 00043 #define Intrepid_MiniTensor_Geometry_h 00044 00045 #include <vector> 00046 #include "Intrepid_MiniTensor_Tensor.h" 00047 00048 namespace Intrepid { 00049 00053 namespace ELEMENT{ 00054 00055 enum Type { 00056 UNKNOWN, 00057 SEGMENTAL, 00058 TRIANGULAR, 00059 QUADRILATERAL, 00060 TETRAHEDRAL, 00061 HEXAHEDRAL}; 00062 00063 } //namespace ELEMENT 00064 00068 template<typename T, Index N> 00069 T 00070 length(Vector<T, N> const & p0, Vector<T, N> const & p1); 00071 00075 template<typename T, Index N> 00076 T 00077 area(Vector<T, N> const & p0, Vector<T, N> const & p1, 00078 Vector<T, N> const & p2); 00079 00084 template<typename T, Index N> 00085 T 00086 area(Vector<T, N> const & p0, Vector<T, N> const & p1, 00087 Vector<T, N> const & p2, Vector<T, N> const & p3); 00088 00092 template<typename T, Index N> 00093 T 00094 volume(Vector<T, N> const & p0, Vector<T, N> const & p1, 00095 Vector<T, N> const & p2, Vector<T, N> const & p3); 00096 00103 template<typename T, Index N> 00104 T 00105 volume(Vector<T, N> const & p0, Vector<T, N> const & p1, 00106 Vector<T, N> const & p2, Vector<T, N> const & p3, 00107 Vector<T, N> const & p4); 00108 00114 template<typename T, Index N> 00115 T 00116 volume(Vector<T, N> const & p0, Vector<T, N> const & p1, 00117 Vector<T, N> const & p2, Vector<T, N> const & p3, 00118 Vector<T, N> const & p4, Vector<T, N> const & p5, 00119 Vector<T, N> const & p6, Vector<T, N> const & p7); 00120 00127 template<typename T, Index N> 00128 Vector<T, N> 00129 centroid(std::vector<Vector<T, N> > const & points); 00130 00136 template<typename T, Index N> 00137 Vector<T, N> 00138 normal(Vector<T, N> const & p0, 00139 Vector<T, N> const & p1, 00140 Vector<T, N> const & p2); 00141 00148 template<typename T, Index N> 00149 bool 00150 in_normal_side( 00151 Vector<T, N> const & p, 00152 Vector<T, N> const & p0, 00153 Vector<T, N> const & p1, 00154 Vector<T, N> const & p2, 00155 T const tolerance = 0); 00156 00163 template<typename T, typename I, Index N> 00164 std::pair< Vector<T, N>, Vector<T, N> > 00165 bounding_box(I start, I end); 00166 00167 template<typename T, typename I> 00168 std::pair< Vector<T, DYNAMIC>, Vector<T, DYNAMIC> > 00169 bounding_box(I start, I end); 00170 00177 template<typename T, Index N> 00178 bool 00179 in_box( 00180 Vector<T, N> const & p, 00181 Vector<T, N> const & min, 00182 Vector<T, N> const & max); 00183 00189 template<typename T, Index N> 00190 Vector<T, N> 00191 random_in_box( 00192 Vector<T, N> const & min, 00193 Vector<T, N> const & max); 00194 00200 template<typename T, Index N> 00201 bool 00202 in_tetrahedron( 00203 Vector<T, N> const & p, 00204 Vector<T, N> const & p0, 00205 Vector<T, N> const & p1, 00206 Vector<T, N> const & p2, 00207 Vector<T, N> const & p3, 00208 T const tolerance = 0); 00209 00216 template<typename T, Index N> 00217 bool 00218 in_hexahedron( 00219 Vector<T, N> const & p, 00220 Vector<T, N> const & p0, 00221 Vector<T, N> const & p1, 00222 Vector<T, N> const & p2, 00223 Vector<T, N> const & p3, 00224 Vector<T, N> const & p4, 00225 Vector<T, N> const & p5, 00226 Vector<T, N> const & p6, 00227 Vector<T, N> const & p7, 00228 T const tolerance = 0); 00229 00236 template<typename T, Index N> 00237 typename std::vector< Vector<T, N> >::size_type 00238 closest_point(Vector<T, N> const & p, std::vector< Vector<T, N> > const & n); 00239 00245 template<typename T, typename Iterator> 00246 T 00247 median(Iterator begin, Iterator end); 00248 00256 template<typename T, Index N> 00257 Vector<T, N> 00258 interpolate_quadrilateral( 00259 Vector<T, dimension_const<N, 2>::value> & xi, 00260 Vector<T, N> const & p0, 00261 Vector<T, N> const & p1, 00262 Vector<T, N> const & p2, 00263 Vector<T, N> const & p3); 00264 00272 template<typename T, Index N> 00273 Vector<T, N> 00274 interpolate_triangle( 00275 Vector<T, dimension_const<N, 3>::value> & xi, 00276 Vector<T, N> const & p0, 00277 Vector<T, N> const & p1, 00278 Vector<T, N> const & p2); 00279 00287 template<typename T, Index N> 00288 Vector<T, N> 00289 interpolate_hexahedron( 00290 Vector<T, dimension_const<N, 3>::value> & xi, 00291 Vector<T, N> const & p0, 00292 Vector<T, N> const & p1, 00293 Vector<T, N> const & p2, 00294 Vector<T, N> const & p3, 00295 Vector<T, N> const & p4, 00296 Vector<T, N> const & p5, 00297 Vector<T, N> const & p6, 00298 Vector<T, N> const & p7); 00299 00307 template<typename T, Index N> 00308 Vector<T, N> 00309 interpolate_tetrahedron( 00310 Vector<T, dimension_const<N, 4>::value> & xi, 00311 Vector<T, N> const & p0, 00312 Vector<T, N> const & p1, 00313 Vector<T, N> const & p2, 00314 Vector<T, N> const & p3); 00315 00324 template<typename T, Index M, Index N> 00325 Vector<T, N> 00326 interpolate_element( 00327 ELEMENT::Type element_type, 00328 Vector<T, M> & xi, 00329 std::vector< Vector<T, N> > const & v); 00330 00337 template<typename T, Index N> 00338 std::vector< std::vector<T> > 00339 distance_matrix(std::vector< Vector<T, N> > const & points); 00340 00347 template<typename T> 00348 std::vector<T> 00349 minimum_distances(std::vector< std::vector<T> > const & distances); 00350 00355 ELEMENT::Type 00356 find_type(Index const dimension, Index const number_nodes); 00357 00361 template<typename T, Index N> 00362 class SphericalParametrization 00363 { 00364 public: 00365 00366 SphericalParametrization(Tensor4<T, N> const & A); 00367 00368 void 00369 operator()(Vector<T, dimension_const<N, 2>::value> const & parameters); 00370 00371 T 00372 get_minimum() const {return minimum_;} 00373 00374 T 00375 get_maximum() const {return maximum_;} 00376 00377 Vector<T, N> 00378 get_arg_minimum() const {return arg_minimum_;} 00379 00380 Vector<T, N> 00381 get_arg_maximum() const {return arg_maximum_;} 00382 00383 private: 00384 00385 Tensor4<T, N> const & 00386 tangent_; 00387 00388 T 00389 minimum_; 00390 00391 Vector<T, N> 00392 arg_minimum_; 00393 00394 T 00395 maximum_; 00396 00397 Vector<T, N> 00398 arg_maximum_; 00399 }; 00400 00404 template<typename T, Index N> 00405 class StereographicParametrization 00406 { 00407 public: 00408 00409 StereographicParametrization(Tensor4<T, N> const & A); 00410 00411 void 00412 operator()(Vector<T, dimension_const<N, 2>::value> const & parameters); 00413 00414 T 00415 get_minimum() const {return minimum_;} 00416 00417 T 00418 get_maximum() const {return maximum_;} 00419 00420 Vector<T, N> 00421 get_arg_minimum() const {return arg_minimum_;} 00422 00423 Vector<T, N> 00424 get_arg_maximum() const {return arg_maximum_;} 00425 00426 private: 00427 00428 Tensor4<T, N> const & 00429 tangent_; 00430 00431 T 00432 minimum_; 00433 00434 Vector<T, N> 00435 arg_minimum_; 00436 00437 T 00438 maximum_; 00439 00440 Vector<T, N> 00441 arg_maximum_; 00442 }; 00443 00447 template<typename T, Index N> 00448 class ProjectiveParametrization 00449 { 00450 public: 00451 00455 ProjectiveParametrization(Tensor4<T, N> const & A); 00456 00460 void 00461 operator()(Vector<T, dimension_const<N, 4>::value> const & parameters); 00462 00463 T 00464 get_minimum() const {return minimum_;} 00465 00466 T 00467 get_maximum() const {return maximum_;} 00468 00469 Vector<T, N> 00470 get_arg_minimum() const {return arg_minimum_;} 00471 00472 Vector<T, N> 00473 get_arg_maximum() const {return arg_maximum_;} 00474 00475 private: 00476 00477 Tensor4<T, N> const & 00478 tangent_; 00479 00480 T 00481 minimum_; 00482 00483 Vector<T, N> 00484 arg_minimum_; 00485 00486 T 00487 maximum_; 00488 00489 Vector<T, N> 00490 arg_maximum_; 00491 }; 00492 00496 template<typename T, Index N> 00497 class TangentParametrization 00498 { 00499 public: 00500 00504 TangentParametrization(Tensor4<T, N> const & A); 00505 00509 void 00510 operator()(Vector<T, dimension_const<N, 2>::value> const & parameters); 00511 00512 T 00513 get_minimum() const {return minimum_;} 00514 00515 T 00516 get_maximum() const {return maximum_;} 00517 00518 Vector<T, N> 00519 get_arg_minimum() const {return arg_minimum_;} 00520 00521 Vector<T, N> 00522 get_arg_maximum() const {return arg_maximum_;} 00523 00524 private: 00525 00526 Tensor4<T, N> const & 00527 tangent_; 00528 00529 T 00530 minimum_; 00531 00532 Vector<T, N> 00533 arg_minimum_; 00534 00535 T 00536 maximum_; 00537 00538 Vector<T, N> 00539 arg_maximum_; 00540 }; 00541 00545 template<typename T, Index N> 00546 class CartesianParametrization 00547 { 00548 public: 00549 00550 CartesianParametrization(Tensor4<T, N> const & A); 00551 00552 void 00553 operator()(Vector<T, dimension_const<N, 3>::value> const & parameters); 00554 00555 T 00556 get_minimum() const {return minimum_;} 00557 00558 T 00559 get_maximum() const {return maximum_;} 00560 00561 Vector<T, N> 00562 get_arg_minimum() const {return arg_minimum_;} 00563 00564 Vector<T, N> 00565 get_arg_maximum() const {return arg_maximum_;} 00566 00567 private: 00568 00569 Tensor4<T, N> const & 00570 tangent_; 00571 00572 T 00573 minimum_; 00574 00575 Vector<T, N> 00576 arg_minimum_; 00577 00578 T 00579 maximum_; 00580 00581 Vector<T, N> 00582 arg_maximum_; 00583 }; 00584 00588 template<typename T, Index N> 00589 class ParametricGrid 00590 { 00591 00592 public: 00593 00597 ParametricGrid() {} 00598 00605 ParametricGrid( 00606 Vector<T, N> const & lower, 00607 Vector<T, N> const & upper, 00608 Vector<Index, N> const & points_per_dimension); 00609 00612 template<typename Visitor> 00613 void 00614 traverse(Visitor & visitor) const; 00615 00616 private: 00617 00618 Vector<T, N> 00619 lower_; 00620 00621 Vector<T, N> 00622 upper_; 00623 00624 Vector<Index, N> 00625 points_per_dimension_; 00626 00627 }; 00628 00629 } // namespace Intrepid 00630 00631 #include "Intrepid_MiniTensor_Geometry.i.h" 00632 #include "Intrepid_MiniTensor_Geometry.t.h" 00633 00634 #endif // Intrepid_MiniTensor_Geometry_h
1.7.6.1