Skip to content

Commit

Permalink
Merge pull request #6 from gha3mi/dev
Browse files Browse the repository at this point in the history
Added Support for OpenMP and do concurrent
  • Loading branch information
gha3mi authored Apr 29, 2024
2 parents 6313869 + 81fb409 commit 8300e82
Show file tree
Hide file tree
Showing 11 changed files with 811 additions and 199 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
- Added `CONTRIBUTING.md` file.
- Add NURBS surface to PPM conversion examples.
- Utilized ForUnitTest for testing.
- Added Support for `OpenMP` and `do concurrent`.

### Changed

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

![](logo/logo.png)

**ForCAD**: A Fortran library for Geometric Modeling using NURBS (Non-Uniform Rational B-Splines).
**ForCAD**: A Parallel Fortran library for Geometric Modeling using NURBS (Non-Uniform Rational B-Splines).

ForCAD supports **B-Spline**, **NURBS**, **Bezier**, and **Rational Bezier** curves, surfaces, and volumes.

## Main Features

- Parallelized using `OpenMP` and `do concurrent`.
- Create NURBS objects by specifying control points, weights and knots.
- Refine NURBS objects by inserting or removing knots and elevating degree.
- Compute basis functions and derivatives of NURBS objects.
Expand Down
12 changes: 6 additions & 6 deletions example/example_ppm1.f90
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ program example_ppm1
call t%timer_start()
call background_color%set('white', use_library=.true.)

do concurrent (i = 1: width)
do i = 1, width
px(:, 3*(i-1)+1) = background_color%get_r()
px(:, 3*(i-1)+2) = background_color%get_g()
px(:, 3*(i-1)+3) = background_color%get_b()
Expand Down Expand Up @@ -84,7 +84,7 @@ program example_ppm1
allocate(idx(ng(1)*ng(2),2))
idx(:,1) = min(max(1, int(Xg(:,1) * width ) + 1), width )
idx(:,2) = min(max(1, int(Xg(:,2) * height) + 1), height)
do concurrent (i = 1: ng(1)*ng(2))
do i = 1, ng(1)*ng(2)
call cmap%compute_RGB(z_values(i), red, green, blue)
px(idx(i,2), 3*(idx(i,1)-1)+1) = red
px(idx(i,2), 3*(idx(i,1)-1)+2) = green
Expand Down Expand Up @@ -140,7 +140,7 @@ program example_ppm1
allocate(idx(ng(1)*ng(2),2))
idx(:,1) = min(max(1, int(Xg(:,1) * width ) + 1), width )
idx(:,2) = min(max(1, int(Xg(:,2) * height) + 1), height)
do concurrent (i = 1: ng(1)*ng(2))
do i = 1, ng(1)*ng(2)
call cmap%compute_RGB(z_values(i), red, green, blue)
px(idx(i,2), 3*(idx(i,1)-1)+1) = red
px(idx(i,2), 3*(idx(i,1)-1)+2) = green
Expand Down Expand Up @@ -201,7 +201,7 @@ program example_ppm1
allocate(idx(ng(1)*ng(2),2))
idx(:,1) = min(max(1, int(Xg(:,1) * width ) + 1), width )
idx(:,2) = min(max(1, int(Xg(:,2) * height) + 1), height)
do concurrent (i = 1: ng(1)*ng(2))
do i = 1, ng(1)*ng(2)
call cmap%compute_RGB(z_values(i), red, green, blue)
px(idx(i,2), 3*(idx(i,1)-1)+1) = red
px(idx(i,2), 3*(idx(i,1)-1)+2) = green
Expand Down Expand Up @@ -261,7 +261,7 @@ program example_ppm1
allocate(idx(ng(1)*ng(2),2))
idx(:,1) = min(max(1, int(Xg(:,1) * width ) + 1), width )
idx(:,2) = min(max(1, int(Xg(:,2) * height) + 1), height)
do concurrent (i = 1: ng(1)*ng(2))
do i = 1, ng(1)*ng(2)
call cmap%compute_RGB(z_values(i), red, green, blue)
px(idx(i,2), 3*(idx(i,1)-1)+1) = red
px(idx(i,2), 3*(idx(i,1)-1)+2) = green
Expand Down Expand Up @@ -324,7 +324,7 @@ program example_ppm1
allocate(idx(ng(1)*ng(2),2))
idx(:,1) = min(max(1, int(Xg(:,1) * width ) + 1), width )
idx(:,2) = min(max(1, int(Xg(:,2) * height) + 1), height)
do concurrent (i = 1: ng(1)*ng(2))
do i = 1, ng(1)*ng(2)
px(idx(i,2), 3*(idx(i,1)-1)+1) = red
px(idx(i,2), 3*(idx(i,1)-1)+2) = green
px(idx(i,2), 3*(idx(i,1)-1)+3) = blue
Expand Down
12 changes: 6 additions & 6 deletions example/example_ppm2.f90
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ program example_ppm2
call t%timer_start()
call background_color%set('white', use_library=.true.)

do concurrent (i = 1: width)
do i = 1, width
px(:, 3*(i-1)+1) = background_color%get_r()
px(:, 3*(i-1)+2) = background_color%get_g()
px(:, 3*(i-1)+3) = background_color%get_b()
Expand Down Expand Up @@ -83,7 +83,7 @@ program example_ppm2
allocate(idx(ng(1)*ng(2),2))
idx(:,1) = min(max(1, int(Xg(:,1) * width ) + 1), width )
idx(:,2) = min(max(1, int(Xg(:,2) * height) + 1), height)
do concurrent (i = 1: ng(1)*ng(2))
do i = 1, ng(1)*ng(2)
call cmap%compute_RGB(z_values(i), red, green, blue)
px(idx(i,2), 3*(idx(i,1)-1)+1) = red
px(idx(i,2), 3*(idx(i,1)-1)+2) = green
Expand Down Expand Up @@ -141,7 +141,7 @@ program example_ppm2
allocate(idx(ng(1)*ng(2),2))
idx(:,1) = min(max(1, int(Xg(:,1) * width ) + 1), width )
idx(:,2) = min(max(1, int(Xg(:,2) * height) + 1), height)
do concurrent (i = 1: ng(1)*ng(2))
do i = 1, ng(1)*ng(2)
call cmap%compute_RGB(z_values(i), red, green, blue)
px(idx(i,2), 3*(idx(i,1)-1)+1) = red
px(idx(i,2), 3*(idx(i,1)-1)+2) = green
Expand Down Expand Up @@ -205,7 +205,7 @@ program example_ppm2
allocate(idx(ng(1)*ng(2),2))
idx(:,1) = min(max(1, int(Xg(:,1) * width ) + 1), width )
idx(:,2) = min(max(1, int(Xg(:,2) * height) + 1), height)
do concurrent (i = 1: ng(1)*ng(2))
do i = 1, ng(1)*ng(2)
call cmap%compute_RGB(z_values(i), red, green, blue)
px(idx(i,2), 3*(idx(i,1)-1)+1) = red
px(idx(i,2), 3*(idx(i,1)-1)+2) = green
Expand Down Expand Up @@ -267,7 +267,7 @@ program example_ppm2
allocate(idx(ng(1)*ng(2),2))
idx(:,1) = min(max(1, int(Xg(:,1) * width ) + 1), width )
idx(:,2) = min(max(1, int(Xg(:,2) * height) + 1), height)
do concurrent (i = 1: ng(1)*ng(2))
do i = 1, ng(1)*ng(2)
call cmap%compute_RGB(z_values(i), red, green, blue)
px(idx(i,2), 3*(idx(i,1)-1)+1) = red
px(idx(i,2), 3*(idx(i,1)-1)+2) = green
Expand Down Expand Up @@ -332,7 +332,7 @@ program example_ppm2
allocate(idx(ng(1)*ng(2),2))
idx(:,1) = min(max(1, int(Xg(:,1) * width ) + 1), width )
idx(:,2) = min(max(1, int(Xg(:,2) * height) + 1), height)
do concurrent (i = 1: ng(1)*ng(2))
do i = 1, ng(1)*ng(2)
px(idx(i,2), 3*(idx(i,1)-1)+1) = red
px(idx(i,2), 3*(idx(i,1)-1)+2) = green
px(idx(i,2), 3*(idx(i,1)-1)+3) = blue
Expand Down
12 changes: 6 additions & 6 deletions example/example_ppm3.f90
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ program example_ppm3
call t%timer_start()
call background_color%set('white', use_library=.true.)

do concurrent (i = 1: width)
do i = 1, width
px(:, 3*(i-1)+1) = background_color%get_r()
px(:, 3*(i-1)+2) = background_color%get_g()
px(:, 3*(i-1)+3) = background_color%get_b()
Expand Down Expand Up @@ -84,7 +84,7 @@ program example_ppm3
allocate(idx(ng(1)*ng(2),2))
idx(:,1) = min(max(1, int(Xg(:,1) * width ) + 1), width )
idx(:,2) = min(max(1, int(Xg(:,2) * height) + 1), height)
do concurrent (i = 1: ng(1)*ng(2))
do i = 1, ng(1)*ng(2)
call cmap%compute_RGB(z_values(i), red, green, blue)
px(idx(i,2), 3*(idx(i,1)-1)+1) = red
px(idx(i,2), 3*(idx(i,1)-1)+2) = green
Expand Down Expand Up @@ -136,7 +136,7 @@ program example_ppm3
allocate(idx(ng(1)*ng(2),2))
idx(:,1) = min(max(1, int(Xg(:,1) * width ) + 1), width )
idx(:,2) = min(max(1, int(Xg(:,2) * height) + 1), height)
do concurrent (i = 1: ng(1)*ng(2))
do i = 1, ng(1)*ng(2)
call cmap%compute_RGB(z_values(i), red, green, blue)
px(idx(i,2), 3*(idx(i,1)-1)+1) = red
px(idx(i,2), 3*(idx(i,1)-1)+2) = green
Expand Down Expand Up @@ -195,7 +195,7 @@ program example_ppm3
allocate(idx(ng(1)*ng(2),2))
idx(:,1) = min(max(1, int(Xg(:,1) * width ) + 1), width )
idx(:,2) = min(max(1, int(Xg(:,2) * height) + 1), height)
do concurrent (i = 1: ng(1)*ng(2))
do i = 1, ng(1)*ng(2)
call cmap%compute_RGB(z_values(i), red, green, blue)
px(idx(i,2), 3*(idx(i,1)-1)+1) = red
px(idx(i,2), 3*(idx(i,1)-1)+2) = green
Expand Down Expand Up @@ -253,7 +253,7 @@ program example_ppm3
allocate(idx(ng(1)*ng(2),2))
idx(:,1) = min(max(1, int(Xg(:,1) * width ) + 1), width )
idx(:,2) = min(max(1, int(Xg(:,2) * height) + 1), height)
do concurrent (i = 1: ng(1)*ng(2))
do i = 1, ng(1)*ng(2)
call cmap%compute_RGB(z_values(i), red, green, blue)
px(idx(i,2), 3*(idx(i,1)-1)+1) = red
px(idx(i,2), 3*(idx(i,1)-1)+2) = green
Expand Down Expand Up @@ -316,7 +316,7 @@ program example_ppm3
allocate(idx(ng(1)*ng(2),2))
idx(:,1) = min(max(1, int(Xg(:,1) * width ) + 1), width )
idx(:,2) = min(max(1, int(Xg(:,2) * height) + 1), height)
do concurrent (i = 1: ng(1)*ng(2))
do i = 1, ng(1)*ng(2)
px(idx(i,2), 3*(idx(i,1)-1)+1) = red
px(idx(i,2), 3*(idx(i,1)-1)+2) = green
px(idx(i,2), 3*(idx(i,1)-1)+3) = blue
Expand Down
2 changes: 0 additions & 2 deletions example/shape_tetragon.f90
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ program shape_tetragon
implicit none

type(nurbs_surface) :: shape !! Declare a NURBS surface object
real(rk), allocatable :: Xc(:,:), Wc(:) !! Arrays for control points and weights
real(rk), allocatable :: knot1(:), knot2(:) !! Arrays for knot vectors in both dimensions

!-----------------------------------------------------------------------------
! Setting up the NURBS tetrangon
Expand Down
1 change: 1 addition & 0 deletions fpm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ source-form = "free"
forimage = {git="https://github.com/gha3mi/forimage.git"}
forcolormap = {git="https://github.com/vmagnin/forcolormap.git"}
fortime = {git="https://github.com/gha3mi/fortime.git"}
openmp = "*"

[dev-dependencies]
forunittest = {git="https://github.com/gha3mi/forunittest"}
Expand Down
Loading

0 comments on commit 8300e82

Please sign in to comment.