conspire/geometry/mesh/write/
mod.rs1#[cfg(test)]
2mod test;
3
4pub mod abaqus;
5#[cfg(feature = "netcdf")]
6pub mod exodus;
7pub mod medit;
8pub mod vtk;
9
10use crate::{geometry::mesh::Mesh, io::Write};
11use std::{io::Error as ErrorIO, path::Path};
12
13use self::abaqus::WriteAbaqus;
14#[cfg(feature = "netcdf")]
15use self::exodus::WriteExodus;
16use self::medit::WriteMedit;
17use self::vtk::{multi_block::WriteVtkMultiBlock, unstructured::WriteVtkUnstructured};
18
19pub enum Output<P>
20where
21 P: AsRef<Path>,
22{
23 Abaqus(P),
24 #[cfg(feature = "netcdf")]
25 Exodus(P),
26 Medit(P),
27 VtkUnstructured(P),
28 VtkMultiBlock(P),
29}
30
31impl<P> AsRef<Path> for Output<P>
32where
33 P: AsRef<Path>,
34{
35 fn as_ref(&self) -> &Path {
36 match self {
37 Output::Abaqus(path) => path.as_ref(),
38 #[cfg(feature = "netcdf")]
39 Output::Exodus(path) => path.as_ref(),
40 Output::Medit(path) => path.as_ref(),
41 Output::VtkUnstructured(path) => path.as_ref(),
42 Output::VtkMultiBlock(path) => path.as_ref(),
43 }
44 }
45}
46
47impl<const D: usize, P> Write<Output<P>> for Mesh<D>
48where
49 P: AsRef<Path>,
50{
51 type Error = ErrorIO;
52 fn write(&self, output: Output<P>) -> Result<(), Self::Error> {
53 match output {
54 Output::Abaqus(path) => self.write_abaqus(path)?,
55 #[cfg(feature = "netcdf")]
56 Output::Exodus(path) => self.write_exodus(path)?,
57 Output::Medit(path) => self.write_medit(path)?,
58 Output::VtkUnstructured(path) => self.write_vtk_unstructured(path)?,
59 Output::VtkMultiBlock(path) => self.write_vtk_multi_block(path)?,
60 }
61 Ok(())
62 }
63}