calculatenormal.F [SRC] [CPP] [JOB] [SCAN]
TOOLS / PREDATAS / GENERIC



   1 | include(dom.inc)
   2 |       SUBROUTINE calculatenormal(nb_nodes, nodelist, n1, n2, n3, norm)
   3 | 
   4 | !       ================================================================!
   5 | !                                                                       !
   6 | !       calculatenormal: Calculates the normal vector of a face         !
   7 | !                                                                       !
   8 | !       in             : The number of nodes of the face 'nb_nodes'     !
   9 | !                        The id list of the nodes 'nodelist'            !
  10 | !       out            : The normal composants ant it's norm            !
  11 | !                                                                       !
  12 | !       author         : J. AMAYA (avril 2007)                          !
  13 | !                                                                       !
  14 | !       ================================================================!
  15 | 
  16 |         USE datas
  17 |         IMPLICIT NONE
  18 | 
  19 | !       IN
  20 |         DOM_INT :: nb_nodes
  21 |         DOM_INT, DIMENSION(nb_nodes) :: nodelist
  22 | 
  23 | !       OUT
  24 |         DOM_REAL :: n1, n2, n3, norm
  25 | 
  26 | !       LOCAL
  27 |         DOM_REAL :: x1, y1, z1, x2, y2, z2, x3, y3, z3
  28 |         DOM_INT          :: ierr
  29 | 
  30 |         IF (nb_nodes.eq.2) THEN
  31 | !         -----------------------------------!
  32 | !         Capture nodes' coordinates (in 2D) !
  33 | !         -----------------------------------!
  34 | 
  35 |           x1 = node_list(1, nodelist(1))
  36 |           y1 = node_list(2, nodelist(1))
  37 |           z1 = node_list(3, nodelist(1))
  38 | 
  39 |           x2 = node_list(1, nodelist(2))
  40 |           y2 = node_list(2, nodelist(2))
  41 |           z2 = node_list(3, nodelist(2))
  42 | 
  43 | !         --------------------------------!
  44 | !         Compute the normal and its norm !
  45 | !         --------------------------------!
  46 | 
  47 |           n1 = y2 - y1
  48 |           n2 = x1 - x2
  49 |           n3 = 0.0d0
  50 | 
  51 |           norm = SQRT( n1*n1 + n2*n2 )
  52 |           n1 = n1 / norm
  53 |           n2 = n2 / norm
  54 |           n3 = n3 / norm
  55 | 
  56 |         ELSE
  57 | !         ----------------------------------------------------!
  58 | !         Capture nodes' coordinates (works for tri and quad) !
  59 | !         ----------------------------------------------------!
  60 |           x1 = node_list(1, nodelist(1))
  61 |           y1 = node_list(2, nodelist(1))
  62 |           z1 = node_list(3, nodelist(1))
  63 | 
  64 |           x2 = node_list(1, nodelist(2))
  65 |           y2 = node_list(2, nodelist(2))
  66 |           z2 = node_list(3, nodelist(2))
  67 | 
  68 |           x3 = node_list(1, nodelist(3))
  69 |           y3 = node_list(2, nodelist(3))
  70 |           z3 = node_list(3, nodelist(3))
  71 | 
  72 | !         --------------------------------!
  73 | !         Compute the normal and its norm !
  74 | !         --------------------------------!
  75 |           n1 = ((y2-y1)*(z3-z1)) - ((y3-y1)*(z2-z1))
  76 |           n2 = ((z2-z1)*(x3-x1)) - ((z3-z1)*(x2-x1))
  77 |           n3 = ((x2-x1)*(y3-y1)) - ((y2-y1)*(x3-x1))
  78 | !          print*, n1, n2, n3
  79 | 
  80 |           norm = SQRT( n1*n1 + n2*n2 + n3*n3 )
  81 |           n1 = n1 / norm
  82 |           n2 = n2 / norm
  83 |           n3 = n3 / norm
  84 | 
  85 |         ENDIF
  86 | 
  87 |       END SUBROUTINE calculatenormal


calculatenormal.F could be called by:
addface.F [TOOLS/PREDATAS/DATAS] - 117
Makefile [TOOLS/PREDATAS] - 81