Пример #1
0
    def CreateAssignmentProcess(self, params):

        if (self.value_is_numeric):
            params.AddValue("variable_name", self.settings["variable_name"])
            counter = 0
            for i in self.value:
                params["value"][counter].SetDouble(i)
                counter += 1
            self.AssignValueProcess = KratosFemDem.AssignVectorToConditionsProcess(
                self.model_part, params)
        else:
            #function values are assigned to a vector variable :: transformation is needed
            if (isinstance(self.var, KratosMultiphysics.Array1DVariable3)):
                variable_name = self.settings["variable_name"].GetString(
                ) + "_VECTOR"
                #print("::[--Assign_Variable--]:: "+variable_name)
                params.AddEmptyValue("variable_name")
                params["variable_name"].SetString(variable_name)
            else:
                params.AddValue("variable_name",
                                self.settings["variable_name"])
            counter = 0
            for i in self.value:
                params["value"][counter].SetDouble(i)
                counter += 1
            params.AddEmptyValue("entity_type").SetString("CONDITIONS")
            self.AssignValueProcess = KratosFemDem.AssignVectorFieldToEntitiesProcess(
                self.model_part, self.compiled_function, "function",
                self.value_is_spatial_function, params)

        # in case of going to previous time step for time step reduction
        self.CreateUnAssignmentProcess(params)
Пример #2
0
 def RegenerateAndUpdatePFEMPressureConditions(self):
     regenerate_cond_process = FEMDEM.RegeneratePfemPressureConditionsProcess3D(
         self.FEMDEM_Solution.FEM_Solution.main_model_part)
     regenerate_cond_process.Execute()
     update_cond_process = FEMDEM.UpdatePressureValuePfemConditionsProcess3D(
         self.FEMDEM_Solution.FEM_Solution.main_model_part)
     update_cond_process.Execute()
Пример #3
0
    def PerformRemeshingIfNecessary(self):

        debug_metric = False
        if debug_metric:
            params = KratosMultiphysics.Parameters("""{}""")
            KratosFemDem.ComputeNormalizedFreeEnergyOnNodesProcess(self.FEM_Solution.main_model_part, self.FEM_Solution.ProjectParameters["AMR_data"]["hessian_variable_parameters"]).Execute()
            MeshingApplication.ComputeHessianSolMetricProcess(self.FEM_Solution.main_model_part, KratosFemDem.EQUIVALENT_NODAL_STRESS, params).Execute()

        if self.DoRemeshing:
            is_remeshing = self.CheckIfHasRemeshed()

            if is_remeshing:
                if self.echo_level > 0:
                    KratosMultiphysics.Logger.PrintInfo("FEM-DEM:: ComputeNormalizedFreeEnergyOnNodesProcess")
                # Extrapolate the free energy as a remeshing criterion
                parameters = self.FEM_Solution.ProjectParameters["AMR_data"]["hessian_variable_parameters"]
                KratosFemDem.ComputeNormalizedFreeEnergyOnNodesProcess(self.FEM_Solution.main_model_part, parameters).Execute()

                # we eliminate the nodal DEM forces
                self.RemoveDummyNodalForces()

            # Perform remeshing
            self.RemeshingProcessMMG.ExecuteInitializeSolutionStep()

            if is_remeshing:
                if self.echo_level > 0:
                    KratosMultiphysics.Logger.PrintInfo("FEM-DEM:: InitializeSolutionAfterRemeshing")
                self.InitializeSolutionAfterRemeshing()
                neighbour_elemental_finder =  KratosMultiphysics.FindElementalNeighboursProcess(self.FEM_Solution.main_model_part, 2, 5)
                neighbour_elemental_finder.ClearNeighbours()
                neighbour_elemental_finder.Execute()
