3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
multidomain/io/vtkoutputmodule.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 *****************************************************************************/
24#ifndef DUMUX_MULTIDOMAIN_VTK_OUTPUT_MODULE_HH
25#define DUMUX_MULTIDOMAIN_VTK_OUTPUT_MODULE_HH
26
27#include <tuple>
28#include <memory>
29#include <utility>
30
31#include <dune/common/hybridutilities.hh>
32#include <dune/common/indices.hh>
33
36
37namespace Dumux {
38
45template<class MDTraits, template<class GV, class S> class Module = Dumux::VtkOutputModule>
47{
48 using MDSolutionVector = typename MDTraits::SolutionVector;
49 static constexpr std::size_t numSubDomains = MDTraits::numSubDomains;
50
51 template<std::size_t i>
52 using GridVariables = typename MDTraits::template SubDomain<i>::GridVariables;
53
54 using MDGridVars = typename MDTraits::template TupleOfSharedPtrConst<GridVariables>;
55
56 template<std::size_t i>
57 using SolutionVector = typename MDTraits::template SubDomain<i>::SolutionVector;
58
59 template<std::size_t i>
60 using VtkOutputModule = Module<GridVariables<i>, SolutionVector<i>>;
61
62 using VtkOutputModuleTuple = typename MDTraits::template TupleOfSharedPtr<VtkOutputModule>;
63
64public:
66 template<std::size_t i>
67 using Type = VtkOutputModule<i>;
68
70 template<std::size_t i>
71 using PtrType = std::shared_ptr<Type<i>>;
72
77
84 MultiDomainVtkOutputModule(MDGridVars&& gridVars, const MDSolutionVector& sol,
85 const std::array<std::string, numSubDomains>& name)
86 {
87 using namespace Dune::Hybrid;
88 forEach(std::make_index_sequence<numSubDomains>{}, [&](auto&& id)
89 {
90 constexpr auto i = std::decay_t<decltype(id)>::value;
91 elementAt(vtkOutputModule_, id) = std::make_shared<Type<i>>(*std::get<i>(gridVars), sol[id], name[id]);
92 });
93 }
94
97 {
98 using namespace Dune::Hybrid;
99 forEach(std::make_index_sequence<numSubDomains>{}, [&](auto&& id)
100 {
101 constexpr auto i = std::decay_t<decltype(id)>::value;
102 MDTraits::template SubDomain<i>::IOFields::initOutputModule(*elementAt(vtkOutputModule_, id));
103 });
104 }
105
107 void write(double t, Dune::VTK::OutputType type = Dune::VTK::ascii)
108 {
109 using namespace Dune::Hybrid;
110 forEach(std::make_index_sequence<numSubDomains>{}, [&](auto&& id)
111 {
112 elementAt(vtkOutputModule_, id)->write(t, type);
113 });
114 }
115
117 template<std::size_t i>
118 const Type<i>& operator[] (Dune::index_constant<i> id) const
119 { return *Dune::Hybrid::elementAt(vtkOutputModule_, id); }
120
122 template<std::size_t i>
123 Type<i>& operator[] (Dune::index_constant<i> id)
124 { return *Dune::Hybrid::elementAt(vtkOutputModule_, id); }
125
127 template<std::size_t i>
128 PtrType<i> get(Dune::index_constant<i> id = Dune::index_constant<i>{})
129 { return Dune::Hybrid::elementAt(vtkOutputModule_, id); }
130
132 template<std::size_t i>
133 void set(PtrType<i> p, Dune::index_constant<i> id = Dune::index_constant<i>{})
134 { Dune::Hybrid::elementAt(vtkOutputModule_, id) = p; }
135
136private:
137
139 typename MDTraits::template Tuple<PtrType> vtkOutputModule_;
140};
141
142} // end namespace Dumux
143
144#endif
Utilities for template meta programming.
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
A VTK output module to simplify writing dumux simulation data to VTK format.
Definition: io/vtkoutputmodule.hh:66
A multidomain wrapper for multiple vtk output modules.
Definition: multidomain/io/vtkoutputmodule.hh:47
PtrType< i > get(Dune::index_constant< i > id=Dune::index_constant< i >{})
return the vtkoutput module for domain with index i
Definition: multidomain/io/vtkoutputmodule.hh:128
void set(PtrType< i > p, Dune::index_constant< i > id=Dune::index_constant< i >{})
set the pointer for sub domain i
Definition: multidomain/io/vtkoutputmodule.hh:133
void initDefaultOutputFields()
initialized all vtkoutput modules with the models default output fields
Definition: multidomain/io/vtkoutputmodule.hh:96
std::shared_ptr< Type< i > > PtrType
export pointer types the stored type
Definition: multidomain/io/vtkoutputmodule.hh:71
MultiDomainVtkOutputModule()=default
The default constructor.
MultiDomainVtkOutputModule(MDGridVars &&gridVars, const MDSolutionVector &sol, const std::array< std::string, numSubDomains > &name)
Contruct the vtk output modules.
Definition: multidomain/io/vtkoutputmodule.hh:84
void write(double t, Dune::VTK::OutputType type=Dune::VTK::ascii)
Write the data for this timestep to file for all output moduless.
Definition: multidomain/io/vtkoutputmodule.hh:107
const Type< i > & operator[](Dune::index_constant< i > id) const
return the output module for domain with index i
Definition: multidomain/io/vtkoutputmodule.hh:118
VtkOutputModule< i > Type
export base types of the stored type
Definition: multidomain/io/vtkoutputmodule.hh:67
A VTK output module to simplify writing dumux simulation data to VTK format.