9#include <dune/common/typelist.hh>
13#include <dune/vtk/utility/arguments.hh>
19 enum class FormatTypes {
24 APPENDED = BINARY | COMPRESSED
26 std::string to_string (Vtk::FormatTypes);
27 inline const auto formatTypesList = {FormatTypes::ASCII, FormatTypes::BINARY, FormatTypes::COMPRESSED, FormatTypes::APPENDED};
34 enum class RangeTypes {
41 std::string to_string (Vtk::RangeTypes);
42 inline const auto rangeTypesList = {RangeTypes::UNSPECIFIED, RangeTypes::AUTO, RangeTypes::SCALAR, RangeTypes::VECTOR, RangeTypes::TENSOR};
48 Vtk::RangeTypes rangeTypeOf (
int ncomps);
51 enum class DataTypes {
60 std::string to_string (Vtk::DataTypes);
61 inline const auto dataTypesLists = {
63 DataTypes::INT8, DataTypes::UINT8,
64 DataTypes::INT16, DataTypes::UINT16,
65 DataTypes::INT32, DataTypes::UINT32,
66 DataTypes::INT64, DataTypes::UINT64,
67 DataTypes::FLOAT32, DataTypes::FLOAT64
74 Vtk::DataTypes dataTypeOf (std::string);
78 Vtk::DataTypes dataTypeOf ()
80 using F =
typename FieldTraits<T>::field_type;
81 if constexpr (std::is_same_v<F, std::int8_t>) {
return Vtk::DataTypes::INT8; }
82 if constexpr (std::is_same_v<F, std::uint8_t>) {
return Vtk::DataTypes::UINT8; }
83 if constexpr (std::is_same_v<F, std::int16_t>) {
return Vtk::DataTypes::INT16; }
84 if constexpr (std::is_same_v<F, std::uint16_t>) {
return Vtk::DataTypes::UINT16; }
85 if constexpr (std::is_same_v<F, std::int32_t>) {
return Vtk::DataTypes::INT32; }
86 if constexpr (std::is_same_v<F, std::uint32_t>) {
return Vtk::DataTypes::UINT32; }
87 if constexpr (std::is_same_v<F, std::int64_t>) {
return Vtk::DataTypes::INT64; }
88 if constexpr (std::is_same_v<F, std::uint64_t>) {
return Vtk::DataTypes::UINT64; }
89 if constexpr (std::is_same_v<F, float>) {
return Vtk::DataTypes::FLOAT32; }
90 if constexpr (std::is_same_v<F, double>) {
return Vtk::DataTypes::FLOAT64; }
91 if constexpr (std::is_same_v<F, long double>) {
return Vtk::DataTypes::FLOAT64; }
92 return Vtk::DataTypes::UNKNOWN;
95 template <
class>
struct NoConstraint : std::true_type {};
98 template <
template <
class>
class C = NoConstraint,
class Caller>
99 void mapDataTypes (Vtk::DataTypes t, Caller caller)
102 case DataTypes::INT8:
if constexpr(C<std::int8_t>::value) caller(MetaType<std::int8_t>{});
break;
103 case DataTypes::UINT8:
if constexpr(C<std::uint8_t>::value) caller(MetaType<std::uint8_t>{});
break;
104 case DataTypes::INT16:
if constexpr(C<std::int16_t>::value) caller(MetaType<std::int16_t>{});
break;
105 case DataTypes::UINT16:
if constexpr(C<std::uint16_t>::value) caller(MetaType<std::uint16_t>{});
break;
106 case DataTypes::INT32:
if constexpr(C<std::int32_t>::value) caller(MetaType<std::int32_t>{});
break;
107 case DataTypes::UINT32:
if constexpr(C<std::uint32_t>::value) caller(MetaType<std::uint32_t>{});
break;
108 case DataTypes::INT64:
if constexpr(C<std::int64_t>::value) caller(MetaType<std::int64_t>{});
break;
109 case DataTypes::UINT64:
if constexpr(C<std::uint64_t>::value) caller(MetaType<std::uint64_t>{});
break;
110 case DataTypes::FLOAT32:
if constexpr(C<float>::value) caller(MetaType<float>{});
break;
111 case DataTypes::FLOAT64:
if constexpr(C<double>::value) caller(MetaType<double>{});
break;
119 template <
template <
class>
class Constraint1 = NoConstraint,
120 template <
class>
class Constraint2 = NoConstraint,
122 void mapDataTypes (Vtk::DataTypes t1, Vtk::DataTypes t2, Caller caller)
124 mapDataTypes<Constraint1>(t1, [&](
auto type1) {
125 mapDataTypes<Constraint2>(t2, [&](
auto type2) {
126 caller(type1, type2);
132 template <
template <
class>
class Constraint1 = NoConstraint,
133 template <
class>
class Constraint2 = NoConstraint,
134 template <
class>
class Constraint3 = NoConstraint,
136 void mapDataTypes (Vtk::DataTypes t1, Vtk::DataTypes t2, Vtk::DataTypes t3, Caller caller)
138 mapDataTypes<Constraint1>(t1, [&](
auto type1) {
139 mapDataTypes<Constraint2>(t2, [&](
auto type2) {
140 mapDataTypes<Constraint3>(t3, [&](
auto type3) {
141 caller(type1, type2, type3);
148 enum class CompressorTypes {
154 std::string to_string (CompressorTypes);
160 enum Parametrization {
167 enum Type : std::uint8_t {
186 QUADRATIC_TRIANGLE = 22,
188 QUADRATIC_TETRA = 24,
189 QUADRATIC_HEXAHEDRON = 25,
190 QUADRATIC_WEDGE = 26,
191 QUADRATIC_PYRAMID = 27,
193 BIQUADRATIC_QUAD = 28,
194 TRIQUADRATIC_HEXAHEDRON = 29,
195 BIQUADRATIC_TRIANGLE = 34,
196 TRIQUADRATIC_PYRAMID = 37,
199 LAGRANGE_TRIANGLE = 69,
200 LAGRANGE_QUADRILATERAL= 70,
201 LAGRANGE_TETRAHEDRON = 71,
202 LAGRANGE_HEXAHEDRON = 72,
204 LAGRANGE_PYRAMID = 74,
216 int layout (
int dim)
const
224 return permutation_[idx];
230 return permutation_.size();
233 bool noPermutation ()
const
235 return noPermutation_;
240 std::vector<int> layout_;
241 std::vector<int> permutation_;
242 bool noPermutation_ =
true;
244 GeometryType to_geometry (std::uint8_t);
250 template <
class... Args>
251 explicit FieldInfo (std::string name, Args... args)
252 : name_(
std::move(name))
253 , ncomps_(getArg<int,unsigned int,long,unsigned long>(args..., 1))
254 , rangeType_(getArg<Vtk::RangeTypes>(args..., Vtk::RangeTypes::AUTO))
255 , dataType_(getArg<Vtk::DataTypes>(args..., Vtk::DataTypes::FLOAT32))
257 if (rangeType_ == Vtk::RangeTypes::AUTO)
258 rangeType_ = rangeTypeOf(ncomps_);
263 : FieldInfo(info.name(), info.
size(), rangeTypeOf(info.type()), dataTypeOf(info.precision()))
267 std::string
const& name ()
const
279 Vtk::RangeTypes rangeType ()
const
285 Vtk::DataTypes dataType ()
const
293 Vtk::RangeTypes rangeType_;
294 Vtk::DataTypes dataType_;
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
Descriptor struct for VTK fields.
Definition: common.hh:328
Type
VTK data type.
Definition: common.hh:333
Various macros to work with Dune module version numbers.
Common stuff for the VTKWriter.
Precision
which precision to use when writing out data to vtk files
Definition: common.hh:271
OutputType
How the bulk data should be stored in the file.
Definition: common.hh:43
Macro for wrapping error checks and throwing exceptions.
#define VTK_ASSERT_MSG(cond, text)
check if condition cond holds; otherwise, throw a VtkError with a message.
Definition: errors.hh:19
Type traits to determine the type of reals (when working with complex numbers)
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
Mapping of Dune geometry types to VTK cell types.
Definition: types.hh:159
int size() const
Number of nodes.
Definition: types.hh:228
std::uint8_t type() const
Return VTK Cell type.
Definition: types.hh:211
int permutation(int idx) const
Return a permutation of Dune element vertices to conform to VTK element numbering.
Definition: types.hh:222
A unique label for each type of element that can occur in a grid.