Пример #4
0
    def Writeresults(self, time):

        # We reorder the Id of the model parts
        femdem_util = FEMDEM.FEMDEMCouplingUtilities()
        reorder_util_elem = FEMDEM.RenumberingNodesUtility(
            self.solid_model_part, self.fluid_model_part)
        reorder_util_elem.RenumberElements()

        Logger.PrintInfo("", "")
        Logger.PrintInfo(
            "",
            "*****************  PRINTING RESULTS FOR GID  *************************"
        )
        Logger.PrintInfo("", "")
        Logger.Flush()

        number_pfem_nodes = femdem_util.GetNumberOfNodes(self.fluid_model_part)
        for node in self.balls_model_part.Nodes:
            node.Id = node.Id + number_pfem_nodes

        if self.GiDMultiFileFlag == "Multiples":
            self.mixed_solid_fluid_model_part.Elements.clear()
            self.mixed_solid_fluid_model_part.Nodes.clear()

            self.mixed_solid_balls_model_part.Elements.clear()
            self.mixed_solid_balls_model_part.Nodes.clear()

            self.mixed_solid_balls_fluid_model_part.Elements.clear()
            self.mixed_solid_balls_fluid_model_part.Nodes.clear()

            # Now we fill the mixed MDPA in order to print
            post_utils = DEMApplication.PostUtilities()
            post_utils.AddModelPartToModelPart(
                self.mixed_solid_fluid_model_part, self.fluid_model_part)

            post_utils.AddModelPartToModelPart(
                self.mixed_solid_balls_model_part, self.balls_model_part)
            post_utils.AddModelPartToModelPart(
                self.mixed_solid_balls_model_part, self.rigid_faces_model_part)

            post_utils.AddModelPartToModelPart(
                self.mixed_solid_balls_fluid_model_part, self.balls_model_part)
            post_utils.AddModelPartToModelPart(
                self.mixed_solid_balls_fluid_model_part,
                self.rigid_faces_model_part)
            post_utils.AddModelPartToModelPart(
                self.mixed_solid_balls_fluid_model_part, self.solid_model_part)
            post_utils.AddModelPartToModelPart(
                self.mixed_solid_balls_fluid_model_part, self.fluid_model_part)

            FEMDEM.FEMDEMCouplingUtilities().RemoveDuplicates(
                self.mixed_solid_fluid_model_part)

        self.write_dem_fem_results(time)
        reorder_util_elem.UndoRenumberElements()
Пример #5
0
 def CreateUnAssignmentProcess(self, params):
     params["compound_assignment"].SetString(
         self.GetInverseAssigment(
             self.settings["compound_assignment"].GetString()))
     if (self.value_is_numeric):
         self.UnAssignValueProcess = KratosFemDem.AssignVectorToConditionsProcess(
             self.model_part, params)
     else:
         self.UnAssignValueProcess = KratosFemDem.AssignVectorFieldToEntitiesProcess(
             self.model_part, self.compiled_function, "function",
             self.value_is_spatial_function, params)
Пример #6
0
    def ExtrapolatePressureLoad(self):
        if self.echo_level > 0:
            self.FEM_Solution.KratosPrintInfo("FEM-DEM:: ExtrapolatePressureLoad")

        if self.PressureLoad:
            # we reconstruct the pressure load if necessary
            if self.FEM_Solution.main_model_part.ProcessInfo[KratosFemDem.RECONSTRUCT_PRESSURE_LOAD] == 1:
                self.FEM_Solution.main_model_part.ProcessInfo[KratosFemDem.INTERNAL_PRESSURE_ITERATION] = 1
                while self.FEM_Solution.main_model_part.ProcessInfo[KratosFemDem.INTERNAL_PRESSURE_ITERATION] > 0:
                    if self.domain_size == 2:
                        KratosFemDem.ExtendPressureConditionProcess2D(self.FEM_Solution.main_model_part).Execute()
                    else:
                        KratosFemDem.ExtendPressureConditionProcess3D(self.FEM_Solution.main_model_part).Execute()
Пример #7
0
    def SetFixAndFreeProcesses(self, params):

        # if( self.fix_time_integration == True ):
        #     params["variable_name"].SetString(self.settings["variable_name"].GetString())
        #     self.primary_variable_name = self.TimeIntegrationMethod.GetPrimaryVariableName()
        #     if( self.primary_variable_name != self.variable_name ):
        #         params["variable_name"].SetString(self.primary_variable_name)

        fix_dof_process = KratosFemDem.FixScalarDofProcess(
            self.model_part, params)
        self.FixDofsProcesses.append(fix_dof_process)
        free_dof_process = KratosFemDem.FreeScalarDofProcess(
            self.model_part, params)
        self.FreeDofsProcesses.append(free_dof_process)
