3#ifndef DUNE_DGF_INTERVALBLOCK_HH
4#define DUNE_DGF_INTERVALBLOCK_HH
10#include <dune/grid/io/file/dgfparser/blocks/basic.hh>
25 Interval(
const Interval& interval,
const std::vector<int>& map )
27 copy( interval, map );
29 void copy(
const Interval& interval,
const std::vector<int>& map )
31 const int size = map.size();
36 assert( size ==
int(interval.n.size()) );
37 for(
int i=0; i<size; ++i )
39 p[ 0 ][ i ] = interval.p[ 0 ][ map[ i ] ];
40 p[ 1 ][ i ] = interval.p[ 1 ][ map[ i ] ];
41 n[ i ] = interval.n[ map[ i ] ];
42 h[ i ] = interval.h[ map[ i ] ];
45 std::array< std::vector< double >, 2 > p;
46 std::vector< double > h;
51 std::vector< Interval > intervals_;
52 std::vector< int > map_;
57 explicit IntervalBlock ( std::istream &in );
59 void get ( std::vector< std::vector< double > > &vtx,
int &nofvtx,
60 std::vector< std::vector< unsigned int > > &
simplex,
int &nofsimpl )
62 for(
size_t i = 0; i < intervals_.size(); ++i )
65 nofvtx += getVtx( i, vtx );
66 nofsimpl += getHexa( i,
simplex, oldvtx );
70 void get ( std::vector< std::vector< double > > &vtx,
int &nofvtx )
72 for(
size_t i = 0; i < intervals_.size(); ++i )
73 nofvtx += getVtx( i, vtx );
76 const Interval &get (
int block )
const
78 return intervals_[ block ];
81 int numIntervals ()
const
83 return intervals_.size();
91 int getVtx (
int block, std::vector< std::vector< double > > &vtx )
const;
92 int getHexa (
int block, std::vector< std::vector< unsigned int > > &cubes,
93 int offset = 0 )
const;
95 int nofvtx (
int block )
const
97 const Interval &interval = get( block );
99 for(
int i = 0; i < dimw_; ++i )
100 n *= (interval.n[ i ] + 1);
104 int nofhexa (
int block )
const
106 const Interval &interval = get( block );
108 for(
int i = 0; i < dimw_; ++i )
109 n *= interval.n[ i ];
115 void parseLine ( std::vector< T > &v );
120 inline std::ostream &
121 operator<< ( std::ostream &out,
const IntervalBlock::Interval &interval )
123 if( interval.p[ 0 ].empty() || interval.p[ 1 ].empty() || interval.n.empty() )
124 return out <<
"Interval {}";
126 out <<
"Interval { p0 = (" << interval.p[ 0 ][ 0 ];
127 for(
size_t i = 1; i < interval.p[ 0 ].size(); ++i )
128 out <<
", " << interval.p[ 0 ][ i ];
129 out <<
"), p1 = (" << interval.p[ 1 ][ 0 ];
130 for(
size_t i = 1; i < interval.p[ 1 ].size(); ++i )
131 out <<
", " << interval.p[ 1 ][ i ];
132 out <<
"), n = (" << interval.n[ 0 ];
133 for(
size_t i = 1; i < interval.n.size(); ++i )
134 out <<
", " << interval.n[ i ];
constexpr GeometryType simplex(unsigned int dim)
Returns a GeometryType representing a simplex of dimension dim.
Definition: type.hh:461
Dune namespace.
Definition: alignedallocator.hh:11