Skip to content
Snippets Groups Projects
tnlExplicitUpdater.h 4.95 KiB
Newer Older
  • Learn to ignore specific revisions
  • /***************************************************************************
                              tnlExplicitUpdater.h  -  description
                                 -------------------
        begin                : Jul 29, 2014
        copyright            : (C) 2014 by Tomas Oberhuber
        email                : tomas.oberhuber@fjfi.cvut.cz
     ***************************************************************************/
    
    /***************************************************************************
     *                                                                         *
     *   This program is free software; you can redistribute it and/or modify  *
     *   it under the terms of the GNU General Public License as published by  *
     *   the Free Software Foundation; either version 2 of the License, or     *
     *   (at your option) any later version.                                   *
     *                                                                         *
     ***************************************************************************/
    
    #ifndef TNLEXPLICITUPDATER_H_
    #define TNLEXPLICITUPDATER_H_
    
    
    #include <functions/tnlFunctionAdapter.h>
    
    template< typename Real,
              typename DofVector,
    
              typename DifferentialOperator,
    
              typename BoundaryConditions,
    
              typename RightHandSide >
    
    class tnlExplicitUpdaterTraverserUserData
    
          const Real *time;
    
          const DifferentialOperator* differentialOperator;
    
          const BoundaryConditions* boundaryConditions;
    
          const RightHandSide* rightHandSide;
    
          DofVector *u, *fu;
    
          tnlExplicitUpdaterTraverserUserData( const Real& time,
    
                                               const DifferentialOperator& differentialOperator,
                                               const BoundaryConditions& boundaryConditions,
                                               const RightHandSide& rightHandSide,
    
                                               DofVector& u,
                                               DofVector& fu )
    
          : time( &time ),
            differentialOperator( &differentialOperator ),
            boundaryConditions( &boundaryConditions ),
            rightHandSide( &rightHandSide ),
            u( &u ),
            fu( &fu )
    
    template< typename Mesh,
              typename DofVector,
    
              typename DifferentialOperator,
    
              typename BoundaryConditions,
    
              typename RightHandSide >
    
    class tnlExplicitUpdater
    {
       public:
          typedef Mesh MeshType;
          typedef typename DofVector::RealType RealType;
          typedef typename DofVector::DeviceType DeviceType;
          typedef typename DofVector::IndexType IndexType;
    
          typedef tnlExplicitUpdaterTraverserUserData< RealType,
    
                                                       DifferentialOperator,
    
                                                       RightHandSide > TraverserUserData;
    
          template< typename EntityType >
    
          void update( const RealType& time,
                       const MeshType& mesh,
    
                       const DifferentialOperator& differentialOperator,
                       const BoundaryConditions& boundaryConditions,
                       const RightHandSide& rightHandSide,
    
                       DofVector& fu ) const;      
          
                class TraverserBoundaryEntitiesProcessor
    
                template< typename GridEntity >
    
    Tomáš Oberhuber's avatar
    Tomáš Oberhuber committed
                __cuda_callable__
    
                static inline void processEntity( const MeshType& mesh,
                                                  TraverserUserData& userData,
                                                  const GridEntity& entity )
    
    Tomáš Oberhuber's avatar
    Tomáš Oberhuber committed
                {
    
                   ( *userData.u )[ entity.getIndex() ] = userData.boundaryConditions->getValue
                   ( entity,
    
                     *userData.u,
                     *userData.time );
    
    Tomáš Oberhuber's avatar
    Tomáš Oberhuber committed
                }
    
          class TraverserInteriorEntitiesProcessor
    
    Tomáš Oberhuber's avatar
    Tomáš Oberhuber committed
                typedef typename MeshType::VertexType VertexType;
             
    
                template< typename EntityType >
    
    Tomáš Oberhuber's avatar
    Tomáš Oberhuber committed
                __cuda_callable__
    
                static inline void processEntity( const MeshType& mesh,
                                                  TraverserUserData& userData,
                                                  const EntityType& entity )
    
                   ( *userData.fu)[ entity.getIndex() ] = 
    
                      userData.differentialOperator->getValue(
                         entity,
                         *userData.u,
                         *userData.time );
    
    Tomáš Oberhuber's avatar
    Tomáš Oberhuber committed
    
                   typedef tnlFunctionAdapter< MeshType, RightHandSide > FunctionAdapter;
    
                   ( * userData.fu )[ entity.getIndex() ] += 
    
                      FunctionAdapter::getValue(
                         *userData.rightHandSide,
                         entity,
    
                         *userData.time );
    
    #include <solvers/pde/tnlExplicitUpdater_impl.h>
    
    #endif /* TNLEXPLICITUPDATER_H_ */