fvbasenewtonconvergencewriter.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 This file is part of the Open Porous Media project (OPM).
5
6 OPM 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 2 of the License, or
9 (at your option) any later version.
10
11 OPM 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 OPM. If not, see <http://www.gnu.org/licenses/>.
18
19 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
28#ifndef EWOMS_FV_BASE_NEWTON_CONVERGENCE_WRITER_HH
29#define EWOMS_FV_BASE_NEWTON_CONVERGENCE_WRITER_HH
30
33
34#include <iostream>
35
37namespace Opm::Properties {
38
39// forward declaration of the required property tags
40template<class TypeTag, class MyTypeTag>
41struct SolutionVector;
42template<class TypeTag, class MyTypeTag>
43struct GlobalEqVector;
44template<class TypeTag, class MyTypeTag>
45struct NewtonMethod;
46template<class TypeTag, class MyTypeTag>
47struct VtkOutputFormat;
48
49} // namespace Opm::Properties
51
52namespace Opm {
59template <class TypeTag>
61{
63
67
68 static const int vtkFormat = getPropValue<TypeTag, Properties::VtkOutputFormat>();
70
71public:
73 : newtonMethod_(nm)
74 {
75 timeStepIdx_ = 0;
76 iteration_ = 0;
77 vtkMultiWriter_ = 0;
78 }
79
81 { delete vtkMultiWriter_; }
82
88 {
89 ++timeStepIdx_;
90 iteration_ = 0;
91 }
92
98 {
99 ++ iteration_;
100 if (!vtkMultiWriter_)
101 vtkMultiWriter_ =
102 new VtkMultiWriter(/*async=*/false,
103 newtonMethod_.problem().gridView(),
104 newtonMethod_.problem().outputDir(),
105 "convergence");
106 vtkMultiWriter_->beginWrite(timeStepIdx_ + iteration_ / 100.0);
107 }
108
118 void writeFields(const SolutionVector& uLastIter,
119 const GlobalEqVector& deltaU)
120 {
121 try {
122 newtonMethod_.problem().model().addConvergenceVtkFields(*vtkMultiWriter_,
123 uLastIter,
124 deltaU);
125 }
126 catch (...) {
127 std::cout << "Oops: exception thrown on rank "
128 << newtonMethod_.problem().gridView().comm().rank()
129 << " while writing the convergence\n" << std::flush;
130 }
131 }
132
138 { vtkMultiWriter_->endWrite(); }
139
148 { iteration_ = 0; }
149
150private:
151 int timeStepIdx_;
152 int iteration_;
153 VtkMultiWriter *vtkMultiWriter_;
154 NewtonMethod& newtonMethod_;
155};
156
157} // namespace Opm
158
159#endif
Writes the intermediate solutions during the Newton scheme for models using a finite volume discretiz...
Definition: fvbasenewtonconvergencewriter.hh:61
void writeFields(const SolutionVector &uLastIter, const GlobalEqVector &deltaU)
Write the Newton update to disk.
Definition: fvbasenewtonconvergencewriter.hh:118
void beginTimeStep()
Called by the Newton method before the actual algorithm is started for any given timestep.
Definition: fvbasenewtonconvergencewriter.hh:87
void endTimeStep()
Called by the Newton method after Newton algorithm has been completed for any given timestep.
Definition: fvbasenewtonconvergencewriter.hh:147
FvBaseNewtonConvergenceWriter(NewtonMethod &nm)
Definition: fvbasenewtonconvergencewriter.hh:72
void beginIteration()
Called by the Newton method before an iteration of the Newton algorithm is started.
Definition: fvbasenewtonconvergencewriter.hh:97
void endIteration()
Called by the Newton method after an iteration of the Newton algorithm has been completed.
Definition: fvbasenewtonconvergencewriter.hh:137
~FvBaseNewtonConvergenceWriter()
Definition: fvbasenewtonconvergencewriter.hh:80
The multi-dimensional Newton method.
Definition: newtonmethod.hh:92
Simplifies writing multi-file VTK datasets.
Definition: vtkmultiwriter.hh:66
void endWrite(bool onlyDiscard=false)
Finalizes the current writer.
Definition: vtkmultiwriter.hh:389
void beginWrite(double t)
Called whenever a new time step must be written.
Definition: vtkmultiwriter.hh:179
Definition: blackoilmodel.hh:72
Definition: blackoilboundaryratevector.hh:37
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:235
The Opm property system, traits with inheritance.