<commit_before>//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#pragma once

#include "Material.h"
#include "DerivativeMaterialInterface.h"

/**
 * CompositeTensorBase computes a simple T type MaterialProperty \f$ \bar T\f$
 * that is summed up from a list of other T objects (tensors) \f$ T_i \f$ with
 * associated weights \f$ w_i \f$.
 * \f$ \bar T = \sum_i T_i\cdot w_i \f$
 * Derivatives w.r.t. variables are computed accordingly.
 * This base class is used by the CompositeMobilityTensor and
 * CompositeElasticityTensor classes.
 *
 * \tparam T The type of the objects to sum together
 */
template <class T, class U>
class CompositeTensorBase : public DerivativeMaterialInterface<U>
{
public:
  CompositeTensorBase(const InputParameters & parameters);

  static InputParameters validParams();

protected:
  /**
   * Output material properties are initialized here so that derived classes can
   * modify the name.
   */
  void initializeDerivativeProperties(const std::string name);

  /**
   * Fill in the
   *  * main tensor property given by M
   *  * derivatives, set up by initializeDerivativeProperties
   *
   * The root_property is kept separate from the derivatives to allow the application
   * of this template to the Eigenstrain calculation, which contributes derivatives to a different
   * material property (and uses a derivative_prefactor of -1).
   */
  virtual void computeQpTensorProperties(MaterialProperty<T> & M, Real derivative_prefactor = 1.0);

  /// component tensor names
  std::vector<MaterialPropertyName> _tensor_names;
  /// component weight names
  std::vector<MaterialPropertyName> _weight_names;

  /// number of dependent variables
  unsigned int _num_args;
  /// number of compomemt tensors and weights
  unsigned int _num_comp;

  /// @{ Composed tensor and its derivatives
  std::vector<MaterialProperty<T> *> _dM;
  std::vector<std::vector<MaterialProperty<T> *>> _d2M;
  /// @}

  /// @{ component tensors and their derivatives w.r.t. the args
  std::vector<const MaterialProperty<T> *> _tensors;
  std::vector<std::vector<const MaterialProperty<T> *>> _dtensors;
  std::vector<std::vector<std::vector<const MaterialProperty<T> *>>> _d2tensors;
  /// @}

  /// @{ component weights and their derivatives w.r.t. the args
  std::vector<const MaterialProperty<Real> *> _weights;
  std::vector<std::vector<const MaterialProperty<Real> *>> _dweights;
  std::vector<std::vector<std::vector<const MaterialProperty<Real> *>>> _d2weights;
  /// @}
};

template <class T, class U>
CompositeTensorBase<T, U>::CompositeTensorBase(const InputParameters & parameters)
  : DerivativeMaterialInterface<U>(parameters),
    _tensor_names(this->template getParamTempl<std::vector<MaterialPropertyName>>("tensors")),
    _weight_names(this->template getParamTempl<std::vector<MaterialPropertyName>>("weights")),
    _num_args(this->DerivativeMaterialInterface<U>::coupledComponents("args")),
    _num_comp(_tensor_names.size()),
    _dM(_num_args),
    _d2M(_num_args),
    _tensors(_num_comp),
    _dtensors(_num_comp),
    _d2tensors(_num_comp),
    _weights(_num_comp),
    _dweights(_num_comp),
    _d2weights(_num_comp)
{
  if (_num_comp != _weight_names.size())
    mooseError("The number of supplied 'tensors' and 'weights' must match.");
}

template <class T, class U>
InputParameters
CompositeTensorBase<T, U>::validParams()
{
  InputParameters params = ::validParams<U>();
  params.addRequiredParam<std::vector<MaterialPropertyName>>("tensors", "Component tensors");
  params.addRequiredParam<std::vector<MaterialPropertyName>>("weights", "Component weights");
  params.addRequiredCoupledVar("args", "variable dependencies for the prefactor");
  return params;
}

template <class T, class U>
void
CompositeTensorBase<T, U>::initializeDerivativeProperties(const std::string name)<commit_msg>Update CompositeTensorBase to new static validParams member function<commit_after>//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#pragma once

#include "Material.h"
#include "DerivativeMaterialInterface.h"

