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

Create a postprocessing function for cfd-dem #1147

Merged
merged 33 commits into from
Jun 6, 2024

Conversation

yashuuzi
Copy link
Collaborator

Description of the problem

  • There were no post-processing functions for cfd-dem, so we need framework to organize them
  • We need the post-processing function which calculate total volume in order to check if total volume is conserved

Description of the solution

  • Create postprocessing_cfd_dem.cc and call it in cfd_dem_coupling.cc
  • Create some prameters for prm file

How Has This Been Tested?

  • Launched several example, and confirmed that the volume calculated with analytical solution is matched with the volume of geometry

Documentation

  • I didn't add this to the documentation or doxygen

@yashuuzi yashuuzi changed the title Create a framework for postprocessing of cfd-dem, and function which calculate the total fluid volume and total solid volume respectively Create a postprocessing function for cfd-dem May 17, 2024
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.

Good job, Soki. I have some comments. I will test it on my side before approving as well.

include/fem-dem/gls_vans.h Outdated Show resolved Hide resolved

struct CFDDEM_postprocessing
{
bool calculate_total_volume;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I find "calculate total volume" a bit generic. What do you think about "compute volume phases"?

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 agree, I think that would makes more sense

Copy link
Contributor

Choose a reason for hiding this comment

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

In this case I think it is better to be even more specific.
calculate_fluid_and_particle_volumes

or something like that. Because here this function is only used in CFD-DEM, it's used anywhere elese.

include/fem-dem/postprocessing_cfd_dem.h Outdated Show resolved Hide resolved
include/fem-dem/postprocessing_cfd_dem.h Show resolved Hide resolved
include/fem-dem/postprocessing_cfd_dem.h Show resolved Hide resolved
source/fem-dem/gls_vans.cc Outdated Show resolved Hide resolved
CFDDEM_postprocessing::declare_parameters(ParameterHandler &prm)
{
prm.enter_subsection("post-processing");
prm.declare_entry("calculate total volume",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like total volume does not give you an idea of what volume you are referring to.

Comment on lines 1 to 36
// Base
#include <deal.II/base/quadrature_lib.h>

// Lac
#include <deal.II/lac/dynamic_sparsity_pattern.h>
#include <deal.II/lac/vector.h>

// grid
#include <deal.II/grid/grid_tools.h>

// Dofs
#include <deal.II/dofs/dof_accessor.h>
#include <deal.II/dofs/dof_handler.h>

// Lac - Trilinos includes
#include <deal.II/lac/trilinos_parallel_block_vector.h>
#include <deal.II/lac/trilinos_vector.h>

// Fe
#include <deal.II/fe/fe_q.h>
#include <deal.II/fe/fe_system.h>
#include <deal.II/fe/fe_values.h>
#include <deal.II/fe/mapping_q.h>

// Lethe includes
#include <core/boundary_conditions.h>
#include <core/parameters.h>
#include <core/rheological_model.h>
#include <core/vector.h>

#include <fem-dem/postprocessing_cfd_dem.h>


using namespace dealii;


Copy link
Collaborator

Choose a reason for hiding this comment

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

You could follow the other files for this part.

calculate_total_volume(const DoFHandler<dim> &void_fraction_dof_handler,
const VectorType &present_void_fraction_solution,
const Quadrature<dim> &quadrature_formula,
std::shared_ptr<Mapping<dim>> mapping)
Copy link
Collaborator

Choose a reason for hiding this comment

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

@blaisb You could parse the argument as Mapping and dereference here, no?. Additionally, would it be possible to make it const?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am unsure what you mean by parse and dereference.
Here the argument could be a const reference to a mapping, that's for sure. Using a share_ptr is kinda equivalent except that it copies the pointer. If it's a shared_ptr, it cannot be const, because shared_ptr have a ref_count mechanism that is modified when you copy it.
Passing as a const reference here would be the best choice IMO. we don't do it for the other post-processing which is a mistake, it should be like that everywhere. Just things we became better at as time went on.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I did not word it correctly but that's what I meant :)

Comment on lines 1273 to 1286
this->pcout << "Total volume of fluid: "
<< std::setprecision(
this->simulation_control->get_log_precision())
<< this->simulation_parameters.physical_properties_manager
.get_density_scale() *
total_volume_fluid
<< " m^3" << std::endl;
this->pcout << "Total volume of fluid: "
<< std::setprecision(
this->simulation_control->get_log_precision())
<< this->simulation_parameters.physical_properties_manager
.get_density_scale() *
total_volume_solid
<< " m^3" << std::endl;
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use the announce string from utilities here, I feel.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup agreed

@voferreira
Copy link
Collaborator

As this introduces a parameter, this parameter needs to be added to the documentation. Additionally, since this feature is used to have an assessment of the accuracy of the void fraction scheme, I feel it would be very useful to have application tests using it. This way, if we try to improve something on the current schemes, we can make sure it gives the same result.

@blaisb
Copy link
Contributor

blaisb commented May 22, 2024

@yashuuzi can you re-indent the code?

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 comments. Nothing major

@@ -358,5 +366,8 @@ class CFDDEMSolver : public GLSVANSSolver<dim>
const unsigned int this_mpi_process;
const unsigned int n_mpi_processes;
LagrangianPostProcessing<dim> dem_post_processing_object;

// Post-processing variables
TableHandler total_volume_table;
Copy link
Contributor

Choose a reason for hiding this comment

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

I am unsure if total_volume is the best name, but I can't think of a better name.
Add a clearer description of what the table contains above that table, otherwise we don't know what it is used for. Post-processing variable is very vague.

@@ -40,6 +40,7 @@ class CFDDEMSimulationParameters

std::shared_ptr<Parameters::VoidFraction<dim>> void_fraction;
Parameters::CFDDEM cfd_dem;
Parameters::CFDDEM_postprocessing cfd_dem_postprocessing;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this requires a new set of parameter. This could be directly into post-processing instead of having a new post-processing section. We already have Multiphysics postprocessing in the postprocessing block, so I think having some CFD-DEM stuff there won't hurt.

@@ -51,6 +52,7 @@ class CFDDEMSimulationParameters
void_fraction = std::make_shared<Parameters::VoidFraction<dim>>();
void_fraction->declare_parameters(prm);
Parameters::CFDDEM::declare_parameters(prm);
Parameters::CFDDEM_postprocessing::declare_parameters(prm);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's better to put it into the regular post-processing parameters.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed


struct CFDDEM_postprocessing
{
bool calculate_total_volume;
Copy link
Contributor

Choose a reason for hiding this comment

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

In this case I think it is better to be even more specific.
calculate_fluid_and_particle_volumes

or something like that. Because here this function is only used in CFD-DEM, it's used anywhere elese.

Comment on lines 30 to 41
# include <deal.II/lac/dynamic_sparsity_pattern.h>
# include <deal.II/lac/vector.h>

// Dofs
# include <deal.II/dofs/dof_handler.h>

// Fe
# include <deal.II/fe/fe.h>
# include <deal.II/fe/mapping_fe.h>

// Lethe includes
# include <core/boundary_conditions.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you double check if you need all these includes ? I think not.

source/fem-dem/CMakeLists.txt Outdated Show resolved Hide resolved
CFDDEMSolver<dim>::postprocess_cfd_dem()
{
// Calculate total volume of fluid and solid
if (this->cfd_dem_simulation_parameters.cfd_dem_postprocessing.calculate_total_volume)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just put it straight in the post-processing parameters (the regular one)

Comment on lines 1273 to 1286
this->pcout << "Total volume of fluid: "
<< std::setprecision(
this->simulation_control->get_log_precision())
<< this->simulation_parameters.physical_properties_manager
.get_density_scale() *
total_volume_fluid
<< " m^3" << std::endl;
this->pcout << "Total volume of fluid: "
<< std::setprecision(
this->simulation_control->get_log_precision())
<< this->simulation_parameters.physical_properties_manager
.get_density_scale() *
total_volume_solid
<< " m^3" << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

Yup agreed

Comment on lines 2 to 31
#include <deal.II/base/quadrature_lib.h>

// Lac
#include <deal.II/lac/dynamic_sparsity_pattern.h>
#include <deal.II/lac/vector.h>

// grid
#include <deal.II/grid/grid_tools.h>

// Dofs
#include <deal.II/dofs/dof_accessor.h>
#include <deal.II/dofs/dof_handler.h>

// Lac - Trilinos includes
#include <deal.II/lac/trilinos_parallel_block_vector.h>
#include <deal.II/lac/trilinos_vector.h>

// Fe
#include <deal.II/fe/fe_q.h>
#include <deal.II/fe/fe_system.h>
#include <deal.II/fe/fe_values.h>
#include <deal.II/fe/mapping_q.h>

// Lethe includes
#include <core/boundary_conditions.h>
#include <core/parameters.h>
#include <core/rheological_model.h>
#include <core/vector.h>

#include <fem-dem/postprocessing_cfd_dem.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need all these includes? I think not.

calculate_total_volume(const DoFHandler<dim> &void_fraction_dof_handler,
const VectorType &present_void_fraction_solution,
const Quadrature<dim> &quadrature_formula,
std::shared_ptr<Mapping<dim>> mapping)
Copy link
Contributor

Choose a reason for hiding this comment

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

I am unsure what you mean by parse and dereference.
Here the argument could be a const reference to a mapping, that's for sure. Using a share_ptr is kinda equivalent except that it copies the pointer. If it's a shared_ptr, it cannot be const, because shared_ptr have a ref_count mechanism that is modified when you copy it.
Passing as a const reference here would be the best choice IMO. we don't do it for the other post-processing which is a mistake, it should be like that everywhere. Just things we became better at as time went on.

source/fem-dem/postprocessing_cfd_dem.cc Outdated Show resolved Hide resolved
Comment on lines 69 to 71
// Get the void fraction at the quadrature point
fe_vf_values[void_fraction].get_function_values(
present_void_fraction_solution, void_fraction_values);
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be done outside of the loop on gauss points.

@yashuuzi
Copy link
Collaborator Author

Thank you so much for reviewing! I'll fix them and let you know when I've done

@yashuuzi yashuuzi force-pushed the postprocessing_void_fraction branch from 6f0e23a to 6bff7eb Compare May 29, 2024 18:54
@yashuuzi
Copy link
Collaborator Author

I'm ready for second review!
Actually I could't come up with good name of parameter which is better than "volume phases", but I think it's understandable.

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.

1-2 last comment.
One more thing, can you add an application test, this would be very important to ensure the feature is stable as a function of time :).

@@ -252,5 +259,23 @@ This subsection controls the post-processing other than the forces and torque on

* ``phase energy name``: name of the output file containing phase energies from Cahn-Hilliard simulations. The default file name is ``phase_energy``.

* ``calculate volume phases``: outputs total volume of fluid phase and total volume of solid phase in CFD-DEM simulation. These volumes are computed as follow:
Copy link
Contributor

Choose a reason for hiding this comment

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

should be phase volumes and not volume phases
like we calculate the volume of the phases and not the phase volume
:)

doc/source/parameters/cfd/post_processing.rst Outdated Show resolved Hide resolved
include/core/parameters.h Outdated Show resolved Hide resolved
@@ -916,6 +916,13 @@ namespace Parameters
/// Prefix for the energy output in Cahn-Hilliard simulations
std::string phase_energy_output_name;

/// Enable calculation of total fluid volume and total particles volume in
/// cfd-dem simulation
bool calculate_volume_phases;
Copy link
Contributor

Choose a reason for hiding this comment

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

would rename phase_volumes instead of volume_phases, but that's minor

Comment on lines 370 to 371
// Post-processing variables to output total fluid volume and total particles
// volume
Copy link
Contributor

Choose a reason for hiding this comment

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

use /// instead of // for these type of comments

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 good to me after applying Bruno's comments. Good job!

@voferreira
Copy link
Collaborator

Please, don't forget to rebase. Your branch is 20 commits behind master.

yashuuzi and others added 2 commits June 4, 2024 10:31
Co-authored-by: Bruno Blais <blais.bruno@gmail.com>
change "volume_phases" into "phase_volumes"
@blaisb
Copy link
Contributor

blaisb commented Jun 5, 2024

@yashuuzi Is this ready for a final review / merge? Try to finish this as a priority :)

@yashuuzi
Copy link
Collaborator Author

yashuuzi commented Jun 5, 2024

I finished modifying and ready to final review!

@blaisb blaisb merged commit 2c19eab into master Jun 6, 2024
8 checks passed
@blaisb blaisb deleted the postprocessing_void_fraction branch June 6, 2024 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants