Skip to content

Commit

Permalink
Rename subsection and function
Browse files Browse the repository at this point in the history
Co-authored-by: hepap <[email protected]>
Co-authored-by: Bruno Blais <[email protected]>
  • Loading branch information
3 people committed Mar 4, 2024
1 parent 078cc2b commit ab44eac
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ subsection boundary conditions heat transfer
end

#---------------------------------------------------
# Constrain Solid Domain
# Constrain Stasis
#---------------------------------------------------

subsection constrain solid domain
subsection constrain stasis
set enable = true
set number of constraints = 1
subsection constraint 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ subsection boundary conditions heat transfer
end

#---------------------------------------------------
# Constrain Solid Domain
# Constrain Stasis
#---------------------------------------------------

subsection constrain solid domain
subsection constrain stasis
set enable = true
set number of constraints = 2
subsection constraint 0
Expand Down
2 changes: 1 addition & 1 deletion doc/source/parameters/cfd/cfd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ General, CFD and Multiphysics
boundary_conditions_multiphysics
box_refinement
cahn_hilliard
constrain_solid_domain
constrain_stasis
dimensionality
dynamic_flow_control
fem
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=======================
Constrain Solid Domain
=======================
=================
Constrain Stasis
=================

This subsection is used to define temperature-dependent solid domains within a defined fluid.
Homogenous constraints are applied on velocity and pressure degrees of freedom of cells found within the prescribed temperature range to mimic a solid.
Expand All @@ -12,7 +12,7 @@ The subsection with default parameters goes as follows:

.. code-block:: text
subsection constrain solid domain
subsection constrain stasis
set enable = false
set number of constraints = 0
subsection constraint 0
Expand Down
28 changes: 14 additions & 14 deletions include/solvers/navier_stokes_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ using namespace dealii;
* @param[in] filtered_phase_fraction_tolerance Tolerance applied on filtered
* phase fraction.
*/
struct SolidDomainConstraint
struct StasisConstraint
{
SolidDomainConstraint(const unsigned int fluid_id,
const double min_solid_temperature,
const double max_solid_temperature,
const double filtered_phase_fraction_tolerance)
StasisConstraint(const unsigned int fluid_id,
const double min_solid_temperature,
const double max_solid_temperature,
const double filtered_phase_fraction_tolerance)
: fluid_id(fluid_id)
, min_solid_temperature(min_solid_temperature)
, max_solid_temperature(max_solid_temperature)
Expand Down Expand Up @@ -478,32 +478,32 @@ class NavierStokesBase : public PhysicsSolver<VectorType>
* @param[in] local_temperature_values Cell's local temperature values at
* quadrature points.
*
* @param[in,out] solid_domain_constraint_struct Struct containing flagged DOF
* @param[in,out] stasis_constraint_struct Struct containing flagged DOF
* containers, temperature range information and fluid id.
*/
void
add_flags_and_constrain_velocity(
const std::vector<types::global_dof_index> &local_dof_indices,
const std::vector<double> &local_temperature_values,
SolidDomainConstraint &solid_domain_constraint_struct);
StasisConstraint &stasis_constraint_struct);

/**
* @brief Check if solid cells are connected to fluid ones and constrain null
* pressure DOFs if they are not.
*
* The check is done by looking if the global DOF indices are located in the
* flag containers (@p dofs_are_in_solid and @p dofs_are_connected_to_fluid)
* of @p solid_domain_constraint_struct.
* of @p stasis_constraint_struct.
*
* @param[in] solid_domain_constraint_struct Struct containing flagged DOF
* @param[in] stasis_constraint_struct Struct containing flagged DOF
* containers, temperature range information and fluid id.
*
* @param[in,out] local_dof_indices Vector for storing a cell's local DOF
* indices.
*/
void
check_and_constrain_pressure(
const SolidDomainConstraint &solid_domain_constraint_struct,
const StasisConstraint &stasis_constraint_struct,
std::vector<types::global_dof_index> &local_dof_indices);

/**
Expand Down Expand Up @@ -717,7 +717,7 @@ class NavierStokesBase : public PhysicsSolver<VectorType>
* physic.
*/
void
constrain_solid_domain(const DoFHandler<dim> *dof_handler_ht);
constrain_stasis_with_temperature(const DoFHandler<dim> *dof_handler_ht);

/**
* @brief Constrain fluids' subdomains according to the temperature field to
Expand All @@ -730,8 +730,8 @@ class NavierStokesBase : public PhysicsSolver<VectorType>
* physic.
*/
void
constrain_solid_domain_vof(const DoFHandler<dim> *dof_handler_vof,
const DoFHandler<dim> *dof_handler_ht);
constrain_stasis_with_temperature_vof(const DoFHandler<dim> *dof_handler_vof,
const DoFHandler<dim> *dof_handler_ht);

