예제 #1
0
    def _ExecuteAfterReading(self):
        self.computing_model_part_name = "computing_domain"  #this submodelpart will be labeled with KratosMultiphysics.ACTIVE flag, you can recover it checking the flag.

        # Auxiliary Kratos parameters object to be called by the CheckAndPepareModelProcess
        params = KratosMultiphysics.Parameters("{}")
        params.AddEmptyValue("computing_model_part_name").SetString(
            self.computing_model_part_name)
        params.AddValue("problem_domain_sub_model_part_list",
                        self.settings["problem_domain_sub_model_part_list"])
        params.AddValue("processes_sub_model_part_list",
                        self.settings["processes_sub_model_part_list"])

        if (self.settings.Has("bodies_list")):
            params.AddValue("bodies_list", self.settings["bodies_list"])

        # CheckAndPrepareModelProcess creates the solid_computational model part
        import check_and_prepare_model_process_solid
        check_and_prepare_model_process_solid.CheckAndPrepareModelProcess(
            self.main_model_part, params).Execute()

        # Constitutive law import
        import constitutive_law_python_utility as constitutive_law_utils
        constitutive_law = constitutive_law_utils.ConstitutiveLawUtility(
            self.main_model_part,
            self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE])
        constitutive_law.Initialize()
        print("    Constitutive law initialized.")
예제 #2
0
    def _import_materials(self):
        # Assign material to model_parts (if Materials.json exists)
        import process_factory

        if(os.path.isfile("Materials.json") or self.input_manager.HasMaterialFile()):

            MaterialParameters = self.input_manager.GetMaterialParameters()

            if MaterialParameters.Has("material_models_list"):

                import KratosMultiphysics.ConstitutiveModelsApplication as KratosMaterials

                domain_model = self.model.GetModel()

                assign_materials_processes = process_factory.KratosProcessFactory(domain_model).ConstructListOfProcesses(MaterialParameters["material_models_list"])

                for process in assign_materials_processes:
                    process.Execute()

                self.model.CleanModel()

        elif os.path.isfile("materials.py"):  # legacy

            import constitutive_law_python_utility as constitutive_law_utils

            constitutive_law = constitutive_law_utils.ConstitutiveLawUtility(self.main_model_part, self.process_info[KratosMultiphysics.SPACE_DIMENSION])

            constitutive_law.Initialize()

            self.model.CleanModel()

            print("::[-----Material------]:: Reading file: materials.py ")

        else:
            print("No Materials.json or Materials.py found ")
예제 #3
0
    def _import_materials(self):
        # Assign material to model_parts (if Materials.json exists)
        import process_factory

        if os.path.isfile("Materials.json"):
            materials_file = open("Materials.json",'r')
            MaterialParameters = KratosMultiphysics.Parameters(materials_file.read())
    
            if(MaterialParameters.Has("material_models_list")):

                import KratosMultiphysics.ConstitutiveModelsApplication as KratosMaterials
                
                domain_model = self.model.GetModel()
        
                assign_materials_processes = process_factory.KratosProcessFactory(domain_model).ConstructListOfProcesses( MaterialParameters["material_models_list"] )

                for process in assign_materials_processes:
                    process.Execute()
                                
        elif os.path.isfile("materials.py"): # legacy
            
            import constitutive_law_python_utility as constitutive_law_utils

            constitutive_law = constitutive_law_utils.ConstitutiveLawUtility(self.main_model_part, self.process_info[KratosMultiphysics.SPACE_DIMENSION]);

            constitutive_law.Initialize();
        
            problem_path = os.getcwd()

            print("   Reading constitutive law from file :" + os.path.join(problem_path, "materials") + ".py ")

        else:
            print(" No Materials.json or Materials.py found ")
예제 #4
0
    def _import_constitutive_laws(self):
        # Constitutive law import
        import constitutive_law_python_utility as constitutive_law_utils
        constitutive_law = constitutive_law_utils.ConstitutiveLawUtility(
            self.main_model_part,
            self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE])
        constitutive_law.Initialize()

        return True
