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

Tracer flow rate at boundaries #1197

Merged
merged 15 commits into from
Aug 6, 2024
Merged

Tracer flow rate at boundaries #1197

merged 15 commits into from
Aug 6, 2024

Conversation

oguevremont
Copy link
Collaborator

@oguevremont oguevremont commented Jul 16, 2024

Description

An application of the tracer physics is to obtain the residence time distribution (RTD) of a flow through a domain. This PR adds the post-processing option that outputs the tracer flow rate at every boundary, providing the data for RTD analyses.

In addition, a bug where the conditions to allow boundary conditions to update their values were too strict was rectified. Each physics is now responsible for deciding when to update their boundary conditions, and this condition was already based on whether boundary conditions were time-dependent.

Testing

Documentation

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)
  • Lethe documentation is up to date
  • New feature has unit test(s) (preferred) or application test(s), and restart files are in the generator folder
  • The branch is rebased onto master
  • Changelog (CHANGELOG.md) is up to date
  • Code is indented with indent-all and .prm files (examples and tests) with prm-indent

Pull request related list:

  • 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 the fix is temporary, an issue is opened
  • The PR description is cleaned and ready for merge

@oguevremont oguevremont force-pushed the tracer_postprocessing branch 2 times, most recently from d560eee to f7c5794 Compare July 16, 2024 17:35
@oguevremont oguevremont marked this pull request as ready for review July 16, 2024 17:39
@oguevremont oguevremont self-assigned this Jul 16, 2024
@oguevremont oguevremont added Enhancement New feature or request Ready for review Post-processing Modifications to the post-processing module labels Jul 16, 2024
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.

Good work! I have a few comments :)

include/solvers/tracer.h 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/tracer.h Outdated Show resolved Hide resolved
applications_tests/lethe-fluid/tracer_flow_rate.prm Outdated Show resolved Hide resolved
source/solvers/tracer.cc Outdated Show resolved Hide resolved
source/solvers/tracer.cc Outdated Show resolved Hide resolved
source/solvers/tracer.cc Outdated Show resolved Hide resolved
source/solvers/tracer.cc Outdated Show resolved Hide resolved
source/solvers/tracer.cc Outdated Show resolved Hide resolved
@oguevremont oguevremont requested a review from hepap July 16, 2024 20:16
Copy link
Collaborator

@OresteMarquis OresteMarquis left a comment

Choose a reason for hiding this comment

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

Really nice! Nothing much to say, only clarifications for my understanding.

@@ -1655,24 +1655,11 @@ CFDDEMSolver<dim>::solve()
while (this->simulation_control->integrate())
{
this->simulation_control->print_progression(this->pcout);
bool refinement_step;
if (this->simulation_parameters.mesh_adaptation.refinement_at_frequency)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just curious to know why is those if conditions are removed from the solvers and fem-dem?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's because in the update_boundary_conditions functions, the only condition to respect was whether boundary conditions are time dependent. This is already very restrictive and not expensive to check, so to simplify the code I remove the refinement_step boolean here. It had no effect on any test. I feel like the previous condition was difficult to understand and didn't bring much.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If it does the same I like it! It is indeed much clearer :)

source/solvers/tracer.cc Show resolved Hide resolved
source/solvers/tracer.cc Show resolved Hide resolved
@oguevremont oguevremont force-pushed the tracer_postprocessing branch from 4d3d401 to 4c9b8da Compare August 5, 2024 15:10
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.

Nice work! Sorry for the delay in my review!

I think your application test is enough, but a unit test could be also nice :)

source/core/parameters.cc Outdated Show resolved Hide resolved
@@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).

## [Master] - 2024-08-05

### Added

- MINOR A post-processing feature for the tracer flow rate through boundaries is added. This allows to produce data useful for residence time distribution analyses. [#1197](https://github.com/chaos-polymtl/lethe/pull/1197)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you should add the fix on the bc update

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.

one small correction left
Nice work! :)

include/solvers/tracer.h Outdated Show resolved Hide resolved
@oguevremont oguevremont requested a review from blaisb August 5, 2024 16:01
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.

