porepy.numerics.mixed_dim.assembler_filters module

Discretization filters to allow partial discretization or assembly.

Content:

AllPassFilter does no filtering. ListFilter: filters based on grid quantities, variables and lists.

New filter classes should be implemented by subclassing the abstract base class AssemblerFilter.

Credits: Design idea and main implementation by Haakon Ervik.

class AllPassFilter[source]

Bases: AssemblerFilter

All pass filter. The filter method always return True.

filter(grids=None, variables=None, terms=None)[source]

Filter grids (in a general sense), variables and discretization terms.

The filter should return true if the combination of grids, variables and terms are considered ‘active’ by the filter. Intended use is to allow the assembler to implement partial discretization or assembly.

Parameters
  • grids (Optional[Union[Grid, List[Grid], MortarGrid, Tuple[Grid, Grid, MortarGrid]]]) – Grid-like quantity found in a pp.MixedDimensionalGrid. Can be either a Grid (MixedDimensionalGrid subdomain), an interface (a MixedDimensionalGrid interface), or a combination of two neighboring grids and an interface.

  • variables (Optional[List[str]]) – A variable, or a list of variables.

  • terms (Optional[List[str]]) – List of terms for discretizations. See Assembler for further explanation.

Returns

True if the grid-variable-term combination passes the filter.

Return type

boolean

class AssemblerFilter[source]

Bases: ABC

Abstract base class of filters for use with the Assembler.

abstract filter(grids=None, variables=None, terms=None)[source]

Filter grids (in a general sense), variables and discretization terms.

The filter should return true if the combination of grids, variables and terms are considered ‘active’ by the filter. Intended use is to allow the assembler to implement partial discretization or assembly.

Parameters
  • grid – Grid-like quantity found in a pp.MixedDimensionalGrid. Can be either a Grid (MixedDimensionalGrid subdomain), an interface (a MixedDimensionalGrid interface), or a combination of two neighboring grids and an interface.

  • variables (Optional[List[str]]) – List of variables.

  • term – List of terms for discretization. See Assembler for further explanation.

  • grids (Optional[Union[Grid, List[Grid], MortarGrid, Tuple[Grid, Grid, MortarGrid]]]) –

  • terms (Optional[List[str]]) –

Returns

True if the grid-variable-term combination passes the filter.

Return type

boolean

class ListFilter(grid_list=None, variable_list=None, term_list=None)[source]

Bases: AssemblerFilter

Filter based on lists of (generalized) grids, variables and terms.

The filter is initialized with lists of grids (specification below), variables and terms that should pass the filter. The filter function will pass a combination of a grid, a set of variables and a term if they are all found in the lists of acceptable combinations.

If a list of grids, variables and/or terms are not provided at the time of initialization, all objects of this the unspecified type will pass the filter. Thus, if neither grids, variables nor terms are specified, the filter effectively becomes an AllPassFilter.

NOTE: If a list (say of grids) is given as an empty list, the filter will become no-pass filter. This is to cover cases where dimension-filtering on grids in a MixedDimensionalGrid returns a empty list, which should result in no-pass, not all-pass behavior. The behavior for variable and term lists is similar.

Acceptable variables and terms can be specified as a negation with the syntax !variable_name. It is not possible to use both negated and standard specification of, say, variables, but negated variables combined with standard terms (or reverse) is permissible.

The generalized grids should be one of
  1. grids: subdomains in the MixedDimensionalGrid

  2. interfaces: (Grid, Grid) tuples, interfaces in the MixedDimensionalGrid.

  3. couplings: (Grid, Grid, (Grid, Grid)) tuples, so an interface, together

with its neighboring subdomains.

Parameters
filter(grids=None, variables=None, terms=None)[source]

Filter grids (in a general sense), variables and discretization terms.

See class documentation for how to use the filter.

Parameters
  • grids (Optional[Union[Grid, List[Grid], MortarGrid, Tuple[Grid, Grid, MortarGrid]]]) – Grid-like quantity found in a pp.MixedDimensionalGrid. Can be either a Grid (MixedDimensionalGrid subdomain), an interface (a MixedDimensionalGrid interface), or a combination of two neighboring grids and an interface.

  • variables (Optional[List[str]]) – A variable, or a list of variables. A list will be passed for off-diagonal terms (internal to subdomains or interfaces), and for coupling terms.

  • terms (Optional[List[str]]) – Term for a discretization. See Assembler for further explanation.

Returns

True if the grid-variable-term combination passes the filter.

Return type

boolean