6 #include <dune/common/typeutilities.hh> 8 #include <amdis/BoundaryManager.hpp> 9 #include <amdis/LinearAlgebra.hpp> 10 #include <amdis/Output.hpp> 11 #include <amdis/gridfunctions/DiscreteFunction.hpp> 12 #include <amdis/io/BackupWriter.hpp> 13 #include <amdis/io/DuneVtkWriter.hpp> 14 #include <amdis/io/FileWriterBase.hpp> 15 #include <amdis/io/GmshWriter.hpp> 16 #include <amdis/io/VTKWriter.hpp> 24 template <
class SystemVector>
29 using Grid =
typename GridView::Grid;
35 : systemVector_(
std::move(systemVector))
36 , boundaryManager_(
std::move(boundaryManager))
46 std::unique_ptr<FileWriterInterface>
49 auto data =
valueOf(*systemVector_, ii...);
50 return create_impl(std::move(type), std::move(prefix), data, Dune::PriorityTag<42>{});
55 REQUIRES(not std::is_same_v<ValueCategory_t<typename Data::Range>,
tag::unknown>),
56 REQUIRES(std::is_arithmetic_v<
typename Dune::FieldTraits<typename Data::Range>::field_type>)>
57 std::unique_ptr<FileWriterInterface>
58 create_impl(std::string type, std::string prefix, Data
const& data, Dune::PriorityTag<2>)
const 60 GridView
const& gridView = systemVector_->basis().gridView();
65 return std::make_unique<VTKWriter<GridView,Data>>(prefix, gridView, data);
69 else if (type ==
"dune-vtk")
71 return std::make_unique<DuneVtkWriter<GridView,Data>>(prefix, gridView, data);
75 else if (type ==
"gmsh")
77 if (!!boundaryManager_)
78 return std::make_unique<GmshWriter<GridView>>(prefix, gridView,
79 std::vector<int>{}, boundaryManager_->boundaryIds());
81 return std::make_unique<GmshWriter<GridView>>(prefix, gridView);
84 else if (type ==
"backup")
86 return std::make_unique<BackupWriter<SystemVector>>(prefix, systemVector_);
89 error_exit(
"Unknown filewriter type '{}' given for '{}'. Use one of " 90 "(vtk, gmsh, backup, [dune-vtk]), where the last one is only available " 91 "if the dune module dune-vtk is found.", type, prefix);
98 REQUIRES(std::is_same_v<ValueCategory_t<typename Data::Range>,
tag::unknown>),
99 REQUIRES(std::is_arithmetic_v<
typename Dune::FieldTraits<typename Data::Range>::field_type>)>
100 std::unique_ptr<FileWriterInterface>
101 create_impl(std::string type, std::string prefix, Data
const& , Dune::PriorityTag<1>)
const 104 if (type ==
"backup")
106 return std::make_unique<BackupWriter<SystemVector>>(prefix, systemVector_);
109 error_exit(
"Filewriter '{}' cannot be applied to this component in the tree. " 110 "Either use the writer 'backup' to write the whole tree, or add a treepath " 111 "to the output prefix '{}'.", type, prefix);
116 template <
class Data>
117 std::unique_ptr<FileWriterInterface>
118 create_impl(std::string, std::string, Data
const&, Dune::PriorityTag<0>)
const 120 error_exit(
"Filewriter cannot be used with unsupported Range and field_type");
125 std::shared_ptr<SystemVector> systemVector_;
126 std::shared_ptr<BoundaryManager<Grid>> boundaryManager_ =
nullptr;
std::index_sequence< I... > Indices
class that represents a sequence of indices
Definition: Index.hpp:40
void error_exit(std::string const &str, Args &&... args)
print a message and exit
Definition: Output.hpp:142
Definition: FieldMatVec.hpp:12
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6
Creator class for filewriters depending on a given type name.
Definition: FileWriterCreator.hpp:25
auto valueOf(DiscreteFunction< C, GB, TP, R > &df, Indices... ii)
A Generator for the childs of a mutable DiscreteFunction.
Definition: DiscreteFunction.hpp:272
typename PreBasis::GridView GridView
The grid view that the FE space is defined on.
Definition: GlobalBasis.hpp:66
FileWriterCreator(std::shared_ptr< SystemVector > systemVector, std::shared_ptr< BoundaryManager< Grid >> boundaryManager=nullptr)
Constructor. Stores the pointer to the systemVector and to the (optional) boundaryManager.
Definition: FileWriterCreator.hpp:33
constexpr bool GlobalBasis
A Dune::Functions::GlobalBasis type.
Definition: Concepts.hpp:190
Manage boundary ids of boundary segments in a grid.
Definition: BoundaryManager.hpp:52
std::unique_ptr< FileWriterInterface > create(std::string type, std::string prefix, Indices... ii) const
Create a new FileWriter of type type
Definition: FileWriterCreator.hpp:47