def Initialize(self, meshing_parameters, dimension): print("::[Meshing Strategy]:: -START-") #meshing parameters self.MeshingParameters = meshing_parameters meshing_options = KratosMultiphysics.Flags() meshing_options.Set(KratosPfem.ModelerUtilities.REMESH, self.settings["remesh"].GetBool()) meshing_options.Set(KratosPfem.ModelerUtilities.REFINE, self.settings["refine"].GetBool()) meshing_options.Set(KratosPfem.ModelerUtilities.RECONNECT, self.settings["reconnect"].GetBool()) meshing_options.Set(KratosPfem.ModelerUtilities.TRANSFER, self.settings["transfer"].GetBool()) meshing_options.Set(KratosPfem.ModelerUtilities.CONSTRAINED, self.settings["constrained"].GetBool()) meshing_options.Set(KratosPfem.ModelerUtilities.MESH_SMOOTHING, self.settings["mesh_smoothing"].GetBool()) meshing_options.Set(KratosPfem.ModelerUtilities.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 = KratosPfem.MeshDataTransferUtilities() self.TransferParameters = KratosPfem.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 modelers for the current strategy self.mesh_modelers = [] #configure meshers: self.SetMeshModelers() 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.mesh_modelers: mesher.SetEchoLevel(self.echo_level) mesher.Initialize(dimension) self.number_of_nodes = 0 self.number_of_elements = 0 self.number_of_conditions = 0 print("::[Meshing Strategy]:: -END-")
def Initialize(self, meshing_parameters, dimension): #parameters self.echo_level = 1 #meshing parameters self.MeshingParameters = meshing_parameters meshing_options = KratosMultiphysics.Flags() meshing_options.Set(KratosPfem.ModelerUtilities.REMESH, self.settings["remesh"].GetBool()) meshing_options.Set(KratosPfem.ModelerUtilities.CONSTRAINED, self.settings["constrained"].GetBool()) meshing_options.Set(KratosPfem.ModelerUtilities.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 = KratosPfem.MeshDataTransferUtilities() self.TransferParameters = KratosPfem.TransferParameters() self.global_transfer = False #mesh modelers for the current strategy self.mesh_modelers = [] #configure meshers: self.SetMeshModelers() for mesher in self.mesh_modelers: 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( KratosPfem.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( KratosPfem.MeshDataTransferUtilities.INITIALIZE_MASTER_CONDITION, False) transfer_options.Set( KratosPfem.MeshDataTransferUtilities. MASTER_ELEMENT_TO_MASTER_CONDITION, True) transfer_parameters.SetOptions(transfer_options)