63 std::string
title =
"Aleph::CA frame";
69namespace ca_vtk_detail {
74 using U = std::remove_cv_t<T>;
75 if constexpr (std::is_same_v<U, bool>)
76 return "unsigned_char";
77 else if constexpr (std::is_floating_point_v<U>
and sizeof(
U) <=
sizeof(
float))
79 else if constexpr (std::is_floating_point_v<U>)
81 else if constexpr (std::is_signed_v<U>
and sizeof(
U) <=
sizeof(
int))
83 else if constexpr (std::is_signed_v<U>)
85 else if constexpr (
sizeof(
U) <=
sizeof(
unsigned int))
86 return "unsigned_int";
88 return "unsigned_long";
94 if constexpr (std::is_same_v<std::remove_cv_t<T>,
bool>)
96 else if constexpr (std::is_integral_v<T>
and sizeof(
T) == 1)
118template <
typename Lattice>
125 "write_vtk_legacy supports rank-2 and rank-3 frames");
127 static_assert(std::is_arithmetic_v<state_t>,
"write_vtk_legacy requires arithmetic states");
135 out <<
"# vtk DataFile Version 3.0\n";
138 out <<
"DATASET STRUCTURED_POINTS\n";
139 out <<
"DIMENSIONS " <<
nx <<
' ' <<
ny <<
' ' <<
nz <<
'\n';
140 out <<
"ORIGIN " <<
opts.origin[0] <<
' ' <<
opts.origin[1] <<
' ' <<
opts.origin[2] <<
'\n';
141 out <<
"SPACING " <<
opts.spacing[0] <<
' ' <<
opts.spacing[1] <<
' ' <<
opts.spacing[2] <<
'\n';
142 out <<
"POINT_DATA " << points <<
'\n';
143 out <<
"SCALARS " <<
opts.scalar_name <<
' ' << ca_vtk_detail::vtk_scalar_type<state_t>() <<
" 1\n";
144 out <<
"LOOKUP_TABLE default\n";
152 out, frame.
at(
coord_t{static_cast<ca_index_t>(r), static_cast<ca_index_t>(c)}));
163 out, frame.
at(
coord_t{static_cast<ca_index_t>(z), static_cast<ca_index_t>(y),
164 static_cast<ca_index_t>(x)}));
187 const std::size_t zero_pad = 6)
196 template <
typename Lattice>
200 if (
const auto parent = path.parent_path();
not parent.empty())
201 std::filesystem::create_directories(parent);
202 std::ofstream
out(path);
Exception handling system with formatted messages for Aleph-w.
#define ah_runtime_error_if(C)
Throws std::runtime_error if condition holds.
size_t size_t int32_t value
size_t size_t int32_t * out
Directory-backed frame sinks for CA trajectories.
File-format readers and writers for cellular-automata frames.
Lattice that adds boundary-aware access on top of a storage.
typename Storage::state_type state_type
typename Storage::coord_type coord_type
static constexpr std::size_t rank
ca_size_t size() const noexcept
state_type at(const coord_type &c) const
Strict access: throws if c is out of range.
Path-pattern sink that writes VTK legacy frames.
VTK_Frame_Sink(std::filesystem::path path_pattern, VTK_Write_Options opts={}, const std::size_t zero_pad=6)
Build a VTK frame sink.
void accept(const std::size_t step, const Lattice &frame)
Write one VTK frame.
std::filesystem::path pattern_
void flush()
VTK frames are written eagerly; this is a no-op.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
void write_scalar(std::ostream &out, const T &value)
const char * vtk_scalar_type()
void write_vtk_legacy(std::ostream &out, const Lattice &frame, const VTK_Write_Options &opts={})
Write a 2D or 3D lattice as VTK legacy STRUCTURED_POINTS.
std::filesystem::path format_step_path(const std::filesystem::path &pattern, const std::size_t step, const std::size_t zero_pad=6)
Format a step-indexed file path.
std::size_t ca_size_t
Unsigned size component used for extents and counts.
Main namespace for Aleph-w library functions.
and
Check uniqueness with explicit hash + equality functors.
std::decay_t< typename HeadC::Item_Type > T
Options for VTK legacy output.
std::string scalar_name
scalar field name
double spacing[3]
grid spacing in x, y, z
double origin[3]
grid origin in x, y, z
std::string title
VTK header title.
C++20 concepts for the Cellular Automata module.