Beispiel #1
0
    def create_equations(self):
        sy11_equations = [
            Group(
                equations=[SummationDensity(dest='fluid', sources=['fluid'])],
                real=False),
            Group(equations=[
                StateEquation(dest='fluid', sources=None, rho0=rho0, p0=p0),
                SY11ColorGradient(dest='fluid', sources=['fluid'])
            ],
                  real=False),
            Group(equations=[
                ScaleSmoothingLength(dest='fluid',
                                     sources=None,
                                     factor=factor1)
            ],
                  real=False,
                  update_nnps=True),
            Group(equations=[SY11DiracDelta(dest='fluid', sources=['fluid'])],
                  real=False),
            Group(equations=[
                InterfaceCurvatureFromNumberDensity(
                    dest='fluid',
                    sources=['fluid'],
                    with_morris_correction=True),
            ],
                  real=False),
            Group(
                equations=[
                    ScaleSmoothingLength(dest='fluid',
                                         sources=None,
                                         factor=factor2)
                ],
                real=False,
                update_nnps=True,
            ),
            Group(equations=[
                MomentumEquationPressureGradient(dest='fluid',
                                                 sources=['fluid'],
                                                 pb=0.0),
                MomentumEquationViscosity(dest='fluid',
                                          sources=['fluid'],
                                          nu=nu),
                ShadlooYildizSurfaceTensionForce(dest='fluid',
                                                 sources=None,
                                                 sigma=sigma),
            ], )
        ]

        adami_equations = [
            Group(
                equations=[SummationDensity(dest='fluid', sources=['fluid'])],
                real=False),
            Group(equations=[
                StateEquation(dest='fluid', sources=None, rho0=rho0, p0=p0),
            ],
                  real=False),
            Group(equations=[
                AdamiColorGradient(dest='fluid', sources=['fluid']),
            ],
                  real=False),
            Group(equations=[
                AdamiReproducingDivergence(dest='fluid',
                                           sources=['fluid'],
                                           dim=2),
            ],
                  real=False),
            Group(equations=[
                MomentumEquationPressureGradient(dest='fluid',
                                                 sources=['fluid'],
                                                 pb=p0),
                MomentumEquationViscosityAdami(dest='fluid',
                                               sources=['fluid']),
                CSFSurfaceTensionForceAdami(
                    dest='fluid',
                    sources=None,
                )
            ], )
        ]

        adami_stress_equations = [
            Group(equations=[
                SummationDensity(dest='fluid', sources=['fluid']),
            ],
                  real=False),
            Group(equations=[
                TaitEOS(dest='fluid',
                        sources=None,
                        rho0=rho0,
                        c0=c0,
                        gamma=7,
                        p0=p0),
            ],
                  real=False),
            Group(equations=[
                ColorGradientAdami(dest='fluid', sources=['fluid']),
            ],
                  real=False),
            Group(equations=[
                ConstructStressMatrix(dest='fluid',
                                      sources=None,
                                      sigma=sigma,
                                      d=2)
            ],
                  real=False),
            Group(equations=[
                MomentumEquationPressureGradientAdami(dest='fluid',
                                                      sources=['fluid']),
                MomentumEquationViscosityAdami(dest='fluid', sources=['fluid'
                                                                      ]),
                SurfaceForceAdami(dest='fluid', sources=['fluid']),
            ]),
        ]

        tvf_equations = [
            Group(
                equations=[SummationDensity(dest='fluid', sources=['fluid'])],
                real=False),
            Group(equations=[
                StateEquation(dest='fluid', sources=None, rho0=rho0, p0=p0),
                SmoothedColor(dest='fluid', sources=['fluid']),
            ],
                  real=False),
            Group(equations=[
                MorrisColorGradient(dest='fluid',
                                    sources=['fluid'],
                                    epsilon=epsilon),
            ],
                  real=False),
            Group(equations=[
                InterfaceCurvatureFromNumberDensity(
                    dest='fluid',
                    sources=['fluid'],
                    with_morris_correction=True),
            ],
                  real=False),
            Group(equations=[
                MomentumEquationPressureGradient(dest='fluid',
                                                 sources=['fluid'],
                                                 pb=p0),
                MomentumEquationViscosity(dest='fluid',
                                          sources=['fluid'],
                                          nu=nu),
                CSFSurfaceTensionForce(dest='fluid', sources=None,
                                       sigma=sigma),
                MomentumEquationArtificialStress(dest='fluid',
                                                 sources=['fluid']),
            ], )
        ]

        morris_equations = [
            Group(equations=[
                SummationDensitySourceMass(dest='fluid', sources=['fluid']),
            ],
                  real=False,
                  update_nnps=False),
            Group(equations=[
                TaitEOS(dest='fluid',
                        sources=None,
                        rho0=rho0,
                        c0=c0,
                        gamma=1.0),
                SmoothedColor(dest='fluid', sources=[
                    'fluid',
                ]),
                ScaleSmoothingLength(dest='fluid',
                                     sources=None,
                                     factor=2.0 / 3.0),
            ],
                  real=False,
                  update_nnps=False),
            Group(equations=[
                MorrisColorGradient(dest='fluid',
                                    sources=[
                                        'fluid',
                                    ],
                                    epsilon=epsilon),
            ],
                  real=False,
                  update_nnps=False),
            Group(equations=[
                InterfaceCurvatureFromDensity(dest='fluid',
                                              sources=['fluid'],
                                              with_morris_correction=True),
                ScaleSmoothingLength(dest='fluid', sources=None, factor=1.5),
            ],
                  real=False,
                  update_nnps=False),
            Group(equations=[
                MomentumEquationPressureGradientMorris(dest='fluid',
                                                       sources=['fluid']),
                MomentumEquationViscosityMorris(dest='fluid',
                                                sources=['fluid']),
                CSFSurfaceTensionForce(dest='fluid', sources=None,
                                       sigma=sigma),
            ],
                  update_nnps=False)
        ]

        if self.options.scheme == 'tvf':
            return tvf_equations
        elif self.options.scheme == 'adami_stress':
            return adami_stress_equations
        elif self.options.scheme == 'adami':
            return adami_equations
        elif self.options.scheme == 'shadloo':
            return sy11_equations
        else:
            return morris_equations
Beispiel #2
0
    def create_equations(self):
        sy11_equations = [
            # We first compute the mass and number density of the fluid
            # phase. This is used in all force computations henceforth. The
            # number density (1/volume) is explicitly set for the solid phase
            # and this isn't modified for the simulation.
            Group(
                equations=[SummationDensity(dest='fluid', sources=['fluid'])]),

            # Given the updated number density for the fluid, we can update
            # the fluid pressure. Additionally, we can compute the Shepard
            # Filtered velocity required for the no-penetration boundary
            # condition. Also compute the gradient of the color function to
            # compute the normal at the interface.
            Group(equations=[
                StateEquation(dest='fluid', sources=None, rho0=rho0, p0=p0),
                SY11ColorGradient(dest='fluid', sources=['fluid'])
            ]),

            #################################################################
            # Begin Surface tension formulation
            #################################################################
            # Scale the smoothing lengths to determine the interface
            # quantities.
            Group(equations=[
                ScaleSmoothingLength(dest='fluid',
                                     sources=None,
                                     factor=factor1)
            ],
                  update_nnps=False),

            # Compute the discretized dirac delta with respect to the new
            # smoothing length.
            Group(equations=[SY11DiracDelta(dest='fluid',
                                            sources=['fluid'])], ),

            # Compute the interface curvature using the modified smoothing
            # length and interface normals computed in the previous Group.
            Group(equations=[
                InterfaceCurvatureFromNumberDensity(
                    dest='fluid',
                    sources=['fluid'],
                    with_morris_correction=True),
            ], ),

            # Now rescale the smoothing length to the original value for the
            # rest of the computations.
            Group(
                equations=[
                    ScaleSmoothingLength(dest='fluid',
                                         sources=None,
                                         factor=factor2)
                ],
                update_nnps=False,
            ),
            #################################################################
            # End Surface tension formulation
            #################################################################

            # The main acceleration block
            Group(
                equations=[

                    # Gradient of pressure for the fluid phase using the
                    # number density formulation. No penetration boundary
                    # condition using Adami et al's generalized wall boundary
                    # condition. The extrapolated pressure and density on the
                    # wall particles is used in the gradient of pressure to
                    # simulate a repulsive force.
                    MomentumEquationPressureGradient(dest='fluid',
                                                     sources=['fluid'],
                                                     pb=p0),

                    # Artificial viscosity for the fluid phase.
                    MomentumEquationViscosity(dest='fluid',
                                              sources=['fluid'],
                                              nu=nu),

                    # Surface tension force for the SY11 formulation
                    ShadlooYildizSurfaceTensionForce(dest='fluid',
                                                     sources=None,
                                                     sigma=sigma),

                    # Artificial stress for the fluid phase
                    MomentumEquationArtificialStress(dest='fluid',
                                                     sources=['fluid']),
                ], )
        ]

        morris_equations = [

            # We first compute the mass and number density of the fluid
            # phase. This is used in all force computations henceforth. The
            # number density (1/volume) is explicitly set for the solid phase
            # and this isn't modified for the simulation.
            Group(
                equations=[SummationDensity(dest='fluid', sources=['fluid'])]),

            # Given the updated number density for the fluid, we can update
            # the fluid pressure. Additionally, we can compute the Shepard
            # Filtered velocity required for the no-penetration boundary
            # condition. Also compute the smoothed color based on the color
            # index for a particle.
            Group(equations=[
                StateEquation(dest='fluid', sources=None, rho0=rho0, p0=p0),
                SmoothedColor(dest='fluid', sources=['fluid'], smooth=True),
            ]),

            #################################################################
            # Begin Surface tension formulation
            #################################################################
            # Compute the gradient of the smoothed color field. At the end of
            # this Group, we will have the interface normals and the
            # discretized dirac delta function for the fluid-fluid interface.
            Group(equations=[
                MorrisColorGradient(dest='fluid',
                                    sources=['fluid'],
                                    epsilon=epsilon),
            ], ),

            # Compute the interface curvature computed in the previous Group.
            Group(equations=[
                InterfaceCurvatureFromNumberDensity(
                    dest='fluid',
                    sources=['fluid'],
                    with_morris_correction=True),
            ], ),
            #################################################################
            # End Surface tension formulation
            #################################################################

            # The main acceleration block
            Group(
                equations=[

                    # Gradient of pressure for the fluid phase
                    MomentumEquationPressureGradient(dest='fluid',
                                                     sources=['fluid'],
                                                     pb=p0),

                    # Artificial viscosity for the fluid phase.
                    MomentumEquationViscosity(dest='fluid',
                                              sources=['fluid'],
                                              nu=nu),

                    # Surface tension force for the Morris formulation
                    CSFSurfaceTensionForce(dest='fluid',
                                           sources=None,
                                           sigma=sigma),

                    # Artificial stress for the fluid phase
                    MomentumEquationArtificialStress(dest='fluid',
                                                     sources=['fluid']),
                ], )
        ]

        adami_equations = [

            # We first compute the mass and number density of the fluid
            # phase. This is used in all force computations henceforth. The
            # number density (1/volume) is explicitly set for the solid phase
            # and this isn't modified for the simulation.
            Group(
                equations=[SummationDensity(dest='fluid', sources=['fluid'])]),

            # Given the updated number density for the fluid, we can update
            # the fluid pressure. Additionally, we can compute the Shepard
            # Filtered velocity required for the no-penetration boundary
            # condition.
            Group(equations=[
                StateEquation(dest='fluid', sources=None, rho0=rho0, p0=p0),
            ]),

            #################################################################
            # Begin Surface tension formulation
            #################################################################
            # Compute the gradient of the color field.
            Group(equations=[
                AdamiColorGradient(dest='fluid', sources=['fluid']),
            ], ),

            # Compute the interface curvature using the color gradients
            # computed in the previous Group.
            Group(equations=[
                AdamiReproducingDivergence(dest='fluid',
                                           sources=['fluid'],
                                           dim=2),
            ], ),
            #################################################################
            # End Surface tension formulation
            #################################################################

            # The main acceleration block
            Group(
                equations=[

                    # Gradient of pressure for the fluid phase
                    MomentumEquationPressureGradient(dest='fluid',
                                                     sources=['fluid'],
                                                     pb=p0),

                    # Artificial viscosity for the fluid phase.
                    MomentumEquationViscosity(dest='fluid',
                                              sources=['fluid'],
                                              nu=nu),

                    # Surface tension force for the CSF formulation
                    CSFSurfaceTensionForce(dest='fluid',
                                           sources=None,
                                           sigma=sigma),

                    # Artificial stress for the fluid phase
                    MomentumEquationArtificialStress(dest='fluid',
                                                     sources=['fluid']),
                ], )
        ]

        if self.options.scheme == 'morris':
            return morris_equations
        elif self.options.scheme == 'adami':
            return adami_equations
        else:
            return sy11_equations