Submodules module

class*, native_transfers=None, use_averaging=True)[source]

Bases: object

An object for managing transfers between levels in a multigrid hierarchy (possibly via embedding in DG spaces).

  • native_transfers – dict mapping UFL element to “natively supported” transfer operators. This should be a three-tuple of (prolong, restrict, inject).

  • use_averaging – Use averaging to approximate the projection out of the embedded DG space? If False, a global L2 projection will be performed.

class Cache(element)[source]

Bases: object

A caching object for work vectors and matrices.


element – The element to use for the caching.


Inverse DG mass matrix :arg DG: the DG space :returns: A PETSc Mat.


A DG work Function matching V :arg V: a function space. :returns: A Function in the embedding DG space.

V_DG_mass(V, DG)[source]

Mass matrix from between V and DG spaces. :arg V: a function space :arg DG: the DG space :returns: A PETSc Mat mapping from V -> DG

V_approx_inv_mass(V, DG)[source]

Approximate inverse mass. Computes (cellwise) (V, V)^{-1} (V, DG). :arg V: a function space :arg DG: the DG space :returns: A PETSc Mat mapping from V -> DG.


Dof weights for averaging projection.


V – function space to compute weights for.


A PETSc Vec.


A KSP inverting a mass matrix :arg V: a function space. :returns: A PETSc KSP for inverting (V, V).

inject(uf, uc)[source]

Inject a function (primal restriction)

  • uc – The source (fine grid) function.

  • uf – The target (coarse grid) function.

op(source, target, transfer_op)[source]

Primal transfer (either prolongation or injection).

  • source – The source function.

  • target – The target function.

  • transfer_op – The transfer operation for the DG space.

prolong(uc, uf)[source]

Prolong a function.

  • uc – The source (coarse grid) function.

  • uf – The target (fine grid) function.

restrict(gf, gc)[source]

Restrict a dual function.

  • gf – The source (fine grid) dual function.

  • gc – The target (coarse grid) dual function.


A work Vec for V :arg V: a function space. :returns: A PETSc Vec for V. module, fine)[source], coarse_dual)[source], coarse)[source] module

class, num_entities)[source]

Bases: tsfc.kernel_interface.firedrake.KernelBuilderBase

Kernel builder for integration on a macro-cell.


num_entities – the number of micro-entities to integrate over.

oriented = False

Prepare the coordinate field.


domainufl.Domain, dual_space=None, parameters=None, name='evaluate')[source]

Generate code for point evaluations.

  • expression – A UFL expression (may contain up to one coefficient, or one argument)

  • dual_space – if the expression has an argument, should we also distribute residual data?


Some coffee AST, Vc, ncell)[source], Vc)[source][source], Vc)[source], parameters=None)[source] module

class, coarse_to_fine_cells, fine_to_coarse_cells, refinements_per_level=1, nested=False)[source]

Bases: object

Create an encapsulation of an hierarchy of meshes.

  • meshes – list of meshes (coarse to fine)

  • coarse_to_fine_cells – list of numpy arrays for each level pair, mapping each coarse cell into fine cells it intersects.

  • fine_to_coarse_cells – list of numpy arrays for each level pair, mapping each fine cell into coarse cells it intersects.

  • refinements_per_level – number of mesh refinements each multigrid level should “see”.

  • nested – Is this mesh hierarchy nested?


Most of the time, you do not need to create this object yourself, instead using MeshHierarchy(), ExtrudedMeshHierarchy(), or NonNestedHierarchy().

comm[source], refinement_levels, refinements_per_level=1, reorder=None, distribution_parameters=None, callbacks=None, mesh_builder=<function Mesh>)[source]

Build a hierarchy of meshes by uniformly refining a coarse mesh.

  • mesh – the coarse Mesh() to refine

  • refinement_levels – the number of levels of refinement

  • refinements_per_level – the number of refinements for each level in the hierarchy.

  • distribution_parameters – options controlling mesh distribution, see Mesh() for details. If None, use the same distribution parameters as were used to distribute the coarse mesh, otherwise, these options override the default.

  • reorder – optional flag indicating whether to reorder the refined meshes.

  • callbacks – A 2-tuple of callbacks to call before and after refinement of the DM. The before callback receives the DM to be refined (and the current level), the after callback receives the refined DM (and the current level).

  • mesh_builder – Function to turn a DM into a Mesh. Used by pyadjoint., height, base_layer=-1, refinement_ratio=2, layers=None, kernel=None, extrusion_type='uniform', gdim=None, mesh_builder=<function ExtrudedMesh>)[source]

Build a hierarchy of extruded meshes by extruding a hierarchy of meshes.

  • base_hierarchy – the unextruded base mesh hierarchy to extrude.

  • height – the height of the domain to extrude to. This is in contrast to the extrusion routines, which take in layer_height, the height of an individual layer. This is because when refining in the extruded dimension, the height of an individual layer will vary.

  • base_layer – the number of layers to use the extrusion of the coarsest grid.

  • refinement_ratio – the ratio by which base_layer should be increased on every refinement. refinement_ratio = 2 means standard uniform refinement. refinement_ratio = 1 means to not refine in the extruded dimension, i.e. the multigrid hierarchy will use semicoarsening.

  • layers – as an alternative to specifying base_layer and refinement_ratio, one may specify directly the number of layers to be used by each level in the extruded hierarchy. This option cannot be combined with base_layer and refinement_ratio. Note that the ratio of successive entries in this iterable must be an integer for the multigrid transfer operators to work.

  • mesh_builder – function used to turn a Mesh into an extruded mesh. Used by pyadjoint.

See ExtrudedMesh() for the meaning of the remaining parameters.*meshes)[source] module, element_size, levels, comm=<mpi4py.MPI.Intracomm object>, distribution_parameters=None, callbacks=None, order=1, mh_constructor=<function MeshHierarchy>, cache=True, verbose=True, gmsh='gmsh', project_refinements_to_cad=True, reorder=None)[source] module, self, coefficient_mapping=None)[source] module, Vf)[source], Vf)[source], Vc)[source][source]

Try and obtain hierarchy and level info from an object.

If no level info is available, return None, None.[source]

Does the provided object have level info?[source], hierarchy, level)[source]

Attach hierarchy and level info to an object.

Module contents