Skip to content

Commit

Permalink
add inside function to domain
Browse files Browse the repository at this point in the history
  • Loading branch information
enigne committed Nov 18, 2024
1 parent bf6dd6e commit 169f778
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pinnicle/domain/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,14 @@ def get_polygon_vertices(self, filepath):
domain_list.append(vertex_list)

return domain_list

def inside(self, x):
"""
return if given points are inside the domain
"""
if self.parameters.time_dependent:
# only check the spatial domain
# TODO: add time domain
return self.geometry.geometry.inside(x)
else:
return self.geometry.inside(x)
11 changes: 11 additions & 0 deletions tests/test_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest
import deepxde as dde
import os
import numpy as np


def test_domain():
Expand All @@ -19,6 +20,11 @@ def test_domain():
d2 = pinn.domain.Domain(p2)
assert type(d2.geometry) == dde.geometry.Polygon

c = np.array([0.5*(d2.geometry.bbox[0]+d2.geometry.bbox[1])])
assert d2.inside(c)
o = np.array([d2.geometry.bbox[0]-[100,100] ,d2.geometry.bbox[1]+[100,100]])
assert not np.any(d2.inside(o))

hp["time_dependent"] = True
hp["start_time"] = 0
hp["end_time"] = 1
Expand All @@ -27,3 +33,8 @@ def test_domain():
assert type(d2.geometry) != dde.geometry.Polygon
assert type(d2.geometry) == dde.geometry.GeometryXTime
assert (d2.geometry.random_points(5)).shape == (5, 3)

c = np.array([0.5*(d2.geometry.geometry.bbox[0]+d2.geometry.geometry.bbox[1])])
assert d2.inside(c)
o = np.array([d2.geometry.geometry.bbox[1]-[100,100] ,d2.geometry.geometry.bbox[1]+[100,100]])
assert not np.any(d2.inside(o))

0 comments on commit 169f778

Please sign in to comment.