DOLFINx 0.11.0.0
DOLFINx C++
Loading...
Searching...
No Matches
ADIOS2Writers.h
Go to the documentation of this file.
1// Copyright (C) 2021-2023 Jørgen S. Dokken and Garth N. Wells
2//
3// This file is part of DOLFINX (https://www.fenicsproject.org)
4//
5// SPDX-License-Identifier: LGPL-3.0-or-later
6
7#pragma once
8
9#ifdef HAS_ADIOS2
10
11#include "vtk_utils.h"
12#include <adios2.h>
13#include <algorithm>
14#include <basix/mdspan.hpp>
15#include <cassert>
16#include <complex>
17#include <concepts>
18#include <dolfinx/common/IndexMap.h>
19#include <dolfinx/fem/DofMap.h>
20#include <dolfinx/fem/FiniteElement.h>
21#include <dolfinx/fem/Function.h>
22#include <dolfinx/mesh/Geometry.h>
23#include <dolfinx/mesh/Mesh.h>
24#include <filesystem>
25#include <memory>
26#include <mpi.h>
27#include <stdexcept>
28#include <string>
29#include <type_traits>
30#include <variant>
31#include <vector>
32
35
36namespace dolfinx::fem
37{
38template <dolfinx::scalar T, std::floating_point U>
39class Function;
40}
41
42namespace dolfinx::io
43{
44namespace adios2_writer
45{
47template <std::floating_point T>
48using U = std::vector<std::variant<
49 std::shared_ptr<const fem::Function<float, T>>,
50 std::shared_ptr<const fem::Function<double, T>>,
51 std::shared_ptr<const fem::Function<std::complex<float>, T>>,
52 std::shared_ptr<const fem::Function<std::complex<double>, T>>>>;
53} // namespace adios2_writer
54
56class ADIOS2Writer
57{
58protected:
65 ADIOS2Writer(MPI_Comm comm, const std::filesystem::path& filename,
66 std::string tag, std::string engine);
67
69 ADIOS2Writer(ADIOS2Writer&& writer) = default;
70
72 ADIOS2Writer(const ADIOS2Writer&) = delete;
73
75 ~ADIOS2Writer();
76
78 ADIOS2Writer& operator=(ADIOS2Writer&& writer) = default;
79
80 // Copy assignment
81 ADIOS2Writer& operator=(const ADIOS2Writer&) = delete;
82
83public:
85 void close();
86
87protected:
88 std::unique_ptr<adios2::ADIOS> _adios;
89 std::unique_ptr<adios2::IO> _io;
90 std::unique_ptr<adios2::Engine> _engine;
91};
92
94namespace impl_adios2
95{
98constexpr std::array field_ext = {"_real", "_imag"};
99
102template <class T>
103adios2::Attribute<T> define_attribute(adios2::IO& io, std::string name,
104 const T& value, std::string var_name = "",
105 std::string separator = "/")
106{
107 if (adios2::Attribute<T> attr = io.InquireAttribute<T>(name); attr)
108 return attr;
109 else
110 return io.DefineAttribute<T>(name, value, var_name, separator);
111}
112
115template <class T>
116adios2::Variable<T> define_variable(adios2::IO& io, std::string name,
117 const adios2::Dims& shape = adios2::Dims(),
118 const adios2::Dims& start = adios2::Dims(),
119 const adios2::Dims& count = adios2::Dims())
120{
121 if (adios2::Variable v = io.InquireVariable<T>(name); v)
122 {
123 if (v.Count() != count and v.ShapeID() == adios2::ShapeID::LocalArray)
124 v.SetSelection({start, count});
125 return v;
126 }
127 else
128 return io.DefineVariable<T>(name, shape, start, count);
129}
130
132template <std::floating_point T>
133std::shared_ptr<const mesh::Mesh<T>>
134extract_common_mesh(const typename adios2_writer::U<T>& u)
135{
136 // Extract mesh from first function
137 assert(!u.empty());
138 auto mesh = std::visit([](auto&& u) { return u->function_space()->mesh(); },
139 u.front());
140 assert(mesh);
141
142 // Check that all functions share the same mesh
143 for (auto& v : u)
144 {
145 std::visit(
146 [&mesh](auto&& u)
147 {
148 if (mesh != u->function_space()->mesh())
149 {
150 throw std::runtime_error(
151 "ADIOS2Writer only supports functions sharing the same mesh");
152 }
153 },
154 v);
155 }
156
157 return mesh;
158}
159
160} // namespace impl_adios2
161
163namespace impl_vtx
164{
167std::stringstream create_vtk_schema(const std::vector<std::string>& point_data,
168 const std::vector<std::string>& cell_data);
169
171template <std::floating_point T>
172std::tuple<std::vector<std::string>, std::vector<std::string>>
173extract_function_names(const typename adios2_writer::U<T>& u)
174{
175 std::vector<std::string> names, dg0_names;
176 std::ranges::for_each(
177 u,
178 [&names, &dg0_names](auto&& v)
179 {
180 std::visit(
181 [&names, &dg0_names](auto&& v)
182 {
183 using U = std::decay_t<decltype(v)>;
184 using X = typename U::element_type;
185
186 // append function names either to dg0_names or names
187 auto& fnames
188 = impl::is_cellwise(*(v->function_space()->element()))
189 ? dg0_names
190 : names;
191
192 if constexpr (std::is_floating_point_v<typename X::value_type>)
193 fnames.push_back(v->name);
194 else
195 {
196 fnames.push_back(v->name + impl_adios2::field_ext[0]);
197 fnames.push_back(v->name + impl_adios2::field_ext[1]);
198 }
199 },
200 v);
201 });
202
203 {
204 // Check names are unique
205 auto sorted = names;
206 std::ranges::sort(sorted);
207 if (std::ranges::unique(sorted).begin() != sorted.end())
208 {
209 throw std::runtime_error(
210 "Function names in VTX output need to be unique.");
211 }
212 }
213
214 return {names, dg0_names};
215}
216
226template <typename T, std::floating_point X>
227void vtx_write_data(adios2::IO& io, adios2::Engine& engine,
228 const fem::Function<T, X>& u)
229{
230 // Get function data array and information about layout
231 assert(u.x());
232 std::span<const T> u_vector = u.x()->array();
233
234 // Pad to 3D if vector/tensor is product of dimensions is smaller than
235 // 3**rank to ensure that we can visualize them correctly in Paraview
236 std::span<const std::size_t> value_shape
237 = u.function_space()->element()->value_shape();
238 std::size_t rank = value_shape.size();
239 std::size_t num_comp = std::reduce(value_shape.begin(), value_shape.end(), 1,
240 std::multiplies{});
241 if (num_comp < std::pow(3, rank))
242 num_comp = std::pow(3, rank);
243
244 std::shared_ptr<const fem::DofMap> dofmap = u.function_space()->dofmap();
245 assert(dofmap);
246 std::shared_ptr<const common::IndexMap> index_map = dofmap->index_map;
247 assert(index_map);
248 int index_map_bs = dofmap->index_map_bs();
249 int dofmap_bs = dofmap->bs();
250 std::uint32_t num_dofs = index_map_bs
251 * (index_map->size_local() + index_map->num_ghosts())
252 / dofmap_bs;
253 if constexpr (std::is_scalar_v<T>)
254 {
255 // ---- Real
256 std::vector<T> data(num_dofs * num_comp, 0);
257 for (std::size_t i = 0; i < num_dofs; ++i)
258 for (int j = 0; j < index_map_bs; ++j)
259 data[i * num_comp + j] = u_vector[i * index_map_bs + j];
260
261 adios2::Variable output = impl_adios2::define_variable<T>(
262 io, u.name, {}, {}, {num_dofs, num_comp});
263 spdlog::debug("Output data size={}", data.size());
264 engine.Put(output, data.data(), adios2::Mode::Sync);
265 }
266 else
267 {
268 // ---- Complex
269 using U = typename T::value_type;
270
271 std::vector<U> data(num_dofs * num_comp, 0);
272 for (std::size_t i = 0; i < num_dofs; ++i)
273 for (int j = 0; j < index_map_bs; ++j)
274 data[i * num_comp + j] = std::real(u_vector[i * index_map_bs + j]);
275
276 adios2::Variable output_real = impl_adios2::define_variable<U>(
277 io, u.name + impl_adios2::field_ext[0], {}, {}, {num_dofs, num_comp});
278 engine.Put(output_real, data.data(), adios2::Mode::Sync);
279
280 std::ranges::fill(data, 0);
281 for (std::size_t i = 0; i < num_dofs; ++i)
282 for (int j = 0; j < index_map_bs; ++j)
283 data[i * num_comp + j] = std::imag(u_vector[i * index_map_bs + j]);
284 adios2::Variable output_imag = impl_adios2::define_variable<U>(
285 io, u.name + impl_adios2::field_ext[1], {}, {}, {num_dofs, num_comp});
286 engine.Put(output_imag, data.data(), adios2::Mode::Sync);
287 }
288}
289
294template <std::floating_point T>
295void vtx_write_mesh(adios2::IO& io, adios2::Engine& engine,
296 const mesh::Mesh<T>& mesh)
297{
298 const mesh::Geometry<T>& geometry = mesh.geometry();
299 auto topology = mesh.topology();
300 assert(topology);
301
302 // "Put" geometry
303 std::shared_ptr<const common::IndexMap> x_map = geometry.index_map();
304 std::uint32_t num_vertices = x_map->size_local() + x_map->num_ghosts();
305 adios2::Variable local_geometry = impl_adios2::define_variable<T>(
306 io, "geometry", {}, {}, {num_vertices, 3});
307 spdlog::debug("Put local_geometry: {}x3", num_vertices);
308 engine.Put(local_geometry, geometry.x().data());
309
310 // Put number of nodes. The mesh data is written with local indices,
311 // therefore we need the ghost vertices.
312 adios2::Variable vertices = impl_adios2::define_variable<std::uint32_t>(
313 io, "NumberOfNodes", {adios2::LocalValueDim});
314 engine.Put<std::uint32_t>(vertices, num_vertices);
315
316 auto [vtkcells, shape]
317 = io::extract_vtk_connectivity(geometry.dofmap(), topology->cell_type());
318
319 // Add cell metadata
320 int tdim = topology->dim();
321 adios2::Variable cell_var = impl_adios2::define_variable<std::uint32_t>(
322 io, "NumberOfCells", {adios2::LocalValueDim});
323 engine.Put<std::uint32_t>(cell_var, shape[0]);
324 spdlog::debug("Put local_cells: {}", shape[0]);
325
326 adios2::Variable celltype_var
328 engine.Put<std::uint32_t>(
329 celltype_var, cells::get_vtk_cell_type(topology->cell_type(), tdim));
330
331 // Pack mesh 'nodes'. Output is written as [N0, v0_0,...., v0_N0, N1,
332 // v1_0,...., v1_N1,....], where N is the number of cell nodes and v0,
333 // etc, is the node index
334 std::vector<std::int64_t> cells(shape[0] * (shape[1] + 1), shape[1]);
335 for (std::size_t c = 0; c < shape[0]; ++c)
336 {
337 std::span vtkcell(vtkcells.data() + c * shape[1], shape[1]);
338 std::span cell(cells.data() + c * (shape[1] + 1), shape[1] + 1);
339 std::ranges::copy(vtkcell, std::next(cell.begin()));
340 }
341
342 // Put topology (nodes)
343 adios2::Variable local_topology = impl_adios2::define_variable<std::int64_t>(
344 io, "connectivity", {}, {}, {shape[0], shape[1] + 1});
345 spdlog::debug("Put local_topology: {}x{}", shape[0], shape[1] + 1);
346
347 engine.Put(local_topology, cells.data());
348
349 // Vertex global ids and ghost markers
350 adios2::Variable orig_id = impl_adios2::define_variable<std::int64_t>(
351 io, "vtkOriginalPointIds", {}, {}, {num_vertices});
352 engine.Put(orig_id, geometry.input_global_indices().data());
353
354 std::vector<std::uint8_t> x_ghost(num_vertices, 0);
355 std::fill(std::next(x_ghost.begin(), x_map->size_local()), x_ghost.end(), 1);
356 adios2::Variable ghost = impl_adios2::define_variable<std::uint8_t>(
357 io, "vtkGhostType", {}, {}, {x_ghost.size()});
358 engine.Put(ghost, x_ghost.data());
359 engine.PerformPuts();
360}
361
369template <std::floating_point T>
370std::pair<std::vector<std::int64_t>, std::vector<std::uint8_t>>
371vtx_write_mesh_from_space(adios2::IO& io, adios2::Engine& engine,
372 const fem::FunctionSpace<T>& V)
373{
374 auto mesh = V.mesh();
375 assert(mesh);
376 auto topology = mesh->topology();
377 assert(topology);
378 int tdim = topology->dim();
379
380 // Get a VTK mesh with points at the 'nodes'
381 auto [x, xshape, x_id, x_ghost, vtk, vtkshape] = io::vtk_mesh_from_space(V);
382
383 spdlog::debug("x={}, xshape={}x{}, x_id={}, x_ghost={}", x.size(), xshape[0],
384 xshape[1], x_id.size(), x_ghost.size());
385
386 std::uint32_t num_dofs = xshape[0];
387
388 // -- Pack mesh 'nodes'. Output is written as [N0, v0_0,...., v0_N0, N1,
389 // v1_0,...., v1_N1,....], where N is the number of cell nodes and v0,
390 // etc, is the node index.
391
392 spdlog::debug("Create cells: [{}x{}]", vtkshape[0], vtkshape[1]);
393
394 // Create vector, setting all entries to nodes per cell (vtk.shape(1))
395 std::vector<std::int64_t> cells(vtkshape[0] * (vtkshape[1] + 1), vtkshape[1]);
396
397 // Set the [v0_0,...., v0_N0, v1_0,...., v1_N1,....] data
398 for (std::size_t c = 0; c < vtkshape[0]; ++c)
399 {
400 std::span vtkcell(vtk.data() + c * vtkshape[1], vtkshape[1]);
401 std::span cell(cells.data() + c * (vtkshape[1] + 1), vtkshape[1] + 1);
402 std::ranges::copy(vtkcell, std::next(cell.begin()));
403 }
404
405 // Define ADIOS2 variables for geometry, topology, celltypes and
406 // corresponding VTK data
407 adios2::Variable local_geometry
408 = impl_adios2::define_variable<T>(io, "geometry", {}, {}, {num_dofs, 3});
409 adios2::Variable local_topology = impl_adios2::define_variable<std::int64_t>(
410 io, "connectivity", {}, {}, {vtkshape[0], vtkshape[1] + 1});
411 adios2::Variable cell_type
413 adios2::Variable vertices = impl_adios2::define_variable<std::uint32_t>(
414 io, "NumberOfNodes", {adios2::LocalValueDim});
415 adios2::Variable elements = impl_adios2::define_variable<std::uint32_t>(
416 io, "NumberOfEntities", {adios2::LocalValueDim});
417
418 // Write mesh information to file
419 spdlog::debug("vertices={}, elements={}, local_geom={}, local_cells={}",
420 num_dofs, vtkshape[0], x.size(), cells.size());
421 engine.Put<std::uint32_t>(vertices, num_dofs);
422 engine.Put<std::uint32_t>(elements, vtkshape[0]);
423 engine.Put<std::uint32_t>(
424 cell_type, cells::get_vtk_cell_type(topology->cell_type(), tdim));
425 engine.Put(local_geometry, x.data());
426 engine.Put(local_topology, cells.data());
427
428 // Node global ids
429 adios2::Variable orig_id = impl_adios2::define_variable<std::int64_t>(
430 io, "vtkOriginalPointIds", {}, {}, {x_id.size(), 1});
431 engine.Put(orig_id, x_id.data());
432 adios2::Variable ghost = impl_adios2::define_variable<std::uint8_t>(
433 io, "vtkGhostType", {}, {}, {x_ghost.size(), 1});
434 engine.Put(ghost, x_ghost.data());
435
436 engine.PerformPuts();
437 return {std::move(x_id), std::move(x_ghost)};
438}
439} // namespace impl_vtx
440
442enum class VTXMeshPolicy : std::int8_t
443{
444 update,
445 reuse
447};
448
454template <std::floating_point T>
455class VTXWriter : public ADIOS2Writer
456{
457public:
469 VTXWriter(MPI_Comm comm, const std::filesystem::path& filename,
470 std::shared_ptr<const mesh::Mesh<T>> mesh,
471 std::string engine = "BPFile")
472 : ADIOS2Writer(comm, filename, "VTX mesh writer", engine), _mesh(mesh),
473 _mesh_reuse_policy(VTXMeshPolicy::update),
474 _has_piecewise_constant(false)
475 {
476 // Define VTK scheme attribute for mesh
477 std::string vtk_scheme = impl_vtx::create_vtk_schema({}, {}).str();
478 impl_adios2::define_attribute<std::string>(*_io, "vtk.xml", vtk_scheme);
479 }
480
496 VTXWriter(MPI_Comm comm, const std::filesystem::path& filename,
497 const typename adios2_writer::U<T>& u, std::string engine,
498 VTXMeshPolicy mesh_policy = VTXMeshPolicy::update)
499 : ADIOS2Writer(comm, filename, "VTX function writer", engine),
500 _mesh(impl_adios2::extract_common_mesh<T>(u)), _u(u),
501 _mesh_reuse_policy(mesh_policy), _has_piecewise_constant(false)
502 {
503 if (u.empty())
504 throw std::runtime_error("VTXWriter fem::Function list is empty.");
505
506 // Extract space from first function
507 auto V0 = std::visit([](auto& u) { return u->function_space().get(); },
508 u.front());
509 assert(V0);
510
511 // Replace first function space if it is a space for piecewise constants
512 bool has_V0_changed = false;
513 for (auto& v : u)
514 {
515 std::visit(
516 [&V0, &has_V0_changed](auto& u)
517 {
518 auto V = u->function_space().get();
519 assert(V);
520 if (!impl::is_cellwise(*V->element()))
521 {
522 V0 = V;
523 has_V0_changed = true;
524 }
525 },
526 v);
527 if (has_V0_changed)
528 break;
529 }
530 auto element0 = V0->element().get();
531 assert(element0);
532
533 // Check if function is mixed
534 if (element0->is_mixed())
535 {
536 throw std::runtime_error(
537 "Mixed functions are not supported by VTXWriter.");
538 }
539
540 // FIXME: is the below check adequate for detecting a Lagrange
541 // element?
542 // Check that element is Lagrange
543 if (!element0->interpolation_ident())
544 {
545 throw std::runtime_error(
546 "Only (discontinuous) Lagrange functions are "
547 "supported. Interpolate Functions before output.");
548 }
549
550 // Check that all functions come from same element type
551 for (auto& v : _u)
552 {
553 std::visit(
554 [V0, this](auto& u)
555 {
556 auto element = u->function_space()->element();
557 assert(element);
558 bool is_piecewise_constant = impl::is_cellwise(*element);
559 _has_piecewise_constant
560 = _has_piecewise_constant || is_piecewise_constant;
561 if (*element != *V0->element().get() and !is_piecewise_constant)
562 {
563 throw std::runtime_error("All functions in VTXWriter must have "
564 "the same element type.");
565 }
566#ifndef NDEBUG
567 auto dmap0 = V0->dofmap()->map();
568 auto dmap = u->function_space()->dofmap()->map();
569 if ((dmap0.size() != dmap.size()
570 or !std::equal(dmap0.data_handle(),
571 dmap0.data_handle() + dmap0.size(),
572 dmap.data_handle()))
573 and !is_piecewise_constant)
574 {
575 throw std::runtime_error(
576 "All functions must have the same dofmap for VTXWriter.");
577 }
578#endif
579 },
580 v);
581 }
582
583 // Define VTK scheme attribute for set of functions
584 auto [names, dg0_names] = impl_vtx::extract_function_names<T>(u);
585 std::string vtk_scheme;
586 vtk_scheme = impl_vtx::create_vtk_schema(names, dg0_names).str();
587
588 impl_adios2::define_attribute<std::string>(*_io, "vtk.xml", vtk_scheme);
589 }
590
605 VTXWriter(MPI_Comm comm, const std::filesystem::path& filename,
606 const typename adios2_writer::U<T>& u,
607 VTXMeshPolicy mesh_policy = VTXMeshPolicy::update)
608 : VTXWriter(comm, filename, u, "BPFile", mesh_policy)
609 {
610 }
611
612 // Copy constructor
613 VTXWriter(const VTXWriter&) = delete;
614
616 VTXWriter(VTXWriter&& file) = default;
617
619 ~VTXWriter() = default;
620
622 VTXWriter& operator=(VTXWriter&&) = default;
623
624 // Copy assignment
625 VTXWriter& operator=(const VTXWriter&) = delete;
626
629 void write(double t)
630 {
631 assert(_io);
632 adios2::Variable var_step
633 = impl_adios2::define_variable<double>(*_io, "step");
634
635 spdlog::debug("ADIOS2: step");
636 assert(_engine);
637 _engine->BeginStep();
638 _engine->template Put<double>(var_step, t);
639
640 // If we have no non-constant functions write the mesh to file
641 auto [names, dg0_names] = impl_vtx::extract_function_names<T>(_u);
642 if ((names.size() == 0) or _u.empty())
643 {
644 spdlog::debug("ADIOS2: write_mesh");
645 impl_vtx::vtx_write_mesh(*_io, *_engine, *_mesh);
646 }
647 else
648 {
649 if (_mesh_reuse_policy == VTXMeshPolicy::update
650 or !(_io->template InquireVariable<std::int64_t>("connectivity")))
651 {
652 // Write a single mesh for functions as they share finite
653 // element
654 std::tie(_x_id, _x_ghost) = std::visit(
655 [&](auto& u)
656 {
657 spdlog::debug("ADIOS2: write_mesh_from_space");
658 return impl_vtx::vtx_write_mesh_from_space(*_io, *_engine,
659 *u->function_space());
660 },
661 _u[0]);
662 }
663 else
664 {
665 // Node global ids
666 adios2::Variable orig_id = impl_adios2::define_variable<std::int64_t>(
667 *_io, "vtkOriginalPointIds", {}, {}, {_x_id.size()});
668 _engine->Put(orig_id, _x_id.data());
669 adios2::Variable ghost = impl_adios2::define_variable<std::uint8_t>(
670 *_io, "vtkGhostType", {}, {}, {_x_ghost.size()});
671 _engine->Put(ghost, _x_ghost.data());
672 _engine->PerformPuts();
673 }
674 }
675
676 spdlog::debug("Write function data");
677 // Write function data for each function to file
678 for (auto& v : _u)
679 {
680 std::visit([&](auto& u) { impl_vtx::vtx_write_data(*_io, *_engine, *u); },
681 v);
682 }
683
684 _engine->EndStep();
685 }
686
687private:
688 std::shared_ptr<const mesh::Mesh<T>> _mesh;
689 adios2_writer::U<T> _u;
690
691 // Control whether the mesh is written to file once or at every time
692 // step
693 VTXMeshPolicy _mesh_reuse_policy;
694 std::vector<std::int64_t> _x_id;
695 std::vector<std::uint8_t> _x_ghost;
696
697 // Special handling of piecewise constant functions
698 bool _has_piecewise_constant;
699};
700
702template <typename U, typename T>
703VTXWriter(MPI_Comm comm, U filename, T mesh)
704 -> VTXWriter<typename std::remove_cvref<
705 typename T::element_type>::type::geometry_type::value_type>;
706
707} // namespace dolfinx::io
708
709#endif
std::shared_ptr< const mesh::Mesh< T > > extract_common_mesh(const typename adios2_writer::U< T > &u)
Extract common mesh from list of Functions.
Definition ADIOS2Writers.h:134
std::pair< std::vector< std::int64_t >, std::vector< std::uint8_t > > vtx_write_mesh_from_space(adios2::IO &io, adios2::Engine &engine, const fem::FunctionSpace< T > &V)
Given a FunctionSpace, create a topology and geometry based on the function space dof coordinates....
Definition ADIOS2Writers.h:371
adios2::Variable< T > define_variable(adios2::IO &io, std::string name, const adios2::Dims &shape=adios2::Dims(), const adios2::Dims &start=adios2::Dims(), const adios2::Dims &count=adios2::Dims())
Definition ADIOS2Writers.h:116
void vtx_write_mesh(adios2::IO &io, adios2::Engine &engine, const mesh::Mesh< T > &mesh)
Definition ADIOS2Writers.h:295
adios2::Attribute< T > define_attribute(adios2::IO &io, std::string name, const T &value, std::string var_name="", std::string separator="/")
Definition ADIOS2Writers.h:103
constexpr std::array field_ext
Definition ADIOS2Writers.h:98
void vtx_write_data(adios2::IO &io, adios2::Engine &engine, const fem::Function< T, X > &u)
Definition ADIOS2Writers.h:227
std::tuple< std::vector< std::string >, std::vector< std::string > > extract_function_names(const typename adios2_writer::U< T > &u)
Extract name of functions and split into real and imaginary component.
Definition ADIOS2Writers.h:173
Degree-of-freedom map representations and tools.
This class represents a finite element function space defined by a mesh, a finite element,...
Definition FunctionSpace.h:34
std::shared_ptr< const mesh::Mesh< geometry_type > > mesh() const
The mesh.
Definition FunctionSpace.h:360
Definition Function.h:47
std::shared_ptr< const FunctionSpace< geometry_type > > function_space() const
Access the function space.
Definition Function.h:147
std::string name
Name.
Definition Function.h:745
std::shared_ptr< const la::Vector< value_type > > x() const
Underlying vector (const version).
Definition Function.h:153
void close()
Close the file.
Definition ADIOS2Writers.cpp:32
Geometry stores the geometry imposed on a mesh.
Definition Geometry.h:34
A Mesh consists of a set of connected and numbered mesh topological entities, and geometry data.
Definition Mesh.h:23
Finite element method functionality.
Definition assemble_expression_impl.h:23
Geometry data structures and algorithms.
Definition BoundingBoxTree.h:22
Functions for the re-ordering of input mesh topology to the DOLFINx ordering, and transpose orderings...
Definition cells.h:119
std::int8_t get_vtk_cell_type(mesh::CellType cell, int dim)
Get VTK cell identifier.
Definition cells.cpp:715
Support for file IO.
Definition ADIOS2Writers.h:43
std::tuple< std::vector< T >, std::array< std::size_t, 2 >, std::vector< std::int64_t >, std::vector< std::uint8_t >, std::vector< std::int64_t >, std::array< std::size_t, 2 > > vtk_mesh_from_space(const fem::FunctionSpace< T > &V)
Given a FunctionSpace, create a topology and geometry based on the dof coordinates.
Definition vtk_utils.h:196
std::pair< std::vector< std::int64_t >, std::array< std::size_t, 2 > > extract_vtk_connectivity(md::mdspan< const std::int32_t, md::dextents< std::size_t, 2 > > dofmap_x, mesh::CellType cell_type)
Extract the cell topology (connectivity) in VTK ordering for all cells the mesh. The 'topology' inclu...
Definition vtk_utils.cpp:23
Mesh data structures and algorithms on meshes.
Definition DofMap.h:32