3#ifndef DUNE_DGF_BOUNDARYDOMBLOCK_HH
4#define DUNE_DGF_BOUNDARYDOMBLOCK_HH
10#include <dune/grid/io/file/dgfparser/blocks/basic.hh>
11#include <dune/grid/io/file/dgfparser/parser.hh>
26 parameter_( DGFBoundaryParameter::defaultValue() ),
33 DomainData (
int id, BoundaryParameter parameter,
bool defaultData =
false )
35 parameter_( parameter ),
36 defaultData_( defaultData )
46 bool hasParameter ()
const
48 return (!parameter_.empty());
52 const BoundaryParameter & parameter ()
const
58 void reset (
int id, BoundaryParameter parameter,
bool defaultData =
false )
61 parameter_ = parameter;
62 defaultData_ = defaultData;
66 bool isDefault ()
const
71 friend std::ostream &
operator<< ( std :: ostream & os,
const DomainData & ddata )
73 os <<
"domain data: id = " << ddata.id();
74 if( ddata.hasParameter() )
75 os <<
", parameter = " << ddata.parameter();
81 BoundaryParameter parameter_;
90 const int dimensionworld;
95 Domain( std::vector< double > p1, std::vector< double > p2,
int id, BoundaryParameter & parameter )
96 : dimensionworld( p1.size() ),
99 data_( id, parameter )
101 if(
int( p2.size() ) != dimensionworld )
104 "ERROR in " << *
this <<
"!");
109 Domain( std::vector< double > p1, std::vector< double > p2, DomainData & data )
110 : dimensionworld( p1.size() ),
115 if(
int( p2.size() ) != dimensionworld )
118 "ERROR in " << *
this <<
"!");
123 Domain (
const Domain & other )
124 : dimensionworld( other.dimensionworld ),
125 left_( other.left_ ),
126 right_( other.right_ ),
129 if( dimensionworld != other.dimensionworld )
132 "ERROR in " << *
this <<
"!");
137 Domain & operator = (
const Domain & other )
139 if( dimensionworld != other.dimensionworld )
142 "ERROR in " << *
this <<
"!");
146 right_= other.right_;
152 template<
class Vector >
153 bool contains (
const Vector & x )
const
156 for(
int i = 0; i < dimensionworld; ++i )
158 if( x[ i ] < left_[ i ] || x[ i ] > right_[ i ] )
164 const DomainData & data ()
const
170 friend std::ostream &
operator<< ( std :: ostream &os,
const Domain & domain )
172 os <<
"domain: " << std::endl;
174 for(
int i = 0; i < domain.dimensionworld; ++i )
175 os << domain.left_[ i ] <<
" ";
178 for(
int i = 0; i < domain.dimensionworld; ++i )
179 os << domain.right_[ i ] <<
" ";
186 std::vector< double > left_, right_;
191 class BoundaryDomBlock
203 DomainData * default_;
207 std::vector< Domain > domains_;
211 BoundaryDomBlock ( std::istream & in,
int cdimworld );
224 return ( counter_ < ndomains_ );
228 const Domain & domain ()
const
230 return domains_.at( counter_ );
234 bool hasDefaultData ()
const
236 return bool( default_ );
240 const DomainData * defaultData ()
const
247 bool hasParameter ()
const;
258 return ( counter_ <= ndomains_ );
263 template<
class Vector >
264 const DomainData * contains (
const std::vector< Vector > & v )
const
266 std::vector< int > index( ndomains_ );
267 for(
int i = 0; i < ndomains_; ++i)
271 for(
size_t i = 0; i < N; ++i )
276 const int n = index.size();
278 for(
int j = n-1; j >= 0; --j )
280 bool inside = domains_[ index[ j ] ].contains( v[ i ] );
282 index.erase( index.begin() + j );
291 if( index.size() > 1 )
292 dwarn <<
"WARNING: ambiguous boundary domain assignment, use first boundary domain in list" << std::endl;
294 return &domains_[ index[ 0 ] ].data();
std::ostream & operator<<(std::ostream &s, const array< T, N > &e)
Output operator for array.
Definition: array.hh:159
#define DUNE_THROW(E, m)
Definition: exceptions.hh:244
DWarnType dwarn(std::cerr)
Stream for warnings indicating problems.
Definition: stdstreams.hh:160
Dune namespace.
Definition: alignment.hh:14
std::string type
type of additional boundary parameters
Definition: parser.hh:23