3.5-git
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 *****************************************************************************/
27#ifndef DUMUX_MULTIDOMAIN_NEWTON_CONVERGENCE_WRITER_HH
28#define DUMUX_MULTIDOMAIN_NEWTON_CONVERGENCE_WRITER_HH
29
30#include <string>
31#include <dune/common/hybridutilities.hh>
33
34namespace Dumux {
35
45template <class MDTraits>
46class MultiDomainNewtonConvergenceWriter : public ConvergenceWriterInterface<typename MDTraits::SolutionVector>
47{
48 template<std::size_t id>
49 using SubDomainGridGeometry = typename MDTraits::template SubDomain<id>::GridGeometry;
50
51 using GridGeometryTuple = typename MDTraits::template TupleOfSharedPtrConst<SubDomainGridGeometry>;
52
53 using SolutionVector = typename MDTraits::SolutionVector;
54
55 template<std::size_t id>
56 using SubDomainSolutionVector = typename MDTraits::template SubDomain<id>::SolutionVector;
57
58 template<std::size_t id>
60
61 using ConvergenceWriterPtrTuple = typename MDTraits::template TupleOfSharedPtr<SubDomainNewtonConvergenceWriter>;
62
63public:
69 MultiDomainNewtonConvergenceWriter(GridGeometryTuple gridGeometryTuple,
70 const std::string& name = "newton_convergence")
71 : gridGeometryTuple_(std::move(gridGeometryTuple))
72 {
73 using namespace Dune::Hybrid;
74 forEach(std::make_index_sequence<MDTraits::numSubDomains>{}, [&](auto&& id)
75 {
76 using ConvWriter = SubDomainNewtonConvergenceWriter<std::decay_t<decltype(id)>::value>;
77 elementAt(convergenceWriterPtrTuple_, id) = std::make_shared<ConvWriter>(*elementAt(gridGeometryTuple, id), name + "_domain_" + std::to_string(id));
78 });
79 }
80
82 void resize()
83 {
84 using namespace Dune::Hybrid;
85 forEach(std::make_index_sequence<MDTraits::numSubDomains>{}, [&](auto&& id)
86 {
87 elementAt(convergenceWriterPtrTuple_, id)->resize();
88 });
89 }
90
93 void reset(std::size_t newId = 0UL)
94 {
95 using namespace Dune::Hybrid;
96 forEach(std::make_index_sequence<MDTraits::numSubDomains>{}, [&](auto&& id)
97 {
98 elementAt(convergenceWriterPtrTuple_, id)->reset(newId);
99 });
100 }
101
102 void write(const SolutionVector& uLastIter,
103 const SolutionVector& deltaU,
104 const SolutionVector& residual) override
105 {
106 using namespace Dune::Hybrid;
107 forEach(std::make_index_sequence<MDTraits::numSubDomains>{}, [&](auto&& id)
108 {
109 constexpr auto i = std::decay_t<decltype(id)>{};
110 elementAt(convergenceWriterPtrTuple_, id)->write(uLastIter[i], deltaU[i], residual[i]);
111 });
112 }
113
114private:
115 GridGeometryTuple gridGeometryTuple_;
116 ConvergenceWriterPtrTuple convergenceWriterPtrTuple_;
117};
118
119} // end namespace Dumux
120
121#endif
Definition: adapt.hh:29
Writes the intermediate solutions for every Newton iteration.
Definition: multidomain/newtonconvergencewriter.hh:47
void reset(std::size_t newId=0UL)
Definition: multidomain/newtonconvergencewriter.hh:93
void resize()
Resizes the output fields. This has to be called whenever the grid changes.
Definition: multidomain/newtonconvergencewriter.hh:82
void write(const SolutionVector &uLastIter, const SolutionVector &deltaU, const SolutionVector &residual) override
Definition: multidomain/newtonconvergencewriter.hh:102
MultiDomainNewtonConvergenceWriter(GridGeometryTuple gridGeometryTuple, const std::string &name="newton_convergence")
Constructor.
Definition: multidomain/newtonconvergencewriter.hh:69
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...