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

Improving the Dirichlet boundary conditions.

parent b247882c
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
TODO: test aproximace pro implicitni schemata 
TODO: pokusit se napsat test explicitni aproximace podobne jako implicinit bez specializace pro grid
TODO: doladit semi-implicitni resic
TODO: doladit heat eq. eoc test
TODO: opravit argumenty metod v heat equation - nekde se nepredavaji dofy a pomocne dofy
TODO: doresit okrajove podminky v heat equation - nacitani ze souboru
      => soucasne Dir. a Neum. okrajove podminky prejmenovat asi tnlAnalytic... a zavest nove tnlDirichlet... a tnlNeumann...
      ktere budou mit sve hodnoty ulozene  ve vektoru      
TODO: neumanovy okrajove podminky
TODO: doladit iterativni resice 
      * nepocitaji se iterace
      * iterovat podle metody nextIteration
      * naspat metodu checkConvergence - ta se vola na konci a napise hlaksu, proc resic pripadne neskonvergoval
TODO: doladit vse s CUDA
TODO: doplnit mesh travelsals pro jine mesh entity nez cell
TODO: implementace maticovych resicu
+2 −2
Original line number Diff line number Diff line
@@ -65,8 +65,8 @@ bool
heatEquationSolver< Mesh, DifferentialOperator, BoundaryCondition, RightHandSide >::
setup( const tnlParameterContainer& parameters )
{
   if( ! boundaryCondition.setup( parameters ) ||
       ! rightHandSide.setup( parameters ) )
   if( ! boundaryCondition.setup( parameters, "boundary-conditions-" ) ||
       ! rightHandSide.setup( parameters, "right-hand-side-" ) )
      return false;
   return true;
}
+2 −2
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@
#include <functions/tnlTestFunction.h>
#include <operators/diffusion/tnlLinearDiffusion.h>
#include <operators/diffusion/tnlExactLinearDiffusion.h>
#include <operators/tnlDirichletBoundaryConditions.h>
#include <operators/tnlAnalyticDirichletBoundaryConditions.h>
#include "tnlHeatEquationEocRhs.h"
#include "heatEquationSolver.h"

@@ -64,7 +64,7 @@ class heatEquationSetter
      typedef tnlTestFunction< MeshType::Dimensions, Real, Device > TestFunction;
      typedef tnlHeatEquationEocRhs< ExactOperator, TestFunction > RightHandSide;
      typedef tnlStaticVector < MeshType::Dimensions, Real > Vertex;
      typedef tnlDirichletBoundaryConditions< MeshType, TestFunction, Real, Index > BoundaryConditions;
      typedef tnlAnalyticDirichletBoundaryConditions< MeshType, TestFunction, Real, Index > BoundaryConditions;
      typedef heatEquationSolver< MeshType, ApproximateOperator, BoundaryConditions, RightHandSide > Solver;
      SolverStarter solverStarter;
      return solverStarter.template run< Solver >( parameters );
+17 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <solvers/tnlFastBuildConfig.h>
#include <solvers/tnlConfigTags.h>
#include <operators/diffusion/tnlLinearDiffusion.h>
#include <operators/tnlAnalyticDirichletBoundaryConditions.h>
#include <operators/tnlDirichletBoundaryConditions.h>
#include <functions/tnlConstantFunction.h>
#include "heatEquationSolver.h"
@@ -36,7 +37,10 @@ class heatEquationConfig
         config.addEntry< tnlString >( "boundary-conditions-type", "Choose the boundary conditions type.", "dirichlet");
            config.addEntryEnum< tnlString >( "dirichlet" );
            config.addEntryEnum< tnlString >( "neumann" );
         config.addEntry< tnlString >( "boundary-conditions", "File with the values of the boundary conditions.", "boundary.tnl" );

         config.addEntry< tnlString >( "boundary-conditions-file", "File with the values of the boundary conditions.", "boundary.tnl" );
         config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." );
         config.addEntry< double >( "right-hand-side-constant", "This sets a constant value for the right-hand side.", 0.0 );
         config.addEntry< tnlString >( "initial-condition", "File with the initial condition.", "initial.tnl");
      };
};
@@ -63,7 +67,18 @@ class heatEquationSetter
      typedef tnlLinearDiffusion< MeshType, Real, Index > ApproximateOperator;
      typedef tnlConstantFunction< Dimensions, Real > RightHandSide;
      typedef tnlStaticVector < MeshType::Dimensions, Real > Vertex;
      typedef tnlDirichletBoundaryConditions< MeshType, RightHandSide, Real, Index > BoundaryConditions;

      tnlString boundaryConditionsType = parameters.GetParameter< tnlString >( "boundary-conditions-type" );
      if( parameters.CheckParameter( "boundary-conditions-constant" ) )
      {
         typedef tnlConstantFunction< Dimensions, Real > ConstantFunction;
         typedef tnlAnalyticDirichletBoundaryConditions< MeshType, ConstantFunction, Real, Index > BoundaryConditions;
         typedef heatEquationSolver< MeshType, ApproximateOperator, BoundaryConditions, RightHandSide > Solver;
         SolverStarter solverStarter;
         return solverStarter.template run< Solver >( parameters );
      }
      typedef tnlVector< Real, Device, Index > VectorType;
      typedef tnlDirichletBoundaryConditions< MeshType, VectorType, Real, Index > BoundaryConditions;
      typedef heatEquationSolver< MeshType, ApproximateOperator, BoundaryConditions, RightHandSide > Solver;
      SolverStarter solverStarter;
      return solverStarter.template run< Solver >( parameters );
