Skip to content

[KratosBio] - Adding Windkessel feature #13448

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

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

Conversation

AMontanino87
Copy link
Contributor

The pull request implements the Windkessel boundary conditions adding a process to the FluidDynamicBiomedicalApplication.

Also unit test are provided to check everything is working fine

@AMontanino87 AMontanino87 requested a review from a team as a code owner May 19, 2025 16:44
@@ -0,0 +1,138 @@
import math
import KratosMultiphysics
from KratosMultiphysics.assign_scalar_variable_process import AssignScalarVariableProcess
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
from KratosMultiphysics.assign_scalar_variable_process import AssignScalarVariableProcess

I think you don't need this.

@@ -0,0 +1,138 @@
import math
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import math

I think you don't need this.


default_settings = KratosMultiphysics.Parameters("""
{
"mesh_id" : 0,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"mesh_id" : 0,

This is no longer needed.

Comment on lines 30 to 31
"resistance1" : 0.0,
"resistance2" : 0.0,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"resistance1" : 0.0,
"resistance2" : 0.0,
"resistance_1" : 0.0,
"resistance_2" : 0.0,

To follow our standard. Besides, if these are not customary ones in de literature (IDK), I'd try to use a more descriptive name for these two values to ease the use.

"compliance" : 0.0,
"venous_pressure" : 0.0,
"initial_pressure" : 0.0,
"pressure_in_mmHg" : true,
Copy link
Member

Choose a reason for hiding this comment

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

Instead, I'd suggest a pressure_unit field that can take string values as Pa and mmHg (otherwise an error is thrown). By doing so you leave the room open to extend it to other units if required in the future.

Comment on lines 53 to 59
pres_settings = settings.Clone()
pres_settings.RemoveValue("resistance1")
pres_settings.RemoveValue("resistance2")
pres_settings.RemoveValue("compliance")
pres_settings.RemoveValue("initial_pressure")
pres_settings.RemoveValue("venous_pressure")
pres_settings.RemoveValue("echo_level")
Copy link
Member

Choose a reason for hiding this comment

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

Which is the purpose of pres_settings? You're using it nowhere.

pres_settings.RemoveValue("echo_level")

# Create a copy of the PRESSURE settings to set the EXTERNAL_PRESSURE
ext_pres_settings = pres_settings.Clone()
Copy link
Member

Choose a reason for hiding this comment

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

Which is the purpose of ext_pres_settings? You're using it nowhere.

Comment on lines +104 to +107
for node in self.outlet_model_part.Nodes:
node.Set(KratosMultiphysics.OUTLET, True)
for condition in self.outlet_model_part.Conditions:
condition.Set(KratosMultiphysics.OUTLET, True)
Copy link
Member

Choose a reason for hiding this comment

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

You can use the SetFlag method from the VariableUtils (it is exported to Python) so these two loops are done in parallel.

Comment on lines 120 to 124
print('Current flow rate', self.current_q1)
if self.pressure_in_mmHg:
print('Outlet new pressure:', self.modified_p1/self.conv, " mmHg")
else:
print('Outlet new pressure:', self.modified_p1, " Pa")
Copy link
Member

Choose a reason for hiding this comment

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

Please use the Logger class for this. Browse for KratosMultiphysics.Logger.PrintInfo usages to see many examples.

Comment on lines 32 to 39
@classmethod
def __GetBlankParameters(cls):
return KratosMultiphysics.Parameters("""{
"name" : "Processes.KratosMultiphysics.FluidDynamicsBiomedicalApplication.apply_windkessel_outlet_process",
"Parameters" : {
"model_part_name" : "OutletModelPart"
}
}""")
Copy link
Member

Choose a reason for hiding this comment

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

Which is the purpose of these?

Comment on lines 41 to 43
@classmethod
def tearDown(self):
KratosUtilities.DeleteFileIfExisting("test_outlet_table.csv")
Copy link
Member

Choose a reason for hiding this comment

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

I think this is doing nothing.

@@ -0,0 +1,126 @@
import csv
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import csv

I think you don't need this.

import KratosMultiphysics
import KratosMultiphysics.KratosUnittest as KratosUnittest
import KratosMultiphysics.kratos_utilities as KratosUtilities
from KratosMultiphysics.FluidDynamicsApplication import apply_outlet_process
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
from KratosMultiphysics.FluidDynamicsApplication import apply_outlet_process

I think you don't need this.

Copy link
Member

@rubenzorrilla rubenzorrilla left a comment

Choose a reason for hiding this comment

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

Some minor comments, mainly related to things that can be removed.

As a comment aside, why don't we make the process in c++ so we can make the nodal loop in parallel?

@rubenzorrilla rubenzorrilla changed the title [KratosBio] - Adding Windkessek feature [KratosBio] - Adding Windkessel feature May 20, 2025
Copy link
Member

@rubenzorrilla rubenzorrilla left a comment

Choose a reason for hiding this comment

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

Looks nice now! Thanks for taking my comments into consideration.

@rubenzorrilla
Copy link
Member

@AMontanino87 @soudah I think you forgot to merge this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants