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 
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:
137 
142  void
143  initialize () override;
144 
156  void
158  std::vector<double> &particle_properties) const override;
159 
163  void
165  typename ParticleHandler<dim>::particle_iterator_range &particles) const override;
166 
172  need_update () const override;
173 
178  late_initialization_mode () const override;
179 
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 
214  std::pair<std::vector<double>, std::vector<Tensor<2,3>>>
215  compute_derivatives(const unsigned int cpo_index,
216  const ArrayView<double> &data,
217  const unsigned int mineral_i,
218  const SymmetricTensor<2,3> &strain_rate_3d,
219  const Tensor<2,3> &velocity_gradient_tensor,
220  const Point<dim> &position,
221  const typename DoFHandler<dim>::active_cell_iterator &cell,
222  const double temperature,
223  const double pressure,
224  const Tensor<1,dim> &velocity,
225  const std::vector<double> &compositions,
227  const SymmetricTensor<2,dim> &deviatoric_strain_rate,
228  const double water_content) const;
229 
246  std::pair<std::vector<double>, std::vector<Tensor<2,3>>>
248  const unsigned int cpo_index,
249  const ArrayView<double> &data,
250  const unsigned int mineral_i,
251  const SymmetricTensor<2,3> &strain_rate_3d,
252  const Tensor<2,3> &velocity_gradient_tensor,
253  const std::array<double,4> ref_resolved_shear_stress,
254  const bool prevent_nondimensionalization = false) const;
255 
256 
260  static
261  void
263 
267  void
269 
270  void
271  save (std::map<std::string, std::string> &status_strings) const override;
272 
273  void
274  load (const std::map<std::string, std::string> &status_strings) override;
275 
279  unsigned int
281 
285  unsigned int
287 
299  const Point<dim> &position,
300  const typename DoFHandler<dim>::active_cell_iterator &cell,
301  const double temperature,
302  const double pressure,
303  const Tensor<1,dim> &velocity,
304  const std::vector<double> &compositions,
306  const SymmetricTensor<2,dim> &deviatoric_strain_rate,
307  const double water_content) const;
308 
315  const double water_content) const;
316 
326  std::array<double,4>
328  double max_value = 1e60) const;
329 
337  inline
338  DeformationType get_deformation_type(const unsigned int cpo_data_position,
339  const ArrayView<double> &data,
340  const unsigned int mineral_i) const
341  {
342  return static_cast<DeformationType>(data[cpo_data_position + 0 + mineral_i * (n_grains * 10 + 2)]);
343  }
344 
353  inline
354  void set_deformation_type(const unsigned int cpo_data_position,
355  const ArrayView<double> &data,
356  const unsigned int mineral_i,
357  const DeformationType deformation_type) const
358  {
359  data[cpo_data_position + 0 + mineral_i * (n_grains * 10 + 2)] = static_cast<double>(deformation_type);
360  }
361 
369  inline
370  double get_volume_fraction_mineral(const unsigned int cpo_data_position,
371  const ArrayView<double> &data,
372  const unsigned int mineral_i) const
373  {
374  return data[cpo_data_position + 1 + mineral_i *(n_grains * 10 + 2)];
375  }
376 
385  inline
386  void set_volume_fraction_mineral(const unsigned int cpo_data_position,
387  const ArrayView<double> &data,
388  const unsigned int mineral_i,
389  const double volume_fraction_mineral) const
390  {
391  data[cpo_data_position + 1 + mineral_i *(n_grains * 10 + 2)] = volume_fraction_mineral;
392  }
393 
402  inline
403  double get_volume_fractions_grains(const unsigned int cpo_data_position,
404  const ArrayView<const double> &data,
405  const unsigned int mineral_i,
406  const unsigned int grain_i) const
407  {
408  return data[cpo_data_position + 2 + grain_i * 10 + mineral_i * (n_grains * 10 + 2)];
409  }
410 
420  inline
421  void set_volume_fractions_grains(const unsigned int cpo_data_position,
422  const ArrayView<double> &data,
423  const unsigned int mineral_i,
424  const unsigned int grain_i,
425  const double volume_fractions_grains) const
426  {
427  data[cpo_data_position + 2 + grain_i * 10 + mineral_i * (n_grains * 10 + 2)] = volume_fractions_grains;
428  }
429 
439  inline
440  Tensor<2,3> get_rotation_matrix_grains(const unsigned int cpo_data_position,
441  const ArrayView<const double> &data,
442  const unsigned int mineral_i,
443  const unsigned int grain_i) const
444  {
445  Tensor<2,3> rotation_matrix;
446  for (unsigned int i = 0; i < Tensor<2,3>::n_independent_components ; ++i)
447  {
448  const ::TableIndices<2> index = Tensor<2,3>::unrolled_to_component_indices(i);
449  rotation_matrix[index] = data[cpo_data_position + 3 + grain_i * 10 + mineral_i * (n_grains * 10 + 2) + i];
450  }
451  return rotation_matrix;
452  }
453 
463  inline
464  void set_rotation_matrix_grains(const unsigned int cpo_data_position,
465  const ArrayView<double> &data,
466  const unsigned int mineral_i,
467  const unsigned int grain_i,
468  const Tensor<2,3> &rotation_matrix) const
469  {
470  for (unsigned int i = 0; i < Tensor<2,3>::n_independent_components ; ++i)
471  {
472  const ::TableIndices<2> index = Tensor<2,3>::unrolled_to_component_indices(i);
473  data[cpo_data_position + 3 + grain_i * 10 + mineral_i * (n_grains * 10 + 2) + i] = rotation_matrix[index];
474  }
475  }
476 
477 
478  private:
482  void
484 
500  double
501  advect_forward_euler(const unsigned int cpo_data_position,
502  const ArrayView<double> &data,
503  const unsigned int mineral_i,
504  const double dt,
505  const std::pair<std::vector<double>, std::vector<Tensor<2,3>>> &derivatives) const;
506 
522  double
523  advect_backward_euler(const unsigned int cpo_data_position,
524  const ArrayView<double> &data,
525  const unsigned int mineral_i,
526  const double dt,
527  const std::pair<std::vector<double>, std::vector<Tensor<2,3>>> &derivatives) const;
528 
529 
536  std::pair<std::vector<double>, std::vector<Tensor<2,3>>>
537  compute_derivatives_spin_tensor(const Tensor<2,3> &velocity_gradient_tensor) const;
538 
542  mutable boost::mt19937 random_number_generator;
543 
548  unsigned int random_number_seed;
549 
554  unsigned int n_grains;
555 
556  unsigned int n_minerals;
557 
561  unsigned int water_index;
562 
569  std::vector<DeformationTypeSelector> deformation_type_selector;
570 
577  std::vector<double> volume_fractions_minerals;
578 
585 
592 
600 
608 
619 
627 
633  double exponent_p;
634 
643 
650  double mobility;
651 
658 
672  std::vector<double> CPX_RRSS;
673 
686  std::vector<double> OlivineD_RRSS;
687 
690  };
691  }
692  }
693 }
694 
695 #endif
boost::iterator_range< particle_iterator > particle_iterator_range
static constexpr TableIndices< rank_ > unrolled_to_component_indices(const unsigned int i)
static void declare_parameters(ParameterHandler &prm)
std::vector< std::pair< std::string, unsigned int > > get_property_information() const override
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.
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.
DeformationType determine_deformation_type_karato_2008(const double stress, const double water_content) const
Computes the deformation type given the stress and water content according to the table in Karato 200...
void parse_parameters(ParameterHandler &prm) override
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.
double advect_backward_euler(const unsigned int cpo_data_position, const ArrayView< double > &data, const unsigned int mineral_i, const double dt, const std::pair< std::vector< double >, std::vector< Tensor< 2, 3 >>> &derivatives) const
Updates the volume fractions and rotation matrices with a Backward Euler scheme.
void load(const std::map< std::string, std::string > &status_strings) override
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.
std::pair< std::vector< double >, std::vector< Tensor< 2, 3 > > > compute_derivatives_drex_2004(const DeformationType deformation_type, const unsigned int cpo_index, const ArrayView< double > &data, const unsigned int mineral_i, const SymmetricTensor< 2, 3 > &strain_rate_3d, const Tensor< 2, 3 > &velocity_gradient_tensor, const std::array< double, 4 > ref_resolved_shear_stress, const bool prevent_nondimensionalization=false) const
Computes the CPO derivatives with the D-Rex 2004 algorithm.
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 compute_random_rotation_matrix(Tensor< 2, 3 > &rotation_matrix) const
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.
std::array< double, 4 > reference_resolved_shear_stress_from_deformation_type(DeformationType deformation_type, double max_value=1e60) const
Computes the reference resolved shear stress (RRSS) based on the selected deformation type.
std::pair< std::vector< double >, std::vector< Tensor< 2, 3 > > > compute_derivatives_spin_tensor(const Tensor< 2, 3 > &velocity_gradient_tensor) const
double advect_forward_euler(const unsigned int cpo_data_position, const ArrayView< double > &data, const unsigned int mineral_i, const double dt, const std::pair< std::vector< double >, std::vector< Tensor< 2, 3 >>> &derivatives) const
Updates the volume fractions and rotation matrices with a Forward Euler scheme.
DeformationType determine_deformation_type(const DeformationTypeSelector deformation_type_selector, const Point< dim > &position, const typename DoFHandler< dim >::active_cell_iterator &cell, const double temperature, const double pressure, const Tensor< 1, dim > &velocity, const std::vector< double > &compositions, const SymmetricTensor< 2, dim > &strain_rate, const SymmetricTensor< 2, dim > &deviatoric_strain_rate, const double water_content) const
Determines the deformation type from the deformation type selector. If the provided deformation_type_...
void update_particle_properties(const ParticleUpdateInputs< dim > &inputs, typename ParticleHandler< dim >::particle_iterator_range &particles) const override
InitializationModeForLateParticles late_initialization_mode() const override
std::pair< std::vector< double >, std::vector< Tensor< 2, 3 > > > compute_derivatives(const unsigned int cpo_index, const ArrayView< double > &data, const unsigned int mineral_i, const SymmetricTensor< 2, 3 > &strain_rate_3d, const Tensor< 2, 3 > &velocity_gradient_tensor, const Point< dim > &position, const typename DoFHandler< dim >::active_cell_iterator &cell, const double temperature, const double pressure, const Tensor< 1, dim > &velocity, const std::vector< double > &compositions, const SymmetricTensor< 2, dim > &strain_rate, const SymmetricTensor< 2, dim > &deviatoric_strain_rate, const double water_content) const
Computes the volume fraction and grain orientation derivatives of all the grains of a mineral.
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.
void initialize_one_particle_property(const Point< dim > &position, std::vector< double > &particle_properties) const override
UpdateFlags get_update_flags(const unsigned int component) const override
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 save(std::map< std::string, std::string > &status_strings) const override
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
UpdateFlags
std::vector< index_type > data
CPOInitialGrainsModel
An enum used to determine how the initial grain sizes and orientations are set for all particles.
DeformationTypeSelector
The type of deformation selector used by the CPO code.
DeformationType
The type of deformation used by the CPO code.
CPODerivativeAlgorithm
The algorithm used to compute the derivatives of the grain size and rotation matrix used in the advec...
AdvectionMethod
The type of Advection method used to advect the CPO properties.