Пример #8
0
    def GenerateDemAfterRemeshing(self):
        # we extrapolate the damage to the nodes
        KratosFemDem.DamageToNodesProcess(self.FEM_Solution.main_model_part, 2).Execute()

        # we create a submodelpart containing the nodes and radius of the corresponding DEM
        KratosFemDem.DemAfterRemeshIdentificatorProcess(self.FEM_Solution.main_model_part, 0.95).Execute()

        # Loop over the elements of the Submodelpart to create the DEM
        for node in self.FEM_Solution.main_model_part.GetSubModelPart("DemAfterRemeshingNodes").Nodes:
            Id = node.Id
            R = node.GetValue(KratosFemDem.DEM_RADIUS)
            Coordinates = self.GetNodeCoordinates(node)
            self.ParticleCreatorDestructor.FEMDEM_CreateSphericParticle(Coordinates, R, Id)
            node.SetValue(KratosFemDem.IS_DEM, True)
Пример #9
0
 def CreateUnAssignmentProcess(self, params):
     params["compound_assignment"].SetString(
         self.GetInverseAssigment(
             self.settings["compound_assignment"].GetString()))
     if (self.value_is_numeric):
         self.UnAssignValueProcess = KratosFemDem.AssignScalarToEntitiesProcess(
             self.model_part, params)
     else:
         if (self.value_is_current_value):
             self.UnAssignValueProcess = KratosMultiphysics.Process(
             )  #void process
         else:
             self.UnAssignValueProcess = KratosFemDem.AssignScalarFieldToEntitiesProcess(
                 self.model_part, self.compiled_function, "function",
                 self.value_is_spatial_function, params)
Пример #10
0
    def InitializeSolutionAfterRemeshing(self):
        # Initialize the "flag" IS_DEM in all the nodes
        KratosMultiphysics.VariableUtils().SetNonHistoricalVariable(KratosFemDem.IS_DEM, False, self.FEM_Solution.main_model_part.Nodes)
        # Initialize the "flag" NODAL_FORCE_APPLIED in all the nodes
        KratosMultiphysics.VariableUtils().SetNonHistoricalVariable(KratosFemDem.NODAL_FORCE_APPLIED, False, self.FEM_Solution.main_model_part.Nodes)
        # Initialize the "flag" RADIUS in all the nodes
        KratosMultiphysics.VariableUtils().SetNonHistoricalVariable(KratosMultiphysics.RADIUS, False, self.FEM_Solution.main_model_part.Nodes)

        if self.FEM_Solution.ProjectParameters.Has("pressure_load_extrapolation") == False:
            self.PressureLoad = False
        else:
            self.PressureLoad = self.FEM_Solution.ProjectParameters["pressure_load_extrapolation"].GetBool()
        if self.PressureLoad:
            KratosFemDem.AssignPressureIdProcess(self.FEM_Solution.main_model_part).Execute()

        # Remove DEMS from previous mesh
        self.SpheresModelPart.Elements.clear()
        self.SpheresModelPart.Nodes.clear()

        self.InitializeDummyNodalForces()

        self.InitializeMMGvariables()
        self.FEM_Solution.model_processes = self.FEM_Solution.AddProcesses()
        self.FEM_Solution.model_processes.ExecuteInitialize()
        self.FEM_Solution.model_processes.ExecuteBeforeSolutionLoop()
        self.FEM_Solution.model_processes.ExecuteInitializeSolutionStep()

        # Search the skin nodes for the remeshing
        skin_detection_process = KratosMultiphysics.SkinDetectionProcess2D(self.FEM_Solution.main_model_part,
                                                                            self.SkinDetectionProcessParameters)
        skin_detection_process.Execute()
        self.GenerateDemAfterRemeshing()
Пример #11
0
 def ExecuteBeforeGeneratingDEM(self): 
     """Here the erased are labeled as INACTIVE so you can access to them. After calling
        GenerateDEM they are totally erased """
     if self.PressureLoad:
         self.ExpandWetNodes()
         KratosFemDem.UpdatePressureVolumeProcess(self.FEM_Solution.main_model_part).Execute()
         self.ExpandWetNodes()
