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

Refactorin the heat equation.

parent ead2c37f
Loading
Loading
Loading
Loading
+2 −23
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#define HEATEQUATIONCONFIG_H_

#include <config/tnlConfigDescription.h>
#include <functions/tnlTestFunction.h>

template< typename ConfigTag >
class heatEquationConfig
@@ -30,29 +31,7 @@ class heatEquationConfig
         config.addDelimiter( "Tests setting::" );
         config.addEntry     < bool >( "approximation-test", "Test of the Laplace operator approximation.", false );
         config.addEntry     < bool >( "eoc-test", "Test of the numerical scheme convergence.", false );
         config.addEntry     < tnlString >( "test-function", "Testing function.", "sin-wave" );
            config.addEntryEnum( "sin-wave" );
            config.addEntryEnum( "sin-bumps" );
            config.addEntryEnum( "exp-bump" );
         config.addEntry     < double >( "wave-length", "Wave length of the sine based test functions.", 1.0 );
         config.addEntry     < double >( "wave-length-x", "Wave length of the sine based test functions.", 1.0 );
         config.addEntry     < double >( "wave-length-y", "Wave length of the sine based test functions.", 1.0 );
         config.addEntry     < double >( "wave-length-z", "Wave length of the sine based test functions.", 1.0 );
         config.addEntry     < double >( "phase", "Phase of the sine based test functions.", 0.0 );
         config.addEntry     < double >( "phase-x", "Phase of the sine based test functions.", 0.0 );
         config.addEntry     < double >( "phase-y", "Phase of the sine based test functions.", 0.0 );
         config.addEntry     < double >( "phase-z", "Phase of the sine based test functions.", 0.0 );
         config.addEntry     < double >( "amplitude", "Amplitude length of the sine based test functions.", 1.0 );
         config.addEntry     < double >( "waves-number", "Cut-off for the sine based test functions.", 0.0 );
         config.addEntry     < double >( "waves-number-x", "Cut-off for the sine based test functions.", 0.0 );
         config.addEntry     < double >( "waves-number-y", "Cut-off for the sine based test functions.", 0.0 );
         config.addEntry     < double >( "waves-number-z", "Cut-off for the sine based test functions.", 0.0 );
         config.addEntry     < double >( "sigma", "Sigma for the exp based test functions.", 1.0 );
         config.addEntry     < tnlString >( "test-function-time-dependence", "Time dependence of the test function.", "none" );
            config.addEntryEnum( "none" );
            config.addEntryEnum( "linear" );
            config.addEntryEnum( "quadratic" );
            config.addEntryEnum( "cosine" );
         tnlTestFunction< 3, double >::configSetup( config );
      }
};

+3 −2
Original line number Diff line number Diff line
@@ -18,10 +18,11 @@
#ifndef TNLTESTFUNCTION_H_
#define TNLTESTFUNCTION_H_

#include <core/tnlHost.h>

template< int FunctionDimensions,
          typename Real,
          typename Device >
          typename Device = tnlHost >
class tnlTestFunction
{
   protected:
@@ -41,7 +42,7 @@ class tnlTestFunction
   tnlTestFunction();

   static void configSetup( tnlConfigDescription& config,
                            const tnlString& prefix );
                            const tnlString& prefix = "" );

   bool init( const tnlParameterContainer& parameters );

