c@a
c@versb
C-----------------------------------------------------------------------
C
CVERS                  Code_Saturne version 1.3
C                      ------------------------
C
C     This file is part of the Code_Saturne Kernel, element of the
C     Code_Saturne CFD tool.
C 
C     Copyright (C) 1998-2007 EDF S.A., France
C
C     contact: saturne-support@edf.fr
C 
C     The Code_Saturne Kernel is free software; you can redistribute it
C     and/or modify it under the terms of the GNU General Public License
C     as published by the Free Software Foundation; either version 2 of
C     the License, or (at your option) any later version.
C 
C     The Code_Saturne Kernel is distributed in the hope that it will be
C     useful, but WITHOUT ANY WARRANTY; without even the implied warranty
C     of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
C     GNU General Public License for more details.
C 
C     You should have received a copy of the GNU General Public License
C     along with the Code_Saturne Kernel; if not, write to the
C     Free Software Foundation, Inc.,
C     51 Franklin St, Fifth Floor,
C     Boston, MA  02110-1301  USA
C
C-----------------------------------------------------------------------
c@verse
                        SUBROUTINE FILTRE
C                       *****************
C     -------------------------------------------------------------
     & ( NCELET , NCEL   , NFAC   , NFABOR ,
     &   IFACEL , IFABOR , IPCVSE, IELVSE ,
     &   VOLUME ,
     &   VAR    , VARFIL , W1     , W2    )
C     -------------------------------------------------------------
C***********************************************************************
C FONCTION :
C --------
c@foncb
CFONC
CFONC FILTRAGE DE LA VARIABLE VAR  PAR UN FILTRE EXPLICITE
CFONC LE RESULTAT EST DANS LA VARIABLE VARFIL
CFONC
c@fonce
C                             ARGUMENTS
c@argub
CARGU .______________.____._____.______________________________________.
CARGU !    NOM       !TYPE!MODE !                   ROLE               !
CARGU !______________!____!_____!______________________________________!
CARGU ! NCELET       ! E  !  -> ! NOMBRE D'ELEMENTS HALO COMPRIS       !
CARGU ! NCEL         ! E  !  -> ! NOMBRE D'ELEMENTS ACTIFS             !
CARGU ! NFAC         ! E  !  -> ! NOMBRE DE FACES INTERNES             !
CARGU ! NFABOR       ! E  !  -> ! NOMBRE DE FACES DE BORD              !
CARGU ! IFACEL       ! TE !  -> ! ELEMENTS VOISINS D'UNE FACE INTERNE  !
CARGU ! (2, NFAC)    !    !     !                                      !
CARGU ! IFABOR       ! TE !  -> ! ELEMENT  VOISIN  D'UNE FACE DE BORD  !
CARGU ! (NFABOR)     !    !     !                                      !
CARGU ! IPCVSE       ! TE !  -> ! POSITION DANS IELVSE DES VOISINS     !
CARGU ! (NCEL  )     !    !     !  ETENDUS DES CELLULES                !
CARGU ! IELVSE (*)   ! TE !  -> ! NUMERO DES VOISINS ETENDUS DES CELLUL!
CARGU ! VOLUME       ! TR !  -> ! VOLUME D'UN DES NCELET ELEMENTS      !
CARGU ! (NCELET      !    !     !                                      !
CARGU ! VAR(NCELET)  ! TR ! <-> ! VARIABLE A FILTRER                   !
CARGU ! VARFIL(NCELET! TR ! <-> ! TABLEAU DE TRAVAIL                   !
CARGU ! W1, W2(NCELET! TR !  -  ! TABLEAU DE TRAVAIL                   !
CARGU !______________!____!_____!______________________________________!
c@argue
C
c@commb
CCOMM                             COMMONS
CCOMM .______________.____._____.______________________________________.
CCOMM !    NOM       !TYPE!MODE !                   ROLE               !
CCOMM !______________!____!_____!______________________________________!
CCOMM !______________!____!_____!______________________________________!
c@comme
C
C     TYPE : E (ENTIER), R (REEL), A (ALPHANUMERIQUE), T (TABLEAU)
C            L (LOGIQUE)   .. ET TYPES COMPOSES (EX : TR TABLEAU REEL)
C     MODE : -> DONNEE, <- RESULTAT, <-> DONNEE MODIFIEE,
C            - TABLEAU DE TRAVAIL
C***********************************************************************
C
      IMPLICIT NONE
C
C***********************************************************************
C     DONNEES EN COMMON
C***********************************************************************
C
      INCLUDE "paramx.h"
      INCLUDE "pointe.h"
      INCLUDE "vector.h"
      INCLUDE "entsor.h"
      INCLUDE "period.h"
      INCLUDE "parall.h"
C
C***********************************************************************
C
      INTEGER          NCELET , NCEL   , NFAC   , NFABOR
      INTEGER          IFACEL(2,NFAC) , IFABOR(NFABOR)
      INTEGER          IPCVSE(*), IELVSE(*)
C
      DOUBLE PRECISION VOLUME(*)
      DOUBLE PRECISION VAR(*), VARFIL(NCELET)
      DOUBLE PRECISION W1(NCELET),W2(NCELET)
C
C VARIABLES LOCALES
C
      INTEGER          IEL, JEL, IFAC, IPOS
      INTEGER          IDIMTE, ITENSO
C
C***********************************************************************
C
C=======================================================================
C 1.  INITIALISATIONS
C=======================================================================
C
C
      IF(IRANGP.GE.0) CALL PARCOM (VAR)
C
      IF(IPERIO.EQ.1) THEN
        IDIMTE = 0
        ITENSO = 0
        CALL PERCOM
C       ===========
     &  ( IDIMTE , ITENSO ,
     &    VAR    , VAR    , VAR   ,
     &    VAR    , VAR    , VAR   ,
     &    VAR    , VAR    , VAR            )
      ENDIF
C
      DO IEL = 1, NCEL
        W1(IEL) = 0.D0
        W2(IEL) = 0.D0
      ENDDO
C
      DO IEL = 1, NCEL
        W1(IEL) = W1(IEL) + VAR(IEL) * VOLUME(IEL)
        W2(IEL) = W2(IEL) + VOLUME(IEL)
        DO IPOS = IPCVSE(IEL), IPCVSE(IEL+1)-1
          JEL = IELVSE(IPOS)
          W1(IEL) = W1(IEL) + VAR(JEL) * VOLUME(JEL)
          W2(IEL) = W2(IEL) + VOLUME(JEL)
        ENDDO
      ENDDO
C
      DO IFAC = 1, NFAC
        IEL = IFACEL(1,IFAC)
        JEL = IFACEL(2,IFAC)
        W1(IEL) = W1(IEL) + VAR(JEL) * VOLUME(JEL)
        W2(IEL) = W2(IEL) + VOLUME(JEL)
        W1(JEL) = W1(JEL) + VAR(IEL) * VOLUME(IEL)
        W2(JEL) = W2(JEL) + VOLUME(IEL)
      ENDDO
C
      DO IEL = 1, NCEL
        VARFIL(IEL) = W1(IEL) / W2(IEL)
      ENDDO
C
      IF(IRANGP.GE.0) CALL PARCOM (VARFIL)
C
      IF(IPERIO.EQ.1) THEN
        IDIMTE = 0
        ITENSO = 0
        CALL PERCOM
C       ===========
     &  ( IDIMTE , ITENSO ,
     &    VARFIL , VARFIL , VARFIL,
     &    VARFIL , VARFIL , VARFIL,
     &    VARFIL , VARFIL , VARFIL         )
      ENDIF
C
      RETURN
      END
c@z