+25 −62
Original line number Diff line number Diff line
#!/bin/bash

dofSize=128
dimension=1;
dofSize=64
dimension=2;
proportions=1

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

amplitude=1.0
@@ -34,8 +34,8 @@ tnl-grid-setup --dimensions ${dimension} \
               --size-z ${dofSize} \
               
tnl-init --mesh mesh.tnl \
             --function ${analyticFunction} \
             --output-file u-ini.tnl \
         --test-function ${analyticFunction} \
         --output-file initial.tnl \
         --amplitude ${amplitude} \
         --wave-length ${waveLength} \
         --wave-length-x ${waveLengthX} \
@@ -51,34 +51,20 @@ tnl-init --mesh mesh.tnl \
             --phase-z ${phaseZ} \
             --sigma ${sigma} \

./heat-equation --dimensions ${dimension} \
                --time-discretisation explicit \
tnl-heat-equation --time-discretisation explicit \
                  --boundary-conditions-type dirichlet \
                  --boundary-conditions-constant 0.5 \
                  --discrete-solver merson \
                --time-function ${timeFunction}\
                --analytic-space-function ${analyticFunction}\
                --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} \
                --snapshot-period 0.001 \
                --final-time 1.0 \
                  --snapshot-period 0.0005 \
                  --final-time 0.1 \
              
tnl-view --mesh mesh.tnl \
         --input-files *.tnl \ 

seznam=`ls numericalSolution-*.gplt`
seznam=`ls u-*.gplt`

for fname in $seznam ; do
   echo "Drawing $fname"
gnuplot << EOF
    set terminal unknown
    #set view 33,33 #3D
@@ -87,41 +73,18 @@ gnuplot << EOF
    #unset ztics
    unset border
    set output '$fname.png'
    plot 'numericalSolution-00000.gplt' with line 
    set yrange [-1.2:1.2]
    set zrange [0.4:1.1]    
    set terminal png
    set title "Numerical solution" 
    plot '$fname' with line 
EOF
done


mencoder "mf://numericalSolution-*.png" -mf fps=22 -o DiffusionNumerical.avi -ovc lavc -lavcopts vcodec=mpeg4

seznam=`ls analyticSolution-*.gplt`

for fname in $seznam ; do
gnuplot << EOF
    set terminal unknown
    #set view 33,33 #3D
    #unset xtics 
    #unset ytics
    #unset ztics
    unset border
    set output '$fname.png'
    plot 'analyticSolution-00000.gplt' with line 
    set yrange [-1.2:1.2]    
    set terminal png
    set title "Analytic solution" 
    plot '$fname' with line 
    splot '$fname' with line 
EOF
done


mencoder "mf://analyticSolution-*.png" -mf fps=22 -o DiffusionAnalytic.avi -ovc lavc -lavcopts vcodec=mpeg4
      
rm *.png
rm *.tnl      
mencoder "mf://u-*.png" -mf fps=22 -o diffusion.avi -ovc lavc -lavcopts vcodec=mpeg4

rm *.gplt      
#rm *.png
#rm *.tnl         
#rm *.gplt      
              
Loading