<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><br>
</p>
<br>
<div class="moz-cite-prefix">On 02.09.2018 05:01, 段俊明 wrote:<br>
</div>
<blockquote type="cite"
cite="mid:13540ba6.7175.165983a7251.Coremail.duanjm@pku.edu.cn">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<p style="font-size:14px;white-space:normal;"> Dear Christian,
</p>
<p style="font-size:14px;white-space:normal;"> <br>
</p>
<p style="font-size:14px;white-space:normal;"> Thanks, I am glad
to recieve your reply!
</p>
<p style="font-size:14px;white-space:normal;"> <br>
</p>
<p style="font-size:14px;white-space:normal;"> I am going to
realize a ALE (Arbitrary Lagrangian Eulerian) finite volume
method for conservation laws,
</p>
<p style="font-size:14px;white-space:normal;"> e.g. Euler
equations, and in ALE method the motion of the grid is
arbitrary.
</p>
<p style="font-size:14px;white-space:normal;"> In the beginning of
a time step t^n, the solution U and the mesh TR are known.
</p>
<p style="font-size:14px;white-space:normal;"> 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.,
</p>
<p style="font-size:14px;white-space:normal;"> x(t) = x(t^n) +
(x_new-x(t^n))*(t-t^n)/dt,
</p>
<p style="font-size:14px;white-space:normal;"> where x(t^n) is the
initial position, x_new the new position of x(t^n), dt the time
step.
</p>
<p style="font-size:14px;white-space:normal;"> 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
</p>
<p style="font-size:14px;white-space:normal;"> in a space-time
control volume. Finally, the solution and the mesh are both
updated.
</p>
<p style="font-size:14px;white-space:normal;"> <br>
</p>
<p style="font-size:14px;white-space:normal;"> I have several
difficulties now.
</p>
<p style="font-size:14px;white-space:normal;"> 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
</p>
<p style="font-size:14px;white-space:normal;"> 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?
</p>
<p style="font-size:14px;white-space:normal;"> The answer in
FAQ tells me that I can use a vector to save the "EntitySeeds",
so I write the following code,
</p>
<p style="font-size:14px;white-space:normal;"> 20 typedef
Dune::OneDGrid GridType;<br>
22 typedef typename GridType :: LeafGridView GridView;<br>
23 typedef typename GridView::template
Codim<0>::Iterator ElementLeafIterator;<br>
25 int Nx(10);<br>
26 GridType grid(Nx, 0, 1);<br>
27 GridView leafView = grid.leafGridView();<br>
28 std::vector<ElementLeafIterator::Entity>
ListElements(Nx);<br>
30 <br>
31 int count = 0;<br>
32 for(auto && it : elements(leafView)) {<br>
33 ListElements[count] = it;<br>
34 count++;
<br>
35 }
</p>
<div> Are the elements in the vector <span
style="font-size:14px;white-space:normal;">ListElements in the
sequence from left to right (from x=0 to x=1)? </span>
</div>
<p> <br>
</p>
<p style="font-size:14px;white-space:normal;"> <br>
</p>
<p style="font-size:14px;white-space:normal;"> 2. As I described
above, how can I move vertices in the grid to a new position if
I know their velocities?
</p>
<p style="font-size:14px;white-space:normal;"> 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,
</p>
<p style="font-size:14px;white-space:normal;"> but I don't
find any functions to do that. Could you give me more details?
</p>
</blockquote>
<br>
Hi Junming Duan,<br>
<br>
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.
<a class="moz-txt-link-freetext" href="https://gitlab.dune-project.org/core/dune-grid/blob/master/dune/grid/uggrid.hh">https://gitlab.dune-project.org/core/dune-grid/blob/master/dune/grid/uggrid.hh</a>
), called <br>
<br>
void setPosition(const typename Traits::template
Codim<dim>::Entity& e,<br>
const FieldVector<double, dim>&
pos);<br>
<br>
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.<br>
<br>
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<br>
<br>
using Grid = Dune::OneDGrid;<br>
using ElementSeed = Grid::template Codim<0>::EntitySeed;<br>
<br>
std::vector<EntitySeed>
elementSeeds(grid.leafGridView().size(0));<br>
Dune::MultipleCodimMultipleGeomTypeMapper<Grid::LeafGridView>
elementMapper(grid.leafGridView(), Dune::mcmgElementLayout());<br>
<br>
for (const auto& element : elements(grid.leafGridView())<br>
elementSeeds[elementMapper.index(element)] = element.seed();<br>
<br>
from an element seed you can reconstruct the entity via the grid
interface (const auto element = grid.entity(elementSeed);).<br>
For your example, you could also sort the elements by coordinate
first to determine the i+1, i+2, index mapping..<br>
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?<br>
<br>
You can also find neighbors of element by iterating over the
intersections of an element (codim 0 entity)<br>
<br>
for (const auto& intersection : intersections(gridView,
element))<br>
if (intersection.neighbor)<br>
const auto outsideElement = intersection.outside();<br>
<br>
And neighbors of neighbors by iterating over the intersections of
outsideElement.<br>
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.<br>
<br>
If all of that is efficient depends on your application.<br>
<br>
Hope this helps a bit<br>
Timo<br>
<br>
<blockquote type="cite"
cite="mid:13540ba6.7175.165983a7251.Coremail.duanjm@pku.edu.cn">
<p style="font-size:14px;white-space:normal;"> <br>
</p>
<p style="font-size:14px;white-space:normal;"> Thank you again!
</p>
<br>
<br>
<span>--
<div> Best Regards,
<div> Junming Duan </div>
</div>
</span>
<blockquote name="replyContent" class="ReferenceQuote"
style="padding-left:5px;margin-left:5px;border-left:#b6b6b6 2px
solid;margin-right:0;"> -----原始邮件-----<br>
<b>发件人:</b><span id="rc_from">"Christian Engwer"
<a class="moz-txt-link-rfc2396E" href="mailto:christian.engwer@uni-muenster.de"><christian.engwer@uni-muenster.de></a></span><br>
<b>发送时间:</b><span id="rc_senttime">2018-08-30 20:03:27 (星期四)</span><br>
<b>收件人:</b> <a class="moz-txt-link-abbreviated" href="mailto:dune@lists.dune-project.org">dune@lists.dune-project.org</a>, "段俊明"
<a class="moz-txt-link-rfc2396E" href="mailto:duanjm@pku.edu.cn"><duanjm@pku.edu.cn></a><br>
<b>抄送:</b> <br>
<b>主题:</b> Re: [Dune] Can I move the grid in the mesh?<br>
<br>
Dear Junming Duan,<br>
<br>
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.<br>
<br>
A) DUNE offers a range of different good implementations. The
UG-grid implementation offers support for moving vertices
directly in the mesh.<br>
<br>
B) There is also the "geometrygrid", which is a meta grid,
allowing to replace the geometry information of an existing DUNE
grid.<br>
<br>
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.<br>
<br>
Feel free to ask further details. To decide which option is
best, it would be nice to learn more about your application.<br>
<br>
Best Christian<br>
<br>
<div class="gmail_quote"> Am 30. August 2018 13:23:13 MESZ
schrieb "段俊明" <a class="moz-txt-link-rfc2396E" href="mailto:duanjm@pku.edu.cn"><duanjm@pku.edu.cn></a>:
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt
0.8ex;border-left:1px solid #CCCCCC;padding-left:1ex;">
<p> Dear developers of DUNE, </p>
<p> <br>
</p>
<p> I am interested in DUNE and want to do my research based
on DUNE. </p>
<p> 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? </p>
<p> I wish to control the position of each grid point varing
with the time. </p>
<br>
<span>--
<div> Best Regards,
<div> Junming Duan </div>
</div>
</span> </blockquote>
</div>
</blockquote>
<br>
<br>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Dune mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Dune@lists.dune-project.org">Dune@lists.dune-project.org</a>
<a class="moz-txt-link-freetext" href="https://lists.dune-project.org/mailman/listinfo/dune">https://lists.dune-project.org/mailman/listinfo/dune</a></pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
_______________________________________________________________
Timo Koch phone: +49 711 685 64676
IWS, Universität Stuttgart fax: +49 711 685 60430
Pfaffenwaldring 61 email: <a class="moz-txt-link-abbreviated" href="mailto:timo.koch@iws.uni-stuttgart.de">timo.koch@iws.uni-stuttgart.de</a>
D-70569 Stuttgart url: <a class="moz-txt-link-abbreviated" href="http://www.hydrosys.uni-stuttgart.de">www.hydrosys.uni-stuttgart.de</a>
_______________________________________________________________</pre>
</body>
</html>