topology
The topology module defines the topology objects, notably the
StructuredTopology. Maintaining strict separation of topological and
geometrical information, the topology represents a set of elements and their
interconnectivity, boundaries, refinements, subtopologies etc, but not their
positioning in physical space. The dimension of the topology represents the
dimension of its elements, not that of the the space they are embedded in.
The primary role of topologies is to form a domain for nutils.function
objects, like the geometry function and function bases for analysis, as well as
provide tools for their construction. It also offers methods for integration and
sampling, thus providing a high level interface to operations otherwise written
out in element loops. For lower level operations topologies can be used as
nutils.element iterators.
- class nutils.topology.Topology(spaces, space_dims, references)
Bases:
objecttopology base class
- Parameters:
- references
The references.
- static empty(spaces, space_dims, ndims)
Return an empty topology.
- Parameters:
- Returns:
The empty topology.
- Return type:
See also
empty_like()create an empty topology with spaces and dimension copied from another topology
- empty_like(self)
Return an empty topology with the same spaces and dimensions as this topology.
- Returns:
The empty topology.
- Return type:
See also
empty_like()create an empty topology with custom spaces and dimension
- disjoint_union(*topos)
Return the union of the given disjoint topologies.
- __str__(self)
string representation
- get_groups(self, *groups)
Return the union of the given groups.
- take(self, _Topology__indices)
Return the selected elements as a disconnected topology.
The indices refer to the raveled list of elements in this topology. The indices are treated as a set: duplicate indices are silently ignored and the returned elements have the same order as in this topology.
- Parameters:
indices (integer
numpy.ndarrayor similar) – The one-dimensional array of element indices.- Returns:
The selected elements.
- Return type:
See also
compress()select elements using a mask
- compress(self, _Topology__mask)
Return the selected elements as a disconnected topology.
The mask refers to the raveled list of elements in this topology.
- Parameters:
mask (boolean
numpy.ndarrayor similar) – The one-dimensional array of elements to select.- Returns:
The selected elements.
- Return type:
See also
take()select elements by index
- slice(self, _Topology__s, _Topology__idim)
Return a slice of the given dimension index.
- basis(self, btype=None, _Topology__degree=None, **kwargs)
Create a basis.
A basis is a set of basis functions organized in a one dimensional array. The available types varies depending on the topology.
- field(self, name, /, *, shape=(), dtype=<class 'float'>, **kwargs)
Create a field.
A field is a contraction of a basis with an argument of given type and shape, the latter prefixed with the required dof axes. The following two functions are fully equivalent on non-tensorial topologies, and functionally equivalent on all topologies:
` self.field(name, shape=S, dtype=D, **B) function.field(name, self.basis(**B), shape=S, dtype=D) `
- sample(self, ischeme, degree)
Create sample.
- integrate_elementwise(self, funcs, *, degree, asfunction=False, ischeme='gauss', arguments=None)
element-wise integration
- integrate(self, funcs, ischeme='gauss', degree=None, edit=None, *, arguments=None, legacy=None)
integrate functions
- integral(self, func, ischeme='gauss', degree=None, edit=None)
- projection(self, fun, onto, geometry, **kwargs)
project and return as function
- project(self, fun, onto, geometry, ischeme='gauss', degree=None, droptol=1e-12, exact_boundaries=False, constrain=None, verify=None, ptype='lsqr', edit=None, *, arguments=None, **solverargs)
L2 projection of function onto function space
- refined_by(self, refine)
Create hierarchically refined topology by selectively refining elements.
- refine(self, _Topology__arg)
Return the refined topology.
If the argument is an
int, then this method behaves likerefine_count(). If the argument is a sequence ofstr, then this method behaves likerefine_spaces(). If the argument is a dictionary ofstrandint, then this method behaves likerefine_spaces_count().- Returns:
The refined topology.
- Return type:
See also
refine_count()refine a topology the given amount times
refine_spaces()refine the given spaces of the topology
refine_spaces_count()refine the given spaces the given amount times
- refine_count(self, count)
Return the topology refined count times.
- Parameters:
count (
int) – The number of times to refine. count is allowed to be zero, in which case the original topology is returned, but not negative.- Returns:
The refined topology.
- Return type:
See also
refine_spaces()refine the given spaces of the topology
refine_spaces_count()refine the given spaces the given amount times
- refine_spaces(self, _Topology__spaces)
Return the topology with the given spaces refined once.
- Parameters:
spaces (iterable of
str) – The spaces to refine. It is an error to specify spaces that do not exist in this topology. It is allowed to specify no spaces, in which case the original topology is returned.- Returns:
The refined topology.
- Return type:
See also
refine_count()refine a topology the given amount times
refine_spaces_count()refine the given spaces the given amount times
- refine_spaces_unchecked(self, _Topology__spaces)
Return the topology with the given spaces refined once.
- Parameters:
spaces (iterable of
str) – The spaces to refine. It is an error to specify spaces that do not exist in this topology. It is allowed to specify no spaces, in which case the original topology is returned.- Returns:
The refined topology.
- Return type:
Notes
This method does not check the validity of the arguments. Use
refine_spaces()instead unless you’re absolutely sure what you are doing.
- refine_spaces_count(self, count)
Return the topology with the given spaces refined the given amount times.
- Parameters:
spaces (mapping of
strtoint) – The spaces to refine together with the count. It is an error to specify spaces that do not exist in this topology. It is allowed to specify no spaces, in which case the original topology is returned.- Returns:
The refined topology.
- Return type:
See also
refine_count()refine a topology the given amount times
refine_spaces()refine the given spaces of the topology
- trim(self, levelset, maxrefine, ndivisions=8, name='trimmed', leveltopo=None, *, arguments=None)
trim element along levelset
- subset(self, topo, newboundary=None, strict=False)
intersection
- indicator(self, subtopo)
Create an indicator function for a subtopology.
- locate(self, geom, coords, *, tol=0, eps=0, maxiter=0, arguments=None, weights=None, maxdist=None, ischeme=None, scale=None, skip_missing=False)
Create a sample based on physical coordinates.
In a finite element application, functions are commonly evaluated in points that are defined on the topology. The reverse, finding a point on the topology based on a function value, is often a nonlinear process and as such involves Newton iterations. The
locatefunction facilitates this search process and produces anutils.sample.Sampleinstance that can be used for the subsequent evaluation of any function in the given physical points.Example:
>>> from . import mesh >>> domain, geom = mesh.unitsquare(nelems=3, etype='mixed') >>> sample = domain.locate(geom, [[.9, .4]], tol=1e-12) >>> sample.eval(geom).round(5).tolist() [[0.9, 0.4]]
Locate requires a geometry function, an array of coordinates, and at least one of
tolandepsto set the tolerance in physical of element space, respectively; if both are specified the least restrictive takes precedence.- Parameters:
geom (1-dimensional
nutils.function.Array) – Geometry function of lengthndims.coords (2-dimensional
floatarray) – Array of coordinates withndimscolumns.tol (
float(default: 0)) – Maximum allowed distance in physical coordinates between target and located point.eps (
float(default: 0)) – Maximum allowed distance in element coordinates between target and located point.maxiter (
int(default: 0)) – Maximum allowed number of Newton iterations, or 0 for unlimited.arguments (
dict(default: None)) – Arguments for function evaluation.weights (
floatarray (default: None)) – Optional weights, in casecoordsare quadrature points, making the resulting sample suitable for integration.maxdist (
float(default: None)) – Speed up failure by setting a physical distance between point and element centroid above which the element is rejected immediately. If all points are expected to be located then this can safely be left unspecified.skip_missing (
bool(default: False)) – When set to true, skip points that are not found (for instance because they fall outside the domain) in the returned sample. When set to false (the default) missing points raise aLocateError.
- Returns:
located
- Return type:
- boundary_spaces(self, _Topology__spaces)
Return the boundary in the given spaces.
- Parameters:
spaces (iterable of
str) – Nonstrict subset ofspaces. Duplicates are silently ignored.- Returns:
The boundary in the given spaces.
- Return type:
- Raises:
ValueError – If the topology is 0D or the set of spaces is empty or not a subset of
spaces.
- boundary_spaces_unchecked(self, _Topology__spaces)
Return the boundary in the given spaces.
The topology must be at least one-dimensional.
- Parameters:
spaces (
frozensetofstr) – Unempty, nonstrict subset ofspaces.- Returns:
The boundary in the given spaces.
- Return type:
Notes
This method does not check the validity of the arguments or the dimension of the topology. Use
boundary_spaces()instead unless you’re absolutely sure what you are doing.
- interfaces_spaces(self, _Topology__spaces)
Return the interfaces in the given spaces.
- Parameters:
spaces (iterable of
str) – Nonstrict subset ofspaces. Duplicates are silently ignored.- Returns:
The interfaces in the given spaces.
- Return type:
- Raises:
ValueError – If the topology is 0D or the set of spaces is empty or not a subset of
spaces.
- interfaces_spaces_unchecked(self, _Topology__spaces)
Return the interfaces in the given spaces.
The topology must be at least one-dimensional.
- Parameters:
spaces (
frozensetofstr) – Unempty, nonstrict subset ofspaces.- Returns:
The interfaces in the given spaces.
- Return type:
Notes
This method does not check the validity of the arguments or the dimension of the topology. Use
interfaces_spaces()instead unless you’re absolutely sure what you are doing.
- basis_discont(self, degree)
discontinuous shape functions
- __weakref__
list of weak references to the object
- class nutils.topology.TransformChainsTopology(space, references, transforms, opposites)
Bases:
Topologybase class for topologies with transform chains
- sample(self, ischeme, degree)
Create sample.
- basis_lagrange(self, degree)
lagrange shape functions
- basis_bernstein(self, degree)
bernstein shape functions
- basis_std(self, degree)
bernstein shape functions
- class nutils.topology.WithGroupsTopology(basetopo, vgroups={}, bgroups={}, igroups={}, pgroups={})
Bases:
TransformChainsTopologyitem topology
- class nutils.topology.OppositeTopology(basetopo)
Bases:
TransformChainsTopologyopposite topology
- class nutils.topology.EmptyTopology(space, todims, fromdims)
Bases:
TransformChainsTopologyempty topology
- class nutils.topology.StructuredTopology(space, root, axes, nrefine=0, bnames=(('left', 'right'), ('bottom', 'top'), ('front', 'back')))
Bases:
TransformChainsTopologystructured topology
- property boundary
- property interfaces
- basis_spline(self, degree, removedofs=None, knotvalues=None, knotmultiplicities=None, continuity=-1, periodic=None)
spline basis
- property refined
refine non-uniformly
- __str__(self)
string representation
- class nutils.topology.ConnectedTopology(space, references, transforms, opposites, connectivity)
Bases:
TransformChainsTopologyunstructured topology with connectivity
- class nutils.topology.SimplexTopology(space, simplices, transforms, opposites)
Bases:
TransformChainsTopologysimpex topology
- basis_bubble(self)
bubble from vertices
- class nutils.topology.UnionTopology(topos, names=())
Bases:
TransformChainsTopologygrouped topology
- class nutils.topology.DisjointUnionTopology(topos, names=())
Bases:
TransformChainsTopologygrouped topology
- class nutils.topology.SubsetTopology(basetopo, refs, newboundary=None)
Bases:
TransformChainsTopologytrimmed
- class nutils.topology.RefinedTopology(basetopo)
Bases:
TransformChainsTopologyrefinement
- class nutils.topology.HierarchicalTopology(basetopo, indices_per_level)
Bases:
TransformChainsTopologycollection of nested topology elments
- property boundary
boundary elements
- property interfaces
- class nutils.topology.MultipatchTopology(topos, connectivity)
Bases:
TransformChainsTopologymultipatch topology
- basis_spline(self, degree, patchcontinuous=True, knotvalues=None, knotmultiplicities=None, *, continuity=-1)
spline from vertices
Create a spline basis with degree
degreeper patch. Ifpatchcontinuous`is true the basis is $C^0$-continuous at patch interfaces.
- basis_patch(self)
degree zero patchwise discontinuous basis
- property boundary
- property interfaces
Return a topology with all element interfaces. The patch interfaces are accessible via the group
'interpatch'and the interfaces inside a patch via'intrapatch'.
- property refined
refine