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

Temperature-dependant solid domain constraints #1038

Merged
merged 22 commits into from
Feb 27, 2024

Conversation

AmishgaAlphonius
Copy link
Collaborator

@AmishgaAlphonius AmishgaAlphonius commented Feb 22, 2024

Description of the problem

  • In phase change simulations, the solid domain was treated as a simple fluid with a higher viscosity (viscous penalization). It worked quite well, but it wasn't the most efficient way to compute fluid dynamics quantities.

Description of the solution

  • In order to improve calculation time and linear system conditioning, homogeneous constraints are imposed on velocity DOFs in a defined solid domain through a temperature range. Additionally, pressure DOFs in the same solid domain that are not connected to fluid cells are also imposed to homogeneous constraints. The temperature range is specified through a new parameter subsection, namely constrain solid domain.

How Has This Been Tested?

  • The new feature has been tested on the Melting Cavity example. With solid domain constraints on cells within the temperature range of [0,29] degC, the linear solver solving time of the fluid dynamics physic was reduced by a little more than the half without altering the postprocessed results. This feature will improve greatly computation times of domains with a higher proportion of "solid" phase.
  • The feature was also tested with the restart feature and no issue occurred. Final results were the same as without the restart.
  • An application test has been add to test this feature : applications_tests/lethe-fluid/heat_transfer_phase_change_constrain_solid_domain.prm (.output)

Documentation

  • A new page for the new parameter subsection (constrain solid domain) has been added : doc/source/parameters/cfd/constrain_solid_domain.rst

Future changes

  • The current implementation of this new feature only works with 1 fluid simulations (an exception is thrown when used with VOF or Cahn Hilliard). However, the implementation with VOF simulations will be added in a near future.

Comments

  • The use of a dynamic_zero_constraints AffineConstraints object, rather than reconstruction of the zero_constraints one at every time step was determined to be optimal after some profiling tests.
  • A small mistake found in establish_solid_domain() was corrected.
  • Parameters are stored in vectors for the upcoming implementation of the feature in multiple fluid simulations.
  • The Variable enum class was moved from parameters.h to multiphysics.h. Using variables from the Variable enum class, the constrained and constraining fields could be parametrized in the future according to user needs.
  • Other minor corrections were also made to the documentation.
  • Missing module imports for the Melting Cavity example postprocessing were added.
  • Please disregard name of the branch, it depicts a slight change of plans.

Copy link
Collaborator

@hepap hepap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First review, I will go through it again on Monday or Thuesday.

Very nice addition and nicely done! Great job :)

doc/source/parameters/cfd/constrain_solid_domain.rst Outdated Show resolved Hide resolved
doc/source/parameters/cfd/constrain_solid_domain.rst Outdated Show resolved Hide resolved
include/core/parameters.h Outdated Show resolved Hide resolved
include/core/parameters.h Outdated Show resolved Hide resolved
include/solvers/navier_stokes_base.h Outdated Show resolved Hide resolved
include/solvers/navier_stokes_base.h Outdated Show resolved Hide resolved
include/solvers/navier_stokes_base.h Outdated Show resolved Hide resolved
include/solvers/simulation_parameters.h Outdated Show resolved Hide resolved
include/solvers/simulation_parameters.h Outdated Show resolved Hide resolved
include/solvers/gls_navier_stokes.h Outdated Show resolved Hide resolved
doc/source/theory/fluid_dynamics/navier-stokes.rst Outdated Show resolved Hide resolved
doc/source/parameters/cfd/constrain_solid_domain.rst Outdated Show resolved Hide resolved
include/core/parameters.h Outdated Show resolved Hide resolved
include/core/parameters.h Outdated Show resolved Hide resolved
include/solvers/navier_stokes_base.h Outdated Show resolved Hide resolved
include/solvers/navier_stokes_base.h Outdated Show resolved Hide resolved
source/core/parameters.cc Outdated Show resolved Hide resolved
source/solvers/gls_navier_stokes.cc Show resolved Hide resolved
source/solvers/navier_stokes_base.cc Outdated Show resolved Hide resolved
include/core/parameters.h Show resolved Hide resolved
Copy link
Contributor

@blaisb blaisb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things there and there. Good job!

Comment on lines +15 to +17
import pandas as pd

import os
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to add these modules?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are called in the script but they are not imported before.

include/core/parameters.h Outdated Show resolved Hide resolved
include/core/parameters.h Show resolved Hide resolved
include/solvers/navier_stokes_base.h Outdated Show resolved Hide resolved
Comment on lines 137 to 139
constrain_solid_domain.declare_parameters(
prm, 1); // at the moment, default value of the number of constraints is
// set to one since we are only applying to one-fluid simulations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value should always be one right? We can use a similar mechanism to the one we use in the boundary conditions to pre-detect the number of contraints. Otherwise, you could have a max constraints to pregenerate them.

