Commit 7e5a1344 authored by Marcus Mohr's avatar Marcus Mohr
Browse files

Adds a basic JSON read test

For computing plate velocities in terraneo we need to import plate shapes
at different ages. The corresponding datafile is in JSON format. This tests
checks that the basic import functionality of the JSON library we inherit
via waLBerla works for such files.
parent dc32756e
......@@ -86,6 +86,10 @@ if(NOT EXISTS ${CMAKE_BINARY_DIR}/data/meshes/3D)
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/data/meshes/3D")
endif()
if(NOT EXISTS ${CMAKE_BINARY_DIR}/data/json)
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/data/json")
endif()
if(NOT EXISTS ${CMAKE_BINARY_DIR}/data/param)
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/data/param")
endif()
......@@ -102,6 +106,7 @@ if(NOT EXISTS ${CMAKE_BINARY_DIR}/data/kerncraftMachineFiles)
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/data/kerncraftMachineFiles")
endif()
waLBerla_link_files_to_builddir(data/json/*.json)
waLBerla_link_files_to_builddir(data/meshes/*.msh)
waLBerla_link_files_to_builddir(data/meshes/3D/*.msh)
waLBerla_link_files_to_builddir(data/param/*.prm)
......
{
"solver": "GMRES",
"tolerance": 1e-6,
"maxIterations": 200,
"preconditionerType": "Multigrid",
"preconditionerParams": {
"smoother": "Chebyshev",
"preSmooth": 3,
"postSmooth": 3,
"coarseGridSolver": "MUMPS"
}
}
add_subdirectory( hyteg )
add_subdirectory( convection_particles )
\ No newline at end of file
add_subdirectory( convection_particles )
add_subdirectory( terraneo )
waLBerla_compile_test(FILES json/BasicJSONReadTest.cpp DEPENDS hyteg core )
waLBerla_execute_test(NAME BasicJSONReadTest)
/*
* Copyright (c) 2022 Marcus Mohr.
*
* This file is part of HyTeG
* (see https://i10git.cs.fau.de/hyteg/hyteg).
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Check that we get neither compile- nor run-time errors, when
// trying to print meta information on the build
#include "core/Environment.h"
#include "core/debug/CheckFunctions.h"
#include "core/extern/json.hpp"
#include "core/logging/Logging.h"
#include "hyteg/BuildInfo.hpp"
#include "hyteg/Git.hpp"
using namespace hyteg;
int main( int argc, char* argv[] )
{
walberla::Environment walberlaEnv( argc, argv );
walberla::logging::Logging::instance()->setLogLevel( walberla::logging::Logging::PROGRESS );
walberla::MPIManager::instance()->useWorldComm();
std::string separator{"--------------------------------------------------"};
WALBERLA_LOG_INFO_ON_ROOT( separator );
printBuildInfo();
printGitInfo();
WALBERLA_LOG_INFO_ON_ROOT( separator );
std::string jsonFileName{"../../data/json/BasicJSONReadTest.json"};
std::ifstream jsonFile;
WALBERLA_LOG_INFO_ON_ROOT( "Opening '" << jsonFileName << "'" );
jsonFile.open( jsonFileName.c_str() );
WALBERLA_CHECK( !!jsonFile, "Error opening file: " << jsonFileName );
WALBERLA_LOG_INFO_ON_ROOT( "Reading '" << jsonFileName << "'" );
nlohmann::json jsonObject;
jsonFile >> jsonObject;
WALBERLA_LOG_INFO_ON_ROOT( "\n" << jsonObject.dump(4) );
WALBERLA_CHECK_EQUAL( jsonObject[ "preconditionerType" ], "Multigrid" );
WALBERLA_CHECK_EQUAL( jsonObject[ "preconditionerParams" ][ "preSmooth" ], 3 );
return 0;
}
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