[Dune] Can I move the grid in the mesh?
Timo Koch
timo.koch at iws.uni-stuttgart.de
Sun Sep 2 17:41:53 CEST 2018
On 02.09.2018 05:01, 段俊明 wrote:
>
> Dear Christian,
>
>
> Thanks, I am glad to recieve your reply!
>
>
> I am going to realize a ALE (Arbitrary Lagrangian Eulerian) finite
> volume method for conservation laws,
>
> e.g. Euler equations, and in ALE method the motion of the grid is
> arbitrary.
>
> In the beginning of a time step t^n, the solution U and the mesh TR
> are known.
>
> I can use U and TR to find a new mesh, denoted by TR_new, then I
> suppose the mesh grid is a linear function of time, i.e.,
>
> x(t) = x(t^n) + (x_new-x(t^n))*(t-t^n)/dt,
>
> where x(t^n) is the initial position, x_new the new position of
> x(t^n), dt the time step.
>
> The speed of the grid (x_new-x(t^n))/dt is embedded in my
> equation, next, I can evolve U to the next time step
>
> in a space-time control volume. Finally, the solution and the mesh are
> both updated.
>
>
> I have several difficulties now.
>
> 1. In one-dimensional problem, I need to perform a fifth WENO
> reconstruction, i.e. I need to get a new polynomial in cell i
>
> from the information of cell i-2, i-1, i, i+1, i+2. How can I
> obtain the information from these five cells if the index i is given?
>
> The answer in FAQ tells me that I can use a vector to save the
> "EntitySeeds", so I write the following code,
>
> 20 typedef Dune::OneDGrid GridType;
> 22 typedef typename GridType :: LeafGridView GridView;
> 23 typedef typename GridView::template Codim<0>::Iterator
> ElementLeafIterator;
> 25 int Nx(10);
> 26 GridType grid(Nx, 0, 1);
> 27 GridView leafView = grid.leafGridView();
> 28 std::vector<ElementLeafIterator::Entity> ListElements(Nx);
> 30
> 31 int count = 0;
> 32 for(auto && it : elements(leafView)) {
> 33 ListElements[count] = it;
> 34 count++;
> 35 }
>
> Are the elements in the vector ListElements in the sequence from
> left to right (from x=0 to x=1)?
>
>
>
> 2. As I described above, how can I move vertices in the grid to a new
> position if I know their velocities?
>
> I cannot modify the information of the entities if I use above
> code. The last email tells me that I can use UG-grid implementation,
>
> but I don't find any functions to do that. Could you give me more
> details?
>
Hi Junming Duan,
to your second question: The grid managers dune-uggrid and dune-foamgrid
have member function in the grid interface to set the vertex position (
see e.g.
https://gitlab.dune-project.org/core/dune-grid/blob/master/dune/grid/uggrid.hh
), called
void setPosition(const typename Traits::template Codim<dim>::Entity& e,
const FieldVector<double, dim>& pos);
taking the Vertex Entity and the new position as arguments. So you just
call "grid.setPosition(vertex, newPos);". In case of adaptive grids this
changes the position of the vertex on all levels of the hierarchic grid.
To your first question, I'm not an expert on this but I think you don't
have a guarantee from the grid interface that the order of the elements
is from left to right (although for OneDGrid that is probably the case,
at least if you don't use local refinement). Also, there is no direct
way to obtain an entity with an index from the grid interface. This was
a deliberate design decision to make the grid interface more general. In
order to allow for index access, you can use EntitySeeds, but your code
maybe something like
using Grid = Dune::OneDGrid;
using ElementSeed = Grid::template Codim<0>::EntitySeed;
std::vector<EntitySeed> elementSeeds(grid.leafGridView().size(0));
Dune::MultipleCodimMultipleGeomTypeMapper<Grid::LeafGridView>
elementMapper(grid.leafGridView(), Dune::mcmgElementLayout());
for (const auto& element : elements(grid.leafGridView())
elementSeeds[elementMapper.index(element)] = element.seed();
from an element seed you can reconstruct the entity via the grid
interface (const auto element = grid.entity(elementSeed);).
For your example, you could also sort the elements by coordinate first
to determine the i+1, i+2, index mapping..
However, a good, more general solution depends on what your need are in
the future. Are you sure you can stick to OneDGrid? Is the OneDGrid
modeling the boundary of a two-dimensional domain?
You can also find neighbors of element by iterating over the
intersections of an element (codim 0 entity)
for (const auto& intersection : intersections(gridView, element))
if (intersection.neighbor)
const auto outsideElement = intersection.outside();
And neighbors of neighbors by iterating over the intersections of
outsideElement.
This way you could build up a local connectivity map using the element
index. With the index you can access the entity via the seed vector.
If all of that is efficient depends on your application.
Hope this helps a bit
Timo
>
> Thank you again!
>
>
>
> --
> Best Regards,
> Junming Duan
>
> -----原始邮件-----
> *发件人:*"Christian Engwer" <christian.engwer at uni-muenster.de>
> *发送时间:*2018-08-30 20:03:27 (星期四)
> *收件人:* dune at lists.dune-project.org, "段俊明" <duanjm at pku.edu.cn>
> *抄送:*
> *主题:* Re: [Dune] Can I move the grid in the mesh?
>
> Dear Junming Duan,
>
> in principal it is possible to achieve what you want to do.
> Actually there are different ways. Which one is better will depend
> on your particular setup.
>
> A) DUNE offers a range of different good implementations. The
> UG-grid implementation offers support for moving vertices directly
> in the mesh.
>
> B) There is also the "geometrygrid", which is a meta grid,
> allowing to replace the geometry information of an existing DUNE grid.
>
> C) As you can write your own discretion (i.e. the local operator),
> you can incorporate the transformation of the mesh into the model
> and use the deformation as model parameters to your bi-linear form.
>
> Feel free to ask further details. To decide which option is best,
> it would be nice to learn more about your application.
>
> Best Christian
>
> Am 30. August 2018 13:23:13 MESZ schrieb "段俊明"
> <duanjm at pku.edu.cn>:
>
> Dear developers of DUNE,
>
>
> I am interested in DUNE and want to do my research based on DUNE.
>
> Now I want to realize a moving mesh method by DUNE, so are
> there any functions in DUNE which allow me to change the
> position of the grid?
>
> I wish to control the position of each grid point varing with
> the time.
>
>
> --
> Best Regards,
> Junming Duan
>
>
>
>
>
>
> _______________________________________________
> Dune mailing list
> Dune at lists.dune-project.org
> https://lists.dune-project.org/mailman/listinfo/dune
--
_______________________________________________________________
Timo Koch phone: +49 711 685 64676
IWS, Universität Stuttgart fax: +49 711 685 60430
Pfaffenwaldring 61 email: timo.koch at iws.uni-stuttgart.de
D-70569 Stuttgart url: www.hydrosys.uni-stuttgart.de
_______________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20180902/c7919d4a/attachment.htm>
More information about the Dune
mailing list