Flow123d  JS_before_hm-978-gfd4e3d8
mixed_mesh_intersections.hh
Go to the documentation of this file.
1 /*!
2  *
3 * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file inspect_elements.hh
15  * @brief Main class MixedMeshIntersections for governing intersection algorithm on meshes of combined dimensions.
16  * @author Pavel Exner
17  *
18  * TODO: in 2d-2d and 1d-2d check that the intersection candidate has been already computed
19  * during algorithm, not when moving to storage..
20  *
21  */
22 #ifndef INSPECT_ELEMENTS_H_
23 #define INSPECT_ELEMENTS_H_
24 
27 
28 class Mesh; // forward declare
29 
30 
33 template<unsigned int N, unsigned int M> class IntersectionLocal;
34 
35 /// Selection of intersections of different dimensions.
37 {
38  none = 0,
39  d13 = 0x0002,
40  d23 = 0x0004,
41  d22 = 0x0008,
42  d12_1 = 0x0010, // different algorithms for 12
43  d12_2 = 0x0020,
44  d12_3 = 0x0040,
45  d12 = 0x00F0, // automatically choose 12 alg.
46  all = 0xFFFF
47 };
48 
49 /** @brief Main class for computation of intersection of meshes of combined dimensions.
50  *
51  * Controls different algorithms for computation of intersection.
52  * Computes intersection in the order:
53  * - 1D-3D
54  * - 2D-3D
55  * - 2D-2D (uses results from 2D-3D)
56  * After computation, it transforms the internal intersection objects into proper output structure
57  * for further usage.
58  * The objects of different intersection types are stored in different vectors:
59  * @p intersection_storageXY_ ..
60  *
61  * When we are on an element, we use @p element_intersections_ to get to all its intersections.
62  *
63  */
65 {
66 public:
67  /// Stores 1D-3D intersections.
69  /// Stores 2D-3D intersections.
71  /// Stores 2D-2D intersections.
73  /// Stores 1D-2D intersections.
75 
76  /**
77  * For every element, stores list of intersections with this element.
78  *
79  * intersection_map_[element index][i].first = other element index
80  * intersection_map_[element index][i].second = index pointer to the intersection object
81  */
82  typedef std::pair<unsigned int, IntersectionLocalBase *> ILpair;
84 
87 
88  /// Calls @p InspectElementsAlgorithm<dim>, computes intersections,
89  /// move them to storage, create the map and throw away the rest.
91 
92  // TODO: move following functions into common intersection test code.
93  // Functions for tests.
94  unsigned int number_of_components(unsigned int dim);
95 
96  /// Computes the size of the intersection in @p dim dimenstions.
97  double measure_13();
98  double measure_23();
99  double measure_22();
100 
101  /// Generates a mesh file of the given name, including the intersection.
102  void print_mesh_to_file_13(std::string name);
103  void print_mesh_to_file_23(std::string name);
104 
105 private:
106  /// Mesh pointer.
108 
113 
114  template<uint dim_A, uint dim_B>
116 
117  template<uint dim_A, uint dim_B>
119 
120  /// Auxiliary function that calls InspectElementsAlgorithm<dim>.
121  template<unsigned int dim> void compute_intersections(InspectElementsAlgorithm<dim> &iea,
127 };
128 
129 
130 
131 
132 #endif // INSPECT_ELEMENTS_H_
IntersectionType
Selection of intersections of different dimensions.
void compute_intersections_22(std::vector< IntersectionLocal< 2, 2 >> &storage)
void print_mesh_to_file_13(std::string name)
Generates a mesh file of the given name, including the intersection.
Common base for intersection object.
Definition: mesh.h:78
Class represents intersection of two elements.
InspectElementsAlgorithm< 1 > algorithm13_
std::vector< std::vector< ILpair > > element_intersections_
Implements algorithm for finding 2D-2D intersections.
void print_mesh_to_file_23(std::string name)
void compute_intersections_12_2(std::vector< IntersectionLocal< 1, 2 >> &storage)
InspectElementsAlgorithm< 2 > algorithm23_
void compute_intersections_12_1(std::vector< IntersectionLocal< 1, 2 >> &storage)
std::pair< unsigned int, IntersectionLocalBase * > ILpair
std::vector< IntersectionLocal< 1, 3 > > intersection_storage13_
Stores 1D-3D intersections.
void append_to_index(std::vector< IntersectionLocal< dim_A, dim_B >> &storage)
double measure_13()
Computes the size of the intersection in dim dimenstions.
void compute_intersections(IntersectionType d=IntersectionType::all)
void store_intersection(std::vector< IntersectionLocal< dim_A, dim_B >> &storage, IntersectionAux< dim_A, dim_B > &isec_aux)
unsigned int number_of_components(unsigned int dim)
InspectElementsAlgorithm22 algorithm22_
InspectElementsAlgorithm12 algorithm12_
Internal auxiliary class representing intersection object of simplex<dimA> and simplex<dimB>.
std::vector< IntersectionLocal< 2, 2 > > intersection_storage22_
Stores 2D-2D intersections.
void compute_intersections_12_3(std::vector< IntersectionLocal< 1, 2 >> &storage)
std::vector< IntersectionLocal< 1, 2 > > intersection_storage12_
Stores 1D-2D intersections.
Implements algorithm for finding 1D-2D intersections.
std::vector< IntersectionLocal< 2, 3 > > intersection_storage23_
Stores 2D-3D intersections.
Main class for computation of intersection of meshes of combined dimensions.