ASPECT
crystal_preferred_orientation.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2022 - 2024 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 
28 DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
29 #include <boost/random.hpp>
30 DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
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 
156  void
157  initialize_one_particle_property (const Point<dim> &position,
158  std::vector<double> &particle_properties) const override;
159 
163  void
164  update_particle_properties (const ParticleUpdateInputs<dim> &inputs,
165  typename ParticleHandler<dim>::particle_iterator_range &particles) const override;
166 
172  need_update () const override;
173 
178  late_initialization_mode () const override;
179 
183  UpdateFlags
184  get_update_flags (const unsigned int component) const override;
185 
193  std::vector<std::pair<std::string, unsigned int>>
194  get_property_information() const override;
195 
213  std::pair<std::vector<double>, std::vector<Tensor<2,3>>>
214  compute_derivatives(const unsigned int cpo_index,
215  const ArrayView<double> &data,
216  const unsigned int mineral_i,
217  const SymmetricTensor<2,3> &strain_rate_3d,
218  const Tensor<2,3> &velocity_gradient_tensor,
219  const Point<dim> &position,
220  const double temperature,
221  const double pressure,
222  const Tensor<1,dim> &velocity,
223  const std::vector<double> &compositions,
224  const SymmetricTensor<2,dim> &strain_rate,
225  const SymmetricTensor<2,dim> &deviatoric_strain_rate,
226  const double water_content) const;
227 
243  std::pair<std::vector<double>, std::vector<Tensor<2,3>>>
244  compute_derivatives_drex_2004(const unsigned int cpo_index,
245  const ArrayView<double> &data,
246  const unsigned int mineral_i,
247  const SymmetricTensor<2,3> &strain_rate_3d,
248  const Tensor<2,3> &velocity_gradient_tensor,
249  const std::array<double,4> ref_resolved_shear_stress,
250  const bool prevent_nondimensionalization = false) const;
251 
252 
256  static
257  void
258  declare_parameters (ParameterHandler &prm);
259 
263  void
264  parse_parameters (ParameterHandler &prm) override;
265 
269  unsigned int
270  get_number_of_grains() const;
271 
275  unsigned int
276  get_number_of_minerals() const;
277 
288  determine_deformation_type(const DeformationTypeSelector deformation_type_selector,
289  const Point<dim> &position,
290  const double temperature,
291  const double pressure,
292  const Tensor<1,dim> &velocity,
293  const std::vector<double> &compositions,
294  const SymmetricTensor<2,dim> &strain_rate,
295  const SymmetricTensor<2,dim> &deviatoric_strain_rate,
296  const double water_content) const;
297 
303  determine_deformation_type_karato_2008(const double stress,
304  const double water_content) const;
305 
315  std::array<double,4>
316  reference_resolved_shear_stress_from_deformation_type(DeformationType deformation_type,
317  double max_value = 1e60) const;
318 
326  inline
327  DeformationType get_deformation_type(const unsigned int cpo_data_position,
328  const ArrayView<double> &data,
329  const unsigned int mineral_i) const
330  {
331  return static_cast<DeformationType>(data[cpo_data_position + 0 + mineral_i * (n_grains * 10 + 2)]);
332  }
333 
342  inline
343  void set_deformation_type(const unsigned int cpo_data_position,
344  const ArrayView<double> &data,
345  const unsigned int mineral_i,
346  const DeformationType deformation_type) const
347  {
348  data[cpo_data_position + 0 + mineral_i * (n_grains * 10 + 2)] = static_cast<double>(deformation_type);
349  }
350 
358  inline
359  double get_volume_fraction_mineral(const unsigned int cpo_data_position,
360  const ArrayView<double> &data,
361  const unsigned int mineral_i) const
362  {
363  return data[cpo_data_position + 1 + mineral_i *(n_grains * 10 + 2)];
364  }
365 
374  inline
375  void set_volume_fraction_mineral(const unsigned int cpo_data_position,
376  const ArrayView<double> &data,
377  const unsigned int mineral_i,
378  const double volume_fraction_mineral) const
379  {
380  data[cpo_data_position + 1 + mineral_i *(n_grains * 10 + 2)] = volume_fraction_mineral;
381  }
382 
391  inline
392  double get_volume_fractions_grains(const unsigned int cpo_data_position,
393  const ArrayView<const double> &data,
394  const unsigned int mineral_i,
395  const unsigned int grain_i) const
396  {
397  return data[cpo_data_position + 2 + grain_i * 10 + mineral_i * (n_grains * 10 + 2)];
398  }
399 
409  inline
410  void set_volume_fractions_grains(const unsigned int cpo_data_position,
411  const ArrayView<double> &data,
412  const unsigned int mineral_i,
413  const unsigned int grain_i,
414  const double volume_fractions_grains) const
415  {
416  data[cpo_data_position + 2 + grain_i * 10 + mineral_i * (n_grains * 10 + 2)] = volume_fractions_grains;
417  }
418 
428  inline
429  Tensor<2,3> get_rotation_matrix_grains(const unsigned int cpo_data_position,
430  const ArrayView<const double> &data,
431  const unsigned int mineral_i,
432  const unsigned int grain_i) const
433  {
434  Tensor<2,3> rotation_matrix;
435  for (unsigned int i = 0; i < Tensor<2,3>::n_independent_components ; ++i)
436  {
437  const ::TableIndices<2> index = Tensor<2,3>::unrolled_to_component_indices(i);
438  rotation_matrix[index] = data[cpo_data_position + 3 + grain_i * 10 + mineral_i * (n_grains * 10 + 2) + i];
439  }
440  return rotation_matrix;
441  }
442 
452  inline
453  void set_rotation_matrix_grains(const unsigned int cpo_data_position,
454  const ArrayView<double> &data,
455  const unsigned int mineral_i,
456  const unsigned int grain_i,
457  const Tensor<2,3> &rotation_matrix) const
458  {
459  for (unsigned int i = 0; i < Tensor<2,3>::n_independent_components ; ++i)
460  {
461  const ::TableIndices<2> index = Tensor<2,3>::unrolled_to_component_indices(i);
462  data[cpo_data_position + 3 + grain_i * 10 + mineral_i * (n_grains * 10 + 2) + i] = rotation_matrix[index];
463  }
464  }
465 
466 
467  private:
471  void
472  compute_random_rotation_matrix(Tensor<2,3> &rotation_matrix) const;
473 
489  double
490  advect_forward_euler(const unsigned int cpo_data_position,
491  const ArrayView<double> &data,
492  const unsigned int mineral_i,
493  const double dt,
494  const std::pair<std::vector<double>, std::vector<Tensor<2,3>>> &derivatives) const;
495 
511  double
512  advect_backward_euler(const unsigned int cpo_data_position,
513  const ArrayView<double> &data,
514  const unsigned int mineral_i,
515  const double dt,
516  const std::pair<std::vector<double>, std::vector<Tensor<2,3>>> &derivatives) const;
517 
518 
525  std::pair<std::vector<double>, std::vector<Tensor<2,3>>>
526  compute_derivatives_spin_tensor(const Tensor<2,3> &velocity_gradient_tensor) const;
527 
531  mutable boost::mt19937 random_number_generator;
532  unsigned int random_number_seed;
533 
534  unsigned int n_grains;
535 
536  unsigned int n_minerals;
537 
541  unsigned int water_index;
542 
549  std::vector<DeformationTypeSelector> deformation_type_selector;
550 
554  std::vector<double> volume_fractions_minerals;
555 
560 
565 
571 
577 
586 
592 
596  double exponent_p;
597 
604 
609  double mobility;
610 
615 
618  };
619  }
620  }
621 }
622 
623 #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.
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.
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)
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...
Definition: compat.h:59
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.
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.
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.
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.