3#ifndef DUNE_DGF_PROJECTIONBLOCK_HH
4#define DUNE_DGF_PROJECTIONBLOCK_HH
8#include <dune/grid/common/boundaryprojection.hh>
9#include <dune/grid/io/file/dgfparser/blocks/basic.hh>
25 friend std::ostream &operator<< ( std::ostream &,
const Token & );
30 defaultKeyword, functionKeyword, segmentKeyword,
31 sqrtKeyword, sinKeyword, cosKeyword, piKeyword,
34 openingParen, closingParen, openingBracket, closingBracket, normDelim,
35 additiveOperator, multiplicativeOperator, powerOperator,
44 void setSymbol (
const Type &t,
char c )
51 friend std::ostream &operator<< ( std::ostream &,
const Token & );
57 template<
int dimworld >
58 class BoundaryProjection;
61 ProjectionBlock ( std::istream &in,
int dimworld );
63 template<
int dimworld >
64 const DuneBoundaryProjection< dimworld > *defaultProjection ()
const
66 if( defaultFunction_ != 0 )
67 return new BoundaryProjection< dimworld >( defaultFunction_ );
72 size_t numBoundaryProjections ()
const
74 return boundaryFunctions_.size();
77 const std::vector< unsigned int > &boundaryFace (
const size_t i )
const
79 assert( i < numBoundaryProjections() );
80 return boundaryFunctions_[ i ].first;
83 template<
int dimworld >
84 const DuneBoundaryProjection< dimworld > *boundaryProjection (
const size_t i )
const
86 assert( i < numBoundaryProjections() );
87 return new BoundaryProjection< dimworld >( boundaryFunctions_[ i ].second );
90 const Expression *function (
const std::string &name )
const
92 const FunctionMap::const_iterator it = functions_.find( name );
93 return (it != functions_.end() ? it->second : 0);
97 void parseFunction ();
98 const Expression *parseBasicExpression (
const std::string &variableName );
99 const Expression *parsePostfixExpression (
const std::string &variableName );
100 const Expression *parseUnaryExpression (
const std::string &variableName );
101 const Expression *parsePowerExpression (
const std::string &variableName );
102 const Expression *parseMultiplicativeExpression (
const std::string &variableName );
103 const Expression *parseExpression (
const std::string &variableName );
104 void parseDefault ();
105 void parseSegment ();
107 void matchToken (
const Token::Type &type,
const std::string &message );
110 static char lowerCase (
char c )
112 return ((c >=
'A') && (c <=
'Z') ? c + (
'a' -
'A') : c);
116 typedef std::map< std::string, const Expression * > FunctionMap;
117 typedef std::pair< std::vector< unsigned int >,
const Expression * > BoundaryFunction;
119 using BasicBlock::line;
122 FunctionMap functions_;
123 const Expression *defaultFunction_;
124 std::vector< BoundaryFunction > boundaryFunctions_;
128 std::ostream &operator<< ( std::ostream &out,
const ProjectionBlock::Token &token );
131 struct ProjectionBlock::Expression
133 typedef std::vector< double > Vector;
135 virtual ~Expression ()
138 virtual void evaluate (
const Vector &argument, Vector &result )
const = 0;
142 template<
int dimworld >
143 class ProjectionBlock::BoundaryProjection
144 :
public DuneBoundaryProjection< dimworld >
146 typedef DuneBoundaryProjection< dimworld > Base;
151 BoundaryProjection (
const Expression *expression )
152 : expression_( expression )
155 virtual CoordinateType operator() (
const CoordinateType &global )
const
157 std::vector< double > x( dimworld );
158 for(
int i = 0; i < dimworld; ++i )
159 x[ i ] = global[ i ];
160 std::vector< double > y;
161 expression_->evaluate( x, y );
162 CoordinateType result;
163 for(
int i = 0; i < dimworld; ++i )
164 result[ i ] = y[ i ];
169 const Expression *expression_;
constexpr auto equals(T1 &&t1, T2 &&t2)
Equality comparison.
Definition: hybridutilities.hh:441
Dune namespace.
Definition: alignment.hh:11
FieldVector< double, dimworld > CoordinateType
type of coordinate vector
Definition: boundaryprojection.hh:26