Debian Codegraph @

packages/stk/stk_performance_tests/stk_mesh/ManyParts.cpp

raw
1 // Copyright 2002 - 2008, 2010, 2011 National Technology Engineering
2 // Solutions of Sandia, LLC (NTESS). Under the terms of Contract
3 // DE-NA0003525 with NTESS, the U.S. Government retains certain rights
4 // in this software.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are
8 // met:
9 //
10 // * Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 //
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following
15 // disclaimer in the documentation and/or other materials provided
16 // with the distribution.
17 //
18 // * Neither the name of NTESS nor the names of its contributors
19 // may be used to endorse or promote products derived from this
20 // software without specific prior written permission.
21 //
22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 //
34
35 #include <gtest/gtest.h>
36
37 #include <stk_mesh/base/MetaData.hpp>
38 #include <stk_mesh/base/Field.hpp>
39 #include <stk_unit_test_utils/timer.hpp>
40
41 TEST(many_parts, many_parts)
42 {
43 const unsigned NUM_RUNS = 5;
44 unsigned num_parts = 8000;
45 stk::unit_test_util::BatchTimer batchTimer(MPI_COMM_WORLD);
46 batchTimer.initialize_batch_timer();
47 for (unsigned j = 0; j < NUM_RUNS; j++) {
48 batchTimer.start_batch_timer();
49
50 const unsigned spatialDim = 3;
51 stk::mesh::MetaData meta(spatialDim);
52
53 stk::mesh::Part& super1 = meta.declare_part("super1");
54 stk::mesh::Part& super2 = meta.declare_part("super2");
55 stk::mesh::Part& super3 = meta.declare_part("super3");
56 stk::mesh::Part& super4 = meta.declare_part("super4");
57
58 stk::mesh::Part& sub1 = meta.declare_part("sub1");
59 stk::mesh::Part& sub2 = meta.declare_part("sub2");
60 stk::mesh::Part& sub3 = meta.declare_part("sub3");
61 stk::mesh::Part& sub4 = meta.declare_part("sub4");
62
63 stk::mesh::PartVector parts;
64 for(unsigned i=0; i<num_parts; ++i) {
65 std::string partName = "part_" + std::to_string(i);
66 stk::mesh::Part& part = meta.declare_part(partName);
67 meta.declare_part_subset(super1, part);
68 meta.declare_part_subset(super2, part);
69 meta.declare_part_subset(super3, part);
70 meta.declare_part_subset(part, sub1);
71 meta.declare_part_subset(part, sub2);
72 meta.declare_part_subset(part, sub3);
73 parts.push_back(&part);
74 }
75
76 typedef stk::mesh::Field<double> VectorField;
77 VectorField& field = meta.declare_field<double>(stk::topology::NODE_RANK, "field");
78 for(size_t i=0; i<parts.size(); ++i) {
79 const stk::mesh::Part& part = *parts[i];
80 stk::mesh::put_field_on_mesh(field, part, 3, nullptr);
81 }
82
83 for(size_t i=0; i<parts.size(); ++i) {
84 meta.declare_part_subset(super4, *parts[i]);
85 meta.declare_part_subset(*parts[i], sub4);
86 }
87
88 batchTimer.stop_batch_timer();
89 }
90 batchTimer.print_batch_timing(num_parts);
91 }