Flow123d
release_3.0.0-968-gc87a28e79
flow123d
src
mesh
node_accessor.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 node_accessor.hh
15
* @brief
16
*/
17
18
#ifndef NODE_ACCESSOR_HH_
19
#define NODE_ACCESSOR_HH_
20
21
#include "
mesh/nodes.hh
"
22
#include "
mesh/mesh.h
"
23
24
/**
25
* Node accessor templated just by dimension of the embedding space, used for access to nodes out of Mesh.
26
* This should allow algorithms over nodes.
27
*/
28
template
<
int
spacedim>
29
class
NodeAccessor
{
30
public
:
31
/**
32
* Default invalid accessor.
33
*/
34
NodeAccessor
()
35
:
mesh_
(NULL)
36
{}
37
38
/**
39
* Node accessor.
40
*/
41
NodeAccessor
(
const
Mesh
*mesh,
unsigned
int
idx
)
42
:
mesh_
(mesh),
node_idx_
(
idx
)
43
{}
44
45
inline
bool
is_valid
()
const
{
46
return
mesh_
!= NULL;
47
}
48
49
inline
const
Node
*
node
()
const
{
50
return
&(
mesh_
->
node_vec_
[
node_idx_
]);
51
}
52
53
inline
unsigned
int
idx
()
const
{
54
return
node_idx_
;
55
}
56
57
inline
unsigned
int
index
()
const
{
58
return
(
unsigned
int
)
mesh_
->
find_node_id
(
node_idx_
);
59
}
60
61
inline
void
inc
() {
62
ASSERT
(
is_valid
()).error(
"Do not call inc() for invalid accessor!"
);
63
node_idx_
++;
64
}
65
66
bool
operator==
(
const
NodeAccessor<spacedim>
& other) {
67
return
(
node_idx_
== other.
node_idx_
);
68
}
69
70
/**
71
* -> dereference operator
72
*
73
* Allow simplify calling of node() method. Example:
74
@code
75
NodeAccessor<3> node_ac(mesh, index);
76
arma::vec centre;
77
centre = node_ac.node()->point(); // full format of access to node
78
centre = node_ac->point(); // short format with dereference operator
79
@endcode
80
*/
81
inline
const
Node
*
operator ->
()
const
{
82
return
&(
mesh_
->
node_vec_
[
node_idx_
]);
83
}
84
85
private
:
86
/// Pointer to the mesh owning the node.
87
const
Mesh
*
mesh_
;
88
89
/// Index into Mesh::node_vec_ array.
90
unsigned
int
node_idx_
;
91
};
92
93
94
#endif
/* NODE_ACCESSOR_HH_ */
NodeAccessor::node
const Node * node() const
Definition:
node_accessor.hh:49
NodeAccessor::is_valid
bool is_valid() const
Definition:
node_accessor.hh:45
ASSERT
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
Definition:
asserts.hh:346
NodeAccessor::index
unsigned int index() const
Definition:
node_accessor.hh:57
NodeAccessor::mesh_
const Mesh * mesh_
Pointer to the mesh owning the node.
Definition:
node_accessor.hh:87
nodes.hh
Nodes of a mesh.
NodeAccessor::operator->
const Node * operator->() const
Definition:
node_accessor.hh:81
NodeAccessor::operator==
bool operator==(const NodeAccessor< spacedim > &other)
Definition:
node_accessor.hh:66
NodeAccessor::NodeAccessor
NodeAccessor()
Definition:
node_accessor.hh:34
Mesh::node_vec_
vector< Node > node_vec_
Definition:
mesh.h:539
NodeAccessor::inc
void inc()
Definition:
node_accessor.hh:61
mesh.h
NodeAccessor::node_idx_
unsigned int node_idx_
Index into Mesh::node_vec_ array.
Definition:
node_accessor.hh:90
Mesh
Definition:
mesh.h:80
Node
Definition:
nodes.hh:31
NodeAccessor
Definition:
mesh.h:54
Mesh::find_node_id
int find_node_id(unsigned int pos) const
Return node id (in GMSH file) of node of given position in node vector.
Definition:
mesh.h:382
NodeAccessor::idx
unsigned int idx() const
Definition:
node_accessor.hh:53
NodeAccessor::NodeAccessor
NodeAccessor(const Mesh *mesh, unsigned int idx)
Definition:
node_accessor.hh:41
Generated by
1.8.17