Commit cc518b8f authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Implementing one sided non-linear diffusion.

parent da06e86c
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -92,6 +92,10 @@ class tnlOperatorFunction< Operator, MeshFunction, void, true >
      
      void setPreimageFunction( const FunctionType& preimageFunction ) { this->preimageFunction = &preimageFunction; }
      
      Operator& getOperator() { return this->operator_; }
      
      const Operator& getOperator() const { return this->operator_; }
      
      bool refresh( const RealType& time = 0.0 ) { return true; };
      
      bool deepRefresh( const RealType& time = 0.0 ) { return true; };
@@ -167,6 +171,10 @@ class tnlOperatorFunction< Operator, PreimageFunction, void, false >
      
      const PreimageFunctionType& getPreimageFunction() const { return *this->preimageFunction; };
      
      Operator& getOperator() { return this->operator_; }
      
      const Operator& getOperator() const { return this->operator_; }

      bool refresh( const RealType& time = 0.0 )
      {
         OperatorFunction operatorFunction( this->operator_, *preimageFunction );         
@@ -285,6 +293,10 @@ class tnlOperatorFunction< Operator, PreimageFunction, BoundaryConditions, false
      
      ImageFunctionType& getImageFunction() { return this->imageFunction; };
      
      Operator& getOperator() { return this->operator_; }
      
      const Operator& getOperator() const { return this->operator_; }

      bool refresh( const RealType& time = 0.0 )
      {
         OperatorFunction operatorFunction( this->operator_, *this->preimageFunction );
+0 −178
Original line number Diff line number Diff line
#ifndef TNLNONLINEARDIFFUSION_H
#define	TNLNONLINEARDIFFUSION_H

#include <core/vectors/tnlVector.h>
#include <mesh/tnlGrid.h>

template< typename Mesh,
          typename NonlinearDiffusionOperator,
          typename Real = typename Mesh::RealType,
          typename Index = typename Mesh::IndexType >
class tnlNonlinearDiffusion
{
 
};


template< typename MeshReal,
          typename Device,
          typename MeshIndex,
          typename Real,
          typename Index,
          typename NonlinearDiffusionOperator >
class tnlNonlinearDiffusion< tnlGrid< 1,MeshReal, Device, MeshIndex >, NonlinearDiffusionOperator, Real, Index >
{
   public: 
   
      typedef tnlGrid< 1, MeshReal, Device, MeshIndex > MeshType;
      typedef typename MeshType::CoordinatesType CoordinatesType;
      typedef Real RealType;
      typedef Device DeviceType;
      typedef Index IndexType;
      typedef NonlinearDiffusionOperator NonlinearDiffusionOperatorType;
      typedef typename MeshType::template MeshEntity< MeshType::meshDimensions > CellType;

      static tnlString getType();

      template< typename MeshEntity,
                typename Vector >
      __cuda_callable__
      Real operator()( const MeshEntity& entity,
                       const Vector& u,
                       const RealType& time) const;

      template< typename MeshEntity >
      __cuda_callable__
      Index getLinearSystemRowLength( const MeshType& mesh,
                                      const IndexType& index,
                                      const MeshEntity& entity ) const;

      template< typename MeshEntity,
                typename MeshFunction,
                typename Vector,
                typename Matrix >
      __cuda_callable__
      void updateLinearSystem( const RealType& time,
                               const RealType& tau,
                               const MeshType& mesh,
                               const IndexType& index,
                               const MeshEntity& entity,
                               const MeshFunction& u,
                               Vector& b,
                               Matrix& matrix ) const;

   public:
       
      NonlinearDiffusionOperator nonlinearDiffusionOperator;
};


template< typename MeshReal,
          typename Device,
          typename MeshIndex,
          typename Real,
          typename Index,
          typename NonlinearDiffusionOperator >
class tnlNonlinearDiffusion< tnlGrid< 2, MeshReal, Device, MeshIndex >, NonlinearDiffusionOperator, Real, Index >
{
   public: 
   
      typedef tnlGrid< 2, MeshReal, Device, MeshIndex > MeshType;
      typedef typename MeshType::CoordinatesType CoordinatesType;
      typedef Real RealType;
      typedef Device DeviceType;
      typedef Index IndexType;
      typedef NonlinearDiffusionOperator NonlinearDiffusionOperatorType;


      static tnlString getType();

      template< typename MeshEntity,
                typename Vector >
      __cuda_callable__
      Real operator()( const MeshEntity& entity,
                       const Vector& u,
                       const RealType& time) const;

      template< typename MeshEntity >
      __cuda_callable__
      Index getLinearSystemRowLength( const MeshType& mesh,
                                      const IndexType& index,
                                      const MeshEntity& entity ) const;

      template< typename MeshEntity,
                typename MeshFunction,
                typename Vector,
                typename Matrix >
      __cuda_callable__
      void updateLinearSystem( const RealType& time,
                               const RealType& tau,
                               const MeshType& mesh,
                               const IndexType& index,
                               const MeshEntity& entity,
                               const MeshFunction& u,
                               Vector& b,
                               Matrix& matrix ) const;
   
   public:
       
      NonlinearDiffusionOperator nonlinearDiffusionOperator;
};


template< typename MeshReal,
          typename Device,
          typename MeshIndex,
          typename Real,
          typename Index,
          typename NonlinearDiffusionOperator >
class tnlNonlinearDiffusion< tnlGrid< 3, MeshReal, Device, MeshIndex >, NonlinearDiffusionOperator, Real, Index >
{
   public: 
   
      typedef tnlGrid< 3, MeshReal, Device, MeshIndex > MeshType;
      typedef typename MeshType::CoordinatesType CoordinatesType;
      typedef Real RealType;
      typedef Device DeviceType;
      typedef Index IndexType;
      typedef NonlinearDiffusionOperator NonlinearDiffusionOperatorType;

      static tnlString getType();

      template< typename MeshEntity,
                typename MeshFunction >
      __cuda_callable__
      Real operator()( const MeshEntity& entity,
                       const MeshFunction& u,
                       const RealType& time) const;

      template< typename MeshEntity >
      __cuda_callable__
      Index getLinearSystemRowLength( const MeshType& mesh,
                                      const IndexType& index,
                                      const MeshEntity& entity ) const;

      template< typename MeshEntity,
                typename MeshFunction,
                typename Vector,                
                typename Matrix >
      __cuda_callable__
      void updateLinearSystem( const RealType& time,
                               const RealType& tau,
                               const MeshType& mesh,
                               const IndexType& index,
                               const MeshEntity& entity,
                               const MeshFunction& u,
                               Vector& b,
                               Matrix& matrix ) const;
     
   public:
       
      NonlinearDiffusionOperator nonlinearDiffusionOperator;
};


#include "tnlNonlinearDiffusion_impl.h"


#endif	/* TNLNONLINEARDIFFUSION_H */
+380 −0

File added.

Preview size limit exceeded, changes collapsed.

+5 −0
Original line number Diff line number Diff line
@@ -71,6 +71,11 @@ class tnlCoFVMGradientNorm< tnlGrid< MeshDimensions, MeshReal, Device, MeshIndex
            ::getType< Index >() + " >";
      }
      
      void setEps( const RealType& eps )
      {
         this->getInnerOperator().setEps( eps );
      }
      
      static constexpr int getPreimageEntitiesDimensions() { return MeshDimensions; };
      static constexpr int getImageEntitiesDimensions() { return MeshDimensions; };

+10 −2
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ class tnlOperatorComposition
      static constexpr int getPreimageEntitiesDimensions() { return InnerOperator::getImageEntitiesDimensions(); };
      static constexpr int getImageEntitiesDimensions() { return OuterOperator::getImageEntitiesDimensions(); };
      
      tnlOperatorComposition( const OuterOperator& outerOperator,
      tnlOperatorComposition( OuterOperator& outerOperator,
                              InnerOperator& innerOperator,
                              const InnerBoundaryConditions& innerBoundaryConditions,
                              const MeshType& mesh )
@@ -72,6 +72,14 @@ class tnlOperatorComposition
         return this->innerOperatorFunction.getPreimageFunction();
      }      
      
      InnerOperator& getInnerOperator() { return this->innerOperatorFunction.getOperator(); }
      
      const InnerOperator& getInnerOperator() const { return this->innerOperatorFunction.getOperator(); }
      
      OuterOperator& getOuterOperator() { return this->outerOperator(); };
      
      const OuterOperator& getOuterOperator() const { return this->outerOperator(); };
      
      bool refresh( const RealType& time = 0.0 )
      {
         return this->innerOperatorFunction.refresh( time );
@@ -97,7 +105,7 @@ class tnlOperatorComposition
   
   protected:
      
      const OuterOperator& outerOperator;
      OuterOperator& outerOperator;
      
      InnerOperatorFunction innerOperatorFunction;      
};
Loading