Пример #12
0
 def ExpandWetNodes(self):
     if self.echo_level > 0:
         KratosMultiphysics.Logger.PrintInfo("FEM-DEM:: ExpandWetNodes")
     if self.PressureLoad:
         # This must be called before Generating DEM
         self.FEM_Solution.main_model_part.ProcessInfo[KratosFemDem.RECONSTRUCT_PRESSURE_LOAD] = 0 # It is modified inside
         extend_wet_nodes_process = KratosFemDem.ExpandWetNodesProcess(self.FEM_Solution.main_model_part)
         extend_wet_nodes_process.Execute()
    def __init__(self, Model, settings ):
        KratosMultiphysics.Process.__init__(self)

        model_part = Model[settings["model_part_name"].GetString()]
        variable_name = settings["variable_name"].GetString()

        self.components_process_list = []

        if settings["active"][0].GetBool() == True:
            x_params = KratosMultiphysics.Parameters("{}")
            x_params.AddValue("model_part_name",settings["model_part_name"])
            if settings.Has("is_fixed"):
                x_params.AddValue("is_fixed",settings["is_fixed"][0])
            x_params.AddValue("value",settings["value"][0])
            x_params.AddEmptyValue("variable_name").SetString(variable_name+"_X")
            if settings["table"][0].GetInt() == 0:
                self.components_process_list.append(KratosMultiphysics.ApplyConstantScalarValueProcess(model_part, x_params))
            else:
                x_params.AddValue("table",settings["table"][0])
                self.components_process_list.append(KratosFemDem.ApplyComponentTableProcess(model_part, x_params))

        if settings["active"][1].GetBool() == True:
            y_params = KratosMultiphysics.Parameters("{}")
            y_params.AddValue("model_part_name",settings["model_part_name"])
            if settings.Has("is_fixed"):
                y_params.AddValue("is_fixed",settings["is_fixed"][1])
            y_params.AddValue("value",settings["value"][1])
            y_params.AddEmptyValue("variable_name").SetString(variable_name+"_Y")
            if settings["table"][1].GetInt() == 0:
                self.components_process_list.append(KratosMultiphysics.ApplyConstantScalarValueProcess(model_part, y_params))
            else:
                y_params.AddValue("table",settings["table"][1])
                self.components_process_list.append(KratosFemDem.ApplyComponentTableProcess(model_part, y_params))

        if settings["active"][2].GetBool() == True:
            z_params = KratosMultiphysics.Parameters("{}")
            z_params.AddValue("model_part_name",settings["model_part_name"])
            if settings.Has("is_fixed"):
                z_params.AddValue("is_fixed",settings["is_fixed"][2])
            z_params.AddValue("value",settings["value"][2])
            z_params.AddEmptyValue("variable_name").SetString(variable_name+"_Z")
            if settings["table"][2].GetInt() == 0:
                self.components_process_list.append(KratosMultiphysics.ApplyConstantScalarValueProcess(model_part, z_params))
            else:
                z_params.AddValue("table",settings["table"][2])
                self.components_process_list.append(KratosFemDem.ApplyComponentTableProcess(model_part, z_params))
Пример #14
0
    def RemoveAloneDEMElements(self):
        if self.echo_level > 0:
            self.FEM_Solution.KratosPrintInfo("FEM-DEM:: RemoveAloneDEMElements")

        remove_alone_DEM_elements_process = KratosFemDem.RemoveAloneDEMElementsProcess(
                                                         self.FEM_Solution.main_model_part, 
                                                         self.SpheresModelPart)
        remove_alone_DEM_elements_process.Execute()
Пример #15
0
    def PerformRemeshingIfNecessary(self):

        debug_metric = False
        if debug_metric:
            params = KratosMultiphysics.Parameters("""{}""")
            KratosFemDem.ComputeNormalizedFreeEnergyOnNodesProcess(
                self.FEM_Solution.main_model_part,
                self.FEM_Solution.ProjectParameters["AMR_data"]
                ["hessian_variable_parameters"]).Execute()
            MeshingApplication.ComputeHessianSolMetricProcess(
                self.FEM_Solution.main_model_part,
                KratosFemDem.EQUIVALENT_NODAL_STRESS, params).Execute()

        if self.DoRemeshing:
            is_remeshing = self.CheckIfHasRemeshed()

            if is_remeshing:
                if self.echo_level > 0:
                    KratosMultiphysics.Logger.PrintInfo(
                        "FEM-DEM:: ComputeNormalizedFreeEnergyOnNodesProcess")
                # Extrapolate the VonMises normalized stress to nodes (remeshing)
                parameters = self.FEM_Solution.ProjectParameters["AMR_data"][
                    "hessian_variable_parameters"]
                KratosFemDem.ComputeNormalizedFreeEnergyOnNodesProcess(
                    self.FEM_Solution.main_model_part, parameters).Execute()

                # we eliminate the nodal DEM forces
                self.RemoveDummyNodalForces()

            # Perform remeshing
            self.RemeshingProcessMMG.ExecuteInitializeSolutionStep()

            if is_remeshing:
                if self.echo_level > 0:
                    KratosMultiphysics.Logger.PrintInfo(
                        "FEM-DEM:: InitializeSolutionAfterRemeshing")
                self.RefineMappedVariables()
                self.InitializeSolutionAfterRemeshing()
                self.nodal_neighbour_finder = KratosMultiphysics.FindNodalNeighboursProcess(
                    self.FEM_Solution.main_model_part, 4, 5)
                self.nodal_neighbour_finder.Execute()
                # We assign the flag to recompute neighbours inside the 3D elements
                utils = KratosMultiphysics.VariableUtils()
                utils.SetNonHistoricalVariable(
                    KratosFemDem.RECOMPUTE_NEIGHBOURS, True,
                    self.FEM_Solution.main_model_part.Elements)
