13 template<
class N,
class DF,
int dimension>
31 static const int negative = -1;
41 std::vector<size_type> node_map;
42 std::vector<size_type> grid_map;
43 std::vector<bool> inside_map;
44 std::vector<bool> boundary_map;
51 for(
int d=dim-1;
d>=0; --
d){
52 c[
d] = index / offsets[
d];
53 index -= c[
d] * offsets[
d];
61 for(
int d=dim-1;
d>=0; --
d)
66 inline Vector<number_type> index2world(
size_type index)
const
68 Vector<number_type> w(dim);
69 Vector<size_type> c = index2grid(index);
105 for(
int d=0;
d<dim; ++
d){
107 offsets[
d] =
d==0 ? 1 : size[
d-1] * offsets[
d-1];
113 inside_map.resize(n_nodes);
114 grid_map.resize(n_nodes);
115 boundary_map.resize(0);
116 boundary_map.resize(n_nodes,
false);
122 inside_map[n] = df.evaluate(x);
124 node_map.push_back(n);
125 grid_map[n] = node_map.size()-1;
132 for(
size_type n=0; n<node_map.size(); ++n){
133 for(
int d=0;
d<dim; ++
d){
134 for(
int s=0; s<2; ++s){
135 const int side = s*2-1;
138 boundary_map[node_map[n]] =
true;
189 return boundary_map[node_map[
ln]];
197 return node_map.size();
217 return index2world(node_map[
ln]);
220 std::vector<Vector<number_type> > getNodeCoordinates()
const
222 std::vector<Vector<number_type> >
coords;
223 for(
size_type n=0; n<node_map.size(); ++n){
225 coords.back() = index2world(node_map[n]);
Class with mathematical matrix operations.
Definition densematrix.hh:33
Structured Grid for Finite Differences.
Definition sgrid.hh:15
DF DomainFunction
Type of the function defining the domain.
Definition sgrid.hh:25
static const int positive
Side definitions for usage in getNeighborIndex(..)
Definition sgrid.hh:30
size_type getNeighborIndex(const size_type ln, const size_type n_dim, const int n_side, const int k=1) const
Provides the index of the k-th neighbor of the node with index ln.
Definition sgrid.hh:164
bool isBoundaryNode(const size_type ln) const
Returns true if the node is on the boundary of the discrete compuational domain.
Definition sgrid.hh:187
Vector< number_type > getCoordinates(const size_type ln) const
Returns the world coordinates of the node with the given node index.
Definition sgrid.hh:215
N number_type
Export number type.
Definition sgrid.hh:22
std::size_t size_type
Export size type.
Definition sgrid.hh:19
Vector< number_type > getCellWidth() const
Returns the cell width h of the structured grid.
Definition sgrid.hh:207
SGrid(const Vector< number_type > extent_, const Vector< size_type > size_, const DomainFunction &df_)
Constructor.
Definition sgrid.hh:93
const size_type invalid_node
The value which is returned to indicate an invalid node.
Definition sgrid.hh:77
size_type getNumberOfNodes() const
Returns the number of nodes which are in the compuational domain.
Definition sgrid.hh:195