Flow123d  3.9.0-c09ffe475
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_
MixedMeshIntersections::store_intersection
void store_intersection(std::vector< IntersectionLocal< dim_A, dim_B >> &storage, IntersectionAux< dim_A, dim_B > &isec_aux)
Definition: mixed_mesh_intersections.cc:106
d12_3
@ d12_3
Definition: mixed_mesh_intersections.hh:44
InspectElementsAlgorithm22
Implements algorithm for finding 2D-2D intersections.
Definition: inspect_elements_algorithm.hh:196
MixedMeshIntersections::measure_23
double measure_23()
Definition: mixed_mesh_intersections.cc:65
MixedMeshIntersections::algorithm22_
InspectElementsAlgorithm22 algorithm22_
Definition: mixed_mesh_intersections.hh:111
MixedMeshIntersections::compute_intersections_12_3
void compute_intersections_12_3(std::vector< IntersectionLocal< 1, 2 >> &storage)
Definition: mixed_mesh_intersections.cc:242
d12_1
@ d12_1
Definition: mixed_mesh_intersections.hh:42
d23
@ d23
Definition: mixed_mesh_intersections.hh:40
MixedMeshIntersections
Main class for computation of intersection of meshes of combined dimensions.
Definition: mixed_mesh_intersections.hh:64
MixedMeshIntersections::compute_intersections_12_2
void compute_intersections_12_2(std::vector< IntersectionLocal< 1, 2 >> &storage)
Definition: mixed_mesh_intersections.cc:283
none
@ none
Definition: mixed_mesh_intersections.hh:38
d13
@ d13
Definition: mixed_mesh_intersections.hh:39
MixedMeshIntersections::algorithm23_
InspectElementsAlgorithm< 2 > algorithm23_
Definition: mixed_mesh_intersections.hh:110
MixedMeshIntersections::compute_intersections_12_1
void compute_intersections_12_1(std::vector< IntersectionLocal< 1, 2 >> &storage)
Definition: mixed_mesh_intersections.cc:303
std::vector
Definition: doxy_dummy_defs.hh:7
input_type_forward.hh
MixedMeshIntersections::intersection_storage13_
std::vector< IntersectionLocal< 1, 3 > > intersection_storage13_
Stores 1D-3D intersections.
Definition: mixed_mesh_intersections.hh:68
InspectElementsAlgorithm< 1 >
MixedMeshIntersections::MixedMeshIntersections
MixedMeshIntersections(Mesh *mesh)
Definition: mixed_mesh_intersections.cc:25
MixedMeshIntersections::~MixedMeshIntersections
~MixedMeshIntersections()
Definition: mixed_mesh_intersections.cc:29
MixedMeshIntersections::number_of_components
unsigned int number_of_components(unsigned int dim)
Definition: mixed_mesh_intersections.cc:33
IntersectionType
IntersectionType
Selection of intersections of different dimensions.
Definition: mixed_mesh_intersections.hh:36
inspect_elements_algorithm.hh
MixedMeshIntersections::algorithm12_
InspectElementsAlgorithm12 algorithm12_
Definition: mixed_mesh_intersections.hh:112
MixedMeshIntersections::compute_intersections_22
void compute_intersections_22(std::vector< IntersectionLocal< 2, 2 >> &storage)
Definition: mixed_mesh_intersections.cc:195
MixedMeshIntersections::mesh
Mesh * mesh
Mesh pointer.
Definition: mixed_mesh_intersections.hh:107
MixedMeshIntersections::compute_intersections
void compute_intersections(IntersectionType d=IntersectionType::all)
Definition: mixed_mesh_intersections.cc:323
MixedMeshIntersections::print_mesh_to_file_13
void print_mesh_to_file_13(std::string name)
Generates a mesh file of the given name, including the intersection.
Definition: mixed_mesh_intersections.cc:400
InspectElementsAlgorithm12
Implements algorithm for finding 1D-2D intersections.
Definition: inspect_elements_algorithm.hh:251
MixedMeshIntersections::intersection_storage22_
std::vector< IntersectionLocal< 2, 2 > > intersection_storage22_
Stores 2D-2D intersections.
Definition: mixed_mesh_intersections.hh:72
MixedMeshIntersections::algorithm13_
InspectElementsAlgorithm< 1 > algorithm13_
Definition: mixed_mesh_intersections.hh:109
d12
@ d12
Definition: mixed_mesh_intersections.hh:45
MixedMeshIntersections::element_intersections_
std::vector< std::vector< ILpair > > element_intersections_
Definition: mixed_mesh_intersections.hh:83
d22
@ d22
Definition: mixed_mesh_intersections.hh:41
Mesh
Definition: mesh.h:361
MixedMeshIntersections::intersection_storage23_
std::vector< IntersectionLocal< 2, 3 > > intersection_storage23_
Stores 2D-3D intersections.
Definition: mixed_mesh_intersections.hh:70
MixedMeshIntersections::intersection_storage12_
std::vector< IntersectionLocal< 1, 2 > > intersection_storage12_
Stores 1D-2D intersections.
Definition: mixed_mesh_intersections.hh:74
MixedMeshIntersections::print_mesh_to_file_23
void print_mesh_to_file_23(std::string name)
Definition: mixed_mesh_intersections.cc:495
IntersectionAux
Internal auxiliary class representing intersection object of simplex<dimA> and simplex<dimB>.
Definition: compute_intersection.hh:47
IntersectionLocal
Class represents intersection of two elements.
Definition: inspect_elements_algorithm.hh:34
all
@ all
Definition: mixed_mesh_intersections.hh:46
MixedMeshIntersections::ILpair
std::pair< unsigned int, IntersectionLocalBase * > ILpair
Definition: mixed_mesh_intersections.hh:82
MixedMeshIntersections::measure_22
double measure_22()
Definition: mixed_mesh_intersections.cc:78
d12_2
@ d12_2
Definition: mixed_mesh_intersections.hh:43
MixedMeshIntersections::measure_13
double measure_13()
Computes the size of the intersection in dim dimenstions.
Definition: mixed_mesh_intersections.cc:41
MixedMeshIntersections::append_to_index
void append_to_index(std::vector< IntersectionLocal< dim_A, dim_B >> &storage)
Definition: mixed_mesh_intersections.cc:130
IntersectionLocalBase
Common base for intersection object.
Definition: intersection_local.hh:48