One small refactoring left and this should be good to go.

Comment on lines 687 to 739
// Fill table
this->tracer_flow_rate_table.add_value(
"time", this->simulation_control->get_current_time());
this->tracer_flow_rate_table.set_precision("time", 12);
for (unsigned int i_bc = 0;
i_bc < this->simulation_parameters.boundary_conditions.size;
++i_bc)
{
this->tracer_flow_rate_table.add_value("flow-rate-" +
Utilities::int_to_string(i_bc,
2),
tracer_flow_rate_vector[i_bc]);
this->tracer_flow_rate_table.set_scientific(
"flow-rate-" + Utilities::int_to_string(i_bc, 2), true);
}

// Console output
if (simulation_parameters.post_processing.verbosity ==
Parameters::Verbosity::verbose)
{
this->pcout << "Tracer flow rate at the boundaries: " << std::endl;
for (unsigned int i_bc = 0;
i_bc < this->simulation_parameters.boundary_conditions.size;
++i_bc)
this->pcout << "\t boundary " << i_bc << ": "
<< tracer_flow_rate_vector[i_bc] << std::endl;
}

if ((simulation_control->get_step_number() %
this->simulation_parameters.post_processing.output_frequency ==
0) &&
Utilities::MPI::this_mpi_process(mpi_communicator) == 0)
{
std::string filename =
simulation_parameters.simulation_control.output_folder +
simulation_parameters.post_processing.tracer_flow_rate_output_name +
".dat";
std::ofstream output(filename.c_str());
this->tracer_flow_rate_table.write_text(output);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Personally I would fill the table write the output outside of the function and not inside. The function calculates the flow rate, it does not really take care of anything else. This should be two functions. One two calculate and one to store the information.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I split into 2 functions as suggested. It makes more sense that way

@oguevremont oguevremont force-pushed the tracer_postprocessing branch from 1fa519b to 9d076f6 Compare August 5, 2024 21:24
@blaisb
Copy link
Contributor

blaisb commented Aug 6, 2024

@oguevremont can you rebase and then I'll be able to merge

oguevremont and others added 5 commits August 5, 2024 20:12
Co-authored-by: hepap <47506601+hepap@users.noreply.github.com>
Co-authored-by: Amishga Alphonius <107414376+AmishgaAlphonius@users.noreply.github.com>
@oguevremont oguevremont force-pushed the tracer_postprocessing branch from 9d076f6 to 28693db Compare August 6, 2024 00:14
@blaisb blaisb merged commit fd4481e into master Aug 6, 2024
8 checks passed
@blaisb blaisb deleted the tracer_postprocessing branch August 6, 2024 01:58
M-Badri pushed a commit to M-Badri/lethe that referenced this pull request Sep 29, 2024
Description
An application of the tracer physics is to obtain the residence time distribution (RTD) of a flow through a domain. This PR adds the post-processing option that outputs the tracer flow rate at every boundary, providing the data for RTD analyses.

In addition, a bug where the conditions to allow boundary conditions to update their values were too strict was rectified. Each physics is now responsible for deciding when to update their boundary conditions, and this condition was already based on whether boundary conditions were time-dependent.

Co-authored-by: Amishga Alphonius <107414376+AmishgaAlphonius@users.noreply.github.com>
Co-authored-by: hepap <47506601+hepap@users.noreply.github.com>
Former-commit-id: fd4481e
blaisb pushed a commit that referenced this pull request Sep 30, 2024
Description
An application of the tracer physics is to obtain the residence time distribution (RTD) of a flow through a domain. This PR adds the post-processing option that outputs the tracer flow rate at every boundary, providing the data for RTD analyses.

In addition, a bug where the conditions to allow boundary conditions to update their values were too strict was rectified. Each physics is now responsible for deciding when to update their boundary conditions, and this condition was already based on whether boundary conditions were time-dependent.

Co-authored-by: Amishga Alphonius <107414376+AmishgaAlphonius@users.noreply.github.com>
Co-authored-by: hepap <47506601+hepap@users.noreply.github.com>
Former-commit-id: fd4481e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Post-processing Modifications to the post-processing module Ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants