Upwinding in Gridap

Hi all,

I want to solve an advection-diffusion problem with DG and upwinding.
Specifically, I need to define the form

f1(u,v) =  ∫( upwinded(u, b, n_Λ) * v )dΛ

where upwinded(u, b, n_Λ) = u.plus if dot(b, n_\Lambda.plus) > 0 else u.minus if dot(b, n_\Lambda.plus) < 0 else mean(u)
So the two parts to the question are

  1. how does one create a conditional function that can be used with the Gridap interface?
  2. Specifically for upwinding, how can we implement the conditions if dot(b, n_\Lambda) as it is a CellField object?

Thanks in advance!

Hey @Simons, late answer, sorry.

I don’t know about upwinding, but, let me assume Λ is a SkeletonTriangulation and n_Λ is get_normal_vector(Λ).

What is b ? Assuming it is a CellField, you need to specify a side for evaluation of operation with the skeleton cell field n_Λ even if it’s not discontinuous: b.⁺ ⋅ n_Λ.⁺.

Then, since max or isless are not automatically supported operations between cell fields, you have to “fix” the comparisons to 0 to get a 1-argument operations (for later composition):

ispos = >(0)
isneg = <(0)

and finally you can use composition and multiplication to select the term you want:

function f1(u,v)
  trace = b.⁺ ⋅  n_Λ.⁺
  ∫(    ispos∘trace * u.⁺  
     +  isneg∘trace * u.⁻
     + iszero∘trace * mean(u) )dΛ
end