3.4
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
multidomain/newtonconvergencewriter.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*****************************************************************************
4 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
26#ifndef DUMUX_MULTIDOMAIN_NEWTON_CONVERGENCE_WRITER_HH
27#define DUMUX_MULTIDOMAIN_NEWTON_CONVERGENCE_WRITER_HH
28
29#include <string>
30#include <dune/common/hybridutilities.hh>
32
33namespace Dumux {
34
43template <class MDTraits>
44class MultiDomainNewtonConvergenceWriter : public ConvergenceWriterInterface<typename MDTraits::SolutionVector>
45{
46 template<std::size_t id>
47 using SubDomainGridGeometry = typename MDTraits::template SubDomain<id>::GridGeometry;
48
49 using GridGeometryTuple = typename MDTraits::template TupleOfSharedPtrConst<SubDomainGridGeometry>;
50
51 using SolutionVector = typename MDTraits::SolutionVector;
52
53 template<std::size_t id>
54 using SubDomainSolutionVector = typename MDTraits::template SubDomain<id>::SolutionVector;
55
56 template<std::size_t id>
58
59 using ConvergenceWriterPtrTuple = typename MDTraits::template TupleOfSharedPtr<SubDomainNewtonConvergenceWriter>;
60
61public:
67 MultiDomainNewtonConvergenceWriter(GridGeometryTuple&& gridGeometryTuple,
68 const std::string& name = "newton_convergence")
69 : gridGeometryTuple_(gridGeometryTuple)
70 {
71 using namespace Dune::Hybrid;
72 forEach(std::make_index_sequence<MDTraits::numSubDomains>{}, [&](auto&& id)
73 {
74 using ConvWriter = SubDomainNewtonConvergenceWriter<std::decay_t<decltype(id)>::value>;
75 elementAt(convergenceWriterPtrTuple_, id) = std::make_shared<ConvWriter>(*elementAt(gridGeometryTuple, id), name + "_domain_" + std::to_string(id));
76 });
77 }
78
80 void resize()
81 {
82 using namespace Dune::Hybrid;
83 forEach(std::make_index_sequence<MDTraits::numSubDomains>{}, [&](auto&& id)
84 {
85 elementAt(convergenceWriterPtrTuple_, id)->resize();
86 });
87 }
88
91 void reset(std::size_t newId = 0UL)
92 {
93 using namespace Dune::Hybrid;
94 forEach(std::make_index_sequence<MDTraits::numSubDomains>{}, [&](auto&& id)
95 {
96 elementAt(convergenceWriterPtrTuple_, id)->reset(newId);
97 });
98 }
99
100 void write(const SolutionVector& uLastIter,
101 const SolutionVector& deltaU,
102 const SolutionVector& residual) override
103 {
104 using namespace Dune::Hybrid;
105 forEach(std::make_index_sequence<MDTraits::numSubDomains>{}, [&](auto&& id)
106 {
107 constexpr auto i = std::decay_t<decltype(id)>{};
108 elementAt(convergenceWriterPtrTuple_, id)->write(uLastIter[i], deltaU[i], residual[i]);
109 });
110 }
111
112private:
113 GridGeometryTuple gridGeometryTuple_;
114 ConvergenceWriterPtrTuple convergenceWriterPtrTuple_;
115};
116
117} // end namespace Dumux
118
119#endif
Definition: adapt.hh:29
Writes the intermediate solutions for every Newton iteration.
Definition: multidomain/newtonconvergencewriter.hh:45
void reset(std::size_t newId=0UL)
Definition: multidomain/newtonconvergencewriter.hh:91
MultiDomainNewtonConvergenceWriter(GridGeometryTuple &&gridGeometryTuple, const std::string &name="newton_convergence")
Constructor.
Definition: multidomain/newtonconvergencewriter.hh:67
void resize()
Resizes the output fields. This has to be called whenever the grid changes.
Definition: multidomain/newtonconvergencewriter.hh:80
void write(const SolutionVector &uLastIter, const SolutionVector &deltaU, const SolutionVector &residual) override
Definition: multidomain/newtonconvergencewriter.hh:100
Definition: nonlinear/newtonconvergencewriter.hh:39
Writes the intermediate solutions for every Newton iteration.
Definition: nonlinear/newtonconvergencewriter.hh:55
This class provides the infrastructure to write the convergence behaviour of the newton method into a...