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

Finishing the heat equation.

parent be2f1d6b
Loading
Loading
Loading
Loading
+3 −11
Original line number Diff line number Diff line
set( tnl_heat_equation_SOURCES     
     tnlHeatEquationEocRhs.h
     tnl-heat-equation.cpp
     tnl-heat-equation-eoc.cpp
     heatEquationSolver_impl.h
     heatEquationSolver.h
     heatEquationEocSolver.h
     heatEquationEocSolver_impl.h
     tnlHeatEquationEocRhs.h )
     tnl-heat-equation-eoc.cpp )
               
IF( BUILD_CUDA )
   CUDA_ADD_EXECUTABLE(tnl-heat-equation${debugExt} tnl-heat-equation.cu)
@@ -24,8 +18,6 @@ INSTALL( TARGETS tnl-heat-equation${debugExt}
         RUNTIME DESTINATION bin
         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )
        
INSTALL( FILES ${tnl_heat_equation_SOURCES}
               Makefile
               tnl-run-heat-equation-eoc-test
INSTALL( FILES tnl-run-heat-equation-eoc-test
               tnl-run-heat-equation
         DESTINATION share/tnl-${tnlVersion}/examples/heat-equation )

examples/heat-equation/Makefile

deleted100644 → 0
+0 −39
Original line number Diff line number Diff line
TNL_VERSION=0.1
TNL_INSTALL_DIR=${HOME}/local/lib
TNL_INCLUDE_DIR=${HOME}/local/include/tnl-${TNL_VERSION}

TARGET = tnl-heat-equation
CONFIG_FILE = $(TARGET).cfg.desc
INSTALL_DIR = ${HOME}/local
CXX = g++
CUDA_CXX = nvcc
OMP_FLAGS = -DHAVE_OPENMP -fopenmp 
CXX_FLAGS = -std=gnu++0x -I$(TNL_INCLUDE_DIR) -O3 $(OMP_FLAGS)
LD_FLAGS = -L$(TNL_INSTALL_DIR) -ltnl-0.1 -lgomp

SOURCES = tnl-heat-equation.cpp
CUDA_SOURCES = tnl-heat-equation.cu
HEADERS = 
OBJECTS = tnl-heat-equation.o
DIST = $(SOURCES) Makefile

all: $(TARGET)
clean: 
	rm -f $(OBJECTS)
	rm -f $(TARGET)-conf.h	

dist: $(DIST)
	tar zcvf $(TARGET).tgz $(DIST) 

install: $(TARGET)
	cp $(TARGET) $(INSTALL_DIR)/bin

uninstall: $(TARGET)
	rm -f $(INSTALL_DIR)/bin/$(TARGET) 

$(TARGET): $(OBJECTS)
	$(CXX) -o $(TARGET) $(OBJECTS) $(LD_FLAGS)

%.o: %.cpp $(HEADERS)
	$(CXX) -c -o $@ $(CXX_FLAGS) $<
+0 −129
Original line number Diff line number Diff line
/***************************************************************************
                          heatEquationSolver.h  -  description
                             -------------------
    begin                : Feb 23, 2013
    copyright            : (C) 2013 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 HEATEQUATIONSOLVER_H_
#define HEATEQUATIONSOLVER_H_

#include <matrices/tnlCSRMatrix.h>
#include <solvers/preconditioners/tnlDummyPreconditioner.h>
#include <solvers/tnlSolverMonitor.h>
#include <core/tnlLogger.h>
#include <core/vectors/tnlVector.h>
#include <core/vectors/tnlSharedVector.h>
#include <solvers/pde/tnlExplicitUpdater.h>
#include <solvers/pde/tnlLinearSystemAssembler.h>
#include <matrices/tnlCSRMatrix.h>
#include <matrices/tnlEllpackMatrix.h>
#include "heatEquationSolver.h"

#include <matrices/tnlSlicedEllpackMatrix.h>
#include <matrices/tnlDenseMatrix.h>


template< typename Mesh,
          typename DifferentialOperator,
          typename BoundaryCondition,
          typename RightHandSide >
class heatEquationSolver
{
   public:

   typedef typename DifferentialOperator::RealType RealType;
   typedef typename Mesh::DeviceType DeviceType;
   typedef typename DifferentialOperator::IndexType IndexType;
   typedef Mesh MeshType;
   typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType;
   typedef tnlSlicedEllpackMatrix< RealType, DeviceType, IndexType > MatrixType;
   typedef typename MatrixType::RowLengthsVector RowLengthsVectorType;

   static tnlString getTypeStatic();

   tnlString getPrologHeader() const;

   void writeProlog( tnlLogger& logger,
                     const tnlParameterContainer& parameters ) const;

   bool setup( const tnlParameterContainer& parameters );

   bool setInitialCondition( const tnlParameterContainer& parameters,
                             const MeshType& mesh,
                             DofVectorType& dofs,
                             DofVectorType& auxDofs );

   bool setupLinearSystem( const MeshType& mesh,
                           MatrixType& matrix );

   bool makeSnapshot( const RealType& time,
                      const IndexType& step,
                      const MeshType& mesh,
                      DofVectorType& dofs,
                      DofVectorType& auxDofs );

   IndexType getDofs( const MeshType& mesh ) const;

   IndexType getAuxiliaryDofs( const MeshType& mesh ) const;

   void bindDofs( const MeshType& mesh,
                  DofVectorType& dofs );

   void bindAuxiliaryDofs( const MeshType& mesh,
                           DofVectorType& auxiliaryDofs );

   bool preIterate( const RealType& time,
                    const RealType& tau,
                    const MeshType& mesh,
                    DofVectorType& dofs,
                    DofVectorType& auxDofs );

   void getExplicitRHS( const RealType& time,
                        const RealType& tau,
                        const MeshType& mesh,
                        DofVectorType& _u,
                        DofVectorType& _fu );


   void assemblyLinearSystem( const RealType& time,
                              const RealType& tau,
                              const MeshType& mesh,
                              DofVectorType& dofs,
                              DofVectorType& auxDofs,
                              MatrixType& matrix,
                              DofVectorType& rightHandSide );

   bool postIterate( const RealType& time,
                     const RealType& tau,
                     const MeshType& mesh,
                     DofVectorType& dofs,
                     DofVectorType& auxDofs );


   tnlSolverMonitor< RealType, IndexType >* getSolverMonitor();
   
   protected:

   tnlSharedVector< RealType, DeviceType, IndexType > solution;

   DifferentialOperator differentialOperator;

   BoundaryCondition boundaryCondition;

   RightHandSide rightHandSide;
};

#include "heatEquationSolver_impl.h"

#endif /* HEATEQUATIONSOLVER_H_ */
+0 −51
Original line number Diff line number Diff line
#!/bin/bash

dofSize=4
dimension=1

analyticFunction="sin-wave"
timeFunction="cosinus"

amplitude=1.0
waveLength=1.0
waveLengthX=1.0
waveLengthY=1.0
waveLengthZ=1.0
wavesNumber=0.0
wavesNumberX=0.0
wavesNumberY=0.0
wavesNumberZ=0.0
phase=0.0
phaseX=0.0
phaseY=0.0
phaseZ=0.0
sigma=1.0

tnl-grid-setup --dimensions ${dimension} \
               --proportions-x 1 \
               --proportions-y 1 \
               --proportions-z 1 \
               --origin-x 0 \
               --origin-y 0 \
               --origin-z 0 \
               --size-x ${dofSize} \
               --size-y ${dofSize} \
               --size-z ${dofSize} \

tnl-discrete --mesh mesh.tnl \
             --function ${analyticFunction} \
             --output-file u-ini.tnl \
             --amplitude ${amplitude} \
             --wave-length ${waveLength} \
             --wave-length-x ${waveLengthX} \
             --wave-length-y ${waveLengthY} \
             --wave-length-z ${waveLengthZ} \
             --waves-number ${wavesNumber} \
             --waves-number-x ${wavesNumberX} \
             --waves-number-y ${wavesNumberY} \
             --waves-number-z ${wavesNumberZ} \
             --phase ${phase} \
             --phase-x ${phaseX} \
             --phase-y ${phaseY} \
             --phase-z ${phaseZ} \
             --sigma ${sigma} \
 No newline at end of file
+3 −3
Original line number Diff line number Diff line
@@ -25,8 +25,8 @@
#include <operators/diffusion/tnlLinearDiffusion.h>
#include <operators/diffusion/tnlExactLinearDiffusion.h>
#include <operators/tnlAnalyticDirichletBoundaryConditions.h>
#include "tnlHeatEquationEocRhs.h"
#include "heatEquationEocSolver.h"
#include <problems/tnlHeatEquationEocRhs.h>
#include <problems/tnlHeatEquationEocProblem.h>

//typedef tnlDefaultConfigTag BuildConfig;
typedef tnlFastBuildConfig BuildConfig;
@@ -68,7 +68,7 @@ class heatEquationSetter
      typedef tnlHeatEquationEocRhs< ExactOperator, TestFunction > RightHandSide;
      typedef tnlStaticVector < MeshType::Dimensions, Real > Vertex;
      typedef tnlAnalyticDirichletBoundaryConditions< MeshType, TestFunction, Real, Index > BoundaryConditions;
      typedef heatEquationEocSolver< MeshType, ApproximateOperator, BoundaryConditions, RightHandSide > Solver;
      typedef tnlHeatEquationEocProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator > Solver;
      SolverStarter solverStarter;
      return solverStarter.template run< Solver >( parameters );
   };
Loading