Intrepid
Intrepid_MiniTensor_Geometry.h
1 // @HEADER
2 // ************************************************************************
3 //
4 // Intrepid Package
5 // Copyright (2007) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions: Alejandro Mota (amota@sandia.gov)
38 //
39 // ************************************************************************
40 // @HEADER
41 
42 #if !defined(Intrepid_MiniTensor_Geometry_h)
43 #define Intrepid_MiniTensor_Geometry_h
44 
45 #include <vector>
46 #include "Intrepid_MiniTensor_Tensor.h"
47 
48 namespace Intrepid {
49 
53 namespace ELEMENT{
54 
55 enum Type {
56  UNKNOWN,
57  SEGMENTAL,
58  TRIANGULAR,
59  QUADRILATERAL,
60  TETRAHEDRAL,
61  HEXAHEDRAL};
62 
63 } //namespace ELEMENT
64 
68 template<typename T>
69 T
70 length(Vector<T> const & p0, Vector<T> const & p1);
71 
75 template<typename T>
76 T
77 area(Vector<T> const & p0, Vector<T> const & p1,
78  Vector<T> const & p2);
79 
84 template<typename T>
85 T
86 area(Vector<T> const & p0, Vector<T> const & p1,
87  Vector<T> const & p2, Vector<T> const & p3);
88 
92 template<typename T>
93 T
94 volume(Vector<T> const & p0, Vector<T> const & p1,
95  Vector<T> const & p2, Vector<T> const & p3);
96 
103 template<typename T>
104 T
105 volume(Vector<T> const & p0, Vector<T> const & p1,
106  Vector<T> const & p2, Vector<T> const & p3,
107  Vector<T> const & p4);
108 
114 template<typename T>
115 T
116 volume(Vector<T> const & p0, Vector<T> const & p1,
117  Vector<T> const & p2, Vector<T> const & p3,
118  Vector<T> const & p4, Vector<T> const & p5,
119  Vector<T> const & p6, Vector<T> const & p7);
120 
127 template<typename T>
128 Vector<T>
129 centroid(std::vector<Vector<T> > const & points);
130 
136 template<typename T>
137 Vector<T>
138 normal(Vector<T> const & p0,
139  Vector<T> const & p1,
140  Vector<T> const & p2);
141 
147 template<typename T>
148 bool
149 in_normal_side(
150  Vector<T> const & p,
151  Vector<T> const & p0,
152  Vector<T> const & p1,
153  Vector<T> const & p2);
154 
161 template<typename T, typename I>
162 std::pair< Vector<T>, Vector<T> >
163 bounding_box(I start, I end);
164 
171 template<typename T>
172 bool
173 in_box(
174  Vector<T> const & p,
175  Vector<T> const & min,
176  Vector<T> const & max);
177 
183 template<typename T>
184 Vector<T>
185 random_in_box(
186  Vector<T> const & min,
187  Vector<T> const & max);
188 
193 template<typename T>
194 bool
195 in_tetrahedron(
196  Vector<T> const & p,
197  Vector<T> const & p0,
198  Vector<T> const & p1,
199  Vector<T> const & p2,
200  Vector<T> const & p3);
201 
207 template<typename T>
208 bool
209 in_hexahedron(
210  Vector<T> const & p,
211  Vector<T> const & p0,
212  Vector<T> const & p1,
213  Vector<T> const & p2,
214  Vector<T> const & p3,
215  Vector<T> const & p4,
216  Vector<T> const & p5,
217  Vector<T> const & p6,
218  Vector<T> const & p7);
219 
226 template<typename T>
227 typename std::vector< Vector<T> >::size_type
228 closest_point(Vector<T> const & p, std::vector< Vector<T> > const & n);
229 
235 template<typename T, typename Iterator>
236 T
237 median(Iterator begin, Iterator end);
238 
246 template<typename T>
247 Vector<T>
248 interpolate_quadrilateral(
249  Vector<T> & xi,
250  Vector<T> const & p0,
251  Vector<T> const & p1,
252  Vector<T> const & p2,
253  Vector<T> const & p3);
254 
262 template<typename T>
263 Vector<T>
264 interpolate_triangle(
265  Vector<T> & xi,
266  Vector<T> const & p0,
267  Vector<T> const & p1,
268  Vector<T> const & p2);
269 
277 template<typename T>
278 Vector<T>
279 interpolate_hexahedron(
280  Vector<T> & xi,
281  Vector<T> const & p0,
282  Vector<T> const & p1,
283  Vector<T> const & p2,
284  Vector<T> const & p3,
285  Vector<T> const & p4,
286  Vector<T> const & p5,
287  Vector<T> const & p6,
288  Vector<T> const & p7);
289 
297 template<typename T>
298 Vector<T>
299 interpolate_tetrahedron(
300  Vector<T> & xi,
301  Vector<T> const & p0,
302  Vector<T> const & p1,
303  Vector<T> const & p2,
304  Vector<T> const & p3);
305 
314 template<typename T>
315 Vector<T>
316 interpolate_element(
317  ELEMENT::Type element_type,
318  Vector<T> & xi,
319  std::vector< Vector<T> > const & v);
320 
327 template<typename T>
328 std::vector< std::vector<T> >
329 distance_matrix(std::vector< Vector<T> > const & points);
330 
337 template<typename T>
338 std::vector<T>
339 minimum_distances(std::vector< std::vector<T> > const & distances);
340 
345 ELEMENT::Type
346 find_type(Index const dimension, Index const number_nodes);
347 
351 template<typename T>
353 {
354 public:
355 
360 
364  void
365  operator()(Vector<T> const & parameters);
366 
367  T
368  get_minimum() const {return minimum_;}
369 
370  T
371  get_maximum() const {return maximum_;}
372 
373  Vector<T>
374  get_arg_minimum() const {return arg_minimum_;}
375 
376  Vector<T>
377  get_arg_maximum() const {return arg_maximum_;}
378 
379 private:
380 
381  Tensor4<T> const &
382  tangent_;
383 
384  T
385  minimum_;
386 
387  Vector<T>
388  arg_minimum_;
389 
390  T
391  maximum_;
392 
393  Vector<T>
394  arg_maximum_;
395 };
396 
400 template<typename T>
402 {
403 public:
404 
409 
413  void
414  operator()(Vector<T> const & parameters);
415 
416  T
417  get_minimum() const {return minimum_;}
418 
419  T
420  get_maximum() const {return maximum_;}
421 
422  Vector<T>
423  get_arg_minimum() const {return arg_minimum_;}
424 
425  Vector<T>
426  get_arg_maximum() const {return arg_maximum_;}
427 
428 private:
429 
430  Tensor4<T> const &
431  tangent_;
432 
433  T
434  minimum_;
435 
436  Vector<T>
437  arg_minimum_;
438 
439  T
440  maximum_;
441 
442  Vector<T>
443  arg_maximum_;
444 };
445 
449 template<typename T>
451 {
452 public:
453 
458 
462  void
463  operator()(Vector<T> const & parameters);
464 
465  T
466  get_minimum() const {return minimum_;}
467 
468  T
469  get_maximum() const {return maximum_;}
470 
471  Vector<T>
472  get_arg_minimum() const {return arg_minimum_;}
473 
474  Vector<T>
475  get_arg_maximum() const {return arg_maximum_;}
476 
477 private:
478 
479  Tensor4<T> const &
480  tangent_;
481 
482  T
483  minimum_;
484 
485  Vector<T>
486  arg_minimum_;
487 
488  T
489  maximum_;
490 
491  Vector<T>
492  arg_maximum_;
493 };
494 
498 template<typename T>
500 {
501 public:
502 
507 
511  void
512  operator()(Vector<T> const & parameters);
513 
514  T
515  get_minimum() const {return minimum_;}
516 
517  T
518  get_maximum() const {return maximum_;}
519 
520  Vector<T>
521  get_arg_minimum() const {return arg_minimum_;}
522 
523  Vector<T>
524  get_arg_maximum() const {return arg_maximum_;}
525 
526 private:
527 
528  Tensor4<T> const &
529  tangent_;
530 
531  T
532  minimum_;
533 
534  Vector<T>
535  arg_minimum_;
536 
537  T
538  maximum_;
539 
540  Vector<T>
541  arg_maximum_;
542 };
543 
547 template<typename T>
549 {
550 public:
551 
556 
560  void
561  operator()(Vector<T> const & parameters);
562 
563  T
564  get_minimum() const {return minimum_;}
565 
566  T
567  get_maximum() const {return maximum_;}
568 
569  Vector<T>
570  get_arg_minimum() const {return arg_minimum_;}
571 
572  Vector<T>
573  get_arg_maximum() const {return arg_maximum_;}
574 
575 private:
576 
577  Tensor4<T> const &
578  tangent_;
579 
580  T
581  minimum_;
582 
583  Vector<T>
584  arg_minimum_;
585 
586  T
587  maximum_;
588 
589  Vector<T>
590  arg_maximum_;
591 };
592 
596 template<typename T>
598 {
599 
600 public:
601 
606 
614  Vector<T> const & lower,
615  Vector<T> const & upper,
616  Vector<Index> const & points_per_dimension);
617 
620  template<typename Visitor>
621  void
622  traverse(Visitor & visitor) const;
623 
624 private:
625 
626  Vector<T>
627  lower_;
628 
629  Vector<T>
630  upper_;
631 
633  points_per_dimension_;
634 
635 };
636 
637 } // namespace Intrepid
638 
639 #include "Intrepid_MiniTensor_Geometry.i.h"
640 #include "Intrepid_MiniTensor_Geometry.t.h"
641 
642 #endif // Intrepid_MiniTensor_Geometry_h