Hi everyone, Some general questions about Firedrake: 1) I ran the poisson_mixed.py example and noticed in the Memory Usage section of -log_summary that there are more creations than destructions. In my experience, not properly destroying PETSc objects can inhibit performance. Is this an issue for you guys? As in, are you guys properly taking care of the memory allocation and related issues? 2) How do I read in an auxiliary data from a datafile? In FEniCS I could load data as a numpy array and use CellFunction() to "align" the data with the connectivity/ordering of the cells. 3) Is there any update regarding adding parallel IO? Last I spoke with Matt he said that he and one or two of you Firedrake folks (Michael Lange I think?) were working on this. 4) Do you guys support Hexahedron elements? When I look through the documentation for UnitCubeMesh and BoxMesh, I see no option for non-tetrahedron elements. Thanks, Justin
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 22/09/15 19:07, Justin Chang wrote:
Hi everyone,
Some general questions about Firedrake:
1) I ran the poisson_mixed.py example and noticed in the Memory Usage section of -log_summary that there are more creations than destructions. In my experience, not properly destroying PETSc objects can inhibit performance. Is this an issue for you guys? As in, are you guys properly taking care of the memory allocation and related issues?
I think we are, yes. At exit, we still have some objects live that have not been collected by the python garbage collector and therefore do not get destroyed before petsc's log summary prints. Effectively what happens is that the DM object (and the sections/SFs inside it) doesn't get destroyed before log_summary is printed. However, I think it's not a performance inhibiting problem.
2) How do I read in an auxiliary data from a datafile? In FEniCS I could load data as a numpy array and use CellFunction() to "align" the data with the connectivity/ordering of the cells.
This is still a messy aspect that we can't do well yet. A (slow) way to do this is to write a python expression and do the interpolation in numpy or similar: I assume you want to assign to a scalar function, if you want a vector-valued function, things are similar but you need to supply some more info (see the docstring of Expression for details: http://firedrakeproject.org/firedrake.html#firedrake.expression.Expression) import numpy as np class MyInit(Expression): def __init__(self): self.data = ... # load data from file into numpy array def eval(self, val, x): # x[0..d-1] are the d coordinate values (x, y, z) val[0] = ... # compute correct value from self.data based on x. init = MyInit() function = Function(V) function.interpolate(init) I think Miklos may have been thinking about (at least) better ways of doing this, but I don't know the details.
3) Is there any update regarding adding parallel IO? Last I spoke with Matt he said that he and one or two of you Firedrake folks (Michael Lange I think?) were working on this.
I'm not sure, maybe Michael can chip in. Cheers, Lawrence -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJWAnLkAAoJECOc1kQ8PEYvOYYH/3aKfeMmKLe8UtPdbSi9dGTY OJd4a8KdSf50lGEkhvXwslg2NBQc1gzdtX72Cq8AUM4csDhGb88Pi6voOeozqhmq NXzW9fcZi03XR6yD9+nTzMw5ie41YletZEqFrKaJ2ul7pYehlJ+GJjyBTyReKtfW /jQ/YJSFSzH4HRIPLyhpnoV5HCXMkWOWV3pQGWeYw4tD8gOHn5ZbcqFJHRES4/4K mJAv/n0VFPm9oLAZ5q6Q6JEfMbZSCqNgatgfjfbKDyv6Zgf0Q3SUdUoqiUN0FST9 nSnxdPovbi5eAqDX5EIJsIEQD6H/whCY/iNG7dpQgm/kzPpmY2fcOWjU4XUJb2I= =MsQk -----END PGP SIGNATURE-----
Lawrence, Thanks for the clarification. One more follow-up question. Yes I only want scalars (for now), and I am guessing that the data that will be loaded into numpy array has to correspond to the connectivity from mesh.cell_orientations? Also, what happens if I run this program in parallel? Will "function.interpolate(init)" first load the numpy array in serial, then distribute across all processes, or will it be interpolated after mesh distribution? Thanks, Justin On Wed, Sep 23, 2015 at 3:37 AM, Lawrence Mitchell < lawrence.mitchell@imperial.ac.uk> wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 22/09/15 19:07, Justin Chang wrote:
Hi everyone,
Some general questions about Firedrake:
1) I ran the poisson_mixed.py example and noticed in the Memory Usage section of -log_summary that there are more creations than destructions. In my experience, not properly destroying PETSc objects can inhibit performance. Is this an issue for you guys? As in, are you guys properly taking care of the memory allocation and related issues?
I think we are, yes. At exit, we still have some objects live that have not been collected by the python garbage collector and therefore do not get destroyed before petsc's log summary prints. Effectively what happens is that the DM object (and the sections/SFs inside it) doesn't get destroyed before log_summary is printed. However, I think it's not a performance inhibiting problem.
2) How do I read in an auxiliary data from a datafile? In FEniCS I could load data as a numpy array and use CellFunction() to "align" the data with the connectivity/ordering of the cells.
This is still a messy aspect that we can't do well yet. A (slow) way to do this is to write a python expression and do the interpolation in numpy or similar:
I assume you want to assign to a scalar function, if you want a vector-valued function, things are similar but you need to supply some more info (see the docstring of Expression for details: http://firedrakeproject.org/firedrake.html#firedrake.expression.Expression )
import numpy as np class MyInit(Expression): def __init__(self): self.data = ... # load data from file into numpy array
def eval(self, val, x): # x[0..d-1] are the d coordinate values (x, y, z) val[0] = ... # compute correct value from self.data based on x.
init = MyInit()
function = Function(V)
function.interpolate(init)
I think Miklos may have been thinking about (at least) better ways of doing this, but I don't know the details.
3) Is there any update regarding adding parallel IO? Last I spoke with Matt he said that he and one or two of you Firedrake folks (Michael Lange I think?) were working on this.
I'm not sure, maybe Michael can chip in.
Cheers,
Lawrence -----BEGIN PGP SIGNATURE----- Version: GnuPG v1
iQEcBAEBAgAGBQJWAnLkAAoJECOc1kQ8PEYvOYYH/3aKfeMmKLe8UtPdbSi9dGTY OJd4a8KdSf50lGEkhvXwslg2NBQc1gzdtX72Cq8AUM4csDhGb88Pi6voOeozqhmq NXzW9fcZi03XR6yD9+nTzMw5ie41YletZEqFrKaJ2ul7pYehlJ+GJjyBTyReKtfW /jQ/YJSFSzH4HRIPLyhpnoV5HCXMkWOWV3pQGWeYw4tD8gOHn5ZbcqFJHRES4/4K mJAv/n0VFPm9oLAZ5q6Q6JEfMbZSCqNgatgfjfbKDyv6Zgf0Q3SUdUoqiUN0FST9 nSnxdPovbi5eAqDX5EIJsIEQD6H/whCY/iNG7dpQgm/kzPpmY2fcOWjU4XUJb2I= =MsQk -----END PGP SIGNATURE-----
_______________________________________________ firedrake mailing list firedrake@imperial.ac.uk https://mailman.ic.ac.uk/mailman/listinfo/firedrake
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 24/09/15 20:53, Justin Chang wrote:
Lawrence,
Thanks for the clarification. One more follow-up question.
Yes I only want scalars (for now), and I am guessing that the data that will be loaded into numpy array has to correspond to the connectivity from mesh.cell_orientations?
Let's recall the class in question: import numpy as np class MyInit(Expression): def __init__(self): self.data = ... # load data from file into numpy array def eval(self, val, x): # x[0..d-1] are the d coordinate values (x, y, z) val[0] = ... # compute correct value from self.data based on x. No, so the idea is that when eval is called, x contains the coordinates values at the basis function node that you're currently interpolating onto. You then need to find the appropriate value (given this position) in the data array and set the node accordingly. BTW, mesh.cell_orientations is a red herring here. That's only necessary if you're solving problems on immersed manifolds. I think what you're asking is, "does the ordering of my input array have to match function space ordering". The answer is no, but you'll need to do some lookups as described above.
Also, what happens if I run this program in parallel? Will "function.interpolate(init)" first load the numpy array in serial, then distribute across all processes, or will it be interpolated after mesh distribution?
So the numpy data will be loaded redundantly on every process. But the interpolation will happen in parallel (i.e. each process will only interpolate its local section). Cheers, Lawrence -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJWCQMHAAoJECOc1kQ8PEYvsQIH/0J6rmOkbpswK5TT+OA2DPOk 20dYZsVMYKkQQ5CvsLmGPvMK0/Ba0s8L4SlH+UPauLk+trk8fvcALJu0xceVU/Dy 95GwNbnRgpQpC+14K0BY9HU2hMTKyMXbMP1/ObzfBkM3zE1KlsuBUxy7KvcBC+n6 zYxoA4TswyiLselnQTKeqR5GBS4DxfncusUk6TtQ5+udwjRFsHxxGWu6J3TvIH6+ W7uml6G69bAaPJUZtQTduv6RSBhoXWTOaRgeWBmlBhZsucZc/A2KWQKw3Bfvkhvq 3m1+26lTlom5glG/hr/GTXloocPtUPXSOkIBMo5G6xRxYdHXLGGB7NuazSIthkk= =N7UL -----END PGP SIGNATURE-----
Lawrence, Okay so if I understand this correctly, self.data need not follow the function space ordering. If it does not, then it is up to the user to interpolate/map the “natural ordered” self.data into function space ordering. This would be easy if I created my own .msh or .exo file and preprocessed the auxiliary data such that it follows the respective “natural ordering” of the mesh formats. Now, how are you guys doing the function space ordering for the built-in mesh generators (e.g., SquareMesh,BoxMesh, etc)? I am looking through the source code, and it seems the ordering will eventually be reordered for caching purposes. In that case, how do I print to file the final coordinates and connectivity of the mesh within Firedrake? Thanks, Justin
On Sep 28, 2015, at 3:06 AM, Lawrence Mitchell <lawrence.mitchell@imperial.ac.uk> wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 24/09/15 20:53, Justin Chang wrote:
Lawrence,
Thanks for the clarification. One more follow-up question.
Yes I only want scalars (for now), and I am guessing that the data that will be loaded into numpy array has to correspond to the connectivity from mesh.cell_orientations?
Let's recall the class in question:
import numpy as np class MyInit(Expression): def __init__(self): self.data = ... # load data from file into numpy array
def eval(self, val, x): # x[0..d-1] are the d coordinate values (x, y, z) val[0] = ... # compute correct value from self.data based on x.
No, so the idea is that when eval is called, x contains the coordinates values at the basis function node that you're currently interpolating onto. You then need to find the appropriate value (given this position) in the data array and set the node accordingly.
BTW, mesh.cell_orientations is a red herring here. That's only necessary if you're solving problems on immersed manifolds. I think what you're asking is, "does the ordering of my input array have to match function space ordering". The answer is no, but you'll need to do some lookups as described above.
Also, what happens if I run this program in parallel? Will "function.interpolate(init)" first load the numpy array in serial, then distribute across all processes, or will it be interpolated after mesh distribution?
So the numpy data will be loaded redundantly on every process. But the interpolation will happen in parallel (i.e. each process will only interpolate its local section).
Cheers,
Lawrence -----BEGIN PGP SIGNATURE----- Version: GnuPG v1
iQEcBAEBAgAGBQJWCQMHAAoJECOc1kQ8PEYvsQIH/0J6rmOkbpswK5TT+OA2DPOk 20dYZsVMYKkQQ5CvsLmGPvMK0/Ba0s8L4SlH+UPauLk+trk8fvcALJu0xceVU/Dy 95GwNbnRgpQpC+14K0BY9HU2hMTKyMXbMP1/ObzfBkM3zE1KlsuBUxy7KvcBC+n6 zYxoA4TswyiLselnQTKeqR5GBS4DxfncusUk6TtQ5+udwjRFsHxxGWu6J3TvIH6+ W7uml6G69bAaPJUZtQTduv6RSBhoXWTOaRgeWBmlBhZsucZc/A2KWQKw3Bfvkhvq 3m1+26lTlom5glG/hr/GTXloocPtUPXSOkIBMo5G6xRxYdHXLGGB7NuazSIthkk= =N7UL -----END PGP SIGNATURE-----
_______________________________________________ firedrake mailing list firedrake@imperial.ac.uk https://mailman.ic.ac.uk/mailman/listinfo/firedrake
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 29/09/15 08:31, Justin Chang wrote:
Lawrence,
Okay so if I understand this correctly, self.data need not follow the function space ordering. If it does not, then it is up to the user to interpolate/map the “natural ordered” self.data into function space ordering.
Exactly.
This would be easy if I created my own .msh or .exo file and preprocessed the auxiliary data such that it follows the respective “natural ordering” of the mesh formats. Now, how are you guys doing the function space ordering for the built-in mesh generators (e.g., SquareMesh,BoxMesh, etc)? I am looking through the source code, and it seems the ordering will eventually be reordered for caching purposes. In that case, how do I print to file the final coordinates and connectivity of the mesh within Firedrake?
If you build a mesh: You can print the (process-local) coordinate data with print mesh.coordinates.vector().array() You can get the map from cells to function space nodes with: print mesh.coordinates.cell_node_map().values These index the coordinate data above (on the local process) Similarly, if you have some different space, V. print V.cell_node_map().values gives you the map from cells to function space nodes. Cheers, Lawrence -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJWClUeAAoJECOc1kQ8PEYvSNgH/AtV3Wh47zsB42CrxFKg/2RE KDxbfOq444Z/XHdyT+sB2Hf+7gTRfcDLFyjnOJD26LGFVIjYyX+HAvO5omvbDL7d dwnYy5VDw8ezP7psdd4dZg/GJiBKZGPFhPkoYedmPriOPRVXRfZd2BaBThMGbea8 KmSC+KDedzs3VcscnZtcg5r9/7+bM7G6Nz11EGJgFCRBtgZSKbO+7BtmE2I5gxuA bZ6pgNGQfT8hv4IBN0UeC7TjvO3hmbLqSGLDpI4aun6Zl0AuE1sorK334f8vwOFy QG915XGaD2MVfzE8nsJEpH4q11T+HiTvhfT6xGZjkBcdw2SwPGLsun1WZOIo5EU= =CZHN -----END PGP SIGNATURE-----
participants (2)
-
Justin Chang
-
Lawrence Mitchell