Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unique API for single/multi-patch Domain objects #173

Merged
merged 5 commits into from
Mar 5, 2025
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion sympde/topology/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import yaml
import os

from collections import abc
from collections import abc, OrderedDict
from typing import Union as TypeUnion, Optional, List, Dict, Iterable, TYPE_CHECKING
# Union clashes with core.basic.Union

Expand Down Expand Up @@ -180,6 +180,20 @@ def mapping(self) -> Optional[Mapping]:
"""The mapping that maps the logical domain to the physical domain"""
return self.args[3]

@property
def subdomains(self) -> tuple:
"""returns subdomains as tuple of Domains"""
if isinstance( self.interior, iterable_types):
subs = self.interior
else:
subs = [self.interior]
return tuple(subs)

@property
def mappings(self) -> OrderedDict:
return OrderedDict([(P.logical_domain, P.mapping)
for P in self.subdomains])

@property
def logical_domain(self) -> Domain:
"""The domain is the image of the logical_domain under the mapping"""
Expand Down Expand Up @@ -481,6 +495,11 @@ def join(cls, patches, connectivity, name):
assert isinstance(connectivity, (tuple, list))
assert isinstance(name, str)

if len(patches) == 1:
# single patch domain: return the patch
assert len(connectivity) == 0
return patches[0]

assert all(p.dim==patches[0].dim for p in patches)
dim = int(patches[0].dim)

Expand Down