Пример #16
0
 def ExpandWetNodes(self):
     if self.PressureLoad:
         # This must be called before Generating DEM
         self.FEM_Solution.main_model_part.ProcessInfo[
             KratosFemDem.
             RECONSTRUCT_PRESSURE_LOAD] = 0  # It is modified inside
         extend_wet_nodes_process = KratosFemDem.ExpandWetNodesProcess(
             self.FEM_Solution.main_model_part)
         extend_wet_nodes_process.Execute()
Пример #17
0
    def CountErasedVolume(self):
        count_erased_vol = True
        if count_erased_vol:
            erased_vol_process = KratosFemDem.ComputeSandProduction(self.FEM_Solution.main_model_part)
            erased_vol_process.Execute()

            self.ErasedVolume = open("ErasedVolume.txt","a")
            erased_vol = self.FEM_Solution.main_model_part.ProcessInfo[KratosFemDem.ERASED_VOLUME]
            self.ErasedVolume.write("    " + "{0:.4e}".format(self.FEM_Solution.time).rjust(11) + "    " + "{0:.4e}".format(erased_vol).rjust(11) + "\n")
            self.ErasedVolume.close()
    def __init__(self, Model, PFEMparameters, path=""):
        super(MainCouplingPfemFemDemAitken_Solution,
              self).__init__(Model, PFEMparameters, path)

        project_parameters = self.FEMDEM_Solution.FEM_Solution.ProjectParameters
        if (project_parameters.Has("Aitken_parameters")):
            if (project_parameters["Aitken_parameters"].Has("tolerance")):
                self.aitken_residual_dof_tolerance = project_parameters[
                    "Aitken_parameters"]["tolerance"].GetDouble()
            else:
                self.aitken_residual_dof_tolerance = 1.0e-7
            if (project_parameters["Aitken_parameters"].Has("max_iterations")):
                self.aitken_max_iterations = project_parameters[
                    "Aitken_parameters"]["max_iterations"].GetInt()
            else:
                self.aitken_max_iterations = 10
            if (project_parameters["Aitken_parameters"].Has("max_relaxation")):
                max_relaxation = project_parameters["Aitken_parameters"][
                    "max_relaxation"].GetDouble()
            else:
                max_relaxation = 0.9
            if (project_parameters["Aitken_parameters"].Has("min_relaxation")):
                min_relaxation = project_parameters["Aitken_parameters"][
                    "min_relaxation"].GetDouble()
            else:
                min_relaxation = 0.2
            if (project_parameters["Aitken_parameters"].Has(
                    "initial_relaxation")):
                initial_relaxation = project_parameters["Aitken_parameters"][
                    "initial_relaxation"].GetDouble()
            else:
                initial_relaxation = 0.825
        else:
            max_relaxation = 0.9
            min_relaxation = 0.1
            initial_relaxation = 0.825
            self.aitken_max_iterations = 10
            self.aitken_residual_dof_tolerance = 1e-5

        self.FSI_aitken_utility = FEMDEM.AitkenRelaxationFEMDEMUtility(
            initial_relaxation, max_relaxation, min_relaxation)

        self.developer_mode = False
        if self.developer_mode:
            self.pressure_plot = open("pressure_plot.txt", "w")
            self.pressure_plot.write(
                "This File prints the pressures at the interface nodes!\n\n")
            self.pressure_plot.close()

        PlotFileIterAitken = open("iterations_Aitken.txt", "w")
        PlotFileIterAitken.write(
            "This file prints the number of iterations at each time step\n\n")
        PlotFileIterAitken.write("       time           ITER\n")
        PlotFileIterAitken.close()
