use crate::mesh::QuadMeshView2d;
use crate::physics::solenoid_stress::types::{Real, Structural2dFormulation};
pub use crate::mesh::{FaceSample, VolumeSample};
pub(crate) fn validate_axisymmetric_nodes<F: Real, const NODES_PER_ELEMENT: usize>(
mesh: QuadMeshView2d<'_, F, NODES_PER_ELEMENT>,
) -> Result<(), String> {
for (index, node) in mesh.nodes_rz.iter().enumerate() {
if node[0] < F::zero() {
return Err(format!(
"node {index} has negative radius {:?}; axisymmetric radius must be nonnegative",
node[0]
));
}
}
Ok(())
}
pub(crate) fn validate_axisymmetric_mesh<F: Real, const NODES_PER_ELEMENT: usize>(
mesh: QuadMeshView2d<'_, F, NODES_PER_ELEMENT>,
) -> Result<(), String> {
validate_axisymmetric_nodes(mesh)?;
mesh.validate_connectivity()
}
pub(crate) fn validate_structural_2d_mesh<F: Real, const NODES_PER_ELEMENT: usize>(
mesh: QuadMeshView2d<'_, F, NODES_PER_ELEMENT>,
formulation: Structural2dFormulation<F>,
) -> Result<(), String> {
match formulation {
Structural2dFormulation::Axisymmetric => validate_axisymmetric_mesh(mesh),
Structural2dFormulation::PlaneStrain { thickness } => {
if thickness <= F::zero() {
return Err(format!(
"plane-strain thickness must be positive; got {thickness:?}"
));
}
mesh.validate_connectivity()
}
}
}