cashocs.geometry.measure#

Extension of integration measures.

Functions

generate_measure(idx, measure)

Generates a measure based on indices.

Classes

Any(*args, **kwargs)

Special type indicating an unconstrained type.

NamedMeasure(*args, **kwargs)

A named integration measure, which can use strings for defining subdomains.

class cashocs.geometry.measure.NamedMeasure(*args, **kwargs)[source]#

Bases: Measure

A named integration measure, which can use strings for defining subdomains.

See base class.

Parameters:
  • integral_type (Literal['dx', 'ds', 'dS'])

  • domain (Optional[fenics.Mesh])

  • subdomain_id (str)

  • metadata (Optional[Dict])

  • subdomain_data (Optional[fenics.MeshFunction])

  • physical_groups (Optional[Dict[str, Dict[str, int]]])

cashocs.geometry.measure.generate_measure(idx, measure)[source]#

Generates a measure based on indices.

Generates a fenics.MeasureSum or _EmptyMeasure object corresponding to measure and the subdomains / boundaries specified in idx. This is a convenient shortcut to writing dx(1) + dx(2) + dx(3) in case many measures are involved.

Parameters:
  • idx (List[int]) – A list of indices for the boundary / volume markers that define the (new) measure.

  • measure (fenics.Measure) – The corresponding UFL measure.

Returns:

The corresponding sum of the measures or an empty measure.

Return type:

fenics.Measure | _EmptyMeasure

Examples

Here, we create a wrapper for the surface measure on the top and bottom of the unit square:

import fenics
import cashocs

mesh, _, boundaries, dx, ds, _ = cashocs.regular_mesh(25)
top_bottom_measure = cashocs.geometry.generate_measure([3,4], ds)
fenics.assemble(1*top_bottom_measure)