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
0 commit comments