ASPECT
cpo_bingham_average.h
Go to the documentation of this file.
1 // ------------------------------------------------------
2 //
3 // SPDX-License-Identifier: GPL-2.0-or-later
4 //
5 // SPDX-FileCopyrightText: Copyright (C) 2023-2026 by the ASPECT authors.
6 //
7 // This file is part of ASPECT.
8 //
9 // Detailed license information governing the source code and
10 // contributions can be found in the folder LICENSES and in
11 // LICENSE and CONTRIBUTING.md at the top level directory.
12 //
13 // ------------------------------------------------------
14 
15 #ifndef _aspect_particle_property_cpo_bingham_average_h
16 #define _aspect_particle_property_cpo_bingham_average_h
17 
21 
22 #include <array>
23 #include <random>
24 
25 namespace aspect
26 {
27  namespace Particle
28  {
29  namespace Property
30  {
31 
32 
42  enum class RotationFormat
43  {
45  };
46 
104  template <int dim>
105  class CpoBinghamAverage : public Interface<dim>, public ::aspect::SimulatorAccess<dim>
106  {
107  public:
111  CpoBinghamAverage() = default;
112 
117  void
118  initialize () override;
119 
120  void
121  update () override;
122 
134  void
135  initialize_one_particle_property (const Point<dim> &position,
136  std::vector<double> &particle_properties) const override;
137 
141  void
142  update_particle_properties (const ParticleUpdateInputs<dim> &inputs,
143  typename ParticleHandler<dim>::particle_iterator_range &particles) const override;
144 
150  need_update () const override;
151 
156  get_update_flags (const unsigned int component) const override;
157 
165  std::vector<std::pair<std::string, unsigned int>>
166  get_property_information() const override;
167 
177  std::array<std::array<double,6>,3>
178  compute_bingham_average(std::vector<Tensor<2,3>> matrices, std::integral_constant<int,6>) const;
179 
180  std::array<std::array<double,4>,3>
181  compute_bingham_average(std::vector<Tensor<2,3>> matrices, std::integral_constant<int,4>) const;
182 
183  std::pair<std::array<double, 4>, std::array<std::array<double,2>,3>>
184  compute_bingham_average(std::vector<Tensor<2,3>> matrices, std::integral_constant<int,2>) const;
185 
189  static
190  void
192 
196  void
197  parse_parameters (ParameterHandler &prm) override;
198 
199  private:
203  unsigned int cpo_data_position;
204 
210 
220  mutable std::mt19937 random_number_generator;
221 
228  unsigned int random_number_seed;
229 
233  unsigned int n_grains;
234 
238  unsigned int n_minerals;
239 
245  unsigned int n_samples;
246 
253  };
254  }
255  }
256 }
257 
258 #endif
void declare_parameters(ParameterHandler &prm)
UpdateFlags
const Particle::Property::CrystalPreferredOrientation< dim > * cpo_particle_property
RotationFormat
This determines whether the mean crystal orientation is output as a rotation matrix, euler angles, or a quaternion.
boost::iterator_range< particle_iterator > particle_iterator_range