Using different random seed when distorting a triangulation

41 views
Skip to first unread message

David F

unread,
May 25, 2020, 11:20:57 PM5/25/20
to deal.II User Group
Hello everyone.

I would like to apply many random distortions to a triangulation. However, the function GridTools::distort_random seems to produce always the same distortion. Is there a way to use different seeds in order to generate always different distortions? It seems that it's not possible through the interface of GridTools::distort_random but I wonder if there is another way to do it, since this seems to me a very basic feature for the users of this function.


Best,
David.

Wolfgang Bangerth

unread,
May 25, 2020, 11:40:57 PM5/25/20
to dea...@googlegroups.com
Interesting question!

The function doesn't currently allow that, it uses the same sequence of random
numbers every time -- by design: This way, if you run your program twice in a
row, it'll produce the same result.

But it wouldn't be very difficult to change that. The function is here:
https://github.com/dealii/dealii/blob/master/source/grid/grid_tools.cc#L1013-L1244
The random number generator is initialized in line 1099. It wouldn't be very
difficult to add an argument to the function that acts as a random seed and is
used in that line to seed the boost::random::mt19937 generator. Want to give
this a try and implement such a change? We'd of course be very happy to take a
patch!

Best
Wolfgang


--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

David F

unread,
May 28, 2020, 6:42:08 PM5/28/20
to deal.II User Group
Yes, it seems indeed easy. I'll try to learn how to send it through the official channel in github.

David

unread,
Oct 5, 2020, 8:24:15 AM10/5/20
to deal.II User Group
Hello, I'm trying to send a pull request with this functionality but there's an error with the format of the code that I don't understand (this is my first pull request).


I don't know how to fix this problem, because it complains about a format error which seems to actually not be there in my code and only shows up in the check. I'd appreciate it if you could tell me the reason for this problem.

David.

Wolfgang Bangerth

unread,
Oct 5, 2020, 11:11:08 AM10/5/20
to dea...@googlegroups.com
On 10/5/20 6:24 AM, David wrote:
> Hello, I'm trying to send a pull request with this functionality but there's
> an error with the format of the code that I don't understand (this is my first
> pull request).
>
> The error is
> here:https://github.com/dealii/dealii/pull/11003/checks?check_run_id=1208978286 <https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdealii%2Fdealii%2Fpull%2F11003%2Fchecks%3Fcheck_run_id%3D1208978286&data=02%7C01%7CWolfgang.Bangerth%40colostate.edu%7C486e88f53b01420a93dc08d8692994c8%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637374974612507572&sdata=1PQR1I1l0fCiNloF70x5%2FBjBXVddxilhFP%2Bq5ZoiXFw%3D&reserved=0>
>
> I don't know how to fix this problem, because it complains about a format
> error which seems to actually not be there in my code and only shows up in the
> check. I'd appreciate it if you could tell me the reason for this problem.

deal.II uses an indentation script that ensures that everything is formatted
the same way. The error you link to above shows that the patch you submitted
doesn't follow the indentation style this script asks for. You can either
change the indentation by hand, or run
make indent
in your build directory. You may get an error that you don't have the
indentation tool installed, but the error message also tells you how to get it.

Best
W.
Reply all
Reply to author
Forward
0 new messages