Copy link
Collaborator Author

@AmishgaAlphonius AmishgaAlphonius Feb 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, I was thinking of having a max value variable, but I didn't do it since it was only one. I'll rename the argument just to make it clear.

Comment on lines 1907 to 1909
NavierStokesBase<dim, VectorType, DofsType>::flag_dofs_in_solid(
std::unordered_set<types::global_dof_index> &dofs_are_in_solid,
const std::vector<types::global_dof_index> &local_dof_indices)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function is called within a cell, I would consider inlining it and defining it in Utilities or somewhere else

Comment on lines 1922 to 1926
template <int dim, typename VectorType, typename DofsType>
bool
NavierStokesBase<dim, VectorType, DofsType>::check_cell_is_in_solid(
const std::unordered_set<types::global_dof_index> &dofs_are_in_solid,
const std::vector<types::global_dof_index> &local_dof_indices)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function is called within a cell, I would consider inlining it and defining it in Utilities or somewhere else

Comment on lines 1937 to 1941
template <int dim, typename VectorType, typename DofsType>
void
NavierStokesBase<dim, VectorType, DofsType>::flag_dofs_connected_to_fluid(
std::unordered_set<types::global_dof_index> &dofs_are_connected_to_fluid,
const std::vector<types::global_dof_index> &local_dof_indices)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function is called within a cell, I would consider inlining it and defining it in Utilities or somewhere else


