ASPECT
crystal_preferred_orientation.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) 2022-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_h
16 #define _aspect_particle_property_cpo_h
17 
20 #include <array>
21 
23 #include <boost/random.hpp>
25 
26 namespace aspect
27 {
28  namespace Particle
29  {
30  namespace Property
31  {
40  enum class DeformationType
41  {
43  };
44 
45 
60  {
62  };
63 
67  enum class AdvectionMethod
68  {
70  };
71 
79  {
81  };
82 
90  {
92  };
93 
123  template <int dim>
125  {
126  public:
130  CrystalPreferredOrientation() = default;
131 
136  void
137  initialize () override;
138 
139  void
140  update () override;
141 
153  void
154  initialize_one_particle_property (const Point<dim> &position,
155  std::vector<double> &particle_properties) const override;
156 
160  void
161  update_particle_properties (const ParticleUpdateInputs<dim> &inputs,
162  typename ParticleHandler<dim>::particle_iterator_range &particles) const override;
163 
169  need_update () const override;
170 
175  late_initialization_mode () const override;
176 
181  get_update_flags (const unsigned int component) const override;
182 
190  std::vector<std::pair<std::string, unsigned int>>
191  get_property_information() const override;
192 
211  std::pair<std::vector<double>, std::vector<Tensor<2,3>>>
212  compute_derivatives(const unsigned int cpo_index,
213  const ArrayView<double> &data,
214  const unsigned int mineral_i,
215  const SymmetricTensor<2,3> &strain_rate_3d,
216  const Tensor<2,3> &velocity_gradient_tensor,
217  const Point<dim> &position,
218  const typename DoFHandler<dim>::active_cell_iterator &cell,
219  const double temperature,
220  const double pressure,
221  const Tensor<1,dim> &velocity,
222  const std::vector<double> &compositions,
224  const SymmetricTensor<2,dim> &deviatoric_strain_rate,
225  const double water_content) const;
226 
243  std::pair<std::vector<double>, std::vector<Tensor<2,3>>>
244  compute_derivatives_drex_2004(const DeformationType deformation_type,
245  const unsigned int cpo_index,
246  const ArrayView<double> &data,
247  const unsigned int mineral_i,
248  const SymmetricTensor<2,3> &strain_rate_3d,
249  const Tensor<2,3> &velocity_gradient_tensor,
250  const std::array<double,4> ref_resolved_shear_stress,
251  const bool prevent_nondimensionalization = false) const;
252 
253 
257  static
258  void
260 
264  void
265  parse_parameters (ParameterHandler &prm) override;
266 
270  unsigned int
271  get_number_of_grains() const;
272 
276  unsigned int
277  get_number_of_minerals() const;
278 
289  determine_deformation_type(const DeformationTypeSelector deformation_type_selector,
290  const Point<dim> &position,
291  const typename DoFHandler<dim>::active_cell_iterator &cell,
292  const double temperature,
293  const double pressure,
294  const Tensor<1,dim> &velocity,
295  const std::vector<double> &compositions,
296  const SymmetricTensor<2,dim> &strain_rate,
297  const SymmetricTensor<2,dim> &deviatoric_strain_rate,
298  const double water_content) const;
299 
305  determine_deformation_type_karato_2008(const double stress,
306  const double water_content) const;
307 
317  std::array<double,4>
318  reference_resolved_shear_stress_from_deformation_type(DeformationType deformation_type,
319  double max_value = 1e60) const;
320 
328  inline
329  DeformationType get_deformation_type(const unsigned int cpo_data_position,
330  const ArrayView<double> &data,
331  const unsigned int mineral_i) const
332  {
333  return static_cast<DeformationType>(data[cpo_data_position + 0 + mineral_i * (n_grains * 10 + 2)]);
334  }
335 
344  inline
345  void set_deformation_type(const unsigned int cpo_data_position,
346  const ArrayView<double> &data,
347  const unsigned int mineral_i,
348  const DeformationType deformation_type) const
349  {
350  data[cpo_data_position + 0 + mineral_i * (n_grains * 10 + 2)] = static_cast<double>(deformation_type);
351  }
352 
360  inline
361  double get_volume_fraction_mineral(const unsigned int cpo_data_position,
362  const ArrayView<double> &data,
363  const unsigned int mineral_i) const
364  {
365  return data[cpo_data_position + 1 + mineral_i *(n_grains * 10 + 2)];
366  }
367 
376  inline
377  void set_volume_fraction_mineral(const unsigned int cpo_data_position,
378  const ArrayView<double> &data,
379  const unsigned int mineral_i,
380  const double volume_fraction_mineral) const
381  {
382  data[cpo_data_position + 1 + mineral_i *(n_grains * 10 + 2)] = volume_fraction_mineral;
383  }
384 
393  inline
394  double get_volume_fractions_grains(const unsigned int cpo_data_position,
395  const ArrayView<const double> &data,
396  const unsigned int mineral_i,
397  const unsigned int grain_i) const
398  {
399  return data[cpo_data_position + 2 + grain_i * 10 + mineral_i * (n_grains * 10 + 2)];
400  }
401 
411  inline
412  void set_volume_fractions_grains(const unsigned int cpo_data_position,
413  const ArrayView<double> &data,
414  const unsigned int mineral_i,
415  const unsigned int grain_i,
416  const double volume_fractions_grains) const
417  {
418  data[cpo_data_position + 2 + grain_i * 10 + mineral_i * (n_grains * 10 + 2)] = volume_fractions_grains;
419  }
420 
430  inline
431  Tensor<2,3> get_rotation_matrix_grains(const unsigned int cpo_data_position,
432  const ArrayView<const double> &data,
433  const unsigned int mineral_i,
434  const unsigned int grain_i) const
435  {
436  Tensor<2,3> rotation_matrix;
437  for (unsigned int i = 0; i < Tensor<2,3>::n_independent_components ; ++i)
438  {
439  const ::TableIndices<2> index = Tensor<2,3>::unrolled_to_component_indices(i);
440  rotation_matrix[index] = data[cpo_data_position + 3 + grain_i * 10 + mineral_i * (n_grains * 10 + 2) + i];
441  }
442  return rotation_matrix;
443  }
444 
454  inline
455  void set_rotation_matrix_grains(const unsigned int cpo_data_position,
456  const ArrayView<double> &data,
457  const unsigned int mineral_i,
458  const unsigned int grain_i,
459  const Tensor<2,3> &rotation_matrix) const
460  {
461  for (unsigned int i = 0; i < Tensor<2,3>::n_independent_components ; ++i)
462  {
463  const ::TableIndices<2> index = Tensor<2,3>::unrolled_to_component_indices(i);
464  data[cpo_data_position + 3 + grain_i * 10 + mineral_i * (n_grains * 10 + 2) + i] = rotation_matrix[index];
465  }
466  }
467 
468 
469  private:
473  void
474  compute_random_rotation_matrix(Tensor<2,3> &rotation_matrix) const;
475 
491  double
492  advect_forward_euler(const unsigned int cpo_data_position,
493  const ArrayView<double> &data,
494  const unsigned int mineral_i,
495  const double dt,
496  const std::pair<std::vector<double>, std::vector<Tensor<2,3>>> &derivatives) const;
497 
513  double
514  advect_backward_euler(const unsigned int cpo_data_position,
515  const ArrayView<double> &data,
516  const unsigned int mineral_i,
517  const double dt,
518  const std::pair<std::vector<double>, std::vector<Tensor<2,3>>> &derivatives) const;
519 
520 
527  std::pair<std::vector<double>, std::vector<Tensor<2,3>>>
528  compute_derivatives_spin_tensor(const Tensor<2,3> &velocity_gradient_tensor) const;
529 
539  mutable boost::mt19937 random_number_generator;
540 
545  unsigned int random_number_seed;
546 
551  unsigned int n_grains;
552 
553  unsigned int n_minerals;
554 
558  unsigned int water_index;
559 
566  std::vector<DeformationTypeSelector> deformation_type_selector;
567 
574  std::vector<double> volume_fractions_minerals;
575 
582 
589 
597 
605 
616 
624 
630  double exponent_p;
631 
640 
647  double mobility;
648 
655 
669  std::vector<double> CPX_RRSS;
670 
683  std::vector<double> OlivineD_RRSS;
684 
687  };
688  }
689  }
690 }
691 
692 #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.