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 : #pragma once 10 : 11 : #include "LAROMANCEStressUpdateBase.h" 12 : 13 : template <bool is_ad> 14 : class LAROMANCEPartitionStressUpdateBaseTempl : public LAROMANCEStressUpdateBaseTempl<is_ad> 15 : { 16 : public: 17 : static InputParameters validParams(); 18 : 19 : LAROMANCEPartitionStressUpdateBaseTempl(const InputParameters & parameters); 20 : 21 : protected: 22 : virtual void initialSetup() override; 23 : virtual void computePartitionWeights(std::vector<GenericReal<is_ad>> & weights, 24 : std::vector<GenericReal<is_ad>> & dweights_dstress) override; 25 : 26 : virtual void exportJSON() override; 27 : 28 : /** 29 : * Compute the partition weight on the location in input-space, 30 : * based on a calibrated Gaussian Process Regression model 31 : */ 32 : virtual GenericReal<is_ad> computeSecondPartitionWeight(); 33 : 34 : /// Width to determine the finite difference derivative for the partition weight 35 : const Real _finite_difference_width; 36 : 37 : /** 38 : * Compute the derivative of the partition weight of the second partition w.r.t. stress 39 : */ 40 : virtual void 41 : computeDSecondPartitionWeightDStress(GenericReal<is_ad> & dsecond_partition_weight_dstress); 42 : 43 : ///@{ Method and container for the Gaussian Process Regression lower triangular covariance matrix 44 36 : virtual std::vector<std::vector<Real>> getClassificationLuu() 45 : { 46 36 : this->checkJSONKey("luu"); 47 72 : return this->_json["luu"].template get<std::vector<std::vector<Real>>>(); 48 : } 49 : std::vector<std::vector<Real>> _partition_Luu; 50 : ///@} 51 : 52 : ///@{ Method and container for the Gaussian Process Regression model training points 53 36 : virtual std::vector<std::vector<Real>> getClassificationXu() 54 : { 55 36 : this->checkJSONKey("xu"); 56 72 : return this->_json["xu"].template get<std::vector<std::vector<Real>>>(); 57 : } 58 : std::vector<std::vector<Real>> _partition_Xu; 59 : ///@} 60 : 61 : ///@{ Method and container for the inducing points of the Gaussian Process Regression model 62 36 : virtual DenseVector<Real> getClassificationVind() 63 : { 64 36 : this->checkJSONKey("vind"); 65 72 : return DenseVector<Real>(this->_json["vind"].template get<std::vector<Real>>()); 66 : } 67 : DenseVector<Real> _partition_Vind; 68 : ///@} 69 : 70 : ///@{ Method and container for the mean values of the training input 71 36 : virtual std::vector<Real> getClassificationMmean() 72 : { 73 36 : this->checkJSONKey("m_mean"); 74 72 : return this->_json["m_mean"].template get<std::vector<Real>>(); 75 : } 76 : std::vector<Real> _partition_Mmean; 77 : ///@} 78 : 79 : ///@{ Method and container for the scale factor of the training input points to normalize all input parameters to equivalent values 80 36 : virtual std::vector<Real> getClassificationMscale() 81 : { 82 36 : this->checkJSONKey("m_scale"); 83 72 : return this->_json["m_scale"].template get<std::vector<Real>>(); 84 : } 85 : std::vector<Real> _partition_Mscale; 86 : ///@} 87 : 88 : ///@{ Method and container for the calibrated Gaussian Regression Model hyperparameter "Ell", which controls the decay of the covariance as a function of distance 89 36 : virtual Real getClassificationEll() 90 : { 91 36 : this->checkJSONKey("ell"); 92 72 : return this->_json["ell"].template get<Real>(); 93 : } 94 : Real _partition_Ell; 95 : ///@} 96 : 97 : ///@{ Method and container for the calibrated Gaussian Regression Model hyperparameter "Eta", which is a scale factor that controls the amplitude of the mean 98 36 : virtual Real getClassificationEta() 99 : { 100 36 : this->checkJSONKey("eta"); 101 72 : return this->_json["eta"].template get<Real>(); 102 : } 103 : Real _partition_Eta; 104 : ///@} 105 : 106 : ///@{ Containers for parition math 107 : std::vector<std::vector<GenericReal<is_ad>>> _partition_difference; 108 : std::vector<GenericReal<is_ad>> _partition_distance; 109 : std::vector<GenericReal<is_ad>> _partition_covariance; 110 : DenseVector<GenericReal<is_ad>> _partition_b; 111 : DenseMatrix<GenericReal<is_ad>> _partition_A; 112 : ///@} 113 : 114 : using LAROMANCEStressUpdateBaseTempl<is_ad>::_input_values; 115 : using LAROMANCEStressUpdateBaseTempl<is_ad>::_second_partition_weight; 116 : using LAROMANCEStressUpdateBaseTempl<is_ad>::_stress_input_index; 117 : using LAROMANCEStressUpdateBaseTempl<is_ad>::_qp; 118 : using LAROMANCEStressUpdateBaseTempl<is_ad>::_old_strain_input_index; 119 : using LAROMANCEStressUpdateBaseTempl<is_ad>::_num_inputs; 120 : using LAROMANCEStressUpdateBaseTempl<is_ad>::_num_partitions; 121 : using LAROMANCEStressUpdateBaseTempl<is_ad>::sigmoid; 122 : }; 123 : 124 : typedef LAROMANCEPartitionStressUpdateBaseTempl<false> LAROMANCEPartitionStressUpdateBase; 125 : typedef LAROMANCEPartitionStressUpdateBaseTempl<true> ADLAROMANCEPartitionStressUpdateBase;