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
def test_mixed_gradient_correction(self): # Given pa = self.pa dest = 'fluid' sources = ['fluid'] eqs = [ Group(equations=[ SummationDensity(dest=dest, sources=sources), ]), Group(equations=[ MixedKernelCorrectionPreStep( dest=dest, sources=sources, dim=self.dim ) ]), Group(equations=[ MixedGradientCorrection(dest=dest, sources=sources, dim=self.dim, tol=100.0), GradPhi(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.gradu, self.expect)
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