-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Constraints] Created VertexConstraint
- Loading branch information
1 parent
848a2ac
commit da310d2
Showing
4 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from .vertex import * # noqa F403 | ||
from .coordinates import * # noqa F403 | ||
|
||
|
||
__all__ = [name for name in dir() if not name.startswith('_')] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from jax_fdm.constraints.vertex import VertexConstraint | ||
|
||
|
||
class VertexXCoordinateConstraint(VertexConstraint): | ||
""" | ||
Constraint the X coordinate of a vertex between a lower and an upper bound. | ||
""" | ||
@staticmethod | ||
def constraint(eqstate, index): | ||
""" | ||
Returns the X coordinate of a vertex from an equilibrium state. | ||
""" | ||
return eqstate.xyz[index, :1] | ||
|
||
|
||
class VertexYCoordinateConstraint(VertexConstraint): | ||
""" | ||
Constraint the Y coordinate of a vertex between a lower and an upper bound. | ||
""" | ||
@staticmethod | ||
def constraint(eqstate, index): | ||
""" | ||
Returns the Y coordinate of a vertex from an equilibrium state. | ||
""" | ||
return eqstate.xyz[index, 1:2] | ||
|
||
|
||
class VertexZCoordinateConstraint(VertexConstraint): | ||
""" | ||
Constraint the Z coordinate of a vertex between a lower and an upper bound. | ||
""" | ||
@staticmethod | ||
def constraint(eqstate, index): | ||
""" | ||
Returns the Z coordinate of a vertex from an equilibrium state. | ||
""" | ||
return eqstate.xyz[index, 2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from jax_fdm.constraints import Constraint | ||
|
||
|
||
class VertexConstraint(Constraint): | ||
""" | ||
Base class for all constraints that pertain to a vertex in a mesh. | ||
""" | ||
def index_from_model(self, model, structure): | ||
""" | ||
The index of the node in a structure. | ||
""" | ||
try: | ||
return structure.vertex_index[self.key] | ||
except TypeError: | ||
return tuple([structure.vertex_index[k] for k in self.key]) |