Convert a shape to the XDMF string description (Scalar, Vector, Tensor).
| 29 | /// Convert a shape to the XDMF string description (Scalar, Vector, |
| 30 | /// Tensor). |
| 31 | std::string shape_to_string(std::span<const std::size_t> shape) |
| 32 | { |
| 33 | if (shape.empty()) |
| 34 | return "Scalar"; |
| 35 | else if (shape.size() == 1 and shape[0] == 1) |
| 36 | return "Scalar"; |
| 37 | else if (shape.size() == 1) |
| 38 | return "Vector"; |
| 39 | else if (shape.size() == 2) |
| 40 | return "Tensor"; |
| 41 | else |
| 42 | throw std::runtime_error("Unsupported value shape"); |
| 43 | } |
| 44 | } // namespace |
| 45 | |
| 46 | //----------------------------------------------------------------------------- |