Skip to content

Commit a4d6d95

Browse files
Merge pull request #14465 from KratosMultiphysics/iga/compute_interface_traction_shell_3p
[Iga/CoSim] Add interface traction computation for shell 3p (K-L) and respective CoSim coupling operation
2 parents dfd3e31 + e18962d commit a4d6d95

14 files changed

Lines changed: 1169 additions & 2 deletions
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Importing the Kratos Library
2+
import KratosMultiphysics as KM
3+
import KratosMultiphysics.IgaApplication as KratosIGA
4+
5+
# Importing the base class
6+
from KratosMultiphysics.CoSimulationApplication.base_classes.co_simulation_coupling_operation import CoSimulationCouplingOperation
7+
8+
# CoSimulation imports
9+
import KratosMultiphysics.CoSimulationApplication.co_simulation_tools as cs_tools
10+
11+
12+
def Create(*args):
13+
return ComputeInterfaceTractionShell3pIGA(*args)
14+
15+
16+
class ComputeInterfaceTractionShell3pIGA(CoSimulationCouplingOperation):
17+
"""Computes and stores interface tractions on Shell 3p IGA interface conditions."""
18+
19+
def __init__(self, settings, solver_wrappers, process_info, data_communicator):
20+
super().__init__(settings, process_info, data_communicator)
21+
22+
model = solver_wrappers[self.settings["solver"].GetString()].model
23+
24+
self.model_part_name = self.settings["model_part_name"].GetString()
25+
self.model_part = model[self.model_part_name]
26+
27+
self.interval = KM.IntervalUtility(self.settings)
28+
29+
self.traction_variable = KM.KratosGlobals.GetVariable(
30+
self.settings["traction_variable_name"].GetString()
31+
)
32+
33+
def InitializeCouplingIteration(self):
34+
if self.interval.IsInInterval(self.model_part.ProcessInfo[KM.TIME]):
35+
self._ComputeInterfaceTractionShell3pIGA()
36+
37+
if self.echo_level > 0:
38+
cs_tools.cs_print_info(
39+
self._ClassName(),
40+
"Interface tractions calculated in ModelPart: " + self.model_part_name
41+
)
42+
43+
def _CopyMissingMaterialPropertiesToConditions(self):
44+
root_model_part = self.model_part.GetRootModelPart()
45+
46+
elem_props = root_model_part.Elements[1].Properties
47+
48+
vars_to_copy = [
49+
KM.DENSITY,
50+
KM.YOUNG_MODULUS,
51+
KM.POISSON_RATIO,
52+
KM.THICKNESS,
53+
KM.CONSTITUTIVE_LAW
54+
]
55+
56+
for cond in self.model_part.Conditions:
57+
cond_props = cond.Properties
58+
59+
for var in vars_to_copy:
60+
if elem_props.Has(var) and not cond_props.Has(var):
61+
cond_props.SetValue(var, elem_props[var])
62+
63+
64+
def _ComputeInterfaceTractionShell3pIGA(self):
65+
self._CopyMissingMaterialPropertiesToConditions()
66+
67+
KratosIGA.ComputeInterfaceTractionShell3pUtility.ComputeAndSetInterfaceTraction(
68+
self.model_part,
69+
self.traction_variable
70+
)
71+
72+
@classmethod
73+
def _GetDefaultParameters(cls):
74+
this_defaults = KM.Parameters("""{
75+
"solver" : "UNSPECIFIED",
76+
"model_part_name" : "",
77+
"traction_variable_name" : "INTERFACE_TRACTION",
78+
"interval" : [0.0, 1e30]
79+
}""")
80+
this_defaults.AddMissingParameters(super()._GetDefaultParameters())
81+
return this_defaults

applications/IgaApplication/custom_python/add_custom_utilities_to_python.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "spaces/ublas_space.h"
2323
#include "custom_utilities/director_utilities.h"
2424
#include "custom_utilities/iga_flags.h"
25+
#include "custom_utilities/compute_interface_traction_shell_3p.h"
2526

2627

2728
namespace Kratos {
@@ -46,6 +47,12 @@ void AddCustomUtilitiesToPython(
4647
iga_flags.attr("FIX_ROTATION_X") = IgaFlags::FIX_ROTATION_X;
4748
iga_flags.attr("FIX_ROTATION_Y") = IgaFlags::FIX_ROTATION_Y;
4849
iga_flags.attr("FIX_ROTATION_Z") = IgaFlags::FIX_ROTATION_Z;
50+
51+
pybind11::class_< ComputeInterfaceTractionShell3pUtility >(m, "ComputeInterfaceTractionShell3pUtility")
52+
.def_static(
53+
"ComputeAndSetInterfaceTraction",
54+
&ComputeInterfaceTractionShell3pUtility::ComputeAndSetInterfaceTraction)
55+
;
4956
}
5057

5158
} // namespace Python

0 commit comments

Comments
 (0)