Ignore:
Timestamp:
07/09/12 15:23:38 (12 years ago)
Author:
ymipsl
Message:

Update on 3D dynamic

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • codes/icosagcm/trunk/src/spherical_geom.f90

    r13 r15  
    7878 
    7979  REAL(rstd)  :: AB,AC,BC 
    80   REAL(rstd)  :: s 
     80  REAL(rstd)  :: s,x 
    8181   
    8282  CALL dist_cart(A,B,AB) 
     
    8585   
    8686  s=(AB+AC+BC)/2 
    87   surf=4*atan(sqrt( tan(s/2) * tan((s-AB)/2)  * tan((s-AC)/2) * tan((s-BC)/2))) 
     87  x=tan(s/2) * tan((s-AB)/2)  * tan((s-AC)/2) * tan((s-BC)/2) 
     88  IF (x<0) x=0. 
     89  surf=4*atan(sqrt( x)) 
    8890   
    8991END SUBROUTINE surf_triangle  
     
    142144 
    143145 
    144   SUBROUTINE circonscrit(A0,B0,C0,Center) 
     146  SUBROUTINE circumcenter(A0,B0,C0,Center) 
    145147  USE vector 
    146148  IMPLICIT NONE 
     
    157159    center=center/sqrt(sum(center**2)) 
    158160     
    159   END SUBROUTINE circonscrit 
     161  END SUBROUTINE circumcenter 
    160162     
    161163 
    162   SUBROUTINE centroide(A,B,C,Center) 
     164  SUBROUTINE compute_centroid(points,n,centr) 
     165  USE vector 
    163166  IMPLICIT NONE 
    164     REAL(rstd), INTENT(IN)  :: A(3),B(3),C(3) 
    165     REAL(rstd), INTENT(OUT) :: Center(3) 
     167    INTEGER :: n 
     168    REAL(rstd), INTENT(IN)  :: points(3,n) 
     169    REAL(rstd), INTENT(OUT) :: Centr(3) 
     170     
     171    REAL(rstd) :: p1(3),p2(3),cross(3) 
     172    REAL(rstd) :: norm_cross 
     173    INTEGER :: i,j 
     174       
     175      Centr(:)=0 
     176      DO i=1,n 
     177        j=MOD(i,n)+1 
     178        p1=points(:,i)/norm(points(:,i)) 
     179        p2=points(:,j)/norm(points(:,j)) 
     180        CALL cross_product2(p1,p2,cross) 
     181        norm_cross=norm(cross) 
     182        if (norm_cross<1e-10) CYCLE  
     183         
     184        Centr(:)=centr(:)+asin(norm_cross)*cross(:)/norm_cross 
     185      ENDDO 
     186       
     187      Centr(:)=centr(:)/norm(centr(:)) 
    166188   
    167     REAL(rstd)  :: AB05(3),AC05(3),BC05(3) 
    168     REAL(rstd)  :: Vab(3),Vbc(3),Vca(3) 
    169     REAL(rstd)  :: t 
    170     INTEGER :: n1,n2 
    171         
    172     AB05=(A+B)/2. 
    173     AC05=(A+C)/2. 
    174     BC05=(B+C)/2. 
    175      
    176     CALL director(A,B,C,Vab) 
    177 !    PRINT *,'director',sum((B-A)*Vab) 
    178     CALL director(B,C,A,Vbc) 
    179 !    PRINT *,'director',sum((C-B)*Vbc) 
    180     CALL director(C,A,B,Vca) 
    181 !    PRINT *,'director',sum((A-C)*Vca) 
    182     
    183     n1=1 ; n2=2 
    184      
    185     t=(Vbc(n1)*(BC05(n2)-AB05(n2))+(AB05(n1)-BC05(n1))*Vbc(n2))/(Vbc(n1)*Vab(n2)-Vab(n1)*Vbc(n2)) 
    186     Center=AB05+t*Vab 
    187     Center=Center/sqrt(sum(Center**2)) 
    188 !    PRINT*,"Center :",A 
    189 !    PRINT*,"Center :",B 
    190 !    PRINT*,"Center :",C 
    191 !    PRINT*,"Center :",Center 
    192     
    193   CONTAINS  
    194    
    195     SUBROUTINE director(A,B,C,V) 
    196     IMPLICIT NONE 
    197     REAL(rstd), INTENT(IN)  :: A(3),B(3),C(3) 
    198     REAL(rstd), INTENT(OUT) :: V(3) 
    199     REAL(rstd) :: AB(3),AC(3) 
    200     REAL(rstd) :: t 
    201      
    202       AB=B-A 
    203       AC=C-A 
    204      
    205       t=sum(AB*AC)/sum(AB**2) 
    206       V=AB*t-AC 
    207     END SUBROUTINE director 
    208         
    209   END SUBROUTINE centroide 
     189  END SUBROUTINE compute_centroid 
    210190 
    211191END MODULE spherical_geom_mod 
Note: See TracChangeset for help on using the changeset viewer.