⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 geo3d.f90

📁 国外大名顶顶的“台风”并行计算流体力学CFD软件的早期版本的源代码
💻 F90
字号:
!------------------------------------------------------------------------------!! MODULE : GEO3D                          Auteur : J. Gressier!                                         Date   : Mai 2002! Fonction                                Modif  : (cf historique)!   Bibliotheque de procedures et fonctions pour le calcul geometrique 3D!! Defauts/Limitations/Divers :!!------------------------------------------------------------------------------!module GEO3Duse TYPHMAKEuse GEO2Duse STRING! -- DECLARATIONS -----------------------------------------------------------type v3d  real(krp) :: x, y, zendtype! -- INTERFACES -------------------------------------------------------------interface v3d_of  module procedure v3d_fromtab, v3d_fromv2d, v3d_fromstrendinterfaceinterface tab  module procedure tab_v3dendinterfaceinterface abs  module procedure v3d_normeendinterfaceinterface sqrabs  module procedure v3d_sqrnormeendinterfaceinterface operator(+)  module procedure v3d_add, v3d_add_tendinterfaceinterface operator(-)  module procedure v3d_sub, v3d_opp, v3d_sub_t, v3d_opp_tendinterfaceinterface operator(*)  module procedure v3d_mult, v3d_mult_t, v3d_mult_ttendinterface!interface assignment(*=)!  module procedure v3d_eq_mult, v3d_eq_mult_t, v3d_eq_mult_tt!endinterfaceinterface operator(/)  module procedure v3d_div, v3d_div_t, v3d_div_ttendinterfaceinterface operator(.scal.)  module procedure v3d_scalar_product, v3d_scalar_product_tendinterfaceinterface operator(.vect.)  module procedure v3d_vectorial_productendinterface! -- Fonctions et Operateurs ------------------------------------------------! -- IMPLEMENTATION ---------------------------------------------------------contains!------------------------------------------------------------------------------!! Fonction : transtypage real(1:3) -> v3d!------------------------------------------------------------------------------!type(v3d) function v3d_fromtab(tab)implicit nonereal(krp), dimension(3) :: tab  v3d_fromtab = v3d(tab(1), tab(2), tab(3))endfunction v3d_fromtab!------------------------------------------------------------------------------!! Fonction : transtypage v2d -> v3d!------------------------------------------------------------------------------!type(v3d) function v3d_fromv2d(v)implicit nonetype(v2d) :: v  v3d_fromv2d = v3d(v%x, v%y, 0._krp)endfunction v3d_fromv2d!------------------------------------------------------------------------------!! Fonction : transtypage v3d -> real(1:3)!------------------------------------------------------------------------------!function tab_v3d(v)implicit nonetype(v3d), intent(in)   :: vreal(krp), dimension(3) :: tab_v3d  tab_v3d(1:3) = (/ v%x, v%y, v%z /)endfunction tab_v3d!------------------------------------------------------------------------------!! Fonction : transtypage (avec traitement) string -> v3d!------------------------------------------------------------------------------!type(v3d) function v3d_fromstr(str, info)implicit nonecharacter(len=*), intent(in)  :: strinteger,          intent(out) :: infocharacter(len=len(str))       :: pstrinteger :: id, if  info = 0  id   = scan(str, '(')  if   = scan(str, ')')  pstr = chg_char(str(id+1:if-1),',',' ')   read(pstr,*,iostat=info) v3d_fromstr !%x, v3d_fromstr%z, v3d_fromstr%y  print*,"TEST STR->V3D",info,":", v3d_fromstrendfunction v3d_fromstr!------------------------------------------------------------------------------!! Fonction : vector add!------------------------------------------------------------------------------!type(v3d) function v3d_add(v1, v2)implicit nonetype(v3d), intent(in) :: v1, v2  v3d_add%x = v1%x + v2%x   v3d_add%y = v1%y + v2%y   v3d_add%z = v1%z + v2%z endfunction v3d_add!------------------------------------------------------------------------------!! Fonction : vector add (array)!------------------------------------------------------------------------------!function v3d_add_t(v1, v2) result(tv)implicit nonetype(v3d), dimension(:), intent(in) :: v1, v2type(v3d), dimension(size(v1))      :: tvinteger :: i, n  n = size(v1)  if (size(v2) /= n) stop  do i = 1, n    tv(i)%x = v1(i)%x + v2(i)%x     tv(i)%y = v1(i)%y + v2(i)%y     tv(i)%z = v1(i)%z + v2(i)%z   enddoendfunction v3d_add_t!------------------------------------------------------------------------------!! Fonction : vector sub!------------------------------------------------------------------------------!type(v3d) function v3d_sub(v1, v2)implicit nonetype(v3d), intent(in) :: v1, v2  v3d_sub%x = v1%x - v2%x   v3d_sub%y = v1%y - v2%y   v3d_sub%z = v1%z - v2%z endfunction v3d_sub!------------------------------------------------------------------------------!! Fonction : vector sub (array)!------------------------------------------------------------------------------!function v3d_sub_t(v1, v2) result(tv)implicit nonetype(v3d), dimension(:), intent(in) :: v1, v2type(v3d), dimension(size(v1))      :: tvinteger :: i, n  n = size(v1)  if (size(v2) /= n) stop  do i = 1, n    tv(i)%x = v1(i)%x - v2(i)%x     tv(i)%y = v1(i)%y - v2(i)%y     tv(i)%z = v1(i)%z - v2(i)%z   enddoendfunction v3d_sub_t!------------------------------------------------------------------------------!! Fonction : vector opposite!------------------------------------------------------------------------------!type(v3d) function v3d_opp(v)implicit nonetype(v3d), intent(in) :: v  v3d_opp%x = - v%x   v3d_opp%y = - v%y   v3d_opp%z = - v%z endfunction v3d_opp!------------------------------------------------------------------------------!! Fonction : vector opposite (array)!------------------------------------------------------------------------------!function v3d_opp_t(v) result(tv)implicit nonetype(v3d), dimension(:), intent(in) :: vtype(v3d), dimension(size(v))      :: tvinteger :: i  do i = 1, size(v)    tv(i)%x = - v(i)%x     tv(i)%y = - v(i)%y     tv(i)%z = - v(i)%z   enddoendfunction v3d_opp_t!------------------------------------------------------------------------------!! Fonction : vector multiplied par real!------------------------------------------------------------------------------!type(v3d) function v3d_mult(x, v)implicit nonereal(krp),   intent(in) :: xtype(v3d), intent(in) :: v  v3d_mult%x = x * v%x   v3d_mult%y = x * v%y   v3d_mult%z = x * v%z endfunction v3d_mult!------------------------------------------------------------------------------!! Assignment : vector v = a . v!------------------------------------------------------------------------------!subroutine v3d_eq_mult(v, a)implicit nonereal(krp), intent(in)    :: atype(v3d), intent(inout) :: v  v%x = a * v%x   v%y = a * v%y   v%z = a * v%z end subroutine v3d_eq_mult!------------------------------------------------------------------------------!! Fonction : vector multiplied par real (array)!------------------------------------------------------------------------------!function v3d_mult_t(x, v) result(tv)implicit nonereal(krp), intent(in) :: xtype(v3d), dimension(:), intent(in) :: vtype(v3d), dimension(size(v))       :: tvinteger :: i  do i = 1, size(v)    tv(i)%x = x * v(i)%x     tv(i)%y = x * v(i)%y     tv(i)%z = x * v(i)%z   enddoendfunction v3d_mult_t!------------------------------------------------------------------------------!! Assignment : v(:) = a . v(:)!------------------------------------------------------------------------------!subroutine v3d_eq_mult_t(v, a)implicit nonereal(krp), intent(in)    :: atype(v3d), intent(inout) :: v(:)integer :: i  do i = 1, size(v)    v(i)%x = a * v(i)%x     v(i)%y = a * v(i)%y     v(i)%z = a * v(i)%z   enddoend subroutine v3d_eq_mult_t!------------------------------------------------------------------------------!! Fonction : vector multiplied par real (array*array)!------------------------------------------------------------------------------!function v3d_mult_tt(x, v) result(tv)implicit nonereal(krp), dimension(:), intent(in) :: xtype(v3d), dimension(:), intent(in) :: vtype(v3d), dimension(size(v))       :: tvinteger :: i  do i = 1, size(v)    tv(i)%x = x(i) * v(i)%x     tv(i)%y = x(i) * v(i)%y     tv(i)%z = x(i) * v(i)%z   enddoendfunction v3d_mult_tt!------------------------------------------------------------------------------!! Assignment : v(:) = a(:) . v(:)!------------------------------------------------------------------------------!subroutine v3d_eq_mult_tt(v, a)implicit nonereal(krp), intent(in)    :: a(:)type(v3d), intent(inout) :: v(:)integer :: i  do i = 1, size(v)    v(i)%x = a(i) * v(i)%x     v(i)%y = a(i) * v(i)%y     v(i)%z = a(i) * v(i)%z   enddoend subroutine v3d_eq_mult_tt!------------------------------------------------------------------------------!! Fonction :  vector divided par real!------------------------------------------------------------------------------!type(v3d) function v3d_div(v,x)implicit nonereal(krp), intent(in) :: xtype(v3d), intent(in) :: v  v3d_div%x = v%x / x   ! DEV / a optimiser  v3d_div%y = v%y / x  v3d_div%z = v%z / x endfunction v3d_div!------------------------------------------------------------------------------!! Fonction : vector divided par real (array)!------------------------------------------------------------------------------!function v3d_div_t(x, v) result(tv)implicit nonereal(krp), intent(in) :: xtype(v3d), dimension(:), intent(in) :: vtype(v3d), dimension(size(v))       :: tvinteger :: i  do i = 1, size(v)    tv(i)%x = v(i)%x /x    tv(i)%y = v(i)%y /x    tv(i)%z = v(i)%z /x  enddoendfunction v3d_div_t!------------------------------------------------------------------------------!! Fonction : vector divided par real (array*array)!------------------------------------------------------------------------------!function v3d_div_tt(x, v) result(tv)implicit nonereal(krp), dimension(:), intent(in) :: xtype(v3d), dimension(:), intent(in) :: vtype(v3d), dimension(size(v))       :: tvinteger :: i  do i = 1, size(v)    tv(i)%x = v(i)%x /x(i)    tv(i)%y = v(i)%y /x(i)    tv(i)%z = v(i)%z /x(i)  enddoendfunction v3d_div_tt!------------------------------------------------------------------------------!! Fonction : vector magnitude!------------------------------------------------------------------------------!real(krp) function v3d_norme(v)implicit nonetype(v3d), intent(in) :: v  v3d_norme = sqrt(v%x*v%x + v%y*v%y + v%z*v%z)endfunction v3d_norme!------------------------------------------------------------------------------!! Fonction : square of norme magnitude!------------------------------------------------------------------------------!real(krp) function v3d_sqrnorme(v)implicit nonetype(v3d), intent(in) :: v  v3d_sqrnorme = v%x*v%x + v%y*v%y + v%z*v%zendfunction v3d_sqrnorme!------------------------------------------------------------------------------!! Fonction : dot product!------------------------------------------------------------------------------!real(krp) function v3d_scalar_product(v1, v2)implicit nonetype(v3d), intent(in) :: v1, v2  v3d_scalar_product = v1%x*v2%x + v1%y*v2%y + v1%z*v2%zendfunction v3d_scalar_product!------------------------------------------------------------------------------!! Fonction : dot product (array)!------------------------------------------------------------------------------!function v3d_scalar_product_t(v1, v2) result(tv)implicit nonetype(v3d), dimension(:), intent(in) :: v1, v2real(krp), dimension(size(v1))      :: tvinteger :: i, n  n = size(v1)  if (size(v2) /= n) stop  do i = 1, n    tv(i) = v1(i)%x*v2(i)%x + v1(i)%y*v2(i)%y + v1(i)%z*v2(i)%z  enddoendfunction v3d_scalar_product_t!------------------------------------------------------------------------------!! Fonction : produit vectoriel!------------------------------------------------------------------------------!type(v3d) function v3d_vectorial_product(v1, v2)implicit nonetype(v3d), intent(in) :: v1, v2  v3d_vectorial_product%x = v1%y*v2%z - v1%z*v2%y  v3d_vectorial_product%y = v1%z*v2%x - v1%x*v2%z  v3d_vectorial_product%z = v1%x*v2%y - v1%y*v2%xendfunction v3d_vectorial_productendmodule GEO3D!------------------------------------------------------------------------------!! Historique des modifications!! mai  2002 : creation du module! juil 2003 : compatibilite des operateurs toute precision!------------------------------------------------------------------------------!

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -