Dear Drake -- Suppose I generate a mesh and FunctionSpace this way (or any other way): mesh = UnitSquareMesh(2,1) W = FunctionSpace(mesh, 'Lagrange', 1) Is there a programmatic and/or option way to view the underlying DMPlex? Actually, where is the underlying DMPlex? When I look at W.dm it is of type DMShell. W.dm.view() gives an output including VecView on the solution, but no real info on the mesh. An example of what I have in mind is the output from DMViewFromOptions(). (Is it somewhere in Firedrake/petsc4py?) For a certain 3-triangle mesh (i.e. not the mesh from UnitSquareMesh() above) the output of DMViewFromOptions() is: DM Object: tiny mesh 1 MPI processes type: plex tiny mesh in 2 dimensions: 0-cells: 5 1-cells: 7 2-cells: 3 Labels: depth: 3 strata with value/size (0 (5), 1 (7), 2 (3)) So I know I have 3 cells with 7 edges and 5 vertices, and the multi-process view tells me about the partition. Thanks! I don't want to write my own viewer in Python until I have no choice. ;-) Ed -- Ed Bueler Dept of Math and Stat and Geophysical Institute University of Alaska Fairbanks Fairbanks, AK 99775-6660 301C Chapman
The DM is the one you found. The rest of this is more a PETSc4py question than a Firedrake question and I have to say that I’m not the PETSc4py expert. However I note that the DM you get from the FunctionSpace has a viewFromOptions method. I think that’s what you’re after. This is a general PETSc4py pattern, by the way. PETSc is written in plain c using an object oriented paradigm where the type is prepended to the function name and the object is passed as the first argument. Since Python has built in object oriented features, these functions become methods in PETSc4py, without the type prefix and without explicitly passing the object. Regrettably, PETSC4py is sparsely documented, so often you have to “just know” the conventions for turning the C interface into the Python one. Regards, David From: <firedrake-bounces@imperial.ac.uk> on behalf of Ed Bueler <elbueler@alaska.edu> Reply-To: firedrake <firedrake@imperial.ac.uk> Date: Thursday, 26 July 2018 at 01:37 To: firedrake <firedrake@imperial.ac.uk> Subject: [firedrake] view of underlying DMPlex? Dear Drake -- Suppose I generate a mesh and FunctionSpace this way (or any other way): mesh = UnitSquareMesh(2,1) W = FunctionSpace(mesh, 'Lagrange', 1) Is there a programmatic and/or option way to view the underlying DMPlex? Actually, where is the underlying DMPlex? When I look at W.dm it is of type DMShell. W.dm.view() gives an output including VecView on the solution, but no real info on the mesh. An example of what I have in mind is the output from DMViewFromOptions(). (Is it somewhere in Firedrake/petsc4py?) For a certain 3-triangle mesh (i.e. not the mesh from UnitSquareMesh() above) the output of DMViewFromOptions() is: DM Object: tiny mesh 1 MPI processes type: plex tiny mesh in 2 dimensions: 0-cells: 5 1-cells: 7 2-cells: 3 Labels: depth: 3 strata with value/size (0 (5), 1 (7), 2 (3)) So I know I have 3 cells with 7 edges and 5 vertices, and the multi-process view tells me about the partition. Thanks! I don't want to write my own viewer in Python until I have no choice. ;-) Ed -- Ed Bueler Dept of Math and Stat and Geophysical Institute University of Alaska Fairbanks Fairbanks, AK 99775-6660 301C Chapman
Hi Ed, On 26/07/18 09:24, Ham, David A wrote:
The DM is the one you found. The rest of this is more a PETSc4py question than a Firedrake question and I have to say that I’m not the PETSc4py expert. However I note that the DM you get from the FunctionSpace has a viewFromOptions method. I think that’s what you’re after.
As well as what David says here, you can also get at the DMPlex object. A little explanation. The DM attached to every FunctionSpace (W.dm in your code) is a DMShell that describes the dof layout (as well as having a global vector, it also has a default section (W.dm.getDefaultSection()). It also has the relevant callback hooks attached to it to do fieldsplitting, as well as coarsen/refine (if you built with a MeshHierarchy). As well as this DMShell, there is also a DMPlex hanging around, that describes the mesh topology. But this is attached to the mesh object you made, rather than the FunctionSpace. You can get at it via mesh._plex: So: from firedrake import * mesh = UnitSquareMesh(...) V = FunctionSpace(mesh, "Lagrange", 2) V.dm.view() # DMShell describing dof layout topology = mesh._plex # or topology = V.ufl_domain()._plex topology.view() # DMPlex describing topology Thanks, Lawrence
participants (3)
- 
                
                Ed Bueler
- 
                
                Ham, David A
- 
                
                Lawrence Mitchell