World Builder  1.1.0-pre
A geodynamic initial conditions generator
grains.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2018-2024 by the authors of the World Builder code.
3 
4  This file is part of the World Builder.
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef WORLD_BUILDER_GRAINS_H
21 #define WORLD_BUILDER_GRAINS_H
22 
23 #include <array>
24 #include <ostream>
25 #include <vector>
26 
27 namespace WorldBuilder
28 {
35  struct grains
36  {
37  grains();
38 
39  grains(const std::vector<double> &vector,
40  const size_t number_of_grains,
41  const size_t start_entry = 0);
42 
43  void unroll_into(std::vector<double> &vector,
44  const size_t start_entry = 0) const;
45 
46  // The sizes of the grains
47  std::vector<double> sizes;
48 
49  // the rotation matrices of the latices of the grains.
50  // todo: convention.
51  std::vector<std::array<std::array<double,3>,3> > rotation_matrices;
52 
53  friend std::ostream &operator<<(std::ostream &os, const grains &grains)
54  {
55  for (unsigned int i = 0; i < grains.sizes.size(); ++i)
56  {
57  os << i << ": s=" << grains.sizes[i] << ", R="
58  << grains.rotation_matrices[i][0][0] << " " << grains.rotation_matrices[i][0][1] << " " << grains.rotation_matrices[i][0][2] << " "
59  << grains.rotation_matrices[i][1][0] << " " << grains.rotation_matrices[i][1][1] << " " << grains.rotation_matrices[i][1][2] << " "
60  << grains.rotation_matrices[i][2][0] << " " << grains.rotation_matrices[i][2][1] << " " << grains.rotation_matrices[i][2][2] << " ";
61  }
62  return os;
63  }
64  };
65 
66 } // namespace WorldBuilder
67 
68 #endif
friend std::ostream & operator<<(std::ostream &os, const grains &grains)
Definition: grains.h:53
std::vector< double > sizes
Definition: grains.h:47
std::vector< std::array< std::array< double, 3 >, 3 > > rotation_matrices
Definition: grains.h:51
void unroll_into(std::vector< double > &vector, const size_t start_entry=0) const
Definition: grains.cc:58