Flow123d  master-1fea4ce
surface_depth.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 surface_depth.hh
15  * @brief
16  */
17 
18 #ifndef SURFACE_DEPTH_HH_
19 #define SURFACE_DEPTH_HH_
20 
21 #include <string>
22 #include <vector>
23 #include <armadillo>
24 #include "mesh/bih_tree.hh"
25 #include "input/input_exception.hh"
26 
27 class Mesh;
28 
29 
31 {
32 public:
33  /// Declaration of exceptions
34  TYPEDEF_ERR_INFO( EI_Message, const std::string);
35  TYPEDEF_ERR_INFO( EI_RegionName, const std::string);
36  TYPEDEF_ERR_INFO( EI_FieldTime, double);
37  TYPEDEF_ERR_INFO( EI_Xcoord, double);
38  TYPEDEF_ERR_INFO( EI_Ycoord, double);
39  TYPEDEF_ERR_INFO( EI_Zcoord, double);
40  TYPEDEF_ERR_INFO( EI_SnapDistance, double);
41  DECLARE_INPUT_EXCEPTION(ExcSurfaceProjection, << EI_Message::val );
42  DECLARE_INPUT_EXCEPTION(ExcTooLargeSnapDistance, << "Distance of projected point during calculation of surface depth is larger "
43  << "than the global snap radius limit!\nRegion: " << EI_RegionName::qval << ", time: " << EI_FieldTime::val
44  << ", coordinates of projected point: [" << EI_Xcoord::val << ", " << EI_Ycoord::val << ", " << EI_Zcoord::val
45  << "], distance of nearest element: " << EI_SnapDistance::val );
46 
47  /**
48  * Constructor
49  */
50  SurfaceDepth(const Mesh *mesh, std::string surface_region, std::string surface_direction);
51 
52  /// Compute distance of point from given surface region (was set in constructor)
53  double compute_distance(arma::vec3 point);
54 
55 protected:
56  /// Create projection matrix \p m_
57  void create_projection_matrix(arma::vec3 surface_vec);
58 
59  /// Construct BIH tree above surface region of given name.
60  void construct_bih_tree(Mesh *mesh, std::string surface_region);
61 
62  /// Precompute solve of distance in transformed coordinations of surface element plane.
63  void prepare_distance_solve(unsigned int elem_idx, arma::vec3 &point, arma::vec3 &x);
64 
65  /// Tree of mesh elements
67 
68  /// normal vector of surface plane
70 
71  /// projection matrix
73 
74  /// vector of inversion projection matrices of elements above which BIH tree is created
76 
77  /// vector of b-vectors (right side of equation system) of elements above which BIH tree is created
79 
80  /// Projection search radius given from global_snap_radius of mesh
82 
83  /// Surface region name (need for exception)
84  std::string surface_region_;
85 
86  /// Surface region name (need for exception)
88 };
89 
90 #endif /* SURFACE_DEPTH_HH_ */
Class for O(log N) lookup for intersections with a set of bounding boxes.
Definition: bih_tree.hh:38
Definition: mesh.h:362
void create_projection_matrix(arma::vec3 surface_vec)
Create projection matrix m_.
TYPEDEF_ERR_INFO(EI_SnapDistance, double)
void construct_bih_tree(Mesh *mesh, std::string surface_region)
Construct BIH tree above surface region of given name.
double projection_search_radius_
Projection search radius given from global_snap_radius of mesh.
std::vector< arma::vec3 > b_vecs_
vector of b-vectors (right side of equation system) of elements above which BIH tree is created
double compute_distance(arma::vec3 point)
Compute distance of point from given surface region (was set in constructor)
DECLARE_INPUT_EXCEPTION(ExcSurfaceProjection,<< EI_Message::val)
DECLARE_INPUT_EXCEPTION(ExcTooLargeSnapDistance,<< "Distance of projected point during calculation of surface depth is larger "<< "than the global snap radius limit!\nRegion: "<< EI_RegionName::qval<< ", time: "<< EI_FieldTime::val<< ", coordinates of projected point: ["<< EI_Xcoord::val<< ", "<< EI_Ycoord::val<< ", "<< EI_Zcoord::val<< "], distance of nearest element: "<< EI_SnapDistance::val)
TYPEDEF_ERR_INFO(EI_Ycoord, double)
std::vector< unsigned int > searched_elements_
Surface region name (need for exception)
std::string surface_region_
Surface region name (need for exception)
arma::mat m_
projection matrix
TYPEDEF_ERR_INFO(EI_Message, const std::string)
Declaration of exceptions.
void prepare_distance_solve(unsigned int elem_idx, arma::vec3 &point, arma::vec3 &x)
Precompute solve of distance in transformed coordinations of surface element plane.
arma::vec3 surface_norm_vec_
normal vector of surface plane
TYPEDEF_ERR_INFO(EI_RegionName, const std::string)
TYPEDEF_ERR_INFO(EI_Zcoord, double)
std::vector< arma::mat > inv_projection_
vector of inversion projection matrices of elements above which BIH tree is created
TYPEDEF_ERR_INFO(EI_FieldTime, double)
SurfaceDepth(const Mesh *mesh, std::string surface_region, std::string surface_direction)
BIHTree bih_tree_
Tree of mesh elements.
TYPEDEF_ERR_INFO(EI_Xcoord, double)
ArmaMat< double, N, M > mat
Definition: armor.hh:936