Ejemplo n.º 1
0
    def __init__(self, model, DEM_parameters):
        self.model = model
        self.main_path = self.GetMainPath()
        self.mdpas_folder_path = self.main_path

        self.DEM_parameters = DEM_parameters  # TODO, can be improved
        self.project_parameters = DEM_parameters
        default_input_parameters = self.GetDefaultInputParameters()
        self.DEM_parameters.ValidateAndAssignDefaults(default_input_parameters)
        self.FixParametersInconsistencies()

        self.do_print_results_option = self.DEM_parameters[
            "do_print_results_option"].GetBool()
        if not "WriteMdpaFromResults" in self.DEM_parameters.keys():
            self.write_mdpa_from_results = False
        else:
            self.write_mdpa_from_results = self.DEM_parameters[
                "WriteMdpaFromResults"].GetBool()
        self.creator_destructor = self.SetParticleCreatorDestructor()
        self.dem_fem_search = self.SetDemFemSearch()
        self.procedures = self.SetProcedures()
        self.SetAnalyticParticleWatcher()
        self.PreUtilities = PreUtilities()
        self.aux = AuxiliaryUtilities()

        # Set the print function TO_DO: do this better...
        self.KratosPrintInfo = self.procedures.KratosPrintInfo

        # Creating necessary directories:
        self.problem_name = self.GetProblemTypeFileName()

        [self.post_path, self.data_and_results,
         self.graphs_path] = self.procedures.CreateDirectories(
             str(self.main_path),
             str(self.problem_name),
             do_print_results=self.do_print_results_option)[:-1]

        # Prepare modelparts
        self.CreateModelParts()

        if self.do_print_results_option:
            self.SetGraphicalOutput()
        self.report = DEM_procedures.Report()
        self.parallelutils = DEM_procedures.ParallelUtils()
        self.materialTest = DEM_procedures.MaterialTest()
        self.translational_scheme = self.SetTranslationalScheme()
        self.rotational_scheme = self.SetRotationalScheme()

        # Define control variables
        self.p_frequency = 100  # activate every 100 steps
        self.step_count = 0
        self.p_count = self.p_frequency

        #self._solver = self._GetSolver()
        self.SetDt()
        self.SetFinalTime()
        self.AddVariables()
        super(DEMAnalysisStage, self).__init__(model, self.DEM_parameters)
Ejemplo n.º 2
0
 def SetGraphicalOutput(self):
     self.demio = DEM_procedures.DEMIo(self.model, self.DEM_parameters,
                                       self.post_path, self.all_model_parts)
     if self.DEM_parameters["post_vtk_option"].GetBool():
         import KratosMultiphysics.DEMApplication.dem_vtk_output as dem_vtk_output
         self.vtk_output = dem_vtk_output.VtkOutput(
             self.main_path, self.problem_name, self.spheres_model_part,
             self.rigid_face_model_part)
Ejemplo n.º 3
0
    def __init__(self, model, path = ""):

        self.model = model
        self.path_for_tests = path
        self.main_path = self.GetMainPath()
        self.LoadParametersFile()
        self.solver_strategy = self.SetSolverStrategy()
        self.creator_destructor = self.SetParticleCreatorDestructor()
        self.dem_fem_search = self.SetDemFemSearch()
        self.procedures = self.SetProcedures()
        self.SetAnalyticParticleWatcher()
        self.PreUtilities = PreUtilities()
        self.aux = AuxiliaryUtilities()



        # Set the print function TO_DO: do this better...
        self.KratosPrintInfo = self.procedures.KratosPrintInfo

        # Creating necessary directories:
        self.problem_name = self.GetProblemTypeFilename()

        [self.post_path,
        self.data_and_results,
        self.graphs_path,
        MPI_results] = self.procedures.CreateDirectories(str(self.main_path), str(self.problem_name))

        # Prepare modelparts
        self.CreateModelParts()

        self.SetGraphicalOutput()
        self.report = DEM_procedures.Report()
        self.parallelutils = DEM_procedures.ParallelUtils()
        self.materialTest = DEM_procedures.MaterialTest()
        self.translational_scheme = self.SetTranslationalScheme()
        self.rotational_scheme = self.SetRotationalScheme()

        # Define control variables
        self.p_frequency = 100   # activate every 100 steps
        self.step_count = 0
        self.p_count = self.p_frequency

        self.solver = self.SetSolver()
        self.SetDt()
        self.SetFinalTime()