예제 #5
0
 def _import_constitutive_laws(self):
     
     if os.path.isfile("materials.py"):
         # Constitutive law import
         import constitutive_law_python_utility as constitutive_law_utils
         constitutive_law = constitutive_law_utils.ConstitutiveLawUtility(self.main_model_part,
                                                                          self.main_model_part.ProcessInfo[KratosMultiphysics.SPACE_DIMENSION]);
         constitutive_law.Initialize();
         
         return True
     else:
         return False        
    def ImportModelPart(self):

        print("::[Mechanical Solver]:: Model reading starts.")
        if (self.settings["model_import_settings"]["input_type"].GetString() ==
                "mdpa"):

            # Here it would be the place to import restart data if required
            ModelPartIO(self.settings["model_import_settings"]
                        ["input_filename"].GetString()).ReadModelPart(
                            self.main_model_part)
            print("    Import input model part.")

            # Auxiliary Kratos parameters object to be called by the CheckAndPepareModelProcess
            aux_params = Parameters("{}")
            aux_params.AddValue(
                "problem_domain_sub_model_part_list",
                self.settings["problem_domain_sub_model_part_list"])
            aux_params.AddValue("processes_sub_model_part_list",
                                self.settings["processes_sub_model_part_list"])

            # CheckAndPrepareModelProcess creates the solid_computational_model_part
            import check_and_preparemodel_process
            check_and_preparemodel_process.CheckAndPrepareModelProcess(
                self.main_model_part, aux_params).Execute()

            # Constitutive law import
            import constitutive_law_python_utility as constitutive_law_utils
            constitutive_law = constitutive_law_utils.ConstitutiveLawUtility(
                self.main_model_part,
                self.main_model_part.ProcessInfo[DOMAIN_SIZE])
            constitutive_law.Initialize()
            print("    Constitutive law initialized.")

        else:
            raise Exception("Other input options are not yet implemented.")

        current_buffer_size = self.main_model_part.GetBufferSize()
        if (self.GetMinimumBufferSize() > current_buffer_size):
            self.main_model_part.SetBufferSize(self.GetMinimumBufferSize())

        print("::[Mechanical Solver]:: Model reading finished.")
예제 #7
0
    # set the buffer size
    model_part.SetBufferSize(buffer_size)
    # Note: the buffer size should be set once the mesh is read for the first time

    print("::[KSM Simulation]:: Reading -END- ")

    model_part.ProcessInfo[LOAD_RESTART] = 0

    # set the degrees of freedom
    solver_constructor.AddDofs(model_part, SolverSettings)

    # set the constitutive law
    import constitutive_law_python_utility as constitutive_law_utils

    constitutive_law = constitutive_law_utils.ConstitutiveLawUtility(
        model_part, domain_size)
    constitutive_law.Initialize()

else:

    print("::[KSM Simulation]:: Reading -RESTART- (RESTART FILE ",
          restart_step, ")- ")

    # reading the model from the restart file
    problem_restart.Load(restart_step)

    print("::[KSM Simulation]:: Reading -END- ")

    model_part.ProcessInfo[LOAD_RESTART] = 1

    # remove results, restart, graph and list posterior files
예제 #8
0
# Setting up the buffer size
spheres_model_part.SetBufferSize(1)
cluster_model_part.SetBufferSize(1)
DEM_inlet_model_part.SetBufferSize(1)
rigid_face_model_part.SetBufferSize(FEM_main_step_solver.buffer_size)  #DEMFFEM

# Adding dofs
solver.AddDofs(spheres_model_part)
solver.AddDofs(cluster_model_part)
solver.AddDofs(DEM_inlet_model_part)
FEM_solver_constructor.AddDofs(rigid_face_model_part, FEMSolverSettings)

#Utilities

# set the constitutive law
constitutive_law = constitutive_law_utils.ConstitutiveLawUtility(
    rigid_face_model_part, DEM_parameters["Dimension"].GetInt())
constitutive_law.Initialize()
conditions = condition_utils.ConditionsUtility(
    rigid_face_model_part, DEM_parameters["Dimension"].GetInt(),
    FEM_general_variables.Incremental_Displacement,
    FEM_general_variables.Incremental_Load, FEMSolverSettings.RotationDofs)

# Creating necessary directories
main_path = os.getcwd()
[post_path, data_and_results, graphs_path,
 MPI_results] = procedures.CreateDirectories(
     str(main_path), str(DEM_parameters["problem_name"].GetString()))

os.chdir(main_path)

KRATOSprint("\nInitializing Problem...")
    def ImportModelPart(self):

        print("::[Mechanical Solver]:: Model reading starts.")
        if (self.settings["model_import_settings"]["input_type"].GetString() ==
                "mdpa"):
            # Here it would be the place to import restart data if required
            KratosMultiphysics.ModelPartIO(
                self.settings["model_import_settings"]
                ["input_filename"].GetString()).ReadModelPart(
                    self.main_model_part)
            print("    Import input model part.")

            # Here we shall check that the input read has the shape we like
            aux_params = KratosMultiphysics.Parameters("{}")
            aux_params.AddValue("volume_model_part_name",
                                self.settings["volume_model_part_name"])
            aux_params.AddValue("skin_parts", self.settings["skin_parts"])

            ######### TO BE REVIEWED AS SOON AS THE REPLACE SETTINGS ARE STATED ###########
            #~ #here we replace the dummy elements we read with proper elements
            #~ self.settings.AddEmptyValue("element_replace_settings")
            #~ if(self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE] == 3):
            #~ self.settings["element_replace_settings"] = KratosMultiphysics.Parameters("""
            #~ {
            #~ "element_name":"VMS3D4N",
            #~ "condition_name": "MonolithicWallCondition3D"
            #~ }
            #~ """)
            #~ elif(self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE] == 2):
            #~ self.settings["element_replace_settings"] = KratosMultiphysics.Parameters("""
            #~ {
            #~ "element_name":"VMS2D3N",
            #~ "condition_name": "MonolithicWallCondition2D"
            #~ }
            #~ """)
            #~ else:
            #~ raise Exception("domain size is not 2 or 3")
            #~
            #~ KratosMultiphysics.ReplaceElementsAndConditionsProcess(self.main_model_part, self.settings["element_replace_settings"]).Execute()
            #~
            #~ import check_and_preparemodel_process
            #~ check_and_preparemodel_process.CheckAndPrepareModelProcess(self.main_model_part, aux_params).Execute()

            ###### TODO: This manner does not allow to set different materials (unique material model)...
            # Set density, Young modulus and Poisson ratio to the nodes
            for el in self.main_model_part.Elements:
                density = el.Properties.GetValue(KratosMultiphysics.DENSITY)
                young_modulus = el.Properties.GetValue(
                    KratosMultiphysics.YOUNG_MODULUS)
                poisson_ratio = el.Properties.GetValue(
                    KratosMultiphysics.POISSON_RATIO)
                break

            KratosMultiphysics.VariableUtils().SetScalarVar(
                KratosMultiphysics.DENSITY, density,
                self.main_model_part.Nodes)
            KratosMultiphysics.VariableUtils().SetScalarVar(
                KratosMultiphysics.YOUNG_MODULUS, young_modulus,
                self.main_model_part.Nodes)
            KratosMultiphysics.VariableUtils().SetScalarVar(
                KratosMultiphysics.POISSON_RATIO, poisson_ratio,
                self.main_model_part.Nodes)
            print("    Density, Young modulus and Poisson ratio set.")

            # Constitutive law import
            import constitutive_law_python_utility as constitutive_law_utils
            constitutive_law = constitutive_law_utils.ConstitutiveLawUtility(
                self.main_model_part, self.main_model_part.ProcessInfo[
                    KratosMultiphysics.DOMAIN_SIZE])
            constitutive_law.Initialize()
            print("    Constitutive law initialized.")

        else:
            raise Exception("Other input options are not yet implemented.")

        current_buffer_size = self.main_model_part.GetBufferSize()
        if (self.GetMinimumBufferSize() > current_buffer_size):
            self.main_model_part.SetBufferSize(self.GetMinimumBufferSize())

        print("::[Mechanical Solver]:: Model reading finished.")
예제 #10
0
    def ImportModelPart(self):

        #add variables (always before importing the model part)
        self.AddVariables()

        if (self.settings["model_import_settings"]["input_type"].GetString() ==
                "mdpa"):
            #here it would be the place to import restart data if required
            kratos_core.ModelPartIO(
                self.settings["model_import_settings"]
                ["input_filename"].GetString()).ReadModelPart(
                    self.main_model_part)

            ##here we shall check that the input read has the shape we like
            aux_params = kratos_core.Parameters("{}")
            aux_params.AddValue("volume_model_part_name",
                                self.settings["volume_model_part_name"])
            aux_params.AddValue("skin_parts", self.settings["skin_parts"])

            #here we could do things to prepare the model part. Probably not needed for the structure
            self.compute_model_part = self.main_model_part

            ##here we must construct correctly the constitutive law
            print(
                "don't forget constructing the constitutive law!!!!!!!!!!!!!!")

            import constitutive_law_python_utility
            constitutive_law = constitutive_law_python_utility.ConstitutiveLawUtility(
                main_model_part, self.settings["DomainSize"])
            constitutive_law.Initialize()

        elif (self.settings["model_import_settings"]["input_type"].GetString()
              == "other_model_part"):  ##generate from another ModelPart
            origin_model_part = self.main_model_part.GetSubModelPart(
                self.settings["model_import_settings"]
                ["origin_model_part_name"].GetString())

            new_model_part_name = self.settings["model_import_settings"][
                "new_model_part_name"].GetString()
            if (not self.main_model_part.HasSubModelPart(new_model_part_name)):
                self.main_model_part.CreateSubModelPart(new_model_part_name)
            new_model_part = self.main_model_part.GetSubModelPart(
                new_model_part_name)

            #fill the model_part to be used by the termal solver
            kratos_core.ConnectivityPreserveModeler().GenerateModelPart(
                origin_model_part, new_model_part,
                "PlasticConvectionDiffusionElement3D", "PlasticThermalFace3D")

            #here we could do things to prepare the model part. Probably not needed for the structure
            self.compute_model_part = self.main_model_part

            ##here we must construct correctly the constitutive law
            print(
                "don't forget constructing the constitutive law!!!!!!!!!!!!!!")

            import constitutive_law_python_utility
            constitutive_law = constitutive_law_python_utility.ConstitutiveLawUtility(
                main_model_part, self.settings["DomainSize"])
            constitutive_law.Initialize()

        else:
            raise Exception("input from restart not yet implemented")

        current_buffer_size = self.main_model_part.GetBufferSize()
        if (self.GetMinimumBufferSize() > current_buffer_size):
            self.main_model_part.SetBufferSize(self.GetMinimumBufferSize())

        print("model reading finished")

        #add dofs (always after importing the model part) (it must be integrated in the ImportModelPart)
        self.AddDofs()
예제 #11
0
# Setting up the buffer size
spheres_model_part.SetBufferSize(1)
cluster_model_part.SetBufferSize(1)
DEM_inlet_model_part.SetBufferSize(1)
rigid_face_model_part.SetBufferSize(FEM_main_step_solver.buffer_size)  #DEMFFEM

# Adding dofs
solver.AddDofs(spheres_model_part)
solver.AddDofs(cluster_model_part)
solver.AddDofs(DEM_inlet_model_part)
FEM_solver_constructor.AddDofs(rigid_face_model_part, FEMSolverSettings)

#Utilities

# set the constitutive law
constitutive_law = constitutive_law_utils.ConstitutiveLawUtility(
    rigid_face_model_part, DEM_parameters.Dimension)
constitutive_law.Initialize()
conditions = condition_utils.ConditionsUtility(
    rigid_face_model_part, DEM_parameters.Dimension,
    FEM_general_variables.Incremental_Displacement,
    FEM_general_variables.Incremental_Load, FEMSolverSettings.RotationDofs)

# Creating necessary directories
main_path = os.getcwd()
[post_path, data_and_results, graphs_path,
 MPI_results] = procedures.CreateDirectories(str(main_path),
                                             str(DEM_parameters.problem_name))

os.chdir(main_path)

KRATOSprint("\nInitializing Problem...")