/usr/include/dune/grid/common/boundaryprojection.hh is in libdune-grid-dev 2.3.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_BOUNDARYPROJECTION_HH
#define DUNE_BOUNDARYPROJECTION_HH
//- system includes
#include <cmath>
//- Dune includes
#include <dune/common/fvector.hh>
#include <dune/common/shared_ptr.hh>
#include <dune/geometry/multilineargeometry.hh>
#include <dune/grid/common/boundarysegment.hh>
namespace Dune
{
/** \brief Interface class for vertex projection at the boundary.
*/
template <int dimworld>
struct DuneBoundaryProjection
{
//! \brief type of coordinate vector
typedef FieldVector< double, dimworld> CoordinateType;
//! \brief destructor
virtual ~DuneBoundaryProjection() {}
//! \brief projection operator projection a global coordinate
virtual CoordinateType operator() (const CoordinateType& global) const = 0;
};
template < int dimworld >
class BoundaryProjectionWrapper
: public DuneBoundaryProjection< dimworld >
{
protected:
typedef DuneBoundaryProjection< dimworld > BaseType;
const BaseType& proj_;
public:
//! \brief type of coordinate vector
typedef typename BaseType :: CoordinateType CoordinateType;
// constructor taking other projection
BoundaryProjectionWrapper( const BaseType& proje )
: proj_( proje )
{}
//! destructor
~BoundaryProjectionWrapper () {}
//! \brief projection operator projection a global coordinate
CoordinateType operator() (const CoordinateType& global) const
{
return proj_( global );
}
};
// BoundarySegmentWrapper
// ----------------------
/** \tparam dim Dimension of the grid */
template< int dim, int dimworld >
class BoundarySegmentWrapper
: public DuneBoundaryProjection< dimworld >
{
typedef DuneBoundaryProjection< dimworld > Base;
typedef MultiLinearGeometry<typename Base::CoordinateType::value_type,dim-1,dimworld> FaceMapping;
public:
typedef typename Base::CoordinateType CoordinateType;
typedef Dune::BoundarySegment< dim, dimworld > BoundarySegment;
/** constructor
*
* \param[in] type geometry type of the boundary face
* \param[in] vertices vertices of the boundary face
* \param[in] boundarySegment geometric realization of the shaped boundary
*
* \note The BoundarySegmentWrapper takes control of the boundary segment.
*/
BoundarySegmentWrapper ( const GeometryType &type,
const std::vector< CoordinateType > &vertices,
const shared_ptr< BoundarySegment > &boundarySegment )
: faceMapping_( FaceMapping( type, vertices ) ),
boundarySegment_( boundarySegment )
{}
CoordinateType operator() ( const CoordinateType &global ) const
{
return boundarySegment() ( faceMapping_.local( global ) );
}
const BoundarySegment &boundarySegment () const
{
return *boundarySegment_;
}
private:
FaceMapping faceMapping_;
const shared_ptr< BoundarySegment > boundarySegment_;
};
//////////////////////////////////////////////////////////////////////
//
// Example of boundary projection projection to a circle
//
//////////////////////////////////////////////////////////////////////
template <int dimworld>
struct CircleBoundaryProjection : public DuneBoundaryProjection< dimworld >
{
//! \brief type of coordinate vector
typedef FieldVector< double, dimworld> CoordinateType;
//! constructor taking radius of circle (default = sqrt( dimworld ) )
CircleBoundaryProjection(const double radius = std::sqrt( (double)dimworld ))
: radius_( radius ) {}
//! \brief destructor
virtual ~CircleBoundaryProjection() {}
//! \brief projection operator projection a global coordinate
virtual CoordinateType operator() (const CoordinateType& global) const
{
CoordinateType prj( global );
// get adjustment factor
const double factor = radius_ / global.two_norm();
// adjust
prj *= factor;
return prj;
}
protected:
//! radius of circ
const double radius_;
};
} // end namespace
#endif // #ifndef DUNE_BOUNDARYPROJECTION_HH
|