From 242a3ef9355b0f3d94cbba1338289eaa5d2e6073 Mon Sep 17 00:00:00 2001 From: Nathaniel Morgan Date: Fri, 17 Jan 2025 15:12:22 -0700 Subject: [PATCH 1/4] refactoring BCs: each solver only uses the specified bdysets from the input --- .../input-impact-erosion.yaml | 8 +- single-node-refactor/input-lattice.yaml | 12 +- single-node-refactor/input-noh-rz.yaml | 8 +- single-node-refactor/input-noh.yaml | 12 +- .../input-origin-erosion.yaml | 12 +- single-node-refactor/input-rz-polar.yaml | 16 +-- single-node-refactor/input-rz.yaml | 8 +- single-node-refactor/input-sgtm-test.yaml | 6 +- single-node-refactor/input.yaml | 13 +- .../standard_inputs/Abaqus_read.yaml | 20 +-- .../standard_inputs/Sedov.yaml | 12 +- .../standard_inputs/Sedov_Erosion.yaml | 12 +- .../standard_inputs/Sedov_Read_Ensight.yaml | 12 +- .../standard_inputs/Sedov_rz_polar.yaml | 12 +- .../standard_inputs/Sod_X.yaml | 24 ++-- .../standard_inputs/Sod_Y.yaml | 24 ++-- .../standard_inputs/Sod_Z.yaml | 24 ++-- .../SGH_solver_3D/include/sgh_solver_3D.h | 4 +- .../Solvers/SGH_solver_3D/src/boundary.cpp | 12 +- .../Solvers/SGH_solver_3D/src/sgh_execute.cpp | 6 +- .../SGH_solver_rz/include/sgh_solver_rz.h | 4 +- .../Solvers/SGH_solver_rz/src/boundary_rz.cpp | 11 +- .../SGH_solver_rz/src/sgh_execute_rz.cpp | 4 +- .../SGH_solver_rz/src/sgh_initialize_rz.cpp | 2 + .../src/common/include/boundary_conditions.h | 43 +++--- single-node-refactor/src/driver.cpp | 8 +- single-node-refactor/src/input/parse_yaml.cpp | 125 +++++++++++------- single-node-refactor/src/input/parse_yaml.h | 2 +- 28 files changed, 259 insertions(+), 197 deletions(-) diff --git a/single-node-refactor/input-impact-erosion.yaml b/single-node-refactor/input-impact-erosion.yaml index 55f79d5bb..a9ea4e8ad 100644 --- a/single-node-refactor/input-impact-erosion.yaml +++ b/single-node-refactor/input-impact-erosion.yaml @@ -39,19 +39,19 @@ boundary_conditions: # Tag Y plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: y_plane direction: y_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag z plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: z_plane direction: z_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity materials: diff --git a/single-node-refactor/input-lattice.yaml b/single-node-refactor/input-lattice.yaml index 9fec12ee8..cd9d671a0 100644 --- a/single-node-refactor/input-lattice.yaml +++ b/single-node-refactor/input-lattice.yaml @@ -34,28 +34,28 @@ solver_options: boundary_conditions: # Tag X plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: x_plane direction: x_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag Y plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: y_plane direction: y_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag z plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: z_plane direction: z_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity materials: - material: diff --git a/single-node-refactor/input-noh-rz.yaml b/single-node-refactor/input-noh-rz.yaml index b2c2be570..43e18f044 100644 --- a/single-node-refactor/input-noh-rz.yaml +++ b/single-node-refactor/input-noh-rz.yaml @@ -38,20 +38,20 @@ solver_options: boundary_conditions: # Tag X plane - boundary_condition: - solver: SGHRZ + solver_id: 0 geometry: x_plane direction: x_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag Y plane - boundary_condition: - solver: SGHRZ + solver_id: 0 geometry: y_plane direction: y_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity diff --git a/single-node-refactor/input-noh.yaml b/single-node-refactor/input-noh.yaml index e07a29ef8..26b324724 100644 --- a/single-node-refactor/input-noh.yaml +++ b/single-node-refactor/input-noh.yaml @@ -38,28 +38,28 @@ solver_options: boundary_conditions: # Tag X plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: x_plane direction: x_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag Y plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: y_plane direction: y_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag z plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: z_plane direction: z_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity diff --git a/single-node-refactor/input-origin-erosion.yaml b/single-node-refactor/input-origin-erosion.yaml index 92d1f669e..6d0e04c02 100644 --- a/single-node-refactor/input-origin-erosion.yaml +++ b/single-node-refactor/input-origin-erosion.yaml @@ -38,31 +38,31 @@ solver_options: boundary_conditions: # Tag X plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: x_plane direction: x_dir value: 0.0 u: 0.0 v: 0.0 w: 1.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag Y plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: y_plane direction: y_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag z plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: z_plane direction: z_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity materials: - material: diff --git a/single-node-refactor/input-rz-polar.yaml b/single-node-refactor/input-rz-polar.yaml index 30339f376..255dff05d 100644 --- a/single-node-refactor/input-rz-polar.yaml +++ b/single-node-refactor/input-rz-polar.yaml @@ -43,34 +43,34 @@ solver_options: boundary_conditions: # Tag X plane - boundary_condition: - solver: SGHRZ + solver_id: 0 geometry: x_plane direction: x_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag Y plane - boundary_condition: - solver: SGHRZ + solver_id: 0 geometry: y_plane direction: y_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag inner circle - boundary_condition: - solver: SGHRZ + solver_id: 0 geometry: cylinder value: 0.025 - type: zero_velocity + velocity_model: zero_velocity # Tag outer circle - boundary_condition: - solver: SGHRZ + solver_id: 0 geometry: cylinder value: 1.2 - type: zero_velocity + velocity_model: zero_velocity materials: - material: diff --git a/single-node-refactor/input-rz.yaml b/single-node-refactor/input-rz.yaml index e91f3c129..220e4a3ea 100644 --- a/single-node-refactor/input-rz.yaml +++ b/single-node-refactor/input-rz.yaml @@ -38,20 +38,20 @@ solver_options: boundary_conditions: # Tag X plane - boundary_condition: - solver: SGHRZ + solver_id: 0 geometry: x_plane direction: x_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag Y plane - boundary_condition: - solver: SGHRZ + solver_id: 0 geometry: y_plane direction: y_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity diff --git a/single-node-refactor/input-sgtm-test.yaml b/single-node-refactor/input-sgtm-test.yaml index 66134885f..43f7ebed8 100644 --- a/single-node-refactor/input-sgtm-test.yaml +++ b/single-node-refactor/input-sgtm-test.yaml @@ -42,7 +42,7 @@ solver_options: # geometry: x_plane # direction: x_dir # value: 0.0 -# type: reflected_velocity +# velocity_model: reflected_velocity # # Tag Y plane @@ -51,7 +51,7 @@ solver_options: # geometry: y_plane # direction: y_dir # value: 0.0 -# type: reflected_velocity +# velocity_model: reflected_velocity # # Tag z plane # - boundary_condition: @@ -59,7 +59,7 @@ solver_options: # geometry: z_plane # direction: z_dir # value: 0.0 -# type: reflected_velocity +# velocity_model: reflected_velocity diff --git a/single-node-refactor/input.yaml b/single-node-refactor/input.yaml index 4c191142e..673651e66 100644 --- a/single-node-refactor/input.yaml +++ b/single-node-refactor/input.yaml @@ -30,6 +30,7 @@ output_options: solver_options: - solver: method: SGH3D + #id: 0 # solver_vars: # - blah # - blah @@ -38,28 +39,28 @@ solver_options: boundary_conditions: # Tag X plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: x_plane direction: x_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag Y plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: y_plane direction: y_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag z plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: z_plane direction: z_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity diff --git a/single-node-refactor/regression_tests/standard_inputs/Abaqus_read.yaml b/single-node-refactor/regression_tests/standard_inputs/Abaqus_read.yaml index f70f65a41..f33f2e5d8 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Abaqus_read.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Abaqus_read.yaml @@ -37,42 +37,42 @@ solver_options: boundary_conditions: # Tag X plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: x_plane direction: x_dir value: -4.0 - type: reflected_velocity + velocity_model: reflected_velocity - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: x_plane direction: x_dir value: 4.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag Y plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: y_plane direction: y_dir value: -4.0 - type: reflected_velocity + velocity_model: reflected_velocity - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: y_plane direction: y_dir value: 4.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag z plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: z_plane direction: z_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity diff --git a/single-node-refactor/regression_tests/standard_inputs/Sedov.yaml b/single-node-refactor/regression_tests/standard_inputs/Sedov.yaml index 7f5389f52..ed8ae38ad 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sedov.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sedov.yaml @@ -28,28 +28,28 @@ solver_options: boundary_conditions: # Tag X plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: x_plane direction: x_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag Y plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: y_plane direction: y_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag z plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: z_plane direction: z_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity materials: - material: diff --git a/single-node-refactor/regression_tests/standard_inputs/Sedov_Erosion.yaml b/single-node-refactor/regression_tests/standard_inputs/Sedov_Erosion.yaml index 85b54ebc7..e37dc1a52 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sedov_Erosion.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sedov_Erosion.yaml @@ -38,31 +38,31 @@ solver_options: boundary_conditions: # Tag X plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: x_plane direction: x_dir value: 0.0 u: 0.0 v: 0.0 w: 1.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag Y plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: y_plane direction: y_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag z plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: z_plane direction: z_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity materials: - material: diff --git a/single-node-refactor/regression_tests/standard_inputs/Sedov_Read_Ensight.yaml b/single-node-refactor/regression_tests/standard_inputs/Sedov_Read_Ensight.yaml index dae206ae7..460bf45bd 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sedov_Read_Ensight.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sedov_Read_Ensight.yaml @@ -25,28 +25,28 @@ solver_options: boundary_conditions: # Tag X plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: x_plane direction: x_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag Y plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: y_plane direction: y_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag z plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: z_plane direction: z_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity materials: - material: diff --git a/single-node-refactor/regression_tests/standard_inputs/Sedov_rz_polar.yaml b/single-node-refactor/regression_tests/standard_inputs/Sedov_rz_polar.yaml index 6f143c051..07270f73c 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sedov_rz_polar.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sedov_rz_polar.yaml @@ -43,27 +43,27 @@ solver_options: boundary_conditions: # Tag X plane - boundary_condition: - solver: SGHRZ + solver_id: 0 geometry: x_plane direction: x_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag Y plane - boundary_condition: - solver: SGHRZ + solver_id: 0 geometry: y_plane direction: y_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag inner circle - boundary_condition: - solver: SGHRZ + solver_id: 0 geometry: cylinder value: 0.025 - type: zero_velocity + velocity_model: zero_velocity diff --git a/single-node-refactor/regression_tests/standard_inputs/Sod_X.yaml b/single-node-refactor/regression_tests/standard_inputs/Sod_X.yaml index e9a8ded81..fd31847b9 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sod_X.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sod_X.yaml @@ -27,54 +27,54 @@ solver_options: boundary_conditions: # Tag X=0 plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: x_plane direction: x_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag Y=0 plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: y_plane direction: y_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag z=0 plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: z_plane direction: z_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag X=1 plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: x_plane direction: x_dir value: 1.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag Y=0.01 plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: y_plane direction: y_dir value: 0.01 - type: reflected_velocity + velocity_model: reflected_velocity # Tag z=0.01 plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: z_plane direction: z_dir value: 0.01 - type: reflected_velocity + velocity_model: reflected_velocity materials: diff --git a/single-node-refactor/regression_tests/standard_inputs/Sod_Y.yaml b/single-node-refactor/regression_tests/standard_inputs/Sod_Y.yaml index c90f4f6a5..7f71f8b7d 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sod_Y.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sod_Y.yaml @@ -27,54 +27,54 @@ solver_options: boundary_conditions: # Tag X=0 plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: x_plane direction: x_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag Y=0 plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: y_plane direction: y_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag z=0 plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: z_plane direction: z_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag X=0.01 plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: x_plane direction: x_dir value: 0.01 - type: reflected_velocity + velocity_model: reflected_velocity # Tag Y=1.0 plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: y_plane direction: y_dir value: 1.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag z=0.01 plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: z_plane direction: z_dir value: 0.01 - type: reflected_velocity + velocity_model: reflected_velocity materials: diff --git a/single-node-refactor/regression_tests/standard_inputs/Sod_Z.yaml b/single-node-refactor/regression_tests/standard_inputs/Sod_Z.yaml index a9c079fcb..91bd1f69b 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sod_Z.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sod_Z.yaml @@ -27,54 +27,54 @@ solver_options: boundary_conditions: # Tag X=0 plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: x_plane direction: x_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag Y=0 plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: y_plane direction: y_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag z=0 plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: z_plane direction: z_dir value: 0.0 - type: reflected_velocity + velocity_model: reflected_velocity # Tag X=0.01 plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: x_plane direction: x_dir value: 0.01 - type: reflected_velocity + velocity_model: reflected_velocity # Tag Y=0.01 plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: y_plane direction: y_dir value: 0.01 - type: reflected_velocity + velocity_model: reflected_velocity # Tag z=1.0 plane - boundary_condition: - solver: SGH3D + solver_id: 0 geometry: z_plane direction: z_dir value: 1.0 - type: reflected_velocity + velocity_model: reflected_velocity materials: diff --git a/single-node-refactor/src/Solvers/SGH_solver_3D/include/sgh_solver_3D.h b/single-node-refactor/src/Solvers/SGH_solver_3D/include/sgh_solver_3D.h index 62a23d289..0ee9fd6df 100644 --- a/single-node-refactor/src/Solvers/SGH_solver_3D/include/sgh_solver_3D.h +++ b/single-node-refactor/src/Solvers/SGH_solver_3D/include/sgh_solver_3D.h @@ -111,6 +111,7 @@ namespace SGH3D_State class SGH3D : public Solver { public: + size_t solver_id; SGH3D() : Solver() { @@ -202,7 +203,8 @@ class SGH3D : public Solver const Mesh_t& mesh, const BoundaryCondition_t& Boundary, DCArrayKokkos& node_vel, - const double time_value) const; + const double time_value, + const size_t solver_id) const; void boundary_contact( const Mesh_t& mesh, diff --git a/single-node-refactor/src/Solvers/SGH_solver_3D/src/boundary.cpp b/single-node-refactor/src/Solvers/SGH_solver_3D/src/boundary.cpp index c900c9321..dc7ae96d7 100644 --- a/single-node-refactor/src/Solvers/SGH_solver_3D/src/boundary.cpp +++ b/single-node-refactor/src/Solvers/SGH_solver_3D/src/boundary.cpp @@ -51,10 +51,16 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. void SGH3D::boundary_velocity(const Mesh_t& mesh, const BoundaryCondition_t& BoundaryConditions, DCArrayKokkos& node_vel, - const double time_value) const + const double time_value, + const size_t solver_id) const { - // Loop over boundary sets - for (size_t bdy_set = 0; bdy_set < mesh.num_bdy_sets; bdy_set++) { + size_t num_vel_bdy_sets = BoundaryConditions.num_vel_bdy_sets_in_solver.host(solver_id); + + // Loop over the velocity boundary sets + for (size_t bc_lid = 0; bc_lid < num_vel_bdy_sets; bc_lid++) { + + size_t bdy_set = BoundaryConditions.vel_bdy_sets_in_solver.host(bc_lid); + // Loop over boundary nodes in a boundary set FOR_ALL(bdy_node_lid, 0, mesh.num_bdy_nodes_in_set.host(bdy_set), { // get the global index for this node on the boundary diff --git a/single-node-refactor/src/Solvers/SGH_solver_3D/src/sgh_execute.cpp b/single-node-refactor/src/Solvers/SGH_solver_3D/src/sgh_execute.cpp index f6e4a04d6..a8146da8d 100644 --- a/single-node-refactor/src/Solvers/SGH_solver_3D/src/sgh_execute.cpp +++ b/single-node-refactor/src/Solvers/SGH_solver_3D/src/sgh_execute.cpp @@ -57,6 +57,7 @@ void SGH3D::execute(SimulationParameters_t& SimulationParamaters, { std::cout << "In execute function in SGH3D solver" << std::endl; + double fuzz = SimulationParamaters.dynamic_options.fuzz; // double tiny = SimulationParamaters.dynamic_options.tiny; double small = SimulationParamaters.dynamic_options.small; @@ -87,7 +88,7 @@ void SGH3D::execute(SimulationParameters_t& SimulationParamaters, double graphics_time = 0.0; // the times for writing graphics dump std::cout << "Applying initial boundary conditions" << std::endl; - boundary_velocity(mesh, BoundaryConditions, State.node.vel, time_value); // Time value = 0.0; + boundary_velocity(mesh, BoundaryConditions, State.node.vel, time_value, this->solver_id); // Time value = 0.0; // extensive energy tallies over the entire mesh double IE_t0 = 0.0; @@ -297,7 +298,6 @@ void SGH3D::execute(SimulationParameters_t& SimulationParamaters, } // end for mat_id - // ---- Update nodal velocities ---- // update_velocity(rk_alpha, dt, @@ -307,7 +307,7 @@ void SGH3D::execute(SimulationParameters_t& SimulationParamaters, State.corner.force); // ---- apply velocity boundary conditions to the boundary patches---- - boundary_velocity(mesh, BoundaryConditions, State.node.vel, time_value); + boundary_velocity(mesh, BoundaryConditions, State.node.vel, time_value, this->solver_id); // ---- apply contact boundary conditions to the boundary patches---- boundary_contact(mesh, BoundaryConditions, State.node.vel, time_value); diff --git a/single-node-refactor/src/Solvers/SGH_solver_rz/include/sgh_solver_rz.h b/single-node-refactor/src/Solvers/SGH_solver_rz/include/sgh_solver_rz.h index c72a0d310..b42a11f13 100644 --- a/single-node-refactor/src/Solvers/SGH_solver_rz/include/sgh_solver_rz.h +++ b/single-node-refactor/src/Solvers/SGH_solver_rz/include/sgh_solver_rz.h @@ -112,6 +112,7 @@ namespace SGHRZ_State class SGHRZ : public Solver { public: + size_t solver_id; SGHRZ() : Solver() { @@ -209,7 +210,8 @@ class SGHRZ : public Solver const Mesh_t& mesh, const BoundaryCondition_t& Boundary, DCArrayKokkos& node_vel, - const double time_value) const; + const double time_value, + const size_t solver_id) const; void boundary_contact_rz( const Mesh_t& mesh, diff --git a/single-node-refactor/src/Solvers/SGH_solver_rz/src/boundary_rz.cpp b/single-node-refactor/src/Solvers/SGH_solver_rz/src/boundary_rz.cpp index 54241c915..7b438ba7c 100644 --- a/single-node-refactor/src/Solvers/SGH_solver_rz/src/boundary_rz.cpp +++ b/single-node-refactor/src/Solvers/SGH_solver_rz/src/boundary_rz.cpp @@ -52,11 +52,16 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. void SGHRZ::boundary_velocity_rz(const Mesh_t& mesh, const BoundaryCondition_t& BoundaryConditions, DCArrayKokkos& node_vel, - const double time_value) const + const double time_value, + const size_t solver_id) const { - // Loop over boundary sets - for (size_t bdy_set = 0; bdy_set < mesh.num_bdy_sets; bdy_set++) { + size_t num_vel_bdy_sets = BoundaryConditions.num_vel_bdy_sets_in_solver.host(solver_id); + + // Loop over the velocity boundary sets + for (size_t bc_lid = 0; bc_lid < num_vel_bdy_sets; bc_lid++) { + + size_t bdy_set = BoundaryConditions.vel_bdy_sets_in_solver.host(bc_lid); // Loop over boundary nodes in a boundary set FOR_ALL(bdy_node_lid, 0, mesh.num_bdy_nodes_in_set.host(bdy_set), { diff --git a/single-node-refactor/src/Solvers/SGH_solver_rz/src/sgh_execute_rz.cpp b/single-node-refactor/src/Solvers/SGH_solver_rz/src/sgh_execute_rz.cpp index ce692ae27..6e3cf2c17 100644 --- a/single-node-refactor/src/Solvers/SGH_solver_rz/src/sgh_execute_rz.cpp +++ b/single-node-refactor/src/Solvers/SGH_solver_rz/src/sgh_execute_rz.cpp @@ -98,7 +98,7 @@ void SGHRZ::execute(SimulationParameters_t& SimulationParamaters, std::cout << "Applying initial boundary conditions" << std::endl; - boundary_velocity_rz(mesh, BoundaryConditions, State.node.vel, time_value); // Time value = 0.0; + boundary_velocity_rz(mesh, BoundaryConditions, State.node.vel, time_value, this->solver_id); // Time value = 0.0; @@ -325,7 +325,7 @@ void SGHRZ::execute(SimulationParameters_t& SimulationParamaters, State.corner.force); // ---- apply velocity boundary conditions to the boundary patches---- - boundary_velocity_rz(mesh, BoundaryConditions, State.node.vel, time_value); + boundary_velocity_rz(mesh, BoundaryConditions, State.node.vel, time_value, this->solver_id); // ---- apply contact boundary conditions to the boundary patches---- //boundary_contact(mesh, BoundaryConditions, State.node.vel, time_value); diff --git a/single-node-refactor/src/Solvers/SGH_solver_rz/src/sgh_initialize_rz.cpp b/single-node-refactor/src/Solvers/SGH_solver_rz/src/sgh_initialize_rz.cpp index ed9aee3a0..0e42c53a2 100644 --- a/single-node-refactor/src/Solvers/SGH_solver_rz/src/sgh_initialize_rz.cpp +++ b/single-node-refactor/src/Solvers/SGH_solver_rz/src/sgh_initialize_rz.cpp @@ -49,6 +49,8 @@ void SGHRZ::initialize(SimulationParameters_t& SimulationParamaters, int rk_num_bins = SimulationParamaters.dynamic_options.rk_num_stages; int num_dim = mesh.num_dims; + // save the solver_id, which is a pravate class variable + //this->solver_id = solver_id_inp; State.node.initialize(rk_num_bins, num_nodes, num_dim, SGHRZ_State::required_node_state); State.GaussPoints.initialize(rk_num_bins, num_gauss_pts, 3, SGHRZ_State::required_gauss_pt_state); // note: dims is always 3 diff --git a/single-node-refactor/src/common/include/boundary_conditions.h b/single-node-refactor/src/common/include/boundary_conditions.h index 2f9d25aa3..21cfc04d4 100644 --- a/single-node-refactor/src/common/include/boundary_conditions.h +++ b/single-node-refactor/src/common/include/boundary_conditions.h @@ -58,7 +58,7 @@ enum BdyTag // types of boundary conditions // WARNING: Currently only velocity is supported -enum BCHydro +enum BCVelocityModels { noVelocityBC = 0, constantVelocityBC = 1, @@ -68,12 +68,13 @@ enum BCHydro userDefinedVelocityBC = 5, pistonVelocityBC = 6 }; -// future options: -// displacement = 6, -// acceleration = 7, -// pressure = 8, -// temperature = 9, -// contact = 10 +// future model options: +// displacementBC = 6, +// accelerationBC = 7, +// pressureBC = 8, +// temperatureBC = 9, +// contactBC = 10 + enum BCFcnLocation { @@ -101,7 +102,7 @@ static std::map bc_geometry_map // future options // { "read_file", boundary_conditions::read_file } -static std::map bc_type_map +static std::map bc_velocity_model_map { { "no_velocity", boundary_conditions::noVelocityBC }, { "constant_velocity", boundary_conditions::constantVelocityBC }, @@ -112,11 +113,13 @@ static std::map bc_type_map { "piston_velocity", boundary_conditions::pistonVelocityBC } }; // future options -// { "displacement", boundary_conditions::displacement }, -// { "acceleration", boundary_conditions::acceleration }, -// { "pressure", boundary_conditions::pressure }, -// { "temperature", boundary_conditions::temperature }, -// { "contact", boundary_conditions::contact } +// { "displacement", boundary_conditions::displacementBC }, +// { "acceleration", boundary_conditions::accelerationBC }, +// { "pressure", boundary_conditions::pressureBC }, +// { "temperature", boundary_conditions::temperatureBC }, +// { "contact", boundary_conditions::contactBC } + + static std::map bc_direction_map { @@ -156,7 +159,7 @@ struct BoundaryConditionEnums_t { solver_input::method solver = solver_input::NONE; ///< Numerical solver method - boundary_conditions::BCHydro BCHydroType; ///< Type of boundary condition + boundary_conditions::BCVelocityModels BCVelocityModel = boundary_conditions::noVelocityBC; ///< Type of velocity boundary condition boundary_conditions::BCDirection Direction; ///< Boundary condition direction @@ -207,6 +210,15 @@ struct BoundaryCondition_t // enums to select BC capabilities, some enums are needed on the host side and device side DCArrayKokkos BoundaryConditionEnums; + // making a psuedo dual ragged right + DCArrayKokkos vel_bdy_sets_in_solver; // (solver, ids) + DCArrayKokkos num_vel_bdy_sets_in_solver; // (solver) + + // keep adding ragged storage for the other BC models -- temp, displacement, etc. + // DCArrayKokkos temp_bdy_sets_in_solver; // (solver, ids) + // DCArrayKokkos num_temp_bdy_sets_in_solver; // (solver) + + // global variables for boundary condition models DCArrayKokkos bc_global_vars; // it is only 4 values, so ragged doesn't make sense now @@ -220,7 +232,8 @@ struct BoundaryCondition_t static std::vector str_bc_inps { "solver", - "type", + "solver_id", + "velocity_model", "geometry", "direction", "value", diff --git a/single-node-refactor/src/driver.cpp b/single-node-refactor/src/driver.cpp index 6b8a2a212..0f2f3ab49 100644 --- a/single-node-refactor/src/driver.cpp +++ b/single-node-refactor/src/driver.cpp @@ -92,7 +92,7 @@ void Driver::initialize() mesh.build_boundry_node_sets(mesh); // Setup Solvers - for (int solver_id = 0; solver_id < SimulationParamaters.solver_inputs.size(); solver_id++) { + for (size_t solver_id = 0; solver_id < SimulationParamaters.solver_inputs.size(); solver_id++) { if (SimulationParamaters.solver_inputs[solver_id].method == solver_input::SGH3D) { @@ -104,6 +104,9 @@ void Driver::initialize() BoundaryConditions, State); + // save the solver_id + sgh_solver->solver_id = solver_id; + solvers.push_back(sgh_solver); } // end if SGH solver else if (SimulationParamaters.solver_inputs[solver_id].method == solver_input::SGHRZ) { @@ -116,6 +119,9 @@ void Driver::initialize() BoundaryConditions, State); + // save the solver_id + sgh_solver_rz->solver_id = solver_id; + solvers.push_back(sgh_solver_rz); } // end if SGHRZ solver //else if (SimulationParamaters.solver_inputs[solver_id].method == solver_input::SGTM3D) { diff --git a/single-node-refactor/src/input/parse_yaml.cpp b/single-node-refactor/src/input/parse_yaml.cpp index ef4a4421e..bc0535d3d 100644 --- a/single-node-refactor/src/input/parse_yaml.cpp +++ b/single-node-refactor/src/input/parse_yaml.cpp @@ -306,7 +306,8 @@ void parse_yaml(Yaml::Node& root, SimulationParameters_t& SimulationParamaters, printf("\n"); std::cout << "Parsing YAML boundary condition options:" << std::endl; } - parse_bcs(root, Boundary); + size_t num_solvers = SimulationParamaters.solver_inputs.size(); + parse_bcs(root, Boundary, num_solvers); if (VERBOSE) { printf("\n"); @@ -2294,7 +2295,7 @@ void parse_materials(Yaml::Node& root, Material_t& Materials, const size_t num_d // ================================================================================= // Parse Boundary Conditions // ================================================================================= -void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions) +void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions, const size_t num_solvers) { Yaml::Node& bc_yaml = root["boundary_conditions"]; @@ -2310,6 +2311,16 @@ void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions) // enums to select options with boundary conditions BoundaryConditions.BoundaryConditionEnums = DCArrayKokkos (num_bcs,"bc_enums"); + // stores the velocity bdy node lists per solver, in the future, this needs to be a DualRaggedRight + BoundaryConditions.vel_bdy_sets_in_solver = DCArrayKokkos (num_solvers, num_bcs, "vel_bdy_sets_in_solver"); + // this stores the number of bdy sets for a solver + BoundaryConditions.num_vel_bdy_sets_in_solver = DCArrayKokkos (num_solvers, "num_vel_bdy_sets_in_solver"); + // set the storage counter to zero + for(size_t solver_id=0; solver_id(num_bcs, 4, "bc_global_values"); // increase 4 for more params BoundaryConditions.bc_state_vars = DCArrayKokkos(num_bcs, 4, "bc_state_values"); // WARNING a place holder @@ -2320,12 +2331,45 @@ void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions) // read the variables names Yaml::Node& inps_yaml = bc_yaml[bc_id]["boundary_condition"]; - // get the material variables names set by the user + // get the boundary condition variables names set by the user std::vector user_str_bc_inps; // extract words from the input file and validate they are correct validate_inputs(inps_yaml, user_str_bc_inps, str_bc_inps, bc_required_inps); + + // verify the boundary condition block connects to a solver + // loop over the words in the boundary input definition and find the solver id + int solver_id = -1; + for (auto& a_word : user_str_bc_inps) { + + Yaml::Node& inps_yaml = bc_yaml[bc_id]["boundary_condition"][a_word]; + + if (a_word.compare("solver_id") == 0) { + solver_id = bc_yaml[bc_id]["boundary_condition"][a_word].As(); + + if (solver_id<0 || solver_id>=num_solvers){ + std::cout << "ERROR: invalid solver_id specified in the boundary condition definition " << std::endl; + + throw std::runtime_error("**** Solver_id is out of bounds ****"); + } // end check on m_id range + + if (VERBOSE) { + std::cout << "\tsolver_id = " << solver_id << std::endl; + } + } // end id + + // add other checks here... + + } // end loop over all boundary condition inputs + + if (solver_id<0){ + std::cout << "ERROR: solver_id must be specified in the boundary condition definition " << std::endl; + + throw std::runtime_error("**** Solver_id is missing ****"); + } // end check on m_id range + + // loop over the words in the material input definition for (auto& a_word : user_str_bc_inps) { if (VERBOSE) { @@ -2335,50 +2379,36 @@ void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions) Yaml::Node& inps_yaml = bc_yaml[bc_id]["boundary_condition"][a_word]; // get solver for this boundary condition - if (a_word.compare("solver") == 0) { - std::string solver = bc_yaml[bc_id]["boundary_condition"][a_word].As(); + if (a_word.compare("solver_id") == 0) { + // do nothing, I already have solver_id - auto map = solver_map; - - // set the solver - if (map.find(solver) != map.end()) { - solver_input::method bc_solver = map[solver]; - - RUN({ - BoundaryConditions.BoundaryConditionEnums(bc_id).solver = bc_solver; - }); + } // solver id + // get boundary condition type + else if (a_word.compare("velocity_model") == 0) { + + // Note: solver_id was retrieved at the top of the bc_id loop - if (VERBOSE) { - std::cout << "\tsolver = " << solver << std::endl; - } - } - else{ - std::cout << "ERROR: invalid boundary condition option input in YAML file: " << solver << std::endl; - std::cout << "Valid options are: " << std::endl; + // find out how many velocity bdy sets have been saved + size_t num_saved = BoundaryConditions.num_vel_bdy_sets_in_solver.host(solver_id); + BoundaryConditions.vel_bdy_sets_in_solver.host(num_saved) = bc_id; + BoundaryConditions.num_vel_bdy_sets_in_solver.host(solver_id) += 1; // increment saved counter - for (const auto& pair : map) { - std::cout << "\t" << pair.first << std::endl; - } - } // end if - } // solver - // get boundary condition type - else if (a_word.compare("type") == 0) { - std::string type = bc_yaml[bc_id]["boundary_condition"][a_word].As(); + std::string velocity_model = bc_yaml[bc_id]["boundary_condition"][a_word].As(); - auto map = bc_type_map; + auto map = bc_velocity_model_map; - // set the type - if (map.find(type) != map.end()) { - auto bc_type = map[type]; + // set the velocity_model + if (map.find(velocity_model) != map.end()) { + auto bc_velocity_model = map[velocity_model]; - // bc_type_map[type] returns enum value, e.g., boundary_conditions::velocity_constant - switch(map[type]){ + // bc_velocity_model_map[velocity_model] returns enum value, e.g., boundary_conditions::velocity_constant + switch(map[velocity_model]){ case boundary_conditions::constantVelocityBC : std::cout << "Setting velocity bc " << std::endl; RUN({ - BoundaryConditions.BoundaryConditionEnums(bc_id).BCHydroType = boundary_conditions::constantVelocityBC ; + BoundaryConditions.BoundaryConditionEnums(bc_id).BCVelocityModel = boundary_conditions::constantVelocityBC ; BoundaryConditions.BoundaryConditionFunctions(bc_id).velocity = &ConstantVelocityBC::velocity; }); break; @@ -2387,7 +2417,7 @@ void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions) std::cout << "Setting velocity bc " << std::endl; RUN({ - BoundaryConditions.BoundaryConditionEnums(bc_id).BCHydroType = boundary_conditions::timeVaringVelocityBC; + BoundaryConditions.BoundaryConditionEnums(bc_id).BCVelocityModel = boundary_conditions::timeVaringVelocityBC; BoundaryConditions.BoundaryConditionFunctions(bc_id).velocity = &TimeVaryingVelocityBC::velocity; }); break; @@ -2396,7 +2426,7 @@ void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions) std::cout << "Setting velocity bc " << std::endl; RUN({ - BoundaryConditions.BoundaryConditionEnums(bc_id).BCHydroType = boundary_conditions::reflectedVelocityBC; + BoundaryConditions.BoundaryConditionEnums(bc_id).BCVelocityModel = boundary_conditions::reflectedVelocityBC; BoundaryConditions.BoundaryConditionFunctions(bc_id).velocity = &ReflectedVelocityBC::velocity; }); break; @@ -2405,7 +2435,7 @@ void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions) std::cout << "Setting velocity bc " << std::endl; RUN({ - BoundaryConditions.BoundaryConditionEnums(bc_id).BCHydroType = boundary_conditions::zeroVelocityBC; + BoundaryConditions.BoundaryConditionEnums(bc_id).BCVelocityModel = boundary_conditions::zeroVelocityBC; BoundaryConditions.BoundaryConditionFunctions(bc_id).velocity = &ZeroVelocityBC::velocity; }); break; @@ -2413,7 +2443,7 @@ void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions) std::cout << "Setting velocity bc " << std::endl; RUN({ - BoundaryConditions.BoundaryConditionEnums(bc_id).BCHydroType = boundary_conditions::userDefinedVelocityBC; + BoundaryConditions.BoundaryConditionEnums(bc_id).BCVelocityModel = boundary_conditions::userDefinedVelocityBC; BoundaryConditions.BoundaryConditionFunctions(bc_id).velocity = &UserDefinedVelocityBC::velocity; }); break; @@ -2421,28 +2451,24 @@ void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions) std::cout << "Setting velocity bc " << std::endl; RUN({ - BoundaryConditions.BoundaryConditionEnums(bc_id).BCHydroType = boundary_conditions::pistonVelocityBC; + BoundaryConditions.BoundaryConditionEnums(bc_id).BCVelocityModel = boundary_conditions::pistonVelocityBC; BoundaryConditions.BoundaryConditionFunctions(bc_id).velocity = &UserDefinedVelocityBC::velocity; }); break; default: - std::cout << "Setting velocity bc " << std::endl; - RUN({ - BoundaryConditions.BoundaryConditionEnums(bc_id).BCHydroType = boundary_conditions::noVelocityBC; - BoundaryConditions.BoundaryConditionFunctions(bc_id).velocity = &NoVelocityBC::velocity; - }); - // no velocity specified is default + std::cout << "ERROR: invalid velocity boundary condition input: " << velocity_model << std::endl; + throw std::runtime_error("**** Velocity BC model Not Understood ****"); break; } // end switch if (VERBOSE) { - std::cout << "\ttype = " << type << std::endl; + std::cout << "\tvelocity_bc_model = " << velocity_model << std::endl; } } else{ - std::cout << "ERROR: invalid boundary condition option input in YAML file: " << type << std::endl; + std::cout << "ERROR: invalid boundary condition option input in YAML file: " << velocity_model << std::endl; std::cout << "Valid options are: " << std::endl; for (const auto& pair : map) { @@ -2475,7 +2501,6 @@ void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions) } } // end if } // direction - // get boundary condition geometry // get boundary condition direction else if (a_word.compare("direction") == 0) { std::string direction = bc_yaml[bc_id]["boundary_condition"][a_word].As(); diff --git a/single-node-refactor/src/input/parse_yaml.h b/single-node-refactor/src/input/parse_yaml.h index 079517737..807638b17 100644 --- a/single-node-refactor/src/input/parse_yaml.h +++ b/single-node-refactor/src/input/parse_yaml.h @@ -108,6 +108,6 @@ void parse_regions(Yaml::Node& root, void parse_materials(Yaml::Node& root, Material_t& Materials, const size_t num_dims); // parse the boundary condition text -void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions); +void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions, const size_t num_solvers); #endif // end Header Guard \ No newline at end of file From a67afa1eb6d4986ffc10935b2e463591b25ec0ea Mon Sep 17 00:00:00 2001 From: Nathaniel Morgan Date: Tue, 21 Jan 2025 13:25:17 -0700 Subject: [PATCH 2/4] addressed feedback to PR, made solver_id a parent variable and directly accessed it in member fcns --- .../src/Solvers/SGH_solver_3D/include/sgh_solver_3D.h | 4 +--- .../src/Solvers/SGH_solver_3D/src/boundary.cpp | 5 ++--- .../src/Solvers/SGH_solver_3D/src/sgh_execute.cpp | 4 ++-- .../src/Solvers/SGH_solver_rz/include/sgh_solver_rz.h | 4 +--- .../src/Solvers/SGH_solver_rz/src/boundary_rz.cpp | 5 ++--- .../src/Solvers/SGH_solver_rz/src/sgh_execute_rz.cpp | 4 ++-- single-node-refactor/src/common/include/state.h | 2 +- single-node-refactor/src/solver.h | 2 ++ 8 files changed, 13 insertions(+), 17 deletions(-) diff --git a/single-node-refactor/src/Solvers/SGH_solver_3D/include/sgh_solver_3D.h b/single-node-refactor/src/Solvers/SGH_solver_3D/include/sgh_solver_3D.h index 0ee9fd6df..62a23d289 100644 --- a/single-node-refactor/src/Solvers/SGH_solver_3D/include/sgh_solver_3D.h +++ b/single-node-refactor/src/Solvers/SGH_solver_3D/include/sgh_solver_3D.h @@ -111,7 +111,6 @@ namespace SGH3D_State class SGH3D : public Solver { public: - size_t solver_id; SGH3D() : Solver() { @@ -203,8 +202,7 @@ class SGH3D : public Solver const Mesh_t& mesh, const BoundaryCondition_t& Boundary, DCArrayKokkos& node_vel, - const double time_value, - const size_t solver_id) const; + const double time_value) const; void boundary_contact( const Mesh_t& mesh, diff --git a/single-node-refactor/src/Solvers/SGH_solver_3D/src/boundary.cpp b/single-node-refactor/src/Solvers/SGH_solver_3D/src/boundary.cpp index dc7ae96d7..c655c28f9 100644 --- a/single-node-refactor/src/Solvers/SGH_solver_3D/src/boundary.cpp +++ b/single-node-refactor/src/Solvers/SGH_solver_3D/src/boundary.cpp @@ -51,10 +51,9 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. void SGH3D::boundary_velocity(const Mesh_t& mesh, const BoundaryCondition_t& BoundaryConditions, DCArrayKokkos& node_vel, - const double time_value, - const size_t solver_id) const + const double time_value) const { - size_t num_vel_bdy_sets = BoundaryConditions.num_vel_bdy_sets_in_solver.host(solver_id); + size_t num_vel_bdy_sets = BoundaryConditions.num_vel_bdy_sets_in_solver.host(this->solver_id); // Loop over the velocity boundary sets for (size_t bc_lid = 0; bc_lid < num_vel_bdy_sets; bc_lid++) { diff --git a/single-node-refactor/src/Solvers/SGH_solver_3D/src/sgh_execute.cpp b/single-node-refactor/src/Solvers/SGH_solver_3D/src/sgh_execute.cpp index a8146da8d..b25f1708e 100644 --- a/single-node-refactor/src/Solvers/SGH_solver_3D/src/sgh_execute.cpp +++ b/single-node-refactor/src/Solvers/SGH_solver_3D/src/sgh_execute.cpp @@ -88,7 +88,7 @@ void SGH3D::execute(SimulationParameters_t& SimulationParamaters, double graphics_time = 0.0; // the times for writing graphics dump std::cout << "Applying initial boundary conditions" << std::endl; - boundary_velocity(mesh, BoundaryConditions, State.node.vel, time_value, this->solver_id); // Time value = 0.0; + boundary_velocity(mesh, BoundaryConditions, State.node.vel, time_value); // Time value = 0.0; // extensive energy tallies over the entire mesh double IE_t0 = 0.0; @@ -307,7 +307,7 @@ void SGH3D::execute(SimulationParameters_t& SimulationParamaters, State.corner.force); // ---- apply velocity boundary conditions to the boundary patches---- - boundary_velocity(mesh, BoundaryConditions, State.node.vel, time_value, this->solver_id); + boundary_velocity(mesh, BoundaryConditions, State.node.vel, time_value); // ---- apply contact boundary conditions to the boundary patches---- boundary_contact(mesh, BoundaryConditions, State.node.vel, time_value); diff --git a/single-node-refactor/src/Solvers/SGH_solver_rz/include/sgh_solver_rz.h b/single-node-refactor/src/Solvers/SGH_solver_rz/include/sgh_solver_rz.h index b42a11f13..c72a0d310 100644 --- a/single-node-refactor/src/Solvers/SGH_solver_rz/include/sgh_solver_rz.h +++ b/single-node-refactor/src/Solvers/SGH_solver_rz/include/sgh_solver_rz.h @@ -112,7 +112,6 @@ namespace SGHRZ_State class SGHRZ : public Solver { public: - size_t solver_id; SGHRZ() : Solver() { @@ -210,8 +209,7 @@ class SGHRZ : public Solver const Mesh_t& mesh, const BoundaryCondition_t& Boundary, DCArrayKokkos& node_vel, - const double time_value, - const size_t solver_id) const; + const double time_value) const; void boundary_contact_rz( const Mesh_t& mesh, diff --git a/single-node-refactor/src/Solvers/SGH_solver_rz/src/boundary_rz.cpp b/single-node-refactor/src/Solvers/SGH_solver_rz/src/boundary_rz.cpp index 7b438ba7c..ce66adfcf 100644 --- a/single-node-refactor/src/Solvers/SGH_solver_rz/src/boundary_rz.cpp +++ b/single-node-refactor/src/Solvers/SGH_solver_rz/src/boundary_rz.cpp @@ -52,11 +52,10 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. void SGHRZ::boundary_velocity_rz(const Mesh_t& mesh, const BoundaryCondition_t& BoundaryConditions, DCArrayKokkos& node_vel, - const double time_value, - const size_t solver_id) const + const double time_value) const { - size_t num_vel_bdy_sets = BoundaryConditions.num_vel_bdy_sets_in_solver.host(solver_id); + size_t num_vel_bdy_sets = BoundaryConditions.num_vel_bdy_sets_in_solver.host(this->solver_id); // Loop over the velocity boundary sets for (size_t bc_lid = 0; bc_lid < num_vel_bdy_sets; bc_lid++) { diff --git a/single-node-refactor/src/Solvers/SGH_solver_rz/src/sgh_execute_rz.cpp b/single-node-refactor/src/Solvers/SGH_solver_rz/src/sgh_execute_rz.cpp index 6e3cf2c17..ce692ae27 100644 --- a/single-node-refactor/src/Solvers/SGH_solver_rz/src/sgh_execute_rz.cpp +++ b/single-node-refactor/src/Solvers/SGH_solver_rz/src/sgh_execute_rz.cpp @@ -98,7 +98,7 @@ void SGHRZ::execute(SimulationParameters_t& SimulationParamaters, std::cout << "Applying initial boundary conditions" << std::endl; - boundary_velocity_rz(mesh, BoundaryConditions, State.node.vel, time_value, this->solver_id); // Time value = 0.0; + boundary_velocity_rz(mesh, BoundaryConditions, State.node.vel, time_value); // Time value = 0.0; @@ -325,7 +325,7 @@ void SGHRZ::execute(SimulationParameters_t& SimulationParamaters, State.corner.force); // ---- apply velocity boundary conditions to the boundary patches---- - boundary_velocity_rz(mesh, BoundaryConditions, State.node.vel, time_value, this->solver_id); + boundary_velocity_rz(mesh, BoundaryConditions, State.node.vel, time_value); // ---- apply contact boundary conditions to the boundary patches---- //boundary_contact(mesh, BoundaryConditions, State.node.vel, time_value); diff --git a/single-node-refactor/src/common/include/state.h b/single-node-refactor/src/common/include/state.h index 1716de52b..ac7df732c 100644 --- a/single-node-refactor/src/common/include/state.h +++ b/single-node-refactor/src/common/include/state.h @@ -149,7 +149,7 @@ struct MaterialToMeshMap_t // initialization method for FE-SGH and MPM methods (max number of elems needed) void initialize(size_t num_elem_max) { - this->elem = DCArrayKokkos(num_elem_max, "material_pt_to_elem"); + if (elem.size() == 0) this->elem = DCArrayKokkos(num_elem_max, "material_pt_to_elem"); }; // end method }; // end MaterialtoMeshMaps_t diff --git a/single-node-refactor/src/solver.h b/single-node-refactor/src/solver.h index e72af3326..289c04100 100644 --- a/single-node-refactor/src/solver.h +++ b/single-node-refactor/src/solver.h @@ -51,6 +51,8 @@ class Solver { public: + size_t solver_id; + Solver(); virtual ~Solver(); From f4081f4f824e5f93a6ba6d4754c3844bd04614b2 Mon Sep 17 00:00:00 2001 From: Nathaniel Morgan Date: Wed, 22 Jan 2025 17:07:41 -0700 Subject: [PATCH 3/4] changed input bc text, moved input bc params to global_vars, and made reflected vel be arbitrary direction --- .../input-impact-erosion.yaml | 20 +- single-node-refactor/input-lattice.yaml | 71 +++-- single-node-refactor/input-noh-rz.yaml | 20 +- single-node-refactor/input-noh.yaml | 33 ++- .../input-origin-erosion.yaml | 36 ++- single-node-refactor/input-rz-polar.yaml | 33 ++- single-node-refactor/input-rz.yaml | 20 +- single-node-refactor/input.yaml | 34 ++- .../standard_inputs/Abaqus_read.yaml | 52 ++-- .../standard_inputs/Sedov.yaml | 35 ++- .../standard_inputs/Sedov_Erosion.yaml | 36 ++- .../standard_inputs/Sedov_Read_Ensight.yaml | 33 ++- .../standard_inputs/Sedov_rz_polar.yaml | 25 +- .../standard_inputs/Sod_X.yaml | 66 +++-- .../standard_inputs/Sod_Y.yaml | 68 +++-- .../standard_inputs/Sod_Z.yaml | 68 +++-- .../Solvers/SGH_solver_3D/src/boundary.cpp | 2 +- .../Solvers/SGH_solver_rz/src/boundary_rz.cpp | 2 +- .../velocity/constant_velocity_bc.h | 4 +- .../velocity/no_velocity_bc.h | 2 +- .../velocity/piston_velocity_bc.h | 4 +- .../velocity/reflected_velocity_bc.h | 16 +- .../velocity/time_varying_velocity_bc.h | 42 ++- .../velocity/user_defined_velocity_bc.h | 2 +- .../velocity/zero_velocity_bc.h | 2 +- .../src/common/include/boundary_conditions.h | 48 ++- single-node-refactor/src/input/parse_yaml.cpp | 279 ++++++++++-------- 27 files changed, 652 insertions(+), 401 deletions(-) diff --git a/single-node-refactor/input-impact-erosion.yaml b/single-node-refactor/input-impact-erosion.yaml index a9ea4e8ad..85978053c 100644 --- a/single-node-refactor/input-impact-erosion.yaml +++ b/single-node-refactor/input-impact-erosion.yaml @@ -40,18 +40,26 @@ boundary_conditions: # Tag Y plane - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: 0.0 + geometry: + type: y_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y + - 0 # z # Tag z plane - boundary_condition: solver_id: 0 - geometry: z_plane - direction: z_dir - value: 0.0 + geometry: + type: z_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 0 # y + - 1 # z materials: diff --git a/single-node-refactor/input-lattice.yaml b/single-node-refactor/input-lattice.yaml index cd9d671a0..a7eb93702 100644 --- a/single-node-refactor/input-lattice.yaml +++ b/single-node-refactor/input-lattice.yaml @@ -13,8 +13,8 @@ mesh_options: num_dims: 3 type: box origin: [0.0, 0.0, 0.0] - length: [1, 1, 1] - num_elems: [64, 64, 64] + length: [0.5, 0.5, 1] + num_elems: [32, 32, 64] output_options: @@ -35,27 +35,59 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: x_plane - direction: x_dir - value: 0.0 + geometry: + type: x_plane + value: 0.0 velocity_model: reflected_velocity - + velocity_bc_global_vars: + - 1 # x + - 0 # y + - 0 # z # Tag Y plane - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: 0.0 + geometry: + type: y_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y + - 0 # z - # Tag z plane + # Tag Z plane - boundary_condition: solver_id: 0 - geometry: z_plane - direction: z_dir - value: 0.0 + geometry: + type: z_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 0 # y + - 1 # z + + # Tag z plane + - boundary_condition: + solver_id: 0 + geometry: + type: z_plane + value: 1.0 + velocity_model: velocity_vs_time + velocity_bc_global_vars: + - 0 # x + - 0 # y + - 1 # z + - -0.1 + - 2 + - 0 + - 10 + # V = V0 exp (-V1 * (t-t_start)) + # vel_0: -0.1 + # vel_1: 2 + # vel_t_start: 0 + # vel_t_end: 10 materials: - material: @@ -106,20 +138,19 @@ regions: w: 0.0 - - fill_volume: type: voxel_file file_path: ../../VTK_Geometry_lattice.vtk material_id: 1 - den: 2.0 - sie: 0.001 + den: 7.86 + sie: 1.e-10 velocity: cartesian u: 0.0 v: 0.0 w: 0.0 - scale_x: 0.01 - scale_y: 0.01 - scale_z: 0.01 - origin: [0.3, 0.3, 0.3] + scale_x: 0.02 + scale_y: 0.02 + scale_z: 0.040635127 + origin: [-0.5, -0.5, 0.] diff --git a/single-node-refactor/input-noh-rz.yaml b/single-node-refactor/input-noh-rz.yaml index 43e18f044..0db957fc5 100644 --- a/single-node-refactor/input-noh-rz.yaml +++ b/single-node-refactor/input-noh-rz.yaml @@ -39,19 +39,27 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: x_plane - direction: x_dir - value: 0.0 + geometry: + type: x_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 1 # x + - 0 # y + - 0 # z # Tag Y plane - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: 0.0 + geometry: + type: y_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y + - 0 # z diff --git a/single-node-refactor/input-noh.yaml b/single-node-refactor/input-noh.yaml index 26b324724..a08e52234 100644 --- a/single-node-refactor/input-noh.yaml +++ b/single-node-refactor/input-noh.yaml @@ -39,27 +39,38 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: x_plane - direction: x_dir - value: 0.0 + geometry: + type: x_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 1 # x + - 0 # y + - 0 # z - # Tag Y plane - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: 0.0 + geometry: + type: y_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y + - 0 # z - # Tag z plane + # Tag Z plane - boundary_condition: solver_id: 0 - geometry: z_plane - direction: z_dir - value: 0.0 + geometry: + type: z_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 0 # y + - 1 # z diff --git a/single-node-refactor/input-origin-erosion.yaml b/single-node-refactor/input-origin-erosion.yaml index 6d0e04c02..aed9646d9 100644 --- a/single-node-refactor/input-origin-erosion.yaml +++ b/single-node-refactor/input-origin-erosion.yaml @@ -39,30 +39,38 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: x_plane - direction: x_dir - value: 0.0 - u: 0.0 - v: 0.0 - w: 1.0 + geometry: + type: x_plane + value: 0.0 velocity_model: reflected_velocity - + velocity_bc_global_vars: + - 1 # x + - 0 # y + - 0 # z # Tag Y plane - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: 0.0 + geometry: + type: y_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y + - 0 # z - # Tag z plane + # Tag Z plane - boundary_condition: solver_id: 0 - geometry: z_plane - direction: z_dir - value: 0.0 + geometry: + type: z_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 0 # y + - 1 # z materials: - material: diff --git a/single-node-refactor/input-rz-polar.yaml b/single-node-refactor/input-rz-polar.yaml index 255dff05d..34fc384f1 100644 --- a/single-node-refactor/input-rz-polar.yaml +++ b/single-node-refactor/input-rz-polar.yaml @@ -44,32 +44,41 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: x_plane - direction: x_dir - value: 0.0 + geometry: + type: x_plane + value: 0.0 velocity_model: reflected_velocity - - + velocity_bc_global_vars: + - 1 # x + - 0 # y + - 0 # z + # Tag Y plane - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: 0.0 + geometry: + type: y_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y + - 0 # z # Tag inner circle - boundary_condition: solver_id: 0 - geometry: cylinder - value: 0.025 + geometry: + type: cylinder + value: 0.025 velocity_model: zero_velocity # Tag outer circle - boundary_condition: solver_id: 0 - geometry: cylinder - value: 1.2 + geometry: + type: cylinder + value: 1.2 velocity_model: zero_velocity materials: diff --git a/single-node-refactor/input-rz.yaml b/single-node-refactor/input-rz.yaml index 220e4a3ea..d20313128 100644 --- a/single-node-refactor/input-rz.yaml +++ b/single-node-refactor/input-rz.yaml @@ -39,19 +39,27 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: x_plane - direction: x_dir - value: 0.0 + geometry: + type: x_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 1 # x + - 0 # y + - 0 # z # Tag Y plane - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: 0.0 + geometry: + type: y_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y + - 0 # z diff --git a/single-node-refactor/input.yaml b/single-node-refactor/input.yaml index 673651e66..5c32ef077 100644 --- a/single-node-refactor/input.yaml +++ b/single-node-refactor/input.yaml @@ -23,7 +23,7 @@ mesh_options: output_options: timer_output_level: thorough - output_file_format: state + output_file_format: ensight #state graphics_time_step: 1.0 # graphics_iteration_step: 10 @@ -40,27 +40,39 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: x_plane - direction: x_dir - value: 0.0 + geometry: + type: x_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 1 # x + - 0 # y + - 0 # z + - # Tag Y plane - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: 0.0 + geometry: + type: y_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y + - 0 # z # Tag z plane - boundary_condition: solver_id: 0 - geometry: z_plane - direction: z_dir - value: 0.0 + geometry: + type: z_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 0 # y + - 1 # z diff --git a/single-node-refactor/regression_tests/standard_inputs/Abaqus_read.yaml b/single-node-refactor/regression_tests/standard_inputs/Abaqus_read.yaml index f33f2e5d8..d3aa591ba 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Abaqus_read.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Abaqus_read.yaml @@ -38,42 +38,60 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: x_plane - direction: x_dir - value: -4.0 + geometry: + type: x_plane + value: -4.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 1 # x + - 0 # y + - 0 # z - boundary_condition: solver_id: 0 - geometry: x_plane - direction: x_dir - value: 4.0 + geometry: + type: x_plane + value: 4.0 velocity_model: reflected_velocity - + velocity_bc_global_vars: + - 1 # x + - 0 # y + - 0 # z # Tag Y plane - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: -4.0 + geometry: + type: y_plane + value: -4.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y + - 0 # z - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: 4.0 + geometry: + type: y_plane + value: 4.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y + - 0 # z # Tag z plane - boundary_condition: solver_id: 0 - geometry: z_plane - direction: z_dir - value: 0.0 + geometry: + type: z_plane + value: 0.0 velocity_model: reflected_velocity - + velocity_bc_global_vars: + - 0 # x + - 0 # y + - 1 # z materials: diff --git a/single-node-refactor/regression_tests/standard_inputs/Sedov.yaml b/single-node-refactor/regression_tests/standard_inputs/Sedov.yaml index ed8ae38ad..b3fad8e0f 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sedov.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sedov.yaml @@ -29,27 +29,40 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: x_plane - direction: x_dir - value: 0.0 + geometry: + type: x_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 1 # x + - 0 # y + - 0 # z + - # Tag Y plane - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: 0.0 + geometry: + type: y_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y + - 0 # z - # Tag z plane + # Tag Z plane - boundary_condition: solver_id: 0 - geometry: z_plane - direction: z_dir - value: 0.0 + geometry: + type: z_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 0 # y + - 1 # z + materials: - material: diff --git a/single-node-refactor/regression_tests/standard_inputs/Sedov_Erosion.yaml b/single-node-refactor/regression_tests/standard_inputs/Sedov_Erosion.yaml index e37dc1a52..8eb3e8923 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sedov_Erosion.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sedov_Erosion.yaml @@ -39,30 +39,40 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: x_plane - direction: x_dir - value: 0.0 - u: 0.0 - v: 0.0 - w: 1.0 + geometry: + type: x_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 1 # x + - 0 # y + - 0 # z # Tag Y plane - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: 0.0 + geometry: + type: y_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y + - 0 # z + - # Tag z plane + # Tag Z plane - boundary_condition: solver_id: 0 - geometry: z_plane - direction: z_dir - value: 0.0 + geometry: + type: z_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 0 # y + - 1 # z materials: - material: diff --git a/single-node-refactor/regression_tests/standard_inputs/Sedov_Read_Ensight.yaml b/single-node-refactor/regression_tests/standard_inputs/Sedov_Read_Ensight.yaml index 460bf45bd..9c3baebec 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sedov_Read_Ensight.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sedov_Read_Ensight.yaml @@ -26,27 +26,38 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: x_plane - direction: x_dir - value: 0.0 + geometry: + type: x_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 1 # x + - 0 # y + - 0 # z - # Tag Y plane - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: 0.0 + geometry: + type: y_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y + - 0 # z - # Tag z plane + # Tag Z plane - boundary_condition: solver_id: 0 - geometry: z_plane - direction: z_dir - value: 0.0 + geometry: + type: z_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 0 # y + - 1 # z materials: - material: diff --git a/single-node-refactor/regression_tests/standard_inputs/Sedov_rz_polar.yaml b/single-node-refactor/regression_tests/standard_inputs/Sedov_rz_polar.yaml index 07270f73c..f8b534a3f 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sedov_rz_polar.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sedov_rz_polar.yaml @@ -44,25 +44,32 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: x_plane - direction: x_dir - value: 0.0 + geometry: + type: x_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 1 # x + - 0 # y + - # Tag Y plane - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: 0.0 + geometry: + type: y_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y # Tag inner circle - boundary_condition: solver_id: 0 - geometry: cylinder - value: 0.025 + geometry: + type: cylinder + value: 0.025 velocity_model: zero_velocity diff --git a/single-node-refactor/regression_tests/standard_inputs/Sod_X.yaml b/single-node-refactor/regression_tests/standard_inputs/Sod_X.yaml index fd31847b9..fbc4b56ec 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sod_X.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sod_X.yaml @@ -25,56 +25,80 @@ solver_options: method: SGH3D boundary_conditions: - # Tag X=0 plane + # Tag X plane - boundary_condition: solver_id: 0 - geometry: x_plane - direction: x_dir - value: 0.0 + geometry: + type: x_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 1 # x + - 0 # y + - 0 # z - # Tag Y=0 plane + # Tag Y plane - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: 0.0 + geometry: + type: y_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y + - 0 # z - # Tag z=0 plane + # Tag Z plane - boundary_condition: solver_id: 0 - geometry: z_plane - direction: z_dir - value: 0.0 + geometry: + type: z_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 0 # y + - 1 # z # Tag X=1 plane - boundary_condition: solver_id: 0 - geometry: x_plane - direction: x_dir - value: 1.0 + geometry: + type: x_plane + value: 1.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 1 # x + - 0 # y + - 0 # z # Tag Y=0.01 plane - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: 0.01 + geometry: + type: y_plane + value: 0.01 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y + - 0 # z # Tag z=0.01 plane - boundary_condition: solver_id: 0 - geometry: z_plane - direction: z_dir - value: 0.01 + geometry: + type: z_plane + value: 0.01 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 0 # y + - 1 # z materials: diff --git a/single-node-refactor/regression_tests/standard_inputs/Sod_Y.yaml b/single-node-refactor/regression_tests/standard_inputs/Sod_Y.yaml index 7f71f8b7d..eb23f749a 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sod_Y.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sod_Y.yaml @@ -25,56 +25,80 @@ solver_options: method: SGH3D boundary_conditions: - # Tag X=0 plane + # Tag X plane - boundary_condition: solver_id: 0 - geometry: x_plane - direction: x_dir - value: 0.0 + geometry: + type: x_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 1 # x + - 0 # y + - 0 # z - # Tag Y=0 plane + # Tag Y plane - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: 0.0 + geometry: + type: y_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y + - 0 # z - # Tag z=0 plane + # Tag Z plane - boundary_condition: solver_id: 0 - geometry: z_plane - direction: z_dir - value: 0.0 + geometry: + type: z_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 0 # y + - 1 # z # Tag X=0.01 plane - boundary_condition: solver_id: 0 - geometry: x_plane - direction: x_dir - value: 0.01 + geometry: + type: x_plane + value: 0.01 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 1 # x + - 0 # y + - 0 # z - # Tag Y=1.0 plane + # Tag y=1.0 plane - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: 1.0 + geometry: + type: y_plane + value: 1.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y + - 0 # z # Tag z=0.01 plane - boundary_condition: solver_id: 0 - geometry: z_plane - direction: z_dir - value: 0.01 + geometry: + type: z_plane + value: 0.01 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 0 # y + - 1 # z materials: diff --git a/single-node-refactor/regression_tests/standard_inputs/Sod_Z.yaml b/single-node-refactor/regression_tests/standard_inputs/Sod_Z.yaml index 91bd1f69b..1c6033f85 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sod_Z.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sod_Z.yaml @@ -25,57 +25,79 @@ solver_options: method: SGH3D boundary_conditions: - # Tag X=0 plane + # Tag X plane - boundary_condition: solver_id: 0 - geometry: x_plane - direction: x_dir - value: 0.0 + geometry: + type: x_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 1 # x + - 0 # y + - 0 # z - # Tag Y=0 plane + # Tag Y plane - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: 0.0 + geometry: + type: y_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y + - 0 # z - # Tag z=0 plane + # Tag Z plane - boundary_condition: solver_id: 0 - geometry: z_plane - direction: z_dir - value: 0.0 + geometry: + type: z_plane + value: 0.0 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 0 # y + - 1 # z # Tag X=0.01 plane - boundary_condition: solver_id: 0 - geometry: x_plane - direction: x_dir - value: 0.01 + geometry: + type: x_plane + value: 0.01 velocity_model: reflected_velocity - + velocity_bc_global_vars: + - 1 # x + - 0 # y + - 0 # z # Tag Y=0.01 plane - boundary_condition: solver_id: 0 - geometry: y_plane - direction: y_dir - value: 0.01 + geometry: + type: y_plane + value: 0.01 velocity_model: reflected_velocity + velocity_bc_global_vars: + - 0 # x + - 1 # y + - 0 # z # Tag z=1.0 plane - boundary_condition: solver_id: 0 - geometry: z_plane - direction: z_dir - value: 1.0 + geometry: + type: z_plane + value: 1.0 velocity_model: reflected_velocity - + velocity_bc_global_vars: + - 0 # x + - 0 # y + - 1 # z materials: - material: diff --git a/single-node-refactor/src/Solvers/SGH_solver_3D/src/boundary.cpp b/single-node-refactor/src/Solvers/SGH_solver_3D/src/boundary.cpp index c655c28f9..ee8cba133 100644 --- a/single-node-refactor/src/Solvers/SGH_solver_3D/src/boundary.cpp +++ b/single-node-refactor/src/Solvers/SGH_solver_3D/src/boundary.cpp @@ -69,7 +69,7 @@ void SGH3D::boundary_velocity(const Mesh_t& mesh, BoundaryConditions.BoundaryConditionFunctions(bdy_set).velocity( mesh, BoundaryConditions.BoundaryConditionEnums, - BoundaryConditions.bc_global_vars, + BoundaryConditions.velocity_bc_global_vars, BoundaryConditions.bc_state_vars, node_vel, time_value, diff --git a/single-node-refactor/src/Solvers/SGH_solver_rz/src/boundary_rz.cpp b/single-node-refactor/src/Solvers/SGH_solver_rz/src/boundary_rz.cpp index ce66adfcf..98a7a9ba2 100644 --- a/single-node-refactor/src/Solvers/SGH_solver_rz/src/boundary_rz.cpp +++ b/single-node-refactor/src/Solvers/SGH_solver_rz/src/boundary_rz.cpp @@ -71,7 +71,7 @@ void SGHRZ::boundary_velocity_rz(const Mesh_t& mesh, // evaluate velocity on this boundary node BoundaryConditions.BoundaryConditionFunctions(bdy_set).velocity(mesh, BoundaryConditions.BoundaryConditionEnums, - BoundaryConditions.bc_global_vars, + BoundaryConditions.velocity_bc_global_vars, BoundaryConditions.bc_state_vars, node_vel, time_value, diff --git a/single-node-refactor/src/boundary_conditions/velocity/constant_velocity_bc.h b/single-node-refactor/src/boundary_conditions/velocity/constant_velocity_bc.h index 88eb9da83..f5dc79420 100644 --- a/single-node-refactor/src/boundary_conditions/velocity/constant_velocity_bc.h +++ b/single-node-refactor/src/boundary_conditions/velocity/constant_velocity_bc.h @@ -60,7 +60,7 @@ namespace ConstantVelocityBC KOKKOS_FUNCTION static void velocity(const Mesh_t& mesh, const DCArrayKokkos& BoundaryConditionEnums, - const DCArrayKokkos& bc_global_vars, + const RaggedRightArrayKokkos& vel_bc_global_vars, const DCArrayKokkos& bc_state_vars, const DCArrayKokkos& node_vel, const double time_value, @@ -70,7 +70,7 @@ static void velocity(const Mesh_t& mesh, { for (size_t dim = 0; dim < mesh.num_dims; dim++) { // Set velocity to zero - node_vel(1, bdy_node_gid, dim) = bc_global_vars(bdy_set, dim); + node_vel(1, bdy_node_gid, dim) = vel_bc_global_vars(bdy_set, dim); } return; diff --git a/single-node-refactor/src/boundary_conditions/velocity/no_velocity_bc.h b/single-node-refactor/src/boundary_conditions/velocity/no_velocity_bc.h index 043ef0241..9a0a4e1c7 100644 --- a/single-node-refactor/src/boundary_conditions/velocity/no_velocity_bc.h +++ b/single-node-refactor/src/boundary_conditions/velocity/no_velocity_bc.h @@ -60,7 +60,7 @@ namespace NoVelocityBC KOKKOS_FUNCTION static void velocity(const Mesh_t& mesh, const DCArrayKokkos& BoundaryConditionEnums, - const DCArrayKokkos& bc_global_vars, + const RaggedRightArrayKokkos& vel_bc_global_vars, const DCArrayKokkos& bc_state_vars, const DCArrayKokkos& node_vel, const double time_value, diff --git a/single-node-refactor/src/boundary_conditions/velocity/piston_velocity_bc.h b/single-node-refactor/src/boundary_conditions/velocity/piston_velocity_bc.h index 953d06d0b..b15b6841f 100644 --- a/single-node-refactor/src/boundary_conditions/velocity/piston_velocity_bc.h +++ b/single-node-refactor/src/boundary_conditions/velocity/piston_velocity_bc.h @@ -62,7 +62,7 @@ namespace PistonVelocityBC KOKKOS_FUNCTION static void velocity(const Mesh_t& mesh, const DCArrayKokkos& BoundaryConditionEnums, - const DCArrayKokkos& bc_global_vars, + const RaggedRightArrayKokkos& vel_bc_global_vars, const DCArrayKokkos& bc_state_vars, const DCArrayKokkos& node_vel, const double time_value, @@ -77,7 +77,7 @@ static void velocity(const Mesh_t& mesh, // Set velocity to the specified value node_vel(1, bdy_node_gid, BoundaryConditionEnums(bdy_set).Direction) = - bc_global_vars(bdy_set, BoundaryConditionEnums(bdy_set).Direction); + vel_bc_global_vars(bdy_set, BoundaryConditionEnums(bdy_set).Direction); return; } // end func diff --git a/single-node-refactor/src/boundary_conditions/velocity/reflected_velocity_bc.h b/single-node-refactor/src/boundary_conditions/velocity/reflected_velocity_bc.h index 5e3a35bd7..a40c7a2ae 100644 --- a/single-node-refactor/src/boundary_conditions/velocity/reflected_velocity_bc.h +++ b/single-node-refactor/src/boundary_conditions/velocity/reflected_velocity_bc.h @@ -62,7 +62,7 @@ namespace ReflectedVelocityBC KOKKOS_FUNCTION static void velocity(const Mesh_t& mesh, const DCArrayKokkos& BoundaryConditionEnums, - const DCArrayKokkos& bc_global_vars, + const RaggedRightArrayKokkos& vel_bc_global_vars, const DCArrayKokkos& bc_state_vars, const DCArrayKokkos& node_vel, const double time_value, @@ -70,13 +70,15 @@ static void velocity(const Mesh_t& mesh, const size_t bdy_node_gid, const size_t bdy_set) { - // directions are: - // x_plane = 0, - // y_plane = 1, - // z_plane = 2, + double mag = 0.0; + for (size_t dim = 0; dim& BoundaryConditionEnums, - const DCArrayKokkos& bc_global_vars, + const RaggedRightArrayKokkos& vel_bc_global_vars, const DCArrayKokkos& bc_state_vars, const DCArrayKokkos& node_vel, const double time_value, @@ -81,10 +84,13 @@ static void velocity(const Mesh_t& mesh, const size_t bdy_node_gid, const size_t bdy_set) { - const double hydro_bc_vel_0 = bc_global_vars(bdy_set, BCVars::hydro_bc_vel_0); - const double hydro_bc_vel_1 = bc_global_vars(bdy_set, BCVars::hydro_bc_vel_1); - const double hydro_bc_vel_t_start = bc_global_vars(bdy_set, BCVars::hydro_bc_vel_t_start); - const double hydro_bc_vel_t_end = bc_global_vars(bdy_set, BCVars::hydro_bc_vel_t_end); + const double x_comp = vel_bc_global_vars(bdy_set, BCVars::x_comp); + const double y_comp = vel_bc_global_vars(bdy_set, BCVars::y_comp); + const double z_comp = vel_bc_global_vars(bdy_set, BCVars::z_comp); + const double hydro_bc_vel_0 = vel_bc_global_vars(bdy_set, BCVars::hydro_bc_vel_0); + const double hydro_bc_vel_1 = vel_bc_global_vars(bdy_set, BCVars::hydro_bc_vel_1); + const double hydro_bc_vel_t_start = vel_bc_global_vars(bdy_set, BCVars::hydro_bc_vel_t_start); + const double hydro_bc_vel_t_end = vel_bc_global_vars(bdy_set, BCVars::hydro_bc_vel_t_end); // directions are as follows: // x_plane = 0, @@ -98,8 +104,22 @@ static void velocity(const Mesh_t& mesh, // the time difference const double time_delta = time_value - hydro_bc_vel_t_start; - node_vel(1, bdy_node_gid, BoundaryConditionEnums(bdy_set).Direction) = - hydro_bc_vel_0 * exp(-hydro_bc_vel_1 * time_delta); + // the desired velocity + const double vel = hydro_bc_vel_0 * exp(-hydro_bc_vel_1 * time_delta); + + double mag = 0.0; + for (size_t dim = 0; dim& BoundaryConditionEnums, - const DCArrayKokkos& bc_global_vars, + const RaggedRightArrayKokkos& vel_bc_global_vars, const DCArrayKokkos& bc_state_vars, const DCArrayKokkos& node_vel, const double time_value, diff --git a/single-node-refactor/src/boundary_conditions/velocity/zero_velocity_bc.h b/single-node-refactor/src/boundary_conditions/velocity/zero_velocity_bc.h index 9e6d48f9c..fa1cb2d61 100644 --- a/single-node-refactor/src/boundary_conditions/velocity/zero_velocity_bc.h +++ b/single-node-refactor/src/boundary_conditions/velocity/zero_velocity_bc.h @@ -62,7 +62,7 @@ namespace ZeroVelocityBC KOKKOS_FUNCTION static void velocity(const Mesh_t& mesh, const DCArrayKokkos& BoundaryConditionEnums, - const DCArrayKokkos& bc_global_vars, + const RaggedRightArrayKokkos& vel_bc_global_vars, const DCArrayKokkos& bc_state_vars, const DCArrayKokkos& node_vel, const double time_value, diff --git a/single-node-refactor/src/common/include/boundary_conditions.h b/single-node-refactor/src/common/include/boundary_conditions.h index 21cfc04d4..cb443de2d 100644 --- a/single-node-refactor/src/common/include/boundary_conditions.h +++ b/single-node-refactor/src/common/include/boundary_conditions.h @@ -82,13 +82,7 @@ enum BCFcnLocation device = 1 }; -// Direction to apply boundary conditions -enum BCDirection -{ - xDir = 0, - yDir = 1, - zDir = 2 -}; + } // end of boundary conditions namespace static std::map bc_geometry_map @@ -121,12 +115,6 @@ static std::map bc_velocity_ -static std::map bc_direction_map -{ - { "x_dir", boundary_conditions::xDir }, - { "y_dir", boundary_conditions::yDir }, - { "z_dir", boundary_conditions::zDir } -}; static std::map bc_location_map { @@ -161,8 +149,6 @@ struct BoundaryConditionEnums_t boundary_conditions::BCVelocityModels BCVelocityModel = boundary_conditions::noVelocityBC; ///< Type of velocity boundary condition - boundary_conditions::BCDirection Direction; ///< Boundary condition direction - boundary_conditions::BCFcnLocation Location = boundary_conditions::device; // host or device BC function }; // end boundary condition enums @@ -178,7 +164,7 @@ struct BoundaryConditionFunctions_t // function pointer for velocity BC's void (*velocity) (const Mesh_t& mesh, const DCArrayKokkos& BoundaryConditionEnums, - const DCArrayKokkos& bc_global_vars, + const RaggedRightArrayKokkos& vel_bc_global_vars, const DCArrayKokkos& bc_state_vars, const DCArrayKokkos& node_vel, const double time_value, @@ -215,12 +201,13 @@ struct BoundaryCondition_t DCArrayKokkos num_vel_bdy_sets_in_solver; // (solver) // keep adding ragged storage for the other BC models -- temp, displacement, etc. - // DCArrayKokkos temp_bdy_sets_in_solver; // (solver, ids) - // DCArrayKokkos num_temp_bdy_sets_in_solver; // (solver) + // DCArrayKokkos temperature_bdy_sets_in_solver; // (solver, ids) + // DCArrayKokkos num_temperature_bdy_sets_in_solver; // (solver) - // global variables for boundary condition models - DCArrayKokkos bc_global_vars; // it is only 4 values, so ragged doesn't make sense now + // global variables for velocity boundary condition models + RaggedRightArrayKokkos velocity_bc_global_vars; + CArrayKokkos num_velocity_bc_global_vars; // state variables for boundary conditions DCArrayKokkos bc_state_vars; @@ -231,20 +218,18 @@ struct BoundaryCondition_t // ------------------------------------- static std::vector str_bc_inps { - "solver", "solver_id", "velocity_model", "geometry", - "direction", + "velocity_bc_global_vars" +}; + +// subfields under geometery +static std::vector str_bc_geometry_inps +{ + "type", "value", - "u", - "v", - "w", - "origin", - "hydro_bc_vel_0", - "hydro_bc_vel_1", - "hydro_bc_vel_t_start", - "hydro_bc_vel_t_end" + "origin" }; // ---------------------------------- @@ -253,5 +238,8 @@ static std::vector str_bc_inps static std::vector bc_required_inps { }; +static std::vector bc_geometery_required_inps +{ +}; #endif // end Header Guard \ No newline at end of file diff --git a/single-node-refactor/src/input/parse_yaml.cpp b/single-node-refactor/src/input/parse_yaml.cpp index bc0535d3d..262fdb310 100644 --- a/single-node-refactor/src/input/parse_yaml.cpp +++ b/single-node-refactor/src/input/parse_yaml.cpp @@ -349,6 +349,7 @@ void validate_inputs( // validate input: user_inputs match words in the str_valid_inputs if (std::find(str_valid_inputs.begin(), str_valid_inputs.end(), var_name) == str_valid_inputs.end()) { std::cout << "ERROR: invalid input: " << var_name << std::endl; + throw std::runtime_error("**** Exiting validate input. Missing required inputs ****"); } // end if variable exists } // end for item in this yaml input @@ -2189,7 +2190,7 @@ void parse_materials(Yaml::Node& root, Material_t& Materials, const size_t num_d std::cout << "num global strength vars = " << num_global_vars << std::endl; } - // store the global eos model parameters + // store the global strength model parameters for (int global_var_id = 0; global_var_id < num_global_vars; global_var_id++) { double strength_var = root["materials"][m_id]["material"]["strength_global_vars"][global_var_id].As(); @@ -2201,7 +2202,7 @@ void parse_materials(Yaml::Node& root, Material_t& Materials, const size_t num_d std::cout << "\t var = " << strength_var << std::endl; } } // end loop over global vars - } // "eos_global_vars" + } // "strength_global_vars" else if (a_word.compare("dissipation_global_vars") == 0) { Yaml::Node & mat_global_vars_yaml = root["materials"][m_id]["material"][a_word]; @@ -2321,13 +2322,23 @@ void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions, const } // end for - // the state for boundary conditions - BoundaryConditions.bc_global_vars = DCArrayKokkos(num_bcs, 4, "bc_global_values"); // increase 4 for more params + // temporary arrays for boundary condition variables + DCArrayKokkos tempVelocityBCGlobalVars (num_bcs, 100, "temporary_velocity_bc_global_values"); + + BoundaryConditions.num_velocity_bc_global_vars = CArrayKokkos (num_bcs, "BoundaryConditions.num_velocity_bc_global_vars"); + + // initialize the num of global vars to 0 for all models + FOR_ALL(bc_id, 0, num_bcs, { + BoundaryConditions.num_velocity_bc_global_vars(bc_id) = 0; + }); // end parallel for + + + // state place holder is here BoundaryConditions.bc_state_vars = DCArrayKokkos(num_bcs, 4, "bc_state_values"); // WARNING a place holder // loop over the BC specified - for (int bc_id = 0; bc_id < num_bcs; bc_id++) { + for (size_t bc_id = 0; bc_id < num_bcs; bc_id++) { // read the variables names Yaml::Node& inps_yaml = bc_yaml[bc_id]["boundary_condition"]; @@ -2501,149 +2512,135 @@ void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions, const } } // end if } // direction - // get boundary condition direction - else if (a_word.compare("direction") == 0) { - std::string direction = bc_yaml[bc_id]["boundary_condition"][a_word].As(); + // get boundary condition geometry + else if (a_word.compare("geometry") == 0) { - auto map = bc_direction_map; + // ----- + // loop over the sub fields under geometry + // ----- + Yaml::Node& inps_subfields_yaml = bc_yaml[bc_id]["boundary_condition"]["geometry"]; - // set the direction - if (map.find(direction) != map.end()) { - auto bc_direction = map[direction]; - RUN({ - BoundaryConditions.BoundaryConditionEnums(bc_id).Direction = bc_direction; - }); - if (VERBOSE) { - std::cout << "\tdirection = " << direction << std::endl; - } - } - else{ - std::cout << "ERROR: invalid boundary condition option input in YAML file: " << direction << std::endl; - std::cout << "Valid options are: " << std::endl; + // get the bc_geometery variables names set by the user + std::vector user_bc_geometry_inputs; + + // extract words from the input file and validate they are correct + validate_inputs(inps_subfields_yaml, user_bc_geometry_inputs, str_bc_geometry_inps, bc_geometery_required_inps); - for (const auto& pair : map) { - std::cout << "\t" << pair.first << std::endl; - } - } // end if - } // direction - // get boundary condition geometry - else if (a_word.compare("geometry") == 0) { - std::string geometry = bc_yaml[bc_id]["boundary_condition"][a_word].As(); - auto map = bc_geometry_map; + // loop over the subfield words + for(auto& a_subfield_word : user_bc_geometry_inputs){ - // set the geometry - if (map.find(geometry) != map.end()) { - auto bc_geometry = map[geometry]; - RUN({ - BoundaryConditions.BoundaryConditionSetup(bc_id).geometry = bc_geometry; - }); + if (a_subfield_word.compare("type") == 0){ + std::string geometry = bc_yaml[bc_id]["boundary_condition"]["geometry"][a_subfield_word].As(); - if (VERBOSE) { - std::cout << "\tgeometry = " << geometry << std::endl; - } - } - else{ - std::cout << "ERROR: invalid boundary condition option input in YAML file: " << geometry << std::endl; - std::cout << "Valid options are: " << std::endl; + auto map = bc_geometry_map; - for (const auto& pair : map) { - std::cout << "\t" << pair.first << std::endl; + // set the geometry + if (map.find(geometry) != map.end()) { + auto bc_geometry = map[geometry]; + RUN({ + BoundaryConditions.BoundaryConditionSetup(bc_id).geometry = bc_geometry; + }); + + if (VERBOSE) { + std::cout << "\tgeometry = " << geometry << std::endl; + } + } + else{ + std::cout << "ERROR: invalid boundary condition option input in YAML file: " << geometry << std::endl; + std::cout << "Valid options are: " << std::endl; + + for (const auto& pair : map) { + std::cout << "\t" << pair.first << std::endl; + } + } // end if + + } // end if type + else if (a_subfield_word.compare("value") == 0) { + double value = bc_yaml[bc_id]["boundary_condition"]["geometry"][a_subfield_word].As(); + RUN({ + BoundaryConditions.BoundaryConditionSetup(bc_id).value = value; + }); + } // end if value + else if (a_subfield_word.compare("origin") == 0) { + std::string origin = bc_yaml[bc_id]["boundary_condition"]["geometry"][a_subfield_word].As(); + if (VERBOSE) { + std::cout << "\torigin = " << origin << std::endl; + } + + // get the origin numbers, values are words + std::vector numbers = exact_array_values(origin, ","); + + double x1 = std::stod(numbers[0]); + double y1 = std::stod(numbers[1]); + double z1; + + if(numbers.size()==3){ + // 3D + z1 = std::stod(numbers[2]); + } + else { + // 2D + z1 = 0.0; + } // + + if (VERBOSE) { + std::cout << "\tx1 = " << x1 << std::endl; + std::cout << "\ty1 = " << y1 << std::endl; + std::cout << "\tz1 = " << z1 << std::endl; + } + // storing the origin values as (x1,y1,z1) + + RUN({ + BoundaryConditions.BoundaryConditionSetup(bc_id).origin[0] = x1; + BoundaryConditions.BoundaryConditionSetup(bc_id).origin[1] = y1; + BoundaryConditions.BoundaryConditionSetup(bc_id).origin[2] = z1; + }); + + } //end origin + else { + // word is unknown + std::cout << "ERROR: invalid input under boundary condition geometery: " << a_subfield_word << std::endl; + std::cout << "Valid options are: " << std::endl; + for (const auto& element : str_bc_geometry_inps) { + std::cout << element << std::endl; + } + throw std::runtime_error("**** Boundary Conditions Not Understood ****"); } - } // end if + + } // end loop over words in the subfield } // geometry // set the value - else if (a_word.compare("value") == 0) { - double value = bc_yaml[bc_id]["boundary_condition"][a_word].As(); - RUN({ - BoundaryConditions.BoundaryConditionSetup(bc_id).value = value; - }); - } // value - // set the u - else if (a_word.compare("u") == 0) { - double u = bc_yaml[bc_id]["boundary_condition"][a_word].As(); - RUN({ - BoundaryConditions.bc_global_vars(bc_id,0) = u; - }); - } // u - // set the v - else if (a_word.compare("v") == 0) { - double v = bc_yaml[bc_id]["boundary_condition"][a_word].As(); - RUN({ - BoundaryConditions.bc_global_vars(bc_id,1) = v; - }); - } // v - // set the w - else if (a_word.compare("w") == 0) { - double w = bc_yaml[bc_id]["boundary_condition"][a_word].As(); - RUN({ - BoundaryConditions.bc_global_vars(bc_id,2) = w; - }); - } // w - // set the bc_vel_0 - else if (a_word.compare("hydro_bc_vel_0") == 0) { - double hydro_bc_vel_0 = bc_yaml[bc_id]["boundary_condition"][a_word].As(); - RUN({ - BoundaryConditions.bc_global_vars(bc_id,0) = hydro_bc_vel_0; - }); - } // - // set the bc_vel_1 - else if (a_word.compare("hydro_bc_vel_1") == 0) { - double hydro_bc_vel_1 = bc_yaml[bc_id]["boundary_condition"][a_word].As(); - RUN({ - BoundaryConditions.bc_global_vars(bc_id,1) = hydro_bc_vel_1; - }); - } // - // set the bc_vel_start - else if (a_word.compare("hydro_bc_vel_t_start") == 0) { - double hydro_bc_vel_t_start = bc_yaml[bc_id]["boundary_condition"][a_word].As(); - RUN({ - BoundaryConditions.bc_global_vars(bc_id,2) = hydro_bc_vel_t_start; - }); - } // - // set the bc_vel_end - else if (a_word.compare("hydro_bc_vel_t_end") == 0) { - double hydro_bc_vel_t_end = bc_yaml[bc_id]["boundary_condition"][a_word].As(); - RUN({ - BoundaryConditions.bc_global_vars(bc_id,3) = hydro_bc_vel_t_end; - }); - } // - else if (a_word.compare("origin") == 0) { - std::string origin = bc_yaml[bc_id]["boundary_condition"][a_word].As(); - if (VERBOSE) { - std::cout << "\torigin = " << origin << std::endl; - } - - // get the origin numbers, values are words - std::vector numbers = exact_array_values(origin, ","); + else if (a_word.compare("velocity_bc_global_vars") == 0) { + Yaml::Node & vel_bc_global_vars_yaml = bc_yaml[bc_id]["boundary_condition"][a_word]; - double x1 = std::stod(numbers[0]); - double y1 = std::stod(numbers[1]); - double z1; + size_t num_global_vars = vel_bc_global_vars_yaml.Size(); - if(numbers.size()==3){ - // 3D - z1 = std::stod(numbers[2]); - } - else { - // 2D - z1 = 0.0; - } // + if(num_global_vars>100){ + throw std::runtime_error("**** Per boundary condition, the code only supports up to 100 velocity global vars in the input file ****"); + } // end check on num_global_vars + RUN({ + BoundaryConditions.num_velocity_bc_global_vars(bc_id) = num_global_vars; + }); + if (VERBOSE) { - std::cout << "\tx1 = " << x1 << std::endl; - std::cout << "\ty1 = " << y1 << std::endl; - std::cout << "\tz1 = " << z1 << std::endl; + std::cout << "num global velocity_bc vars = " << num_global_vars << std::endl; } - // storing the origin values as (x1,y1,z1) - RUN({ - BoundaryConditions.BoundaryConditionSetup(bc_id).origin[0] = x1; - BoundaryConditions.BoundaryConditionSetup(bc_id).origin[1] = y1; - BoundaryConditions.BoundaryConditionSetup(bc_id).origin[2] = z1; - }); + // store the global eos model parameters + for (int global_var_id = 0; global_var_id < num_global_vars; global_var_id++) { + double velocity_bc_var = bc_yaml[bc_id]["boundary_condition"]["velocity_bc_global_vars"][global_var_id].As(); + + RUN({ + tempVelocityBCGlobalVars(bc_id, global_var_id) = velocity_bc_var; + }); - } // origin + if (VERBOSE) { + std::cout << "\t var = " << velocity_bc_var << std::endl; + } + } // end loop over global vars + } // end else if on velocity_bc_global_vars else { std::cout << "ERROR: invalid input: " << a_word << std::endl; std::cout << "Valid options are: " << std::endl; @@ -2654,8 +2651,28 @@ void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions, const } } // end for words in boundary conditions + + // add checks for velocity vs time boundary condition + + } // end loop over BCs specified + + // allocate ragged right memory to hold the model global variables + BoundaryConditions.velocity_bc_global_vars = RaggedRightArrayKokkos (BoundaryConditions.num_velocity_bc_global_vars, "BoundaryConditions.velocity_bc_global_vars"); + // ... allocate other bc global vars here + + // save the global variables + FOR_ALL(bc_id, 0, num_bcs, { + + for (size_t var_lid=0; var_lid Date: Thu, 23 Jan 2025 09:13:47 -0700 Subject: [PATCH 4/4] updated boundary condition input syntax --- .../input-impact-erosion.yaml | 12 ++--- single-node-refactor/input-lattice.yaml | 24 ++++----- single-node-refactor/input-noh-rz.yaml | 12 ++--- single-node-refactor/input-noh.yaml | 18 +++---- .../input-origin-erosion.yaml | 26 +++++---- single-node-refactor/input-rz-polar.yaml | 24 ++++----- single-node-refactor/input-rz.yaml | 12 ++--- single-node-refactor/input.yaml | 18 +++---- .../standard_inputs/Abaqus_read.yaml | 30 +++++------ .../standard_inputs/Sedov.yaml | 18 +++---- .../standard_inputs/Sedov_Erosion.yaml | 18 +++---- .../standard_inputs/Sedov_Read_Ensight.yaml | 18 +++---- .../standard_inputs/Sedov_rz_polar.yaml | 19 +++---- .../standard_inputs/Sod_X.yaml | 36 ++++++------- .../standard_inputs/Sod_Y.yaml | 36 ++++++------- .../standard_inputs/Sod_Z.yaml | 36 ++++++------- .../src/common/include/boundary_conditions.h | 33 ++++++------ .../src/common/src/geometry_new.cpp | 2 +- single-node-refactor/src/input/parse_yaml.cpp | 53 +++++++++++-------- 19 files changed, 230 insertions(+), 215 deletions(-) diff --git a/single-node-refactor/input-impact-erosion.yaml b/single-node-refactor/input-impact-erosion.yaml index 85978053c..e6ac5e3a8 100644 --- a/single-node-refactor/input-impact-erosion.yaml +++ b/single-node-refactor/input-impact-erosion.yaml @@ -40,10 +40,10 @@ boundary_conditions: # Tag Y plane - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y @@ -52,10 +52,10 @@ boundary_conditions: # Tag z plane - boundary_condition: solver_id: 0 - geometry: + surface: type: z_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 0 # y diff --git a/single-node-refactor/input-lattice.yaml b/single-node-refactor/input-lattice.yaml index a7eb93702..c041d32a0 100644 --- a/single-node-refactor/input-lattice.yaml +++ b/single-node-refactor/input-lattice.yaml @@ -35,10 +35,10 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: + surface: type: x_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 1 # x - 0 # y @@ -47,10 +47,10 @@ boundary_conditions: # Tag Y plane - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y @@ -59,10 +59,10 @@ boundary_conditions: # Tag Z plane - boundary_condition: solver_id: 0 - geometry: + surface: type: z_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 0 # y @@ -71,10 +71,10 @@ boundary_conditions: # Tag z plane - boundary_condition: solver_id: 0 - geometry: + surface: type: z_plane - value: 1.0 - velocity_model: velocity_vs_time + plane_position: 1.0 + velocity_model: time_varying velocity_bc_global_vars: - 0 # x - 0 # y diff --git a/single-node-refactor/input-noh-rz.yaml b/single-node-refactor/input-noh-rz.yaml index 0db957fc5..5db5b6fe7 100644 --- a/single-node-refactor/input-noh-rz.yaml +++ b/single-node-refactor/input-noh-rz.yaml @@ -39,10 +39,10 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: + surface: type: x_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 1 # x - 0 # y @@ -52,10 +52,10 @@ boundary_conditions: # Tag Y plane - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y diff --git a/single-node-refactor/input-noh.yaml b/single-node-refactor/input-noh.yaml index a08e52234..d56edc6e5 100644 --- a/single-node-refactor/input-noh.yaml +++ b/single-node-refactor/input-noh.yaml @@ -39,10 +39,10 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: + surface: type: x_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 1 # x - 0 # y @@ -51,10 +51,10 @@ boundary_conditions: # Tag Y plane - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y @@ -63,10 +63,10 @@ boundary_conditions: # Tag Z plane - boundary_condition: solver_id: 0 - geometry: + surface: type: z_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 0 # y diff --git a/single-node-refactor/input-origin-erosion.yaml b/single-node-refactor/input-origin-erosion.yaml index aed9646d9..460664f37 100644 --- a/single-node-refactor/input-origin-erosion.yaml +++ b/single-node-refactor/input-origin-erosion.yaml @@ -39,10 +39,10 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: + surface: type: x_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 1 # x - 0 # y @@ -51,10 +51,10 @@ boundary_conditions: # Tag Y plane - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y @@ -63,10 +63,10 @@ boundary_conditions: # Tag Z plane - boundary_condition: solver_id: 0 - geometry: + surface: type: z_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 0 # y @@ -78,6 +78,7 @@ materials: eos_model_type: decoupled eos_model: gamma_law_gas # strength_model: none + dissipation_model: MARS dissipation_global_vars: - 1.0 # q1 - 1.0 # q1ex @@ -99,11 +100,14 @@ materials: eos_model_type: decoupled eos_model: gamma_law_gas # strength_model: none + dissipation_model: MARS dissipation_global_vars: - 1.0 # q1 - - 1.333 # q1ex - - 1.0 # q2 + - 1.0 # q1ex + - 1.333 # q2 - 1.333 # q2ex + - 0.0 # phi_min + - 1.0 # phi_curl_min eos_global_vars: - 1.666666666666667 - 1.0E-14 diff --git a/single-node-refactor/input-rz-polar.yaml b/single-node-refactor/input-rz-polar.yaml index 34fc384f1..c7aaee402 100644 --- a/single-node-refactor/input-rz-polar.yaml +++ b/single-node-refactor/input-rz-polar.yaml @@ -44,10 +44,10 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: + surface: type: x_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 1 # x - 0 # y @@ -56,10 +56,10 @@ boundary_conditions: # Tag Y plane - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y @@ -68,18 +68,18 @@ boundary_conditions: # Tag inner circle - boundary_condition: solver_id: 0 - geometry: + surface: type: cylinder - value: 0.025 - velocity_model: zero_velocity + radius: 0.025 + velocity_model: fixed # Tag outer circle - boundary_condition: solver_id: 0 - geometry: + surface: type: cylinder - value: 1.2 - velocity_model: zero_velocity + radius: 1.2 + velocity_model: fixed materials: - material: diff --git a/single-node-refactor/input-rz.yaml b/single-node-refactor/input-rz.yaml index d20313128..97de23fa1 100644 --- a/single-node-refactor/input-rz.yaml +++ b/single-node-refactor/input-rz.yaml @@ -39,10 +39,10 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: + surface: type: x_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 1 # x - 0 # y @@ -52,10 +52,10 @@ boundary_conditions: # Tag Y plane - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y diff --git a/single-node-refactor/input.yaml b/single-node-refactor/input.yaml index 5c32ef077..8668151c4 100644 --- a/single-node-refactor/input.yaml +++ b/single-node-refactor/input.yaml @@ -40,10 +40,10 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: + surface: type: x_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 1 # x - 0 # y @@ -53,10 +53,10 @@ boundary_conditions: # Tag Y plane - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y @@ -65,10 +65,10 @@ boundary_conditions: # Tag z plane - boundary_condition: solver_id: 0 - geometry: + surface: type: z_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 0 # y diff --git a/single-node-refactor/regression_tests/standard_inputs/Abaqus_read.yaml b/single-node-refactor/regression_tests/standard_inputs/Abaqus_read.yaml index d3aa591ba..2d4f989ce 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Abaqus_read.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Abaqus_read.yaml @@ -38,10 +38,10 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: + surface: type: x_plane - value: -4.0 - velocity_model: reflected_velocity + plane_position: -4.0 + velocity_model: reflected velocity_bc_global_vars: - 1 # x - 0 # y @@ -49,10 +49,10 @@ boundary_conditions: - boundary_condition: solver_id: 0 - geometry: + surface: type: x_plane - value: 4.0 - velocity_model: reflected_velocity + plane_position: 4.0 + velocity_model: reflected velocity_bc_global_vars: - 1 # x - 0 # y @@ -61,10 +61,10 @@ boundary_conditions: # Tag Y plane - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: -4.0 - velocity_model: reflected_velocity + plane_position: -4.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y @@ -72,10 +72,10 @@ boundary_conditions: - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: 4.0 - velocity_model: reflected_velocity + plane_position: 4.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y @@ -84,10 +84,10 @@ boundary_conditions: # Tag z plane - boundary_condition: solver_id: 0 - geometry: + surface: type: z_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 0 # y diff --git a/single-node-refactor/regression_tests/standard_inputs/Sedov.yaml b/single-node-refactor/regression_tests/standard_inputs/Sedov.yaml index b3fad8e0f..d0f0c496d 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sedov.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sedov.yaml @@ -29,10 +29,10 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: + surface: type: x_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 1 # x - 0 # y @@ -42,10 +42,10 @@ boundary_conditions: # Tag Y plane - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y @@ -54,10 +54,10 @@ boundary_conditions: # Tag Z plane - boundary_condition: solver_id: 0 - geometry: + surface: type: z_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 0 # y diff --git a/single-node-refactor/regression_tests/standard_inputs/Sedov_Erosion.yaml b/single-node-refactor/regression_tests/standard_inputs/Sedov_Erosion.yaml index 8eb3e8923..aa0f24bdd 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sedov_Erosion.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sedov_Erosion.yaml @@ -39,10 +39,10 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: + surface: type: x_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 1 # x - 0 # y @@ -52,10 +52,10 @@ boundary_conditions: # Tag Y plane - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y @@ -65,10 +65,10 @@ boundary_conditions: # Tag Z plane - boundary_condition: solver_id: 0 - geometry: + surface: type: z_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 0 # y diff --git a/single-node-refactor/regression_tests/standard_inputs/Sedov_Read_Ensight.yaml b/single-node-refactor/regression_tests/standard_inputs/Sedov_Read_Ensight.yaml index 9c3baebec..4493aabd8 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sedov_Read_Ensight.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sedov_Read_Ensight.yaml @@ -26,10 +26,10 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: + surface: type: x_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 1 # x - 0 # y @@ -38,10 +38,10 @@ boundary_conditions: # Tag Y plane - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y @@ -50,10 +50,10 @@ boundary_conditions: # Tag Z plane - boundary_condition: solver_id: 0 - geometry: + surface: type: z_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 0 # y diff --git a/single-node-refactor/regression_tests/standard_inputs/Sedov_rz_polar.yaml b/single-node-refactor/regression_tests/standard_inputs/Sedov_rz_polar.yaml index f8b534a3f..fe5fc1d50 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sedov_rz_polar.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sedov_rz_polar.yaml @@ -44,10 +44,10 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: + surface: type: x_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 1 # x - 0 # y @@ -56,21 +56,22 @@ boundary_conditions: # Tag Y plane - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y + # Tag inner circle - boundary_condition: solver_id: 0 - geometry: + surface: type: cylinder - value: 0.025 - velocity_model: zero_velocity + radius: 0.025 + velocity_model: fixed diff --git a/single-node-refactor/regression_tests/standard_inputs/Sod_X.yaml b/single-node-refactor/regression_tests/standard_inputs/Sod_X.yaml index fbc4b56ec..cca718495 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sod_X.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sod_X.yaml @@ -28,10 +28,10 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: + surface: type: x_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 1 # x - 0 # y @@ -41,10 +41,10 @@ boundary_conditions: # Tag Y plane - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y @@ -53,10 +53,10 @@ boundary_conditions: # Tag Z plane - boundary_condition: solver_id: 0 - geometry: + surface: type: z_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 0 # y @@ -66,10 +66,10 @@ boundary_conditions: # Tag X=1 plane - boundary_condition: solver_id: 0 - geometry: + surface: type: x_plane - value: 1.0 - velocity_model: reflected_velocity + plane_position: 1.0 + velocity_model: reflected velocity_bc_global_vars: - 1 # x - 0 # y @@ -79,10 +79,10 @@ boundary_conditions: # Tag Y=0.01 plane - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: 0.01 - velocity_model: reflected_velocity + plane_position: 0.01 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y @@ -91,10 +91,10 @@ boundary_conditions: # Tag z=0.01 plane - boundary_condition: solver_id: 0 - geometry: + surface: type: z_plane - value: 0.01 - velocity_model: reflected_velocity + plane_position: 0.01 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 0 # y diff --git a/single-node-refactor/regression_tests/standard_inputs/Sod_Y.yaml b/single-node-refactor/regression_tests/standard_inputs/Sod_Y.yaml index eb23f749a..85877f697 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sod_Y.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sod_Y.yaml @@ -28,10 +28,10 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: + surface: type: x_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 1 # x - 0 # y @@ -41,10 +41,10 @@ boundary_conditions: # Tag Y plane - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y @@ -53,10 +53,10 @@ boundary_conditions: # Tag Z plane - boundary_condition: solver_id: 0 - geometry: + surface: type: z_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 0 # y @@ -66,10 +66,10 @@ boundary_conditions: # Tag X=0.01 plane - boundary_condition: solver_id: 0 - geometry: + surface: type: x_plane - value: 0.01 - velocity_model: reflected_velocity + plane_position: 0.01 + velocity_model: reflected velocity_bc_global_vars: - 1 # x - 0 # y @@ -79,10 +79,10 @@ boundary_conditions: # Tag y=1.0 plane - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: 1.0 - velocity_model: reflected_velocity + plane_position: 1.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y @@ -91,10 +91,10 @@ boundary_conditions: # Tag z=0.01 plane - boundary_condition: solver_id: 0 - geometry: + surface: type: z_plane - value: 0.01 - velocity_model: reflected_velocity + plane_position: 0.01 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 0 # y diff --git a/single-node-refactor/regression_tests/standard_inputs/Sod_Z.yaml b/single-node-refactor/regression_tests/standard_inputs/Sod_Z.yaml index 1c6033f85..6726694c7 100644 --- a/single-node-refactor/regression_tests/standard_inputs/Sod_Z.yaml +++ b/single-node-refactor/regression_tests/standard_inputs/Sod_Z.yaml @@ -28,10 +28,10 @@ boundary_conditions: # Tag X plane - boundary_condition: solver_id: 0 - geometry: + surface: type: x_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 1 # x - 0 # y @@ -41,10 +41,10 @@ boundary_conditions: # Tag Y plane - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y @@ -53,10 +53,10 @@ boundary_conditions: # Tag Z plane - boundary_condition: solver_id: 0 - geometry: + surface: type: z_plane - value: 0.0 - velocity_model: reflected_velocity + plane_position: 0.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 0 # y @@ -66,10 +66,10 @@ boundary_conditions: # Tag X=0.01 plane - boundary_condition: solver_id: 0 - geometry: + surface: type: x_plane - value: 0.01 - velocity_model: reflected_velocity + plane_position: 0.01 + velocity_model: reflected velocity_bc_global_vars: - 1 # x - 0 # y @@ -78,10 +78,10 @@ boundary_conditions: # Tag Y=0.01 plane - boundary_condition: solver_id: 0 - geometry: + surface: type: y_plane - value: 0.01 - velocity_model: reflected_velocity + plane_position: 0.01 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 1 # y @@ -90,10 +90,10 @@ boundary_conditions: # Tag z=1.0 plane - boundary_condition: solver_id: 0 - geometry: + surface: type: z_plane - value: 1.0 - velocity_model: reflected_velocity + plane_position: 1.0 + velocity_model: reflected velocity_bc_global_vars: - 0 # x - 0 # y diff --git a/single-node-refactor/src/common/include/boundary_conditions.h b/single-node-refactor/src/common/include/boundary_conditions.h index cb443de2d..d05fbf903 100644 --- a/single-node-refactor/src/common/include/boundary_conditions.h +++ b/single-node-refactor/src/common/include/boundary_conditions.h @@ -44,7 +44,7 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace boundary_conditions { -// supported geometry for boundary conditions +// supported surface geometry for boundary conditions enum BdyTag { xPlane = 0, // tag an x-plane @@ -85,7 +85,7 @@ enum BCFcnLocation } // end of boundary conditions namespace -static std::map bc_geometry_map +static std::map bc_surface_map { { "x_plane", boundary_conditions::xPlane }, { "y_plane", boundary_conditions::yPlane }, @@ -98,13 +98,13 @@ static std::map bc_geometry_map static std::map bc_velocity_model_map { - { "no_velocity", boundary_conditions::noVelocityBC }, - { "constant_velocity", boundary_conditions::constantVelocityBC }, - { "velocity_vs_time", boundary_conditions::timeVaringVelocityBC }, - { "reflected_velocity", boundary_conditions::reflectedVelocityBC }, - { "zero_velocity", boundary_conditions::zeroVelocityBC }, - { "user_defined_velocity", boundary_conditions::userDefinedVelocityBC }, - { "piston_velocity", boundary_conditions::pistonVelocityBC } + { "none", boundary_conditions::noVelocityBC }, + { "constant", boundary_conditions::constantVelocityBC }, + { "time_varying", boundary_conditions::timeVaringVelocityBC }, + { "reflected", boundary_conditions::reflectedVelocityBC }, + { "fixed", boundary_conditions::zeroVelocityBC }, + { "user_defined", boundary_conditions::userDefinedVelocityBC }, + { "piston", boundary_conditions::pistonVelocityBC } }; // future options // { "displacement", boundary_conditions::displacementBC }, @@ -131,9 +131,9 @@ static std::map bc_location_map ///////////////////////////////////////////////////////////////////////////// struct BoundaryConditionSetup_t { - boundary_conditions::BdyTag geometry; ///< Geometry boundary condition is applied to, e.g., sphere, plane + boundary_conditions::BdyTag surface; ///< Geometry boundary condition is applied to, e.g., sphere, plane double origin[3] = { 0.0, 0.0, 0.0 }; ///< origin of surface being tagged, e.g., sphere or cylinder surface - double value = 0.0; ///< value = position, radius, etc. defining the geometric shape + double value = 0.0; ///< value = position, radius, etc. defining the surface geometric shape }; // end boundary condition setup ///////////////////////////////////////////////////////////////////////////// @@ -220,15 +220,16 @@ static std::vector str_bc_inps { "solver_id", "velocity_model", - "geometry", + "surface", "velocity_bc_global_vars" }; -// subfields under geometery -static std::vector str_bc_geometry_inps +// subfields under surface +static std::vector str_bc_surface_inps { "type", - "value", + "plane_position", + "radius", "origin" }; @@ -238,7 +239,7 @@ static std::vector str_bc_geometry_inps static std::vector bc_required_inps { }; -static std::vector bc_geometery_required_inps +static std::vector bc_surface_required_inps { }; diff --git a/single-node-refactor/src/common/src/geometry_new.cpp b/single-node-refactor/src/common/src/geometry_new.cpp index eee926a97..7ca84e85a 100644 --- a/single-node-refactor/src/common/src/geometry_new.cpp +++ b/single-node-refactor/src/common/src/geometry_new.cpp @@ -723,7 +723,7 @@ void tag_bdys(const BoundaryCondition_t& boundary, FOR_ALL(bdy_set, 0, mesh.num_bdy_sets, { // tag boundaries - int bc_tag_id = boundary.BoundaryConditionSetup(bdy_set).geometry; + int bc_tag_id = boundary.BoundaryConditionSetup(bdy_set).surface; double val = boundary.BoundaryConditionSetup(bdy_set).value; double orig_x = boundary.BoundaryConditionSetup(bdy_set).origin[0]; double orig_y = boundary.BoundaryConditionSetup(bdy_set).origin[1]; diff --git a/single-node-refactor/src/input/parse_yaml.cpp b/single-node-refactor/src/input/parse_yaml.cpp index 262fdb310..4463e0c93 100644 --- a/single-node-refactor/src/input/parse_yaml.cpp +++ b/single-node-refactor/src/input/parse_yaml.cpp @@ -349,7 +349,6 @@ void validate_inputs( // validate input: user_inputs match words in the str_valid_inputs if (std::find(str_valid_inputs.begin(), str_valid_inputs.end(), var_name) == str_valid_inputs.end()) { std::cout << "ERROR: invalid input: " << var_name << std::endl; - throw std::runtime_error("**** Exiting validate input. Missing required inputs ****"); } // end if variable exists } // end for item in this yaml input @@ -2485,6 +2484,8 @@ void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions, const for (const auto& pair : map) { std::cout << "\t" << pair.first << std::endl; } + + throw std::runtime_error("**** Boundary Condition Velocity Model Not Understood ****"); } // end if } // type // get boundary condition direction @@ -2510,60 +2511,68 @@ void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions, const for (const auto& pair : map) { std::cout << "\t" << pair.first << std::endl; } + throw std::runtime_error("**** Boundary Conditions Not Understood ****"); } // end if } // direction - // get boundary condition geometry - else if (a_word.compare("geometry") == 0) { + // get boundary condition surface geometry + else if (a_word.compare("surface") == 0) { // ----- - // loop over the sub fields under geometry + // loop over the sub fields under surface // ----- - Yaml::Node& inps_subfields_yaml = bc_yaml[bc_id]["boundary_condition"]["geometry"]; + Yaml::Node& inps_subfields_yaml = bc_yaml[bc_id]["boundary_condition"]["surface"]; // get the bc_geometery variables names set by the user - std::vector user_bc_geometry_inputs; + std::vector user_bc_surface_inputs; // extract words from the input file and validate they are correct - validate_inputs(inps_subfields_yaml, user_bc_geometry_inputs, str_bc_geometry_inps, bc_geometery_required_inps); + validate_inputs(inps_subfields_yaml, user_bc_surface_inputs, str_bc_surface_inps, bc_surface_required_inps); // loop over the subfield words - for(auto& a_subfield_word : user_bc_geometry_inputs){ + for(auto& a_subfield_word : user_bc_surface_inputs){ if (a_subfield_word.compare("type") == 0){ - std::string geometry = bc_yaml[bc_id]["boundary_condition"]["geometry"][a_subfield_word].As(); + std::string surface = bc_yaml[bc_id]["boundary_condition"]["surface"][a_subfield_word].As(); - auto map = bc_geometry_map; + auto map = bc_surface_map; - // set the geometry - if (map.find(geometry) != map.end()) { - auto bc_geometry = map[geometry]; + // set the surface + if (map.find(surface) != map.end()) { + auto bc_surface = map[surface]; RUN({ - BoundaryConditions.BoundaryConditionSetup(bc_id).geometry = bc_geometry; + BoundaryConditions.BoundaryConditionSetup(bc_id).surface = bc_surface; }); if (VERBOSE) { - std::cout << "\tgeometry = " << geometry << std::endl; + std::cout << "\tsurface = " << surface << std::endl; } } else{ - std::cout << "ERROR: invalid boundary condition option input in YAML file: " << geometry << std::endl; + std::cout << "ERROR: invalid boundary condition option input in YAML file: " << surface << std::endl; std::cout << "Valid options are: " << std::endl; for (const auto& pair : map) { std::cout << "\t" << pair.first << std::endl; } + throw std::runtime_error("**** Boundary Condition Surface Inputs Not Understood ****"); } // end if } // end if type - else if (a_subfield_word.compare("value") == 0) { - double value = bc_yaml[bc_id]["boundary_condition"]["geometry"][a_subfield_word].As(); + else if (a_subfield_word.compare("plane_position") == 0) { + double value = bc_yaml[bc_id]["boundary_condition"]["surface"][a_subfield_word].As(); + RUN({ + BoundaryConditions.BoundaryConditionSetup(bc_id).value = value; + }); + } // end if value + else if (a_subfield_word.compare("radius") == 0) { + double value = bc_yaml[bc_id]["boundary_condition"]["surface"][a_subfield_word].As(); RUN({ BoundaryConditions.BoundaryConditionSetup(bc_id).value = value; }); } // end if value else if (a_subfield_word.compare("origin") == 0) { - std::string origin = bc_yaml[bc_id]["boundary_condition"]["geometry"][a_subfield_word].As(); + std::string origin = bc_yaml[bc_id]["boundary_condition"]["surface"][a_subfield_word].As(); if (VERBOSE) { std::cout << "\torigin = " << origin << std::endl; } @@ -2602,14 +2611,14 @@ void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions, const // word is unknown std::cout << "ERROR: invalid input under boundary condition geometery: " << a_subfield_word << std::endl; std::cout << "Valid options are: " << std::endl; - for (const auto& element : str_bc_geometry_inps) { + for (const auto& element : str_bc_surface_inps) { std::cout << element << std::endl; } throw std::runtime_error("**** Boundary Conditions Not Understood ****"); } } // end loop over words in the subfield - } // geometry + } // surface // set the value else if (a_word.compare("velocity_bc_global_vars") == 0) { Yaml::Node & vel_bc_global_vars_yaml = bc_yaml[bc_id]["boundary_condition"][a_word]; @@ -2653,7 +2662,7 @@ void parse_bcs(Yaml::Node& root, BoundaryCondition_t& BoundaryConditions, const // add checks for velocity vs time boundary condition - + } // end loop over BCs specified