Commit 6cfac331 authored by Markus Holzer's avatar Markus Holzer
Browse files

Small changes

parent 5f071be4
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// This file is part of waLBerla. waLBerla 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 3 of
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
......@@ -19,56 +19,52 @@
//
//======================================================================================================================
#include "field/GhostLayerField.h"
#include "field/interpolators/NearestNeighborInterpolator.h"
#include "field/interpolators/TrilinearInterpolator.h"
#include "core/debug/TestSubsystem.h"
#include "core/mpi/Environment.h"
#include "field/GhostLayerField.h"
#include "field/interpolators/NearestNeighborInterpolator.h"
#include "field/interpolators/TrilinearInterpolator.h"
using namespace walberla;
void testNearestNeighbor1D()
{
GhostLayerField<real_t,1> field ( 2,2,2,2, 0);
GhostLayerField< real_t, 1 > field(2, 2, 2, 2, 0);
for( auto it = field.beginWithGhostLayer(); it != field.end(); ++it )
for (auto it = field.beginWithGhostLayer(); it != field.end(); ++it)
*it = real_c(it.x());
field::NearestNeighborInterpolator<GhostLayerField<real_t,1> > ip ( field );
field::NearestNeighborInterpolator< GhostLayerField< real_t, 1 > > ip(field);
WALBERLA_CHECK_FLOAT_EQUAL( ip( real_c(0), real_c(0), real_c(0) ), real_c(0) );
WALBERLA_CHECK_FLOAT_EQUAL( ip( real_c(0.5), real_c(0), real_c(0) ), real_c(0) );
WALBERLA_CHECK_FLOAT_EQUAL( ip(-real_c(0.5), real_c(0), real_c(0) ), -real_c(1) );
WALBERLA_CHECK_FLOAT_EQUAL( ip( real_c(1.9), real_c(0), real_c(0) ), real_c(1) );
WALBERLA_CHECK_FLOAT_EQUAL(ip(real_c(0), real_c(0), real_c(0)), real_c(0))
WALBERLA_CHECK_FLOAT_EQUAL(ip(real_c(0.5), real_c(0), real_c(0)), real_c(0))
WALBERLA_CHECK_FLOAT_EQUAL(ip(-real_c(0.5), real_c(0), real_c(0)), -real_c(1))
WALBERLA_CHECK_FLOAT_EQUAL(ip(real_c(1.9), real_c(0), real_c(0)), real_c(1))
}
void testTrilinear1D()
{
GhostLayerField<real_t,1> field ( 2,2,2,2, 0);
GhostLayerField< real_t, 1 > field(2, 2, 2, 2, 0);
for( auto it = field.beginWithGhostLayer(); it != field.end(); ++it )
for (auto it = field.beginWithGhostLayer(); it != field.end(); ++it)
*it = real_c(it.x());
field::TrilinearInterpolator<GhostLayerField<real_t,1> > ip ( field );
field::TrilinearInterpolator< GhostLayerField< real_t, 1 > > ip(field);
WALBERLA_CHECK_FLOAT_EQUAL( ip( real_c(0.5), real_c(0.5), real_c(0.5) ), real_c(0) );
WALBERLA_CHECK_FLOAT_EQUAL(ip(real_c(0.5), real_c(0.5), real_c(0.5)), real_c(0))
// Left Hit
WALBERLA_CHECK_FLOAT_EQUAL( ip( real_c(0), real_c(0), real_c(0) ), -real_c(0.5) );
WALBERLA_CHECK_FLOAT_EQUAL(ip(real_c(0), real_c(0), real_c(0)), -real_c(0.5))
// Right Hit
WALBERLA_CHECK_FLOAT_EQUAL( ip( real_c(1), real_c(0), real_c(0) ), real_c(0.5) );
WALBERLA_CHECK_FLOAT_EQUAL(ip(real_c(1), real_c(0), real_c(0)), real_c(0.5))
// Left boundary included
WALBERLA_CHECK_FLOAT_EQUAL( ip( -real_c(0.5), real_c(0), real_c(0) ), -real_c(1) );
WALBERLA_CHECK_FLOAT_EQUAL(ip(-real_c(0.5), real_c(0), real_c(0)), -real_c(1))
}
int main( int argc, char**argv )
int main(int argc, char** argv)
{
mpi::Environment mpiEnv( argc, argv );
mpi::Environment mpiEnv(argc, argv);
debug::enterTestMode();
testTrilinear1D();
......
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