Commit 10e03d0c authored by Marcel Koch's avatar Marcel Koch
Browse files

clean up ginkgo test

parent f20daf76
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "hyteg/misc/ExactStencilWeights.hpp" #include "hyteg/misc/ExactStencilWeights.hpp"
#include "hyteg/p1functionspace/P1ConstantOperator.hpp" #include "hyteg/p1functionspace/P1ConstantOperator.hpp"
#include "hyteg/p1functionspace/P1Function.hpp" #include "hyteg/p1functionspace/P1Function.hpp"
#include "hyteg/elementwiseoperators/P1ElementwiseOperator.hpp"
#include "hyteg/primitivestorage/SetupPrimitiveStorage.hpp" #include "hyteg/primitivestorage/SetupPrimitiveStorage.hpp"
#include "hyteg/primitivestorage/Visualization.hpp" #include "hyteg/primitivestorage/Visualization.hpp"
#include "hyteg/primitivestorage/loadbalancing/SimpleBalancer.hpp" #include "hyteg/primitivestorage/loadbalancing/SimpleBalancer.hpp"
...@@ -69,7 +70,9 @@ void ginkgoSolveTest( const uint_t& level, ...@@ -69,7 +70,9 @@ void ginkgoSolveTest( const uint_t& level,
hyteg::P1Function< real_t > err( "err", storage, level, level + 1 ); hyteg::P1Function< real_t > err( "err", storage, level, level + 1 );
hyteg::P1Function< real_t > residuum( "err", storage, level, level + 1 ); hyteg::P1Function< real_t > residuum( "err", storage, level, level + 1 );
hyteg::P1ConstantLaplaceOperator A( storage, level, level + 1 ); //using Op = hyteg::P1ConstantLaplaceOperator;
using Op = hyteg::P1ElementwiseLaplaceOperator;
Op A(storage, level, level + 1);
std::function< real_t( const hyteg::Point3D& ) > exact = []( const hyteg::Point3D& xx ) { std::function< real_t( const hyteg::Point3D& ) > exact = []( const hyteg::Point3D& xx ) {
return sin( xx[0] ) * sinh( xx[1] ); return sin( xx[0] ) * sinh( xx[1] );
...@@ -82,43 +85,28 @@ void ginkgoSolveTest( const uint_t& level, ...@@ -82,43 +85,28 @@ void ginkgoSolveTest( const uint_t& level,
b.interpolate( exact, level, hyteg::DirichletBoundary ); b.interpolate( exact, level, hyteg::DirichletBoundary );
x_exact.interpolate( exact, level ); x_exact.interpolate( exact, level );
// x.interpolate( exact, level + 1, hyteg::DirichletBoundary ); uint_t localDoFs = hyteg::numberOfLocalDoFs< P1FunctionTag >( *storage, level );
// x.interpolate( rand, level + 1, hyteg::Inner ); uint_t globalDoFs = hyteg::numberOfGlobalDoFs< P1FunctionTag >( *storage, level );
// b.interpolate( exact, level + 1, hyteg::DirichletBoundary );
// x_exact.interpolate( exact, level + 1 );
uint_t localDoFs1 = hyteg::numberOfLocalDoFs< P1FunctionTag >( *storage, level ); WALBERLA_LOG_INFO( "localDoFs: " << localDoFs << " globalDoFs: " << globalDoFs );
// uint_t localDoFs2 = hyteg::numberOfLocalDoFs< P1FunctionTag >( *storage, level + 1 );
uint_t globalDoFs1 = hyteg::numberOfGlobalDoFs< P1FunctionTag >( *storage, level );
// uint_t globalDoFs2 = hyteg::numberOfGlobalDoFs< P1FunctionTag >( *storage, level + 1 );
WALBERLA_LOG_INFO( "localDoFs1: " << localDoFs1 << " globalDoFs1: " << globalDoFs1 ); GinkgoCGSolver< Op > solver{ storage, level, constraints::penalty, 1e-30, 1e-12, 1000, exec };
// WALBERLA_LOG_INFO( "localDoFs2: " << localDoFs2 << " globalDoFs2: " << globalDoFs2 ); solver.setPrintInfo(true);
GinkgoCGSolver< hyteg::P1ConstantLaplaceOperator > solver_1{ storage, level, constraints::zero_row, 1e-30, 1e-12, 1000, exec };
walberla::WcTimer timer; walberla::WcTimer timer;
solver_1.solve( A, x, b, level ); solver.solve( A, x, b, level );
// solver_2.solve( A, x, b, x, level + 1, 0, 0 );
timer.end(); timer.end();
WALBERLA_LOG_INFO_ON_ROOT( "time was: " << timer.last() ); WALBERLA_LOG_INFO_ON_ROOT( "time was: " << timer.last() );
A.apply( x, residuum, level, hyteg::Inner ); A.apply( x, residuum, level, hyteg::Inner );
// A.apply( x, residuum, level + 1, hyteg::Inner );
err.assign( {1.0, -1.0}, {x, x_exact}, level ); err.assign( {1.0, -1.0}, {x, x_exact}, level );
// err.assign( {1.0, -1.0}, {x, x_exact}, level + 1 );
real_t discr_l2_err_1 = std::sqrt( err.dotGlobal( err, level ) / (real_t) globalDoFs1 ); real_t discr_l2_err = std::sqrt( err.dotGlobal( err, level ) / (real_t) globalDoFs );
// real_t discr_l2_err_2 = std::sqrt( err.dotGlobal( err, level + 1 ) / (real_t) globalDoFs2 ); real_t residuum_l2 = std::sqrt( residuum.dotGlobal( residuum, level ) / (real_t) globalDoFs );
real_t residuum_l2_1 = std::sqrt( residuum.dotGlobal( residuum, level ) / (real_t) globalDoFs1 );
// real_t residuum_l2_2 = std::sqrt( residuum.dotGlobal( residuum, level + 1 ) / (real_t) globalDoFs2 );
WALBERLA_LOG_INFO_ON_ROOT( "discrete L2 error 1 = " << discr_l2_err_1 ); WALBERLA_LOG_INFO_ON_ROOT( "discrete L2 error 1 = " << discr_l2_err );
// WALBERLA_LOG_INFO_ON_ROOT( "discrete L2 error 2 = " << discr_l2_err_2 ); WALBERLA_LOG_INFO_ON_ROOT( "residuum 1 = " << residuum_l2 );
// WALBERLA_LOG_INFO_ON_ROOT( "error ratio = " << ( discr_l2_err_1 / discr_l2_err_2 ) );
WALBERLA_LOG_INFO_ON_ROOT( "residuum 1 = " << residuum_l2_1 );
// WALBERLA_LOG_INFO_ON_ROOT( "residuum 2 = " << residuum_l2_2 );
// VTKOutput vtkOutput("../../output", "P1GinkgoSolve", storage); // VTKOutput vtkOutput("../../output", "P1GinkgoSolve", storage);
// vtkOutput.add( x ); // vtkOutput.add( x );
...@@ -127,13 +115,9 @@ void ginkgoSolveTest( const uint_t& level, ...@@ -127,13 +115,9 @@ void ginkgoSolveTest( const uint_t& level,
// vtkOutput.add( residuum ); // vtkOutput.add( residuum );
// vtkOutput.write( level ); // vtkOutput.write( level );
WALBERLA_CHECK_FLOAT_EQUAL_EPSILON( residuum_l2_1, 0.0, 1e-11 ); WALBERLA_CHECK_FLOAT_EQUAL_EPSILON( residuum_l2, 0.0, 1e-11 );
//WALBERLA_CHECK_FLOAT_EQUAL_EPSILON( residuum_l2_2, 0.0, 1e-15 );
WALBERLA_CHECK_LESS( discr_l2_err_1, errEps );
//WALBERLA_CHECK_LESS( 8.0, ( discr_l2_err_1 / discr_l2_err_2 ) );
WALBERLA_CHECK_LESS( discr_l2_err, errEps );
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment