Plugins
Loading...
Searching...
No Matches
ls_init.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015: G-CSC, Goethe University Frankfurt
3 * Authors: Christian Wehner, Dmitry Logashenko
4 *
5 * This file is part of UG4.
6 *
7 * UG4 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License version 3 (as published by the
9 * Free Software Foundation) with the following additional attribution
10 * requirements (according to LGPL/GPL v3 §7):
11 *
12 * (1) The following notice must be displayed in the Appropriate Legal Notices
13 * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 *
15 * (2) The following notice must be displayed at a prominent place in the
16 * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 *
18 * (3) The following bibliography is recommended for citation and must be
19 * preserved in all covered files:
20 * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 * parallel geometric multigrid solver on hierarchically distributed grids.
22 * Computing and visualization in science 16, 4 (2013), 151-164"
23 * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 * flexible software system for simulating pde based models on high performance
25 * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU Lesser General Public License for more details.
31 */
32
33/*
34 * Initialization of the level-set function.
35 */
36
37#ifndef __H__UG__PLUGINS__LEVEL_SET__LS_INIT_H__
38#define __H__UG__PLUGINS__LEVEL_SET__LS_INIT_H__
39
40#include <vector>
41
42// ug4 headers
43#include "common/common.h"
44#include "common/util/raster.h"
47
48namespace ug{
49namespace LevelSet{
50
59template <typename TGridFunc>
61{
64
66 typedef TGridFunc grid_func_type;
67
69 typedef typename TGridFunc::domain_type domain_type;
70
72 typedef typename TGridFunc::algebra_type algebra_type;
73
75 typedef typename domain_type::grid_type grid_type;
76
78 typedef typename domain_type::position_attachment_type position_attachment_type;
79
81 typedef typename domain_type::position_accessor_type position_accessor_type;
82
84 static const int dim = TGridFunc::dim;
85
87 typedef typename TGridFunc::template traits<Vertex>::const_iterator VertexConstIterator;
88
91
94
95public:
96
99 (
100 const char * raster_file
101 )
102 : m_bRelative (false), m_rt_gl (-1), m_rt_tol (1e-6), m_bDefaultTop (false), m_localTopFacesOnly (false)
103 {
104 m_raster.load_from_asc(raster_file);
105 }
106
108 void interpolate_to
109 (
111 );
112
115 (
116 const char * top_ss_names
117 )
118 {
119 m_top_ss_names = top_ss_names;
120 m_bRelative = true;
121 }
122
125 (
126 const char * top_ss_names,
127 int grid_level
128 )
129 {
130 m_top_ss_names = top_ss_names;
131 m_rt_gl = grid_level;
132 m_bRelative = true;
133 }
134
137 (
138 number tolerance
139 )
140 {
141 m_rt_tol = tolerance;
142 }
143
146 (
147 number default_top_z
148 )
149 {
150 m_rt_default = default_top_z;
151 m_bDefaultTop = true;
152 }
153
155
157 bool localTopFacesOnly
158 )
159 {
160 m_localTopFacesOnly = localTopFacesOnly;
161 }
162
163private:
164
166 typedef Raster<number, dim - 1> raster_t;
168
171
173 std::string m_top_ss_names;
174
177
180
183
186
188
189
192 {
194
196
197 public:
198
201 (
202 SmartPtr<domain_type> sp_domain,
203 const std::string & top_ss_names
204 )
205 : m_sp_domain (sp_domain),
206 m_top_ss_grp (sp_domain->subset_handler (), TokenizeString (top_ss_names))
207 {};
208
210 void init
211 (
212 int grid_level
213 );
214
215 void init
216 (
217 int grid_level,
218 bool useLocalTopFacesOnly
219 );
220
222 bool get_min_at
223 (
224 const MathVector<dim> & over,
225 number tolerance,
226 number & z
227 );
228
229 private:
230
233
236
237# ifdef UG_PARALLEL
240# endif
243
245 std::vector<top_intersection_record_t> m_top_intersection_records;
246 };
247
248};
249
250} // end namespace LevelSet
251} // end namespace ug
252
253// include implementation
254#include "ls_init_impl.h"
255
256#endif // __H__UG__PLUGINS__LEVEL_SET__LS_INIT_H__
257
258/* End of File */
an auxiliary class for the computation of the relative height
Definition ls_init.h:192
SmartPtr< domain_type > m_sp_domain
multigrid of the domain
Definition ls_init.h:232
std::vector< top_intersection_record_t > m_top_intersection_records
array to store all the intersections
Definition ls_init.h:245
lg_ntree< dim-1, dim, side_t > top_tracer_tree_t
Definition ls_init.h:193
RayElemIntersectionRecord< side_t * > top_intersection_record_t
Definition ls_init.h:195
Grid m_top_grid
auxiliary grid of the top faces
Definition ls_init.h:239
z_ray_tracer_t(SmartPtr< domain_type > sp_domain, const std::string &top_ss_names)
class constructor
Definition ls_init.h:201
void init(int grid_level)
initializer: creates the tree
Definition ls_init_impl.h:115
bool get_min_at(const MathVector< dim > &over, number tolerance, number &z)
computes the minimum z-coordiate of the top (returns true if the top found, false otherwise)
Definition ls_init_impl.h:220
top_tracer_tree_t m_top_tracer_tree
tracer tree of the top faces
Definition ls_init.h:242
SubsetGroup m_top_ss_grp
subset group of the top faces
Definition ls_init.h:235
Definition ls_init.h:61
number m_rt_default
default position of the top (if the ray tracing fails) - used only if m_bRelative
Definition ls_init.h:182
void set_local_top_faces_only(bool localTopFacesOnly)
if relative values are used, tells whether the value can be obtained by local top faces only
Definition ls_init.h:156
domain_type::position_accessor_type position_accessor_type
type of the position accessor
Definition ls_init.h:81
void set_rel_default(number default_top_z)
sets default position of the top (only used if m_bRelative)
Definition ls_init.h:146
bool m_localTopFacesOnly
Definition ls_init.h:187
static const int dim
world dimension
Definition ls_init.h:84
raster_t m_raster
Definition ls_init.h:167
LSFbyRaster< TGridFunc > this_type
this type
Definition ls_init.h:63
void interpolate_to(SmartPtr< TGridFunc > spLSF)
computes the level-set function
Definition ls_init_impl.h:54
TGridFunc::template traits< Vertex >::const_iterator VertexConstIterator
vertex base iterator
Definition ls_init.h:87
int m_rt_gl
grid level of the top surface (or -1 if the surface)
Definition ls_init.h:176
number m_rt_tol
tolerance for the ray tracing (to the top surfaces)
Definition ls_init.h:179
grid_dim_traits< dim-1 >::element_type side_t
side type
Definition ls_init.h:93
bool m_bDefaultTop
whether the default position of the top is specified
Definition ls_init.h:185
void set_rel_tolerance(number tolerance)
sets the tolerance for getting the position of the top (only used if m_bRelative)
Definition ls_init.h:137
TGridFunc grid_func_type
grid function type
Definition ls_init.h:66
TGridFunc::algebra_type algebra_type
type of the algebra
Definition ls_init.h:72
bool m_bRelative
whether relative to the top
Definition ls_init.h:170
LSFbyRaster(const char *raster_file)
class constructor
Definition ls_init.h:99
grid_dim_traits< dim >::element_type elem_t
element type
Definition ls_init.h:90
domain_type::position_attachment_type position_attachment_type
type of the position accessor
Definition ls_init.h:78
Raster< number, dim - 1 > raster_t
the raster of the heights
Definition ls_init.h:166
std::string m_top_ss_names
top subsets (if specified)
Definition ls_init.h:173
void set_relative_to(const char *top_ss_names, int grid_level)
sets the top subset
Definition ls_init.h:125
TGridFunc::domain_type domain_type
type of the domain
Definition ls_init.h:69
void set_relative_to(const char *top_ss_names)
sets the top subset
Definition ls_init.h:115
domain_type::grid_type grid_type
grid type
Definition ls_init.h:75
void load_from_asc(const char *filename)
SmartPtr< TSubsetHandler > subset_handler()
int element_type() const
vector< string > TokenizeString(const char *str, const char delimiter=',')
double number