Dear Abbas, Dear Prof. Bangerth,
Thank you very much for your fast replies to my post. I'm sorry for not having found step-74 myself before.step-74 is I think indeed what I am looking for: However, when I played around with step-74, I ran into the following two issues:
degree = 1(1) trying to solve in 1D:
- I get errors of the following type:
error: ‘class dealii::DoFAccessor<0, 1, 1, false>’ has no member named ‘measure’
411 | re() / cell->face(face_no)->measure(); I can make it run by removing the calls to these functions and replace the penalty factor which would involve them by a constant number, which according to the output seems to work o.k. but might need further tuning of the penalty constant (here just chosen as a constant of 100).
- This first point however is less important than (2) below, because my desired usecase is anyways either 2D or 3D, so I could adjust the boundary conditions to make the 2D essentially 1D. However, it would of course be nice to be able to solve a simple 1D problem as the one described in the .pdf first.
On Friday, June 21, 2024 at 12:11:32 AM UTC+2 Wolfgang Bangerth wrote:
> Since the equations I'm trying to solve are conservations laws, I would like
> to use a finite volume type of implementation. I know that deal.ii is a finite
> element library. However, since I would like to use a fully implicit approach
> and later hopefully octree refined grids, I think deal.ii offers the things
> needed for this task as well as many functionalities and interfaces for future
> tasks.
This is true, but before you get fully settled on FV methods, may I suggest
that you also think about the accuracy you get for the simplicity? If you use
piecewise constants (=finite volumes), the best you can hope for is O(h)
accuracy. That's quite inaccurate. By using finite element methods, you will
generally be able to obtain much better accuracy (not just in terms of the
convergence *rate*, but in *absolute errors*).
I agree, the discontinuous elements are very promising for this because ideally, I could (1) recover the desired finitevolume formulation for degree 0, (2) keep the conservativeness and (3) easily get better accuracy by using higher order elements.
> To start, I've summarized a simplified problem I would like to solve in the
> appended .pdf file. It's a 1D Laplace equation using finite volumes.
I think I understand what you want to do, but you may want to see if you can
make your writing more precise. For example, in (4), you say you integrate
over S, but you're missing the normal vector that in your case is either +1 or
-1, but is necessary to ensure that the formula is correct. You can see that
in the transition between (5) and (6) where a minus sign magically appears in
front of the first term. Of course, (5) and (6) are also not exactly equal,
but only approximately.
Second, in (6) there magically appears a factor of h^2 for which I don't have
an explanation.
(No need to write back to these comments -- I just wanted to point it out, the
teacher in me can't just let it go ;-) )
Thank you very much for the comments - helps me to be more precise.
Nick,
2)
When you use DG0, all of the terms in the weak from cancel to zero except for the face term penallty*jump(u)*jump(v). (du/dx and dv/dy are zero inside an element)
That penalty term in the DG community is seen as something that adds stability and isn't at the core of the scheme.
In FV after doing your Gauss integral you end up asking yourself "what is the value of the gradient at the face" and set that to be mu*(u2-u1)/h. You get to construct one based on the values on an element and it's neighbour
That's a shortcoming of FV in a way because if you want to construct anything of higher order you'll have to querry values form the neighbours of neighbours of neighbours... In 2d/3d FV and with unstructured grids, constructing this isn't easy.The second term in the DG weak form: the jump(u) *mu * average(gradv), is supposed to be exactly that, but it gets cancelled out when you use DG0. In DG grad(v) on a face is calculated based on data of the local cell, in FV grad(v) gets calculated based on data from the neighbouring cells. BTW, that term is what you get from integrating by parts.
Back to your question and if you insist on using DG0:
So to match the penalty*jump(u)*jump(v) with what you get from an FV scheme (mu*(u2-u1)/h) maybe you might try to set the penalty to be something like (mu/h) where h is the distance between the element centers. (That's not it tho)
1)That penalty term is there to enhance stability but I don't know if there is more to it. It penalizes the jump across the elements. See if going higher with a constant penalty helps with the accuracy.
Or maybe scale it with the element size.
There are other DG tutorials for the Poisson equation maybe they'll have something there for you too.
(Never liked that penalty term tbh either. All my homies hate the penalty parameter. JK).
AbbasOn Sunday, June 23, 2024 at 1:24:38 AM UTC+2 Wolfgang Bangerth wrote:
Nik:
> (1) trying to solve in 1D:
>
> * I get errors of the following type:
> *error: ‘class dealii::DoFAccessor<0, 1, 1, false>’ has no member
> named ‘measure’
> 411 | re() / cell->face(face_no)->measure();* / I can make it run
> by removing the calls to these functions and replace the penalty
> factor which would involve them by a constant number, which according
> to the output seems to work o.k. but might need further tuning of the
> penalty constant (here just chosen as a constant of 100)./
Yes, that's because the measure of a face in 1d is hard to define -- what is
the measure of a point in a zero-dimensional space?
If you have a good idea for how the 'extent1/2' variables should be defined in
1d, let us know and we can patch the program so that it will also work in 1d.