effectivesolidheatcapacity.hh 3.58 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// -*- 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
 *
 * \brief Class for the evaluation of the porosity subject to precipitation.
 */
#ifndef DUMUX_EFFECTIVE_SOLID_HEATCAPACITY_HH
#define DUMUX_EFFECTIVE_SOLID_HEATCAPACITY_HH

#include <dumux/discretization/evalsolution.hh>

namespace Dumux
{

/*!
 * \ingroup Fluidmatrixinteractions
 */

/**
 * \brief Calculates the effective solid heat capacity
 */
template<class TypeTag>
class EffectiveSolidHeatCapacity
{
    using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
    using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
    using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
    using SpatialParams = typename GET_PROP_TYPE(TypeTag, SpatialParams);
    using ElementSolution = typename GET_PROP_TYPE(TypeTag, ElementSolutionVector);
    using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume);

    static const int dim = GridView::dimension;
    static const int dimWorld = GridView::dimensionworld;
    static const int numComponents = GET_PROP_VALUE(TypeTag, NumComponents);
    static const int numSolidPhases = GET_PROP_VALUE(TypeTag, NumSPhases);

    using Element = typename GridView::template Codim<0>:: Entity;

public:
    void init(const SpatialParams& spatialParams)
    {
        spatialParamsPtr_ = &spatialParams;
    }

    // calculates the effective solid heat capacity of multiple solid phases accordin to
    // their volume fractions
    Scalar effectiveSolidHeatCapacity(const Element& element,
                            const SubControlVolume& scv,
                            const ElementSolution& elemSol) const
    {
        auto priVars = evalSolution(element, element.geometry(), elemSol, scv.center());

        Scalar sumPrecipitates = 0.0;
        Scalar effCp = 0.0;
        for (unsigned int solidPhaseIdx = 0; solidPhaseIdx < numSolidPhases; ++solidPhaseIdx)
        {
            sumPrecipitates += priVars[numComponents + solidPhaseIdx];
            effCp += priVars[numComponents + solidPhaseIdx]*spatialParams_().solidPhaseHeatCapacity(element, scv, elemSol, solidPhaseIdx);
        }

        return effCp/sumPrecipitates;
    }

private:
    const SpatialParams& spatialParams_() const
    { return *spatialParamsPtr_; }

    const SpatialParams* spatialParamsPtr_;
};

} // namespace Dumux

#endif