예제 #1
0
    def setUpSolvers(self):
        oss_switch = 0

        import vms_monolithic_solver
        vms_monolithic_solver.AddVariables(self.fluid_model_part)

        if self.convection_diffusion_solver == 'bfecc':
            import bfecc_convection_diffusion_solver as thermal_solver
        elif self.convection_diffusion_solver == 'eulerian':
            import convection_diffusion_solver as thermal_solver
        else:
            raise Exception(
                "Unsupported convection-diffusion solver option: {0}".format(
                    self.convection_diffusion_solver))

        thermal_solver.AddVariables(self.fluid_model_part)

        model_part_io = ModelPartIO(self.input_file)
        model_part_io.ReadModelPart(self.fluid_model_part)

        self.fluid_model_part.SetBufferSize(2)
        vms_monolithic_solver.AddDofs(self.fluid_model_part)
        thermal_solver.AddDofs(self.fluid_model_part)

        # Building custom fluid solver
        self.fluid_solver = vms_monolithic_solver.MonolithicSolver(
            self.fluid_model_part, self.domain_size)
        rel_vel_tol = 1e-5
        abs_vel_tol = 1e-7
        rel_pres_tol = 1e-5
        abs_pres_tol = 1e-7
        self.fluid_solver.conv_criteria = VelPrCriteria(
            rel_vel_tol, abs_vel_tol, rel_pres_tol, abs_pres_tol)
        self.fluid_solver.conv_criteria.SetEchoLevel(0)

        alpha = -0.3
        move_mesh = 0
        self.fluid_solver.time_scheme = ResidualBasedPredictorCorrectorVelocityBossakSchemeTurbulent(
            alpha, move_mesh, self.domain_size)
        import KratosMultiphysics.python_linear_solver_factory as linear_solver_factory
        self.fluid_solver.linear_solver = linear_solver_factory.ConstructSolver(
            Parameters(r'''{
                "solver_type" : "amgcl"
            }'''))
        builder_and_solver = ResidualBasedBlockBuilderAndSolver(
            self.fluid_solver.linear_solver)
        self.fluid_solver.max_iter = 50
        self.fluid_solver.compute_reactions = False
        self.fluid_solver.ReformDofSetAtEachStep = False
        self.fluid_solver.MoveMeshFlag = False

        self.fluid_solver.solver = ResidualBasedNewtonRaphsonStrategy(\
                self.fluid_model_part,
                self.fluid_solver.time_scheme,
                self.fluid_solver.linear_solver,
                self.fluid_solver.conv_criteria,
                builder_and_solver,
                self.fluid_solver.max_iter,
                self.fluid_solver.compute_reactions,
                self.fluid_solver.ReformDofSetAtEachStep,
                self.fluid_solver.MoveMeshFlag)

        self.fluid_solver.solver.SetEchoLevel(0)
        self.fluid_solver.solver.Check()

        self.fluid_model_part.ProcessInfo.SetValue(OSS_SWITCH, oss_switch)

        self.fluid_solver.divergence_clearance_steps = 0
        self.fluid_solver.use_slip_conditions = 0

        if self.convection_diffusion_solver == 'eulerian':
            # Duplicate model part

            thermal_model_part = self.model.CreateModelPart("Thermal")
            conv_diff_element = "EulerianConvDiff2D"
            conv_diff_condition = "Condition2D2N"

            MergeVariableListsUtility().Merge(self.fluid_model_part,
                                              thermal_model_part)

            modeler = ConnectivityPreserveModeler()
            modeler.GenerateModelPart(self.fluid_model_part,
                                      thermal_model_part, conv_diff_element,
                                      conv_diff_condition)

            # thermal solver
            self.thermal_solver = thermal_solver.ConvectionDiffusionSolver(
                thermal_model_part, self.domain_size)
        else:

            class SolverSettings:
                def __init__(self, domain_size):
                    self.domain_size = domain_size

            settings = SolverSettings(self.domain_size)
            self.thermal_solver = thermal_solver.CreateSolver(
                self.model_part, settings)
        self.thermal_solver.Initialize()
예제 #2
0
    def setUpSolvers(self):
        oss_switch = 0

        import vms_monolithic_solver
        vms_monolithic_solver.AddVariables(self.model_part)

        if self.convection_diffusion_solver == 'bfecc':
            import bfecc_convection_diffusion_solver as thermal_solver
        elif self.convection_diffusion_solver == 'eulerian':
            import eulerian_convection_diffusion_solver as thermal_solver
        else:
            raise Exception(
                "Unsupported convection-diffusion solver option: {0}".format(
                    self.convection_diffusion_solver))

        thermal_solver.AddVariables(self.model_part)
        self.model_part.AddNodalSolutionStepVariable(FACE_HEAT_FLUX)
        self.model_part.AddNodalSolutionStepVariable(PROJECTED_SCALAR1)

        model_part_io = ModelPartIO(self.input_file)
        model_part_io.ReadModelPart(self.model_part)

        self.model_part.SetBufferSize(2)
        vms_monolithic_solver.AddDofs(self.model_part)
        thermal_solver.AddDofs(self.model_part)

        # Building custom fluid solver
        self.fluid_solver = vms_monolithic_solver.MonolithicSolver(
            self.model_part, self.domain_size)
        rel_vel_tol = 1e-5
        abs_vel_tol = 1e-7
        rel_pres_tol = 1e-5
        abs_pres_tol = 1e-7
        self.fluid_solver.conv_criteria = VelPrCriteria(
            rel_vel_tol, abs_vel_tol, rel_pres_tol, abs_pres_tol)
        self.fluid_solver.conv_criteria.SetEchoLevel(0)

        alpha = -0.3
        move_mesh = 0
        self.fluid_solver.time_scheme = ResidualBasedPredictorCorrectorVelocityBossakSchemeTurbulent(
            alpha, move_mesh, self.domain_size)
        precond = DiagonalPreconditioner()
        self.fluid_solver.linear_solver = BICGSTABSolver(1e-6, 5000, precond)
        builder_and_solver = ResidualBasedBlockBuilderAndSolver(
            self.fluid_solver.linear_solver)
        self.fluid_solver.max_iter = 50
        self.fluid_solver.compute_reactions = False
        self.fluid_solver.ReformDofSetAtEachStep = False
        self.fluid_solver.MoveMeshFlag = False

        self.fluid_solver.solver = ResidualBasedNewtonRaphsonStrategy(\
                self.model_part,
                self.fluid_solver.time_scheme,
                self.fluid_solver.linear_solver,
                self.fluid_solver.conv_criteria,
                builder_and_solver,
                self.fluid_solver.max_iter,
                self.fluid_solver.compute_reactions,
                self.fluid_solver.ReformDofSetAtEachStep,
                self.fluid_solver.MoveMeshFlag)

        self.fluid_solver.solver.SetEchoLevel(0)
        self.fluid_solver.solver.Check()

        self.model_part.ProcessInfo.SetValue(OSS_SWITCH, oss_switch)

        self.fluid_solver.divergence_clearance_steps = 0
        self.fluid_solver.use_slip_conditions = 0

        # thermal solver
        class SolverSettings:
            def __init__(self, domain_size):
                self.domain_size = domain_size

        settings = SolverSettings(self.domain_size)
        self.thermal_solver = thermal_solver.CreateSolver(
            self.model_part, settings)
        self.thermal_solver.Initialize()