Loading examples/heat-equation/heatEquationScheme.h 0 → 100644 +59 −0 Original line number Diff line number Diff line /*************************************************************************** heatEquationScheme.h - description ------------------- begin : Aug 05, 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 HEATEQUATIONSCHEME_H_ #define HEATEQUATIONSCHEME_H_ template< typename Mesh, typename DifferentialOperator, typename RightHandSide > class heatEquationScheme { public: typedef Mesh MeshType; typedef typename MeshType::CoordinatesType CoordinatesType; typedef typename MeshType::VertexType VertexType; typedef typename MeshType::DeviceType DeviceType; typedef typename DifferentialOperator::RealType RealType; typedef typename DifferentialOperator::IndexType 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 ); protected: DifferentialOperator differentialOperator; RightHandSide rightHandSide; }; #include "heatEquationScheme_impl.h" #endif /* HEATEQUATIONSCHEME_H_ */ examples/heat-equation/heatEquationScheme_impl.h 0 → 100644 +43 −0 Original line number Diff line number Diff line /*************************************************************************** heatEquationScheme_impl.h - description ------------------- begin : Aug 05, 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 HEATEQUATIONSCHEME_IMPL_H_ #define HEATEQUATIONSCHEME_IMPL_H_ template< typename Mesh, typename DifferentialOperator, typename RightHandSide > template< typename Vector > #ifdef HAVE_CUDA __device__ __host__ #endif void heatEquationScheme< Mesh, DifferentialOperator, RightHandSide >:: explicitUpdate( const RealType& time, const RealType& tau, const MeshType& mesh, const IndexType cellIndex, const CoordinatesType& coordinates, Vector& u, Vector& fu ) { this->differentialOperator.explicitUpdate( time, tau, mesh, cellIndex, coordinates, u, fu ); VertexType vertex = mesh.getCellCenter( coordinates ); fu[ cellIndex ] += this->rightHandSide.getValue( vertex ); } #endif /* HEATEQUATIONSCHEME_IMPL_H_ */ examples/heat-equation/heatEquationSetter_impl.h +7 −33 Original line number Diff line number Diff line Loading @@ -20,9 +20,7 @@ #include "heatEquationSetter.h" #include "heatEquationSolver.h" #include <functions/tnlSinWaveFunction.h> #include <functions/tnlSinBumpsFunction.h> #include <functions/tnlExpBumpFunction.h> #include <functions/tnlTestFunction.h> #include <schemes/diffusion/tnlLinearDiffusion.h> #include "tnlDirichletBoundaryConditions.h" #include "tnlRightHandSide.h" Loading @@ -36,40 +34,16 @@ template< typename Real, template< typename TimeFunction > bool heatEquationSetter< Real, Device, Index, MeshType, ConfigTag, SolverStarter > ::setAnalyticSpaceFunction (const tnlParameterContainer& parameters) { SolverStarter solverStarter; //DODELAT NACTENI Z PRIKAZOVY RADKY: RHS, Diffusion, BoundaryConditions !!!!! const tnlString& analyticSpaceFunctionParameter = parameters.GetParameter<tnlString>("test-function"); typedef tnlLinearDiffusion< MeshType, Real, Index > Scheme; typedef tnlLinearDiffusion< MeshType, Real, Index > Diffusion; typedef tnlTestFunction< MeshType::Dimensions, Real, Device > RightHandSide; typedef tnlStaticVector < MeshType::Dimensions, Real > Vertex; typedef tnlConstantFunction< MeshType::Dimensions, Vertex, Device > BCFunction; typedef tnlConstantFunction< MeshType::Dimensions, Real > BCFunction; typedef tnlDirichletBoundaryConditions< MeshType, BCFunction, Real, Index > BoundaryConditions; typedef tnlRightHandSide< MeshType, Real, Index > RightHandSide; if (analyticSpaceFunctionParameter == "sin-wave") { typedef tnlSinWaveFunction< MeshType::Dimensions, Vertex, DeviceType > TestFunction; 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 > Solver; return solverStarter.template run< Solver >( parameters ); } if (analyticSpaceFunctionParameter == "exp-bump") { typedef tnlExpBumpFunction<MeshType::Dimensions,Vertex,DeviceType > TestFunction; typedef heatEquationSolver< MeshType, Scheme, BoundaryConditions, RightHandSide > Solver; typedef heatEquationSolver< MeshType, Diffusion, BoundaryConditions, RightHandSide > Solver; SolverStarter solverStarter; return solverStarter.template run< Solver >( parameters ); } cerr<<"Unknown test-function parameter: "<<analyticSpaceFunctionParameter<<". "; return 0; } template< typename Real, typename Device, typename Index, Loading examples/heat-equation/heatEquationSolver.h +8 −13 Original line number Diff line number Diff line /*************************************************************************** simpleProblemSolver.h - description heatEquationSolver.h - description ------------------- begin : Feb 23, 2013 copyright : (C) 2013 by Tomas Oberhuber Loading @@ -26,22 +26,24 @@ #include <core/vectors/tnlSharedVector.h> #include <solvers/pde/tnlExplicitUpdater.h> #include "heatEquationSolver.h" #include "heatEquationScheme.h" #include "tnlAnalyticSolution.h" template< typename Mesh, typename Diffusion, typename DifferentialOperator, typename BoundaryCondition, typename RightHandSide > class heatEquationSolver { public: typedef typename Diffusion::RealType RealType; typedef typename DifferentialOperator::RealType RealType; typedef typename Mesh::DeviceType DeviceType; typedef typename Diffusion::IndexType IndexType; typedef typename DifferentialOperator::IndexType IndexType; typedef Mesh MeshType; typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType; typedef heatEquationScheme< Mesh, DifferentialOperator, RightHandSide > Scheme; static tnlString getTypeStatic(); Loading Loading @@ -84,18 +86,11 @@ class heatEquationSolver analyticLaplace, numericalLaplace; tnlExplicitUpdater< Mesh, DofVectorType, BoundaryCondition, Diffusion > explicitUpdater; //AnalyticSpaceFunction analyticSpaceFunction; //TimeFunction timeFunction; //AnalyticSolution< MeshType, RealType, IndexType > analyticSolution; tnlExplicitUpdater< Mesh, DofVectorType, BoundaryCondition, Scheme > explicitUpdater; BoundaryCondition boundaryCondition; Diffusion diffusion; RightHandSide RHS; //IndexType ifLaplaceCompare, ifSolutionCompare; Scheme scheme; }; #include "heatEquationSolver_impl.h" Loading examples/heat-equation/heatEquationSolver_impl.h +1 −1 Original line number Diff line number Diff line Loading @@ -208,7 +208,7 @@ void heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide > tau, mesh, this->boundaryCondition, this->diffusion, this->scheme, _u, _fu ); } Loading Loading
examples/heat-equation/heatEquationScheme.h 0 → 100644 +59 −0 Original line number Diff line number Diff line /*************************************************************************** heatEquationScheme.h - description ------------------- begin : Aug 05, 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 HEATEQUATIONSCHEME_H_ #define HEATEQUATIONSCHEME_H_ template< typename Mesh, typename DifferentialOperator, typename RightHandSide > class heatEquationScheme { public: typedef Mesh MeshType; typedef typename MeshType::CoordinatesType CoordinatesType; typedef typename MeshType::VertexType VertexType; typedef typename MeshType::DeviceType DeviceType; typedef typename DifferentialOperator::RealType RealType; typedef typename DifferentialOperator::IndexType 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 ); protected: DifferentialOperator differentialOperator; RightHandSide rightHandSide; }; #include "heatEquationScheme_impl.h" #endif /* HEATEQUATIONSCHEME_H_ */
examples/heat-equation/heatEquationScheme_impl.h 0 → 100644 +43 −0 Original line number Diff line number Diff line /*************************************************************************** heatEquationScheme_impl.h - description ------------------- begin : Aug 05, 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 HEATEQUATIONSCHEME_IMPL_H_ #define HEATEQUATIONSCHEME_IMPL_H_ template< typename Mesh, typename DifferentialOperator, typename RightHandSide > template< typename Vector > #ifdef HAVE_CUDA __device__ __host__ #endif void heatEquationScheme< Mesh, DifferentialOperator, RightHandSide >:: explicitUpdate( const RealType& time, const RealType& tau, const MeshType& mesh, const IndexType cellIndex, const CoordinatesType& coordinates, Vector& u, Vector& fu ) { this->differentialOperator.explicitUpdate( time, tau, mesh, cellIndex, coordinates, u, fu ); VertexType vertex = mesh.getCellCenter( coordinates ); fu[ cellIndex ] += this->rightHandSide.getValue( vertex ); } #endif /* HEATEQUATIONSCHEME_IMPL_H_ */
examples/heat-equation/heatEquationSetter_impl.h +7 −33 Original line number Diff line number Diff line Loading @@ -20,9 +20,7 @@ #include "heatEquationSetter.h" #include "heatEquationSolver.h" #include <functions/tnlSinWaveFunction.h> #include <functions/tnlSinBumpsFunction.h> #include <functions/tnlExpBumpFunction.h> #include <functions/tnlTestFunction.h> #include <schemes/diffusion/tnlLinearDiffusion.h> #include "tnlDirichletBoundaryConditions.h" #include "tnlRightHandSide.h" Loading @@ -36,40 +34,16 @@ template< typename Real, template< typename TimeFunction > bool heatEquationSetter< Real, Device, Index, MeshType, ConfigTag, SolverStarter > ::setAnalyticSpaceFunction (const tnlParameterContainer& parameters) { SolverStarter solverStarter; //DODELAT NACTENI Z PRIKAZOVY RADKY: RHS, Diffusion, BoundaryConditions !!!!! const tnlString& analyticSpaceFunctionParameter = parameters.GetParameter<tnlString>("test-function"); typedef tnlLinearDiffusion< MeshType, Real, Index > Scheme; typedef tnlLinearDiffusion< MeshType, Real, Index > Diffusion; typedef tnlTestFunction< MeshType::Dimensions, Real, Device > RightHandSide; typedef tnlStaticVector < MeshType::Dimensions, Real > Vertex; typedef tnlConstantFunction< MeshType::Dimensions, Vertex, Device > BCFunction; typedef tnlConstantFunction< MeshType::Dimensions, Real > BCFunction; typedef tnlDirichletBoundaryConditions< MeshType, BCFunction, Real, Index > BoundaryConditions; typedef tnlRightHandSide< MeshType, Real, Index > RightHandSide; if (analyticSpaceFunctionParameter == "sin-wave") { typedef tnlSinWaveFunction< MeshType::Dimensions, Vertex, DeviceType > TestFunction; 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 > Solver; return solverStarter.template run< Solver >( parameters ); } if (analyticSpaceFunctionParameter == "exp-bump") { typedef tnlExpBumpFunction<MeshType::Dimensions,Vertex,DeviceType > TestFunction; typedef heatEquationSolver< MeshType, Scheme, BoundaryConditions, RightHandSide > Solver; typedef heatEquationSolver< MeshType, Diffusion, BoundaryConditions, RightHandSide > Solver; SolverStarter solverStarter; return solverStarter.template run< Solver >( parameters ); } cerr<<"Unknown test-function parameter: "<<analyticSpaceFunctionParameter<<". "; return 0; } template< typename Real, typename Device, typename Index, Loading
examples/heat-equation/heatEquationSolver.h +8 −13 Original line number Diff line number Diff line /*************************************************************************** simpleProblemSolver.h - description heatEquationSolver.h - description ------------------- begin : Feb 23, 2013 copyright : (C) 2013 by Tomas Oberhuber Loading @@ -26,22 +26,24 @@ #include <core/vectors/tnlSharedVector.h> #include <solvers/pde/tnlExplicitUpdater.h> #include "heatEquationSolver.h" #include "heatEquationScheme.h" #include "tnlAnalyticSolution.h" template< typename Mesh, typename Diffusion, typename DifferentialOperator, typename BoundaryCondition, typename RightHandSide > class heatEquationSolver { public: typedef typename Diffusion::RealType RealType; typedef typename DifferentialOperator::RealType RealType; typedef typename Mesh::DeviceType DeviceType; typedef typename Diffusion::IndexType IndexType; typedef typename DifferentialOperator::IndexType IndexType; typedef Mesh MeshType; typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType; typedef heatEquationScheme< Mesh, DifferentialOperator, RightHandSide > Scheme; static tnlString getTypeStatic(); Loading Loading @@ -84,18 +86,11 @@ class heatEquationSolver analyticLaplace, numericalLaplace; tnlExplicitUpdater< Mesh, DofVectorType, BoundaryCondition, Diffusion > explicitUpdater; //AnalyticSpaceFunction analyticSpaceFunction; //TimeFunction timeFunction; //AnalyticSolution< MeshType, RealType, IndexType > analyticSolution; tnlExplicitUpdater< Mesh, DofVectorType, BoundaryCondition, Scheme > explicitUpdater; BoundaryCondition boundaryCondition; Diffusion diffusion; RightHandSide RHS; //IndexType ifLaplaceCompare, ifSolutionCompare; Scheme scheme; }; #include "heatEquationSolver_impl.h" Loading
examples/heat-equation/heatEquationSolver_impl.h +1 −1 Original line number Diff line number Diff line Loading @@ -208,7 +208,7 @@ void heatEquationSolver< Mesh,Diffusion,BoundaryCondition,RightHandSide > tau, mesh, this->boundaryCondition, this->diffusion, this->scheme, _u, _fu ); } Loading