Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move boundary conditions of all fluid dynamics solvers to base class #1313

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to the Lethe project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/).

## [Master] - 2024-10-09

### Changed

- MAJOR The boundary conditions for the fluid dynamics applications: matrix-based, matrix-free and block applications are now implemented only in the NavierStokesBase class. [#1313](https://github.com/chaos-polymtl/lethe/pull/1313)

## [Master] - 2024-10-04

### Changed
Expand Down
18 changes: 0 additions & 18 deletions include/solvers/fluid_dynamics_matrix_based.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ class FluidDynamicsMatrixBased
virtual void
setup_dofs_fd() override;

/**
* @brief update non zero constraint if the boundary is time-dependent
*/
void
update_boundary_conditions();

/**
* @brief Sets the initial condition for the solver
*
Expand Down Expand Up @@ -102,18 +96,6 @@ class FluidDynamicsMatrixBased
void
setup_preconditioner() override;

/**
* @brief Define the non-zero constraints used to solve the problem.
*/
void
define_non_zero_constraints();

/**
* @brief Define the zero constraints used to solve the problem.
*/
void
define_zero_constraints();

/**
* @brief Define the zero constraints used to solved the problem that change
* with other physics' solutions.
Expand Down
18 changes: 0 additions & 18 deletions include/solvers/fluid_dynamics_matrix_free.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,6 @@ class FluidDynamicsMatrixFree
virtual void
setup_dofs_fd() override;

/**
* @brief Update non zero constraints if the boundary is time dependent.
*/
void
update_boundary_conditions();

/**
* @brief Set the initial conditions for the solver. If the simulation is
* restarted from a checkpoint, the initial solution setting is bypassed
Expand Down Expand Up @@ -370,18 +364,6 @@ class FluidDynamicsMatrixFree
void
calculate_time_derivative_previous_solutions();

/**
* @brief Define the non-zero constraints used to solve the problem.
*/
void
define_non_zero_constraints();

/**
* @brief Define the zero constraints used to solve the problem.
*/
void
define_zero_constraints();

/**
* @brief Set up appropriate preconditioner.
*
Expand Down
19 changes: 19 additions & 0 deletions include/solvers/navier_stokes_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,25 @@ class NavierStokesBase : public PhysicsSolver<VectorType>
void
set_nodal_values();

/**
* @brief Define the non-zero constraints used to solve the problem.
*/
void
define_non_zero_constraints();

/**
* @brief Define the zero constraints used to solve the problem.
*/
void
define_zero_constraints();

/**
* @brief Update non-zero constraints if the boundary is time dependent.
* Note: not implemented for the block fluid dynamics application.
*/
void
update_boundary_conditions();

/**
* @brief Check if a specifique boundary condition exist
* @param bc, the boundary type that we want to check if it exists
Expand Down
143 changes: 25 additions & 118 deletions source/solvers/fluid_dynamics_block.cc
Original file line number Diff line number Diff line change
Expand Up @@ -581,125 +581,32 @@ FluidDynamicsBlock<dim>::setup_dofs_fd()
FEValuesExtractors::Vector velocities(0);

// Non-zero constraints
auto &nonzero_constraints = this->nonzero_constraints;
{
nonzero_constraints.clear();
nonzero_constraints.reinit(locally_relevant_dofs_acquisition);


DoFTools::make_hanging_node_constraints(this->dof_handler,
nonzero_constraints);
for (unsigned int i_bc = 0;
i_bc < this->simulation_parameters.boundary_conditions.size;
++i_bc)
{
if (this->simulation_parameters.boundary_conditions.type[i_bc] ==
BoundaryConditions::BoundaryType::noslip)
{
VectorTools::interpolate_boundary_values(
*this->mapping,
this->dof_handler,
this->simulation_parameters.boundary_conditions.id[i_bc],
dealii::Functions::ZeroFunction<dim>(dim + 1),
nonzero_constraints,
this->fe->component_mask(velocities));
}
else if (this->simulation_parameters.boundary_conditions.type[i_bc] ==
BoundaryConditions::BoundaryType::slip)
{
std::set<types::boundary_id> no_normal_flux_boundaries;
no_normal_flux_boundaries.insert(
this->simulation_parameters.boundary_conditions.id[i_bc]);
VectorTools::compute_no_normal_flux_constraints(
this->dof_handler,
0,
no_normal_flux_boundaries,
nonzero_constraints);
}
else if (this->simulation_parameters.boundary_conditions.type[i_bc] ==
BoundaryConditions::BoundaryType::function)
{
VectorTools::interpolate_boundary_values(
*this->mapping,
this->dof_handler,
this->simulation_parameters.boundary_conditions.id[i_bc],
NavierStokesFunctionDefined<dim>(
&this->simulation_parameters.boundary_conditions
.bcFunctions[i_bc]
.u,
&this->simulation_parameters.boundary_conditions
.bcFunctions[i_bc]
.v,
&this->simulation_parameters.boundary_conditions
.bcFunctions[i_bc]
.w),
nonzero_constraints,
this->fe->component_mask(velocities));
}

else if (this->simulation_parameters.boundary_conditions.type[i_bc] ==
BoundaryConditions::BoundaryType::periodic)
{
DoFTools::make_periodicity_constraints(
this->dof_handler,
this->simulation_parameters.boundary_conditions.id[i_bc],
this->simulation_parameters.boundary_conditions.periodic_id[i_bc],
this->simulation_parameters.boundary_conditions
.periodic_direction[i_bc],
nonzero_constraints);
}
}
}
nonzero_constraints.close();

{
this->zero_constraints.clear();
this->zero_constraints.reinit(locally_relevant_dofs_acquisition);
this->define_non_zero_constraints();

DoFTools::make_hanging_node_constraints(this->dof_handler,
this->zero_constraints);
// Check whether the boundary conditions specified in the parameter file are
// available for this solver
for (unsigned int i_bc = 0;
i_bc < this->simulation_parameters.boundary_conditions.size;
++i_bc)
{
if (this->simulation_parameters.boundary_conditions.type[i_bc] ==
BoundaryConditions::BoundaryType::pressure ||
this->simulation_parameters.boundary_conditions.type[i_bc] ==
BoundaryConditions::BoundaryType::function_weak ||
this->simulation_parameters.boundary_conditions.type[i_bc] ==
BoundaryConditions::BoundaryType::partial_slip ||
this->simulation_parameters.boundary_conditions.type[i_bc] ==
BoundaryConditions::BoundaryType::outlet)
{
Assert(
false,
ExcMessage(
"The following boundary conditions are not supported by the lethe-fluid-block application: pressure, function weak, partial slip and outlet."));
}
}

for (unsigned int i_bc = 0;
i_bc < this->simulation_parameters.boundary_conditions.size;
++i_bc)
{
if (this->simulation_parameters.boundary_conditions.type[i_bc] ==
BoundaryConditions::BoundaryType::slip)
{
std::set<types::boundary_id> no_normal_flux_boundaries;
no_normal_flux_boundaries.insert(
this->simulation_parameters.boundary_conditions.id[i_bc]);
VectorTools::compute_no_normal_flux_constraints(
this->dof_handler,
0,
no_normal_flux_boundaries,
this->zero_constraints);
}
else if (this->simulation_parameters.boundary_conditions.type[i_bc] ==
BoundaryConditions::BoundaryType::periodic)
{
DoFTools::make_periodicity_constraints(
this->dof_handler,
this->simulation_parameters.boundary_conditions.id[i_bc],
this->simulation_parameters.boundary_conditions.periodic_id[i_bc],
this->simulation_parameters.boundary_conditions
.periodic_direction[i_bc],
this->zero_constraints);
}
else // if(nsparam.boundaryConditions.boundaries[i_bc].type==Parameters::noslip
// || Parameters::function)
{
VectorTools::interpolate_boundary_values(
*this->mapping,
this->dof_handler,
this->simulation_parameters.boundary_conditions.id[i_bc],
dealii::Functions::ZeroFunction<dim>(dim + 1),
this->zero_constraints,
this->fe->component_mask(velocities));
}
}
}
this->zero_constraints.close();
// Zero constraints
this->define_zero_constraints();

this->present_solution.reinit(this->locally_owned_dofs,
this->locally_relevant_dofs,
Expand Down Expand Up @@ -739,7 +646,7 @@ FluidDynamicsBlock<dim>::setup_dofs_fd()
DoFTools::make_sparsity_pattern(this->dof_handler,
coupling,
sparsity_pattern,
nonzero_constraints,
this->nonzero_constraints,
true,
Utilities::MPI::this_mpi_process(
MPI_COMM_WORLD));
Expand Down
Loading
Loading