1pub mod bundle;
7pub mod cgns;
8pub mod exodus;
9pub mod fluent;
10pub mod gmsh;
11pub mod hdf5;
12pub mod partitioned;
13pub mod petsc_hdf5;
14pub mod ply;
15pub mod vtk;
16pub mod xdmf;
17
18use crate::data::coordinates::Coordinates;
19use crate::data::discretization::Discretization;
20use crate::data::mixed_section::MixedSectionStore;
21use crate::data::section::Section;
22use crate::data::storage::Storage;
23use crate::mesh_error::MeshSieveError;
24use crate::topology::cell_type::CellType;
25use crate::topology::labels::LabelSet;
26use crate::topology::sieve::Sieve;
27use std::collections::BTreeMap;
28use std::io::{Read, Write};
29
30pub use bundle::MeshBundle;
31pub use partitioned::{
32 GatherPolicy, NeighborLinks, OverlapLink, OverlapMetadata, PartitionedMeshData,
33 PartitionedMeshMetadata, PartitionedMeshWriteOutcome, read_partitioned_mesh,
34 write_local_piece_with_metadata, write_partitioned_mesh,
35};
36
37#[derive(Debug)]
39pub struct MeshData<S, V, St, CtSt>
40where
41 St: Storage<V>,
42 CtSt: Storage<CellType>,
43{
44 pub sieve: S,
46 pub coordinates: Option<Coordinates<V, St>>,
48 pub sections: BTreeMap<String, Section<V, St>>,
50 pub mixed_sections: MixedSectionStore,
52 pub labels: Option<LabelSet>,
54 pub cell_types: Option<Section<CellType, CtSt>>,
56 pub discretization: Option<Discretization>,
58}
59
60impl<S, V, St, CtSt> MeshData<S, V, St, CtSt>
61where
62 St: Storage<V>,
63 CtSt: Storage<CellType>,
64{
65 pub fn new(sieve: S) -> Self {
67 Self {
68 sieve,
69 coordinates: None,
70 sections: BTreeMap::new(),
71 mixed_sections: MixedSectionStore::default(),
72 labels: None,
73 cell_types: None,
74 discretization: None,
75 }
76 }
77}
78
79pub trait SieveSectionReader {
81 type Sieve: Sieve;
83 type Value;
85 type Storage: Storage<Self::Value>;
87 type CellStorage: Storage<CellType>;
89
90 fn read<R: Read>(
92 &self,
93 reader: R,
94 ) -> Result<MeshData<Self::Sieve, Self::Value, Self::Storage, Self::CellStorage>, MeshSieveError>;
95}
96
97pub trait SieveSectionWriter {
99 type Sieve: Sieve;
101 type Value;
103 type Storage: Storage<Self::Value>;
105 type CellStorage: Storage<CellType>;
107
108 fn write<W: Write>(
110 &self,
111 writer: W,
112 mesh: &MeshData<Self::Sieve, Self::Value, Self::Storage, Self::CellStorage>,
113 ) -> Result<(), MeshSieveError>;
114}