@@ -136,21 +136,38 @@ end
136136 return dv
137137end
138138
139- # This formulation was chosen to be consistent with the used pressure_acceleration formulations
140- @propagate_inbounds function continuity_equation! (dv, density_calculator:: ContinuityDensity ,
139+ # For compatibility with the old continuity equation function
140+ @propagate_inbounds function continuity_equation! (dv:: AbstractArray ,
141+ density_calculator:: ContinuityDensity ,
141142 particle_system:: AbstractFluidSystem ,
142143 neighbor_system,
143144 v_particle_system, v_neighbor_system,
144145 particle, neighbor, pos_diff, distance,
145146 m_b, rho_a, rho_b, grad_kernel)
147+ drho_particle = Ref (zero (rho_a))
146148 vdiff = current_velocity (v_particle_system, particle_system, particle) -
147149 current_velocity (v_neighbor_system, neighbor_system, neighbor)
148150
151+ continuity_equation! (drho_particle, density_calculator, particle_system,
152+ neighbor_system, v_particle_system, v_neighbor_system,
153+ particle, neighbor, pos_diff, distance,
154+ m_b, rho_a, rho_b, vdiff, grad_kernel)
155+ dv[end , particle] += drho_particle[]
156+ end
157+
158+ # This formulation was chosen to be consistent with the used pressure_acceleration formulations
159+ @propagate_inbounds function continuity_equation! (drho_particle,
160+ density_calculator:: ContinuityDensity ,
161+ particle_system:: AbstractFluidSystem ,
162+ neighbor_system,
163+ v_particle_system, v_neighbor_system,
164+ particle, neighbor, pos_diff, distance,
165+ m_b, rho_a, rho_b, vdiff, grad_kernel)
149166 vdiff += continuity_equation_shifting_term (shifting_technique (particle_system),
150167 particle_system, neighbor_system,
151168 particle, neighbor, rho_a, rho_b)
152169
153- dv[ end , particle ] += rho_a / rho_b * m_b * dot (vdiff, grad_kernel)
170+ drho_particle[ ] += div_fast ( rho_a, rho_b) * m_b * dot (vdiff, grad_kernel)
154171
155172 # Artificial density diffusion should only be applied to systems representing a fluid
156173 # with the same physical properties i.e. density and viscosity.
0 commit comments