Пример #19
0
 def _create_newton_raphson_hexaedrons_strategy(self):
     computing_model_part = self.GetComputingModelPart()
     mechanical_scheme = self._get_solution_scheme()
     linear_solver = self._get_linear_solver()
     mechanical_convergence_criterion = self._get_convergence_criterion()
     return KratosFemDem.HexahedraNewtonRaphsonStrategy(
         computing_model_part, mechanical_scheme, linear_solver,
         mechanical_convergence_criterion,
         self.settings["max_iteration"].GetInt(),
         self.settings["compute_reactions"].GetBool(),
         self.settings["reform_dofs_at_each_step"].GetBool(),
         self.settings["move_mesh_flag"].GetBool())
Пример #20
0
    def CreateAssignmentProcess(self, params):

        params["variable_name"].SetString(
            self.settings["variable_name"].GetString())
        if (self.value_is_numeric):
            params.AddEmptyValue("value").SetDouble(self.value)
            params.AddEmptyValue("entity_type").SetString("NODES")
            self.AssignValueProcess = KratosFemDem.AssignScalarToEntitiesProcess(
                self.model_part, params)
        else:
            if (self.value_is_current_value):
                self.AssignValueProcess = KratosMultiphysics.Process(
                )  #void process
            else:
                params.AddEmptyValue("entity_type").SetString("NODES")
                self.AssignValueProcess = KratosFemDem.AssignScalarFieldToEntitiesProcess(
                    self.model_part, self.compiled_function, "function",
                    self.value_is_spatial_function, params)

        # in case of going to previous time step for time step reduction
        self.CreateUnAssignmentProcess(params)
Пример #21
0
 def _create_DEM_coupled_newton_raphson_strategy(self, DEM_strategy):
     computing_model_part = self.GetComputingModelPart()
     mechanical_scheme = self._get_solution_scheme()
     mechanical_convergence_criterion = self._get_convergence_criterion()
     builder_and_solver = self._get_builder_and_solver()
     return KratosFemDem.ResidualBasedDEMCoupledNewtonRaphsonStrategy(
         computing_model_part, DEM_strategy, mechanical_scheme,
         mechanical_convergence_criterion, builder_and_solver,
         self.settings["max_iteration"].GetInt(),
         self.settings["compute_reactions"].GetBool(),
         self.settings["reform_dofs_at_each_step"].GetBool(),
         self.settings["move_mesh_flag"].GetBool())
Пример #22
0
    def CreateInitialSkinDEM(self):

        initial_dem_skin_process = KratosFemDem.InitialDemSkinProcess(self.FEM_Solution.main_model_part)
        initial_dem_skin_process.Execute()

        # Loop over the elements of the Submodelpart to create the DEM
        for node in self.FEM_Solution.main_model_part.GetSubModelPart("InitialDemSkin").Nodes:

            Id = node.Id
            R = node.GetValue(KratosFemDem.DEM_RADIUS)
            Coordinates = self.GetNodeCoordinates(node)
            self.ParticleCreatorDestructor.FEMDEM_CreateSphericParticle(Coordinates, R, Id)
            node.SetValue(KratosFemDem.IS_DEM, True)
Пример #23
0
    def GenerateDEM(self): # This method creates the DEM elements and remove the damaged FEM, Additionally remove the isolated elements
        if self.echo_level > 0:
            KratosMultiphysics.Logger.PrintInfo("FEM-DEM:: GenerateDEM")

        if self.FEM_Solution.main_model_part.ProcessInfo[KratosFemDem.GENERATE_DEM]:
            dem_generator_process = KratosFemDem.GenerateDemProcess(self.FEM_Solution.main_model_part, self.SpheresModelPart)
            dem_generator_process.Execute()

            # We remove the inactive DEM associated to fem_nodes
            self.RemoveAloneDEMElements()
            self.RemoveIsolatedFiniteElements()
            element_eliminator = KratosMultiphysics.AuxiliarModelPartUtilities(self.FEM_Solution.main_model_part)
            element_eliminator.RemoveElementsAndBelongings(KratosMultiphysics.TO_ERASE)
