cad.geometry#
Functions#
|
Export a single-patch igakit NURBS object to a PSYDAC geometry file in HDF5 format |
|
This function reads a geopdes geometry file and convert it to igakit nurbs object |
|
This function refines the knot sequence. |
|
This function refines the nurbs object. |
Classes#

|
Distributed discrete geometry that works for single and multiple patches. |
Details#
- class Geometry(domain: Domain, *, ddm: DomainDecomposition | MultiPatchDomainDecomposition, pdim: int, mappings: dict[str, BasicCallableMapping | None] | None = None)[source]#
Bases:
objectDistributed discrete geometry that works for single and multiple patches.
A Geometry object is usually created by calling
discretizeon a SymPDE domain:discretize(domain, filename=...)callsGeometry.from_file, anddiscretize(domain, ncells=...)callsGeometry.from_topological_domain.It can also be created directly with one of the class methods:
Geometry.from_file: from a geometry file (single or multi-patch).Geometry.from_discrete_mapping: from aSplineMapping(single patch).Geometry.from_topological_domain: from a topological domain, the number of cells, and the periodicity (single or multi-patch).
The constructor
__init__is meant for internal use by these class methods.- classmethod from_file(filename: str, *, domain: Domain | None = None, comm: Intracomm | None = None, mpi_dims_mask: Iterable[bool] | None = None)[source]#
Create a Geometry instance from an HDF5 input file in Psydac format.
- Parameters:
- filename: str
The path to the geometry file.
- domain: sympde.topology.Domain, optional
The topological domain of the geometry. It must match the domain defined in the file: same dimension, patch names, patches and interfaces. Each patch must have a non-analytical mapping, to which the corresponding spline mapping is attached; hence the same domain should not be used with different geometry files. If not given, the domain is created from the file.
- comm: MPI.Intracomm, optional
The MPI intra-communicator.
- mpi_dims_mask: Iterable[bool], optional
True if the dimension is to be used in the domain decomposition (=default for each dimension). If mpi_dims_mask[i]=False, the i-th dimension will not be decomposed.
- Returns:
- Geometry
The new instance.
- Raises:
- ValueError
If the given domain does not match the domain defined in the file, or if one of its patches has no mapping or an analytical mapping.
- classmethod from_discrete_mapping(mapping, *, name=None)[source]#
Create a single-patch Geometry instance from one discrete mapping.
The geometry uses the domain decomposition of the mapping’s spline space, hence its distribution across the MPI processes is that of the mapping.
- Parameters:
- mappingSplineMapping
The mapping from the unit square to the physical domain.
- namestr
Optional name for the symbolic Mapping that will be created. Needed to avoid conflicts in case several mappings are created.
- Returns:
- Geometry
The new instance.
- classmethod from_topological_domain(domain, ncells, *, periodic=None, comm=None, mpi_dims_mask=None)[source]#
Create a Geometry instance from a topological domain, without discrete mappings.
The domain may have symbolic mappings (e.g. analytical mappings), and callable mappings attached to them are kept (e.g. the discrete mappings of a domain returned by
Geometry.from_file), but no discrete mappings are created. All the patches of the domain must beNCubeInteriorobjects of the same dimension, i.e. lines, squares, or cubes. The physical dimension is given by the mappings of the patches if they have any, and otherwise it equals the logical dimension.- Parameters:
- domainsympde.topology.Domain
The single- or multi-patch topological domain, with or without symbolic mappings.
- ncellsIterable[int] | dict[str, Iterable[int]]
The number of cells along each direction. A list or tuple applies to all patches; a dictionary gives the number of cells of each patch, keyed by the names of the domain interiors.
- periodicIterable[bool] | dict[str, Iterable[bool]], optional
The periodicity along each direction, given in the same way as
ncells(default: no periodicity). A warning is issued if a multipatch domain is periodic along any direction.- commMPI.Intracomm, optional
The MPI intra-communicator.
- mpi_dims_maskIterable[bool], optional
True if the dimension is to be used in the domain decomposition (=default for each dimension). If mpi_dims_mask[i]=False, the i-th dimension will not be decomposed. Only used for a single patch.
- Returns:
- Geometry
The new instance.
- Raises:
- TypeError
If a patch of the domain is not an
NCubeInterior.- ValueError
If the patches of the domain have different physical dimensions.
- property ldim#
- property pdim#
- property ncells#
- property periodic#
- property comm#
- property domain#
- property ddm#
- property mappings#
- export_nurbs_to_hdf5(filename, nurbs, periodic=None, comm=None)[source]#
Export a single-patch igakit NURBS object to a PSYDAC geometry file in HDF5 format
- Parameters:
- filename<str>
Name of output geometry file, e.g. ‘geo.h5’
- nurbs<igakit.nurbs.NURBS>
igakit geometry nurbs object
- comm<MPI.COMM>
mpi communicator
- import_geopdes_to_nurbs(filename)[source]#
This function reads a geopdes geometry file and convert it to igakit nurbs object
- Parameters:
- filename<str>
the filename of the geometry file
- Returns:
- nrb<igakit.nurbs.NURBS>
the geometry nurbs object
- refine_knots(knots, ncells, degree, multiplicity=None, tol=1e-09)[source]#
This function refines the knot sequence. It contructs a new grid based on the new number of cells, and it adds the new break points to the nrb grid, such that the total number of cells is equal to the new number of cells. We use knot insertion to construct the new knot sequence , so the geometry is identical to the previous one. It also elevates the degree of the nrb object based on the new degree.
- Parameters:
- knots<list>
list of knot sequences in each direction
- ncells<list>
total number of cells in each direction
- degree<list>
degree in each direction
- multiplicity<list>
multiplicity of each knot in the knot sequence in each direction
- tol<float>
Minimum distance between two break points.
- Returns:
- knots<list>
the refined knot sequences in each direction
- refine_nurbs(nrb, ncells=None, degree=None, multiplicity=None, tol=1e-09)[source]#
This function refines the nurbs object. It contructs a new grid based on the new number of cells, and it adds the new break points to the nrb grid, such that the total number of cells is equal to the new number of cells. We use knot insertion to construct the new knot sequence , so the geometry is identical to the previous one. It also elevates the degree of the nrb object based on the new degree.
- Parameters:
- nrb<igakit.nurbs.NURBS>
geometry nurbs object
- ncells<list>
total number of cells in each direction
- degree<list>
degree in each direction
- multiplicity<list>
multiplicity of each knot in the knot sequence in each direction
- tol<float>
Minimum distance between two break points.
- Returns:
- nrb<igakit.nurbs.NURBS>
the refined geometry nurbs object