+29 −16
Original line number Diff line number Diff line
@@ -41,18 +41,31 @@ tnlTestFunction< FunctionDimensions, Real, Device >::
configSetup( tnlConfigDescription& config,
             const tnlString& prefix )
{
   config.addEntry     < tnlString >( "test-function", "Testing function.", "sin-wave" );
      config.addEntryEnum( "sin-wave" );
      config.addEntryEnum( "sin-bumps" );
      config.addEntryEnum( "exp-bump" );
   config.addEntry     < double >( prefix + "value", "Value of the constant function.", 0.0 );
   config.addEntry< double >( prefix + "amplitude", "Amplitude of the sine and exp functions.", 1.0 );
   config.addEntry< double >( prefix + "sigma", "Sigma parameter of the exp-bump function.", 1.0 );
   config.addEntry< double >( prefix + "waves-number", "Number of waves of the sine functions.", 0.0 );
   config.addEntry< double >( prefix + "wave-length", "Wave length of the sine functions.", 1.0 );
   config.addEntry< double >( prefix + "wave-length-x", "Wave length of the sin-bumps function.", 1.0 );
   config.addEntry< double >( prefix + "wave-length-y", "Wave length of the sin-bumps functions.", 1.0 );
   config.addEntry< double >( prefix + "wave-length-z", "Wave length of the sin-bumps functions.", 1.0 );
   config.addEntry< double >( prefix + "phase", "Phase of the sine functions.", 0.0 );
   config.addEntry< double >( prefix + "phase-x", "Phase of the sin-bumps function.", 0.0 );
   config.addEntry< double >( prefix + "phase-y", "Phase of the sin-bumps function.", 0.0 );
   config.addEntry< double >( prefix + "phase-z", "Phase of the sin-bumps function.", 0.0 );
   config.addEntry     < double >( prefix + "wave-length", "Wave length of the sine based test functions.", 1.0 );
   config.addEntry     < double >( prefix + "wave-length-x", "Wave length of the sine based test functions.", 1.0 );
   config.addEntry     < double >( prefix + "wave-length-y", "Wave length of the sine based test functions.", 1.0 );
   config.addEntry     < double >( prefix + "wave-length-z", "Wave length of the sine based test functions.", 1.0 );
   config.addEntry     < double >( prefix + "phase", "Phase of the sine based test functions.", 0.0 );
   config.addEntry     < double >( prefix + "phase-x", "Phase of the sine based test functions.", 0.0 );
   config.addEntry     < double >( prefix + "phase-y", "Phase of the sine based test functions.", 0.0 );
   config.addEntry     < double >( prefix + "phase-z", "Phase of the sine based test functions.", 0.0 );
   config.addEntry     < double >( prefix + "amplitude", "Amplitude length of the sine based test functions.", 1.0 );
   config.addEntry     < double >( prefix + "waves-number", "Cut-off for the sine based test functions.", 0.0 );
   config.addEntry     < double >( prefix + "waves-number-x", "Cut-off for the sine based test functions.", 0.0 );
   config.addEntry     < double >( prefix + "waves-number-y", "Cut-off for the sine based test functions.", 0.0 );
   config.addEntry     < double >( prefix + "waves-number-z", "Cut-off for the sine based test functions.", 0.0 );
   config.addEntry     < double >( prefix + "sigma", "Sigma for the exp based test functions.", 1.0 );
   config.addEntry     < tnlString >( "test-function-time-dependence", "Time dependence of the test function.", "none" );
      config.addEntryEnum( "none" );
      config.addEntryEnum( "linear" );
      config.addEntryEnum( "quadratic" );
      config.addEntryEnum( "cosine" );

}

template< int FunctionDimensions,
@@ -70,11 +83,11 @@ initFunction( const tnlParameterContainer& parameters )
      return false;
   }

   if( Device::DeviceType == tnlHostDevice )
   if( Device::DeviceType == ( int ) tnlHostDevice )
   {
      function = auxFunction;
   }
   if( Device::DeviceType == tnlCudaDevice )
   if( Device::DeviceType == ( int ) tnlCudaDevice )
   {
      function = passToDevice( *auxFunction );
      delete auxFunction;
@@ -158,9 +171,9 @@ void
tnlTestFunction< FunctionDimensions, Real, Device >::
deleteFunction()
{
   if( Device::DeviceType == tnlHostDevice )
   if( Device::DeviceType == ( int ) tnlHostDevice )
      delete ( FunctionType * ) function;
   if( Device::DeviceType == tnlCudaDevice )
   if( Device::DeviceType == ( int ) tnlCudaDevice )
      tnlCuda::freeFromDevice( ( FunctionType * ) function );
}

+1 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ bool tnlEllpackMatrix< Real, Device, Index >::setDimensions( const IndexType row
                   << " columns = " << columns << endl );
   this->rows = rows;
   this->columns = columns;   
   if( Device::DeviceType == tnlCudaDevice )
   if( Device::DeviceType == ( int ) tnlCudaDevice )
      this->alignedRows = roundToMultiple( columns, tnlCuda::getWarpSize() );
   else this->alignedRows = rows;
   if( this->rowLengths != 0 )
+55 −0
Original line number Diff line number Diff line
/***************************************************************************
                          tnlExactLinearDiffusion_impl.h  -  description
                             -------------------
    begin                : Aug 8, 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 TNLEXACTLINEARDIFFUSION_IMPL_H_
#define TNLEXACTLINEARDIFFUSION_IMPL_H_

template<>
   template< typename Function, typename Vertex >
typename Function::RealType
tnlExactLinearDiffusion< 1 >::
getValue( const Function& function,
          const Vertex& v )
{
   return function.template getValue< 2 >( v );
}

template<>
   template< typename Function, typename Vertex >
typename Function::RealType
tnlExactLinearDiffusion< 2 >::
getValue( const Function& function,
          const Vertex& v )
{
   return function.template getValue< 2, 0 >( v ) +
          function.template getValue< 0, 2 >( v );
}

template<>
   template< typename Function, typename Vertex >
typename Function::RealType
tnlExactLinearDiffusion< 3 >::
getValue( const Function& function,
          const Vertex& v )
{
   return function.template getValue< 2, 0, 0 >( v ) +
          function.template getValue< 0, 2, 0 >( v ) +
          function.template getValue< 0, 0, 2 >( v );

}

#endif /* TNLEXACTLINEARDIFFUSION_IMPL_H_ */
Loading