ASPECT
crystal_preferred_orientation.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2022 - 2026 by the authors of the ASPECT code.
3 
4  This file is part of ASPECT.
5 
6  ASPECT is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2, or (at your option)
9  any later version.
10 
11  ASPECT 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 General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with ASPECT; see the file LICENSE. If not see
18  <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef _aspect_particle_property_cpo_h
22 #define _aspect_particle_property_cpo_h
23 
26 #include <array>
27 
29 #include <boost/random.hpp>
31 
32 namespace aspect
33 {
34  namespace Particle
35  {
36  namespace Property
37  {
46  enum class DeformationType
47  {
49  };
50 
51 
66  {
68  };
69 
73  enum class AdvectionMethod
74  {
76  };
77 
85  {
87  };
88 
96  {
98  };
99 
129  template <int dim>
131  {
132  public:
136  CrystalPreferredOrientation() = default;
137 
142  void
143  initialize () override;
144 
145  void
146  update () override;
147 
159  void
160  initialize_one_particle_property (const Point<dim> &position,
161  std::vector<double> &particle_properties) const override;
162 
166  void
167  update_particle_properties (const ParticleUpdateInputs<dim> &inputs,
168  typename ParticleHandler<dim>::particle_iterator_range &particles) const override;
169 
175  need_update () const override;
176 
181  late_initialization_mode () const override;
182 
187  get_update_flags (const unsigned int component) const override;
188 
196  std::vector<std::pair<std::string, unsigned int>>
197  get_property_information() const override;
198 
217  std::pair<std::vector<double>, std::vector<Tensor<2,3>>>
218  compute_derivatives(const unsigned int cpo_index,
219  const ArrayView<double> &data,
220  const unsigned int mineral_i,
221  const SymmetricTensor<2,3> &strain_rate_3d,
222  const Tensor<2,3> &velocity_gradient_tensor,
223  const Point<dim> &position,
224  const typename DoFHandler<dim>::active_cell_iterator &cell,
225  const double temperature,
226  const double pressure,
227  const Tensor<1,dim> &velocity,
228  const std::vector<double> &compositions,
230  const SymmetricTensor<2,dim> &deviatoric_strain_rate,
231  const double water_content) const;
232 
249  std::pair<std::vector<double>, std::vector<Tensor<2,3>>>
250  compute_derivatives_drex_2004(const DeformationType deformation_type,
251  const unsigned int cpo_index,
252  const ArrayView<double> &data,
253  const unsigned int mineral_i,
254  const SymmetricTensor<2,3> &strain_rate_3d,
255  const Tensor<2,3> &velocity_gradient_tensor,
256  const std::array<double,4> ref_resolved_shear_stress,
257  const bool prevent_nondimensionalization = false) const;
258 
259 
263  static
264  void
266 
270  void
271  parse_parameters (ParameterHandler &prm) override;
272 
276  unsigned int
277  get_number_of_grains() const;
278 
282  unsigned int
283  get_number_of_minerals() const;
284 
295  determine_deformation_type(const DeformationTypeSelector deformation_type_selector,
296  const Point<dim> &position,
297  const typename DoFHandler<dim>::active_cell_iterator &cell,
298  const double temperature,
299  const double pressure,
300  const Tensor<1,dim> &velocity,
301  const std::vector<double> &compositions,
302  const SymmetricTensor<2,dim> &strain_rate,
303  const SymmetricTensor<2,dim> &deviatoric_strain_rate,
304  const double water_content) const;
305 
311  determine_deformation_type_karato_2008(const double stress,
312  const double water_content) const;
313 
323  std::array<double,4>
324  reference_resolved_shear_stress_from_deformation_type(DeformationType deformation_type,
325  double max_value = 1e60) const;
326 
334  inline
335  DeformationType get_deformation_type(const unsigned int cpo_data_position,
336  const ArrayView<double> &data,
337  const unsigned int mineral_i) const
338  {
339  return static_cast<DeformationType>(data[cpo_data_position + 0 + mineral_i * (n_grains * 10 + 2)]);
340  }
341 
350  inline
351  void set_deformation_type(const unsigned int cpo_data_position,
352  const ArrayView<double> &data,
353  const unsigned int mineral_i,
354  const DeformationType deformation_type) const
355  {
356  data[cpo_data_position + 0 + mineral_i * (n_grains * 10 + 2)] = static_cast<double>(deformation_type);
357  }
358 
366  inline
367  double get_volume_fraction_mineral(const unsigned int cpo_data_position,
368  const ArrayView<double> &data,
369  const unsigned int mineral_i) const
370  {
371  return data[cpo_data_position + 1 + mineral_i *(n_grains * 10 + 2)];
372  }
373 
382  inline
383  void set_volume_fraction_mineral(const unsigned int cpo_data_position,
384  const ArrayView<double> &data,
385  const unsigned int mineral_i,
386  const double volume_fraction_mineral) const
387  {
388  data[cpo_data_position + 1 + mineral_i *(n_grains * 10 + 2)] = volume_fraction_mineral;
389  }
390 
399  inline
400  double get_volume_fractions_grains(const unsigned int cpo_data_position,
401  const ArrayView<const double> &data,
402  const unsigned int mineral_i,
403  const unsigned int grain_i) const
404  {
405  return data[cpo_data_position + 2 + grain_i * 10 + mineral_i * (n_grains * 10 + 2)];
406  }
407 
417  inline
418  void set_volume_fractions_grains(const unsigned int cpo_data_position,
419  const ArrayView<double> &data,
420  const unsigned int mineral_i,
421  const unsigned int grain_i,
422  const double volume_fractions_grains) const
423  {
424  data[cpo_data_position + 2 + grain_i * 10 + mineral_i * (n_grains * 10 + 2)] = volume_fractions_grains;
425  }
426 
436  inline
437  Tensor<2,3> get_rotation_matrix_grains(const unsigned int cpo_data_position,
438  const ArrayView<const double> &data,
439  const unsigned int mineral_i,
440  const unsigned int grain_i) const
441  {
442  Tensor<2,3> rotation_matrix;
443  for (unsigned int i = 0; i < Tensor<2,3>::n_independent_components ; ++i)
444  {
445  const ::TableIndices<2> index = Tensor<2,3>::unrolled_to_component_indices(i);
446  rotation_matrix[index] = data[cpo_data_position + 3 + grain_i * 10 + mineral_i * (n_grains * 10 + 2) + i];
447  }
448  return rotation_matrix;
449  }
450 
460  inline
461  void set_rotation_matrix_grains(const unsigned int cpo_data_position,
462  const ArrayView<double> &data,
463  const unsigned int mineral_i,
464  const unsigned int grain_i,
465  const Tensor<2,3> &rotation_matrix) const
466  {
467  for (unsigned int i = 0; i < Tensor<2,3>::n_independent_components ; ++i)
468  {
469  const ::TableIndices<2> index = Tensor<2,3>::unrolled_to_component_indices(i);
470  data[cpo_data_position + 3 + grain_i * 10 + mineral_i * (n_grains * 10 + 2) + i] = rotation_matrix[index];
471  }
472  }
473 
474 
475  private:
479  void
480  compute_random_rotation_matrix(Tensor<2,3> &rotation_matrix) const;
481 
497  double
498  advect_forward_euler(const unsigned int cpo_data_position,
499  const ArrayView<double> &data,
500  const unsigned int mineral_i,
501  const double dt,
502  const std::pair<std::vector<double>, std::vector<Tensor<2,3>>> &derivatives) const;
503 
519  double
520  advect_backward_euler(const unsigned int cpo_data_position,
521  const ArrayView<double> &data,
522  const unsigned int mineral_i,
523  const double dt,
524  const std::pair<std::vector<double>, std::vector<Tensor<2,3>>> &derivatives) const;
525 
526 
533  std::pair<std::vector<double>, std::vector<Tensor<2,3>>>
534  compute_derivatives_spin_tensor(const Tensor<2,3> &velocity_gradient_tensor) const;
535 
545  mutable boost::mt19937 random_number_generator;
546 
551  unsigned int random_number_seed;
552 
557  unsigned int n_grains;
558 
559  unsigned int n_minerals;
560 
564  unsigned int water_index;
565 
572  std::vector<DeformationTypeSelector> deformation_type_selector;
573 
580  std::vector<double> volume_fractions_minerals;
581 
588 
595 
603 
611 
622 
630 
636  double exponent_p;
637 
646 
653  double mobility;
654 
661 
675  std::vector<double> CPX_RRSS;
676 
689  std::vector<double> OlivineD_RRSS;
690 
693  };
694  }
695  }
696 }
697 
698 #endif
void set_volume_fraction_mineral(const unsigned int cpo_data_position, const ArrayView< double > &data, const unsigned int mineral_i, const double volume_fraction_mineral) const
Sets the value in the data array representing the volume fraction of a mineral.
DeformationTypeSelector
The type of deformation selector used by the CPO code.
std::vector< index_type > data
CPODerivativeAlgorithm
The algorithm used to compute the derivatives of the grain size and rotation matrix used in the advec...
DeformationType
The type of deformation used by the CPO code.
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
double get_volume_fraction_mineral(const unsigned int cpo_data_position, const ArrayView< double > &data, const unsigned int mineral_i) const
Returns the value in the data array representing the volume fraction of a mineral.
void declare_parameters(ParameterHandler &prm)
UpdateFlags
AdvectionMethod
The type of Advection method used to advect the CPO properties.
CPOInitialGrainsModel
An enum used to determine how the initial grain sizes and orientations are set for all particles...
Tensor< 2, 3 > get_rotation_matrix_grains(const unsigned int cpo_data_position, const ArrayView< const double > &data, const unsigned int mineral_i, const unsigned int grain_i) const
Gets the rotation matrix for a grain in a mineral.
boost::iterator_range< particle_iterator > particle_iterator_range
void set_deformation_type(const unsigned int cpo_data_position, const ArrayView< double > &data, const unsigned int mineral_i, const DeformationType deformation_type) const
Sets the value in the data array representing the deformation type.
DeformationType get_deformation_type(const unsigned int cpo_data_position, const ArrayView< double > &data, const unsigned int mineral_i) const
Returns the value in the data array representing the deformation type.
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
void set_rotation_matrix_grains(const unsigned int cpo_data_position, const ArrayView< double > &data, const unsigned int mineral_i, const unsigned int grain_i, const Tensor< 2, 3 > &rotation_matrix) const
Sets the rotation matrix for a grain in a mineral.
static constexpr TableIndices< rank_ > unrolled_to_component_indices(const unsigned int i)
double get_volume_fractions_grains(const unsigned int cpo_data_position, const ArrayView< const double > &data, const unsigned int mineral_i, const unsigned int grain_i) const
Returns the value in the data array representing the volume fraction of a grain.
void set_volume_fractions_grains(const unsigned int cpo_data_position, const ArrayView< double > &data, const unsigned int mineral_i, const unsigned int grain_i, const double volume_fractions_grains) const
Sets the value in the data array representing the volume fraction of a grain.