Пример #1
0
 def create_equations(self):
     eqns = self.scheme.get_equations()
     if self.options.scheme == 'iisph' or self.options.scheme == 'sisph':
         return eqns
     if self.options.scheme == 'gtvf':
         return eqns
     n = len(eqns)
     if self.kernel_corr == 'grad-corr':
         eqn1 = Group(equations=[
             GradientCorrectionPreStep('fluid', ['fluid', 'boundary'])
         ], real=False)
         for i in range(n):
             eqn2 = GradientCorrection('fluid', ['fluid', 'boundary'])
             eqns[i].equations.insert(0, eqn2)
         eqns.insert(0, eqn1)
     elif self.kernel_corr == 'mixed-corr':
         eqn1 = Group(equations=[
             MixedKernelCorrectionPreStep('fluid', ['fluid', 'boundary'])
         ], real=False)
         for i in range(n):
             eqn2 = GradientCorrection('fluid', ['fluid', 'boundary'])
             eqns[i].equations.insert(0, eqn2)
         eqns.insert(0, eqn1)
     elif self.kernel_corr == 'crksph':
         eqn1 = Group(equations=[
             CRKSPHPreStep('fluid', ['fluid', 'boundary']),
             CRKSPHPreStep('boundary', ['fluid', 'boundary'])
         ], real=False)
         for i in range(n):
             eqn2 = CRKSPH('fluid', ['fluid', 'boundary'])
             eqn3 = CRKSPH('boundary', ['fluid', 'boundary'])
             eqns[i].equations.insert(0, eqn3)
             eqns[i].equations.insert(0, eqn2)
         eqns.insert(0, eqn1)
     return eqns
Пример #2
0
    def test_crksph(self):
        # Given
        pa = self.pa
        dest = 'fluid'
        sources = ['fluid']
        pa.add_property('zero_mom')
        pa.add_property('first_mom', stride=3)
        pa.rho[:] = 1.0
        eqs = [
            Group(equations=[
                SummationDensity(dest=dest, sources=sources),
            ]),
            Group(equations=[
                CRKSPHPreStep(dest=dest, sources=sources, dim=self.dim)
            ]),
            Group(equations=[
                CRKSPH(dest=dest, sources=sources,
                       dim=self.dim, tol=1000.0),
                GradPhi(dest=dest, sources=sources),
                VerifyCRKSPH(dest=dest, sources=sources)
            ])
        ]
        a_eval = self._make_accel_eval(eqs)

        # When
        a_eval.evaluate(0.0, 0.1)

        # Then
        np.testing.assert_array_almost_equal(pa.zero_mom, 1.0)
        np.testing.assert_array_almost_equal(pa.first_mom, 0.0)
        np.testing.assert_array_almost_equal(pa.gradu, self.expect)
Пример #3
0
 def create_equations(self):
     eqns = self.scheme.get_equations()
     n = len(eqns)
     tol = 1.0
     if self.kernel_corr == 'grad-corr':
         eqn1 = Group(
             equations=[GradientCorrectionPreStep('fluid', ['fluid'])],
             real=False)
         for i in range(n):
             eqn2 = GradientCorrection('fluid', ['fluid'], 2, tol)
             eqns[i].equations.insert(0, eqn2)
         eqns.insert(0, eqn1)
     elif self.kernel_corr == 'mixed-corr':
         eqn1 = Group(
             equations=[MixedKernelCorrectionPreStep('fluid', ['fluid'])],
             real=False)
         for i in range(n):
             eqn2 = GradientCorrection('fluid', ['fluid'], 2, tol)
             eqns[i].equations.insert(0, eqn2)
         eqns.insert(0, eqn1)
     elif self.kernel_corr == 'crksph':
         eqn1 = Group(equations=[CRKSPHPreStep('fluid', ['fluid'])],
                      real=False)
         for i in range(n):
             eqn2 = CRKSPH('fluid', ['fluid'], 2, tol)
             eqns[i].equations.insert(0, eqn2)
         eqns.insert(0, eqn1)
     return eqns