16#ifndef __H__UG__PLUGINS__LEVEL_SET_POSITION_H__
17#define __H__UG__PLUGINS__LEVEL_SET_POSITION_H__
46template <
typename TGr
idFunction>
61 typedef typename TGridFunction::element_type
elem_type;
64 static const int dim = TGridFunction::dim;
91 pnt[0] = p_min;
pnt[1] = p_max;
115 const char * lsf_cmp_name,
118 :
LSPositionZ (spLSF, spLSF->fct_id_by_name (lsf_cmp_name), ls_value)
152 std::vector<number> & z,
168 std::vector<number> z;
170 if (z.size () == 0)
return false;
172 for (
size_t i = 1; i < z.size (); i++)
189 return default_height;
196 std::vector<number>
xy
199 if (
xy.size () !=
dim - 1)
200 UG_THROW (
"LSPositionZ::height_at: Only " <<
dim - 1 <<
"coordinates may be specified!");
204 for (
size_t i = 0; i <
dim - 1; i++) xy_vec [i] =
xy [i];
206 return std::numeric_limits<number>::quiet_NaN ();
238 std::vector<number> & z,
280template <
typename TGr
idFunction>
289 static const int wDim = gf_type::dim;
348 template <
int refDim>
362 std::vector<std::vector<number> > vvvDeriv[],
369 template <
typename TElem>
391 template <
int elemDim>
395 template <
int elemDim>
428template <
typename TGr
idFunction>
437 static const int wDim = gf_type::dim;
511 template <
int refDim>
525 std::vector<std::vector<number> > vvvDeriv[],
532 template <
typename TElem>
556 template <
int elemDim>
578template <
typename TLSPosZ>
587 static const int dim = t_ls_measurer::dim;
617 std::vector<number>
xyz
620 bool z_given =
false;
628 else if (
xyz.size () !=
dim - 1)
629 UG_THROW (
"LSPositionAtPoints::add_pnt: Only " <<
dim - 1 <<
"coordinates may be specified!");
632 for (
size_t i = 0; i <
dim - 1; i++) xy_vec [i] =
xyz [i];
633 add_pnt (xy_vec, z_spec, z_given);
647 const char * file_name,
673 bool print_difference =
false
679 const char * file_name,
680 bool print_difference =
false
686 bool print_difference =
false
695 const char * file_name,
703 const char * file_name
parameterString s
Definition Biogas.lua:2
Definition level_set_pos.h:431
domain_type::grid_type grid_type
grid type
Definition level_set_pos.h:449
SmartPtr< measurer_type > m_sp_ls_pos_z
the object to measure the z-coordinate of the level set
Definition level_set_pos.h:563
LSPosZCellToVrtData< gf_type > this_type
this type
Definition level_set_pos.h:440
gf_type::domain_type domain_type
domain type
Definition level_set_pos.h:446
Attachment< number > h_a_type
type of the attachment for the averaged height at the vertices
Definition level_set_pos.h:468
bool m_use_ss_z_as_default
whether to use the z-coord. of the subset as the default value
Definition level_set_pos.h:565
~LSPosZCellToVrtData()
Destructor.
Definition level_set_pos_impl.h:652
void reinit_for(int dim)
Initializer (should be called before every use). Reinialize the measurer before running this reinit!
Definition level_set_pos_impl.h:892
void reinit_for_()
Initializer for the constant dimensionality.
Definition level_set_pos_impl.h:709
Attachment< size_t > num_a_type
type of the attachment numbering the elements
Definition level_set_pos.h:459
number m_default_height
the default value of the z-coordinate if the level set is not found
Definition level_set_pos.h:566
virtual bool requires_grid_fct() const
Returns true to get the grid element in the evaluation routine.
Definition level_set_pos.h:508
StdDependentUserData< this_type, number, wDim > base_type
the base type
Definition level_set_pos.h:443
h_a_type m_a_height
attachment keeping the averaged height at the vertex
Definition level_set_pos.h:570
TGridFunction gf_type
type of the grid function
Definition level_set_pos.h:434
LSPositionZ< TGridFunction > measurer_type
type of the class for measuring the height of the level-set
Definition level_set_pos.h:456
Grid::AttachmentAccessor< Vertex, h_a_type > h_aa_t
type of the attachment accessor for the averaged height at the vertices
Definition level_set_pos.h:471
static const int wDim
world dimension
Definition level_set_pos.h:437
domain_type::position_accessor_type pos_acc_type
position attachment accessor type
Definition level_set_pos.h:452
Attachment< size_t > cnt_a_type
type of the attachment for counting elements adjecent to the vertices
Definition level_set_pos.h:462
void reinit()
Initializer (should be called before every use). Reinialize the measurer before running this reinit!
Definition level_set_pos_impl.h:917
void eval_and_deriv(number vValue[], const MathVector< wDim > vGlobIP[], number time, int si, GridObject *elem, const MathVector< wDim > vCornerCoords[], const MathVector< refDim > vLocIP[], const size_t nip, LocalVector *u, bool bDeriv, int s, std::vector< std::vector< number > > vvvDeriv[], const MathMatrix< refDim, wDim > *vJT=NULL)
Performs the main computations:
Definition level_set_pos_impl.h:939
SubsetGroup m_SsGrp
(low-dimensional) subsets to compute the coordinates over
Definition level_set_pos.h:561
Grid::AttachmentAccessor< Vertex, cnt_a_type > cnt_aa_t
type of the attachment accessor for counting elements adjecent to the vertices
Definition level_set_pos.h:465
cnt_a_type m_a_vrt_div
attachment keeping the number of the elements adjecent to a vertex
Definition level_set_pos.h:569
void get_xy_for_all_(num_a_type &a_elem_num, MathVector< wDim-1 > *xy_pos, number *z_pos)
Computes the xy-coordinates of the evaluation points for all elements of the given type.
Definition level_set_pos_impl.h:666
int m_elem_dim
dimensionality of the elements (-1 = not initizlised)
Definition level_set_pos.h:568
void set_default_height(number defaultHeight)
sets the default value for the points with no level set
Definition level_set_pos.h:487
virtual bool continuous() const
We consider here the height as a continuous field as it is represented at vertices.
Definition level_set_pos.h:505
Definition level_set_pos.h:283
static const int wDim
world dimension
Definition level_set_pos.h:289
void set_default_height(number defaultHeight)
sets the default value for the points with no level set
Definition level_set_pos.h:324
void reinit()
Initializer (should be called before every use). Reinialize the measurer before running this reinit!
Definition level_set_pos_impl.h:521
SmartPtr< measurer_type > m_sp_ls_pos_z
the object to measure the z-coordinate of the level set
Definition level_set_pos.h:408
domain_type::position_accessor_type pos_acc_type
position attachment accessor type
Definition level_set_pos.h:301
TGridFunction gf_type
type of the grid function
Definition level_set_pos.h:286
LSPosZData< gf_type > this_type
this type
Definition level_set_pos.h:292
StdDependentUserData< this_type, number, wDim > base_type
the base type
Definition level_set_pos.h:295
~LSPosZData()
Destructor.
Definition level_set_pos_impl.h:279
number m_default_height
the default value of the z-coordinate if the level set is not found
Definition level_set_pos.h:411
void reinit_for(int dim)
Initializer (should be called before every use). Reinialize the measurer before running this reinit!
Definition level_set_pos_impl.h:499
void eval_and_deriv(number vValue[], const MathVector< wDim > vGlobIP[], number time, int si, GridObject *elem, const MathVector< wDim > vCornerCoords[], const MathVector< refDim > vLocIP[], const size_t nip, LocalVector *u, bool bDeriv, int s, std::vector< std::vector< number > > vvvDeriv[], const MathMatrix< refDim, wDim > *vJT=NULL)
Performs the main computations:
Definition level_set_pos_impl.h:543
bool m_use_ss_z_as_default
whether to use the z-coord. of the subset as the default value
Definition level_set_pos.h:410
virtual bool continuous() const
We consider here the height as a continuous field only if it is evaluated at vertices.
Definition level_set_pos.h:342
void get_xy_for_all_(MathVector< wDim-1 > *xy_pos, number *z_pos)
Computes the xy-coordinates of the evaluation points for all elements of the given type.
Definition level_set_pos_impl.h:290
std::vector< number > m_elem_z
z-coordinates of the level set at the elements of the subsets
Definition level_set_pos.h:415
LSPositionZ< TGridFunction > measurer_type
type of the class for measuring the height of the level-set
Definition level_set_pos.h:305
void detach_for_()
Destroys the attachment (for the templated dimensionality)
Definition level_set_pos_impl.h:468
num_a_type m_a_elem_num
attachment keeping a numbering of the elements (vertices etc.) in the subsets
Definition level_set_pos.h:414
void reinit_for_()
Initializer for the constant dimensionality.
Definition level_set_pos_impl.h:330
Attachment< size_t > num_a_type
type of the attachment numbering the elements
Definition level_set_pos.h:308
virtual bool requires_grid_fct() const
Returns true to get the grid element in the evaluation routine.
Definition level_set_pos.h:345
SubsetGroup m_SsGrp
(low-dimensional) subsets to compute the coordinates over
Definition level_set_pos.h:406
void detach_for(int dim)
Destroys the attachment (for a variable dimensionality)
Definition level_set_pos_impl.h:479
int m_elem_dim
dimensionality of the elements (-1 = not initizlised)
Definition level_set_pos.h:413
gf_type::domain_type domain_type
domain type
Definition level_set_pos.h:298
Definition level_set_pos.h:580
static const int dim
world dimension
Definition level_set_pos.h:587
void append_to_table(const char *file_name, size_t step, number time)
appends the data to a given file
Definition level_set_pos_impl.h:1172
std::vector< t_pnt_data > m_v_points
the points to evaluate at
Definition level_set_pos.h:724
number spec_z_at_pnt(size_t i)
return the specified z-coordinate at point i
Definition level_set_pos.h:664
bool z_is_spec(size_t i)
return true iff the z-coordinate of point i is given
Definition level_set_pos.h:667
void compute()
compute the z-coordinates
Definition level_set_pos_impl.h:1068
void add_pnt(MathVector< dim-1 > &xy, number z_spec=0, bool z_given=false)
adds a point
Definition level_set_pos.h:604
void load_points_from(std::istream &in, bool z_given=false)
load points from a stream
Definition level_set_pos_impl.h:1008
void print_table_header(const char *file_name)
prints the table header to a given file
Definition level_set_pos_impl.h:1207
SmartPtr< t_ls_measurer > m_sp_ls_measurer
the measurer
Definition level_set_pos.h:722
void print(bool print_difference=false)
prints the table of the points into the ug shell
Definition level_set_pos.h:685
TLSPosZ t_ls_measurer
measurer type
Definition level_set_pos.h:584
size_t n_points()
returns the number points
Definition level_set_pos.h:655
void print_to(std::ostream &out, bool print_difference=false)
prints the table of the points into a given stream
Definition level_set_pos_impl.h:1114
LSPositionAtPoints(SmartPtr< t_ls_measurer > sp_ls_measurer)
constructor
Definition level_set_pos.h:593
number z_at_pnt(size_t i)
return the computed z-coordinate at point i
Definition level_set_pos.h:661
void clear_pnt()
clear the points
Definition level_set_pos.h:600
const MathVector< dim-1 > & coord(size_t i)
returns the low-dim. coordinates the point i
Definition level_set_pos.h:658
Definition level_set_pos.h:48
SmartPtr< grid_func_type > m_spLSF
level-set function
Definition level_set_pos.h:245
std::vector< elem_type * > m_vpCut
array of the intersected elements
Definition level_set_pos.h:257
TGridFunction::algebra_type algebra_type
algebra type
Definition level_set_pos.h:58
TGridFunction::element_type elem_type
generic element type
Definition level_set_pos.h:61
void get_z(std::vector< number > &z, number small_z=1e-12)
get the point at the level set
Definition level_set_pos_impl.h:122
std::vector< elem_intersect_data > m_intersections
set of the intersections
Definition level_set_pos.h:263
size_t m_lsf_fct
component for the level-set function (0 if the grid function is scalar)
Definition level_set_pos.h:248
lg_ntree< dim-1, dim, elem_type > tree_type
quad- or octtree type to search the elements
Definition level_set_pos.h:76
std::vector< intersect_rec_type > m_intersectionRecords
intersection recorder
Definition level_set_pos.h:260
number height_at_dv(const MathVector< dim-1 > &xy, number default_height)
returns the largest z-coordinate or the default value (if no intersections found)
Definition level_set_pos.h:181
void get_height(const MathVector< dim-1 > &xy, std::vector< number > &z, number small_z=1e-12)
get the z-coordinates
Definition level_set_pos.h:150
SmartPtr< grid_func_type > lsf()
returns the level-set function
Definition level_set_pos.h:130
size_t lsf_fct()
returns the component of the grid function
Definition level_set_pos.h:133
LSPositionZ(SmartPtr< grid_func_type > spLSF, size_t lsf_fct, number ls_value=0)
the most general class constructor
Definition level_set_pos.h:99
TGridFunction grid_func_type
grid function type
Definition level_set_pos.h:52
number level_set_zero()
returns the value for the level set (the s.c. "level set zero")
Definition level_set_pos.h:136
size_t m_traNI
number of iterations for the inverse transformation of the coordinates (for non-linear transformation...
Definition level_set_pos.h:268
static number lsf_threshold()
threshold for the level-set-function
Definition level_set_pos.h:73
int lsf_sign(size_t noc, number lsf[])
sign of the LSF in the element
Definition level_set_pos_impl.h:39
bool get_intersected(const MathVector< dim-1 > &xy)
get the elements intersected by the ray
Definition level_set_pos_impl.h:95
TGridFunction::domain_type domain_type
domain type
Definition level_set_pos.h:55
RayElemIntersectionRecord< elem_type * > intersect_rec_type
intersection record type
Definition level_set_pos.h:79
LSPositionZ(SmartPtr< grid_func_type > spLSF, const char *lsf_cmp_name, number ls_value=0)
class constructor
Definition level_set_pos.h:113
static const size_t maxNumCorners
max. number of the corners of the elements in the domain
Definition level_set_pos.h:67
LSPositionZ(SmartPtr< grid_func_type > spLSF)
class constructor for the simplest (and historically standard) case
Definition level_set_pos.h:123
void fill_cut()
get the elements cut by the level set
Definition level_set_pos_impl.h:58
bool get_height_at(const MathVector< dim-1 > &xy, number &height)
gets the largest z-coordinate (returns false if no intersections found)
Definition level_set_pos.h:163
number m_traTol
tolerance for the inverse transformation of the coordinates (for non-linear transformations)
Definition level_set_pos.h:266
number m_level_set_zero
value of the level set (standardly 0)
Definition level_set_pos.h:251
static const int dim
world dimension
Definition level_set_pos.h:64
void set_transform_tol(number tol, size_t nIter)
sets the tolerance for the inverce transformation of the elements (for non-linear transformations)
Definition level_set_pos.h:213
tree_type m_tree
the quad- or octtree:
Definition level_set_pos.h:254
void reinit()
initialize the object: find the intersected elements and prepare the tree
Definition level_set_pos.h:139
void create_tree(TIterator elemsBegin, TIterator elemsEnd)
void enable_warnings(bool enable)
position_attachment_type & position_attachment()
LogAssistant & GetLogAssistant()
Helper class for computation of the position of the level set in all the elements.
Definition level_set_pos.h:542
LSPosZCellToVrtData * m_pThis
Definition level_set_pos.h:543
void operator()(TElem &)
Definition level_set_pos.h:549
num_a_type & m_a_elem_num
Definition level_set_pos.h:544
number * m_z_pos
Definition level_set_pos.h:546
MathVector< wDim-1 > * m_xy_pos
Definition level_set_pos.h:545
GetXYForElements(LSPosZCellToVrtData *pThis, num_a_type &a_elem_num, MathVector< wDim-1 > *xy_pos, number *z_pos)
Definition level_set_pos.h:547
Helper class for computation of the position of the level set in all the elements.
Definition level_set_pos.h:378
number * m_z_pos
Definition level_set_pos.h:381
void operator()(TElem &)
Definition level_set_pos.h:384
LSPosZData * m_pThis
Definition level_set_pos.h:379
GetXYForElements(LSPosZData *pThis, MathVector< wDim-1 > *xy_pos, number *z_pos)
Definition level_set_pos.h:382
MathVector< wDim-1 > * m_xy_pos
Definition level_set_pos.h:380
type of point data
Definition level_set_pos.h:710
number z
computed value of the z-coordiate
Definition level_set_pos.h:712
bool z_given
iff z is specified
Definition level_set_pos.h:714
number z_spec
expected value of z-coordinate
Definition level_set_pos.h:713
t_pnt_data(MathVector< dim-1 > &the_xy, number the_z_spec, bool if_z_given)
Definition level_set_pos.h:718
MathVector< dim-1 > xy
low-dim coordinate of the point
Definition level_set_pos.h:711
bool valid
if not computed or the level set is not covered by the top surface
Definition level_set_pos.h:716
a structure to get the intersection points of an element
Definition level_set_pos.h:83
MathVector< dim > pnt[2]
the intersection points
Definition level_set_pos.h:85
elem_type * elem
the intersected element
Definition level_set_pos.h:84
elem_intersect_data(elem_type *e, MathVector< dim > p_min, MathVector< dim > p_max)
Definition level_set_pos.h:88