Пример #24
0
    def GenerateDEM(self):  # 3D version
        if self.echo_level > 0:
            KratosMultiphysics.Logger.PrintInfo("FEM-DEM:: GenerateDEM")
        if self.FEM_Solution.main_model_part.ProcessInfo[
                KratosFemDem.GENERATE_DEM]:
            dem_generator_process = KratosFemDem.GenerateDemProcess(
                self.FEM_Solution.main_model_part, self.SpheresModelPart)
            dem_generator_process.Execute()

            self.RemoveAloneDEMElements()
            element_eliminator = KratosMultiphysics.AuxiliarModelPartUtilities(
                self.FEM_Solution.main_model_part)
            element_eliminator.RemoveElementsAndBelongings(
                KratosMultiphysics.TO_ERASE)
Пример #25
0
    def Initialize(self):
        # Now we storage the FEM modelpart in the PFEM_Solution
        self.PFEM_Solution.Initialize()

        if self.FEMDEM_Solution.CreateInitialSkin:
            self.FEMDEM_Solution.ComputeSkinSubModelPart()
            if self.FEMDEM_Solution.DEMFEM_contact:
                self.FEMDEM_Solution.TransferFEMSkinToDEM()
            FEMDEM.GenerateInitialSkinDEMProcess(self.FEMDEM_Solution.FEM_Solution.main_model_part, self.FEMDEM_Solution.SpheresModelPart).Execute()

        # We copy the output params in the PFEM
        self.PFEM_Solution.graphical_output = self.PFEM_Solution.SetCustomGraphicalOutput(self.FEMDEM_Solution.FEM_Solution.ProjectParameters)
        self.PFEM_Solution.GraphicalOutputExecuteInitialize()

        # Initialize the coupled post process
        self.InitializePostProcess()
Пример #26
0
	def GenerateDEM(self): # 3D version
		if self.echo_level > 0:
			self.FEM_Solution.KratosPrintInfo("FEM-DEM:: GenerateDEM")
		self.CountErasedVolume()

		if self.FEM_Solution.main_model_part.ProcessInfo[KratosFemDem.GENERATE_DEM]:
			dem_generator_process = KratosFemDem.GenerateDemProcess(self.FEM_Solution.main_model_part, self.SpheresModelPart)
			dem_generator_process.Execute()

			self.RemoveAloneDEMElements()
			element_eliminator = KratosMultiphysics.AuxiliarModelPartUtilities(self.FEM_Solution.main_model_part)
			element_eliminator.RemoveElementsAndBelongings(KratosMultiphysics.TO_ERASE)

			# We assign the flag to recompute neighbours inside the 3D elements
			utils = KratosMultiphysics.VariableUtils()
			utils.SetNonHistoricalVariable(KratosFemDem.RECOMPUTE_NEIGHBOURS, True, self.FEM_Solution.main_model_part.Elements)
Пример #27
0
    def __init__(self, Model, settings):
        KratosMultiphysics.Process.__init__(self)

        model_part = Model[settings["model_part_name"].GetString()]

        params = KratosMultiphysics.Parameters("{}")
        params.AddValue("model_part_name", settings["model_part_name"])
        params.AddValue("variable_name", settings["variable_name"])
        if settings.Has("is_fixed"):
            params.AddValue("is_fixed", settings["is_fixed"])

        params.AddValue("value", settings["value"])
        if settings["table"].GetInt() == 0:
            self.process = KratosMultiphysics.ApplyConstantScalarValueProcess(
                model_part, params)
        else:
            params.AddValue("table", settings["table"])
            self.process = KratosFemDem.ApplyDoubleTableProcess(
                model_part, params)
Пример #28
0
    def GenerateDEM(self): # This method creates the DEM elements and remove the damaged FEM, Additionally remove the isolated elements
        if self.echo_level > 0:
            self.FEM_Solution.KratosPrintInfo("FEM-DEM:: GenerateDEM")

        # If we want to compute sand production
        # self.CountErasedVolume()

        if self.FEM_Solution.main_model_part.ProcessInfo[KratosFemDem.GENERATE_DEM]:
            dem_generator_process = KratosFemDem.GenerateDemProcess(self.FEM_Solution.main_model_part, self.SpheresModelPart)
            dem_generator_process.Execute()

            # We remove the inactive DEM associated to fem_nodes
            # self.RemoveAloneDEMElements()
            # self.RemoveIsolatedFiniteElements()
            element_eliminator = KratosMultiphysics.AuxiliarModelPartUtilities(self.FEM_Solution.main_model_part)
            element_eliminator.RemoveElementsAndBelongings(KratosMultiphysics.TO_ERASE)

            if self.domain_size == 3:
                # We assign the flag to recompute neighbours inside the 3D elements
                utils = KratosMultiphysics.VariableUtils()
                utils.SetNonHistoricalVariable(KratosFemDem.RECOMPUTE_NEIGHBOURS, True, self.FEM_Solution.main_model_part.Elements)
