Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
fluid_dynamics_nitsche.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2020-2025 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4#ifndef lethe_fluid_dynamics_nitsche_h
5#define lethe_fluid_dynamics_nitsche_h
6
7#include <core/solid_base.h>
8
10
11using namespace dealii;
12
13/**
14 * A solver class for the Navier-Stokes equation using GLS stabilization
15 * and Nitsche immersed boundary method
16 *
17 * @tparam dim An integer that denotes the dimension of the space in which
18 * the flow is solved
19 *
20 * @ingroup solvers
21 * @author Bruno Blais, 2019
22 */
23
24template <int dim, int spacedim = dim>
26{
27public:
29
30 virtual void
31 solve() override;
32
33private:
34 /**
35 * @brief Adds the nitsche restriction to the global matrix and global rhs on
36 * the cells surrounding the immersed solid
37 */
38 template <bool assemble_matrix>
39 void
41
42 /**
43 * @brief Calculates the force due to the fluid motion on the solid
44 * @return Tensor of forces on the solid
45 */
46 Tensor<1, spacedim>
47 calculate_forces_on_solid(const unsigned int i_solid);
48
49 /**
50 * @brief Calculates the torque due to the fluid motion on the solid
51 * @return Tensor of torque on the solid. This is always a 3D tensor even in
52 * 2D
53 */
54 Tensor<1, 3>
55 calculate_torque_on_solid(const unsigned int i_solid);
56
57 /**
58 * @brief Calculates the torque due to the fluid motion on the solid
59 * @return Tensor of torque on the solid. This is always a 3D tensor even in
60 * 2D
61 */
62 Tensor<1, 3>
64
65 /**
66 * @brief Post-process for forces on solid after an iteration
67 * @param i_solid is the solid index
68 * @param first_solid_forces is a boolean set to true for the first call of
69 * this method, used for table output formatting
70 */
71 void
72 postprocess_solid_forces(const unsigned int i_solid, bool first_solid_forces);
73
74
75 /**
76 * @brief Post-process for torques on solid after an iteration
77 * @param i_solid is the solid index
78 * @param first_solid_torques is a boolean set to true for the first call of
79 * this method, used for table output formatting
80 */
81 void
82 postprocess_solid_torques(const unsigned int i_solid,
83 bool first_solid_torques);
84
85 /**
86 * @brief Call for the assembly of the matrix
87 */
88 virtual void
93
94 /**
95 * @brief Call for the assembly of the right-hand side
96 */
97 virtual void
99 {
100 assemble_rhs();
101 }
102
103 /**
104 * @brief Same as in fluid_dynamics_matrix_based, but calls
105 * assemble_nitsche_restriction() when global matrix and rhs are assembled
106 *
107 * @deprecated This function is to be deprecated when the new assembly
108 * mechanism is integrated to this solver
109 */
110 void
112
113 /**
114 * @brief Same as in fluid_dynamics_matrix_based, but calls
115 * assemble_nitsche_restriction() when rhs is assembled
116 *
117 * @deprecated This function is to be deprecated when the new assembly
118 * mechanism is integrated to this solver
119 */
120 void
121 assemble_rhs();
122
123 /**
124 * @brief Outputs a vtu file for each output frequency of the particles
125 */
126 void
127 output_solid_particles(const unsigned int i_solid);
128 /**
129 * @brief Outputs a vtu file for each output frequency of the solid
130 * triangulation
131 */
132 void
133 output_solid_triangulation(const unsigned int i_solid);
134
135 /**
136 * @brief Allow the refinement of the mesh according to one of the 2 methods
137 * proposed. Overrides the regular mesh adaptation by ensuring that the
138 * Nitsche solids are prepared for adaptation.
139 */
140 virtual void
141 refine_mesh() override;
142
143 /**
144 * @brief Returns a vector of references to TableHandler objects that needs
145 * to be serialized/deserialized for a given solver.
146 *
147 * @return Structure containing a vector of references to TableHandler objects
148 * that needs to be serialized/deserialized for a given solver, and their
149 * corresponding file names.
150 */
151 std::vector<OutputStructTableHandler>
152 gather_tables() override;
153
154 /**
155 * @brief Write a gls_nitsche simulation checkpointing to allow for
156 * gls_nitsche simulation restart
157 */
158 virtual void
159 write_checkpoint() override;
160
161 /**
162 * @brief Read a gls_nitsche simulation checkpoint and initiate simulation
163 * restart
164 */
165 virtual void
166 read_checkpoint() override;
167
168 std::shared_ptr<std::vector<std::shared_ptr<SolidBase<dim, spacedim>>>>
170 std::vector<PVDHandler> pvdhandler_solid_triangulation;
171 std::vector<PVDHandler> pvdhandler_solid_particles;
172
173 std::vector<TableHandler> solid_forces_table;
174 std::vector<TableHandler> solid_torques_table;
175};
176
177
178#endif
FluidDynamicsMatrixBased(SimulationParameters< dim > &nsparam, const FluidDynamicsFormulation fluid_dynamics_formulation=FluidDynamicsFormulation::standard)
Construct the matrix-based Navier-Stokes solver.
FluidDynamicsNitsche(SimulationParameters< spacedim > &nsparam)
void output_solid_triangulation(const unsigned int i_solid)
Outputs a vtu file for each output frequency of the solid triangulation.
void assemble_nitsche_restriction()
Adds the nitsche restriction to the global matrix and global rhs on the cells surrounding the immerse...
void postprocess_solid_torques(const unsigned int i_solid, bool first_solid_torques)
Post-process for torques on solid after an iteration.
std::vector< PVDHandler > pvdhandler_solid_triangulation
std::vector< OutputStructTableHandler > gather_tables() override
Returns a vector of references to TableHandler objects that needs to be serialized/deserialized for a...
Tensor< 1, 3 > calculate_torque_on_solid()
Calculates the torque due to the fluid motion on the solid.
virtual void read_checkpoint() override
Read a gls_nitsche simulation checkpoint and initiate simulation restart.
void output_solid_particles(const unsigned int i_solid)
Outputs a vtu file for each output frequency of the particles.
std::vector< TableHandler > solid_forces_table
void assemble_matrix_and_rhs()
Same as in fluid_dynamics_matrix_based, but calls assemble_nitsche_restriction() when global matrix a...
virtual void assemble_system_matrix() override
Call for the assembly of the matrix.
Tensor< 1, spacedim > calculate_forces_on_solid(const unsigned int i_solid)
Calculates the force due to the fluid motion on the solid.
std::shared_ptr< std::vector< std::shared_ptr< SolidBase< dim, spacedim > > > > solids
virtual void solve() override
solve Solves the Navier-Stokes problem
std::vector< PVDHandler > pvdhandler_solid_particles
virtual void refine_mesh() override
Allow the refinement of the mesh according to one of the 2 methods proposed. Overrides the regular me...
virtual void assemble_system_rhs() override
Call for the assembly of the right-hand side.
virtual void write_checkpoint() override
Write a gls_nitsche simulation checkpointing to allow for gls_nitsche simulation restart.
void postprocess_solid_forces(const unsigned int i_solid, bool first_solid_forces)
Post-process for forces on solid after an iteration.
void assemble_rhs()
Same as in fluid_dynamics_matrix_based, but calls assemble_nitsche_restriction() when rhs is assemble...
std::vector< TableHandler > solid_torques_table