Theseus
Compressible flow solver
Loading...
Searching...
No Matches
AxisymmetryConfig.hpp
Go to the documentation of this file.
1// Copyright (c) 2025-2026 Board of Trustees of the University of Illinois
2//
3// This file is part of Theseus.
4//
5// SPDX-License-Identifier: BSD-3-Clause
6#pragma once
7
9#include "json.hpp"
10#include "mfem.hpp"
11
12#include <cmath>
13#include <stdexcept>
14#include <string>
15
16namespace Theseus
17{
20 {
24 static constexpr int conservative_equations = 4;
25
26 static void Validate(const nlohmann::json &config,
27 const nlohmann::json &runtime,
28 bool axisymmetric_build)
29 {
30 if (config.contains("compileTime") &&
31 config["compileTime"].contains("AXISYMMETRIC"))
32 {
33 const bool requested =
34 config["compileTime"]["AXISYMMETRIC"].get<bool>();
35 if (requested != axisymmetric_build)
36 {
37 throw std::invalid_argument(
38 std::string("compileTime.AXISYMMETRIC requests ") +
39 (requested ? "an axisymmetric" : "a Cartesian") +
40 " executable, but this executable was built " +
41 (axisymmetric_build ? "with" : "without") +
42 " AXISYMMETRIC");
43 }
44 }
45
46 if (!axisymmetric_build)
47 {
48 return;
49 }
50
51 const int dim = runtime.value("dim", spatial_dimension);
52 if (dim != spatial_dimension)
53 {
54 throw std::invalid_argument(
55 "axisymmetric simulations require runTime.dim = 2");
56 }
57
58 const int num_equations =
59 runtime.value("num_equations", conservative_equations);
60 if (num_equations != conservative_equations)
61 {
62 throw std::invalid_argument(
63 "swirl-free axisymmetric simulations require "
64 "runTime.num_equations = 4");
65 }
66 }
67
68 static void ValidateMesh(const mfem::Mesh &mesh)
69 {
70 if (mesh.Dimension() != spatial_dimension ||
71 mesh.SpaceDimension() != spatial_dimension)
72 {
73 throw std::invalid_argument(
74 "axisymmetric meshes must have topological and spatial dimension 2");
75 }
76
77 for (int vertex = 0; vertex < mesh.GetNV(); ++vertex)
78 {
79 const mfem::real_t radius = mesh.GetVertex(vertex)[radial_coordinate];
80 if (!std::isfinite(radius) ||
82 {
83 throw std::invalid_argument(
84 "axisymmetric mesh has a negative radial coordinate at vertex " +
85 std::to_string(vertex) + ": r = " + std::to_string(radius));
86 }
87 }
88 }
89 };
90}
Definition AxisymmetricGeometry.hpp:15
static constexpr mfem::real_t radius_tolerance
Definition AxisymmetricGeometry.hpp:22
static constexpr int axial_coordinate
Definition AxisymmetricGeometry.hpp:19
static constexpr int radial_coordinate
Definition AxisymmetricGeometry.hpp:20
static constexpr int spatial_dimension
Definition AxisymmetricGeometry.hpp:21
Foundational state and coordinate contract for swirl-free axisymmetry.
Definition AxisymmetryConfig.hpp:20
static constexpr int spatial_dimension
Definition AxisymmetryConfig.hpp:23
static void ValidateMesh(const mfem::Mesh &mesh)
Definition AxisymmetryConfig.hpp:68
static constexpr int axial_coordinate
Definition AxisymmetryConfig.hpp:21
static constexpr int conservative_equations
Definition AxisymmetryConfig.hpp:24
static constexpr int radial_coordinate
Definition AxisymmetryConfig.hpp:22
static void Validate(const nlohmann::json &config, const nlohmann::json &runtime, bool axisymmetric_build)
Definition AxisymmetryConfig.hpp:26