/**
* @brief write_checkpoint
Expand Down Expand Up @@ -870,7 +870,7 @@ class NavierStokesBase : public PhysicsSolver<VectorType>
std::shared_ptr<FEValues<dim>> fe_values_vof;
/// Vector containing solid domain constraint structs for
/// temperature-dependent solid domain constraints in VOF simulations
std::vector<SolidDomainConstraint> solid_domain_constraint_structs;
std::vector<StasisConstraint> stasis_constraint_structs;
/// Dynamic homogeneous constraints used for temperature-dependent solid
/// domain constraints
AffineConstraints<double> dynamic_zero_constraints;
Expand Down
4 changes: 2 additions & 2 deletions source/core/parameters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ namespace Parameters
dealii::ParameterHandler &prm,
const unsigned int number_of_constraints)
{
prm.enter_subsection("constrain solid domain");
prm.enter_subsection("constrain stasis");
{
prm.declare_entry(
"enable",
Expand Down Expand Up @@ -564,7 +564,7 @@ namespace Parameters
void
ConstrainSolidDomain::parse_parameters(dealii::ParameterHandler &prm)
{
prm.enter_subsection("constrain solid domain");
prm.enter_subsection("constrain stasis");
{
this->enable = prm.get_bool("enable");
this->number_of_constraints = prm.get_integer("number of constraints");
Expand Down
13 changes: 7 additions & 6 deletions source/solvers/gls_navier_stokes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,13 @@ GLSNavierStokesSolver<dim>::define_dynamic_zero_constraints()
this->multiphysics->get_dof_handler(PhysicsID::heat_transfer);

if (!this->simulation_parameters.multiphysics.VOF)
this->constrain_solid_domain(dof_handler_ht);
this->constrain_stasis_with_temperature(dof_handler_ht);
else
{
const DoFHandler<dim> *dof_handler_vof =
this->multiphysics->get_dof_handler(PhysicsID::VOF);
this->constrain_solid_domain_vof(dof_handler_vof, dof_handler_ht);
this->constrain_stasis_with_temperature_vof(dof_handler_vof,
dof_handler_ht);
}

this->dynamic_zero_constraints.merge(
Expand All @@ -414,11 +415,11 @@ GLSNavierStokesSolver<dim>::define_dynamic_zero_constraints()
this->dynamic_zero_constraints.close();

// Clear sets for next time step
for (SolidDomainConstraint &solid_domain_constraint_struct :
this->solid_domain_constraint_structs)
for (StasisConstraint &stasis_constraint_struct :
this->stasis_constraint_structs)
{
solid_domain_constraint_struct.dofs_are_in_solid.clear();
solid_domain_constraint_struct.dofs_are_connected_to_fluid.clear();
stasis_constraint_struct.dofs_are_in_solid.clear();
stasis_constraint_struct.dofs_are_connected_to_fluid.clear();
}
}

Expand Down
60 changes: 28 additions & 32 deletions source/solvers/navier_stokes_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -623,22 +623,21 @@ NavierStokesBase<dim, VectorType, DofsType>::
if (!this->simulation_parameters.constrain_solid_domain.enable)
return;

// Initialize SolidDomainConstraint structs for each constraint
// Initialize StasisConstraint structs for each constraint
for (unsigned int c_id = 0;
c_id <
this->simulation_parameters.constrain_solid_domain.number_of_constraints;
c_id++)
{
SolidDomainConstraint solid_domain_constraint_struct(
StasisConstraint stasis_constraint_struct(
this->simulation_parameters.constrain_solid_domain.fluid_ids[c_id],
this->simulation_parameters.constrain_solid_domain
.temperature_min_values[c_id],
this->simulation_parameters.constrain_solid_domain
.temperature_max_values[c_id],
this->simulation_parameters.constrain_solid_domain
.filtered_phase_fraction_tolerance[c_id]);
this->solid_domain_constraint_structs.push_back(
solid_domain_constraint_struct);
this->stasis_constraint_structs.push_back(stasis_constraint_struct);
}

// For temperature-dependent constraints
Expand Down Expand Up @@ -1821,16 +1820,16 @@ NavierStokesBase<dim, VectorType, DofsType>::establish_solid_domain(

template <int dim, typename VectorType, typename DofsType>
void
NavierStokesBase<dim, VectorType, DofsType>::constrain_solid_domain(
NavierStokesBase<dim, VectorType, DofsType>::constrain_stasis_with_temperature(
const DoFHandler<dim> *dof_handler_ht)
{
const unsigned int dofs_per_cell = this->fe->dofs_per_cell;
std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);

// Get struct containing temperature range information and flag
// containers for DOFs.
SolidDomainConstraint &solid_domain_constraint_struct =
this->solid_domain_constraint_structs[0];
StasisConstraint &stasis_constraint_struct =
this->stasis_constraint_structs[0];

// Get temperature solution
const auto temperature_solution =
Expand All @@ -1848,18 +1847,17 @@ NavierStokesBase<dim, VectorType, DofsType>::constrain_solid_domain(
local_temperature_values);
add_flags_and_constrain_velocity(local_dof_indices,
local_temperature_values,
solid_domain_constraint_struct);
stasis_constraint_struct);
}
}
check_and_constrain_pressure(solid_domain_constraint_struct,
local_dof_indices);
check_and_constrain_pressure(stasis_constraint_struct, local_dof_indices);
}

template <int dim, typename VectorType, typename DofsType>
void
NavierStokesBase<dim, VectorType, DofsType>::constrain_solid_domain_vof(
const DoFHandler<dim> *dof_handler_vof,
const DoFHandler<dim> *dof_handler_ht)
NavierStokesBase<dim, VectorType, DofsType>::
constrain_stasis_with_temperature_vof(const DoFHandler<dim> *dof_handler_vof,
const DoFHandler<dim> *dof_handler_ht)
{
const unsigned int dofs_per_cell = this->fe->dofs_per_cell;
std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
Expand All @@ -1877,8 +1875,8 @@ NavierStokesBase<dim, VectorType, DofsType>::constrain_solid_domain_vof(

// Loop over structs containing fluid id, temperature range information and
// flag containers for DOFs.
for (SolidDomainConstraint &solid_domain_constraint_struct :
this->solid_domain_constraint_structs)
for (StasisConstraint &stasis_constraint_struct :
this->stasis_constraint_structs)
{
for (const auto &cell : dof_handler.active_cell_iterators())
{
Expand All @@ -1899,9 +1897,9 @@ NavierStokesBase<dim, VectorType, DofsType>::constrain_solid_domain_vof(
for (const double &filtered_phase_fraction :
local_filtered_phase_fraction_values)
{
if (abs(solid_domain_constraint_struct.fluid_id -
if (abs(stasis_constraint_struct.fluid_id -
filtered_phase_fraction) >=
solid_domain_constraint_struct
stasis_constraint_struct
.filtered_phase_fraction_tolerance)
{
cell_is_in_right_fluid = false;
Expand All @@ -1916,7 +1914,7 @@ NavierStokesBase<dim, VectorType, DofsType>::constrain_solid_domain_vof(
{
flag_dofs_connected_to_fluid(
local_dof_indices,
solid_domain_constraint_struct.dofs_are_connected_to_fluid);
stasis_constraint_struct.dofs_are_connected_to_fluid);
continue;
}

Expand All @@ -1926,11 +1924,10 @@ NavierStokesBase<dim, VectorType, DofsType>::constrain_solid_domain_vof(
local_temperature_values);
add_flags_and_constrain_velocity(local_dof_indices,
local_temperature_values,
solid_domain_constraint_struct);
stasis_constraint_struct);
}
}
check_and_constrain_pressure(solid_domain_constraint_struct,
local_dof_indices);
check_and_constrain_pressure(stasis_constraint_struct, local_dof_indices);
}
}

Expand All @@ -1939,18 +1936,18 @@ void
NavierStokesBase<dim, VectorType, DofsType>::add_flags_and_constrain_velocity(
const std::vector<types::global_dof_index> &local_dof_indices,
const std::vector<double> &local_temperature_values,
SolidDomainConstraint &solid_domain_constraint_struct)
StasisConstraint &stasis_constraint_struct)
{
bool cell_is_solid = false;

// Flag cell if the cell is solid and constrain its velocity DOFs
for (const double &temperature : local_temperature_values)
{
if (temperature >= solid_domain_constraint_struct.min_solid_temperature &&
temperature <= solid_domain_constraint_struct.max_solid_temperature)
if (temperature >= stasis_constraint_struct.min_solid_temperature &&
temperature <= stasis_constraint_struct.max_solid_temperature)
{
flag_dofs_in_solid(local_dof_indices,
solid_domain_constraint_struct.dofs_are_in_solid);
stasis_constraint_struct.dofs_are_in_solid);
constrain_solid_cell_velocity_dofs(false,
local_dof_indices,
this->dynamic_zero_constraints);
Expand All @@ -1963,28 +1960,27 @@ NavierStokesBase<dim, VectorType, DofsType>::add_flags_and_constrain_velocity(
// be constrained.
if (!cell_is_solid)
flag_dofs_connected_to_fluid(
local_dof_indices,
solid_domain_constraint_struct.dofs_are_connected_to_fluid);
local_dof_indices, stasis_constraint_struct.dofs_are_connected_to_fluid);
}

template <int dim, typename VectorType, typename DofsType>
void
NavierStokesBase<dim, VectorType, DofsType>::check_and_constrain_pressure(
const SolidDomainConstraint &solid_domain_constraint_struct,
const StasisConstraint &stasis_constraint_struct,
std::vector<types::global_dof_index> &local_dof_indices)
{
for (const auto &cell : dof_handler.active_cell_iterators())
{
if (cell->is_locally_owned() || cell->is_ghost())
{
cell->get_dof_indices(local_dof_indices);
bool cell_is_solid = check_cell_is_in_solid(
solid_domain_constraint_struct.dofs_are_in_solid,
local_dof_indices);
bool cell_is_solid =
check_cell_is_in_solid(stasis_constraint_struct.dofs_are_in_solid,
local_dof_indices);
if (cell_is_solid)
{
bool connected_to_fluid = check_cell_is_connected_to_fluid(
solid_domain_constraint_struct.dofs_are_connected_to_fluid,
stasis_constraint_struct.dofs_are_connected_to_fluid,
local_dof_indices);
if (!connected_to_fluid)
{
Expand Down

0 comments on commit ab44eac

Please sign in to comment.