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

Implenting linear diffusion test.

parent db210e86
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@ set( ENABLE_CODECOVERAGE )

ADD_SUBDIRECTORY( data )
ADD_SUBDIRECTORY( benchmarks )
ADD_SUBDIRECTORY( approximation-tests )
ADD_SUBDIRECTORY( unit-tests )
ADD_SUBDIRECTORY( long-time-unit-tests )

+0 −5
Original line number Diff line number Diff line
INSTALL( FILES tnl-functions-test
         DESTINATION share/tnl-${tnlVersion} )                                                            

set( common_headers tnlApproximationTest.h
                    tnlApproximationTest_impl.h )                                                                       
+0 −44
Original line number Diff line number Diff line
#!/usr/bin/env bash

FUNCTIONS="sin-wave"
GRID_DIMS="16 32 64 128 256 512"
for function in $FUNCTIONS;
do
   mkdir ${function}
   cd ${function}
   
   for grid_dim in $GRID_DIMS;
   do
      mkdir ${grid_dim}
      cd ${grid_dim}
      
      tnl-grid-setup --output-file mesh.tnl \
                     --dimensions 1 \
                     --size-x ${grid_dim}
      
      tnl-discrete --mesh mesh.tnl \
                   --function ${function} \
                   --wave-length 1 \
                   --output-file u.tnl

      tnl-discrete --mesh mesh.tnl \
                   --function ${function} \
                   --wave-length 1 \
                   --x-derivative 1 \
                   --output-file u-x-exact.tnl
      
      tnl-discrete --mesh mesh.tnl \
                   --function ${function} \
                   --wave-length 1 \
                   --x-derivative 1 \
                   --approximate-derivatives yes \
                   --output-file u-x-approx.tnl
                   
      tnl-view --mesh mesh.tnl \
               --check-output-file yes \
               --input-files u*.tnl
      cd ..
   done

   cd ..
done
+1 −0
Original line number Diff line number Diff line
ADD_SUBDIRECTORY( core )
ADD_SUBDIRECTORY( matrices )
ADD_SUBDIRECTORY( mesh )
ADD_SUBDIRECTORY( schemes )
ADD_SUBDIRECTORY( solver )

set( headers tnlUnitTestStarter.h
+86 −0
Original line number Diff line number Diff line
/***************************************************************************
                          tnlLinearDiffusionTester.h  -  description
                             -------------------
    begin                : Aug 30, 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 TNLLINEARDIFFUSIONTESTER_H_
#define TNLLINEARDIFFUSIONTESTER_H_

#ifdef HAVE_CPPUNIT
#include <cppunit/TestSuite.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestCaller.h>
#include <cppunit/TestCase.h>
#include <cppunit/Message.h>
#include <schemes/diffusion/tnlLinearDiffusion.h>
#include <functions/tnlExpBumpFunction.h>
#include <tnlApproximationError.h>

template< typename MeshType,
          typename TestFunction >
class tnlLinearDiffusionTester{}

template< int Dimensions,
          typename Real,
          typename Device,
          typename Index,
          typename TestFunction >
class tnlLinearDiffusionTester< tnlGrid< Dimensions, Real, Device, Index >,
                                TestFunction > : public CppUnit :: TestCase
{
   public:
   typedef tnlGrid< Dimensions, Real, Device, Index > MeshType;
   typedef tnlLinearDiffusionTester< MeshType > TesterType;
   typedef typename CppUnit::TestCaller< TesterType > TestCallerType;
   typedef tnlLinearDiffusionTestSetter< MeshType, FunctionType > TestSetter;
   typedef tnlExactLinearDiffusion< Dimensions > ExactOperator;
   typedef tnlLinearDiffusion< MeshType, Real, Index > ApproximateOperator;

   tnlLinearDiffusionTester(){};

   virtual
   ~tnlLinearDiffusionTester(){};

   static CppUnit :: Test* suite()
   {
      CppUnit :: TestSuite* suiteOfTests = new CppUnit :: TestSuite( "tnlLinearDiffusionTester" );
      CppUnit :: TestResult result;

      suiteOfTests -> addTest( new TestCallerType( "approximationTest", &TesterType::approximationTest ) );

      return suiteOfTests;
   }

   void expBumpApproximationTest()
   {
      TestFunction testFunction;
      TestFunctionSetter::setTestFunction( testFunction );

      MeshType mesh;
      TestSetter::setMesh( mesh, coarseMeshSize );

      Real l1Err, l2Err, maxErr;
      tnlApproximationError( mesh,
                             exactOperator,
                             approximateOperator,
                             testFunction,
                             l1Err,
                             l2Err,
                             maxErr );

   }


#endif /* TNLLINEARDIFFUSIONTESTER_H_ */
Loading