def SetTransferParameters(self): # Create TransferParameters self.TransferParameters = KratosDelaunay.TransferParameters() transfer_variables = self.settings["elemental_variables_to_transfer"] #for variable in transfer_variables: # self.TransferParameters.SetVariable( KratosMultiphysics.KratosGlobals.GetVariable( variable.GetString() ) ) for i in range(0, transfer_variables.size()): self.TransferParameters.SetVariable( KratosMultiphysics.KratosGlobals.GetVariable( transfer_variables[i].GetString()))
def Initialize(self,meshing_parameters,dimension): #meshing parameters self.MeshingParameters = meshing_parameters meshing_options = KratosMultiphysics.Flags() meshing_options.Set(KratosDelaunay.MesherUtilities.REMESH, self.settings["remesh"].GetBool()) meshing_options.Set(KratosDelaunay.MesherUtilities.REFINE, self.settings["refine"].GetBool()) meshing_options.Set(KratosDelaunay.MesherUtilities.TRANSFER, self.settings["transfer"].GetBool()) meshing_options.Set(KratosDelaunay.MesherUtilities.RECONNECT, False) meshing_options.Set(KratosDelaunay.MesherUtilities.CONSTRAINED, False) meshing_options.Set(KratosDelaunay.MesherUtilities.MESH_SMOOTHING, False) meshing_options.Set(KratosDelaunay.MesherUtilities.VARIABLES_SMOOTHING, False) self.MeshingParameters.SetOptions(meshing_options) self.MeshingParameters.SetReferenceElement(self.settings["reference_element_type"].GetString()) self.MeshingParameters.SetReferenceCondition(self.settings["reference_condition_type"].GetString()) #set variables to global transfer self.MeshDataTransfer = KratosDelaunay.MeshDataTransferUtilities() self.TransferParameters = KratosDelaunay.TransferParameters() self.global_transfer = False #mesh meshers for the current strategy self.meshers = [] #configure meshers: self.SetMeshers(); self.model_part = self.main_model_part if( self.main_model_part.Name != self.MeshingParameters.GetSubModelPartName() ): self.model_part = self.main_model_part.GetSubModelPart(self.MeshingParameters.GetSubModelPartName()) for mesher in self.meshers: mesher.SetEchoLevel(self.echo_level) mesher.Initialize(dimension) self.number_of_nodes = 0 self.number_of_elements = 0 self.number_of_conditions = 0
def Initialize(self, meshing_parameters, dimension): #parameters self.echo_level = 0 #meshing parameters self.MeshingParameters = meshing_parameters meshing_options = KratosMultiphysics.Flags() meshing_options.Set(KratosDelaunay.MesherUtilities.REMESH, self.settings["remesh"].GetBool()) meshing_options.Set(KratosDelaunay.MesherUtilities.CONSTRAINED, self.settings["constrained"].GetBool()) meshing_options.Set(KratosDelaunay.MesherUtilities.CONTACT_SEARCH, True) self.MeshingParameters.SetOptions(meshing_options) self.MeshingParameters.SetReferenceCondition( self.settings["contact_parameters"] ["contact_condition_type"].GetString()) #set contact properties properties = KratosMultiphysics.Properties(0) contact_parameters = self.settings["contact_parameters"] #build friction law :: pass it as a property parameter friction_law_module = contact_parameters["kratos_module"].GetString() friction_law_type_name = contact_parameters[ "friction_law_type"].GetString() #import module if not previously imported module = __import__(friction_law_module) module_name = (friction_law_module.split("."))[-1] FrictionLaw = getattr(getattr(module, module_name), friction_law_type_name) friction_law = FrictionLaw() #properties have not python interface for this variable type #properties.SetValue( KratosContact.FRICTION_LAW, friction_law.Clone() ) #properties.SetValue(KratosContact.FRICTION_LAW_NAME, friction_law_type_name ) properties.SetValue( KratosMultiphysics.KratosGlobals.GetVariable("FRICTION_LAW_NAME"), friction_law_type_name) contact_variables = contact_parameters["variables_of_properties"] #iterators of a json list are not working right now :: must be done by hand: properties.SetValue( KratosMultiphysics.KratosGlobals.GetVariable("FRICTION_ACTIVE"), contact_variables["FRICTION_ACTIVE"].GetBool()) properties.SetValue( KratosMultiphysics.KratosGlobals.GetVariable("MU_STATIC"), contact_variables["MU_STATIC"].GetDouble()) properties.SetValue( KratosMultiphysics.KratosGlobals.GetVariable("MU_DYNAMIC"), contact_variables["MU_DYNAMIC"].GetDouble()) properties.SetValue( KratosMultiphysics.KratosGlobals.GetVariable("PENALTY_PARAMETER"), contact_variables["PENALTY_PARAMETER"].GetDouble()) properties.SetValue( KratosMultiphysics.KratosGlobals.GetVariable( "TANGENTIAL_PENALTY_RATIO"), contact_variables["TANGENTIAL_PENALTY_RATIO"].GetDouble()) properties.SetValue( KratosMultiphysics.KratosGlobals.GetVariable("TAU_STAB"), contact_variables["TAU_STAB"].GetDouble()) self.MeshingParameters.SetProperties(properties) #set variables to global transfer self.MeshDataTransfer = KratosDelaunay.MeshDataTransferUtilities() self.TransferParameters = KratosDelaunay.TransferParameters() self.global_transfer = False #mesh meshers for the current strategy self.meshers = [] #configure meshers: self.SetMeshers() for mesher in self.meshers: mesher.Initialize(dimension) self.number_of_nodes = 0 self.number_of_elements = 0 self.number_of_conditions = 0 # prepare model conditions to recieve data transfer_parameters = self.MeshingParameters.GetTransferParameters() transfer_options = transfer_parameters.GetOptions() if (self.main_model_part.ProcessInfo[KratosMultiphysics.IS_RESTARTED] == False): transfer_options.Set( KratosDelaunay.MeshDataTransferUtilities. INITIALIZE_MASTER_CONDITION, True) transfer_parameters.SetOptions(transfer_options) self.MeshDataTransfer.TransferBoundaryData(transfer_parameters, self.main_model_part) # set flags for the transfer needed for the contact domain transfer_options.Set( KratosDelaunay.MeshDataTransferUtilities. INITIALIZE_MASTER_CONDITION, False) transfer_options.Set( KratosDelaunay.MeshDataTransferUtilities. MASTER_ELEMENT_TO_MASTER_CONDITION, True) transfer_parameters.SetOptions(transfer_options)
def Initialize(self, meshing_parameters, dimension): #meshing parameters self.MeshingParameters = meshing_parameters meshing_options = KratosMultiphysics.Flags() meshing_options.Set(KratosDelaunay.MesherUtilities.REMESH, self.settings["remesh"].GetBool()) meshing_options.Set(KratosDelaunay.MesherUtilities.REFINE, self.settings["refine"].GetBool()) meshing_options.Set(KratosDelaunay.MesherUtilities.RECONNECT, self.settings["reconnect"].GetBool()) meshing_options.Set(KratosDelaunay.MesherUtilities.TRANSFER, self.settings["transfer"].GetBool()) meshing_options.Set(KratosDelaunay.MesherUtilities.CONSTRAINED, self.settings["constrained"].GetBool()) meshing_options.Set(KratosDelaunay.MesherUtilities.MESH_SMOOTHING, self.settings["mesh_smoothing"].GetBool()) meshing_options.Set(KratosDelaunay.MesherUtilities.VARIABLES_SMOOTHING, self.settings["variables_smoothing"].GetBool()) self.MeshingParameters.SetOptions(meshing_options) self.MeshingParameters.SetReferenceElement( self.settings["reference_element_type"].GetString()) self.MeshingParameters.SetReferenceCondition( self.settings["reference_condition_type"].GetString()) #set variables to global transfer self.MeshDataTransfer = KratosDelaunay.MeshDataTransferUtilities() self.TransferParameters = KratosDelaunay.TransferParameters() self.global_transfer = False if (self.settings["variables_smoothing"].GetBool() == True): self.global_transfer = True transfer_variables = self.settings["elemental_variables_to_smooth"] #for variable in transfer_variables: # self.TransferParameters.SetVariable( KratosMultiphysics.KratosGlobals.GetVariable( variable.GetString() ) ) for i in range(0, transfer_variables.size()): self.TransferParameters.SetVariable( KratosMultiphysics.KratosGlobals.GetVariable( transfer_variables[i].GetString())) #mesh meshers for the current strategy self.meshers = [] #configure meshers: self.SetMeshers() self.model_part = self.main_model_part if (self.main_model_part.Name != self.MeshingParameters.GetSubModelPartName()): self.model_part = self.main_model_part.GetSubModelPart( self.MeshingParameters.GetSubModelPartName()) for mesher in self.meshers: mesher.SetEchoLevel(self.echo_level) mesher.Initialize(dimension) self.number_of_nodes = 0 self.number_of_elements = 0 self.number_of_conditions = 0 print(self._class_prefix() + " Ready")