@@ -3,7 +3,8 @@ using Printf
33using Parameters # helps setting default parameters in structures
44using SpecialFunctions: erfc
55using GeoParams
6- using ScatteredInterpolation
6+ using ScatteredInterpolation
7+ using StaticArrays
78
89# Setup_geometry
910#
561562# Internal function that rotates the coordinates
562563function Rot3D! (X,Y,Z, StrikeAngle, DipAngle)
563564
564- #=
565- # rotation matrixes
566- roty = [cosd(-DipAngle) 0 sind(-DipAngle) ; 0 1 0 ; -sind(-DipAngle) 0 cosd(-DipAngle)];
567- rotz = [cosd(StrikeAngle) -sind(StrikeAngle) 0 ; sind(StrikeAngle) cosd(StrikeAngle) 0 ; 0 0 1]
568-
569- for i in eachindex(X)
570- CoordVec = [X[i], Y[i], Z[i]]
571- CoordRot = rotz*CoordVec;
572- CoordRot = roty*CoordRot;
573- X[i] = CoordRot[1];
574- Y[i] = CoordRot[2];
575- Z[i] = CoordRot[3];
576- end
577- =#
578-
579565 # precompute trigonometric functions (expensive!)
580566 sindStrikeAngle, cosStrikeAngle = sincosd (StrikeAngle)
581567 sinDipAngle, cosDipAngle = sincosd (- DipAngle) # note the minus here to be consistent with the earlier version of the code
@@ -591,14 +577,14 @@ end
591577
592578Perform rotation for a point in 3D space
593579"""
594- function Rot3D (X:: Number ,Y:: Number ,Z:: Number , cosStrikeAngle, sindStrikeAngle, cosDipAngle, sinDipAngle)
580+ function Rot3D (X:: _T ,Y:: _T ,Z:: _T , cosStrikeAngle:: _T , sindStrikeAngle:: _T , cosDipAngle:: _T , sinDipAngle:: _T ) where _T <: Number
595581
596582 # rotation matrixes
597583 # roty = [cosd(-DipAngle) 0 sind(-DipAngle) ; 0 1 0 ; -sind(-DipAngle) 0 cosd(-DipAngle)];
598- roty = [cosDipAngle 0 sinDipAngle ; 0 1 0 ; - sinDipAngle 0 cosDipAngle]; # note that dip-angle is changed from before!
599- rotz = [cosStrikeAngle - sindStrikeAngle 0 ; sindStrikeAngle cosStrikeAngle 0 ; 0 0 1 ]
584+ roty = @SMatrix [cosDipAngle 0 sinDipAngle ; 0 1 0 ; - sinDipAngle 0 cosDipAngle]; # note that dip-angle is changed from before!
585+ rotz = @SMatrix [cosStrikeAngle - sindStrikeAngle 0 ; sindStrikeAngle cosStrikeAngle 0 ; 0 0 1 ]
600586
601- CoordVec = [X, Y, Z]
587+ CoordVec = @SVector [X, Y, Z]
602588 CoordRot = rotz* CoordVec;
603589 CoordRot = roty* CoordRot;
604590
@@ -1506,12 +1492,13 @@ end
15061492=#
15071493
15081494"""
1509- find_slab !(ls, d, X,Y,Z, Start, End, Top, Bottom, seg_slab, D0, L0 )
1495+ find_slab_distance !(ls, d, X,Y,Z, trench::Trench )
15101496
15111497Function that finds the perpendicular distance to the top and bottom of the slab `d`, and the current length of the slab `l`.
15121498
15131499"""
1514- function find_slab! (ls, d, X,Y,Z, Start, End,Top,Bottom,seg_slab,D0,L0,direction)
1500+ function find_slab_distance! (ls, d, X,Y,Z, Top, Bottom, trench:: Trench )
1501+ @unpack D0, L0, n_seg, Start, End, direction = trench;
15151502
15161503 # Perform rotation of 3D coordinates along the angle from Start -> End:
15171504 Xrot = X .- Start[1 ];
@@ -1521,20 +1508,18 @@ function find_slab!(ls, d, X,Y,Z, Start, End,Top,Bottom,seg_slab,D0,L0,direction
15211508
15221509 xb = Rot3D (End[1 ]- Start[1 ],End[2 ]- Start[2 ], 0.0 , cosd (StrikeAngle), sind (StrikeAngle), 1.0 , 0.0 )
15231510
1524- # xb1 = transform_coordinate!(X,Y,Z,Xrot,Yrot,Start,End,direction);
1525-
15261511 # dl
1527- dl = L0/ seg_slab ;
1512+ dl = L0/ n_seg ;
15281513
15291514 l = 0 # length at the trench position
15301515
15311516 # Construct the slab
1532- for i = 1 : (seg_slab - 1 )
1517+ for i = 1 : (n_seg - 1 )
15331518
15341519 ln = l+ dl;
15351520
1536- pa = (Top[i,1 ],Top[i,2 ]); # D = 0 | L = l
1537- pb = (Bottom[i,1 ],Bottom[i,2 ]); # D = -D0 | L=l
1521+ pa = (Top[i,1 ], Top[i,2 ]); # D = 0 | L = l
1522+ pb = (Bottom[i,1 ], Bottom[i,2 ]); # D = -D0 | L=l
15381523
15391524 pc = (Bottom[i+ 1 ,1 ],Bottom[i+ 1 ,2 ]); # D = -D0 |L=L+dl
15401525 pd = (Top[i+ 1 ,1 ],Top[i+ 1 ,2 ]) # D = 0| L = L+dl
@@ -1554,7 +1539,6 @@ function find_slab!(ls, d, X,Y,Z, Start, End,Top,Bottom,seg_slab,D0,L0,direction
15541539
15551540 # Find the particles
15561541 yp = Yrot[ind_s];
1557-
15581542 zp = Z[ind_s];
15591543
15601544 # Initialize the ind that are going to be used by inpoly
@@ -1595,20 +1579,6 @@ function find_slab!(ls, d, X,Y,Z, Start, End,Top,Bottom,seg_slab,D0,L0,direction
15951579end
15961580
15971581
1598- """
1599-
1600- Internal routine which finds distance perpendicular (`d`) and along (`ls`) the slab, as specified in `trench`.
1601- """
1602- function find_slab_distance! (ls, d, trench, Top, Bottom, X,Y,Z)
1603- @unpack D0, L0, n_seg, Start, End, direction = trench;
1604-
1605- # Finds the distance to the slab
1606- GeophysicalModelGenerator. find_slab! (ls, d, X,Y,Z, Start,End, Top,Bottom,n_seg,D0,L0,direction);
1607-
1608- return nothing
1609- end
1610-
1611-
16121582
16131583"""
16141584 addSlab!(Phase, Temp, Grid::AbstractGeneralGrid, trench::Trench; phase = ConstantPhase(1), T = nothing)
@@ -1657,10 +1627,10 @@ function addSlab!(Phase, Temp, Grid::AbstractGeneralGrid, trench::Trench;
16571627 Top,Bottom = compute_slab_surface (trench);
16581628
16591629 # Find the distance to the slab (along & perpendicular)
1660- find_slab_distance! (ls, d, trench, Top, Bottom, X,Y,Z );
1630+ find_slab_distance! (ls, d, X,Y,Z, Top, Bottom, trench );
16611631
16621632 # Function to fill up the temperature and the phase.
1663- ind = findall ((- trench. D0 .<= d .<= 0.0 ));
1633+ ind = findall ((- trench. D0 .<= d .<= 0.0 ));Grid
16641634
16651635 if isa (T, LinearWeightedTemperature)
16661636 l_decouplingind = findall (Top[:,2 ]. <= - trench. d_decoupling);
0 commit comments