5#ifndef DUNE_DGF_BOUNDARYDOMBLOCK_HH 
    6#define DUNE_DGF_BOUNDARYDOMBLOCK_HH 
   12#include <dune/grid/io/file/dgfparser/blocks/basic.hh> 
   13#include <dune/grid/io/file/dgfparser/parser.hh> 
   28          parameter_( DGFBoundaryParameter::defaultValue() ),
 
   35      DomainData ( 
int id, BoundaryParameter parameter, 
bool defaultData = 
false )
 
   37          parameter_( parameter ),
 
   38          defaultData_( defaultData )
 
   48      bool hasParameter ()
 const 
   50        return (!parameter_.empty());
 
   54      const BoundaryParameter & parameter ()
 const 
   60      void reset ( 
int id, BoundaryParameter parameter, 
bool defaultData = 
false )
 
   63        parameter_ = parameter;
 
   64        defaultData_ = defaultData;
 
   68      bool isDefault ()
 const 
   73      friend std::ostream & operator<< ( std :: ostream & os, 
const DomainData & ddata )
 
   75        os << 
"domain data: id = " << ddata.id();
 
   76        if( ddata.hasParameter() )
 
   77          os << 
", parameter = " << ddata.parameter();
 
   83      BoundaryParameter parameter_;
 
   92      const int dimensionworld;
 
   97      Domain( std::vector< double > p1, std::vector< double > p2, 
int id, BoundaryParameter & parameter )
 
   98        : dimensionworld( p1.
size() ),
 
  101          data_( id, parameter )
 
  103        if( 
int( p2.size() ) != dimensionworld )
 
  106                     "ERROR in " << *
this << 
"!");
 
  111      Domain( std::vector< double > p1, std::vector< double > p2, DomainData & data )
 
  112        : dimensionworld( p1.
size() ),
 
  117        if( 
int( p2.size() ) != dimensionworld )
 
  120                     "ERROR in " << *
this << 
"!");
 
  125      Domain ( 
const Domain & other )
 
  126        : dimensionworld( other.dimensionworld ),
 
  127          left_( other.left_ ),
 
  128          right_( other.right_ ),
 
  131        if( dimensionworld != other.dimensionworld )
 
  134                     "ERROR in " << *
this << 
"!");
 
  139      Domain & operator = ( 
const Domain & other )
 
  141        if( dimensionworld != other.dimensionworld )
 
  144                     "ERROR in " << *
this << 
"!");
 
  148        right_= other.right_;
 
  154      template< 
class Vector >
 
  155      bool contains ( 
const Vector & x )
 const 
  158        for( 
int i = 0; i < dimensionworld; ++i )
 
  160          if( x[ i ] < left_[ i ] || x[ i ] > right_[ i ] )
 
  166      const DomainData & data ()
 const 
  172      friend std::ostream & operator<< ( std :: ostream &os, 
const Domain & domain )
 
  174        os << 
"domain: " << std::endl;
 
  176        for( 
int i = 0; i < domain.dimensionworld; ++i )
 
  177          os << domain.left_[ i ] << 
"  ";
 
  180        for( 
int i = 0; i < domain.dimensionworld; ++i )
 
  181          os << domain.right_[ i ] << 
"  ";
 
  188      std::vector< double > left_, right_;
 
  193    class BoundaryDomBlock
 
  205      DomainData * default_;
 
  209      std::vector< Domain > domains_;
 
  213      BoundaryDomBlock ( std::istream & in, 
int cdimworld );
 
  226        return ( counter_ < ndomains_ );
 
  230      const Domain & domain ()
 const 
  232        return domains_.at( counter_ );
 
  236      bool hasDefaultData ()
 const 
  238        return bool( default_ );
 
  242      const DomainData * defaultData ()
 const 
  249      bool hasParameter () 
const;
 
  260        return ( counter_ <= ndomains_ );
 
  265      template< 
class Vector >
 
  266      const DomainData * 
contains ( 
const std::vector< Vector > & v )
 const 
  268        std::vector< int > index( ndomains_ );
 
  269        for( 
int i = 0; i <  ndomains_; ++i)
 
  273        for( 
size_t i = 0; i <  N; ++i )
 
  278          const int n = index.size();
 
  280          for( 
int j = n-1; j >= 0; --j )
 
  282            bool inside = domains_[ index[ j ] ].contains( v[ i ] );
 
  284              index.erase( index.begin() + j );
 
  293        if( index.size() > 1 )
 
  294          dwarn << 
"WARNING: ambiguous boundary domain assignment, use first boundary domain in list" << std::endl;
 
  296        return &domains_[ index[ 0 ] ].data();
 
#define DUNE_THROW(E,...)
Definition: exceptions.hh:314
 
DWarnType dwarn(std::cerr)
Stream for warnings indicating problems.
Definition: stdstreams.hh:162
 
Dune namespace.
Definition: alignedallocator.hh:13
 
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
 
constexpr std::bool_constant<((II==value)||...)> contains(std::integer_sequence< T, II... >, std::integral_constant< T, value >)
Checks whether or not a given sequence contains a value.
Definition: integersequence.hh:137
 
std::string type
type of additional boundary parameters
Definition: parser.hh:25