BlackoilLegacyDetails.hpp
1 /*
2  Copyright 2013, 2015 SINTEF ICT, Applied Mathematics.
3  Copyright 2014, 2015 Dr. Blatt - HPC-Simulation-Software & Services
4  Copyright 2014, 2015 Statoil ASA.
5  Copyright 2015 NTNU
6  Copyright 2015 IRIS AS
7 
8  This file is part of the Open Porous Media project (OPM).
9 
10  OPM is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  OPM is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with OPM. If not, see <http://www.gnu.org/licenses/>.
22 */
23 
24 #ifndef OPM_BLACKOILLEGACYDETAILS_HEADER_INCLUDED
25 #define OPM_BLACKOILLEGACYDETAILS_HEADER_INCLUDED
26 
27 #include <opm/core/linalg/ParallelIstlInformation.hpp>
28 
29 namespace Opm {
30 namespace detail {
36  template <class ADB>
37  inline
38  double infinityNorm( const ADB& a, const boost::any& pinfo = boost::any() )
39  {
40  static_cast<void>(pinfo); // Suppress warning in non-MPI case.
41 #if HAVE_MPI
42  if ( pinfo.type() == typeid(ParallelISTLInformation) )
43  {
44  const ParallelISTLInformation& real_info =
45  boost::any_cast<const ParallelISTLInformation&>(pinfo);
46  double result=0;
47  real_info.computeReduction(a.value(), Reduction::makeLInfinityNormFunctor<double>(), result);
48  return result;
49  }
50  else
51 #endif
52  {
53  if( a.value().size() > 0 ) {
54  return a.value().matrix().template lpNorm<Eigen::Infinity> ();
55  }
56  else { // this situation can occur when no wells are present
57  return 0.0;
58  }
59  }
60  }
61 
65  template <class ADB>
66  inline
67  double infinityNormWell( const ADB& a, const boost::any& pinfo )
68  {
69  static_cast<void>(pinfo); // Suppress warning in non-MPI case.
70  double result=0;
71  if( a.value().size() > 0 ) {
72  result = a.value().matrix().template lpNorm<Eigen::Infinity> ();
73  }
74 #if HAVE_MPI
75  if ( pinfo.type() == typeid(ParallelISTLInformation) )
76  {
77  const ParallelISTLInformation& real_info =
78  boost::any_cast<const ParallelISTLInformation&>(pinfo);
79  result = real_info.communicator().max(result);
80  }
81 #endif
82  return result;
83  }
84  } // namespace detail
85 } // namespace Opm
86 
87 #endif // OPM_BLACKOILDETAILS_HEADER_INCLUDED
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: AdditionalObjectDeleter.hpp:22