@@ -1966,14 +1966,15 @@ def _renumber_entities(self, reorder):
1966
1966
if reorder :
1967
1967
swarm = self .topology_dm
1968
1968
parent = self ._parent_mesh .topology_dm
1969
- swarm_parent_cell_nums = swarm .getField ("DMSwarm_cellid" ).ravel ()
1969
+ cell_id_name = swarm .getCellDMActive ().getCellID ()
1970
+ swarm_parent_cell_nums = swarm .getField (cell_id_name ).ravel ()
1970
1971
parent_renum = self ._parent_mesh ._dm_renumbering .getIndices ()
1971
1972
pStart , _ = parent .getChart ()
1972
1973
parent_renum_inv = np .empty_like (parent_renum )
1973
1974
parent_renum_inv [parent_renum - pStart ] = np .arange (len (parent_renum ))
1974
1975
# Use kind = 'stable' to make the ordering deterministic.
1975
1976
perm = np .argsort (parent_renum_inv [swarm_parent_cell_nums - pStart ], kind = 'stable' ).astype (IntType )
1976
- swarm .restoreField ("DMSwarm_cellid" )
1977
+ swarm .restoreField (cell_id_name )
1977
1978
perm_is = PETSc .IS ().create (comm = swarm .comm )
1978
1979
perm_is .setType ("general" )
1979
1980
perm_is .setIndices (perm )
@@ -3557,11 +3558,9 @@ def _pic_swarm_in_mesh(
3557
3558
#. ``parentcellextrusionheight`` which contains the extrusion height of
3558
3559
the immersed vertex in the parent mesh cell.
3559
3560
3560
- Another three are required for proper functioning of the DMSwarm:
3561
+ Another two are required for proper functioning of the DMSwarm:
3561
3562
3562
3563
#. ``DMSwarmPIC_coor`` which contains the coordinates of the point.
3563
- #. ``DMSwarm_cellid`` the DMPlex cell within which the DMSwarm point is
3564
- located.
3565
3564
#. ``DMSwarm_rank``: the MPI rank which owns the DMSwarm point.
3566
3565
3567
3566
.. note::
@@ -3794,7 +3793,6 @@ def _dmswarm_create(
3794
3793
# These are created by default for a PIC DMSwarm
3795
3794
default_fields = [
3796
3795
("DMSwarmPIC_coor" , gdim , RealType ),
3797
- ("DMSwarm_cellid" , 1 , IntType ),
3798
3796
("DMSwarm_rank" , 1 , IntType ),
3799
3797
]
3800
3798
@@ -3853,12 +3851,6 @@ def _dmswarm_create(
3853
3851
# Set to Particle In Cell (PIC) type
3854
3852
if not isinstance (plex , PETSc .DMSwarm ):
3855
3853
swarm .setType (PETSc .DMSwarm .Type .PIC )
3856
- else :
3857
- # This doesn't work where we embed a DMSwarm in a DMSwarm, instead
3858
- # we register some default fields manually
3859
- for name , size , dtype in default_fields :
3860
- if name == "DMSwarmPIC_coor" or name == "DMSwarm_cellid" :
3861
- swarm .registerField (name , size , dtype = dtype )
3862
3854
3863
3855
# Register any fields
3864
3856
for name , size , dtype in swarm .default_extra_fields + swarm .other_fields :
@@ -3872,14 +3864,15 @@ def _dmswarm_create(
3872
3864
# Add point coordinates. This amounts to our own implementation of
3873
3865
# DMSwarmSetPointCoordinates because Firedrake's mesh coordinate model
3874
3866
# doesn't always exactly coincide with that of DMPlex: in most cases the
3875
- # plex_parent_cell_nums (DMSwarm_cellid field) and parent_cell_nums
3876
- # (parentcellnum field), the latter being the numbering used by firedrake,
3877
- # refer fundamentally to the same cells. For extruded meshes the DMPlex
3878
- # dimension is based on the topological dimension of the base mesh.
3867
+ # plex_parent_cell_nums and parent_cell_nums (parentcellnum field), the
3868
+ # latter being the numbering used by firedrake, refer fundamentally to the
3869
+ # same cells. For extruded meshes the DMPlex dimension is based on the
3870
+ # topological dimension of the base mesh.
3879
3871
3880
3872
# NOTE ensure that swarm.restoreField is called for each field too!
3881
3873
swarm_coords = swarm .getField ("DMSwarmPIC_coor" ).reshape ((num_vertices , gdim ))
3882
- swarm_parent_cell_nums = swarm .getField ("DMSwarm_cellid" ).ravel ()
3874
+ cell_id_name = swarm .getCellDMActive ().getCellID ()
3875
+ swarm_parent_cell_nums = swarm .getField (cell_id_name ).ravel ()
3883
3876
field_parent_cell_nums = swarm .getField ("parentcellnum" ).ravel ()
3884
3877
field_reference_coords = swarm .getField ("refcoord" ).reshape ((num_vertices , tdim ))
3885
3878
field_global_index = swarm .getField ("globalindex" ).ravel ()
@@ -3903,7 +3896,7 @@ def _dmswarm_create(
3903
3896
swarm .restoreField ("refcoord" )
3904
3897
swarm .restoreField ("parentcellnum" )
3905
3898
swarm .restoreField ("DMSwarmPIC_coor" )
3906
- swarm .restoreField ("DMSwarm_cellid" )
3899
+ swarm .restoreField (cell_id_name )
3907
3900
3908
3901
if extruded :
3909
3902
field_base_parent_cell_nums = swarm .getField ("parentcellbasenum" ).ravel ()
0 commit comments