Exemplo n.º 1
0
    def _initialize_alm_parameters(self, computing_model_part):
        """ This method initializes the ALM parameters from the process info

        Keyword arguments:
        self -- It signifies an instance of a class.
        computing_model_part -- The model part that contains the structural problem to be solved
        """

        # We call the process info
        process_info = self.main_model_part.ProcessInfo

        if (self.settings["advance_ALM_parameters"]["manual_ALM"].GetBool() is False):
            # Computing the scale factors or the penalty parameters (StiffnessFactor * E_mean/h_mean)
            alm_var_parameters = KM.Parameters("""{}""")
            alm_var_parameters.AddValue("stiffness_factor", self.settings["advance_ALM_parameters"]["stiffness_factor"])
            alm_var_parameters.AddValue("penalty_scale_factor", self.settings["advance_ALM_parameters"]["penalty_scale_factor"])
            self.alm_var_process = CSMA.ALMVariablesCalculationProcess(self.contact_model_part, KM.NODAL_H, alm_var_parameters)
            self.alm_var_process.Execute()
            # We don't consider scale factor
            if (self.settings["advance_ALM_parameters"]["use_scale_factor"].GetBool() is False):
                process_info[KM.SCALE_FACTOR] = 1.0
        else:
            # We set the values in the process info
            process_info[KM.INITIAL_PENALTY] = self.settings["advance_ALM_parameters"]["penalty"].GetDouble()
            process_info[KM.SCALE_FACTOR] = self.settings["advance_ALM_parameters"]["scale_factor"].GetDouble()

        # We set a minimum value
        if (process_info[KM.INITIAL_PENALTY] < sys.float_info.epsilon):
            process_info[KM.INITIAL_PENALTY] = 1.0e0
        if (process_info[KM.SCALE_FACTOR] < sys.float_info.epsilon):
            process_info[KM.SCALE_FACTOR] = 1.0e0
            
        # We print the parameters considered
        KM.Logger.PrintInfo("SCALE_FACTOR: ", "{:.2e}".format(process_info[KM.SCALE_FACTOR]))
        KM.Logger.PrintInfo("INITIAL_PENALTY: ", "{:.2e}".format(process_info[KM.INITIAL_PENALTY]))
Exemplo n.º 2
0
    def _initialize_problem_parameters(self):
        """ This method initializes the ALM parameters from the process info

        Keyword arguments:
        self -- It signifies an instance of a class.
        """

        # We call to the base process (in fact not, to avoid writing twice the values)
        #super(PenaltyContactProcess, self)._initialize_problem_parameters()

        # We call the process info
        process_info = self.main_model_part.ProcessInfo

        if not self.contact_settings["advance_ALM_parameters"][
                "manual_ALM"].GetBool():
            # We compute NODAL_H that can be used in the search and some values computation
            self.find_nodal_h = KM.FindNodalHProcess(self.computing_model_part)
            self.find_nodal_h.Execute()

            # Computing the scale factors or the penalty parameters (StiffnessFactor * E_mean/h_mean)
            alm_var_parameters = KM.Parameters("""{}""")
            alm_var_parameters.AddValue(
                "stiffness_factor",
                self.contact_settings["advance_ALM_parameters"]
                ["stiffness_factor"])
            alm_var_parameters.AddValue(
                "penalty_scale_factor",
                self.contact_settings["advance_ALM_parameters"]
                ["penalty_scale_factor"])
            self.alm_var_process = CSMA.ALMVariablesCalculationProcess(
                self._get_process_model_part(), KM.NODAL_H, alm_var_parameters)
            self.alm_var_process.Execute()
            # We rescale, the process is designed for ALM formulation
            process_info[
                KM.INITIAL_PENALTY] = 1.0e0 * process_info[KM.INITIAL_PENALTY]
        else:
            # We set the values in the process info
            process_info[KM.INITIAL_PENALTY] = self.contact_settings[
                "advance_ALM_parameters"]["penalty"].GetDouble()

        # We set a minimum value
        if process_info[KM.INITIAL_PENALTY] < sys.float_info.epsilon:
            process_info[KM.INITIAL_PENALTY] = 1.0e13

        # Setting on nodes
        initial_penalty = process_info[KM.INITIAL_PENALTY]
        KM.VariableUtils().SetNonHistoricalVariable(
            KM.INITIAL_PENALTY, initial_penalty,
            self.computing_model_part.Nodes)

        # We print the parameters considered
        KM.Logger.PrintInfo("INITIAL_PENALTY: ",
                            "{:.2e}".format(process_info[KM.INITIAL_PENALTY]))
Exemplo n.º 3
0
    def _initialize_alm_parameters(self, computing_model_part):
        if (self.params["manual_ALM"].GetBool() == False):
            # Computing the scale factors or the penalty parameters (StiffnessFactor * E_mean/h_mean)
            self.find_nodal_h = KratosMultiphysics.FindNodalHProcess(
                computing_model_part)
            self.find_nodal_h.Execute()

            alm_var_parameters = KratosMultiphysics.Parameters("""{}""")
            alm_var_parameters.AddValue("stiffness_factor",
                                        self.params["stiffness_factor"])
            alm_var_parameters.AddValue("penalty_scale_factor",
                                        self.params["penalty_scale_factor"])
            self.alm_var_process = ContactStructuralMechanicsApplication.ALMVariablesCalculationProcess(
                self.contact_model_part, KratosMultiphysics.NODAL_H,
                alm_var_parameters)
            self.alm_var_process.Execute()
            # We don't consider scale factor
            if (self.params["use_scale_factor"].GetBool() == False):
                self.main_model_part.ProcessInfo[
                    KratosMultiphysics.SCALE_FACTOR] = 1.0
        else:
            # We set the values in the process info
            self.main_model_part.ProcessInfo[
                KratosMultiphysics.
                INITIAL_PENALTY] = self.params["penalty"].GetDouble()
            self.main_model_part.ProcessInfo[
                KratosMultiphysics.
                SCALE_FACTOR] = self.params["scale_factor"].GetDouble()

        # We print the parameters considered
        print("The parameters considered finally are: ")
        print(
            "SCALE_FACTOR: ", "{:.2e}".format(self.main_model_part.ProcessInfo[
                KratosMultiphysics.SCALE_FACTOR]))
        print(
            "INITIAL_PENALTY: ",
            "{:.2e}".format(self.main_model_part.ProcessInfo[
                KratosMultiphysics.INITIAL_PENALTY]))
