Skip to content

Commit

Permalink
Add ansatz, cmp_volume, cmp_area and cmp_length
Browse files Browse the repository at this point in the history
- Added `det`, `inv`, `dyad` and `gauss_leg` procedures in the `forcad_utils` module.
- Added procedure `set1a` to the `nurbs_curve` derived type.
- Added procedure `set4` to the `nurbs_curve` NURBS derived type.
- Added optional input variable `elem` to `derivative_scalar` procedures.
- Added `ansatz` procedures to compute shape functions, derivatives of shape functions and (dV, dA, dL).
- Added `cmp_length()` to compute the length of a NURBS curve.
- Added `cmp_area()` to compute the area of a NURBS surface.
- Added `cmp_volume()` to compute the volume of a NURBS volume.
- Added examples for `cmp_length()`, `cmp_area()`, and `cmp_volume()`.

Signed-off-by: Seyed Ali Ghasemi <info@gha3mi.com>
  • Loading branch information
gha3mi committed Jun 28, 2024
1 parent a1964d2 commit 99c9cd3
Show file tree
Hide file tree
Showing 9 changed files with 827 additions and 97 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ All notable changes to [ForCAD](https://github.com/gha3mi/forcad) will be docume

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

## [Unreleased]

### Added

- Added `det`, `inv`, `dyad` and `gauss_leg` procedures in the `forcad_utils` module.
- Added procedure `set1a` to the `nurbs_curve` derived type.
- Added procedure `set4` to the `nurbs_curve` NURBS derived type.
- Added optional input variable `elem` to `derivative_scalar` procedures.
- Added `ansatz` procedures to compute shape functions, derivatives of shape functions and (dV, dA, dL).
- Added `cmp_length()` to compute the length of a NURBS curve.
- Added `cmp_area()` to compute the area of a NURBS surface.
- Added `cmp_volume()` to compute the volume of a NURBS volume.
- Added examples for `cmp_length()`, `cmp_area()`, and `cmp_volume()`.

## [0.5.1]

### Changed
Expand Down
23 changes: 23 additions & 0 deletions example/cmp_area.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
program compute_area

use forcad

implicit none

type(nurbs_surface) :: shape
real(rk) :: area
real(rk) :: Xc(4,3)

Xc(1,:) = [0.0_rk, 0.0_rk, 0.0_rk]
Xc(2,:) = [2.0_rk, 0.0_rk, 0.0_rk]
Xc(3,:) = [0.0_rk, 2.0_rk, 0.0_rk]
Xc(4,:) = [2.0_rk, 2.0_rk, 0.0_rk]

call shape%set(&
knot1=[0.0_rk, 0.0_rk, 1.0_rk, 1.0_rk],&
knot2=[0.0_rk, 0.0_rk, 1.0_rk, 1.0_rk],&
Xc=Xc)

call shape%cmp_area(area)
print*, area
end program
20 changes: 20 additions & 0 deletions example/cmp_length.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
program compute_length

use forcad

implicit none

type(nurbs_curve) :: shape
real(rk) :: length
real(rk) :: Xc(2,3)

Xc(1,:) = [0.0_rk, 0.0_rk, 0.0_rk]
Xc(2,:) = [2.0_rk, 0.0_rk, 0.0_rk]

call shape%set(&
knot=[0.0_rk, 0.0_rk, 1.0_rk, 1.0_rk],&
Xc=Xc)

call shape%cmp_length(length)
print*, length
end program
28 changes: 28 additions & 0 deletions example/cmp_volume.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
program compute_volume

use forcad

implicit none

type(nurbs_volume) :: shape
real(rk) :: volume
real(rk) :: Xc(8,3)

Xc(1,:) = [0.0_rk, 0.0_rk, 0.0_rk]
Xc(2,:) = [2.0_rk, 0.0_rk, 0.0_rk]
Xc(3,:) = [0.0_rk, 2.0_rk, 0.0_rk]
Xc(4,:) = [2.0_rk, 2.0_rk, 0.0_rk]
Xc(5,:) = [0.0_rk, 0.0_rk, 2.0_rk]
Xc(6,:) = [2.0_rk, 0.0_rk, 2.0_rk]
Xc(7,:) = [0.0_rk, 2.0_rk, 2.0_rk]
Xc(8,:) = [2.0_rk, 2.0_rk, 2.0_rk]

call shape%set(&
knot1=[0.0_rk, 0.0_rk, 1.0_rk, 1.0_rk],&
knot2=[0.0_rk, 0.0_rk, 1.0_rk, 1.0_rk],&
knot3=[0.0_rk, 0.0_rk, 1.0_rk, 1.0_rk],&
Xc=Xc)

call shape%cmp_volume(volume)
print*, volume
end program
18 changes: 17 additions & 1 deletion fpm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ 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 = "*"
stdlib = "*"

[dev-dependencies]
forunittest = {git="https://github.com/gha3mi/forunittest"}
Expand Down Expand Up @@ -158,4 +159,19 @@ main = "nearest_point_3d.f90"
[[example]]
name = "nearest_point_2d_bench"
source-dir = "example"
main = "nearest_point_2d_bench.f90"
main = "nearest_point_2d_bench.f90"

[[example]]
name = "cmp_length"
source-dir = "example"
main = "cmp_length.f90"

[[example]]
name = "cmp_area"
source-dir = "example"
main = "cmp_area.f90"

[[example]]
name = "cmp_volume"
source-dir = "example"
main = "cmp_volume.f90"
Loading

0 comments on commit 99c9cd3

Please sign in to comment.