template <int dim, typename VectorType, typename DofsType>
bool
NavierStokesBase<dim, VectorType, DofsType>::check_cell_is_connected_to_fluid(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function is called within a cell, I would consider inlining it and defining it in Utilities or somewhere else

Comment on lines 1972 to 1975
NavierStokesBase<dim, VectorType, DofsType>::constrain_pressure(
const bool &non_zero_constraints,
const std::vector<types::global_dof_index> &local_dof_indices,
AffineConstraints<double> &zero_constraints)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function is called within a cell, I would consider inlining it and defining it in Utilities or somewhere else

doc/source/parameters/cfd/constrain_solid_domain.rst Outdated Show resolved Hide resolved
include/core/parameters.h Outdated Show resolved Hide resolved
include/solvers/gls_navier_stokes.h Outdated Show resolved Hide resolved
@AmishgaAlphonius AmishgaAlphonius force-pushed the vof-solid-velocity-constraint branch from cd9380f to dce627f Compare February 27, 2024 18:33
@blaisb
Copy link
Contributor

blaisb commented Feb 27, 2024

@AmishgaAlphonius can you rebase if the tests don't pass? Then I'll merge after CI

@blaisb blaisb merged commit 332dabe into master Feb 27, 2024
8 checks passed
@blaisb blaisb deleted the vof-solid-velocity-constraint branch February 27, 2024 23:48
blaisb added a commit that referenced this pull request Mar 5, 2024
Description of the problem
In phase change simulations, the solid domain was treated as a simple fluid with a higher viscosity (viscous penalization). It worked quite well, but it wasn't the most efficient way to compute fluid dynamics quantities. In order to improve calculation time and linear system conditioning, homogeneous constraints are imposed on velocity DOFs in a defined solid domain through a temperature range. Additionally, pressure DOFs in the same solid domain that are not connected to fluid cells are also imposed to homogeneous constraints. The temperature range is specified through a parameter subsection, namely constrain solid domain. Previously, the implementation was done for single-fluid simulations (Temperature-dependant solid domain constraints #1038), but simulations such as laser powder bed fusion (LPBF) meltpool ones require two fluids when modelling.
Description of the solution
This PR, implements the new temperature-dependent solid domain constraints for two-phase Volume of Fluid (VOF) simulations. To select cells on which the constraints are applied, we check if the filtered phase fraction at quadrature points in the cell are within a range of accepted values. This range of accepted values is defined with the phase fraction tolerance parameter. This parameter defines an absolute tolerance on filtered phase fraction.
How Has This Been Tested?
The new feature has been tested on the Melting Cavity example by modelling to parts of the domain with different fluids while keeping the same properties in both fluids.
An application test has been added to test this feature : applications_tests/lethe-fluid/heat_transfer_vof_phase_change_constrain_solid_domain.prm (.output)
Documentation
Documentation page was updated: (doc/source/parameters/cfd/constrain_solid_domain.rst).
Comments
The structure of constrain_solid_domain() changed a bit. More functions were added to avoid code line repetitions in constrain_solid_domain_vof().
Small corrections were made in other files.

Co-authored-by: hepap <[email protected]>
Co-authored-by: Bruno Blais <[email protected]>
Co-authored-by: Olivier Guévremont <[email protected]>
blaisb pushed a commit that referenced this pull request Mar 13, 2024
Description
This PR adds a small section in the melting cavity example featuring the new constrain stasis feature from (Temperature-dependant solid domain constraints #1038).
Documentation
Parameter documentation was also updated : doc/source/parameters/cfd/constrain_stasis.rst
M-Badri pushed a commit to M-Badri/lethe that referenced this pull request Sep 29, 2024
Description of the problem
In phase change simulations, the solid domain was treated as a simple fluid with a higher viscosity (viscous penalization). It worked quite well, but it wasn't the most efficient way to compute fluid dynamics quantities.
Description of the solution
In order to improve calculation time and linear system conditioning, homogeneous constraints are imposed on velocity DOFs in a defined solid domain through a temperature range. Additionally, pressure DOFs in the same solid domain that are not connected to fluid cells are also imposed to homogeneous constraints. The temperature range is specified through a new parameter subsection, namely constrain solid domain.
How Has This Been Tested?
The new feature has been tested on the Melting Cavity example. With solid domain constraints on cells within the temperature range of [0,29] degC, the linear solver solving time of the fluid dynamics physic was reduced by a little more than the half without altering the postprocessed results. This feature will improve greatly computation times of domains with a higher proportion of "solid" phase.
The feature was also tested with the restart feature and no issue occurred. Final results were the same as without the restart.
An application test has been add to test this feature : applications_tests/lethe-fluid/heat_transfer_phase_change_constrain_solid_domain.prm (.output)
Documentation
A new page for the new parameter subsection (constrain solid domain) has been added : doc/source/parameters/cfd/constrain_solid_domain.rst
Future changes
The current implementation of this new feature only works with 1 fluid simulations (an exception is thrown when used with VOF or Cahn Hilliard). However, the implementation with VOF simulations will be added in a near future.
Comments
The use of a dynamic_zero_constraints AffineConstraints object, rather than reconstruction of the zero_constraints one at every time step was determined to be optimal after some profiling tests.
A small mistake found in establish_solid_domain() was corrected.
Parameters are stored in vectors for the upcoming implementation of the feature in multiple fluid simulations.
The Variable enum class was moved from parameters.h to multiphysics.h. Using variables from the Variable enum class, the constrained and constraining fields could be parametrized in the future according to user needs.
Other minor corrections were also made to the documentation.
Missing module imports for the Melting Cavity example postprocessing were added.
Please disregard name of the branch, it depicts a slight change of plans.

Co-authored-by: hepap <[email protected]>
Co-authored-by: Olivier Guévremont <[email protected]>
Co-authored-by: Bruno Blais <[email protected]>
Former-commit-id: 332dabe
M-Badri pushed a commit to M-Badri/lethe that referenced this pull request Sep 29, 2024
…-polymtl#1048)

Description of the problem
In phase change simulations, the solid domain was treated as a simple fluid with a higher viscosity (viscous penalization). It worked quite well, but it wasn't the most efficient way to compute fluid dynamics quantities. In order to improve calculation time and linear system conditioning, homogeneous constraints are imposed on velocity DOFs in a defined solid domain through a temperature range. Additionally, pressure DOFs in the same solid domain that are not connected to fluid cells are also imposed to homogeneous constraints. The temperature range is specified through a parameter subsection, namely constrain solid domain. Previously, the implementation was done for single-fluid simulations (Temperature-dependant solid domain constraints chaos-polymtl#1038), but simulations such as laser powder bed fusion (LPBF) meltpool ones require two fluids when modelling.
Description of the solution
This PR, implements the new temperature-dependent solid domain constraints for two-phase Volume of Fluid (VOF) simulations. To select cells on which the constraints are applied, we check if the filtered phase fraction at quadrature points in the cell are within a range of accepted values. This range of accepted values is defined with the phase fraction tolerance parameter. This parameter defines an absolute tolerance on filtered phase fraction.
How Has This Been Tested?
The new feature has been tested on the Melting Cavity example by modelling to parts of the domain with different fluids while keeping the same properties in both fluids.
An application test has been added to test this feature : applications_tests/lethe-fluid/heat_transfer_vof_phase_change_constrain_solid_domain.prm (.output)
Documentation
Documentation page was updated: (doc/source/parameters/cfd/constrain_solid_domain.rst).
Comments
The structure of constrain_solid_domain() changed a bit. More functions were added to avoid code line repetitions in constrain_solid_domain_vof().
Small corrections were made in other files.

Co-authored-by: hepap <[email protected]>
Co-authored-by: Bruno Blais <[email protected]>
Co-authored-by: Olivier Guévremont <[email protected]>
Former-commit-id: 581ad84
M-Badri pushed a commit to M-Badri/lethe that referenced this pull request Sep 29, 2024
Description
This PR adds a small section in the melting cavity example featuring the new constrain stasis feature from (Temperature-dependant solid domain constraints chaos-polymtl#1038).
Documentation
Parameter documentation was also updated : doc/source/parameters/cfd/constrain_stasis.rst

Former-commit-id: e843eae
blaisb added a commit that referenced this pull request Sep 30, 2024
Description of the problem
In phase change simulations, the solid domain was treated as a simple fluid with a higher viscosity (viscous penalization). It worked quite well, but it wasn't the most efficient way to compute fluid dynamics quantities.
Description of the solution
In order to improve calculation time and linear system conditioning, homogeneous constraints are imposed on velocity DOFs in a defined solid domain through a temperature range. Additionally, pressure DOFs in the same solid domain that are not connected to fluid cells are also imposed to homogeneous constraints. The temperature range is specified through a new parameter subsection, namely constrain solid domain.
How Has This Been Tested?
The new feature has been tested on the Melting Cavity example. With solid domain constraints on cells within the temperature range of [0,29] degC, the linear solver solving time of the fluid dynamics physic was reduced by a little more than the half without altering the postprocessed results. This feature will improve greatly computation times of domains with a higher proportion of "solid" phase.
The feature was also tested with the restart feature and no issue occurred. Final results were the same as without the restart.
An application test has been add to test this feature : applications_tests/lethe-fluid/heat_transfer_phase_change_constrain_solid_domain.prm (.output)
Documentation
A new page for the new parameter subsection (constrain solid domain) has been added : doc/source/parameters/cfd/constrain_solid_domain.rst
Future changes
The current implementation of this new feature only works with 1 fluid simulations (an exception is thrown when used with VOF or Cahn Hilliard). However, the implementation with VOF simulations will be added in a near future.
Comments
The use of a dynamic_zero_constraints AffineConstraints object, rather than reconstruction of the zero_constraints one at every time step was determined to be optimal after some profiling tests.
A small mistake found in establish_solid_domain() was corrected.
Parameters are stored in vectors for the upcoming implementation of the feature in multiple fluid simulations.
The Variable enum class was moved from parameters.h to multiphysics.h. Using variables from the Variable enum class, the constrained and constraining fields could be parametrized in the future according to user needs.
Other minor corrections were also made to the documentation.
Missing module imports for the Melting Cavity example postprocessing were added.
Please disregard name of the branch, it depicts a slight change of plans.

Co-authored-by: hepap <[email protected]>
Co-authored-by: Olivier Guévremont <[email protected]>
Co-authored-by: Bruno Blais <[email protected]>
Former-commit-id: 332dabe
blaisb added a commit that referenced this pull request Sep 30, 2024
Description of the problem
In phase change simulations, the solid domain was treated as a simple fluid with a higher viscosity (viscous penalization). It worked quite well, but it wasn't the most efficient way to compute fluid dynamics quantities. In order to improve calculation time and linear system conditioning, homogeneous constraints are imposed on velocity DOFs in a defined solid domain through a temperature range. Additionally, pressure DOFs in the same solid domain that are not connected to fluid cells are also imposed to homogeneous constraints. The temperature range is specified through a parameter subsection, namely constrain solid domain. Previously, the implementation was done for single-fluid simulations (Temperature-dependant solid domain constraints #1038), but simulations such as laser powder bed fusion (LPBF) meltpool ones require two fluids when modelling.
Description of the solution
This PR, implements the new temperature-dependent solid domain constraints for two-phase Volume of Fluid (VOF) simulations. To select cells on which the constraints are applied, we check if the filtered phase fraction at quadrature points in the cell are within a range of accepted values. This range of accepted values is defined with the phase fraction tolerance parameter. This parameter defines an absolute tolerance on filtered phase fraction.
How Has This Been Tested?
The new feature has been tested on the Melting Cavity example by modelling to parts of the domain with different fluids while keeping the same properties in both fluids.
An application test has been added to test this feature : applications_tests/lethe-fluid/heat_transfer_vof_phase_change_constrain_solid_domain.prm (.output)
Documentation
Documentation page was updated: (doc/source/parameters/cfd/constrain_solid_domain.rst).
Comments
The structure of constrain_solid_domain() changed a bit. More functions were added to avoid code line repetitions in constrain_solid_domain_vof().
Small corrections were made in other files.

Co-authored-by: hepap <[email protected]>
Co-authored-by: Bruno Blais <[email protected]>
Co-authored-by: Olivier Guévremont <[email protected]>
Former-commit-id: 581ad84
blaisb pushed a commit that referenced this pull request Sep 30, 2024
Description
This PR adds a small section in the melting cavity example featuring the new constrain stasis feature from (Temperature-dependant solid domain constraints #1038).
Documentation
Parameter documentation was also updated : doc/source/parameters/cfd/constrain_stasis.rst

Former-commit-id: e843eae
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants