diff --git a/dune/fufem/arcofcircle.hh b/dune/fufem/arcofcircle.hh index 035bd29a18704698aa531f2e99a9f31500a25f86..c1766392624b10a6ae7a719323ae6a5c495a023f 100644 --- a/dune/fufem/arcofcircle.hh +++ b/dune/fufem/arcofcircle.hh @@ -33,5 +33,126 @@ class ArcOfCircle : public Dune::BoundarySegment<2> double toAngle_; }; +/** \brief Boundary segments for a 3D-tube/tube-segment prism grid that is aligned with the x-axis. + * + * \param center - The center of the circle that the characterizes the position of tube. + * \param radius - The radius of the circle. + * \param length - Length of the boundary segment in x-direction. + * \param fromAngle - Segment fromAngle. (0 <= fromAngle <= toAngle <= 2*PI) + * \param toAngle - Segment toAngle. (0 <= fromAngle <= toAngle <= 2*PI) + * + */ +template<class ctype> +class TubeLowerSegment : public Dune::BoundarySegment<3> +{ + public: + + TubeLowerSegment(const Dune::FieldVector<ctype,3>& center, ctype radius, ctype length, + ctype fromAngle, ctype toAngle) + : center_(center), radius_(radius), length_(length), fromAngle_(fromAngle), toAngle_(toAngle) + {} + + Dune::FieldVector<ctype,3> operator()(const Dune::FieldVector<ctype,2>& local) const { + + ctype angle = fromAngle_ + (local[0] + local[1])*(toAngle_ - fromAngle_); + + Dune::FieldVector<ctype,3> result = center_; + + result[0] += local[1]*length_; + result[1] += radius_ * std::cos(angle); + result[2] += radius_ * std::sin(angle); + + return result; + } + + Dune::FieldVector<ctype,3> center_; + + ctype radius_; + ctype length_; + + ctype fromAngle_; + ctype toAngle_; +}; + +/** \brief Boundary segments for a 3D-tube/tube-segment prism grid that is aligned with the x-axis. + * + * \param center - The center of the circle that the characterizes the position of tube. + * \param radius - The radius of the circle. + * \param length - Length of the boundary segment in x-direction. + * \param fromAngle - Segment fromAngle. (0 <= fromAngle <= toAngle <= 2*PI) + * \param toAngle - Segment toAngle. (0 <= fromAngle <= toAngle <= 2*PI) + * + */ +template<class ctype> +class TubeUpperSegment : public Dune::BoundarySegment<3> +{ + public: + + TubeUpperSegment(const Dune::FieldVector<ctype,3>& center, ctype radius, ctype length, + ctype fromAngle, ctype toAngle) + : center_(center), radius_(radius), length_(length), fromAngle_(fromAngle), toAngle_(toAngle) + {} + + Dune::FieldVector<ctype,3> operator()(const Dune::FieldVector<ctype,2>& local) const { + + ctype angle = fromAngle_ + local[0]*(toAngle_ - fromAngle_); + + Dune::FieldVector<ctype,3> result = center_; + + result[0] += local[1]*length_; + result[1] += radius_ * std::cos(angle); + result[2] += radius_ * std::sin(angle); + + return result; + } + + Dune::FieldVector<ctype,3> center_; + + ctype radius_; + ctype length_; + + ctype fromAngle_; + ctype toAngle_; +}; + +/** \brief Lateral boundary segments for a 3D-tube/tube-segment prism grid that is aligned with the x-axis. + * + * \param center - The center of the circle that the characterizes the position of tube. + * \param radius - The radius of the circle. + * \param length - Thickness of the tube(-segment). + * \param fromAngle - Segment fromAngle. (0 <= fromAngle <= toAngle <= 2*PI) + * \param toAngle - Segment toAngle. (0 <= fromAngle <= toAngle <= 2*PI) + * + */ +template<class ctype> +class TubeLateralSegment : public Dune::BoundarySegment<3> +{ + public: + + TubeLateralSegment(const Dune::FieldVector<ctype,3>& center, ctype radius, ctype thickness, + ctype fromAngle, ctype toAngle) + : center_(center), radius_(radius), thickness_(thickness), fromAngle_(fromAngle), toAngle_(toAngle) + {} + + Dune::FieldVector<ctype,3> operator()(const Dune::FieldVector<ctype,2>& local) const { + + ctype angle = fromAngle_ + local[0]*(toAngle_ - fromAngle_); + + Dune::FieldVector<ctype,3> result = center_; + + result[1] += (radius_ +local[1]*thickness_)* std::cos(angle); + result[2] += (radius_ +local[1]*thickness_)* std::sin(angle); + + return result; + } + + Dune::FieldVector<ctype,3> center_; + + ctype radius_; + ctype thickness_; + + ctype fromAngle_; + ctype toAngle_; +}; #endif