Exemplo n.º 4
0
    def ExecuteInitialize(self):
        # Appending the conditions created to the self.main_model_part
        computing_model_part = self.main_model_part.GetSubModelPart(
            self.computing_model_part_name)
        if (computing_model_part.HasSubModelPart("Contact")):
            interface_model_part = computing_model_part.GetSubModelPart(
                "Contact")
        else:
            interface_model_part = computing_model_part.CreateSubModelPart(
                "Contact")

        # We consider frictional contact (We use the SLIP flag because was the easiest way)
        if self.params["contact_type"].GetString() == "Frictional":
            computing_model_part.Set(KratosMultiphysics.SLIP, True)
        else:
            computing_model_part.Set(KratosMultiphysics.SLIP, False)

        # We recompute the normal at each iteration (false by default)
        self.main_model_part.ProcessInfo[
            ContactStructuralMechanicsApplication.
            CONSIDER_NORMAL_VARIATION] = self.normal_variation
        # We recompute the pairs at each iteration (true by default)
        self.main_model_part.ProcessInfo[
            ContactStructuralMechanicsApplication.
            CONSIDER_PAIR_VARIATION] = self.params["pair_variation"].GetBool()
        # We set the max gap factor for the gap adaptation
        max_gap_factor = self.params["max_gap_factor"].GetDouble()
        self.main_model_part.ProcessInfo[
            ContactStructuralMechanicsApplication.ADAPT_PENALTY] = (
                max_gap_factor > 0.0)
        self.main_model_part.ProcessInfo[ContactStructuralMechanicsApplication.
                                         MAX_GAP_FACTOR] = max_gap_factor

        # We set the value that scales in the tangent direction the penalty and scale parameter
        if self.params["contact_type"].GetString() == "Frictional":
            self.main_model_part.ProcessInfo[
                ContactStructuralMechanicsApplication.
                TANGENT_FACTOR] = self.params["tangent_factor"].GetDouble()

        # Copying the properties in the contact model part
        self.contact_model_part.SetProperties(
            computing_model_part.GetProperties())

        # Setting the integration order and active check factor
        for prop in computing_model_part.GetProperties():
            prop[ContactStructuralMechanicsApplication.
                 INTEGRATION_ORDER_CONTACT] = self.params[
                     "integration_order"].GetInt()
            prop[ContactStructuralMechanicsApplication.
                 ACTIVE_CHECK_FACTOR] = self.params[
                     "active_check_factor"].GetDouble()

        for node in self.contact_model_part.Nodes:
            node.Set(KratosMultiphysics.INTERFACE, True)
        del (node)

        self.Preprocess = ContactStructuralMechanicsApplication.InterfacePreprocessCondition(
            computing_model_part)

        if self.params["contact_type"].GetString() == "Frictionless":
            if self.normal_variation == True:
                if self.axisymmetric == True:
                    condition_name = "ALMNVFrictionlessAxisymMortarContact"
                else:
                    condition_name = "ALMNVFrictionlessMortarContact"
            else:
                if self.axisymmetric == True:
                    condition_name = "ALMFrictionlessAxisymMortarContact"
                else:
                    condition_name = "ALMFrictionlessMortarContact"
        elif self.params["contact_type"].GetString() == "Frictional":
            if self.normal_variation == True:
                if self.axisymmetric == True:
                    condition_name = "ALMNVFrictionalAxisymMortarContact"
                else:
                    condition_name = "ALMNVFrictionalMortarContact"
            else:
                if self.axisymmetric == True:
                    condition_name = "ALMFrictionalAxisymMortarContact"
                else:
                    condition_name = "ALMFrictionalMortarContact"

        #print("MODEL PART BEFORE CREATING INTERFACE")
        #print(computing_model_part)

        # It should create the conditions automatically
        interface_parameters = KratosMultiphysics.Parameters(
            """{"condition_name": "", "final_string": "", "simplify_geometry": false}"""
        )
        interface_parameters["condition_name"].SetString(condition_name)
        if (self.dimension == 2):
            self.Preprocess.GenerateInterfacePart2D(computing_model_part,
                                                    self.contact_model_part,
                                                    interface_parameters)
        else:
            self.Preprocess.GenerateInterfacePart3D(computing_model_part,
                                                    self.contact_model_part,
                                                    interface_parameters)

        # When all conditions are simultaneously master and slave
        if (self.params["assume_master_slave"].GetString() == ""):
            for node in self.contact_model_part.Conditions:
                node.Set(KratosMultiphysics.SLAVE, True)
            del (node)
            for cond in self.contact_model_part.Conditions:
                cond.Set(KratosMultiphysics.SLAVE, True)
            del (cond)

        if (self.params["manual_ALM"].GetBool() == False):
            # Computing the scale factors or the penalty parameters (StiffnessFactor * E_mean/h_mean)
            self.find_nodal_h = KratosMultiphysics.FindNodalHProcess(
                computing_model_part)
            self.find_nodal_h.Execute()

            alm_var_parameters = KratosMultiphysics.Parameters("""{}""")
            alm_var_parameters.AddValue("stiffness_factor",
                                        self.params["stiffness_factor"])
            alm_var_parameters.AddValue("penalty_scale_factor",
                                        self.params["penalty_scale_factor"])
            self.alm_var_process = ContactStructuralMechanicsApplication.ALMVariablesCalculationProcess(
                self.contact_model_part, KratosMultiphysics.NODAL_H,
                alm_var_parameters)
            self.alm_var_process.Execute()
            # We don't consider scale factor
            if (self.params["use_scale_factor"].GetBool() == False):
                self.main_model_part.ProcessInfo[
                    KratosMultiphysics.SCALE_FACTOR] = 1.0
        else:
            # We set the values in the process info
            self.main_model_part.ProcessInfo[
                KratosMultiphysics.
                INITIAL_PENALTY] = self.params["penalty"].GetDouble()
            self.main_model_part.ProcessInfo[
                KratosMultiphysics.
                SCALE_FACTOR] = self.params["scale_factor"].GetDouble()

        # We print the parameters considered
        print("The parameters considered finally are: ")
        print(
            "SCALE_FACTOR: ", "{:.2e}".format(self.main_model_part.ProcessInfo[
                KratosMultiphysics.SCALE_FACTOR]))
        print(
            "INITIAL_PENALTY: ",
            "{:.2e}".format(self.main_model_part.ProcessInfo[
                KratosMultiphysics.INITIAL_PENALTY]))

        #print("MODEL PART AFTER CREATING INTERFACE")
        #print(computing_model_part)

        # We copy the conditions to the ContactSubModelPart
        for cond in self.contact_model_part.Conditions:
            interface_model_part.AddCondition(cond)
        del (cond)
        for node in self.contact_model_part.Nodes:
            interface_model_part.AddNode(node, 0)
        del (node)

        # Creating the search
        search_parameters = KratosMultiphysics.Parameters("""{}""")
        search_parameters.AddValue("type_search", self.params["type_search"])
        search_parameters.AddValue("allocation_size",
                                   self.params["max_number_results"])
        search_parameters.AddValue("bucket_size", self.params["bucket_size"])
        search_parameters.AddValue("search_factor",
                                   self.params["search_factor"])
        search_parameters.AddValue("dual_search_check",
                                   self.params["dual_search_check"])
        search_parameters.AddValue("strict_search_check",
                                   self.params["strict_search_check"])
        search_parameters.AddValue("use_exact_integration",
                                   self.params["use_exact_integration"])
        self.contact_search = ContactStructuralMechanicsApplication.TreeContactSearch(
            computing_model_part, search_parameters)

        # We initialize the conditions
        self.alm_init_var = ContactStructuralMechanicsApplication.ALMFastInit(
            self.contact_model_part)
        self.alm_init_var.Execute()

        # We initialize the search utility
        self.contact_search.CreatePointListMortar()
        self.contact_search.InitializeMortarConditions()