Debian Codegraph @

test/unit/cpp/io/XMLMeshValueCollection.cpp

raw
1 // Copyright (C) 2007 Magnus Vikstrøm
2 //
3 // This file is part of DOLFIN.
4 //
5 // DOLFIN is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // DOLFIN is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17
18 #include <dolfin.h>
19 #include <catch.hpp>
20
21 using namespace dolfin;
22
23 //-----------------------------------------------------------------------------
24 TEST_CASE("MeshValueCollection IO test", "[!hide][meshvaluecollection_io]")
25 {
26 // Create mesh and read file
27 // Link to the mesh is quite long...
28 auto mesh = std::make_shared<UnitCubeMesh>(5, 5, 5);
29 MeshValueCollection<std::size_t> markers(mesh, "./io/xml_value_collection_ref.xml");
30 //MeshValueCollection<std::size_t>
31 // markers(mesh, "./test/unit/cpp/io/xml_value_collection_ref.xml");
32
33 // Check size
34 CHECK(dolfin::MPI::sum(mesh->mpi_comm(), markers.size()) == (std::size_t) 6);
35
36 // Check sum of values
37 const std::map<std::pair<std::size_t, std::size_t>, std::size_t>&
38 values = markers.values();
39 std::size_t sum = 0;
40 for (auto it = values.begin(); it != values.end(); ++it)
41 sum += it->second;
42
43 CHECK(dolfin::MPI::sum(mesh->mpi_comm(), sum) == (std::size_t) 48);
44 }