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

Refactoring the heat equation.

parent 25efbf59
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -7,8 +7,6 @@ set( tnl_heat_equation_SOURCES
               tnlRightHandSide.h
               tnlNeumannBoundaryConditions_impl.h
               tnlNeumannBoundaryConditions.h
               tnlLinearDiffusion.h
               tnlLinearDiffusion_impl.h
               tnlDirichletBoundaryConditions_impl.h
               tnlDirichletBoundaryConditions.h
               tnlAnalyticSolution_impl.h
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@
#include <generators/functions/tnlSinBumpsFunction.h>
#include "tnlTimeFunction.h"
#include "tnlDirichletBoundaryConditions.h"
#include "tnlLinearDiffusion.h"
#include <schemes/diffusion/tnlLinearDiffusion.h>
#include "tnlNeumannBoundaryConditions.h"
#include "tnlZeroRightHandSide.h"
#include "tnlRightHandSide.h"
+4 −4
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@
#include <generators/functions/tnlSinWaveFunction.h>
#include <generators/functions/tnlSinBumpsFunction.h>
#include <generators/functions/tnlExpBumpFunction.h>
#include "tnlLinearDiffusion.h"
#include <schemes/diffusion/tnlLinearDiffusion.h>
#include "tnlDirichletBoundaryConditions.h"
#include "tnlRightHandSide.h"

@@ -48,19 +48,19 @@ bool heatEquationSetter< Real, Device, Index, MeshType, ConfigTag, SolverStarter
   if (analyticSpaceFunctionParameter == "sin-wave")
   {
      typedef tnlSinWaveFunction< MeshType::Dimensions, Vertex, DeviceType > TestFunction;
      typedef heatEquationSolver< MeshType, Scheme, BoundaryConditions, RightHandSide, TimeFunction, TestFunction > Solver;
      typedef heatEquationSolver< MeshType, Scheme, BoundaryConditions, RightHandSide > Solver;
      return solverStarter.template run< Solver >( parameters );
   }
   if (analyticSpaceFunctionParameter == "sin-bumps")
   {
      typedef tnlSinBumpsFunction<MeshType::Dimensions,Vertex,DeviceType > TestFunction;
      typedef heatEquationSolver< MeshType, Scheme, BoundaryConditions, RightHandSide, TimeFunction, TestFunction > Solver;
      typedef heatEquationSolver< MeshType, Scheme, BoundaryConditions, RightHandSide > Solver;
      return solverStarter.template run< Solver >( parameters );
   }
   if (analyticSpaceFunctionParameter == "exp-bump")
   {
      typedef tnlExpBumpFunction<MeshType::Dimensions,Vertex,DeviceType > TestFunction;
      typedef heatEquationSolver< MeshType, Scheme, BoundaryConditions, RightHandSide, TimeFunction, TestFunction > Solver;
      typedef heatEquationSolver< MeshType, Scheme, BoundaryConditions, RightHandSide > Solver;
      return solverStarter.template run< Solver >( parameters );
   }
   
+17 −26
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ template< typename Mesh, typename Diffusion, typename BoundaryCondition, typenam
bool heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide >
:: init( const tnlParameterContainer& parameters )
{
   analyticSpaceFunction.init(parameters);
   /*analyticSpaceFunction.init(parameters);
   ifLaplaceCompare = parameters.GetParameter< IndexType >( "approximation-test" );
   if((ifLaplaceCompare != 0) && (ifLaplaceCompare != 1))
   {
@@ -60,7 +60,7 @@ bool heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide >
   {
      cerr << "Unknown value of solution-convergence-test parameter. Valid values are 0 or 1. You set " << ifSolutionCompare << ". ";
      return false;
   }
   }*/
   return true;
}

@@ -106,11 +106,9 @@ bindDofs( const MeshType& mesh,
template< typename Mesh,
          typename Diffusion,
          typename BoundaryCondition,
          typename RightHandSide,
          typename TimeFunction,
          typename AnalyticSpaceFunction >
          typename RightHandSide >
void
heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide,TimeFunction,AnalyticSpaceFunction >::
heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide >::
bindAuxiliaryDofs( const MeshType& mesh,
                   DofVectorType& auxiliaryDofVector )
{
@@ -121,9 +119,8 @@ bindAuxiliaryDofs( const MeshType& mesh,
}


template< typename Mesh, typename Diffusion, typename BoundaryCondition, typename RightHandSide,
          typename TimeFunction, typename AnalyticSpaceFunction>
bool heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide,TimeFunction,AnalyticSpaceFunction>
template< typename Mesh, typename Diffusion, typename BoundaryCondition, typename RightHandSide >
bool heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide >
:: setInitialCondition( const tnlParameterContainer& parameters,
                        const MeshType& mesh )
{
@@ -135,7 +132,7 @@ bool heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide,TimeFunc
   }
   
   //boundaryCondition.applyBoundaryConditions(mesh,numericalSolution,0.0,timeFunction,analyticSpaceFunction);
   timeFunction.applyInitTimeValues( numericalSolution);
   //timeFunction.applyInitTimeValues( numericalSolution);
   
   return true;
}
@@ -143,15 +140,11 @@ bool heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide,TimeFunc
template< typename Mesh,
          typename Diffusion,
          typename BoundaryCondition,
          typename RightHandSide,
          typename TimeFunction,
          typename AnalyticSpaceFunction >
          typename RightHandSide >
bool heatEquationSolver< Mesh,
                         Diffusion,
                         BoundaryCondition,
                         RightHandSide,
                         TimeFunction,
                         AnalyticSpaceFunction >::
                         RightHandSide >::
makeSnapshot( const RealType& time,
              const IndexType& step,
              const MeshType& mesh )
@@ -163,7 +156,7 @@ makeSnapshot( const RealType& time,
   if( ! this->numericalSolution.save( fileName ) )
      return false;
 
   if( ifSolutionCompare == 1)
   /*if( ifSolutionCompare == 1)
   {
      analyticSolution.computeAnalyticSolution( mesh, time, exactSolution, timeFunction, analyticSpaceFunction );
      FileNameBaseNumberEnding( "analyticSolution-", step, 5, ".tnl", fileName );
@@ -186,14 +179,13 @@ makeSnapshot( const RealType& time,
         return false;
      
      exit(0);
   }
   }*/
   
   return true;
}

template< typename Mesh, typename Diffusion, typename BoundaryCondition, typename RightHandSide,
          typename TimeFunction, typename AnalyticSpaceFunction>
void heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide,TimeFunction,AnalyticSpaceFunction> 
template< typename Mesh, typename Diffusion, typename BoundaryCondition, typename RightHandSide >
void heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide > 
:: GetExplicitRHS( const RealType& time,
                   const RealType& tau,
                   const Mesh& mesh,
@@ -219,11 +211,10 @@ void heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide,TimeFunc
                                                        _fu );
}

template< typename Mesh, typename Diffusion, typename BoundaryCondition, typename RightHandSide, 
          typename TimeFunction, typename AnalyticSpaceFunction>
tnlSolverMonitor< typename heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide,TimeFunction,AnalyticSpaceFunction>:: RealType,
                  typename heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide,TimeFunction,AnalyticSpaceFunction> :: IndexType >*
                  heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide,TimeFunction,AnalyticSpaceFunction> 
template< typename Mesh, typename Diffusion, typename BoundaryCondition, typename RightHandSide >
tnlSolverMonitor< typename heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide >::RealType,
                  typename heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide >::IndexType >*
                  heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide > 
::  getSolverMonitor()
{
   return 0;
+0 −108
Original line number Diff line number Diff line
#ifndef TNLLINEARDIFFUSION_H
#define	TNLLINEARDIFFUSION_H

#include <core/vectors/tnlVector.h>

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


template< typename MeshReal,
          typename Device,
          typename MeshIndex,
          typename Real,
          typename Index >
class tnlLinearDiffusion< tnlGrid< 1,MeshReal, Device, MeshIndex >, Real, Index >
{
   public: 
   
   typedef tnlGrid< 1, MeshReal, Device, MeshIndex > MeshType;
   typedef typename MeshType::CoordinatesType CoordinatesType;
   typedef Real RealType;
   typedef Device DeviceType;
   typedef Index IndexType;

   template< typename Vector >
#ifdef HAVE_CUDA
   __device__ __host__
#endif
   void explicitUpdate( const RealType& time,
                        const RealType& tau,
                        const MeshType& mesh,
                        const IndexType cellIndex,
                        const CoordinatesType& coordinates,
                        Vector& u,
                        Vector& fu );
   
};


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

   template< typename Vector >
#ifdef HAVE_CUDA
   __device__ __host__
#endif
   void explicitUpdate( const RealType& time,
                        const RealType& tau,
                        const MeshType& mesh,
                        const IndexType index,
                        const CoordinatesType& coordinates,
                        Vector& u,
                        Vector& fu );
   
};


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

   template< typename Vector >
#ifdef HAVE_CUDA
   __device__ __host__
#endif
   void explicitUpdate( const RealType& time,
                        const RealType& tau,
                        const MeshType& mesh,
                        const IndexType index,
                        const CoordinatesType& coordinates,
                        Vector& u,
                        Vector& fu );
   
};


#include "tnlLinearDiffusion_impl.h"


#endif	/* TNLLINEARDIFFUSION_H */
Loading