Esempio n. 1
0
 def _set_constitutive_law(self):
     ## Construct the constitutive law needed for the embedded element
     if (self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE] ==
             3):
         self.main_model_part.Properties[1][
             KratosMultiphysics.
             CONSTITUTIVE_LAW] = KratosCFD.Newtonian3DLaw()
     elif (self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE]
           == 2):
         self.main_model_part.Properties[1][
             KratosMultiphysics.
             CONSTITUTIVE_LAW] = KratosCFD.Newtonian2DLaw()
Esempio n. 2
0
    def _ExecuteAfterReading(self):
        ## Base class _ExecuteAfterReading call
        super(NavierStokesEmbeddedMonolithicSolver,
              self)._ExecuteAfterReading()

        ## Set the SOUND_VELOCITY value (wave velocity)
        if self.main_model_part.Properties[1].Has(
                KratosMultiphysics.SOUND_VELOCITY):
            self.main_model_part.ProcessInfo[
                KratosMultiphysics.
                SOUND_VELOCITY] = self.main_model_part.Properties[1][
                    KratosMultiphysics.SOUND_VELOCITY]
        else:
            # If the wave velocity is not defined take a large enough value to consider the fluid as incompressible
            default_sound_velocity = 1e+12
            self.main_model_part.ProcessInfo[
                KratosMultiphysics.SOUND_VELOCITY] = default_sound_velocity
            # Set the wave velocity in the model part nodes
            KratosMultiphysics.VariableUtils().SetScalarVar(
                KratosMultiphysics.SOUND_VELOCITY, default_sound_velocity,
                self.main_model_part.Nodes)

        ## Set the DYNAMIC_VISCOSITY variable needed for the embedded element
        for element in self.main_model_part.Elements:
            dyn_viscosity = element.Properties.GetValue(
                KratosMultiphysics.DYNAMIC_VISCOSITY)
            break

        KratosMultiphysics.VariableUtils().SetScalarVar(
            KratosMultiphysics.DYNAMIC_VISCOSITY, dyn_viscosity,
            self.main_model_part.Nodes)

        ## Construct the constitutive law needed for the embedded element
        if (self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE] ==
                3):
            self.main_model_part.Properties[1][
                KratosMultiphysics.
                CONSTITUTIVE_LAW] = KratosFluid.Newtonian3DLaw()
        elif (self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE]
              == 2):
            self.main_model_part.Properties[1][
                KratosMultiphysics.
                CONSTITUTIVE_LAW] = KratosFluid.Newtonian2DLaw()

        ## Setting the nodal distance
        if (self.settings["distance_reading_settings"]
            ["import_mode"].GetString() == "from_GiD_file"):
            import read_distance_from_file
            DistanceUtility = read_distance_from_file.DistanceImportUtility(
                self.main_model_part,
                self.settings["distance_reading_settings"])
            DistanceUtility.ImportDistance()
        elif (self.settings["distance_reading_settings"]
              ["import_mode"].GetString() == "from_mdpa"):
            print("Distance function taken from the .mdpa input file.")
            # Recall to swap the distance sign (GiD considers d<0 in the fluid region)
            for node in self.main_model_part.Nodes:
                distance_value = node.GetSolutionStepValue(
                    KratosMultiphysics.DISTANCE)
                node.SetSolutionStepValue(KratosMultiphysics.DISTANCE,
                                          -distance_value)