Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
hyteg
hyteg
Commits
10e03d0c
Commit
10e03d0c
authored
Aug 16, 2021
by
Marcel Koch
Browse files
clean up ginkgo test
parent
f20daf76
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/hyteg/P1/P1GinkgoSolveTest.cpp
View file @
10e03d0c
...
...
@@ -31,6 +31,7 @@
#include "hyteg/misc/ExactStencilWeights.hpp"
#include "hyteg/p1functionspace/P1ConstantOperator.hpp"
#include "hyteg/p1functionspace/P1Function.hpp"
#include "hyteg/elementwiseoperators/P1ElementwiseOperator.hpp"
#include "hyteg/primitivestorage/SetupPrimitiveStorage.hpp"
#include "hyteg/primitivestorage/Visualization.hpp"
#include "hyteg/primitivestorage/loadbalancing/SimpleBalancer.hpp"
...
...
@@ -69,7 +70,9 @@ void ginkgoSolveTest( const uint_t& level,
hyteg
::
P1Function
<
real_t
>
err
(
"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
)
{
return
sin
(
xx
[
0
]
)
*
sinh
(
xx
[
1
]
);
...
...
@@ -82,43 +85,28 @@ void ginkgoSolveTest( const uint_t& level,
b
.
interpolate
(
exact
,
level
,
hyteg
::
DirichletBoundary
);
x_exact
.
interpolate
(
exact
,
level
);
// x.interpolate( exact, level + 1, hyteg::DirichletBoundary );
// x.interpolate( rand, level + 1, hyteg::Inner );
// b.interpolate( exact, level + 1, hyteg::DirichletBoundary );
// x_exact.interpolate( exact, level + 1 );
uint_t
localDoFs
=
hyteg
::
numberOfLocalDoFs
<
P1FunctionTag
>
(
*
storage
,
level
);
uint_t
globalDoFs
=
hyteg
::
numberOfGlobalDoFs
<
P1FunctionTag
>
(
*
storage
,
level
);
uint_t
localDoFs1
=
hyteg
::
numberOfLocalDoFs
<
P1FunctionTag
>
(
*
storage
,
level
);
// 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
(
"localDoFs: "
<<
localDoFs
<<
" globalDoFs: "
<<
globalDoFs
);
WALBERLA_LOG_INFO
(
"localDoFs1: "
<<
localDoFs1
<<
" globalDoFs1: "
<<
globalDoFs1
);
// WALBERLA_LOG_INFO( "localDoFs2: " << localDoFs2 << " globalDoFs2: " << globalDoFs2 );
GinkgoCGSolver
<
hyteg
::
P1ConstantLaplaceOperator
>
solver_1
{
storage
,
level
,
constraints
::
zero_row
,
1e-30
,
1e-12
,
1000
,
exec
};
GinkgoCGSolver
<
Op
>
solver
{
storage
,
level
,
constraints
::
penalty
,
1e-30
,
1e-12
,
1000
,
exec
};
solver
.
setPrintInfo
(
true
);
walberla
::
WcTimer
timer
;
solver_1
.
solve
(
A
,
x
,
b
,
level
);
// solver_2.solve( A, x, b, x, level + 1, 0, 0 );
solver
.
solve
(
A
,
x
,
b
,
level
);
timer
.
end
();
WALBERLA_LOG_INFO_ON_ROOT
(
"time was: "
<<
timer
.
last
()
);
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 + 1 );
real_t
discr_l2_err_1
=
std
::
sqrt
(
err
.
dotGlobal
(
err
,
level
)
/
(
real_t
)
globalDoFs1
);
// real_t discr_l2_err_2 = std::sqrt( err.dotGlobal( err, level + 1 ) / (real_t) globalDoFs2 );
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 );
real_t
discr_l2_err
=
std
::
sqrt
(
err
.
dotGlobal
(
err
,
level
)
/
(
real_t
)
globalDoFs
);
real_t
residuum_l2
=
std
::
sqrt
(
residuum
.
dotGlobal
(
residuum
,
level
)
/
(
real_t
)
globalDoFs
);
WALBERLA_LOG_INFO_ON_ROOT
(
"discrete L2 error 1 = "
<<
discr_l2_err_1
);
// WALBERLA_LOG_INFO_ON_ROOT( "discrete L2 error 2 = " << discr_l2_err_2 );
// 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 );
WALBERLA_LOG_INFO_ON_ROOT
(
"discrete L2 error 1 = "
<<
discr_l2_err
);
WALBERLA_LOG_INFO_ON_ROOT
(
"residuum 1 = "
<<
residuum_l2
);
// VTKOutput vtkOutput("../../output", "P1GinkgoSolve", storage);
// vtkOutput.add( x );
...
...
@@ -127,13 +115,9 @@ void ginkgoSolveTest( const uint_t& level,
// vtkOutput.add( residuum );
// vtkOutput.write( level );
WALBERLA_CHECK_FLOAT_EQUAL_EPSILON
(
residuum_l2_1
,
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_FLOAT_EQUAL_EPSILON
(
residuum_l2
,
0.0
,
1e-11
);
WALBERLA_CHECK_LESS
(
discr_l2_err
,
errEps
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment