3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
circumsphere.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*****************************************************************************
4 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
26#ifndef DUMUX_GEOMETRY_CIRCUMSPHERE_HH
27#define DUMUX_GEOMETRY_CIRCUMSPHERE_HH
28
29#include <type_traits>
30#include <dumux/common/math.hh>
32
33namespace Dumux {
34
40template<class Point>
41static inline Sphere<typename Point::value_type, Point::dimension>
42circumSphereOfTriangle(const Point& a, const Point& b, const Point& c)
43{
44 const auto ac = c - a;
45 const auto ab = b - a;
46 const auto n = crossProduct(ab, ac);
47 const auto distCenterToA = (crossProduct(n, ab)*ac.two_norm2() + crossProduct(ac, n)*ab.two_norm2()) / (2.0*n.two_norm2());
48
49 return { a + distCenterToA, distCenterToA.two_norm() };
50}
51
56template<class Geometry, typename std::enable_if_t<Geometry::mydimension == 2, int> = 0>
57static inline Sphere<typename Geometry::ctype, Geometry::coorddimension>
58circumSphereOfTriangle(const Geometry& triangle)
59{
60 assert(triangle.corners() == 3 && "Geometry is not a triangle.");
61 return circumSphereOfTriangle(triangle.corner(0), triangle.corner(1), triangle.corner(2));
62}
63
64} // end namespace Dumux
65
66#endif
Define some often used mathematical functions.
A function to compute bounding spheres of points clouds or convex polytopes.
static Sphere< typename Point::value_type, Point::dimension > circumSphereOfTriangle(const Point &a, const Point &b, const Point &c)
Computes the circumsphere of a triangle.
Definition: circumsphere.hh:42
Dune::FieldVector< Scalar, 3 > crossProduct(const Dune::FieldVector< Scalar, 3 > &vec1, const Dune::FieldVector< Scalar, 3 > &vec2)
Cross product of two vectors in three-dimensional Euclidean space.
Definition: math.hh:654
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29