Skip to content

Commit 814a0f0

Browse files
authored
Prescribed motion (#1411)
* Introduce prescribed motion option for mesh motion * Fix various issues with view * Fix rotation bug * Introduce new regression test * Fix format * Fix format on .C * Fix gold file * Fix moving cylinder yaml * Add comments to clarify indices
1 parent 18ac798 commit 814a0f0

7 files changed

Lines changed: 655 additions & 0 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#ifndef MOTIONPRESCRIBEDKERNEL_H
2+
#define MOTIONPRESCRIBEDKERNEL_H
3+
4+
#include "NgpMotion.h"
5+
#include <array>
6+
#include <vector>
7+
8+
namespace sierra {
9+
namespace nalu {
10+
11+
struct MotionValues
12+
{
13+
double time_value = 0.0;
14+
std::array<double, 3> x_disp = {-1e16, -1e16, -1e16};
15+
std::array<double, 3> vel = {0.0, 0.0, 0.0};
16+
std::array<double, 3> angular_vel = {0.0, 0.0, 0.0};
17+
std::array<double, 3> angular_disp = {-1e16, -1e16, -1e16};
18+
};
19+
20+
class MotionPrescribedKernel : public NgpMotionKernel<MotionPrescribedKernel>
21+
{
22+
public:
23+
MotionPrescribedKernel(const YAML::Node&);
24+
25+
MotionPrescribedKernel() = default;
26+
27+
virtual ~MotionPrescribedKernel() = default;
28+
29+
/** Function to compute motion-specific transformation matrix
30+
*
31+
* @param[in] time Current time
32+
* @param[in] xyz Coordinates
33+
* @return Transformation matrix
34+
*/
35+
KOKKOS_FUNCTION
36+
virtual mm::TransMatType
37+
build_transformation(const double& time, const mm::ThreeDVecType& xyz);
38+
39+
/** Function to compute motion-specific velocity
40+
*
41+
* @param[in] time Current time
42+
* @param[in] compTrans Transformation matrix
43+
* including all motions
44+
* @param[in] mxyz Model coordinates
45+
* @param[in] cxyz Transformed coordinates
46+
* @return Velocity vector associated with coordinates
47+
*/
48+
KOKKOS_FUNCTION
49+
virtual mm::ThreeDVecType compute_velocity(
50+
const double& time,
51+
const mm::TransMatType& compTrans,
52+
const mm::ThreeDVecType& mxyz,
53+
const mm::ThreeDVecType& cxyz);
54+
55+
private:
56+
void load(const YAML::Node&);
57+
Kokkos::View<double**> defined_motion_values_;
58+
};
59+
60+
} // namespace nalu
61+
} // namespace sierra
62+
63+
#endif /* MOTIONPRESCRIBEDKERNEL_H */

reg_tests/CTestList.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ if(NOT ENABLE_CUDA AND NOT ENABLE_ROCM)
247247
if (ENABLE_TIOGA AND ENABLE_HYPRE)
248248
add_test_r(oversetRotCylNGPHypre 2)
249249
add_test_r(oversetOscCylNGPHypre 2)
250+
add_test_r(oversetPrescribedCylinder 4)
250251
if (ENABLE_TRILINOS_SOLVERS)
251252
add_test_r(oversetRotCylinderHypre 2)
252253
add_test_r(oversetRotCylMultiRealm 2)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
6.419191047322649e-09 1 0.005
2+
2.861861117289262e-09 2 0.01
3+
2.062491630492124e-09 3 0.015
4+
8.329447081884246e-10 4 0.02
5+
4.362243623884177e-10 5 0.025
Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
Simulations:
2+
- name: sim1
3+
time_integrator: ti_1
4+
optimizer: opt1
5+
6+
linear_solvers:
7+
- name: solve_scalar
8+
type: hypre
9+
method: hypre_gmres
10+
preconditioner: boomerAMG
11+
tolerance: 1e-5
12+
max_iterations: 200
13+
kspace: 25
14+
output_level: 0
15+
bamg_relax_type: 18
16+
bamg_max_levels: 1
17+
18+
- name: solve_cont
19+
type: hypre
20+
method: hypre_gmres
21+
preconditioner: boomerAMG
22+
tolerance: 1e-5
23+
max_iterations: 200
24+
kspace: 5
25+
output_level: 0
26+
27+
28+
realms:
29+
30+
- name: realm_1
31+
mesh: ../../mesh/oversetCylinder.g
32+
automatic_decomposition_type: rcb
33+
use_edges: yes
34+
activate_aura: true
35+
36+
equation_systems:
37+
name: theEqSys
38+
# 3 iterations still causes pressure discontinuity at overset boundary
39+
# 5 iterations is better
40+
max_iterations: 3
41+
decoupled_overset_solve: yes
42+
43+
solver_system_specification:
44+
velocity: solve_scalar
45+
pressure: solve_cont
46+
47+
systems:
48+
49+
- LowMachEOM:
50+
name: myLowMach
51+
max_iterations: 1
52+
convergence_tolerance: 1e-7
53+
54+
initial_conditions:
55+
56+
- constant: ic_1
57+
target_name:
58+
- Unspecified-2-HEX
59+
- Unspecified-3-HEX
60+
value:
61+
pressure: 0.0
62+
velocity: [0.0,0.0,0.0]
63+
64+
material_properties:
65+
target_name:
66+
- Unspecified-2-HEX
67+
- Unspecified-3-HEX
68+
specifications:
69+
- name: density
70+
type: constant
71+
value: 1.00
72+
73+
- name: viscosity
74+
type: constant
75+
value: 0.005
76+
77+
boundary_conditions:
78+
79+
- open_boundary_condition: bc_1
80+
target_name: inlet
81+
open_user_data:
82+
velocity: [0.0,0.0,0.0]
83+
pressure: 0.0
84+
85+
- open_boundary_condition: bc_2
86+
target_name: outlet
87+
open_user_data:
88+
pressure: 0.0
89+
velocity: [0.0,0.0,0.0]
90+
91+
- open_boundary_condition: bc_3
92+
target_name: top
93+
open_user_data:
94+
95+
- open_boundary_condition: bc_4
96+
target_name: bottom
97+
open_user_data:
98+
99+
- wall_boundary_condition: bc_5
100+
target_name: wall
101+
wall_user_data:
102+
user_function_name:
103+
velocity: wind_energy
104+
user_function_string_parameters:
105+
velocity: [interior]
106+
107+
- symmetry_boundary_condition: bc_6
108+
target_name: side11
109+
symmetry_user_data:
110+
111+
- symmetry_boundary_condition: bc_7
112+
target_name: side12
113+
symmetry_user_data:
114+
115+
- symmetry_boundary_condition: bc_8
116+
target_name: side21
117+
symmetry_user_data:
118+
119+
- symmetry_boundary_condition: bc_9
120+
target_name: side22
121+
symmetry_user_data:
122+
123+
- overset_boundary_condition: bc_overset
124+
overset_connectivity_type: tioga
125+
overset_user_data:
126+
tioga_populate_inactive_part: false
127+
tioga_options:
128+
symmetry_direction: 2
129+
set_resolutions: no
130+
mesh_group:
131+
- overset_name: interior
132+
mesh_parts: [ Unspecified-2-HEX ]
133+
wall_parts: [ wall ]
134+
ovset_parts: [ overset1 ]
135+
136+
- overset_name: wake
137+
mesh_parts: [ Unspecified-3-HEX]
138+
139+
mesh_motion:
140+
- name: interior
141+
mesh_parts: [ Unspecified-2-HEX ]
142+
frame: non_inertial
143+
motion:
144+
- type: prescribed
145+
centroid: [0.0, 0.05, 0.0]
146+
variables: [time, x_disp, y_disp, z_disp, x_angular_vel, y_angular_vel, z_angular_vel]
147+
values:
148+
- [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
149+
- [2.0, -1.0, 0.0, 1.0, 0.0, 0.05, 0.0]
150+
- [3.0, 1.0, 0.0, -1.0, 0.0, -0.05, 0.0]
151+
152+
solution_options:
153+
name: myOptions
154+
155+
fix_pressure_at_node:
156+
value: 0.0
157+
node_lookup_type: spatial_location
158+
location: [-5.0, 0.05, -5.0]
159+
search_target_part: [Unspecified-3-HEX]
160+
search_method: stk_kdtree
161+
162+
reduced_sens_cvfem_poisson: yes
163+
164+
options:
165+
166+
- hybrid_factor:
167+
velocity: 1.0
168+
169+
- limiter:
170+
pressure: no
171+
velocity: no
172+
173+
- projected_nodal_gradient:
174+
pressure: element
175+
velocity: element
176+
177+
post_processing:
178+
179+
- type: surface
180+
physics: surface_force_and_moment
181+
output_file_name: oversetMovingCylinder.dat
182+
frequency: 1
183+
parameters: [0,0]
184+
target_name: wall
185+
186+
turbulence_averaging:
187+
time_filter_interval: 100000.0
188+
189+
specifications:
190+
- name: one
191+
target_name: [Unspecified-2-HEX, Unspecified-3-HEX]
192+
compute_q_criterion: yes
193+
compute_vorticity: yes
194+
195+
output:
196+
output_data_base_name: out/oversetMovingCylinder.exo
197+
output_frequency: 1000
198+
output_node_set: no
199+
output_variables:
200+
- velocity
201+
- pressure
202+
- iblank
203+
- iblank_cell
204+
- mesh_displacement
205+
- q_criterion
206+
- vorticity
207+
208+
209+
210+
Time_Integrators:
211+
- StandardTimeIntegrator:
212+
name: ti_1
213+
start_time: 0
214+
termination_step_count: 5
215+
time_step: 0.005
216+
time_stepping_type: fixed
217+
time_step_count: 0
218+
second_order_accuracy: yes
219+
220+
realms:
221+
- realm_1

src/mesh_motion/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ target_sources(nalu PRIVATE
66
${CMAKE_CURRENT_SOURCE_DIR}/MeshTransformationAlg.C
77
${CMAKE_CURRENT_SOURCE_DIR}/MotionDeformingInteriorKernel.C
88
${CMAKE_CURRENT_SOURCE_DIR}/MotionRotationKernel.C
9+
${CMAKE_CURRENT_SOURCE_DIR}/MotionPrescribedKernel.C
910
${CMAKE_CURRENT_SOURCE_DIR}/MotionScalingKernel.C
1011
${CMAKE_CURRENT_SOURCE_DIR}/MotionTranslationKernel.C
1112
${CMAKE_CURRENT_SOURCE_DIR}/MotionOscillationKernel.C

src/mesh_motion/FrameBase.C

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "mesh_motion/MotionDeformingInteriorKernel.h"
55
#include "mesh_motion/MotionScalingKernel.h"
66
#include "mesh_motion/MotionRotationKernel.h"
7+
#include "mesh_motion/MotionPrescribedKernel.h"
78
#include "mesh_motion/MotionTranslationKernel.h"
89
#include "mesh_motion/MotionOscillationKernel.h"
910
#include "mesh_motion/TurbineSurrogateKernel.h"
@@ -81,6 +82,8 @@ FrameBase::load(const YAML::Node& node)
8182
motionKernels_[i].reset(new MotionWavesKernel(meta_, motion_def));
8283
else if (type == "turbine_surrogate")
8384
motionKernels_[i].reset(new TurbineSurrogateKernel(meta_, motion_def));
85+
else if (type == "prescribed")
86+
motionKernels_[i].reset(new MotionPrescribedKernel(motion_def));
8487
else
8588
throw std::runtime_error(
8689
"FrameBase: Invalid mesh motion type: " + type);

0 commit comments

Comments
 (0)