-
Notifications
You must be signed in to change notification settings - Fork 54
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
Conversation
postprocessing_cfd_dem.cc
q_points is missed
There was a problem hiding this 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/parameters_cfd_dem.h
Outdated
|
||
struct CFDDEM_postprocessing | ||
{ | ||
bool calculate_total_volume; |
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
source/fem-dem/parameters_cfd_dem.cc
Outdated
CFDDEM_postprocessing::declare_parameters(ParameterHandler &prm) | ||
{ | ||
prm.enter_subsection("post-processing"); | ||
prm.declare_entry("calculate total volume", |
There was a problem hiding this comment.
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.
// 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; | ||
|
||
|
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
source/fem-dem/cfd_dem_coupling.cc
Outdated
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup agreed
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. |
@yashuuzi can you re-indent the code? |
There was a problem hiding this 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
include/fem-dem/cfd_dem_coupling.h
Outdated
@@ -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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
include/fem-dem/parameters_cfd_dem.h
Outdated
|
||
struct CFDDEM_postprocessing | ||
{ | ||
bool calculate_total_volume; |
There was a problem hiding this comment.
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 <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> |
There was a problem hiding this comment.
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/cfd_dem_coupling.cc
Outdated
CFDDEMSolver<dim>::postprocess_cfd_dem() | ||
{ | ||
// Calculate total volume of fluid and solid | ||
if (this->cfd_dem_simulation_parameters.cfd_dem_postprocessing.calculate_total_volume) |
There was a problem hiding this comment.
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)
source/fem-dem/cfd_dem_coupling.cc
Outdated
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup agreed
#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> |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
// Get the void fraction at the quadrature point | ||
fe_vf_values[void_fraction].get_function_values( | ||
present_void_fraction_solution, void_fraction_values); |
There was a problem hiding this comment.
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.
Thank you so much for reviewing! I'll fix them and let you know when I've done |
6f0e23a
to
6bff7eb
Compare
I'm ready for second review! |
There was a problem hiding this 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: |
There was a problem hiding this comment.
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
:)
include/core/parameters.h
Outdated
@@ -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; |
There was a problem hiding this comment.
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
include/fem-dem/cfd_dem_coupling.h
Outdated
// Post-processing variables to output total fluid volume and total particles | ||
// volume |
There was a problem hiding this comment.
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
There was a problem hiding this 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!
Please, don't forget to rebase. Your branch is 20 commits behind master. |
Co-authored-by: Bruno Blais <blais.bruno@gmail.com>
change "volume_phases" into "phase_volumes"
@yashuuzi Is this ready for a final review / merge? Try to finish this as a priority :) |
I finished modifying and ready to final review! |
Description of the problem
Description of the solution
How Has This Been Tested?
Documentation