示例#1
0
    def __init__(self, main_model_part, custom_settings):
        
        self.main_model_part = main_model_part    

        ##settings string in json format
        default_settings = KratosMultiphysics.Parameters("""
        {
            "python_module"   : "rigid_body",
            "model_part_name" : "RigidBodyDomain",
            "rigid_body_settings":{
               "rigid_body_element_type": "TranslatoryRigidElement3D1N",
               "fixed_body": true,
               "compute_body_parameters": false,
               "rigid_body_model_part_name": "RigidBodyDomain",
               "rigid_body_parameters":{
                   "center_of_gravity": [0.0 ,0.0, 0.0],
                   "mass":0.0,
                   "main_inertias": [0.0, 0.0, 0.0],
                   "main_axes": [ [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0] ]
               }
            }
        }
        """)
        
        ## new node and rigid body element inside the same mesh : boundary conditions also applied
        ## this node and elements must be considered in the computing model part
        ## new contact conditions must be already assembled

        ## if exist a movement from a point different from CG a link condition must be used

        ##overwrite the default settings with user-provided parameters
        self.settings = custom_settings
        self.settings.ValidateAndAssignDefaults(default_settings)
                
        # construct rigid body // it will contain the array of nodes, array of elements, and the array of conditions
        self.rigid_body_model_part = self.main_model_part.GetSubModelPart(self.settings["model_part_name"].GetString())
        self.rigid_body_model_part.Set(KratosMultiphysics.RIGID)
        
        for node in self.rigid_body_model_part.Nodes:
            node.Set(KratosMultiphysics.RIGID,True)

        for node in self.rigid_body_model_part.Conditions:
            node.Set(KratosMultiphysics.ACTIVE,False)
 

        #check for the bounding box of a compound wall
        box_settings = KratosMultiphysics.Parameters("""
        {
            "parameters_list":[{
                   "upper_point": [0.0, 0.0, 0.0],
                   "lower_point": [0.0, 0.0, 0.0],
                   "convexity": 1
            }],
            "velocity" : [0.0, 0.0, 0.0]
        }
        """)

        box_parameters = box_settings["parameters_list"][0]
        
        upper_point = self.GetUpperPoint(self.rigid_body_model_part)
        counter = 0
        for i in upper_point:
            box_parameters["upper_point"][counter].SetDouble(i)
            counter+=1

        lower_point = self.GetLowerPoint(self.rigid_body_model_part)
        counter = 0
        for i in lower_point:
            box_parameters["lower_point"][counter].SetDouble(i)
            counter+=1

        self.bounding_box = KratosPfemBase.SpatialBoundingBox(box_settings)
        
        # construct rigid element // must pass an array of nodes to the element, create a node (CG) and a rigid element set them in the model_part, set the node CG as the reference node of the wall_bounding_box, BLOCKED, set in the wall_model_part for imposed movements processes.
        creation_utility = KratosContact.RigidBodyCreationUtility()
        creation_utility.CreateRigidBodyElement(self.main_model_part, self.bounding_box, self.settings["rigid_body_settings"])


        print("::[Rigid_Body]:: -BUILT-")
