[Fortran] 纯文本查看 复制代码
module hydromodelUtil
implicit none
double precision, parameter :: pi=3.141593d0
type singleinfo
integer :: controlno
integer :: unittype
integer :: solid
double precision :: coearea
double precision :: volume
double precision, dimension(3) :: center
integer :: pointcount, trianglecount
double precision, dimension(:,:), allocatable :: pointchain
double precision, dimension(:,:,:), allocatable :: trianglechain
end type singleinfo
contains
subroutine cylindermeshing(r, h, cylinderinfo)
implicit none
double precision :: r, h
type(singleinfo) :: cylinderinfo
integer :: polyedge=60
double precision, dimension(:,:), allocatable :: point
double precision :: dtheta
integer :: meshi
dtheta=2*pi/real(polyedge)
cylinderinfo%volume=(0.5d0*polyedge*sin(dtheta)*r**2)*h
cylinderinfo%center=(/ 0.0d0, 0.0d0, 0.5d0*h /)
cylinderinfo%pointcount=2*polyedge
cylinderinfo%trianglecount=4*polyedge
allocate(point(2,polyedge+1) )
do meshi=1, polyedge, 1
point(1,meshi)=r*cos( (real(meshi)-1.0d0)*dtheta)
point(2,meshi)=r*sin( (real(meshi)-1.0d0)*dtheta)
end do
point(:, polyedge+1)=point(:, 1)
do meshi=1, polyedge, 1
cylinderinfo%pointchain(1:2,meshi)=point(1:2,meshi)
cylinderinfo%pointchain(3,meshi)=0.0d0
cylinderinfo%pointchain(1:2,polyedge+meshi)=point(1:2,meshi)
cylinderinfo%pointchain(3,polyedge+meshi)=h
end do
end subroutine cylindermeshing
function thirddet(deta)
double precision, dimension(3,3) :: deta
double precision :: thirddet
thirddet=deta(1,1)*(deta(2,2)*deta(3,3)-deta(3,2)*deta(2,3)) &
& -deta(2,1)*(deta(1,2)*deta(3,3)-deta(3,2)*deta(1,3)) &
& +deta(3,1)*(deta(1,2)*deta(2,3)-deta(2,2)*deta(1,3))
end function thirddet
end module hydromodelUtil