// Copyright (c) 2010-2023, Lawrence Livermore National Security, LLC. Produced // at the Lawrence Livermore National Laboratory. All Rights reserved. See files // LICENSE and NOTICE for details. LLNL-CODE-806117. // // This file is part of the MFEM library. For more information and source code // availability visit https://mfem.org. // // MFEM is free software; you can redistribute it and/or modify it under the // terms of the BSD-3 license. We welcome feedback and contributions, see file // CONTRIBUTING.md for details. #include "unit_tests.hpp" #include "mfem.hpp" namespace mfem { #ifdef MFEM_USE_MPI // TODO: modify the tests here to support HYPRE_USING_GPU? #ifndef HYPRE_USING_GPU namespace internal { std::vector GenerateColumnPartitioning(const int world_size, const int rank, const int size_per_rank) { std::vector col; if (HYPRE_AssumedPartitionCheck()) { int offset = rank*size_per_rank; col = {offset, offset + size_per_rank}; } else { col.resize(world_size+1); for (int i=0; i<=world_size; ++i) { col[i] = i*size_per_rank; } } return col; } } // namespace internal TEST_CASE("HypreParVector I/O", "[Parallel], [HypreParVector]") { // Create a test vector (two entries per rank) with entries increasing // sequentially. Write the vector to a file, read it into another vector, and // make sure we get the same answer. int world_size, rank; MPI_Comm_size(MPI_COMM_WORLD, &world_size); MPI_Comm_rank(MPI_COMM_WORLD, &rank); int size_per_rank = 2; HYPRE_BigInt glob_size = world_size*size_per_rank; std::vector col = internal::GenerateColumnPartitioning(world_size, rank, size_per_rank); // Initialize vector and write to files HypreParVector v1(MPI_COMM_WORLD, glob_size, col.data()); for (int i=0; i col = internal::GenerateColumnPartitioning(world_size, rank, size_per_rank); // Initialize vector HypreParVector v1(MPI_COMM_WORLD, glob_size, col.data()); for (int i=0; i col = internal::GenerateColumnPartitioning(world_size, rank, size_per_rank); // Initialize vector HypreParVector v1(MPI_COMM_WORLD, glob_size, col.data()); for (int i=0; i