diff --git a/CMakeLists.txt b/CMakeLists.txt index e1aa10ca985e0c8123b50811a680957beb1c613b..dd233617914b79438a9c68835da08db7ad0750fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -343,12 +343,6 @@ if(OGS_BUILD_CLI OR OGS_BUILD_UTILS OR BUILD_TESTING) endif() if( BUILD_TESTING AND NOT IS_SUBPROJECT ) add_subdirectory( Tests ) - - if(OGS_USE_MPI) - add_subdirectory( SimpleTests/MeshTests/MPI ) - else() - add_subdirectory( SimpleTests/MeshTests ) - endif() endif() file(WRITE ${PROJECT_BINARY_DIR}/disabled-tests.log "${DISABLED_TESTS_LOG}") diff --git a/SimpleTests/MeshTests/CMakeLists.txt b/SimpleTests/MeshTests/CMakeLists.txt deleted file mode 100644 index afc33c04688b934ffaab617a7bc29670b73e0e1b..0000000000000000000000000000000000000000 --- a/SimpleTests/MeshTests/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# Create the executable -add_executable(MeshRead - MeshRead.cpp - ${SOURCES} - ${HEADERS} -) - -target_link_libraries(MeshRead - MeshLib - MathLib - BaseLib - GeoLib - ${BOOST_LIBRARIES} -) - -# Create MeshSearchTest executable -add_executable(MeshSearchTest - MeshSearchTest.cpp - ${SOURCES} - ${HEADERS} -) - -target_link_libraries(MeshSearchTest - MeshLib - MathLib - BaseLib - GeoLib - ${BOOST_LIBRARIES} -) diff --git a/SimpleTests/MeshTests/MPI/CMakeLists.txt b/SimpleTests/MeshTests/MPI/CMakeLists.txt deleted file mode 100644 index d860bec2028ec88c6f5b15becd2353d8b11584cd..0000000000000000000000000000000000000000 --- a/SimpleTests/MeshTests/MPI/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -add_executable(test_node_partitioned_mesh - NodePartitionedMeshTester.cpp -) - -target_link_libraries(test_node_partitioned_mesh - MeshLib - ${ADDITIONAL_LIBS} - ${BOOST_LIBRARIES} -) - -if(OGS_USE_PETSC) - target_link_libraries(test_node_partitioned_mesh ${PETSC_LIBRARIES}) -endif() - -if(OGS_USE_MPI) - target_link_libraries(test_node_partitioned_mesh MPI::MPI_CXX) -endif() - -AddTest( - NAME NodePartitionedMeshTestASCII - PATH NodePartitionedMesh/ASCII - EXECUTABLE test_node_partitioned_mesh - EXECUTABLE_ARGS mesh_3d ${Data_BINARY_DIR}/NodePartitionedMesh/ASCII - WRAPPER mpirun - WRAPPER_ARGS -np 3 - TESTER diff - DIFF_DATA mesh_3d_partition_0.msh mesh_3d_partition_1.msh mesh_3d_partition_2.msh -) - -AddTest( - NAME NodePartitionedMeshTestBinary - PATH NodePartitionedMesh/Binary - EXECUTABLE test_node_partitioned_mesh - EXECUTABLE_ARGS mesh_3d ${Data_BINARY_DIR}/NodePartitionedMesh/Binary - WRAPPER mpirun - WRAPPER_ARGS -np 3 - TESTER diff - DIFF_DATA mesh_3d_partition_0.msh mesh_3d_partition_1.msh mesh_3d_partition_2.msh -) diff --git a/SimpleTests/MeshTests/MPI/NodePartitionedMeshTester.cpp b/SimpleTests/MeshTests/MPI/NodePartitionedMeshTester.cpp deleted file mode 100644 index e0152154613a9c6ea23291b189d629a06aec85dc..0000000000000000000000000000000000000000 --- a/SimpleTests/MeshTests/MPI/NodePartitionedMeshTester.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/*! - \file NodePartitionedMeshTester.cpp - \author Wenqing Wang - \date 2014.11 - \brief Test class readNodePartitionedMesh to read node-wise partitioned mesh - with MPI functions. - - \copyright - Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org) - Distributed under a Modified BSD License. - See accompanying file LICENSE.txt or - http://www.opengeosys.org/project/license -*/ - -#include <iomanip> -#include <fstream> -#include <string> - -#include <mpi.h> - -#ifdef USE_PETSC -#include <petscksp.h> -#endif - -#include <logog/include/logog.hpp> - -#include "BaseLib/FileTools.h" -#include "BaseLib/LogogCustomCout.h" -#include "BaseLib/TemplateLogogFormatterSuppressedGCC.h" - -#include "MeshLib/IO/MPI_IO/NodePartitionedMeshReader.h" - -#include "MeshLib/Node.h" -#include "MeshLib/Elements/Element.h" - -using namespace MeshLib; - -int main(int argc, char *argv[]) -{ - LOGOG_INITIALIZE(); - - MPI_Init(&argc, &argv); - -#ifdef USE_PETSC - char help[] = "ogs6 with PETSc \n"; - PetscInitialize(&argc, &argv, nullptr, help); -#endif - - BaseLib::LogogCustomCout* out = new BaseLib::LogogCustomCout(1); - using LogogFormatter = BaseLib::TemplateLogogFormatterSuppressedGCC - <TOPIC_LEVEL_FLAG | TOPIC_FILE_NAME_FLAG | TOPIC_LINE_NUMBER_FLAG>; - LogogFormatter* fmt = new LogogFormatter(); - - out->SetFormatter(*fmt); - - const std::string file_name = argv[1]; - std::string output_dir = ""; - if (argc > 2) - output_dir = argv[2]; - - NodePartitionedMesh *mesh = nullptr; - { - MeshLib::IO::NodePartitionedMeshReader read_pmesh(MPI_COMM_WORLD); - mesh = read_pmesh.read(file_name); - } - if (!mesh) - { - ERR("Could not read mesh from files with prefix %s.", file_name.c_str()); - return EXIT_FAILURE; - } - - int rank; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - const std::string rank_str = std::to_string(rank); - const std::string ofile_name = file_name + "_partition_" + rank_str + ".msh"; - std::ofstream os(BaseLib::joinPaths(output_dir, ofile_name), std::ios::trunc); - - // Output nodes - os.setf(std::ios::scientific, std::ios::floatfield); - std::setprecision(10); - const std::size_t nn = mesh->getNumberOfNodes(); - for(std::size_t i=0; i<nn; i++) - { - const double *x = mesh->getNode(i)->getCoords(); - os << mesh->getNode(i)->getID() << " " - << std::setw(14) << x[0] << " " << x[1] << " "<< x[2] << "\n"; - } - os.flush(); - - // Output elements - const std::size_t ne = mesh->getNumberOfElements(); - for(std::size_t i=0; i<ne; i++) - { - const Element *elem = mesh->getElement(i); - Node* const* ele_nodes = elem->getNodes(); - - for(unsigned j=0; j<elem->getNumberOfNodes(); j++) - { - os << ele_nodes[j]->getID() << " "; - } - os << "\n"; - } - os.flush(); - - delete mesh; - - delete out; - delete fmt; - -#ifdef USE_PETSC - PetscFinalize(); -#endif - - MPI_Finalize(); - - LOGOG_SHUTDOWN(); -} diff --git a/SimpleTests/MeshTests/MeshRead.cpp b/SimpleTests/MeshTests/MeshRead.cpp deleted file mode 100644 index 5f40406ea6a0dda095d721b64ca6ca6ffe90e264..0000000000000000000000000000000000000000 --- a/SimpleTests/MeshTests/MeshRead.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2012/05/09 - * \brief Test for reading meshes. - * - * \copyright - * Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#include <tclap/CmdLine.h> -#include <logog/include/logog.hpp> - -#include "BaseLib/LogogSimpleFormatter.h" -#include "BaseLib/MemWatch.h" -#include "BaseLib/RunTime.h" -#include "BaseLib/StringTools.h" -#include "BaseLib/FileTools.h" - -#include "MeshLib/IO/readMeshFromFile.h" - -#include "MeshLib/Node.h" -#include "MeshLib/Elements/Element.h" -#include "MeshLib/Mesh.h" - - -int main(int argc, char *argv[]) -{ - LOGOG_INITIALIZE(); - auto* custom_format(new BaseLib::LogogSimpleFormatter); - auto* logogCout(new logog::Cout); - logogCout->SetFormatter(*custom_format); - - TCLAP::CmdLine cmd("Simple mesh loading test", ' ', "0.1"); - - // Define a value argument and add it to the command line. - // A value arg defines a flag and a type of value that it expects, - // such as "-m meshfile". - TCLAP::ValueArg<std::string> mesh_arg("m","mesh","input mesh file",true,"homer","string"); - - // Add the argument mesh_arg to the CmdLine object. The CmdLine object - // uses this Arg to parse the command line. - cmd.add( mesh_arg ); - - cmd.parse( argc, argv ); - - std::string fname (mesh_arg.getValue()); - -#ifndef WIN32 - BaseLib::MemWatch mem_watch; - unsigned long mem_without_mesh (mem_watch.getVirtMemUsage()); -#endif - BaseLib::RunTime run_time; - run_time.start(); - MeshLib::Mesh* mesh = MeshLib::IO::readMeshFromFile(fname); -#ifndef WIN32 - unsigned long mem_with_mesh (mem_watch.getVirtMemUsage()); -// std::cout << "mem for mesh: " << (mem_with_mesh - mem_without_mesh)/(1024*1024) << " MB" << std::endl; - INFO ("mem for mesh: %i MB", (mem_with_mesh - mem_without_mesh)/(1024*1024)); -#endif - -// std::cout << "time for reading: " << run_time.elapsed() << " s" << std::endl; - INFO ("time for reading: %f s", run_time.elapsed()); - -/* - unsigned elem_id = 25000; - const MeshLib::Element* e = mesh->getElement(elem_id); - const std::size_t nElems = mesh->getNumberOfElements(); - for (unsigned i=0; i< e->getNumberOfNeighbors(); i++) - { - for (unsigned j=0; j< nElems; j++) - if (mesh->getElement(j) == e->getNeighbor(i)) - std::cout << "neighbour of element " << elem_id << " : " << j << std::endl; - } -*/ - - delete mesh; - delete logogCout; - delete custom_format; - LOGOG_SHUTDOWN(); -} - diff --git a/SimpleTests/MeshTests/MeshSearchTest.cpp b/SimpleTests/MeshTests/MeshSearchTest.cpp deleted file mode 100644 index 13f2d117422e8184b8c502414f21705110bcd9bc..0000000000000000000000000000000000000000 --- a/SimpleTests/MeshTests/MeshSearchTest.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/** - * Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/LICENSE.txt - * - * @file MeshSearchTest.cpp - * - * Created on Aug 30, 2012 by Thomas Fischer - */ - -#include <tclap/CmdLine.h> -#include <logog/include/logog.hpp> - -#include "BaseLib/LogogSimpleFormatter.h" -#include "BaseLib/MemWatch.h" -#include "BaseLib/RunTime.h" - -#include "MeshLib/IO/Legacy/MeshIO.h" - -#include "GeoLib/Grid.h" - -#include "MeshLib/Node.h" -#include "MeshLib/Elements/Element.h" -#include "MeshLib/Mesh.h" - -void testMeshGridAlgorithm(MeshLib::Mesh const*const mesh, - std::vector<GeoLib::Point*>& pnts_for_search, - std::vector<std::size_t> &idx_found_nodes, bool contiguous) -{ - // constructing Grid - INFO ("[MeshGridAlgorithm] constructing mesh grid object ..."); - - if (contiguous) { - std::vector<MeshLib::Node> mesh_nodes; - std::size_t n_nodes(mesh->getNodes().size()); - mesh_nodes.reserve(n_nodes); - for (std::size_t k(0); k<n_nodes; k++) { - mesh_nodes.emplace_back(*(mesh->getNodes()[k])); - } -#ifndef WIN32 - BaseLib::MemWatch mem_watch; - unsigned long mem_without_mesh (mem_watch.getVirtMemUsage()); -#endif - clock_t start_grid_construction = clock(); - GeoLib::Grid<MeshLib::Node> mesh_grid(mesh_nodes.begin(), mesh_nodes.end(), 511); - clock_t end_grid_construction = clock(); -#ifndef WIN32 - unsigned long mem_with_mesh (mem_watch.getVirtMemUsage()); -#endif - INFO("\tdone, construction time: %f seconds", (end_grid_construction-start_grid_construction)/(double)(CLOCKS_PER_SEC)); - #ifndef WIN32 - INFO ("[MeshGridAlgorithm] mem for mesh grid: %i MB", (mem_with_mesh - mem_without_mesh)/(1024*1024)); - #endif - const std::size_t n_pnts_for_search(pnts_for_search.size()); - INFO ("[MeshGridAlgorithm] searching %d points ...", pnts_for_search.size()); - clock_t start = clock(); - for (std::size_t k(0); k<n_pnts_for_search; k++) { - MeshLib::Node const* node(mesh_grid.getNearestPoint(*(pnts_for_search[k]))); - idx_found_nodes.push_back(node->getID()); - } - clock_t stop = clock(); - INFO("\tdone, search time: %f seconds", (stop-start)/(double)(CLOCKS_PER_SEC)); - } else { -#ifndef WIN32 - BaseLib::MemWatch mem_watch; - unsigned long mem_without_mesh (mem_watch.getVirtMemUsage()); -#endif - clock_t start_grid_construction = clock(); - GeoLib::Grid<MeshLib::Node> mesh_grid(mesh->getNodes().begin(), mesh->getNodes().end(), 511); - clock_t end_grid_construction = clock(); -#ifndef WIN32 - unsigned long mem_with_mesh (mem_watch.getVirtMemUsage()); -#endif - INFO("\tdone, construction time: %f seconds", (end_grid_construction-start_grid_construction)/(double)(CLOCKS_PER_SEC)); -#ifndef WIN32 - INFO ("[MeshGridAlgorithm] mem for mesh grid: %i MB", (mem_with_mesh - mem_without_mesh)/(1024*1024)); -#endif - const std::size_t n_pnts_for_search(pnts_for_search.size()); - INFO ("[MeshGridAlgorithm] searching %d points ...", pnts_for_search.size()); - clock_t start = clock(); - for (std::size_t k(0); k<n_pnts_for_search; k++) { - MeshLib::Node const* node(mesh_grid.getNearestPoint(*(pnts_for_search[k]))); - idx_found_nodes.push_back(node->getID()); - } - clock_t stop = clock(); - INFO("\tdone, search time: %f seconds", (stop-start)/(double)(CLOCKS_PER_SEC)); - } -} - -int main(int argc, char *argv[]) -{ - LOGOG_INITIALIZE(); - auto* logog_cout(new logog::Cout); - auto* custom_format(new BaseLib::LogogSimpleFormatter); - logog_cout->SetFormatter(*custom_format); - - TCLAP::CmdLine cmd("Simple mesh search test", ' ', "0.1"); - - // Define a value argument and add it to the command line. - // A value arg defines a flag and a type of value that it expects, - // such as "-m meshfile". - TCLAP::ValueArg<std::string> mesh_arg("m","mesh","input mesh file",true,"test.msh","string"); - - // Add the argument mesh_arg to the CmdLine object. The CmdLine object - // uses this Arg to parse the command line. - cmd.add( mesh_arg ); - - TCLAP::ValueArg<unsigned> number_arg("n","number-of-test-points","the number of test points",true,10000,"positive number"); - cmd.add( number_arg ); - - TCLAP::ValueArg<bool> contiguous_arg("c","use-contiguous-memory","use a contiguous memory for the test",false,true,"yes or no | 1 or 0"); - cmd.add( contiguous_arg ); - - cmd.parse( argc, argv ); - - std::string fname (mesh_arg.getValue()); - - MeshLib::IO::Legacy::MeshIO mesh_io; -#ifndef WIN32 - BaseLib::MemWatch mem_watch; - unsigned long mem_without_mesh (mem_watch.getVirtMemUsage()); -#endif - BaseLib::RunTime run_time; - run_time.start(); - MeshLib::Mesh* mesh (mesh_io.loadMeshFromFile(fname)); -#ifndef WIN32 - unsigned long mem_with_mesh (mem_watch.getVirtMemUsage()); - INFO ("mem for mesh: %i MB", (mem_with_mesh - mem_without_mesh)/(1024*1024)); -#endif - INFO ("time for reading: %f s", run_time.elapsed()); - - // *** preparing test data - std::vector<MeshLib::Node*> const& nodes(mesh->getNodes()); - std::vector<GeoLib::Point*> pnts_for_search; - unsigned n(std::min(static_cast<unsigned>(nodes.size()), number_arg.getValue())); - for (std::size_t k(0); k<n; k++) { - pnts_for_search.push_back(new GeoLib::Point(*(nodes[k]), k)); - } - - std::vector<std::size_t> idx_found_nodes; - testMeshGridAlgorithm(mesh, pnts_for_search, idx_found_nodes, contiguous_arg.getValue()); - - for (std::size_t k(0); k<n; k++) { - delete pnts_for_search[k]; - } - - delete mesh; - delete custom_format; - delete logog_cout; - LOGOG_SHUTDOWN(); -}