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 with Sharp IB #1185

Merged
merged 32 commits into from
Jul 12, 2024
Merged

Tracer with Sharp IB #1185

merged 32 commits into from
Jul 12, 2024

Conversation

oguevremont
Copy link
Collaborator

@oguevremont oguevremont commented Jul 4, 2024

Description

  • Previously, the tracer physics used with the Sharp IB solver could not consider material dependent physical properties: both fluid and solid had the same diffusivity.
  • Now, physical properties of immersed solids are defined using the solid 0 section, though only one solid can be used at the moment.
  • A tracer diffusivity model based on the signed distance function used in the Sharp IB has been added, which allows to smooth the diffusivity transition at the fluid/solid interface. The architecture is there for future models and could serve as a base for reactive physics models used in heterogeneous catalysis.

Testing

  • [tests/core/immersed_solid_diffusivity_tanh] Unit test for the tanh diffusivity transition model.
  • [applications_tests/lethe-fluid-sharp/tracer_around_sphere] 2D application test where the tracer physics is used with the Sharp IB solver. This also tests the new diffusivity model.

Documentation

[doc/source/parameters/cfd/physical_properties] The new model has been added in new section where immersed solids models will be added in the future.

Miscellaneous (will be removed when merged)

This PR was done with more generality than needed in preparation of the reactive physics that will be implemented soon.

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 added WIP When a PR is open but not ready for review Enhancement New feature or request Ready for review and removed WIP When a PR is open but not ready for review labels Jul 4, 2024
@oguevremont oguevremont requested review from hepap and acdaigneault July 4, 2024 18:22
Comment on lines 248 to 256
set number of solids = 1
subsection solid 0
set tracer diffusivity model = immersed solid tanh
subsection immersed solid
subsection tanh levelset
set tracer diffusivity inside = 1
set tracer diffusivity outside = 1
set tracer diffusivity thickness = 1
end
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I understand. Why do you have a subsectoin solid and then inside the subsection solid have a subsection immersed solid? Shouldnt the immersed solid be its own subsection?

Furthermore, here you specify the diffusivity inside and outside. But outside of the solid is the fluid. Consequently, are you not duplicated a parameter which is the fluid diffusivity. I think that's not a very wise decision. Essentially, you are duplicating the fluid diffusivity model twice by having the solid also specify it....

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can the diffusivity at the outside edge of the solid be different from the fluid diffusivity?

Copy link
Collaborator Author

@oguevremont oguevremont Jul 5, 2024

Choose a reason for hiding this comment

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

The way I coded it yes, so we could have a fluid diffusivity, and a solid diffusivity that varies depending on the depth. The wording could be improved though.

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 changed it to only a fluid model, that can be based also on levelset (for IB methods). I restructured the parameters as well in this way

Comment on lines 464 to 454
enum class TracerDiffusivityModel
{
constant,
tanh_levelset
} tracer_diffusivity_model;
Copy link
Contributor

Choose a reason for hiding this comment

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

That's not really a diffusivity model per say right, it's more like an interface model and we have classes for interface models (e.g. surface tension is an interface model)

Comment on lines +4 to +7
DEAL:: levelset = 0, diffusivity = 1.00000, dD/dlevelset numerical = 20.0000
DEAL:: levelset = 100, diffusivity = 2.00000, dD/dlevelset numerical = 0.00000
DEAL:: levelset = -100, diffusivity = 0.00000, dD/dlevelset numerical = 0.00000
DEAL::OK
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 curious, in which situation do you think you will need the jacobian of the diffusivity coefficient with respect to the level set function?

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 will not be used, I'll remove it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We don't have to test it, but the jacobian is virtual in the PhysicalPropertyModel parent class

Copy link
Contributor

Choose a reason for hiding this comment

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

legit, no worries then

Comment on lines 21 to 25
Tracer statistics :
Min : 0
Max : 0.7887
Average : 0.01367
Std-Dev : 0.09216
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it the statistic from the steady it 1? or the initial condition?

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 were from the initial condition, good catch. postprocess() was not called in sharp

doc/source/parameters/cfd/physical_properties.rst Outdated Show resolved Hide resolved

* The ``tracer diffusivity outside`` parameter represents the desired diffusivity outside (or at the edge) of the solid. Setting it equal to the fluid diffusivity should provide a smooth transition.

* The ``tracer diffusivity thickness`` parameter represents thickness of the applied tanh function.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add the equation of the tanh function you use?

doc/source/parameters/cfd/physical_properties.rst Outdated Show resolved Hide resolved
Comment on lines 315 to 326
* @brief ImmersedSolidPhysicalProperties - Defines the parameters for immersed solids
* and more specifically how they behave close to their interface.
*/
struct ImmersedSolidPhysicalProperties
{
TanhLevelsetParameters tanh_levelset_parameters;

void
declare_parameters(ParameterHandler &prm);
void
parse_parameters(ParameterHandler &prm, const Dimensionality dimensions);
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is because of the generalization you talked about in the PR description?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes that's it

include/solvers/tracer_scratch_data.h Outdated Show resolved Hide resolved
Comment on lines 248 to 256
set number of solids = 1
subsection solid 0
set tracer diffusivity model = immersed solid tanh
subsection immersed solid
subsection tanh levelset
set tracer diffusivity inside = 1
set tracer diffusivity outside = 1
set tracer diffusivity thickness = 1
end
end
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can the diffusivity at the outside edge of the solid be different from the fluid diffusivity?

source/solvers/gls_navier_stokes.cc Outdated Show resolved Hide resolved
source/solvers/navier_stokes_base.cc Outdated Show resolved Hide resolved
source/solvers/tracer_scratch_data.cc Outdated Show resolved Hide resolved
@oguevremont oguevremont force-pushed the tracer_with_sharp branch 2 times, most recently from 740ad65 to 6b363fe Compare July 8, 2024 19:08
@blaisb
Copy link
Contributor

blaisb commented Jul 8, 2024

@oguevremont is this ready to review or not ? It seems to be in an intermediary state. If so please remove the ready to review label

@oguevremont
Copy link
Collaborator Author

@oguevremont is this ready to review or not ? It seems to be in an intermediary state. If so please remove the ready to review label

It is not ready yet, I forgot to remove the ready to review label.

@oguevremont oguevremont added the WIP When a PR is open but not ready for review label Jul 8, 2024
@oguevremont oguevremont added Ready for review and removed WIP When a PR is open but not ready for review labels Jul 8, 2024
doc/source/parameters/cfd/physical_properties.rst Outdated Show resolved Hide resolved
doc/source/parameters/cfd/physical_properties.rst Outdated Show resolved Hide resolved
include/core/tracer_diffusivity_model.h Outdated Show resolved Hide resolved
Comment on lines 231 to 245
void
vector_jacobian(const std::map<field, std::vector<double>> &field_vectors,
const field id,
std::vector<double> &jacobian_vector) override
{
AssertThrow(field_vectors.find(field::levelset) != field_vectors.end(),
PhysicialPropertyModelFieldUndefined(
"LevelsetDependentTracerDiffusivity", "levelset"));
vector_numerical_jacobian(field_vectors, id, jacobian_vector);
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the jacobian_vector is always initialized with zeros, this will work. But if it's not, I think you should have the same if condition as the jacobinan() function.

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 added the condition to be safe

@blaisb blaisb requested a review from hepap July 10, 2024 15:26
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.

Just a few minor things there and there, but after that this is good to go for me.

doc/source/parameters/cfd/physical_properties.rst Outdated Show resolved Hide resolved
doc/source/parameters/cfd/physical_properties.rst Outdated Show resolved Hide resolved
source/solvers/tracer.cc Outdated Show resolved Hide resolved
@@ -71,15 +80,16 @@ TracerScratchData<dim>::calculate_physical_properties()
diffusivity_models[0]->vector_value(fields, tracer_diffusivity_0);
diffusivity_models[1]->vector_value(fields, tracer_diffusivity_1);

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe would be a good time to add an assert here instead so that it Throws.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For now we don't support tracer with 2 fluids at all right? So can I just throw an error instead of using an assert?

Comment on lines +4 to +7
DEAL:: levelset = 0, diffusivity = 1.00000, dD/dlevelset numerical = 20.0000
DEAL:: levelset = 100, diffusivity = 2.00000, dD/dlevelset numerical = 0.00000
DEAL:: levelset = -100, diffusivity = 0.00000, dD/dlevelset numerical = 0.00000
DEAL::OK
Copy link
Contributor

Choose a reason for hiding this comment

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

legit, no worries then

@blaisb blaisb merged commit e7bfe64 into master Jul 12, 2024
8 checks passed
@blaisb blaisb deleted the tracer_with_sharp branch July 12, 2024 19:07
M-Badri pushed a commit to M-Badri/lethe that referenced this pull request Sep 29, 2024
Description
Previously, the tracer physics used with the Sharp IB solver could not consider material dependent physical properties: both fluid and solid had the same diffusivity.
Now, physical properties of immersed solids are defined using the solid 0 section, though only one solid can be used at the moment.
A tracer diffusivity model based on the signed distance function used in the Sharp IB has been added, which allows to smooth the diffusivity transition at the fluid/solid interface. The architecture is there for future models and could serve as a base for reactive physics models used in heterogeneous catalysis.
Testing
[tests/core/immersed_solid_diffusivity_tanh] Unit test for the tanh diffusivity transition model.
[applications_tests/lethe-fluid-sharp/tracer_around_sphere] 2D application test where the tracer physics is used with the Sharp IB solver. This also tests the new diffusivity model.
Documentation
[doc/source/parameters/cfd/physical_properties] The new model has been added in new section where immersed solids models will be added in the future.

Co-authored-by: hepap <[email protected]>
Co-authored-by: Bruno Blais <[email protected]>
Former-commit-id: e7bfe64
blaisb added a commit that referenced this pull request Sep 30, 2024
Description
Previously, the tracer physics used with the Sharp IB solver could not consider material dependent physical properties: both fluid and solid had the same diffusivity.
Now, physical properties of immersed solids are defined using the solid 0 section, though only one solid can be used at the moment.
A tracer diffusivity model based on the signed distance function used in the Sharp IB has been added, which allows to smooth the diffusivity transition at the fluid/solid interface. The architecture is there for future models and could serve as a base for reactive physics models used in heterogeneous catalysis.
Testing
[tests/core/immersed_solid_diffusivity_tanh] Unit test for the tanh diffusivity transition model.
[applications_tests/lethe-fluid-sharp/tracer_around_sphere] 2D application test where the tracer physics is used with the Sharp IB solver. This also tests the new diffusivity model.
Documentation
[doc/source/parameters/cfd/physical_properties] The new model has been added in new section where immersed solids models will be added in the future.

Co-authored-by: hepap <[email protected]>
Co-authored-by: Bruno Blais <[email protected]>
Former-commit-id: e7bfe64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants