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

Refactor void fraction out of solver #1392

Open
wants to merge 25 commits into
base: master
Choose a base branch
from

Conversation

blaisb
Copy link
Contributor

@blaisb blaisb commented Dec 3, 2024

Description

The facilities required to calculate the void fraction were all contained within the unresolved CFD-DEM solver and the VANS solver. This is very problematic, because it makes it difficult to develop new void fraction schemes, but also prevents the development of new VANS schemes (e.g. matrix free). Consequently, I Have used the new interface developed by @AmishgaAlphonius to refactor the void fraction calculation completely out of the VANS and unresolved CFD-DEM solver. The result is very lightweight.

I also took the opportunity to deprecate the bounding of the void fraction. This feature was never used and was actually dangerous for convergence. Consequently, it has now been fully deprecated and the documentation has been adapted.

Testing

None of the tests results were changed, this is great since nothing should have changed.

Documentation

I have removed the documentation related to the bounding of the void fraction and all of its mention within the examples.

Miscellaneous (will be removed when merged)

Checklist (will be removed when merged)

See this page for more information about the pull request process.

Code related list:

  • All in-code documentation related to this PR is up to date (Doxygen format)
  • Copyright headers are present and up to date
  • Lethe documentation is up to date
  • The branch is rebased onto master
  • Code is indented with indent-all and .prm files (examples and tests) with prm-indent
  • If parameters are modified, the tests and the documentation of examples are up to date
  • Changelog (CHANGELOG.md) is up to date if the refactor affects the user experience or the codebase

Pull request related list:

  • No other PR is open related to this refactoring
  • Labels are applied
  • There are at least 2 reviewers (or 1 if small feature) excluding the responsible for the merge
  • If this PR closes an issue or is related to a project, it is linked in the "Projects" or "Development" section
  • If any future works is planned, an issue is opened
  • The PR description is cleaned and ready for merge

@blaisb blaisb added the Refactoring This PR is only refactoring or clean up label Dec 3, 2024
@blaisb blaisb force-pushed the refactor_void_fraction_out_of_solver branch from e3db630 to 2ea7c62 Compare December 3, 2024 18:41
Copy link
Collaborator

@voferreira voferreira left a comment

Choose a reason for hiding this comment

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

First pass. I will redo it later, but I feel there's not much else to do. It is very nice that it is a separate class now!

include/fem-dem/void_fraction.h Show resolved Hide resolved
include/fem-dem/void_fraction.h Outdated Show resolved Hide resolved
include/fem-dem/void_fraction.h Show resolved Hide resolved
include/fem-dem/void_fraction.h Show resolved Hide resolved
include/fem-dem/void_fraction.h Show resolved Hide resolved
include/fem-dem/void_fraction.h Outdated Show resolved Hide resolved
source/fem-dem/void_fraction.cc Show resolved Hide resolved
source/fem-dem/void_fraction.cc Outdated Show resolved Hide resolved
source/fem-dem/void_fraction.cc Show resolved Hide resolved
source/fem-dem/void_fraction.cc Show resolved Hide resolved
@blaisb blaisb force-pushed the refactor_void_fraction_out_of_solver branch from e8745f9 to d7e3e42 Compare December 4, 2024 16:31
Copy link
Collaborator

@AmishgaAlphonius AmishgaAlphonius left a comment

Choose a reason for hiding this comment

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

Here's a first pass, it's nice to see code files getting lighter and features more portable from one file to another. Nice work :)

CHANGELOG.md Outdated Show resolved Hide resolved
include/fem-dem/void_fraction.h Outdated Show resolved Hide resolved
include/fem-dem/void_fraction.h Outdated Show resolved Hide resolved
include/fem-dem/void_fraction.h Outdated Show resolved Hide resolved
include/fem-dem/void_fraction.h Outdated Show resolved Hide resolved
source/fem-dem/void_fraction.cc Outdated Show resolved Hide resolved
source/fem-dem/void_fraction.cc Outdated Show resolved Hide resolved
source/fem-dem/void_fraction.cc Outdated Show resolved Hide resolved
source/fem-dem/void_fraction.cc Outdated Show resolved Hide resolved
source/fem-dem/void_fraction.cc Outdated Show resolved Hide resolved
Copy link
Collaborator

@AmishgaAlphonius AmishgaAlphonius left a comment

Choose a reason for hiding this comment

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

Last minor comments/suggestions :)

public:
VoidFractionBase(
parallel::DistributedTriangulationBase<dim> *triangulation,
std::shared_ptr<Parameters::VoidFractionParameters<dim>> input_parameters,
const Parameters::LinearSolver &linear_solver_parameters,
Particles::ParticleHandler<dim> *particle_handler,
const unsigned int fe_degree,
const bool simplex,
const ConditionalOStream &pcout)
: PhysicsLinearSubequationsSolver(pcout)
, dof_handler(*triangulation)
, triangulation(triangulation)
, void_fraction_parameters(input_parameters)
, linear_solver_parameters(linear_solver_parameters)
// BB TODO verify if the particle handler can be remade const
, particle_handler(particle_handler)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Still missing the brief for the constructor

include/fem-dem/void_fraction.h Outdated Show resolved Hide resolved
include/fem-dem/void_fraction.h Outdated Show resolved Hide resolved
include/fem-dem/void_fraction.h Outdated Show resolved Hide resolved
include/fem-dem/void_fraction.h Outdated Show resolved Hide resolved
include/fem-dem/void_fraction.h Outdated Show resolved Hide resolved
source/fem-dem/void_fraction.cc Show resolved Hide resolved
Comment on lines 26 to 56
const MPI_Comm mpi_communicator = dof_handler.get_communicator();

dof_handler.distribute_dofs(*fe);
locally_owned_dofs = dof_handler.locally_owned_dofs();

locally_relevant_dofs = DoFTools::extract_locally_relevant_dofs(dof_handler);

void_fraction_constraints.clear();
void_fraction_constraints.reinit(locally_relevant_dofs);
DoFTools::make_hanging_node_constraints(dof_handler,
void_fraction_constraints);

/// TODO ADD Periodic constraints
void_fraction_constraints.close();

void_fraction_locally_relevant.reinit(locally_owned_dofs,
locally_relevant_dofs,
mpi_communicator);

this->previous_void_fraction.resize(maximum_number_of_previous_solutions());

// Initialize vector of previous solutions for the void fraction
for (auto &solution : this->previous_void_fraction)
{
solution.reinit(this->locally_owned_dofs,
this->locally_relevant_dofs,
this->triangulation->get_communicator());
}

void_fraction_locally_owned.reinit(locally_owned_dofs,
this->triangulation->get_communicator());
Copy link
Collaborator

Choose a reason for hiding this comment

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

In that case, why is the local copy not used everywhere here?

Co-authored-by: Amishga Alphonius <[email protected]>
Copy link
Collaborator

@voferreira voferreira left a comment

Choose a reason for hiding this comment

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

All clear

@blaisb
Copy link
Contributor Author

blaisb commented Dec 4, 2024

Thanks for the nice thorough review @AmishgaAlphonius and @voferreira . Really helped a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactoring This PR is only refactoring or clean up Reviewed and ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants