Пример #1
0
    def __init__(self, Model, settings):

        KM.Process.__init__(self)

        default_settings = KM.Parameters("""
            {
                "model_part_name"              : "model_part_name",
                "topographic_model_part_name"  : "topographic_model_part",
                "create_topographic_model_part": true,
                "update_topography"            : false,
                "update_free_surface"          : false,
                "topography_variable"          : "BATHYMETRY",
                "free_surface_variable"        : "FREE_SURFACE_ELEVATION",
                "nodal_variables_to_transfer"  : [],
                "nonhistorical_variables_to_transfer" : []
            }
            """)
        settings.ValidateAndAssignDefaults(default_settings)

        self.computing_model_part = Model[
            settings["model_part_name"].GetString()]

        # Creating the utility for the topographic model part management
        self.use_topographic_model_part = settings[
            "create_topographic_model_part"].GetBool()
        self.update_topography = False
        self.update_free_surface = False
        if self.use_topographic_model_part:
            self.topographic_model_part = Model.CreateModelPart(
                settings["topographic_model_part_name"].GetString())
            self.topography_utility = SW.ReplicateModelPartUtility(
                self.computing_model_part, self.topographic_model_part)
            self.nodal_variables = self._GenerateVariableListFromInput(
                settings["nodal_variables_to_transfer"])
            self.nonhistorical_variables = self._GenerateVariableListFromInput(
                settings["nonhistorical_variables_to_transfer"])
            self.topography_variable = KM.KratosGlobals.GetVariable(
                settings["topography_variable"].GetString())
            self.free_surface_variable = KM.KratosGlobals.GetVariable(
                settings["free_surface_variable"].GetString())
            self.update_topography = settings["update_topography"].GetBool()
            self.update_free_surface = settings["update_free_surface"].GetBool(
            )

        # The DefineAuxiliaryProperties method duplicates the current number of properties:
        # For each property, it creates another one, which means dry state.
        # It should be called only once, otherwise, the number of properties will increase without limits
        self.properties_utility = SW.PostProcessUtilities(
            self.computing_model_part)
        self.properties_utility.DefineAuxiliaryProperties()

        KM.VariableUtils().SetNonHistoricalVariableToZero(
            SW.WATER_HEIGHT, self.computing_model_part.Nodes)
        KM.VariableUtils().SetNonHistoricalVariableToZero(
            SW.WATER_SURFACE, self.computing_model_part.Nodes)
Пример #2
0
    def __init__(self, Model, settings):
        """ VisualizationMeshProcess.

        This process provides several tools for post-procesing.
        - Generation of an auxiliar model part for the topography visualization as a separate file.
        - Setting the TOPOGRAPHY and FREE_SURFACE_ELEVATION into DISPLACEMENT_Z or Z-coordinate to view the mesh deformation.
        - Duplication of the properties to use them as a dry-wet flag.
        """

        KM.Process.__init__(self)

        default_settings = KM.Parameters("""
            {
                "model_part_name"                : "model_part_name",
                "topographic_model_part_name"    : "topographic_model_part",
                "create_topographic_model_part"  : true,
                "use_properties_as_dry_wet_flag" : false,
                "mesh_deformation_mode"          : "use_nodal_displacement",
                "wet_flag"                       : "FLUID",
                "topography_variable"            : "TOPOGRAPHY",
                "free_surface_variable"          : "FREE_SURFACE_ELEVATION",
                "nodal_variables_to_transfer"    : ["TOPOGRAPHY"],
                "nonhistorical_variables_to_transfer" : []
            }
            """)
        settings.ValidateAndAssignDefaults(default_settings)

        self.computing_model_part = Model[
            settings["model_part_name"].GetString()]

        # Getting the deformation mode options and storing the variable for the free surface
        mesh_deformation_mode = settings["mesh_deformation_mode"].GetString()
        if mesh_deformation_mode == "use_z_coordinate":
            self.deform_mesh = True
        elif mesh_deformation_mode == "use_nodal_displacement":
            self.deform_mesh = False
        else:
            msg = """VisualizationMeshProcess.
            Unkown 'mesh_deformation_mode'. The possible options are:
             - use_z_coordinate
             - use_nodal_displacement
            The input is {}
            """
            raise Exception(msg.format(mesh_deformation_mode))
        self.free_surface_variable = KM.KratosGlobals.GetVariable(
            settings["free_surface_variable"].GetString())

        # Creating the utility for the topographic model part management
        self.use_topographic_model_part = settings[
            "create_topographic_model_part"].GetBool()
        if self.use_topographic_model_part:
            self.topographic_model_part = Model.CreateModelPart(
                settings["topographic_model_part_name"].GetString())
            self.topography_utility = SW.ReplicateModelPartUtility(
                self.computing_model_part, self.topographic_model_part)
            self.nodal_variables = GenerateVariableListFromInput(
                settings["nodal_variables_to_transfer"])
            self.nonhistorical_variables = GenerateVariableListFromInput(
                settings["nonhistorical_variables_to_transfer"])
            self.topography_variable = KM.KratosGlobals.GetVariable(
                settings["topography_variable"].GetString())

        # The DefineAuxiliaryProperties method duplicates the current number of properties:
        # For each property, it creates another one, which means dry state.
        # It should be called only once, otherwise, the number of properties would increase exponentially
        self.use_properties_as_dry_wet_flag = settings[
            "use_properties_as_dry_wet_flag"].GetBool()
        if self.use_properties_as_dry_wet_flag:
            self.properties_utility = SW.PostProcessUtilities(
                self.computing_model_part)
            self.properties_utility.DefineAuxiliaryProperties()
            self.wet_flag = KM.KratosGlobals.GetFlag(
                settings["wet_flag"].GetString())