3#ifndef DUNE_DGF_PROJECTIONBLOCK_HH
4#define DUNE_DGF_PROJECTIONBLOCK_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 & );
60 template<
int dimworld >
61 class BoundaryProjection;
63 void registerProjectionFactory(
const int dimworld );
65 static const char* blockId() {
return "Projection"; }
69 template<
int dimworld >
85 const std::vector< unsigned int > &
boundaryFace (
const size_t i )
const
91 template<
int dimworld >
100 const FunctionMap::const_iterator it =
functions_.find( name );
101 return (it !=
functions_.end() ? it->second.first : 0);
112 std::stringstream str;
113 str << blockId() << std::endl;
114 str << funcexpr << std::endl;
115 str <<
"#" << std::endl;
123 void parseFunction (
const std::string& exprname );
128 ExpressionPointer parseMultiplicativeExpression (
const std::string &variableName );
130 void parseDefault ();
131 void parseSegment ();
133 void matchToken (
const Token::Type &type,
const std::string &message );
136 static char lowerCase (
char c )
138 return ((c >=
'A') && (c <=
'Z') ? c + (
'a' -
'A') : c);
154 std::ostream &
operator<< ( std::ostream &out,
const ProjectionBlock::Token &token );
168 template<
int dimworld >
169 class ProjectionBlock::BoundaryProjection
173 typedef BoundaryProjection < dimworld > This;
174 typedef typename Base :: ObjectStreamType ObjectStreamType;
180 : expression_( exprpair.first ),
181 expressionName_( exprpair.second )
184 BoundaryProjection( ObjectStreamType& buffer )
187 buffer.read( (
char *) &size,
sizeof(
int) );
188 expressionName_.resize( size );
189 buffer.read( (
char *) expressionName_.c_str(), size );
193 virtual CoordinateType operator() (
const CoordinateType &global )
const override
195 std::vector< double > x( dimworld );
196 for(
int i = 0; i < dimworld; ++i )
197 x[ i ] = global[ i ];
198 std::vector< double > y;
199 expression_->evaluate( x, y );
200 CoordinateType result;
201 for(
int i = 0; i < dimworld; ++i )
202 result[ i ] = y[ i ];
207 virtual void backup( std::stringstream& buffer )
const override
209 buffer.write( (
const char *) &key(),
sizeof(
int ));
210 int size = expressionName_.size();
211 buffer.write( (
const char *) &size,
sizeof(
int) );
212 buffer.write( expressionName_.c_str(), size );
215 static void registerFactory()
219 key() = Base::template registerFactory< This >();
231 std::string expressionName_;
234 inline void ProjectionBlock::registerProjectionFactory(
const int dimworld )
236 if( dimworld == 3 ) {
237 BoundaryProjection< 3 > :: registerFactory();
239 else if ( dimworld == 2 ) {
240 BoundaryProjection< 2 > :: registerFactory();
242 else if ( dimworld == 1 ) {
243 BoundaryProjection< 1 > :: registerFactory();
246 DUNE_THROW(NotImplemented,
"ProjectionBlock::registerProjectionFactory not implemented for dimworld = " << dimworld);
Include standard header files.
Definition: agrid.hh:58
std::ostream & operator<<(std::ostream &out, const IntervalBlock::Interval &interval)
Definition: interval.hh:121
Interface class for vertex projection at the boundary.
Definition: boundaryprojection.hh:31
FieldVector< double, dimworld > CoordinateType
type of coordinate vector
Definition: boundaryprojection.hh:40
std::stringstream line
Definition: basic.hh:45
Definition: io/file/dgfparser/blocks/projection.hh:22
static ProjectionBlock::ExpressionPair createExpression(const std::string &funcexpr, const int dimworld)
Definition: io/file/dgfparser/blocks/projection.hh:110
size_t numBoundaryProjections() const
Definition: io/file/dgfparser/blocks/projection.hh:80
const std::vector< unsigned int > & boundaryFace(const size_t i) const
Definition: io/file/dgfparser/blocks/projection.hh:85
std::shared_ptr< Expression > ExpressionPointer
Definition: io/file/dgfparser/blocks/projection.hh:56
ExpressionPointer function(const std::string &name) const
Definition: io/file/dgfparser/blocks/projection.hh:98
FunctionMap functions_
Definition: io/file/dgfparser/blocks/projection.hh:148
friend std::ostream & operator<<(std::ostream &, const Token &)
Definition: projection.cc:836
ExpressionPair lastFunctionInserted() const
Definition: io/file/dgfparser/blocks/projection.hh:104
std::pair< ExpressionPointer, std::string > ExpressionPair
Definition: io/file/dgfparser/blocks/projection.hh:57
std::pair< std::vector< unsigned int >, ExpressionPair > BoundaryFunction
Definition: io/file/dgfparser/blocks/projection.hh:143
Token token
Definition: io/file/dgfparser/blocks/projection.hh:147
std::vector< BoundaryFunction > boundaryFunctions_
Definition: io/file/dgfparser/blocks/projection.hh:150
const DuneBoundaryProjection< dimworld > * defaultProjection() const
Definition: io/file/dgfparser/blocks/projection.hh:70
const DuneBoundaryProjection< dimworld > * boundaryProjection(const size_t i) const
Definition: io/file/dgfparser/blocks/projection.hh:92
std::map< std::string, ExpressionPair > FunctionMap
Definition: io/file/dgfparser/blocks/projection.hh:142
ExpressionPair defaultFunction_
Definition: io/file/dgfparser/blocks/projection.hh:149
Definition: io/file/dgfparser/blocks/projection.hh:158
virtual ~Expression()
Definition: io/file/dgfparser/blocks/projection.hh:161
virtual void evaluate(const Vector &argument, Vector &result) const =0
std::vector< double > Vector
Definition: io/file/dgfparser/blocks/projection.hh:159