Ejemplo n.º 4
0
    def CreateModelParts(self):
        self.spheres_model_part = self.model.CreateModelPart("SpheresPart")
        self.rigid_face_model_part = self.model.CreateModelPart("RigidFacePart")
        self.cluster_model_part = self.model.CreateModelPart("ClusterPart")
        self.dem_inlet_model_part = self.model.CreateModelPart("DEMInletPart")
        self.mapping_model_part = self.model.CreateModelPart("MappingPart")
        self.contact_model_part = self.model.CreateModelPart("ContactPart")

        mp_list = []
        mp_list.append(self.spheres_model_part)
        mp_list.append(self.rigid_face_model_part)
        mp_list.append(self.cluster_model_part)
        mp_list.append(self.dem_inlet_model_part)
        mp_list.append(self.mapping_model_part)
        mp_list.append(self.contact_model_part)

        self.all_model_parts = DEM_procedures.SetOfModelParts(mp_list)
Ejemplo n.º 5
0
    def Initialize(self):
        self.time = 0.0
        self.time_old_print = 0.0

        self.ReadModelParts()

        self.SetAnalyticFaceWatcher()

        self.post_normal_impact_velocity_option = False
        if "PostNormalImpactVelocity" in self.DEM_parameters.keys():
            if self.DEM_parameters["PostNormalImpactVelocity"].GetBool():
                self.post_normal_impact_velocity_option = True
                self.FillAnalyticSubModelParts()

        # Setting up the buffer size
        self.procedures.SetUpBufferSizeInAllModelParts(
            self.spheres_model_part, 1, self.cluster_model_part, 1,
            self.dem_inlet_model_part, 1, self.rigid_face_model_part, 1)

        self.KratosPrintInfo("Initializing Problem...")

        self.GraphicalOutputInitialize()

        # Perform a partition to balance the problem
        self.SetSearchStrategy()

        self.SolverBeforeInitialize()

        self.parallelutils.Repart(self.spheres_model_part)

        #Setting up the BoundingBox
        self.bounding_box_time_limits = self.procedures.SetBoundingBoxLimits(
            self.all_model_parts, self.creator_destructor)

        #Finding the max id of the nodes... (it is necessary for anything that will add spheres to the self.spheres_model_part, for instance, the INLETS and the CLUSTERS read from mdpa file.z
        #max_Id = self.procedures.FindMaxNodeIdAccrossModelParts(self.creator_destructor, self.all_model_parts)   # TODO this seems not be longer required
        #self.creator_destructor.SetMaxNodeId(max_Id)
        self.creator_destructor.SetMaxNodeId(
            self.all_model_parts.MaxNodeId)  #TODO check functionalities

        self.DEMFEMProcedures = DEM_procedures.DEMFEMProcedures(
            self.DEM_parameters, self.graphs_path, self.spheres_model_part,
            self.rigid_face_model_part)

        self.DEMEnergyCalculator = DEM_procedures.DEMEnergyCalculator(
            self.DEM_parameters, self.spheres_model_part,
            self.cluster_model_part, self.graphs_path, "EnergyPlot.grf")

        self.materialTest.Initialize(self.DEM_parameters, self.procedures,
                                     self._GetSolver(), self.graphs_path,
                                     self.post_path, self.spheres_model_part,
                                     self.rigid_face_model_part)

        self.KratosPrintInfo("Initialization Complete")

        self.report.Prepare(timer,
                            self.DEM_parameters["ControlTime"].GetDouble())

        self.materialTest.PrintChart()
        self.materialTest.PrepareDataForGraph()

        self.post_utils = DEM_procedures.PostUtils(self.DEM_parameters,
                                                   self.spheres_model_part)
        self.report.total_steps_expected = int(self.end_time /
                                               self._GetSolver().dt)

        super().Initialize()

        self.seed = self.DEM_parameters["seed"].GetInt()
        #Constructing a model part for the DEM inlet. It contains the DEM elements to be released during the simulation
        #Initializing the DEM solver must be done before creating the DEM Inlet, because the Inlet configures itself according to some options of the DEM model part
        self.SetInlet()

        self.SetInitialNodalValues()

        self.KratosPrintInfo(self.report.BeginReport(timer))

        if self.DEM_parameters["output_configuration"][
                "print_number_of_neighbours_histogram"].GetBool():
            self.PreUtilities.PrintNumberOfNeighboursHistogram(
                self.spheres_model_part,
                os.path.join(self.graphs_path,
                             "number_of_neighbours_histogram.txt"))