Пример #29
0
	def InitializeSolutionStep(self):

        # modified for the remeshing
		self.FEM_Solution.delta_time = self.FEM_Solution.main_model_part.ProcessInfo[KratosMultiphysics.DELTA_TIME]
		self.FEM_Solution.time = self.FEM_Solution.time + self.FEM_Solution.delta_time
		self.FEM_Solution.main_model_part.CloneTimeStep(self.FEM_Solution.time)
		self.FEM_Solution.step = self.FEM_Solution.step + 1
		self.FEM_Solution.main_model_part.ProcessInfo[KratosMultiphysics.STEP] = self.FEM_Solution.step

		self.nodal_neighbour_finder = KratosMultiphysics.FindNodalNeighboursProcess(self.FEM_Solution.main_model_part, 4, 5)
		self.nodal_neighbour_finder.Execute()

		if self.DoRemeshing:
			is_remeshing = self.CheckIfHasRemeshed()

			if is_remeshing:
				# Extrapolate the VonMises normalized stress to nodes (remeshing)
				# KratosFemDem.StressToNodesProcess(self.FEM_Solution.main_model_part, 2).Execute()
				KratosFemDem.ComputeNormalizedFreeEnergyOnNodesProcess(self.FEM_Solution.main_model_part, 2).Execute()

				# we eliminate the nodal DEM forces
				self.RemoveDummyNodalForces()

			# Perform remeshing
			self.RemeshingProcessMMG.ExecuteInitializeSolutionStep()

			if is_remeshing:
				self.RefineMappedVariables()
				self.InitializeSolutionAfterRemeshing()
				self.nodal_neighbour_finder = KratosMultiphysics.FindNodalNeighboursProcess(self.FEM_Solution.main_model_part, 4, 5)
				self.nodal_neighbour_finder.Execute()

		self.FEM_Solution.InitializeSolutionStep()

		# Create initial skin of DEM's
		self.create_initial_dem_skin = False  # Hard Coded TODO
		if self.create_initial_dem_skin and self.FEM_Solution.step == 1:
			self.CreateInitialSkinDEM()
Пример #30
0
    def __init__(self, convergence_criterion_parameters):
        """Create a convergence criterion from json parameters.

        Keyword arguments:
        convergence_criterion_parameters

        If no error is raised, a valid convergence criterion is accessible
        through the member variable mechanical_convergence_criterion after
        return.
        """
        # Note that all the convergence settings are introduced via a Kratos parameters object.
        D_RT = convergence_criterion_parameters["displacement_relative_tolerance"].GetDouble()
        D_AT = convergence_criterion_parameters["displacement_absolute_tolerance"].GetDouble()
        R_RT = convergence_criterion_parameters["residual_relative_tolerance"].GetDouble()
        R_AT = convergence_criterion_parameters["residual_absolute_tolerance"].GetDouble()

        echo_level = convergence_criterion_parameters["echo_level"].GetInt()

        if(echo_level >= 1):
            print("::[Mechanical_Solver]:: Convergence criterion [", convergence_criterion_parameters["convergence_criterion"].GetString(),"]")

        rotation_dofs = False
        if(convergence_criterion_parameters.Has("rotation_dofs")):
            if(convergence_criterion_parameters["rotation_dofs"].GetBool()):
                rotation_dofs = True

        component_wise = False
        if(convergence_criterion_parameters.Has("component_wise")):
            if(convergence_criterion_parameters["component_wise"].GetBool()):
                component_wise = True


        if(convergence_criterion_parameters["convergence_criterion"].GetString() == "FemDem_Residual_criterion"):
            self.mechanical_convergence_criterion = KratosFemDem.FemDemResidualCriteria(R_RT, R_AT)
            self.mechanical_convergence_criterion.SetEchoLevel(echo_level)
        else:
            raise Exception("Unsupported \"convergence_criterion\" : " + convergence_criterion_parameters["convergence_criterion"].GetString())