-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split MirrorSymmetry in cylindrical and cartesian version
- Loading branch information
1 parent
5ea6d53
commit 1791d83
Showing
3 changed files
with
42 additions
and
35 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
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 |
---|---|---|
@@ -1,35 +1,42 @@ | ||
struct MirrorSymmetry{T} | ||
struct CartesianMirrorSymmetry{T} | ||
symmetry_plane::Plane{T} #Plane{T}(origin, normal) | ||
end | ||
|
||
function MirrorSymmetry{T}(origin::CylindricalPoint{T}, normal::CylindricalVector{T}) where {T} | ||
_origin = CartesianPoint(origin) | ||
_normal = CartesianVector{T}(cos(origin[2]) * normal[1] - sin(origin[2]) * normal[2], | ||
sin(origin[2]) * normal[1] + cos(origin[2]) * normal[2], normal[3]) | ||
MirrorSymmetry{T}(Plane{T}(_origin, _normal)) | ||
struct CylindricalMirrorSymmetry{T} | ||
origin::CylindricalPoint{T} | ||
normal::CylindricalVector{T} | ||
end | ||
|
||
function MirrorSymmetry{T}(origin::CartesianPoint{T}, normal::CartesianVector{T}) where {T} | ||
MirrorSymmetry{T}(Plane{T}(origin, normal)) | ||
function CartesianMirrorSymmetry{T}(origin::CartesianPoint{T}, normal::CartesianVector{T}) where {T} | ||
CartesianMirrorSymmetry{T}(Plane{T}(origin, normal)) | ||
end | ||
|
||
function MirrorSymmetry(axis, value::T, units::NamedTuple = default_unit_tuple()) where {T<:SSDFloat} | ||
function CartesianMirrorSymmetry(axis, value::T, units::NamedTuple = default_unit_tuple()) where {T<:SSDFloat} | ||
length_unit = units.length | ||
angle_unit = units.angle | ||
if axis == "phi" || axis == "φ" | ||
MirrorSymmetry{T}(CylindricalPoint{T}(r=to_internal_units(1 * length_unit), φ = to_internal_units(value * angle_unit)), | ||
CylindricalVector{T}(0, to_internal_units(1 * length_unit), 0)) | ||
elseif axis == "x" | ||
MirrorSymmetry{T}(CartesianPoint{T}(x = to_internal_units(value * length_unit)), CartesianVector{T}(1,0,0)) | ||
if axis == "x" | ||
CartesianMirrorSymmetry{T}(CartesianPoint{T}(x = to_internal_units(value * length_unit)), CartesianVector{T}(1,0,0)) | ||
elseif axis == "y" | ||
MirrorSymmetry{T}(CartesianPoint{T}(y = to_internal_units(value * length_unit)), CartesianVector{T}(0,1,0)) | ||
CartesianMirrorSymmetry{T}(CartesianPoint{T}(y = to_internal_units(value * length_unit)), CartesianVector{T}(0,1,0)) | ||
elseif axis == "z" | ||
MirrorSymmetry{T}(CartesianPoint{T}(z = to_internal_units(value * length_unit)), CartesianVector{T}(0,0,1)) | ||
CartesianMirrorSymmetry{T}(CartesianPoint{T}(z = to_internal_units(value * length_unit)), CartesianVector{T}(0,0,1)) | ||
else | ||
@error "Wrong axis" | ||
end | ||
end | ||
|
||
function CylindricalMirrorSymmetry(axis, value::T, units::NamedTuple = default_unit_tuple()) where {T<:SSDFloat} | ||
length_unit = units.length | ||
angle_unit = units.angle | ||
if axis == "phi" || axis == "φ" | ||
CylindricalMirrorSymmetry{T}(CylindricalPoint{T}(r=to_internal_units(1 * length_unit), φ = to_internal_units(value * angle_unit)), | ||
CylindricalVector{T}(0, to_internal_units(1 * length_unit), 0)) | ||
elseif axis == "z" | ||
CylindricalMirrorSymmetry{T}(CartesianPoint{T}(z = to_internal_units(value * length_unit)), CartesianVector{T}(0,0,1)) | ||
elseif axis == "r" | ||
@error "Mirror symmetry along r not defined" | ||
else | ||
@error "Wrong axis" | ||
end | ||
end | ||
end | ||
|
||
|
||
|