underworld3 icon indicating copy to clipboard operation
underworld3 copied to clipboard

Mass Conservation in the Latest Underworld3 Version

Open gp37 opened this issue 5 months ago • 5 comments

I’m testing the newest version of Underworld3 and noticed that the Stokes solver seems to enforce only the standard incompressible form of the continuity equation: ∇⋅u=0 In earlier UW3 examples (and older versions), I recall there being ways to modify or extend this equation to include compressibility effects, for example: ∇⋅(ρu)=0 Is this feature no longer available?

gp37 avatar Aug 06 '25 14:08 gp37

Apologies, this would probably be something I did unintentionally when refactoring the solvers. There should be a way to set the RHS term. I'll have a look.

@jcgraciosa - you did the benchmarks originally, can you think about a regression test for this and other less-travelled parts of the equation templating system.

lmoresi avatar Aug 19 '25 07:08 lmoresi

I'll do a regression test of this and will update soon.

jcgraciosa avatar Aug 20 '25 07:08 jcgraciosa

The Stokes solver has a PF0 property / expression that should capture the RHS of the continuity equation. This is a different interface to the previous one, so it needs testing, but the code hooks are there ... @jcgraciosa , we could just try the previous benchmarks - we have to do this for the benchmarking paper at some point.

lmoresi avatar Sep 01 '25 12:09 lmoresi

Could you give an example of how you would implement the PFO property?

gp37 avatar Sep 23 '25 13:09 gp37

Hello @gp37! To do the TALA approximation in Underworld3, you can add the following in your model set-up:

stokes.penalty = -(2/3) * viscosity
stokes.constraints = sympy.Matrix([stokes.div_u + dot(v_soln.fn, gradient(rho_bar))/rho_bar]) 

In the code snippet above:

  1. stokes - the stokes solver you created
  2. viscosity - viscosity value
  3. stokes.div_u - the expression of the velocity divergence which is a property of the Stokes solver
  4. v_soln - the velocity mesh variable
  5. rho_bar - the expression stating how rho varies (e.g. as a function of depth)

If there are other questions, let me know.

jcgraciosa avatar Oct 16 '25 02:10 jcgraciosa