Skip to content
Snippets Groups Projects
Commit ad761a28 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

introduce evalSolution function

parent 4e2fcb9f
No related branches found
No related tags found
1 merge request!617[WIP] Next
...@@ -37,17 +37,16 @@ template<class TypeTag> ...@@ -37,17 +37,16 @@ template<class TypeTag>
class BoxElementSolution class BoxElementSolution
{ {
using GridView = typename GET_PROP_TYPE(TypeTag, GridView); using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables);
using Element = typename GridView::template Codim<0>::Entity; using Element = typename GridView::template Codim<0>::Entity;
using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector);
using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry);
using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry); using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
public: public:
using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables);
//! Default constructors //! Default constructors
BoxElementSolution() = default; BoxElementSolution() = default;
BoxElementSolution(BoxElementSolution&& other) = default;
BoxElementSolution(const BoxElementSolution& other) = default;
//! Constructor with element and solution and gridgeometry //! Constructor with element and solution and gridgeometry
BoxElementSolution(const Element& element, const SolutionVector& sol, BoxElementSolution(const Element& element, const SolutionVector& sol,
......
...@@ -37,16 +37,15 @@ template<class TypeTag> ...@@ -37,16 +37,15 @@ template<class TypeTag>
class CCElementSolution class CCElementSolution
{ {
using GridView = typename GET_PROP_TYPE(TypeTag, GridView); using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables);
using Element = typename GridView::template Codim<0>::Entity; using Element = typename GridView::template Codim<0>::Entity;
using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector);
using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry);
public: public:
using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables);
//! Default constructors //! Default constructors
CCElementSolution() = default; CCElementSolution() = default;
CCElementSolution(CCElementSolution&& other) = default;
CCElementSolution(const CCElementSolution& other) = default;
//! Constructor with element and solution //! Constructor with element and solution
CCElementSolution(const Element& element, const SolutionVector& sol, CCElementSolution(const Element& element, const SolutionVector& sol,
......
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program 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. *
* *
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
*
* \ingroup Discretization
* \brief free functions for the evaluation of primary variables and gradients inside elements.
*/
#ifndef DUMUX_DISCRETIZATION_EVAL_SOLUTION_HH
#define DUMUX_DISCRETIZATION_EVAL_SOLUTION_HH
#include <dune/localfunctions/lagrange/pqkfactory.hh>
#include <dumux/discretization/box/elementsolution.hh>
#include <dumux/discretization/cellcentered/elementsolution.hh>
namespace Dumux
{
/*!
* \brief Interpolates a given box element solution to a given global position.
*
* \return the interpolated Primary Variables
* \param element The element
* \param fvGridGeometry The finite volume grid geometry
* \param elemSol The primary variables at the dofs of the element
* \param globalPos The global position
*/
template< class Element, class FVGridGeometry, class TypeTag >
typename BoxElementSolution<TypeTag>::PrimaryVariables
evalSolution(const Element& element,
const typename Element::Geometry& geometry,
const FVGridGeometry& fvGridGeometry,
const BoxElementSolution<TypeTag>& elemSol,
const typename Element::Geometry::GlobalCoordinate& globalPos)
{
using PrimaryVariables = typename BoxElementSolution<TypeTag>::PrimaryVariables;
using Scalar = typename PrimaryVariables::value_type;
// interpolate the solution
const auto& localBasis = fvGridGeometry.feCache().get(geometry.type()).localBasis();
// evaluate the shape functions at the scv center
const auto localPos = geometry.local(globalPos);
std::vector< Dune::FieldVector<Scalar, 1> > shapeValues;
localBasis.evaluateFunction(localPos, shapeValues);
PrimaryVariables result(0.0);
for (int i = 0; i < geometry.corners(); ++i)
{
auto value = elemSol[i];
value *= shapeValues[i][0];
result += value;
}
return result;
}
/*!
* \brief Interpolates a given CCElementSolution to a given global position.
*
* \return the (constant over the element) Primary Variables
* \param element The element
* \param fvGridGeometry The finite volume grid geometry
* \param elemSol The primary variables at the dofs of the element
* \param globalPos The global position
*/
template< class Element, class FVGridGeometry, class TypeTag >
typename CCElementSolution<TypeTag>::PrimaryVariables
evalSolution(const Element& element,
const typename Element::Geometry& geometry,
const FVGridGeometry& fvGridGeometry,
const CCElementSolution<TypeTag>& elemSol,
const typename Element::Geometry::GlobalCoordinate& globalPos)
{
return elemSol[0];
}
} // namespace Dumux
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment