00001 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 00002 // vi: set et ts=4 sw=4 sts=4: 00003 /* 00004 This file is part of the Open Porous Media project (OPM). 00005 00006 OPM is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation, either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 OPM is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with OPM. If not, see <http://www.gnu.org/licenses/>. 00018 00019 Consult the COPYING file in the top-level source directory of this 00020 module for the precise wording of the license and the list of 00021 copyright holders. 00022 */ 00030 #ifndef OPM_MEANS_HH 00031 #define OPM_MEANS_HH 00032 00033 #include <cmath> 00034 00035 namespace Opm { 00044 template <class Scalar> 00045 inline Scalar arithmeticMean(Scalar x, Scalar y) 00046 { return (x+y)/2; } 00047 00056 template <class Scalar> 00057 inline Scalar geometricMean(Scalar x, Scalar y) 00058 { 00059 if (x*y <= 0.0) 00060 return 0.0; 00061 00062 return std::sqrt(x*y); 00063 } 00064 00073 template <class Scalar> 00074 inline Scalar harmonicMean(Scalar x, Scalar y) 00075 { 00076 if (x*y <= 0) 00077 return 0.0; 00078 00079 return (2*x*y)/(y + x); 00080 } 00081 00082 } // namespace Ewoms 00083 00084 #endif // EWOMS_AVERAGE_HH