5#ifndef DUNE_DGF_PROJECTIONBLOCK_HH
6#define DUNE_DGF_PROJECTIONBLOCK_HH
27 friend std::ostream &
operator<< ( std::ostream &,
const Token & );
32 defaultKeyword, functionKeyword, segmentKeyword,
33 sqrtKeyword, sinKeyword, cosKeyword, piKeyword,
36 openingParen, closingParen, openingBracket, closingBracket, normDelim,
37 additiveOperator, multiplicativeOperator, powerOperator,
46 void setSymbol (
const Type &t,
char c )
53 friend std::ostream &
operator<< ( std::ostream &,
const Token & );
62 template<
int dimworld >
63 class BoundaryProjection;
65 void registerProjectionFactory(
const int dimworld );
67 static const char* blockId() {
return "Projection"; }
71 template<
int dimworld >
87 const std::vector< unsigned int > &
boundaryFace (
const size_t i )
const
93 template<
int dimworld >
102 const FunctionMap::const_iterator it =
functions_.find( name );
103 return (it !=
functions_.end() ? it->second.first : 0);
114 std::stringstream str;
115 str << blockId() << std::endl;
116 str << funcexpr << std::endl;
117 str <<
"#" << std::endl;
125 void parseFunction (
const std::string& exprname );
130 ExpressionPointer parseMultiplicativeExpression (
const std::string &variableName );
132 void parseDefault ();
133 void parseSegment ();
135 void matchToken (
const Token::Type &type,
const std::string &message );
138 static char lowerCase (
char c )
140 return ((c >=
'A') && (c <=
'Z') ? c + (
'a' -
'A') : c);
156 std::ostream &
operator<< ( std::ostream &out,
const ProjectionBlock::Token &token );
170 template<
int dimworld >
171 class ProjectionBlock::BoundaryProjection
175 typedef BoundaryProjection < dimworld > This;
182 : expression_( exprpair.first ),
183 expressionName_( exprpair.second )
186 BoundaryProjection( ObjectStreamType& buffer )
189 buffer.read( (
char *) &size,
sizeof(
int) );
190 expressionName_.resize( size );
191 buffer.read( (
char *) expressionName_.c_str(), size );
195 virtual CoordinateType operator() (
const CoordinateType &global )
const override
197 std::vector< double > x( dimworld );
198 for(
int i = 0; i < dimworld; ++i )
199 x[ i ] = global[ i ];
200 std::vector< double > y;
201 expression_->evaluate( x, y );
202 CoordinateType result;
203 for(
int i = 0; i < dimworld; ++i )
204 result[ i ] = y[ i ];
209 virtual void backup( std::stringstream& buffer )
const override
211 buffer.write( (
const char *) &key(),
sizeof(
int ));
212 int size = expressionName_.size();
213 buffer.write( (
const char *) &size,
sizeof(
int) );
214 buffer.write( expressionName_.c_str(), size );
217 static void registerFactory()
221 key() = Base::template registerFactory< This >();
233 std::string expressionName_;
236 inline void ProjectionBlock::registerProjectionFactory(
const int dimworld )
238 if( dimworld == 3 ) {
239 BoundaryProjection< 3 > :: registerFactory();
241 else if ( dimworld == 2 ) {
242 BoundaryProjection< 2 > :: registerFactory();
244 else if ( dimworld == 1 ) {
245 BoundaryProjection< 1 > :: registerFactory();
248 DUNE_THROW(NotImplemented,
"ProjectionBlock::registerProjectionFactory not implemented for dimworld = " << dimworld);
Include standard header files.
Definition: agrid.hh:60
std::ostream & operator<<(std::ostream &out, const IntervalBlock::Interval &interval)
Definition: interval.hh:123
Interface class for vertex projection at the boundary.
Definition: boundaryprojection.hh:33
BaseType::ObjectStreamType ObjectStreamType
Definition: boundaryprojection.hh:36
FieldVector< double, dimworld > CoordinateType
type of coordinate vector
Definition: boundaryprojection.hh:42
std::stringstream line
Definition: basic.hh:47
Definition: io/file/dgfparser/blocks/projection.hh:24
static ProjectionBlock::ExpressionPair createExpression(const std::string &funcexpr, const int dimworld)
Definition: io/file/dgfparser/blocks/projection.hh:112
size_t numBoundaryProjections() const
Definition: io/file/dgfparser/blocks/projection.hh:82
const std::vector< unsigned int > & boundaryFace(const size_t i) const
Definition: io/file/dgfparser/blocks/projection.hh:87
std::shared_ptr< Expression > ExpressionPointer
Definition: io/file/dgfparser/blocks/projection.hh:58
ProjectionBlock(std::istream &in, int dimworld)
Definition: projection.cc:447
ExpressionPointer function(const std::string &name) const
Definition: io/file/dgfparser/blocks/projection.hh:100
FunctionMap functions_
Definition: io/file/dgfparser/blocks/projection.hh:150
friend std::ostream & operator<<(std::ostream &, const Token &)
Definition: projection.cc:838
ExpressionPair lastFunctionInserted() const
Definition: io/file/dgfparser/blocks/projection.hh:106
std::pair< ExpressionPointer, std::string > ExpressionPair
Definition: io/file/dgfparser/blocks/projection.hh:59
std::pair< std::vector< unsigned int >, ExpressionPair > BoundaryFunction
Definition: io/file/dgfparser/blocks/projection.hh:145
Token token
Definition: io/file/dgfparser/blocks/projection.hh:149
std::vector< BoundaryFunction > boundaryFunctions_
Definition: io/file/dgfparser/blocks/projection.hh:152
const DuneBoundaryProjection< dimworld > * defaultProjection() const
Definition: io/file/dgfparser/blocks/projection.hh:72
const DuneBoundaryProjection< dimworld > * boundaryProjection(const size_t i) const
Definition: io/file/dgfparser/blocks/projection.hh:94
std::map< std::string, ExpressionPair > FunctionMap
Definition: io/file/dgfparser/blocks/projection.hh:144
ExpressionPair defaultFunction_
Definition: io/file/dgfparser/blocks/projection.hh:151
Definition: io/file/dgfparser/blocks/projection.hh:160
virtual ~Expression()
Definition: io/file/dgfparser/blocks/projection.hh:163
virtual void evaluate(const Vector &argument, Vector &result) const =0
std::vector< double > Vector
Definition: io/file/dgfparser/blocks/projection.hh:161