Files
opm-simulators/ebos/femcpgridcompat.hh

107 lines
3.1 KiB
C++
Raw Normal View History

// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
/*!
* \file
*
* \brief This file ensures that ebos can be compiled in the presence of dune-fem
*
* It implements a few work-arounds for some incompatibilities with the Dune grid
* interface of CpGrid. A better way would be to make CpGrid conforming.
*/
#ifndef EWOMS_FEM_CPGRID_COMPAT_HH
#define EWOMS_FEM_CPGRID_COMPAT_HH
#if HAVE_DUNE_FEM
#include <dune/common/version.hh>
#include <dune/fem/gridpart/common/gridpart.hh>
#include <dune/fem/misc/compatibility.hh>
#include <dune/fem/io/streams/streams.hh>
namespace Dune
{
namespace cpgrid
{
template <int codim>
class Entity;
template <int codim>
class EntityPointer;
}
#if DUNE_VERSION_NEWER( DUNE_FEM, 2, 6 )
template <int dim, int cdim>
auto referenceElement(const Dune::cpgrid::Geometry<dim, cdim>& geo)
-> decltype(referenceElement<double, dim>(geo.type()))
{
return referenceElement<double, dim>(geo.type());
}
#endif
// specialization of dune-fem compatiblity functions for CpGrid, since CpGrid does not use the interface classes.
namespace Fem
{
////////////////////////////////////////////////////////////
//
// make_entity for CpGrid entities
//
////////////////////////////////////////////////////////////
template <int codim>
inline Dune::cpgrid::Entity< codim > make_entity ( const Dune::cpgrid::EntityPointer< codim >& entityPointer )
{
return *entityPointer;
}
template <int codim>
inline Dune::cpgrid::Entity<codim> make_entity ( Dune::cpgrid::Entity<codim> entity )
{
return std::move( entity );
}
////////////////////////////////////////////////////////////
//
// GridEntityAccess for CpGrid entities
//
////////////////////////////////////////////////////////////
template< int codim >
struct GridEntityAccess< Dune::cpgrid::Entity< codim > >
{
typedef Dune::cpgrid::Entity< codim > EntityType;
typedef EntityType GridEntityType;
fix most pedantic compiler warnings in the basic infrastructure i.e., using clang 3.8 to compile the test suite with the following flags: ``` -Weverything -Wno-documentation -Wno-documentation-unknown-command -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-undef -Wno-padded -Wno-global-constructors -Wno-exit-time-destructors -Wno-weak-vtables -Wno-float-equal ``` should not produce any warnings anymore. In my opinion the only flag which would produce beneficial warnings is -Wdocumentation. This has not been fixed in this patch because writing documentation is left for another day (or, more likely, year). note that this patch consists of a heavy dose of the OPM_UNUSED macro and plenty of static_casts (to fix signedness issues). Fixing the singedness issues were quite a nightmare and the fact that the Dune API is quite inconsistent in that regard was not exactly helpful. :/ Finally this patch includes quite a few formatting changes (e.g., all occurences of 'T &t' should be changed to `T& t`) and some fixes for minor issues which I've found during the excercise. I've made sure that all unit tests the test suite still pass successfully and I've made sure that flow_ebos still works for Norne and that it did not regress w.r.t. performance. (Note that this patch does not fix compiler warnings triggered `ebos` and `flow_ebos` but only those caused by the basic infrastructure or the unit tests.) v2: fix the warnings that occur if the dune-localfunctions module is not available. thanks to [at]atgeirr for testing. v3: fix dune 2.3 build issue
2016-11-07 15:14:07 +01:00
static const GridEntityType& gridEntity ( const EntityType& entity )
{
return entity;
}
};
} // namespace Fem
} // end namespace Dune
#endif // #if HAVE_DUNE_FEM
#endif // EWOMS_FEM_CPGRID_COMPAT_HH