示例#2
0
    def SetRefiningParameters(self):

        # Create RefiningParameters
        self.RefiningParameters = KratosPfemBase.RefiningParameters()
        self.RefiningParameters.Initialize()

        # parameters
        self.RefiningParameters.SetAlphaParameter(
            self.settings["alpha_shape"].GetDouble())

        # custom set of the mesh size from settings from initial mesh or other parts
        self.SetMeshSizeValues()

        # set mesh refinement in box
        size = self.domain_size
        refining_box = self.settings["refining_parameters"]["refining_box"]
        if (refining_box["refine_in_box_only"].GetBool()):
            radius = refining_box["radius"].GetDouble()
            center = Vector(size)
            velocity = Vector(size)

            for i in range(0, size):
                center[i] = refining_box["center"][i].GetDouble()
                velocity[i] = refining_box["velocity"][i].GetDouble()

            refining_box = KratosPfemBase.SpatialBoundingBox(
                center, radius, velocity)
            self.RefiningParameters.SetRefiningBox(refining_box)

        self.RefiningParameters.SetThresholdVariable(
            KratosMultiphysics.KratosGlobals.GetVariable(
                self.settings["refining_parameters"]
                ["threshold_variable"].GetString()))
        self.RefiningParameters.SetReferenceThreshold(
            self.settings["refining_parameters"]
            ["reference_threshold"].GetDouble())

        self.RefiningParameters.SetErrorVariable(
            KratosMultiphysics.KratosGlobals.GetVariable(
                self.settings["refining_parameters"]
                ["error_variable"].GetString()))
        self.RefiningParameters.SetReferenceError(
            self.settings["refining_parameters"]
            ["reference_error"].GetDouble())

        removing_options = KratosMultiphysics.Flags()

        #remove nodes
        remove_nodes = self.settings["refining_parameters"]["remove_nodes"]
        removing_options.Set(KratosPfemBase.ModelerUtilities.REMOVE_NODES,
                             remove_nodes["apply_removal"].GetBool())
        removing_options.Set(
            KratosPfemBase.ModelerUtilities.REMOVE_NODES_ON_DISTANCE,
            remove_nodes["on_distance"].GetBool())
        removing_options.Set(
            KratosPfemBase.ModelerUtilities.REMOVE_NODES_ON_ERROR,
            remove_nodes["on_error"].GetBool())
        removing_options.Set(
            KratosPfemBase.ModelerUtilities.REMOVE_NODES_ON_THRESHOLD,
            remove_nodes["on_threshold"].GetBool())

        #remove boundary
        remove_boundary = self.settings["refining_parameters"][
            "remove_boundary"]
        removing_options.Set(
            KratosPfemBase.ModelerUtilities.REMOVE_BOUNDARY_NODES,
            remove_boundary["apply_removal"].GetBool())
        removing_options.Set(
            KratosPfemBase.ModelerUtilities.REMOVE_BOUNDARY_NODES_ON_DISTANCE,
            remove_boundary["on_distance"].GetBool())
        removing_options.Set(
            KratosPfemBase.ModelerUtilities.REMOVE_BOUNDARY_NODES_ON_ERROR,
            remove_boundary["on_error"].GetBool())
        removing_options.Set(
            KratosPfemBase.ModelerUtilities.REMOVE_BOUNDARY_NODES_ON_THRESHOLD,
            remove_boundary["on_threshold"].GetBool())

        refining_options = KratosMultiphysics.Flags()
        refining_options.Set(
            KratosPfemBase.ModelerUtilities.REFINE,
            self.settings["meshing_strategy"]["refine"].GetBool())
        refining_options.Set(
            KratosPfemBase.ModelerUtilities.REFINE_ADD_NODES,
            self.settings["refining_parameters"]["add_nodes"].GetBool())
        refining_options.Set(
            KratosPfemBase.ModelerUtilities.REFINE_INSERT_NODES,
            self.settings["refining_parameters"]["insert_nodes"].GetBool())

        #refine elements
        refine_elements = self.settings["refining_parameters"][
            "refine_elements"]
        refining_options.Set(KratosPfemBase.ModelerUtilities.REFINE_ELEMENTS,
                             refine_elements["apply_refinement"].GetBool())
        refining_options.Set(
            KratosPfemBase.ModelerUtilities.REFINE_ELEMENTS_ON_DISTANCE,
            refine_elements["on_distance"].GetBool())
        refining_options.Set(
            KratosPfemBase.ModelerUtilities.REFINE_ELEMENTS_ON_ERROR,
            refine_elements["on_error"].GetBool())
        refining_options.Set(
            KratosPfemBase.ModelerUtilities.REFINE_ELEMENTS_ON_THRESHOLD,
            refine_elements["on_threshold"].GetBool())

        #refine boundary
        refine_boundary = self.settings["refining_parameters"][
            "refine_boundary"]
        refining_options.Set(KratosPfemBase.ModelerUtilities.REFINE_BOUNDARY,
                             refine_boundary["apply_refinement"].GetBool())
        refining_options.Set(
            KratosPfemBase.ModelerUtilities.REFINE_BOUNDARY_ON_DISTANCE,
            refine_boundary["on_distance"].GetBool())
        refining_options.Set(
            KratosPfemBase.ModelerUtilities.REFINE_BOUNDARY_ON_ERROR,
            refine_boundary["on_error"].GetBool())
        refining_options.Set(
            KratosPfemBase.ModelerUtilities.REFINE_BOUNDARY_ON_THRESHOLD,
            refine_boundary["on_threshold"].GetBool())

        self.RefiningParameters.SetRefiningOptions(refining_options)
        self.RefiningParameters.SetRemovingOptions(removing_options)