xfem.mlset module

Convenience layer module for integration using multiple level sets.

class xfem.mlset.DomainTypeArray(dtlist, lsets=None, persistent_compress=False, do_safety_checks=True)

Bases: object

Container class for multiple level sets.

Parameters

dtlist{list(tuples({ENUM,ANY})), tuple({ENUM,ANY})}

The tuple(s) describing the region of interest. The regions described by the individual tuples must be of the same co-dimension and the same length. Each ANY is expanded internally into a POS and a NEG region.

lsetstuple(ngsolve.GridFunction)

Optional argument (default=None): A tuple of discrete level set functions, with respect to which the domain in defined. If this given, then the DomainTypeArray is compressed into regions with positive measure on initialisation.

persistent_compressbool

Optional argument (default=False): Sets whether the result from operations on this DomainTypeArray instance should automatically be compressed with respect to lsets.

Attributes

as_listlist(tuples)

Expanded list containing tuples describing the region of interest.

codimint

Co-dimension of the contained region of interest.

lsets{None, tuple(ngsolve.GridFunction)}

The set of level set functions, with respect to which the instance is compressed if persistent_compress=True.

persistent_compressbool

Indicates, whether the instance to be compressed persistently after operations. the default value is False.

do_safety_checksbool

Option to turn of safety checks on the input list. This is useful if a copy of an existing DomainTypeArray is made and it is known, that the input is permissible. Default is value is True.

Methods

Boundary(element_marking=False):

A DomainTypeArray describing the boundary of the current DomainTypeArray region.

Compress(lsets, persistent=False):

Remove domain regions which have have zero measure with respect to the given level set functions.

Indicator(lsets):

Returns an indicator CoefficientFunction of the instances’ region (codim=0 only).

IndicatorSmoothed(lsets, eps):

Returns an indicator CoefficientFunction of an eps-region around the current instances’ region (codim>0 only).

GetOuterNormals(lsetsp1):

Returns a dictionary, containing the outward pointing unit normal vectors on each section of self.Boundary(). The keys are the tuples of the boundary segments, each normal vector is defined on.

Boundary()

Compute the boundary of the instances’ contained region. If persistent_compress=True has been set for the instance, then the result will compressed into boundary regions with positive measure.

Returns

DomainTypeArray

Container of the resulting boundary region.

Compress(lsets, persistent=False)

For a given set of level sets, this function removes any regions contained in the instance, which do not have a positive measure. The level sets remain attached to the instance, such that self.Boundary() called after self.Compress(lsets) automatically compresses the output.

Parameters

lsetstuple(ngsolve.GridFunction)

The set of level sets with respect to which it is computed, whether regions have positive measure.

persistentbool

Sets compression to continue on operations such as Boundary(). Default vale = False

Returns

None

GetOuterNormals(lsetsp1)

For each region in self.Boundary(), we compute the outward pointing unit normal vector.

Parameters

lesetsp1tuple(ngsolve.GridFunction)

The set of P1 level set functions.

Returns

dict(ngsolve.GridFunction)

Each normal is accessible with the tuple defining the boundary region it is defined on as the key.

Indicator(lsets)

Indicator CoefficientFunction for a DomainTypeArray of codim=0.

Parameters

lsetstuple(ngsolve.CoefficientFunctions)

The set of level set functions with respect to which the instances’ region is defined.

Returns

CoefficientFunction

1 in the region on interest, 0 else.

IndicatorSmoothed(lsets, eps=0.03)

Indicator CoefficientFunction, indicating the eps-region around the instances’ region (codim>0). We assume that the level sets are approximately signed distance functions in the eps region of the zero set.

Parameters

lsetstuple(ngsolve.CoefficientFunctions)

The set of level set functions defining the region.

epsfloat

The distance around the sub-domain which is indicated (default eps=0.01).

Returns

CoefficientFunction

1 in the region of distance eps around the sub-domain, 0 else.

xfem.mlset.TensorIntersection(*args)

Construct the intersection of an arbitrary number of regions, described by different DomainTypeArrays, each dependent on a different set of level sets. This increases the tuple-dimension of the resulting domain regions.

Parameters

*argsDomainTypeArray

Variable list of DomainTypeArray objects.

Returns

DomainTypeArray

Container of the resulting region.

xfem.mlset.TensorUnion(*args)

Construct the union of an arbitrary number of regions, described by different DomainTypeArrays, each dependent on a different set of level sets. This increases the tuple-dimension of the resulting domain regions.

Parameters

*argsDomainTypeArray

Variable list of DomainTypeArray objects of the same co-dimension.

Returns

DomainTypeArray

Container of the resulting region.