Loading...
Searching...
No Matches
fvbaseboundarycontext.hh
Go to the documentation of this file.
// -*- 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.
*/
#ifndef EWOMS_FV_BASE_BOUNDARY_CONTEXT_HH
#define EWOMS_FV_BASE_BOUNDARY_CONTEXT_HH
#include <dune/common/fvector.hh>
#include <opm/models/discretization/common/fvbaseproperties.hh>
#include <cstddef>
namespace Opm {
template<class TypeTag>
class FvBaseBoundaryContext
{
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using Problem = GetPropType<TypeTag, Properties::Problem>;
using Model = GetPropType<TypeTag, Properties::Model>;
using Stencil = GetPropType<TypeTag, Properties::Stencil>;
using ElementContext = GetPropType<TypeTag, Properties::ElementContext>;
using IntensiveQuantities = GetPropType<TypeTag, Properties::IntensiveQuantities>;
using ExtensiveQuantities = GetPropType<TypeTag, Properties::ExtensiveQuantities>;
using GradientCalculator = GetPropType<TypeTag, Properties::GradientCalculator>;
using GridView = GetPropType<TypeTag, Properties::GridView>;
using Element = typename GridView::template Codim<0>::Entity;
using IntersectionIterator = typename GridView::IntersectionIterator;
using Intersection = typename GridView::Intersection;
enum { dim = GridView::dimension };
enum { dimWorld = GridView::dimensionworld };
using CoordScalar = typename GridView::ctype;
using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>;
using Vector = Dune::FieldVector<Scalar, dimWorld>;
public:
explicit FvBaseBoundaryContext(const ElementContext& elemCtx)
: elemCtx_(elemCtx)
, intersectionIt_(gridView().ibegin(element()))
{}
void increment()
{
const auto& iend = gridView().iend(element());
if (intersectionIt_ == iend) {
return;
}
++intersectionIt_;
// iterate to the next boundary intersection
while (intersectionIt_ != iend && intersectionIt_->neighbor()) {
++intersectionIt_;
}
}
const Problem& problem() const
{ return elemCtx_.problem(); }
const Model& model() const
{ return elemCtx_.model(); }
const GridView& gridView() const
{ return elemCtx_.gridView(); }
const Element& element() const
{ return elemCtx_.element(); }
const ElementContext& elementContext() const
{ return elemCtx_; }
const GradientCalculator& gradientCalculator() const
{ return elemCtx_.gradientCalculator(); }
std::size_t numDof(unsigned timeIdx) const
{ return elemCtx_.numDof(timeIdx); }
std::size_t numPrimaryDof(unsigned timeIdx) const
{ return elemCtx_.numPrimaryDof(timeIdx); }
std::size_t numInteriorFaces(unsigned timeIdx) const
{ return elemCtx_.numInteriorFaces(timeIdx); }
std::size_t numBoundaryFaces(unsigned timeIdx) const
{ return elemCtx_.stencil(timeIdx).numBoundaryFaces(); }
const Stencil& stencil(unsigned timeIdx) const
{ return elemCtx_.stencil(timeIdx); }
Vector normal(unsigned boundaryFaceIdx, unsigned timeIdx) const
{
auto tmp = stencil(timeIdx).boundaryFace[boundaryFaceIdx].normal;
tmp /= tmp.two_norm();
return tmp;
}
Scalar boundarySegmentArea(unsigned boundaryFaceIdx, unsigned timeIdx) const
{ return elemCtx_.stencil(timeIdx).boundaryFace(boundaryFaceIdx).area(); }
const GlobalPosition& pos(unsigned boundaryFaceIdx, unsigned timeIdx) const
{ return stencil(timeIdx).boundaryFace(boundaryFaceIdx).integrationPos(); }
const GlobalPosition& cvCenter(unsigned boundaryFaceIdx, unsigned timeIdx) const
{
const unsigned scvIdx = stencil(timeIdx).boundaryFace(boundaryFaceIdx).interiorIndex();
return stencil(timeIdx).subControlVolume(scvIdx).globalPos();
}
unsigned focusDofIndex() const
{ return elemCtx_.focusDofIndex(); }
unsigned interiorScvIndex(unsigned boundaryFaceIdx, unsigned timeIdx) const
{ return stencil(timeIdx).boundaryFace(boundaryFaceIdx).interiorIndex(); }
unsigned globalSpaceIndex(unsigned boundaryFaceIdx, unsigned timeIdx) const
{ return elemCtx_.globalSpaceIndex(interiorScvIndex(boundaryFaceIdx, timeIdx), timeIdx); }
const IntensiveQuantities& intensiveQuantities(unsigned boundaryFaceIdx, unsigned timeIdx) const
{
const unsigned interiorScvIdx = this->interiorScvIndex(boundaryFaceIdx, timeIdx);
return elemCtx_.intensiveQuantities(interiorScvIdx, timeIdx);
}
const ExtensiveQuantities& extensiveQuantities(unsigned boundaryFaceIdx, unsigned timeIdx) const
{ return elemCtx_.boundaryExtensiveQuantities(boundaryFaceIdx, timeIdx); }
const Intersection intersection(unsigned) const
{ return *intersectionIt_; }
IntersectionIterator& intersectionIt()
{ return intersectionIt_; }
protected:
const ElementContext& elemCtx_;
IntersectionIterator intersectionIt_;
};
} // namespace Opm
#endif
Opm::FvBaseBoundaryContext::pos
const GlobalPosition & pos(unsigned boundaryFaceIdx, unsigned timeIdx) const
Return the position of a local entity in global coordinates.
Definition fvbaseboundarycontext.hh:183
Opm::FvBaseBoundaryContext::cvCenter
const GlobalPosition & cvCenter(unsigned boundaryFaceIdx, unsigned timeIdx) const
Return the position of a control volume's center in global coordinates.
Definition fvbaseboundarycontext.hh:192
Opm::FvBaseBoundaryContext::normal
Vector normal(unsigned boundaryFaceIdx, unsigned timeIdx) const
Returns the outer unit normal of the boundary segment.
Definition fvbaseboundarycontext.hh:164
Opm::FvBaseBoundaryContext::globalSpaceIndex
unsigned globalSpaceIndex(unsigned boundaryFaceIdx, unsigned timeIdx) const
Return the global space index of the sub-control volume at the interior of a boundary segment.
Definition fvbaseboundarycontext.hh:222
Opm::FvBaseBoundaryContext::stencil
const Stencil & stencil(unsigned timeIdx) const
Definition fvbaseboundarycontext.hh:155
Opm::FvBaseBoundaryContext::FvBaseBoundaryContext
FvBaseBoundaryContext(const ElementContext &elemCtx)
The constructor.
Definition fvbaseboundarycontext.hh:72
Opm::FvBaseBoundaryContext::boundarySegmentArea
Scalar boundarySegmentArea(unsigned boundaryFaceIdx, unsigned timeIdx) const
Returns the area [m^2] of a given boudary segment.
Definition fvbaseboundarycontext.hh:174
Opm::FvBaseBoundaryContext::focusDofIndex
unsigned focusDofIndex() const
Return the local sub-control volume index upon which the linearization is currently focused.
Definition fvbaseboundarycontext.hh:202
Opm::FvBaseBoundaryContext::intersection
const Intersection intersection(unsigned) const
Return the intersection for the neumann segment.
Definition fvbaseboundarycontext.hh:256
Opm::FvBaseBoundaryContext::gridView
const GridView & gridView() const
Definition fvbaseboundarycontext.hh:107
Opm::FvBaseBoundaryContext::elementContext
const ElementContext & elementContext() const
Returns a reference to the element context object.
Definition fvbaseboundarycontext.hh:119
Opm::FvBaseBoundaryContext::intensiveQuantities
const IntensiveQuantities & intensiveQuantities(unsigned boundaryFaceIdx, unsigned timeIdx) const
Return the intensive quantities for the finite volume in the interiour of a boundary segment.
Definition fvbaseboundarycontext.hh:232
Opm::FvBaseBoundaryContext::problem
const Problem & problem() const
Definition fvbaseboundarycontext.hh:95
Opm::FvBaseBoundaryContext::numDof
std::size_t numDof(unsigned timeIdx) const
Definition fvbaseboundarycontext.hh:131
Opm::FvBaseBoundaryContext::element
const Element & element() const
Definition fvbaseboundarycontext.hh:113
Opm::FvBaseBoundaryContext::gradientCalculator
const GradientCalculator & gradientCalculator() const
Returns a reference to the current gradient calculator.
Definition fvbaseboundarycontext.hh:125
Opm::FvBaseBoundaryContext::numBoundaryFaces
std::size_t numBoundaryFaces(unsigned timeIdx) const
Return the number of boundary segments of the current element.
Definition fvbaseboundarycontext.hh:149
Opm::FvBaseBoundaryContext::numInteriorFaces
std::size_t numInteriorFaces(unsigned timeIdx) const
Definition fvbaseboundarycontext.hh:143
Opm::FvBaseBoundaryContext::interiorScvIndex
unsigned interiorScvIndex(unsigned boundaryFaceIdx, unsigned timeIdx) const
Return the local sub-control volume index of the interior of a boundary segment.
Definition fvbaseboundarycontext.hh:212
Opm::FvBaseBoundaryContext::numPrimaryDof
std::size_t numPrimaryDof(unsigned timeIdx) const
Definition fvbaseboundarycontext.hh:137
Opm::FvBaseBoundaryContext::model
const Model & model() const
Definition fvbaseboundarycontext.hh:101
Opm::FvBaseBoundaryContext::extensiveQuantities
const ExtensiveQuantities & extensiveQuantities(unsigned boundaryFaceIdx, unsigned timeIdx) const
Return the extensive quantities for a given boundary face.
Definition fvbaseboundarycontext.hh:244
Opm::FvBaseBoundaryContext::intersectionIt
IntersectionIterator & intersectionIt()
Return the intersection for the neumann segment.
Definition fvbaseboundarycontext.hh:267
fvbaseproperties.hh
Declare the properties used by the infrastructure code of the finite volume discretizations.
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43
Opm::GetPropType
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition propertysystem.hh:233