Ejemplo n.º 6
0
 def SetProcedures(self):
     return DEM_procedures.Procedures(self.DEM_parameters)
Ejemplo n.º 7
0
    def Initialize(self):
        self.step = 0
        self.time = 0.0

        self.AddVariables()

        self.ReadModelParts()

        self.SetAnalyticFaceWatcher()  # TODO check order

        self.post_normal_impact_velocity_option = False
        if "PostNormalImpactVelocity" in self.DEM_parameters.keys():
            if self.DEM_parameters["PostNormalImpactVelocity"].GetBool():
                self.post_normal_impact_velocity_option = True
                self.FillAnalyticSubModelParts()

        # Setting up the buffer size
        self.procedures.SetUpBufferSizeInAllModelParts(self.spheres_model_part, 1, self.cluster_model_part, 1, self.dem_inlet_model_part, 1, self.rigid_face_model_part, 1)
        # Adding dofs
        # self.AddAllDofs() # Calls to this method are deprecated.
        self.AddDofs()

        #-----------os.chdir(self.main_path)
        self.KratosPrintInfo("Initializing Problem...")

        self.GraphicalOutputInitialize()

        # Perform a partition to balance the problem
        self.SetSearchStrategy()

        self.SolverBeforeInitialize()

        self.parallelutils.Repart(self.spheres_model_part)

        #Setting up the BoundingBox
        self.bounding_box_time_limits = self.procedures.SetBoundingBoxLimits(self.all_model_parts, self.creator_destructor)

        #Finding the max id of the nodes... (it is necessary for anything that will add spheres to the self.spheres_model_part, for instance, the INLETS and the CLUSTERS read from mdpa file.z
        max_Id = self.procedures.FindMaxNodeIdAccrossModelParts(self.creator_destructor, self.all_model_parts)
        #self.creator_destructor.SetMaxNodeId(max_Id)
        self.creator_destructor.SetMaxNodeId(self.all_model_parts.MaxNodeId)  #TODO check functionalities

        #Strategy Initialization
        #-------------os.chdir(self.main_path)

        self.SolverInitialize()

        #Constructing a model part for the DEM inlet. It contains the DEM elements to be released during the simulation
        #Initializing the DEM solver must be done before creating the DEM Inlet, because the Inlet configures itself according to some options of the DEM model part
        self.SetInlet()

        self.SetInitialNodalValues()

        self.DEMFEMProcedures = DEM_procedures.DEMFEMProcedures(self.DEM_parameters, self.graphs_path, self.spheres_model_part, self.rigid_face_model_part)

        #------------os.chdir(self.graphs_path)
        self.DEMEnergyCalculator = DEM_procedures.DEMEnergyCalculator(self.DEM_parameters, self.spheres_model_part, self.cluster_model_part, self.graphs_path, "EnergyPlot.grf")

        self.materialTest.Initialize(self.DEM_parameters, self.procedures, self.solver, self.graphs_path, self.post_path, self.spheres_model_part, self.rigid_face_model_part)

        self.KratosPrintInfo("Initialization Complete")

        self.report.Prepare(timer, self.DEM_parameters["ControlTime"].GetDouble())

        #self.procedures.ModelData(self.spheres_model_part, self.solver) #check link with ModelDataInfo = "OFF"

        self.materialTest.PrintChart()
        self.materialTest.PrepareDataForGraph()

        self.post_utils = DEM_procedures.PostUtils(self.DEM_parameters, self.spheres_model_part)
        self.report.total_steps_expected = int(self.end_time / self.solver.dt)
        self.KratosPrintInfo(self.report.BeginReport(timer))