<div dir="ltr"><div dir="ltr">On Mon, May 22, 2023 at 4:41 AM Berend van Wachem <<a href="mailto:berend.vanwachem@ovgu.de">berend.vanwachem@ovgu.de</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Dear Matt,<br>
<br>
I'm really sorry for this stupid bug!<br></blockquote><div><br></div><div>No problem. You have really helped me get the bugs out of Plex.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I can confirm that setting the coordinates with both <br>
CellCoordinatesLocal and CoordinatesLocal works.<br>
<br>
Best regards, Berend.<br>
<br>
Many thanks and best regards, Berend.<br>
<br>
On 5/17/23 23:04, Matthew Knepley wrote:<br>
> On Wed, May 17, 2023 at 2:01 PM Berend van Wachem <br>
> <<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a>>> wrote:<br>
> <br>
> Dear Matt,<br>
> <br>
> I tried it, but it doesn't seem to work.<br>
> Attached is a very small working example illustrating the problem.<br>
> I create a DMPlexBox Mesh, periodic in the Y direction. I then scale<br>
> the Y coordinates with a factor 10, and add 1.0 to it. Both<br>
> DMGetCoordinatesLocal and DMGetCellCoordinatesLocal.<br>
> Then I evaluate the coordinates with DMPlexGetCellCoordinates. Most<br>
> of the Y coordinates are correct, but not all of them - for<br>
> instance, the minimum Y coordinate is 0.0, and this should be 1.0.<br>
> <br>
> Am I doing something wrong?<br>
> <br>
> <br>
> Quickly, I see that<br>
> <br>
> a *= 10.0 + 1.0;<br>
> <br>
> is the same as<br>
> <br>
> a *= 11.0;<br>
> <br>
> not multiply by 10 and add 1. I will send it back when I get everything <br>
> the way I want.<br>
> <br>
> Thanks,<br>
> <br>
> Matt<br>
> <br>
> Thanks and best regards,<br>
> <br>
> Berend.<br>
> <br>
> On 5/17/23 17:58, Matthew Knepley wrote:<br>
> > On Wed, May 17, 2023 at 11:20 AM Berend van Wachem<br>
> <<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a>><br>
> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a>>>><br>
> wrote:<br>
> ><br>
> > Dear Matt,<br>
> ><br>
> > Is there a way to 'redo' the DMLocalizeCoordinates() ? Or to<br>
> undo it?<br>
> > Alternatively, can we make the calling of<br>
> DMLocalizeCoordinates() in the DMPlexCreate...() routines optional?<br>
> ><br>
> > Otherwise, we would have to copy all arrays of coordinates<br>
> from DMGetCoordinatesLocal() and DMGetCellCoordinatesLocal() before<br>
> > scaling them.<br>
> ><br>
> ><br>
> > I am likely not being clear. I think all you have to do is the<br>
> following:<br>
> ><br>
> > DMGetCoordinatesLocal(dm, &xl);<br>
> > VecScale(xl, scale);<br>
> > DMSetCoordinatesLocal(dm, xl);<br>
> > DMGetCellCoordinatesLocal(dm, &xl);<br>
> > VecScale(xl, scale);<br>
> > DMSetCellCoordinatesLocal(dm, xl);<br>
> ><br>
> > Does this not work?<br>
> ><br>
> > Thanks,<br>
> ><br>
> > Matt<br>
> ><br>
> > Best regards, Berend.<br>
> ><br>
> > On 5/17/23 16:35, Matthew Knepley wrote:<br>
> > > On Wed, May 17, 2023 at 10:21 AM Berend van Wachem<br>
> <<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a>><br>
> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a>>><br>
> > <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a><br>
> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a>> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a><br>
> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a>>>>> wrote:<br>
> > ><br>
> > > Dear Matt,<br>
> > ><br>
> > > Thanks for getting back to me so quickly.<br>
> > ><br>
> > > If I scale each of the coordinates of the mesh (say, I<br>
> want to cube each<br>
> > > co-ordinate), and I do this for both:<br>
> > ><br>
> > > DMGetCoordinatesLocal();<br>
> > > DMGetCellCoordinatesLocal();<br>
> > ><br>
> > > How do I know I am not cubing one coordinate multiple<br>
> times?<br>
> > ><br>
> > ><br>
> > > Good question. Right now, the only connection between the<br>
> two sets of coordinates is DMLocalizeCoordinates(). Since<br>
> > sometimes<br>
> > > people want to do non-trivial things to<br>
> > > coordinates, I prefer not to push in an API for "just"<br>
> scaling, but I could be convinced<br>
> > > the other way.<br>
> > ><br>
> > > Thanks,<br>
> > ><br>
> > > Matt<br>
> > ><br>
> > > Thanks, Berend.<br>
> > ><br>
> > > On 5/17/23 16:10, Matthew Knepley wrote:<br>
> > > > On Wed, May 17, 2023 at 10:02 AM Berend van Wachem<br>
> > > > <<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a><br>
> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a>> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a><br>
> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a>>> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a><br>
> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a>><br>
> > <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a><br>
> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a>>>> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a><br>
> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a>> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a><br>
> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a>>><br>
> > > <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a><br>
> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a>> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a><br>
> <mailto:<a href="mailto:berend.vanwachem@ovgu.de" target="_blank">berend.vanwachem@ovgu.de</a>>>>>> wrote:<br>
> > > ><br>
> > > > Dear PETSc Team,<br>
> > > ><br>
> > > > We are using DMPlex, and we create a mesh using<br>
> > > ><br>
> > > > DMPlexCreateBoxMesh (.... );<br>
> > > ><br>
> > > > and get a uniform mesh. The mesh is periodic.<br>
> > > ><br>
> > > > We typically want to "scale" the coordinates<br>
> (vertices) of the mesh,<br>
> > > > and<br>
> > > > to achieve this, we call<br>
> > > ><br>
> > > > DMGetCoordinatesLocal(dm, &coordinates);<br>
> > > ><br>
> > > > and scale the entries in the Vector coordinates<br>
> appropriately.<br>
> > > ><br>
> > > > and then<br>
> > > ><br>
> > > > DMSetCoordinatesLocal(dm, coordinates);<br>
> > > ><br>
> > > ><br>
> > > > After this, we localise the coordinates by calling<br>
> > > ><br>
> > > > DMLocalizeCoordinates(dm);<br>
> > > ><br>
> > > > This worked fine up to PETSc 3.18, but with<br>
> versions after this, the<br>
> > > > coordinates we get from the call<br>
> > > ><br>
> > > > DMPlexGetCellCoordinates(dm, CellID, &isDG,<br>
> &CoordSize,<br>
> > > > &ArrayCoordinates, &Coordinates);<br>
> > > ><br>
> > > > are no longer correct if the mesh is periodic.<br>
> A number of the<br>
> > > > coordinates returned from calling<br>
> DMPlexGetCellCoordinates are wrong.<br>
> > > ><br>
> > > > I think, this is because DMLocalizeCoordinates<br>
> is now automatically<br>
> > > > called within the routine DMPlexCreateBoxMesh.<br>
> > > ><br>
> > > > So, my question is: How should we scale the<br>
> coordinates from a periodic<br>
> > > > DMPlex mesh so that they are reflected<br>
> correctly when calling both<br>
> > > > DMGetCoordinatesLocal and<br>
> DMPlexGetCellCoordinates, with PETSc versions<br>
> > > > >= 3.18?<br>
> > > ><br>
> > > ><br>
> > > > I think we might have to add an API function. For<br>
> now, when you scale<br>
> > > > the coordinates,<br>
> > > > can you scale both copies?<br>
> > > ><br>
> > > > DMGetCoordinatesLocal()<br>
> > > > DMGetCellCoordinatesLocal();<br>
> > > ><br>
> > > > and then set them back.<br>
> > > ><br>
> > > > Thanks,<br>
> > > ><br>
> > > > Matt<br>
> > > ><br>
> > > > Many thanks, Berend.<br>
> > > ><br>
> > > > --<br>
> > > > What most experimenters take for granted before<br>
> they begin their<br>
> > > > experiments is infinitely more interesting than any<br>
> results to which<br>
> > > > their experiments lead.<br>
> > > > -- Norbert Wiener<br>
> > > ><br>
> > > > <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
> <<a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a>><br>
> <<a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
> <<a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a>>><br>
> > <<a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
> <<a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a>><br>
> <<a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
> <<a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a>>>><br>
> <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a><br>
> <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a>><br>
> > <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a><br>
> <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a>>><br>
> > > <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a><br>
> <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a>><br>
> <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a><br>
> <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a>>>>><br>
> > ><br>
> > ><br>
> > ><br>
> > > --<br>
> > > What most experimenters take for granted before they begin<br>
> their experiments is infinitely more interesting than any<br>
> > results to<br>
> > > which their experiments lead.<br>
> > > -- Norbert Wiener<br>
> > ><br>
> > > <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
> <<a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a>><br>
> <<a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
> <<a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a>>><br>
> <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a><br>
> <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a>><br>
> > <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a><br>
> <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a>>>><br>
> ><br>
> ><br>
> ><br>
> > --<br>
> > What most experimenters take for granted before they begin their<br>
> experiments is infinitely more interesting than any results to<br>
> > which their experiments lead.<br>
> > -- Norbert Wiener<br>
> ><br>
> > <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
> <<a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a>><br>
> <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a><br>
> <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a>>><br>
> <br>
> <br>
> <br>
> -- <br>
> What most experimenters take for granted before they begin their <br>
> experiments is infinitely more interesting than any results to which <br>
> their experiments lead.<br>
> -- Norbert Wiener<br>
> <br>
> <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a> <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a>><br>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>