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

Merge branch 'revisions' of geraldine.fjfi.cvut.cz:/local/projects/tnl/tnl into revisions

Conflicts:
	src/functions/tnlOperatorFunction.h
	src/operators/tnlFunctionInverseOperator.h
	src/operators/tnlOperator.h
	src/operators/tnlOperatorComposition.h
	tests/unit-tests/operators/diffusion/CMakeLists.txt
parents fcfcea32 dbb56ebf
Loading
Loading
Loading
Loading
+94 −0
Original line number Diff line number Diff line
/***************************************************************************
                          tnlExactMeanCurvature.h  -  description
                             -------------------
    begin                : Feb 18, 2016
    copyright            : (C) 2016 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 TNLEXACTMEANCURVATURE_H
#define	TNLEXACTMEANCURVATURE_H

#include<operators/diffusion/tnlExactNonlinearDiffusion.h>
#include<operators/tnlExactFunctionInverseOperator.h>
#include<operators/geometric/tnlExactGradientNorm.h>

template< int Dimensions,
          typename Real >
class tnlExactMeanCurvature
{
   public:
      
      typedef tnlExactGradientNorm< Dimensions, Real > ExactGradientNorm;
      typedef tnlExactFunctionInverseOperator< Dimensions, Real > FunctionInverse;
      typedef tnlExactNonlinearDiffusion< Dimensions, Real > NonlinearDiffusion;
      
      typedef typename OperatorType::RealType RealType;
      
      static tnlString getType()
      {
         return tnlString( "tnlExactMeanCurvature< " ) + 
                tnlString( Dimensions) + ", " +
                RealType::getType() + " >";         
      }
      
      template< typename Function >
      __cuda_callable__
      typename Function::RealType 
         operator()( const Function& function,
                     const typename Function::VertexType& v, 
                     const typename Function::RealType& time = 0.0 ) const
      {
         return this->nonlinearDiffusion( this->functionInverse( this->gradientNorm( function( v, time ) ) ) );
      }
      
      template< typename Function, 
                int XDerivative = 0,
                int YDerivative = 0,
                int ZDerivative = 0 >
      __cuda_callable__
      typename Function::RealType
         getPartialDerivative( const Function& function,
                               const typename Function::VertexType& v,
                               const typename Function::RealType& time = 0.0 ) const
      {
         static_assert( XDerivative >= 0 && YDerivative >= 0 && ZDerivative >= 0,
            "Partial derivative must be non-negative integer." );
         static_assert( XDerivative + YDerivative + ZDerivative < 1, "Partial derivative of higher order then 1 are not implemented yet." );
         typedef typename Function::RealType RealType;
         
         if( XDerivative == 1 )
         {
         }
         if( YDerivative == 1 )
         {
         }
         if( ZDerivative == 1 )
         {
         }         
      }
      
      
   protected:
      
      ExactGradientNorm gradientNorm;
      
      FunctionInverse functionInverse;
      
      NonlinearDiffusion nonlinearDiffusion;
      
};


#endif	/* TNLEXACTMEANCURVATURE_H */
+3 −0
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@
#include <operators/diffusion/tnlOneSidedNonlinearDiffusion.h>
#include <functions/tnlOperatorFunction.h>
#include <functions/tnlConstantFunction.h>
#include <operators/diffusion/tnlExactMeanCurvature.h>


template< typename Mesh,
          typename Real = typename Mesh::RealType,
@@ -45,6 +47,7 @@ class tnlOneSidedMeanCurvature
      typedef tnlNeumannBoundaryConditions< MeshType, NonlinearityBoundaryConditionsFunction > NonlinearityBoundaryConditions;
      typedef tnlOperatorFunction< NonlinearityOperator, NonlinearityMeshFunction, NonlinearityBoundaryConditions, EvaluateNonlinearityOnFly > Nonlinearity;
      typedef tnlOneSidedNonlinearDiffusion< Mesh, Nonlinearity, RealType, IndexType > NonlinearDiffusion;
      typedef tnlExactMeanCurvature< Mesh::getMeshDimensions(), RealType > ExactOperatorType;
      
      tnlOneSidedMeanCurvature()
      : nonlinearity( gradientNorm, nonlinearityBoundaryConditions ),
+92 −0
Original line number Diff line number Diff line
/***************************************************************************
                          tnlExactFunctionInverseOperator.h  -  description
                             -------------------
    begin                : Feb 17, 2016
    copyright            : (C) 2016 by 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 TNLEXACTFUNCTIONINVERSEOPERATOR_H
#define	TNLEXACTFUNCTIONINVERSEOPERATOR_H

#include <core/tnlString.h>
#include <core/tnlCuda.h>
#include <operators/tnlOperator.h>

template< int Dimensions,
          typename Real >
class tnlExactFunctionInverseOperator
   : public tnlDomain< Dimensions, SpaceDomain >
{
   public:
     
      typedef Real RealType;
      
      static tnlString getType()
      {
         return tnlString( "tnlExactFunctionInverseOperator< " ) + 
                tnlString( Dimensions) + ", " +
                RealType::getType() + " >";         
      }
      
      template< typename Function >
      __cuda_callable__
      typename Function::RealType 
         operator()( const Function& function,
                     const typename Function::VertexType& v, 
                     const typename Function::RealType& time = 0.0 ) const
      {
         typedef typename Function::RealType RealType;
         return 1.0 / function( v, time );
      }
      
      template< typename Function, 
                int XDerivative = 0,
                int YDerivative = 0,
                int ZDerivative = 0 >
      __cuda_callable__
      typename Function::RealType
         getPartialDerivative( const Function& function,
                               const typename Function::VertexType& v,
                               const typename Function::RealType& time = 0.0 ) const
      {
         static_assert( XDerivative >= 0 && YDerivative >= 0 && ZDerivative >= 0,
            "Partial derivative must be non-negative integer." );
         static_assert( XDerivative + YDerivative + ZDerivative < 2, "Partial derivative of higher order then 1 are not implemented yet." );
         typedef typename Function::RealType RealType;
         
         if( XDerivative == 1 )
         {
            const RealType f = function( v, time );
            const RealType f_x = function.template getPartialDerivative< 1, 0, 0 >( v, time );
            return -f_x / ( f * f );
         }
         if( YDerivative == 1 )
         {
            const RealType f = function( v, time );
            const RealType f_y = function.template getPartialDerivative< 0, 1, 0 >( v, time );
            return -f_y / ( f * f );            
         }
         if( ZDerivative == 1 )
         {
            const RealType f = function( v, time );
            const RealType f_z = function.template getPartialDerivative< 0, 0, 1 >( v, time );
            return -f_z / ( f * f );            
         }         
      }

};



#endif	/* TNLEXACTFUNCTIONINVERSEOPERATOR_H */
+44 −0
Original line number Diff line number Diff line
/***************************************************************************
                          tnlExactOperatorComposition.h  -  description
                             -------------------
    begin                : Feb 17, 2016
    copyright            : (C) 2016 by 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 TNLEXACTOPERATORCOMPOSITION_H
#define TNLEXACTOPERATORCOMPOSITION_H

template< typename OuterOperator,
          typename InnerOperator >
class tnlExactOperatorComposition
{
   public:
      
      template< typename Function >
      __cuda_callable__ inline
      typename Function::RealType operator()( const Function& function,
                                              const typename Function::VertexType& v,
                                              const typename Function::RealType& time = 0.0 ) const
      {
         return OuterOperator( innerOperator( function, v, time), v, time );
      }
      
   protected:
      
      InnerOperator innerOperator;
      
      OuterOperator outerOperator;
};

#endif /* TNLEXACTOPERATORCOMPOSITION_H */
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ class tnlOperator : public tnlDomain< Mesh::getMeshDimensions(), DomainType >
      typedef typename MeshType::IndexType MeshIndexType;
      typedef Real RealType;
      typedef Index IndexType;
      typedef void ExactOperatorType;
      
      constexpr static int getMeshDimensions() { return MeshType::getMeshDimensions(); }
      constexpr static int getPreimageEntitiesDimensions() { return PreimageEntitiesDimensions; }
Loading