-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add Xt to nurbs_surface and nurbs_volume derived types. - Add examples for 1D, 2D, and 3D. - Update fpm.toml. - Update CHANGELOG.md.
- Loading branch information
Showing
8 changed files
with
199 additions
and
26 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,44 @@ | ||
program nearest_point_1d | ||
|
||
use forcad, only: rk, nurbs_curve | ||
|
||
implicit none | ||
|
||
type(nurbs_curve) :: shape !! Declare a NURBS curve object | ||
real(rk), allocatable :: nearest_Xg(:) !! Coordinates of the nearest point on the curve | ||
real(rk) :: nearest_Xt !! Corresponding parametric coordinates of the nearest point | ||
integer :: id !! id of the nearest point | ||
|
||
!----------------------------------------------------------------------------- | ||
! Setting up the NURBS circle | ||
!----------------------------------------------------------------------------- | ||
|
||
!> Set a circle with radius 2.0 and center at [0.0, 0.0, 0.0] | ||
call shape%set_circle(center = [0.0_rk, 0.0_rk, 0.0_rk], radius = 2.0_rk) | ||
|
||
!----------------------------------------------------------------------------- | ||
! Creating circle | ||
!----------------------------------------------------------------------------- | ||
|
||
!> Generate the NURBS circle with a resolution of 100 | ||
call shape%create(res = 100) | ||
|
||
!----------------------------------------------------------------------------- | ||
! Nearest point on the curve | ||
!----------------------------------------------------------------------------- | ||
|
||
!> Find the nearest point on the curve to a given point | ||
! nearest_Xg: Coordinates of the nearest point on the curve (optional) | ||
! nearest_Xt: Corresponding parametric coordinates of the nearest point (optional) | ||
! id: id of the nearest point (optional) | ||
call shape%nearest_point([2.0_rk, 3.0_rk, 5.0_rk], nearest_Xg, nearest_Xt, id) | ||
print *, 'Nearest point on the curve:', nearest_Xg, 'with parametric coordinates:', nearest_Xt, 'and id:', id | ||
|
||
!----------------------------------------------------------------------------- | ||
! Finalizing | ||
!----------------------------------------------------------------------------- | ||
|
||
!> Finalize the NURBS curve object | ||
call shape%finalize() | ||
|
||
end program |
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,45 @@ | ||
program nearest_point_3d | ||
|
||
use forcad, only: rk, nurbs_volume | ||
|
||
implicit none | ||
|
||
type(nurbs_volume) :: shape !! Declare a NURBS volume object | ||
real(rk), allocatable :: nearest_Xg(:) !! Coordinates of the nearest point on the volume | ||
real(rk), allocatable :: nearest_Xt(:) !! Corresponding parametric coordinates of the nearest point | ||
integer :: id !! id of the nearest point | ||
|
||
!----------------------------------------------------------------------------- | ||
! Setting up the NURBS hexahedron | ||
!----------------------------------------------------------------------------- | ||
|
||
!> Set up a hexahedron shape with dimensions L = [2.0, 4.0, 8.0] and a specified number of control points nc = [4, 6, 8]. | ||
!> The weights of the control points (Wc) are optional. | ||
call shape%set_hexahedron(L=[2.0_rk, 4.0_rk, 8.0_rk], nc=[4,6,8]) | ||
|
||
!----------------------------------------------------------------------------- | ||
! Creating the NURBS volume | ||
!----------------------------------------------------------------------------- | ||
|
||
!> Generate the NURBS volume with resolutions of 8, 16 and 32 | ||
call shape%create(8, 16, 32) | ||
|
||
!----------------------------------------------------------------------------- | ||
! Nearest point on the volume | ||
!----------------------------------------------------------------------------- | ||
|
||
!> Find the nearest point on the volume to a given point | ||
! nearest_Xg: Coordinates of the nearest point on the volume (optional) | ||
! nearest_Xt: Corresponding parametric coordinates of the nearest point (optional) | ||
! id: id of the nearest point (optional) | ||
call shape%nearest_point([2.0_rk, 3.0_rk, 5.0_rk], nearest_Xg, nearest_Xt, id) | ||
print *, 'Nearest point on the volume:', nearest_Xg, 'with parametric coordinates:', nearest_Xt, 'and id:', id | ||
|
||
!----------------------------------------------------------------------------- | ||
! Finalizing | ||
!----------------------------------------------------------------------------- | ||
|
||
!> Finalize the NURBS volume object | ||
call shape%finalize() | ||
|
||
end program |
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
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