@@ -32,62 +32,6 @@ def snes_ctx(self):
3232 """
3333 return VOID (self .solver_objs ['dmda' ], stars = '*' )
3434
35- def _setup (self ):
36- return ()
37-
38- def _extend_setup (self ):
39- """
40- Hook for subclasses to add additional setup calls.
41- """
42- return ()
43-
44- def _create_dmda_calls (self , dmda ):
45- dmda_create = self ._create_dmda (dmda )
46- dm_setup = petsc_call ('DMSetUp' , [dmda ])
47- dm_mat_type = petsc_call ('DMSetMatType' , [dmda , 'MATSHELL' ])
48- return dmda_create , dm_setup , dm_mat_type
49-
50- def _create_dmda (self , dmda ):
51- sobjs = self .solver_objs
52- grid = self .field_data .grid
53- nspace_dims = len (grid .dimensions )
54-
55- # MPI communicator
56- args = [sobjs ['comm' ]]
57-
58- # Type of ghost nodes
59- args .extend (['DM_BOUNDARY_GHOSTED' for _ in range (nspace_dims )])
60-
61- # Stencil type
62- if nspace_dims > 1 :
63- args .append ('DMDA_STENCIL_BOX' )
64-
65- # Global dimensions
66- args .extend (list (grid .shape )[::- 1 ])
67- # No.of processors in each dimension
68- if nspace_dims > 1 :
69- args .extend (list (grid .distributor .topology )[::- 1 ])
70-
71- # Number of degrees of freedom per node
72- args .append (dmda .dofs )
73- # "Stencil width" -> size of overlap
74- # TODO: Instead, this probably should be
75- # extracted from field_data.target._size_outhalo?
76- stencil_width = self .field_data .space_order
77-
78- args .append (stencil_width )
79- args .extend ([Null ]* nspace_dims )
80-
81- # The distributed array object
82- args .append (Byref (dmda ))
83-
84- # The PETSc call used to create the DMDA
85- dmda = petsc_call (f'DMDACreate{ nspace_dims } d' , args )
86-
87- return dmda
88-
89-
90- class Builder (BuilderBase ):
9135 def _setup (self ):
9236 sobjs = self .solver_objs
9337 dmda = sobjs ['dmda' ]
@@ -190,6 +134,57 @@ def _setup(self):
190134 extended_setup = self ._extend_setup ()
191135 return base_setup + extended_setup
192136
137+ def _extend_setup (self ):
138+ """
139+ Hook for subclasses to add additional setup calls.
140+ """
141+ return ()
142+
143+ def _create_dmda_calls (self , dmda ):
144+ dmda_create = self ._create_dmda (dmda )
145+ dm_setup = petsc_call ('DMSetUp' , [dmda ])
146+ dm_mat_type = petsc_call ('DMSetMatType' , [dmda , 'MATSHELL' ])
147+ return dmda_create , dm_setup , dm_mat_type
148+
149+ def _create_dmda (self , dmda ):
150+ sobjs = self .solver_objs
151+ grid = self .field_data .grid
152+ nspace_dims = len (grid .dimensions )
153+
154+ # MPI communicator
155+ args = [sobjs ['comm' ]]
156+
157+ # Type of ghost nodes
158+ args .extend (['DM_BOUNDARY_GHOSTED' for _ in range (nspace_dims )])
159+
160+ # Stencil type
161+ if nspace_dims > 1 :
162+ args .append ('DMDA_STENCIL_BOX' )
163+
164+ # Global dimensions
165+ args .extend (list (grid .shape )[::- 1 ])
166+ # No.of processors in each dimension
167+ if nspace_dims > 1 :
168+ args .extend (list (grid .distributor .topology )[::- 1 ])
169+
170+ # Number of degrees of freedom per node
171+ args .append (dmda .dofs )
172+ # "Stencil width" -> size of overlap
173+ # TODO: Instead, this probably should be
174+ # extracted from field_data.target._size_outhalo?
175+ stencil_width = self .field_data .space_order
176+
177+ args .append (stencil_width )
178+ args .extend ([Null ]* nspace_dims )
179+
180+ # The distributed array object
181+ args .append (Byref (dmda ))
182+
183+ # The PETSc call used to create the DMDA
184+ dmda = petsc_call (f'DMDACreate{ nspace_dims } d' , args )
185+
186+ return dmda
187+
193188
194189class CoupledBuilder (BuilderBase ):
195190 def _setup (self ):
0 commit comments