/**
 * CompositeTensorBase computes a simple T type MaterialProperty \f$ \bar T\f$
 * that is summed up from a list of other T objects (tensors) \f$ T_i \f$ with
 * associated weights \f$ w_i \f$.
 * \f$ \bar T = \sum_i T_i\cdot w_i \f$
 * Derivatives w.r.t. variables are computed accordingly.
 * This base class is used by the CompositeMobilityTensor and
 * CompositeElasticityTensor classes.
 *
 * \tparam T The type of the objects to sum together
 */
template <class T, class U>
class CompositeTensorBase : public DerivativeMaterialInterface<U>
{
public:
  CompositeTensorBase(const InputParameters & parameters);

  static InputParameters validParams();

protected:
  /**
   * Output material properties are initialized here so that derived classes can
   * modify the name.
   */
  void initializeDerivativeProperties(const std::string name);

  /**
   * Fill in the
   *  * main tensor property given by M
   *  * derivatives, set up by initializeDerivativeProperties
   *
   * The root_property is kept separate from the derivatives to allow the application
   * of this template to the Eigenstrain calculation, which contributes derivatives to a different
   * material property (and uses a derivative_prefactor of -1).
   */
  virtual void computeQpTensorProperties(MaterialProperty<T> & M, Real derivative_prefactor = 1.0);

  /// component tensor names
  std::vector<MaterialPropertyName> _tensor_names;
  /// component weight names
  std::vector<MaterialPropertyName> _weight_names;

  /// number of dependent variables
  unsigned int _num_args;
  /// number of compomemt tensors and weights
  unsigned int _num_comp;

  /// @{ Composed tensor and its derivatives
  std::vector<MaterialProperty<T> *> _dM;
  std::vector<std::vector<MaterialProperty<T> *>> _d2M;
  /// @}

  /// @{ component tensors and their derivatives w.r.t. the args
  std::vector<const MaterialProperty<T> *> _tensors;
  std::vector<std::vector<const MaterialProperty<T> *>> _dtensors;
  std::vector<std::vector<std::vector<const MaterialProperty<T> *>>> _d2tensors;
  /// @}

  /// @{ component weights and their derivatives w.r.t. the args
  std::vector<const MaterialProperty<Real> *> _weights;
  std::vector<std::vector<const MaterialProperty<Real> *>> _dweights;
  std::vector<std::vector<std::vector<const MaterialProperty<Real> *>>> _d2weights;
  /// @}
};

template <class T, class U>
CompositeTensorBase<T, U>::CompositeTensorBase(const InputParameters & parameters)
  : DerivativeMaterialInterface<U>(parameters),
    _tensor_names(this->template getParamTempl<std::vector<MaterialPropertyName>>("tensors")),
    _weight_names(this->template getParamTempl<std::vector<MaterialPropertyName>>("weights")),
    _num_args(this->DerivativeMaterialInterface<U>::coupledComponents("args")),
    _num_comp(_tensor_names.size()),
    _dM(_num_args),
    _d2M(_num_args),
    _tensors(_num_comp),
    _dtensors(_num_comp),
    _d2tensors(_num_comp),
    _weights(_num_comp),
    _dweights(_num_comp),
    _d2weights(_num_comp)
{
  if (_num_comp != _weight_names.size())
    mooseError("The number of supplied 'tensors' and 'weights' must match.");
}

template <class T, class U>
InputParameters
CompositeTensorBase<T, U>::validParams()
{
  InputParameters params = U::validParams();
  params.addRequiredParam<std::vector<MaterialPropertyName>>("tensors", "Component tensors");
  params.addRequiredParam<std::vector<MaterialPropertyName>>("weights", "Component weights");
  params.addRequiredCoupledVar("args", "variable dependencies for the prefactor");
  return params;
}

template <class T, class U>
void
CompositeTensorBase<T, U>::initializeDerivativeProperties(const std::string name)
{'fraction_non_alphanumeric': 0.12080048514251061, 'fraction_numerical': 0.003153426318981201, 'mean_word_length': 4.898426323319027, 'pattern_counts': {'":': 0, '<': 92, '<?xml version=': 0, '>': 98, 'https://': 6, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1685049', 'n_tokens_mistral': 2513, 'n_tokens_neox': 2461, 'n_words': 664}