Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #pragma once 11 : 12 : #include "EulerAngleProvider.h" 13 : 14 : // Forward declaration 15 : class RotationTensor; 16 : class GrainTrackerInterface; 17 : class GrainForceAndTorqueInterface; 18 : 19 : /** 20 : * Update Euler angles of each grains after rigid body rotation 21 : * This class estimates the rotation of principal axes of the grains due to applied torques 22 : * and calculates the final grain orientation. 23 : * Step1: Calculate RotationTensor based on euler angles from previous time step (R0) 24 : * Step2: Obtain the torque acting on the grains at current time Step 25 : * Step3: Calculate the angular velocities around global axes 26 : * Step4: Calculate change in euler angles due to torque and corresponding rotation matrix(R1) 27 : * Step5: Calculate final rotation matrix, R = R1 * R0, determines the final position of any rotated 28 : * vector 29 : * Step6: Back-calculate the euler angles from the final rotation matrix 30 : * Step7: Ensure euler angles comply with Bunge definitions 31 : */ 32 : class EulerAngleUpdater : public EulerAngleProvider 33 : { 34 : public: 35 : static InputParameters validParams(); 36 : 37 : EulerAngleUpdater(const InputParameters & parameters); 38 : 39 : virtual void initialize() override; 40 58 : virtual void execute() override {} 41 58 : virtual void finalize() override {} 42 : 43 : virtual const EulerAngles & getEulerAngles(unsigned int) const override; 44 : virtual const EulerAngles & getEulerAnglesOld(unsigned int) const; 45 : virtual unsigned int getGrainNum() const override; 46 : 47 : protected: 48 : const GrainTrackerInterface & _grain_tracker; 49 : const EulerAngleProvider & _euler; 50 : const GrainForceAndTorqueInterface & _grain_torque; 51 : const VectorPostprocessorValue & _grain_volumes; 52 : 53 : const Real _mr; 54 : /// Whether this is the first time updating angles, in which case the initial euler angle provider should be used 55 : bool & _first_time; 56 : /// Whether the simulation has recovered once. This only serves to prevent using the old angles in initialize() 57 : /// as problem.converged() returns false on the very first initialize() call after recovering 58 : bool _first_time_recovered; 59 : /// Used to determine whether a timestep is being repeated 60 : int & _t_step_old; 61 : 62 : /// Current set of Euler angles (one per grain), updated on initialize() 63 : std::vector<EulerAngles> & _angles; 64 : /// Previous set of Euler angles, used when the time step failed to reset the angles (pre-update) 65 : std::vector<EulerAngles> & _angles_old; 66 : };