diff --git a/framework/doc/content/source/utils/DualReal.md b/framework/doc/content/source/utils/ADReal.md similarity index 94% rename from framework/doc/content/source/utils/DualReal.md rename to framework/doc/content/source/utils/ADReal.md index 622aa02ecd0a..96309d34017b 100644 --- a/framework/doc/content/source/utils/DualReal.md +++ b/framework/doc/content/source/utils/ADReal.md @@ -1,6 +1,6 @@ -# DualReal +# ADReal -`DualReal` is the type underpinning all of MOOSE's automatic differentiation (AD) +`ADReal` is the type underpinning all of MOOSE's automatic differentiation (AD) capabilities. [#overview] @@ -8,7 +8,7 @@ capabilities. ## Overview id=overview -`DualReal` is a MOOSE typedef defined from the +`ADReal` is a MOOSE typedef defined from the [MetaPhysicL](https://github.com/libMesh/MetaPhysicL) template class `DualNumber`. `DualNumber` takes two template arguments `T` and `D`; `T` represents the "value" type of the `DualNumber`, e.g. the type of $f(\vec{x})$, diff --git a/framework/doc/content/source/utils/MooseTypes.md b/framework/doc/content/source/utils/MooseTypes.md index 6218b34dd2bb..bffea85ba538 100644 --- a/framework/doc/content/source/utils/MooseTypes.md +++ b/framework/doc/content/source/utils/MooseTypes.md @@ -10,7 +10,7 @@ differentiation in MOOSE. It defines the following macros: - `ADRankTwoTensor` - `ADRankFourTensor` -which resolve to either `Real` or [`DualReal`](/DualReal.md) based objects +which resolve to either `Real` or [`ADReal`](/ADReal.md) based objects depending on whether `compute_stage` is equivalent to `RESIDUAL` or `JACOBIAN`. `compute_stage` is a template argument to AD consuming and producing objects like `ADKernel` and `ADMaterial` respectively. diff --git a/framework/include/base/Assembly.h b/framework/include/base/Assembly.h index f497eda215df..e6f98ce6f0d9 100644 --- a/framework/include/base/Assembly.h +++ b/framework/include/base/Assembly.h @@ -23,8 +23,6 @@ #include "libmesh/numeric_vector.h" #include "libmesh/elem_side_builder.h" -#include "DualRealOps.h" - #include // libMesh forward declarations @@ -2376,7 +2374,7 @@ class Assembly /// The current coordinate transformation coefficients MooseArray _coord; /// The AD version of the current coordinate transformation coefficients - MooseArray _ad_coord; + MooseArray _ad_coord; /// Data structure for tracking/grouping a set of quadrature rules for a /// particular dimensionality of mesh element. @@ -2777,30 +2775,30 @@ class Assembly std::vector _temp_reference_points; /// AD quantities - std::vector> _ad_dxyzdxi_map; - std::vector> _ad_dxyzdeta_map; - std::vector> _ad_dxyzdzeta_map; - std::vector> _ad_d2xyzdxi2_map; - std::vector> _ad_d2xyzdxideta_map; - std::vector> _ad_d2xyzdeta2_map; - std::vector _ad_jac; - MooseArray _ad_JxW; - MooseArray> _ad_q_points; - std::vector _ad_dxidx_map; - std::vector _ad_dxidy_map; - std::vector _ad_dxidz_map; - std::vector _ad_detadx_map; - std::vector _ad_detady_map; - std::vector _ad_detadz_map; - std::vector _ad_dzetadx_map; - std::vector _ad_dzetady_map; - std::vector _ad_dzetadz_map; - - MooseArray _ad_JxW_face; - MooseArray> _ad_normals; - MooseArray> _ad_q_points_face; + std::vector> _ad_dxyzdxi_map; + std::vector> _ad_dxyzdeta_map; + std::vector> _ad_dxyzdzeta_map; + std::vector> _ad_d2xyzdxi2_map; + std::vector> _ad_d2xyzdxideta_map; + std::vector> _ad_d2xyzdeta2_map; + std::vector _ad_jac; + MooseArray _ad_JxW; + MooseArray> _ad_q_points; + std::vector _ad_dxidx_map; + std::vector _ad_dxidy_map; + std::vector _ad_dxidz_map; + std::vector _ad_detadx_map; + std::vector _ad_detady_map; + std::vector _ad_detadz_map; + std::vector _ad_dzetadx_map; + std::vector _ad_dzetady_map; + std::vector _ad_dzetadz_map; + + MooseArray _ad_JxW_face; + MooseArray> _ad_normals; + MooseArray> _ad_q_points_face; MooseArray _curvatures; - MooseArray _ad_curvatures; + MooseArray _ad_curvatures; /** * Container of displacement numbers and directions diff --git a/framework/include/dgkernels/ADDGKernel.h b/framework/include/dgkernels/ADDGKernel.h index 4affa0b48ca7..1a289c8775e1 100644 --- a/framework/include/dgkernels/ADDGKernel.h +++ b/framework/include/dgkernels/ADDGKernel.h @@ -11,8 +11,6 @@ #include "DGKernelBase.h" -#include "DualRealOps.h" - class ADDGKernel : public DGKernelBase, public NeighborMooseVariableInterface { public: diff --git a/framework/include/interfaces/Coupleable.h b/framework/include/interfaces/Coupleable.h index 70e2d2bc4c13..58a2b7ce1ad4 100644 --- a/framework/include/interfaces/Coupleable.h +++ b/framework/include/interfaces/Coupleable.h @@ -1395,7 +1395,7 @@ class Coupleable _default_value; /// Will hold the default value for optional coupled variables for automatic differentiation. - mutable std::unordered_map>> _ad_default_value; + mutable std::unordered_map>> _ad_default_value; /// Will hold the default value for optional vector coupled variables. mutable std::unordered_map> @@ -1432,7 +1432,7 @@ class Coupleable /// Zero value of a variable const VariableValue & _zero; const VariablePhiValue & _phi_zero; - const MooseArray & _ad_zero; + const MooseArray & _ad_zero; /// Zero gradient of a variable const VariableGradient & _grad_zero; diff --git a/framework/include/kernels/ADKernel.h b/framework/include/kernels/ADKernel.h index c122a5677638..eb76d35a7da1 100644 --- a/framework/include/kernels/ADKernel.h +++ b/framework/include/kernels/ADKernel.h @@ -11,7 +11,6 @@ #include "KernelBase.h" #include "ADFunctorInterface.h" -#include "DualRealOps.h" // forward declarations template diff --git a/framework/include/restart/DataIO.h b/framework/include/restart/DataIO.h index 76d0c7708413..1d605114049c 100644 --- a/framework/include/restart/DataIO.h +++ b/framework/include/restart/DataIO.h @@ -10,7 +10,7 @@ #pragma once // MOOSE includes -#include "DualReal.h" +#include "ADReal.h" #include "MooseTypes.h" #include "HashMap.h" #include "MooseError.h" @@ -397,7 +397,7 @@ void dataStore(std::ostream & stream, Node *& n, void * context); template <> void dataStore(std::ostream & stream, std::stringstream & s, void * context); template <> -void dataStore(std::ostream & stream, DualReal & dn, void * context); +void dataStore(std::ostream & stream, ADReal & dn, void * context); template <> void dataStore(std::ostream & stream, RealEigenVector & v, void * context); template <> @@ -421,7 +421,7 @@ void dataStore(std::ostream & stream, template inline void -dataStore(std::ostream & stream, std::array & dn, void * context) +dataStore(std::ostream & stream, std::array & dn, void * context) { for (std::size_t i = 0; i < N; ++i) dataStore(stream, dn[i], context); @@ -429,7 +429,7 @@ dataStore(std::ostream & stream, std::array & dn, void * context) template inline void -dataStore(std::ostream & stream, DualReal (&dn)[N], void * context) +dataStore(std::ostream & stream, ADReal (&dn)[N], void * context) { for (std::size_t i = 0; i < N; ++i) dataStore(stream, dn[i], context); @@ -722,7 +722,7 @@ void dataLoad(std::istream & stream, Node *& e, void * context); template <> void dataLoad(std::istream & stream, std::stringstream & s, void * context); template <> -void dataLoad(std::istream & stream, DualReal & dn, void * context); +void dataLoad(std::istream & stream, ADReal & dn, void * context); template <> void dataLoad(std::istream & stream, RealEigenVector & v, void * context); template <> @@ -753,7 +753,7 @@ void dataLoad(std::istream & stream, template inline void -dataLoad(std::istream & stream, std::array & dn, void * context) +dataLoad(std::istream & stream, std::array & dn, void * context) { for (std::size_t i = 0; i < N; ++i) dataLoad(stream, dn[i], context); @@ -761,7 +761,7 @@ dataLoad(std::istream & stream, std::array & dn, void * context) template inline void -dataLoad(std::istream & stream, DualReal (&dn)[N], void * context) +dataLoad(std::istream & stream, ADReal (&dn)[N], void * context) { for (std::size_t i = 0; i < N; ++i) dataLoad(stream, dn[i], context); diff --git a/framework/include/timeintegrators/AStableDirk4.h b/framework/include/timeintegrators/AStableDirk4.h index f44f2f20cc04..29ba0474182a 100644 --- a/framework/include/timeintegrators/AStableDirk4.h +++ b/framework/include/timeintegrators/AStableDirk4.h @@ -57,9 +57,9 @@ class AStableDirk4 : public TimeIntegrator virtual int order() override { return 4; } virtual void computeTimeDerivatives() override; - void computeADTimeDerivatives(DualReal & ad_u_dot, + void computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & ad_u_dotdot) const override; + ADReal & ad_u_dotdot) const override; virtual void solve() override; virtual void postResidual(NumericVector & residual) override; diff --git a/framework/include/timeintegrators/ActuallyExplicitEuler.h b/framework/include/timeintegrators/ActuallyExplicitEuler.h index 6b2a2b65e787..6620aaa9f1d7 100644 --- a/framework/include/timeintegrators/ActuallyExplicitEuler.h +++ b/framework/include/timeintegrators/ActuallyExplicitEuler.h @@ -24,9 +24,9 @@ class ActuallyExplicitEuler : public ExplicitTimeIntegrator virtual int order() override { return 1; } virtual void computeTimeDerivatives() override; - void computeADTimeDerivatives(DualReal & ad_u_dot, + void computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & ad_u_dotdot) const override; + ADReal & ad_u_dotdot) const override; virtual void solve() override; virtual void postResidual(NumericVector & residual) override; diff --git a/framework/include/timeintegrators/BDF2.h b/framework/include/timeintegrators/BDF2.h index 0a7ace4b074a..50ffc9928a6e 100644 --- a/framework/include/timeintegrators/BDF2.h +++ b/framework/include/timeintegrators/BDF2.h @@ -25,9 +25,9 @@ class BDF2 : public TimeIntegrator virtual int order() override { return 2; } virtual void preStep() override; virtual void computeTimeDerivatives() override; - void computeADTimeDerivatives(DualReal & ad_u_dot, + void computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & ad_u_dotdot) const override; + ADReal & ad_u_dotdot) const override; virtual void postResidual(NumericVector & residual) override; protected: diff --git a/framework/include/timeintegrators/CentralDifference.h b/framework/include/timeintegrators/CentralDifference.h index 82f8534726ee..175c600c804c 100644 --- a/framework/include/timeintegrators/CentralDifference.h +++ b/framework/include/timeintegrators/CentralDifference.h @@ -26,9 +26,9 @@ class CentralDifference : public ActuallyExplicitEuler virtual int order() override { return 2; } virtual void computeTimeDerivatives() override; - void computeADTimeDerivatives(DualReal & ad_u_dot, + void computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & ad_u_dotdot) const override; + ADReal & ad_u_dotdot) const override; protected: /// solution vector for \f$ {du^dotdot}\over{du} \f$ diff --git a/framework/include/timeintegrators/CrankNicolson.h b/framework/include/timeintegrators/CrankNicolson.h index fb3286f7455c..8b9abfbe0db1 100644 --- a/framework/include/timeintegrators/CrankNicolson.h +++ b/framework/include/timeintegrators/CrankNicolson.h @@ -29,9 +29,9 @@ class CrankNicolson : public TimeIntegrator virtual void init() override; virtual int order() override { return 2; } virtual void computeTimeDerivatives() override; - void computeADTimeDerivatives(DualReal & ad_u_dot, + void computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & ad_u_dotdot) const override; + ADReal & ad_u_dotdot) const override; virtual void postResidual(NumericVector & residual) override; virtual void postStep() override; diff --git a/framework/include/timeintegrators/ExplicitEuler.h b/framework/include/timeintegrators/ExplicitEuler.h index add0942fa74c..2a3dabc41dd2 100644 --- a/framework/include/timeintegrators/ExplicitEuler.h +++ b/framework/include/timeintegrators/ExplicitEuler.h @@ -24,9 +24,9 @@ class ExplicitEuler : public TimeIntegrator virtual void preSolve() override; virtual int order() override { return 1; } virtual void computeTimeDerivatives() override; - void computeADTimeDerivatives(DualReal & ad_u_dot, + void computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & ad_u_dotdot) const override; + ADReal & ad_u_dotdot) const override; virtual void postResidual(NumericVector & residual) override; protected: diff --git a/framework/include/timeintegrators/ExplicitRK2.h b/framework/include/timeintegrators/ExplicitRK2.h index 29fea40ae14c..490e916d802f 100644 --- a/framework/include/timeintegrators/ExplicitRK2.h +++ b/framework/include/timeintegrators/ExplicitRK2.h @@ -62,9 +62,9 @@ class ExplicitRK2 : public TimeIntegrator virtual int order() override { return 2; } virtual void computeTimeDerivatives() override; - void computeADTimeDerivatives(DualReal & ad_u_dot, + void computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & ad_u_dotdot) const override; + ADReal & ad_u_dotdot) const override; virtual void solve() override; virtual void postResidual(NumericVector & residual) override; diff --git a/framework/include/timeintegrators/ExplicitSSPRungeKutta.h b/framework/include/timeintegrators/ExplicitSSPRungeKutta.h index f0b7c7679aac..8c7aa888bc12 100644 --- a/framework/include/timeintegrators/ExplicitSSPRungeKutta.h +++ b/framework/include/timeintegrators/ExplicitSSPRungeKutta.h @@ -22,9 +22,9 @@ class ExplicitSSPRungeKutta : public ExplicitTimeIntegrator ExplicitSSPRungeKutta(const InputParameters & parameters); virtual void computeTimeDerivatives() override; - virtual void computeADTimeDerivatives(DualReal & ad_u_dot, + virtual void computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & ad_u_dotdot) const override; + ADReal & ad_u_dotdot) const override; virtual void solve() override; virtual void postResidual(NumericVector & residual) override; virtual int order() override { return _order; } diff --git a/framework/include/timeintegrators/ExplicitTVDRK2.h b/framework/include/timeintegrators/ExplicitTVDRK2.h index 3eac5788ecd6..98caff9453d0 100644 --- a/framework/include/timeintegrators/ExplicitTVDRK2.h +++ b/framework/include/timeintegrators/ExplicitTVDRK2.h @@ -53,9 +53,9 @@ class ExplicitTVDRK2 : public TimeIntegrator virtual int order() override { return 2; } virtual void computeTimeDerivatives() override; - void computeADTimeDerivatives(DualReal & ad_u_dot, + void computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & ad_u_dotdot) const override; + ADReal & ad_u_dotdot) const override; virtual void solve() override; virtual void postResidual(NumericVector & residual) override; diff --git a/framework/include/timeintegrators/ImplicitEuler.h b/framework/include/timeintegrators/ImplicitEuler.h index 6a3ad6ca4760..6c8d7ee9bd7f 100644 --- a/framework/include/timeintegrators/ImplicitEuler.h +++ b/framework/include/timeintegrators/ImplicitEuler.h @@ -24,9 +24,9 @@ class ImplicitEuler : public TimeIntegrator virtual int order() override { return 1; } virtual void computeTimeDerivatives() override; - void computeADTimeDerivatives(DualReal & ad_u_dot, + void computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & ad_u_dotdot) const override; + ADReal & ad_u_dotdot) const override; virtual void postResidual(NumericVector & residual) override; protected: diff --git a/framework/include/timeintegrators/ImplicitMidpoint.h b/framework/include/timeintegrators/ImplicitMidpoint.h index 4bb4a505040f..017f6a0daa85 100644 --- a/framework/include/timeintegrators/ImplicitMidpoint.h +++ b/framework/include/timeintegrators/ImplicitMidpoint.h @@ -48,9 +48,9 @@ class ImplicitMidpoint : public TimeIntegrator virtual int order() override { return 2; } virtual void computeTimeDerivatives() override; - void computeADTimeDerivatives(DualReal & ad_u_dot, + void computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & ad_u_dotdot) const override; + ADReal & ad_u_dotdot) const override; virtual void solve() override; virtual void postResidual(NumericVector & residual) override; diff --git a/framework/include/timeintegrators/LStableDirk2.h b/framework/include/timeintegrators/LStableDirk2.h index 2ed1681039d7..7b93014f0fa7 100644 --- a/framework/include/timeintegrators/LStableDirk2.h +++ b/framework/include/timeintegrators/LStableDirk2.h @@ -44,9 +44,9 @@ class LStableDirk2 : public TimeIntegrator virtual int order() override { return 2; } virtual void computeTimeDerivatives() override; - void computeADTimeDerivatives(DualReal & ad_u_dot, + void computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & ad_u_dotdot) const override; + ADReal & ad_u_dotdot) const override; virtual void solve() override; virtual void postResidual(NumericVector & residual) override; diff --git a/framework/include/timeintegrators/LStableDirk3.h b/framework/include/timeintegrators/LStableDirk3.h index 664e292709ef..f437314019e4 100644 --- a/framework/include/timeintegrators/LStableDirk3.h +++ b/framework/include/timeintegrators/LStableDirk3.h @@ -46,9 +46,9 @@ class LStableDirk3 : public TimeIntegrator virtual int order() override { return 3; } virtual void computeTimeDerivatives() override; - virtual void computeADTimeDerivatives(DualReal & ad_u_dot, + virtual void computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & ad_u_dotdot) const override; + ADReal & ad_u_dotdot) const override; virtual void solve() override; virtual void postResidual(NumericVector & residual) override; diff --git a/framework/include/timeintegrators/LStableDirk4.h b/framework/include/timeintegrators/LStableDirk4.h index 4e7a408279ec..64aa1cb71e00 100644 --- a/framework/include/timeintegrators/LStableDirk4.h +++ b/framework/include/timeintegrators/LStableDirk4.h @@ -57,9 +57,9 @@ class LStableDirk4 : public TimeIntegrator virtual int order() override { return 4; } virtual void computeTimeDerivatives() override; - virtual void computeADTimeDerivatives(DualReal & ad_u_dot, + virtual void computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & ad_u_dotdot) const override; + ADReal & ad_u_dotdot) const override; virtual void solve() override; virtual void postResidual(NumericVector & residual) override; diff --git a/framework/include/timeintegrators/NewmarkBeta.h b/framework/include/timeintegrators/NewmarkBeta.h index c5ca28f55b3c..03ac4af36d54 100644 --- a/framework/include/timeintegrators/NewmarkBeta.h +++ b/framework/include/timeintegrators/NewmarkBeta.h @@ -25,9 +25,9 @@ class NewmarkBeta : public TimeIntegrator virtual int order() override { return 1; } virtual void computeTimeDerivatives() override; - virtual void computeADTimeDerivatives(DualReal & ad_u_dot, + virtual void computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & ad_u_dotdot) const override; + ADReal & ad_u_dotdot) const override; virtual void postResidual(NumericVector & residual) override; protected: diff --git a/framework/include/timeintegrators/TimeIntegrator.h b/framework/include/timeintegrators/TimeIntegrator.h index e91f747bdd30..c7aade25760a 100644 --- a/framework/include/timeintegrators/TimeIntegrator.h +++ b/framework/include/timeintegrators/TimeIntegrator.h @@ -108,9 +108,9 @@ class TimeIntegrator : public MooseObject, public Restartable /** * method for computing local automatic differentiation time derivatives */ - virtual void computeADTimeDerivatives(DualReal & ad_u_dot, + virtual void computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & ad_u_dot_dot) const = 0; + ADReal & ad_u_dot_dot) const = 0; /** * Gets the total number of nonlinear iterations over all stages of the time step. diff --git a/framework/include/utils/ADReal.h b/framework/include/utils/ADReal.h index 2dd24149f4f2..9bd9aa10d42a 100644 --- a/framework/include/utils/ADReal.h +++ b/framework/include/utils/ADReal.h @@ -10,7 +10,35 @@ #pragma once #include "ADRealForward.h" -#include "DualRealOps.h" +#include "MooseError.h" + +#include "metaphysicl/dualsemidynamicsparsenumberarray.h" +#include "metaphysicl/metaphysicl_exceptions.h" + +namespace Moose +{ +template +inline void +derivInsert(SemiDynamicSparseNumberArray> & derivs, + libMesh::dof_id_type index, + Real value) +{ +#ifndef NDEBUG + try + { + derivs.insert(index) = value; + } + catch (MetaPhysicL::LogicError &) + { + mooseError("The last insertion into the sparse derivative storage container exceeded the " + "underlying array size. Consider running `configure --with-derivative-size=` to " + "obtain a larger underlying container"); + } +#else + derivs.insert(index) = value; +#endif +} +} namespace Eigen { @@ -109,4 +137,3 @@ struct ScalarBinaryOpTraits, Real, BinaryOp> { typedef MetaPhysicL::DualNumber ReturnType; }; -} // namespace Eigen diff --git a/framework/include/utils/ADRealForward.h b/framework/include/utils/ADRealForward.h index fc8ac73cf888..d6448f6dbd3d 100644 --- a/framework/include/utils/ADRealForward.h +++ b/framework/include/utils/ADRealForward.h @@ -9,6 +9,39 @@ #pragma once -#include "DualReal.h" +#include "MooseConfig.h" +#include "libmesh/libmesh_common.h" +#include "metaphysicl/metaphysicl_version.h" -typedef DualReal ADReal; +#if METAPHYSICL_MAJOR_VERSION < 1 +namespace MetaPhysicL +{ +template +class DualNumber; +} +#else +#include "metaphysicl/dualnumber_forward.h" +#endif + +namespace MetaPhysicL +{ +template +class SemiDynamicSparseNumberArray; +template +struct NWrapper; +} + +using libMesh::Real; +using MetaPhysicL::DualNumber; +using MetaPhysicL::NWrapper; +using MetaPhysicL::SemiDynamicSparseNumberArray; + +typedef SemiDynamicSparseNumberArray> + DNDerivativeType; + +template +using DNDerivativeSize = SemiDynamicSparseNumberArray>; + +typedef DualNumber ADReal; diff --git a/framework/include/utils/ColumnMajorMatrix.h b/framework/include/utils/ColumnMajorMatrix.h index 6650e7e18560..75f2f75288a9 100644 --- a/framework/include/utils/ColumnMajorMatrix.h +++ b/framework/include/utils/ColumnMajorMatrix.h @@ -12,7 +12,7 @@ #include "DenseMatrix.h" #include "Moose.h" // using namespace libMesh #include "MooseError.h" -#include "DualReal.h" +#include "ADReal.h" #include "MooseTypes.h" #include "libmesh/type_tensor.h" diff --git a/framework/include/utils/DenseMatrix.h b/framework/include/utils/DenseMatrix.h index 7b018180e8bd..dbb6638fdaf9 100644 --- a/framework/include/utils/DenseMatrix.h +++ b/framework/include/utils/DenseMatrix.h @@ -9,12 +9,11 @@ #pragma once +#include "ADReal.h" #include "libmesh/dense_matrix.h" -#include "DualRealOps.h" - namespace libMesh { template <> -DenseMatrix::DenseMatrix(const unsigned int new_m, const unsigned int new_n); +DenseMatrix::DenseMatrix(const unsigned int new_m, const unsigned int new_n); } diff --git a/framework/include/utils/DualReal.h b/framework/include/utils/DualReal.h deleted file mode 100644 index 8862e8485f90..000000000000 --- a/framework/include/utils/DualReal.h +++ /dev/null @@ -1,49 +0,0 @@ -//* 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 "MooseConfig.h" - -#include "libmesh/libmesh_common.h" -#include "libmesh/compare_types.h" - -#include "metaphysicl/metaphysicl_version.h" - -namespace MetaPhysicL -{ -#if METAPHYSICL_MAJOR_VERSION < 1 -template -class DualNumber; -#else -#include "metaphysicl/dualnumber_forward.h" -#endif -template -class SemiDynamicSparseNumberArray; -template -class NumberArray; -template -struct NWrapper; -} - -using libMesh::Real; -using MetaPhysicL::DualNumber; -using MetaPhysicL::NumberArray; -using MetaPhysicL::NWrapper; -using MetaPhysicL::SemiDynamicSparseNumberArray; - -typedef SemiDynamicSparseNumberArray> - DNDerivativeType; - -template -using DNDerivativeSize = SemiDynamicSparseNumberArray>; - -typedef DualNumber DualReal; diff --git a/framework/include/utils/DualRealOps.h b/framework/include/utils/DualRealOps.h deleted file mode 100644 index 01a4f4505f85..000000000000 --- a/framework/include/utils/DualRealOps.h +++ /dev/null @@ -1,14 +0,0 @@ -//* 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 "MooseConfig.h" -#include "DualReal.h" -#include "SparseOps.h" diff --git a/framework/include/utils/MooseTypes.h b/framework/include/utils/MooseTypes.h index dcd1ba3e26de..dc48650182ee 100644 --- a/framework/include/utils/MooseTypes.h +++ b/framework/include/utils/MooseTypes.h @@ -364,7 +364,7 @@ typedef MooseArray ADVariableGradient; typedef MooseArray ADVariableSecond; typedef MooseArray ADVectorVariableValue; typedef MooseArray ADVectorVariableGradient; -typedef MooseArray> ADVectorVariableSecond; +typedef MooseArray> ADVectorVariableSecond; namespace Moose { @@ -507,9 +507,9 @@ constexpr std::false_type always_false{}; /** * some AD typedefs for backwards compatability */ -typedef ADRealVectorValue DualRealVectorValue; -typedef ADRealTensorValue DualRealTensorValue; -typedef ADRealGradient DualRealGradient; +typedef ADRealVectorValue ADRealVectorValue; +typedef ADRealTensorValue ADRealTensorValue; +typedef ADRealGradient ADRealGradient; template using ADTemplateVariableValue = diff --git a/framework/include/utils/MooseUtils.h b/framework/include/utils/MooseUtils.h index 1b66f65ce18c..5a005a0bea8c 100644 --- a/framework/include/utils/MooseUtils.h +++ b/framework/include/utils/MooseUtils.h @@ -1004,7 +1004,7 @@ struct IsLikeReal static constexpr bool value = true; }; template <> -struct IsLikeReal +struct IsLikeReal { static constexpr bool value = true; }; diff --git a/framework/include/utils/MultiDimensionalInterpolation.h b/framework/include/utils/MultiDimensionalInterpolation.h index b6222dbfc68b..170615527a9d 100644 --- a/framework/include/utils/MultiDimensionalInterpolation.h +++ b/framework/include/utils/MultiDimensionalInterpolation.h @@ -11,7 +11,7 @@ #include "Moose.h" #include "MooseTypes.h" -#include "DualReal.h" +#include "ADReal.h" #include "MultiIndex.h" #include #include @@ -84,5 +84,5 @@ class MultiDimensionalInterpolationTempl }; typedef MultiDimensionalInterpolationTempl MultiDimensionalInterpolation; -typedef MultiDimensionalInterpolationTempl DualMultiDimensionalInterpolation; +typedef MultiDimensionalInterpolationTempl DualMultiDimensionalInterpolation; typedef DualMultiDimensionalInterpolation ADMultiDimensionalInterpolation; diff --git a/framework/include/utils/SparseOps.h b/framework/include/utils/SparseOps.h deleted file mode 100644 index 36a02b050d84..000000000000 --- a/framework/include/utils/SparseOps.h +++ /dev/null @@ -1,39 +0,0 @@ -//* 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 "MooseError.h" -#include "metaphysicl/dualsemidynamicsparsenumberarray.h" -#include "metaphysicl/metaphysicl_exceptions.h" - -namespace Moose -{ -template -inline void -derivInsert(SemiDynamicSparseNumberArray> & derivs, - libMesh::dof_id_type index, - Real value) -{ -#ifndef NDEBUG - try - { - derivs.insert(index) = value; - } - catch (MetaPhysicL::LogicError &) - { - mooseError("The last insertion into the sparse derivative storage container exceeded the " - "underlying array size. Consider running `configure --with-derivative-size=` to " - "obtain a larger underlying container"); - } -#else - derivs.insert(index) = value; -#endif -} -} diff --git a/framework/include/utils_nonunity/ADRankFourTensorForward.h b/framework/include/utils_nonunity/ADRankFourTensorForward.h index b4a8b988527b..2295425edb1f 100644 --- a/framework/include/utils_nonunity/ADRankFourTensorForward.h +++ b/framework/include/utils_nonunity/ADRankFourTensorForward.h @@ -15,4 +15,4 @@ typedef RankFourTensorTempl ADRankFourTensor; // for backward compatibility -typedef RankFourTensorTempl DualRankFourTensor; +typedef RankFourTensorTempl DualRankFourTensor; diff --git a/framework/include/utils_nonunity/ADRankThreeTensorForward.h b/framework/include/utils_nonunity/ADRankThreeTensorForward.h index 967d4de0aedc..96176e97cefc 100644 --- a/framework/include/utils_nonunity/ADRankThreeTensorForward.h +++ b/framework/include/utils_nonunity/ADRankThreeTensorForward.h @@ -15,4 +15,4 @@ typedef RankThreeTensorTempl ADRankThreeTensor; // for backward compatibility -typedef RankThreeTensorTempl DualRankThreeTensor; +typedef RankThreeTensorTempl DualRankThreeTensor; diff --git a/framework/include/utils_nonunity/ADRankTwoTensorForward.h b/framework/include/utils_nonunity/ADRankTwoTensorForward.h index 59a2344b6945..ce1f1c9d83b5 100644 --- a/framework/include/utils_nonunity/ADRankTwoTensorForward.h +++ b/framework/include/utils_nonunity/ADRankTwoTensorForward.h @@ -15,4 +15,4 @@ typedef RankTwoTensorTempl ADRankTwoTensor; // for backward compatibility -typedef RankTwoTensorTempl DualRankTwoTensor; +typedef RankTwoTensorTempl DualRankTwoTensor; diff --git a/framework/include/utils_nonunity/RankFourTensorImplementation.h b/framework/include/utils_nonunity/RankFourTensorImplementation.h index a67c77361771..4423349ffc41 100644 --- a/framework/include/utils_nonunity/RankFourTensorImplementation.h +++ b/framework/include/utils_nonunity/RankFourTensorImplementation.h @@ -34,7 +34,7 @@ namespace MathUtils template <> void mooseSetToZero>(RankFourTensorTempl & v); template <> -void mooseSetToZero>(RankFourTensorTempl & v); +void mooseSetToZero>(RankFourTensorTempl & v); } template diff --git a/framework/include/utils_nonunity/RankThreeTensor.h b/framework/include/utils_nonunity/RankThreeTensor.h index 5434b6f0c176..a826e840507d 100644 --- a/framework/include/utils_nonunity/RankThreeTensor.h +++ b/framework/include/utils_nonunity/RankThreeTensor.h @@ -45,7 +45,7 @@ void mooseSetToZero(T & v); template <> void mooseSetToZero>(RankThreeTensorTempl & v); template <> -void mooseSetToZero>(RankThreeTensorTempl & v); +void mooseSetToZero>(RankThreeTensorTempl & v); } /** diff --git a/framework/include/utils_nonunity/RankTwoTensor.h b/framework/include/utils_nonunity/RankTwoTensor.h index 2e7dd558bf75..de9f0ee7a6ce 100644 --- a/framework/include/utils_nonunity/RankTwoTensor.h +++ b/framework/include/utils_nonunity/RankTwoTensor.h @@ -141,7 +141,7 @@ class RankTwoTensorTempl : public libMesh::TensorValue void printReal(std::ostream & stm = Moose::out) const; /// Print the Real part of the RankTwoTensorTempl along with its first nDual dual numbers - void printDualReal(unsigned int nDual, std::ostream & stm = Moose::out) const; + void printADReal(unsigned int nDual, std::ostream & stm = Moose::out) const; /// @} diff --git a/framework/include/utils_nonunity/RankTwoTensorImplementation.h b/framework/include/utils_nonunity/RankTwoTensorImplementation.h index b63f42cccd7b..0d87b4b4b21f 100644 --- a/framework/include/utils_nonunity/RankTwoTensorImplementation.h +++ b/framework/include/utils_nonunity/RankTwoTensorImplementation.h @@ -749,7 +749,7 @@ ADRankTwoTensor::printReal(std::ostream & stm) const template <> void -ADRankTwoTensor::printDualReal(unsigned int nDual, std::ostream & stm) const +ADRankTwoTensor::printADReal(unsigned int nDual, std::ostream & stm) const { const ADRankTwoTensor & a = *this; for (const auto i : make_range(N)) diff --git a/framework/include/utils_nonunity/SymmetricRankFourTensorImplementation.h b/framework/include/utils_nonunity/SymmetricRankFourTensorImplementation.h index c9c32eb27139..0ed01a4d762a 100644 --- a/framework/include/utils_nonunity/SymmetricRankFourTensorImplementation.h +++ b/framework/include/utils_nonunity/SymmetricRankFourTensorImplementation.h @@ -31,8 +31,7 @@ namespace MathUtils template <> void mooseSetToZero>(SymmetricRankFourTensorTempl & v); template <> -void -mooseSetToZero>(SymmetricRankFourTensorTempl & v); +void mooseSetToZero>(SymmetricRankFourTensorTempl & v); } template diff --git a/framework/include/utils_nonunity/SymmetricRankTwoTensor.h b/framework/include/utils_nonunity/SymmetricRankTwoTensor.h index f480f449a3ee..a89071b2449a 100644 --- a/framework/include/utils_nonunity/SymmetricRankTwoTensor.h +++ b/framework/include/utils_nonunity/SymmetricRankTwoTensor.h @@ -409,11 +409,11 @@ class SymmetricRankTwoTensorTempl /// Print the rank two tensor void print(std::ostream & stm = Moose::out) const; - /// Print the Real part of the DualReal rank two tensor + /// Print the Real part of the ADReal rank two tensor void printReal(std::ostream & stm = Moose::out) const; - /// Print the Real part of the DualReal rank two tensor along with its first nDual dual numbers - void printDualReal(unsigned int nDual, std::ostream & stm = Moose::out) const; + /// Print the Real part of the ADReal rank two tensor along with its first nDual dual numbers + void printADReal(unsigned int nDual, std::ostream & stm = Moose::out) const; /// Add identity times a to _vals void addIa(const T & a); diff --git a/framework/include/variables/MooseVariableData.h b/framework/include/variables/MooseVariableData.h index a4c929d9060b..60478194d3ee 100644 --- a/framework/include/variables/MooseVariableData.h +++ b/framework/include/variables/MooseVariableData.h @@ -452,7 +452,7 @@ class MooseVariableData : public MooseVariableDataBase * values as they're referred to here in this class). These methods are only truly meaningful * for nodal basis families */ - void assignADNodalValue(const DualReal & value, const unsigned int & component); + void assignADNodalValue(const ADReal & value, const unsigned int & component); void fetchADDoFValues(); const FEType & _fe_type; @@ -480,7 +480,7 @@ class MooseVariableData : public MooseVariableDataBase typename Moose::ADType::type _ad_nodal_value; /// A zero AD variable - DualReal _ad_zero; + ADReal _ad_zero; /// AD u dot flags mutable bool _need_ad_u_dot; diff --git a/framework/include/variables/MooseVariableDataFV.h b/framework/include/variables/MooseVariableDataFV.h index c2ed66f2b188..83bce9314717 100644 --- a/framework/include/variables/MooseVariableDataFV.h +++ b/framework/include/variables/MooseVariableDataFV.h @@ -22,7 +22,6 @@ #include "libmesh/fe_type.h" #include "libmesh/dof_map.h" #include "libmesh/enum_fe_family.h" -#include "DualRealOps.h" #include "SubProblem.h" #include @@ -315,7 +314,7 @@ class MooseVariableDataFV : public MooseVariableDataBase, public Mes FieldVariableValue _increment; /// A zero AD variable - const DualReal _ad_zero; + const ADReal _ad_zero; /// SolutionState second_u flags mutable bool _need_second; @@ -356,9 +355,9 @@ class MooseVariableDataFV : public MooseVariableDataBase, public Mes ADTemplateVariableValue _ad_u; ADTemplateVariableGradient _ad_grad_u; ADTemplateVariableSecond _ad_second_u; - MooseArray _ad_dof_values; - MooseArray _ad_dofs_dot; - MooseArray _ad_dofs_dotdot; + MooseArray _ad_dof_values; + MooseArray _ad_dofs_dot; + MooseArray _ad_dofs_dotdot; ADTemplateVariableValue _ad_u_dot; ADTemplateVariableValue _ad_u_dotdot; ADTemplateVariableGradient _ad_grad_u_dot; diff --git a/framework/include/variables/MooseVariableDataLinearFV.h b/framework/include/variables/MooseVariableDataLinearFV.h index ddb848a7bc13..7e7bbff67acc 100644 --- a/framework/include/variables/MooseVariableDataLinearFV.h +++ b/framework/include/variables/MooseVariableDataLinearFV.h @@ -22,7 +22,6 @@ #include "libmesh/fe_type.h" #include "libmesh/dof_map.h" #include "libmesh/enum_fe_family.h" -#include "DualRealOps.h" #include "SubProblem.h" #include "MooseVariableDataFV.h" diff --git a/framework/src/base/Assembly.C b/framework/src/base/Assembly.C index 1a80c47a1eeb..95d079cc035f 100644 --- a/framework/src/base/Assembly.C +++ b/framework/src/base/Assembly.C @@ -1069,7 +1069,7 @@ Assembly::computeSinglePointMapAD(const Elem * elem, { libmesh_assert(elem_nodes[i]); const Node & node = *elem_nodes[i]; - libMesh::VectorValue elem_point = node; + libMesh::VectorValue elem_point = node; if (do_derivatives) for (const auto & [disp_num, direction] : _disp_numbers_and_directions) if (node.n_dofs(sys_num, disp_num)) @@ -1119,7 +1119,7 @@ Assembly::computeSinglePointMapAD(const Elem * elem, { libmesh_assert(elem_nodes[i]); const Node & node = *elem_nodes[i]; - libMesh::VectorValue elem_point = node; + libMesh::VectorValue elem_point = node; if (do_derivatives) for (const auto & [disp_num, direction] : _disp_numbers_and_directions) Moose::derivInsert( @@ -1195,7 +1195,7 @@ Assembly::computeSinglePointMapAD(const Elem * elem, { libmesh_assert(elem_nodes[i]); const Node & node = *elem_nodes[i]; - libMesh::VectorValue elem_point = node; + libMesh::VectorValue elem_point = node; if (do_derivatives) for (const auto & [disp_num, direction] : _disp_numbers_and_directions) Moose::derivInsert( @@ -1377,7 +1377,7 @@ Assembly::computeFaceMap(const Elem & elem, const unsigned int side, const std:: else _ad_normals[0] = Point(1.); - VectorValue side_point; + VectorValue side_point; if (_calculate_face_xyz) { const Node & node = side_elem.node_ref(0); @@ -1425,7 +1425,7 @@ Assembly::computeFaceMap(const Elem & elem, const unsigned int side, const std:: for (unsigned int i = 0; i < n_mapping_shape_functions; i++) { const Node & node = side_elem.node_ref(i); - VectorValue side_point = node; + VectorValue side_point = node; if (do_derivatives) for (const auto & [disp_num, direction] : _disp_numbers_and_directions) @@ -1445,7 +1445,7 @@ Assembly::computeFaceMap(const Elem & elem, const unsigned int side, const std:: for (unsigned int p = 0; p < n_qp; p++) { _ad_normals[p] = - (VectorValue(_ad_dxyzdxi_map[p](1), -_ad_dxyzdxi_map[p](0), 0.)).unit(); + (VectorValue(_ad_dxyzdxi_map[p](1), -_ad_dxyzdxi_map[p](0), 0.)).unit(); const auto the_jac = _ad_dxyzdxi_map[p].norm(); _ad_JxW_face[p] = the_jac * qw[p]; if (_calculate_curvatures) @@ -1491,7 +1491,7 @@ Assembly::computeFaceMap(const Elem & elem, const unsigned int side, const std:: for (unsigned int i = 0; i < n_mapping_shape_functions; i++) { const Node & node = side_elem.node_ref(i); - VectorValue side_point = node; + VectorValue side_point = node; if (do_derivatives) for (const auto & [disp_num, direction] : _disp_numbers_and_directions) diff --git a/framework/src/constraints/ADMortarConstraint.C b/framework/src/constraints/ADMortarConstraint.C index 88bf1b144db4..cfe0c59f3f5e 100644 --- a/framework/src/constraints/ADMortarConstraint.C +++ b/framework/src/constraints/ADMortarConstraint.C @@ -67,7 +67,7 @@ ADMortarConstraint::computeResidual(Moose::MortarType mortar_type) void ADMortarConstraint::computeJacobian(Moose::MortarType mortar_type) { - std::vector residuals; + std::vector residuals; std::size_t test_space_size = 0; typedef Moose::ConstraintJacobianType JType; typedef Moose::MortarType MType; diff --git a/framework/src/restart/DataIO.C b/framework/src/restart/DataIO.C index 845479806621..446d805900f4 100644 --- a/framework/src/restart/DataIO.C +++ b/framework/src/restart/DataIO.C @@ -21,8 +21,6 @@ #include "libmesh/petsc_vector.h" #include "libmesh/enum_solver_package.h" -#include "DualRealOps.h" - template <> void dataStore(std::ostream & stream, Real & v, void * /*context*/) @@ -88,11 +86,11 @@ dataStore(std::ostream & stream, RankFourTensor & rft, void * context) template <> void -dataStore(std::ostream & stream, DualReal & dn, void * context) +dataStore(std::ostream & stream, ADReal & dn, void * context) { dataStore(stream, dn.value(), context); - if (DualReal::do_derivatives) + if (ADReal::do_derivatives) { auto & derivatives = dn.derivatives(); std::size_t size = derivatives.size(); @@ -227,7 +225,7 @@ dataStore(std::ostream & stream, TensorValue & v, void * context) } template void dataStore(std::ostream & stream, TensorValue & v, void * context); -template void dataStore(std::ostream & stream, TensorValue & v, void * context); +template void dataStore(std::ostream & stream, TensorValue & v, void * context); template void @@ -246,7 +244,7 @@ dataStore(std::ostream & stream, DenseMatrix & v, void * context) } template void dataStore(std::ostream & stream, DenseMatrix & v, void * context); -template void dataStore(std::ostream & stream, DenseMatrix & v, void * context); +template void dataStore(std::ostream & stream, DenseMatrix & v, void * context); template void @@ -262,7 +260,7 @@ dataStore(std::ostream & stream, VectorValue & v, void * context) } template void dataStore(std::ostream & stream, VectorValue & v, void * context); -template void dataStore(std::ostream & stream, VectorValue & v, void * context); +template void dataStore(std::ostream & stream, VectorValue & v, void * context); void dataStore(std::ostream & stream, Point & p, void * context) @@ -399,11 +397,11 @@ dataLoad(std::istream & stream, std::vector & v, void * context) template <> void -dataLoad(std::istream & stream, DualReal & dn, void * context) +dataLoad(std::istream & stream, ADReal & dn, void * context) { dataLoad(stream, dn.value(), context); - if (DualReal::do_derivatives) + if (ADReal::do_derivatives) { auto & derivatives = dn.derivatives(); std::size_t size = 0; @@ -562,7 +560,7 @@ dataLoad(std::istream & stream, TensorValue & v, void * context) } template void dataLoad(std::istream & stream, TensorValue & v, void * context); -template void dataLoad(std::istream & stream, TensorValue & v, void * context); +template void dataLoad(std::istream & stream, TensorValue & v, void * context); template void @@ -582,7 +580,7 @@ dataLoad(std::istream & stream, DenseMatrix & v, void * context) } template void dataLoad(std::istream & stream, DenseMatrix & v, void * context); -template void dataLoad(std::istream & stream, DenseMatrix & v, void * context); +template void dataLoad(std::istream & stream, DenseMatrix & v, void * context); template void @@ -599,7 +597,7 @@ dataLoad(std::istream & stream, VectorValue & v, void * context) } template void dataLoad(std::istream & stream, VectorValue & v, void * context); -template void dataLoad(std::istream & stream, VectorValue & v, void * context); +template void dataLoad(std::istream & stream, VectorValue & v, void * context); void dataLoad(std::istream & stream, Point & p, void * context) diff --git a/framework/src/timeintegrators/AStableDirk4.C b/framework/src/timeintegrators/AStableDirk4.C index a180d3ea0052..5e6cd0af00cd 100644 --- a/framework/src/timeintegrators/AStableDirk4.C +++ b/framework/src/timeintegrators/AStableDirk4.C @@ -96,9 +96,9 @@ AStableDirk4::computeTimeDerivatives() } void -AStableDirk4::computeADTimeDerivatives(DualReal & ad_u_dot, +AStableDirk4::computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & /*ad_u_dotdot*/) const + ADReal & /*ad_u_dotdot*/) const { computeTimeDerivativeHelper(ad_u_dot, _solution_old(dof)); } diff --git a/framework/src/timeintegrators/ActuallyExplicitEuler.C b/framework/src/timeintegrators/ActuallyExplicitEuler.C index 34bb49f7cc91..0d3f332a16e4 100644 --- a/framework/src/timeintegrators/ActuallyExplicitEuler.C +++ b/framework/src/timeintegrators/ActuallyExplicitEuler.C @@ -54,9 +54,9 @@ ActuallyExplicitEuler::computeTimeDerivatives() } void -ActuallyExplicitEuler::computeADTimeDerivatives(DualReal & ad_u_dot, +ActuallyExplicitEuler::computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & /*ad_u_dotdot*/) const + ADReal & /*ad_u_dotdot*/) const { computeTimeDerivativeHelper(ad_u_dot, _solution_old(dof)); } diff --git a/framework/src/timeintegrators/BDF2.C b/framework/src/timeintegrators/BDF2.C index b32cdb1e1ae4..416961d7f432 100644 --- a/framework/src/timeintegrators/BDF2.C +++ b/framework/src/timeintegrators/BDF2.C @@ -64,9 +64,9 @@ BDF2::computeTimeDerivatives() } void -BDF2::computeADTimeDerivatives(DualReal & ad_u_dot, +BDF2::computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & /*ad_u_dotdot*/) const + ADReal & /*ad_u_dotdot*/) const { auto ad_sln = ad_u_dot; if (_t_step != 1) diff --git a/framework/src/timeintegrators/CentralDifference.C b/framework/src/timeintegrators/CentralDifference.C index a6090e98e209..a3cfb30eff89 100644 --- a/framework/src/timeintegrators/CentralDifference.C +++ b/framework/src/timeintegrators/CentralDifference.C @@ -42,9 +42,9 @@ CentralDifference::CentralDifference(const InputParameters & parameters) } void -CentralDifference::computeADTimeDerivatives(DualReal & ad_u_dot, +CentralDifference::computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & ad_u_dotdot) const + ADReal & ad_u_dotdot) const { computeTimeDerivativeHelper(ad_u_dot, ad_u_dotdot, _solution_old(dof), _solution_older(dof)); } diff --git a/framework/src/timeintegrators/CrankNicolson.C b/framework/src/timeintegrators/CrankNicolson.C index d1df8378c6ed..3126bf136bdd 100644 --- a/framework/src/timeintegrators/CrankNicolson.C +++ b/framework/src/timeintegrators/CrankNicolson.C @@ -42,9 +42,9 @@ CrankNicolson::computeTimeDerivatives() } void -CrankNicolson::computeADTimeDerivatives(DualReal & ad_u_dot, +CrankNicolson::computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & /*ad_u_dotdot*/) const + ADReal & /*ad_u_dotdot*/) const { computeTimeDerivativeHelper(ad_u_dot, _solution_old(dof)); } diff --git a/framework/src/timeintegrators/ExplicitEuler.C b/framework/src/timeintegrators/ExplicitEuler.C index 324f8016a1c8..1639be7cc1ad 100644 --- a/framework/src/timeintegrators/ExplicitEuler.C +++ b/framework/src/timeintegrators/ExplicitEuler.C @@ -48,9 +48,9 @@ ExplicitEuler::computeTimeDerivatives() } void -ExplicitEuler::computeADTimeDerivatives(DualReal & ad_u_dot, +ExplicitEuler::computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & /*ad_u_dotdot*/) const + ADReal & /*ad_u_dotdot*/) const { computeTimeDerivativeHelper(ad_u_dot, _solution_old(dof)); } diff --git a/framework/src/timeintegrators/ExplicitRK2.C b/framework/src/timeintegrators/ExplicitRK2.C index 4fab7a327690..8f8d95889463 100644 --- a/framework/src/timeintegrators/ExplicitRK2.C +++ b/framework/src/timeintegrators/ExplicitRK2.C @@ -59,9 +59,9 @@ ExplicitRK2::computeTimeDerivatives() } void -ExplicitRK2::computeADTimeDerivatives(DualReal & ad_u_dot, +ExplicitRK2::computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & /*ad_u_dotdot*/) const + ADReal & /*ad_u_dotdot*/) const { computeTimeDerivativeHelper(ad_u_dot, _solution_old(dof), _solution_older(dof)); } diff --git a/framework/src/timeintegrators/ExplicitSSPRungeKutta.C b/framework/src/timeintegrators/ExplicitSSPRungeKutta.C index 45ecd23ef490..9e1b54196188 100644 --- a/framework/src/timeintegrators/ExplicitSSPRungeKutta.C +++ b/framework/src/timeintegrators/ExplicitSSPRungeKutta.C @@ -75,7 +75,7 @@ ExplicitSSPRungeKutta::computeTimeDerivatives() void ExplicitSSPRungeKutta::computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & /*ad_u_dotdot*/) const + ADReal & /*ad_u_dotdot*/) const { // Note that if the solution for the current stage is not a nullptr, then neither // are the previous stages. diff --git a/framework/src/timeintegrators/ExplicitTVDRK2.C b/framework/src/timeintegrators/ExplicitTVDRK2.C index 6b4b6ddfae3a..1a625c6d904b 100644 --- a/framework/src/timeintegrators/ExplicitTVDRK2.C +++ b/framework/src/timeintegrators/ExplicitTVDRK2.C @@ -61,9 +61,9 @@ ExplicitTVDRK2::computeTimeDerivatives() } void -ExplicitTVDRK2::computeADTimeDerivatives(DualReal & ad_u_dot, +ExplicitTVDRK2::computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & /*ad_u_dotdot*/) const + ADReal & /*ad_u_dotdot*/) const { computeTimeDerivativeHelper(ad_u_dot, _solution_old(dof), _solution_older(dof)); } diff --git a/framework/src/timeintegrators/ImplicitEuler.C b/framework/src/timeintegrators/ImplicitEuler.C index 18ea8775b8b6..0cc7df9a456b 100644 --- a/framework/src/timeintegrators/ImplicitEuler.C +++ b/framework/src/timeintegrators/ImplicitEuler.C @@ -40,9 +40,9 @@ ImplicitEuler::computeTimeDerivatives() } void -ImplicitEuler::computeADTimeDerivatives(DualReal & ad_u_dot, +ImplicitEuler::computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & /*ad_u_dotdot*/) const + ADReal & /*ad_u_dotdot*/) const { computeTimeDerivativeHelper(ad_u_dot, _solution_old(dof)); } diff --git a/framework/src/timeintegrators/ImplicitMidpoint.C b/framework/src/timeintegrators/ImplicitMidpoint.C index b1d9a9c32ca4..7d7daa654ebe 100644 --- a/framework/src/timeintegrators/ImplicitMidpoint.C +++ b/framework/src/timeintegrators/ImplicitMidpoint.C @@ -49,9 +49,9 @@ ImplicitMidpoint::computeTimeDerivatives() } void -ImplicitMidpoint::computeADTimeDerivatives(DualReal & ad_u_dot, +ImplicitMidpoint::computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & /*ad_u_dotdot*/) const + ADReal & /*ad_u_dotdot*/) const { computeTimeDerivativeHelper(ad_u_dot, _solution_old(dof)); } diff --git a/framework/src/timeintegrators/LStableDirk2.C b/framework/src/timeintegrators/LStableDirk2.C index c438a5f035af..5904203e5ea2 100644 --- a/framework/src/timeintegrators/LStableDirk2.C +++ b/framework/src/timeintegrators/LStableDirk2.C @@ -52,9 +52,9 @@ LStableDirk2::computeTimeDerivatives() } void -LStableDirk2::computeADTimeDerivatives(DualReal & ad_u_dot, +LStableDirk2::computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & /*ad_u_dotdot*/) const + ADReal & /*ad_u_dotdot*/) const { computeTimeDerivativeHelper(ad_u_dot, _solution_old(dof)); } diff --git a/framework/src/timeintegrators/LStableDirk3.C b/framework/src/timeintegrators/LStableDirk3.C index b125b75fe789..9fec25a0deca 100644 --- a/framework/src/timeintegrators/LStableDirk3.C +++ b/framework/src/timeintegrators/LStableDirk3.C @@ -71,9 +71,9 @@ LStableDirk3::computeTimeDerivatives() } void -LStableDirk3::computeADTimeDerivatives(DualReal & ad_u_dot, +LStableDirk3::computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & /*ad_u_dotdot*/) const + ADReal & /*ad_u_dotdot*/) const { computeTimeDerivativeHelper(ad_u_dot, _solution_old(dof)); } diff --git a/framework/src/timeintegrators/LStableDirk4.C b/framework/src/timeintegrators/LStableDirk4.C index 870cb5a5f149..f144ced1ee8b 100644 --- a/framework/src/timeintegrators/LStableDirk4.C +++ b/framework/src/timeintegrators/LStableDirk4.C @@ -66,9 +66,9 @@ LStableDirk4::computeTimeDerivatives() } void -LStableDirk4::computeADTimeDerivatives(DualReal & ad_u_dot, +LStableDirk4::computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & /*ad_u_dotdot*/) const + ADReal & /*ad_u_dotdot*/) const { computeTimeDerivativeHelper(ad_u_dot, _solution_old(dof)); } diff --git a/framework/src/timeintegrators/NewmarkBeta.C b/framework/src/timeintegrators/NewmarkBeta.C index 6126f9e1145d..4fa100cbdef1 100644 --- a/framework/src/timeintegrators/NewmarkBeta.C +++ b/framework/src/timeintegrators/NewmarkBeta.C @@ -96,9 +96,9 @@ NewmarkBeta::computeTimeDerivatives() } void -NewmarkBeta::computeADTimeDerivatives(DualReal & ad_u_dot, +NewmarkBeta::computeADTimeDerivatives(ADReal & ad_u_dot, const dof_id_type & dof, - DualReal & ad_u_dotdot) const + ADReal & ad_u_dotdot) const { const auto & u_old = _solution_old(dof); const auto & u_dot_old = (*_sys.solutionUDotOld())(dof); diff --git a/framework/src/utils/ColumnMajorMatrix.C b/framework/src/utils/ColumnMajorMatrix.C index 972e65845c85..809c41efd56f 100644 --- a/framework/src/utils/ColumnMajorMatrix.C +++ b/framework/src/utils/ColumnMajorMatrix.C @@ -10,8 +10,6 @@ // MOOSE includes #include "ColumnMajorMatrix.h" -#include "DualRealOps.h" - #include "libmesh/petsc_macro.h" // PETSc includes @@ -165,8 +163,8 @@ ColumnMajorMatrixTempl::eigen(ColumnMajorMatrixTempl & eval, template <> void -ColumnMajorMatrixTempl::eigen(ColumnMajorMatrixTempl &, - ColumnMajorMatrixTempl &) const +ColumnMajorMatrixTempl::eigen(ColumnMajorMatrixTempl &, + ColumnMajorMatrixTempl &) const { mooseError("Eigen solves with AD types is not supported."); } @@ -227,10 +225,10 @@ ColumnMajorMatrixTempl::eigenNonsym(ColumnMajorMatrixTempl & eval_real, template <> void -ColumnMajorMatrixTempl::eigenNonsym(ColumnMajorMatrixTempl &, - ColumnMajorMatrixTempl &, - ColumnMajorMatrixTempl &, - ColumnMajorMatrixTempl &) const +ColumnMajorMatrixTempl::eigenNonsym(ColumnMajorMatrixTempl &, + ColumnMajorMatrixTempl &, + ColumnMajorMatrixTempl &, + ColumnMajorMatrixTempl &) const { mooseError("Eigen solves with AD types is not supported."); } @@ -302,7 +300,7 @@ ColumnMajorMatrixTempl::checkShapeEquality(const ColumnMajorMatrixTempl & template <> void -ColumnMajorMatrixTempl::inverse(ColumnMajorMatrixTempl &) const +ColumnMajorMatrixTempl::inverse(ColumnMajorMatrixTempl &) const { mooseError("Inverse solves with AD types is not supported for the ColumnMajorMatrix class."); } @@ -330,4 +328,4 @@ ColumnMajorMatrixTempl::norm() } template class ColumnMajorMatrixTempl; -template class ColumnMajorMatrixTempl; +template class ColumnMajorMatrixTempl; diff --git a/framework/src/utils/DenseMatrixADReal.C b/framework/src/utils/DenseMatrixADReal.C new file mode 100644 index 000000000000..9ab5a0699a1a --- /dev/null +++ b/framework/src/utils/DenseMatrixADReal.C @@ -0,0 +1,113 @@ +//* 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 + +#include "DenseMatrix.h" +#include "ADReal.h" +#include "MooseError.h" + +#include "libmesh/dense_matrix_base_impl.h" +#include "libmesh/dense_matrix_impl.h" + +namespace libMesh +{ +template <> +void +DenseMatrix::_multiply_blas(const DenseMatrixBase &, _BLAS_Multiply_Flag) +{ + mooseError("No blas/lapack support for type ", demangle(typeid(ADReal).name())); +} + +template <> +void +DenseMatrix::_lu_decompose_lapack() +{ + mooseError("No blas/lapack support for type ", demangle(typeid(ADReal).name())); +} + +template <> +void +DenseMatrix::_svd_lapack(DenseVector &) +{ + mooseError("No blas/lapack support for type ", demangle(typeid(ADReal).name())); +} + +template <> +void +DenseMatrix::_svd_lapack(DenseVector &, DenseMatrix &, DenseMatrix &) +{ + mooseError("No blas/lapack support for type ", demangle(typeid(ADReal).name())); +} + +template <> +void +DenseMatrix::_svd_helper( + char, char, std::vector &, std::vector &, std::vector &) +{ + mooseError("No blas/lapack support for type ", demangle(typeid(ADReal).name())); +} + +template <> +void +DenseMatrix::_svd_solve_lapack(const DenseVector & /*rhs*/, + DenseVector & /*x*/, + Real /*rcond*/) const +{ + mooseError("No blas/lapack support for type ", demangle(typeid(ADReal).name())); +} + +template <> +void +DenseMatrix::_evd_lapack(DenseVector &, + DenseVector &, + DenseMatrix *, + DenseMatrix *) +{ + mooseError("No blas/lapack support for type ", demangle(typeid(ADReal).name())); +} + +template <> +void +DenseMatrix::_lu_back_substitute_lapack(const DenseVector &, DenseVector &) +{ + mooseError("No blas/lapack support for type ", demangle(typeid(ADReal).name())); +} + +template <> +void +DenseMatrix::_matvec_blas( + ADReal, ADReal, DenseVector &, const DenseVector &, bool) const +{ + mooseError("No blas/lapack support for type ", demangle(typeid(ADReal).name())); +} + +template <> +DenseMatrix::DenseMatrix(const unsigned int new_m, const unsigned int new_n) + : DenseMatrixBase(new_m, new_n), use_blas_lapack(false), _val(), _decomposition_type(NONE) +{ + this->resize(new_m, new_n); +} + +template class DenseMatrixBase; +template class DenseMatrix; + +template void DenseMatrix::vector_mult_add(DenseVector &, + const int, + const DenseVector &) const; +template void DenseMatrix::vector_mult_add(DenseVector &, + const double, + const DenseVector &) const; + +template void DenseMatrix::vector_mult(DenseVector &, + const DenseVector &) const; +template void DenseMatrix::vector_mult(DenseVector &, + const DenseVector &) const; + +template void DenseMatrix::cholesky_solve(const DenseVector & b, + DenseVector & x); +} diff --git a/framework/src/utils/DenseMatrixDualReal.C b/framework/src/utils/DenseMatrixDualReal.C deleted file mode 100644 index abb554c99727..000000000000 --- a/framework/src/utils/DenseMatrixDualReal.C +++ /dev/null @@ -1,121 +0,0 @@ -//* 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 - -#include "DenseMatrix.h" -#include "DualReal.h" -#include "MooseError.h" - -#include "libmesh/dense_matrix_base_impl.h" -#include "libmesh/dense_matrix_impl.h" - -#include "DualRealOps.h" - -namespace libMesh -{ -template <> -void -DenseMatrix::_multiply_blas(const DenseMatrixBase &, _BLAS_Multiply_Flag) -{ - mooseError("No blas/lapack support for type ", demangle(typeid(DualReal).name())); -} - -template <> -void -DenseMatrix::_lu_decompose_lapack() -{ - mooseError("No blas/lapack support for type ", demangle(typeid(DualReal).name())); -} - -template <> -void -DenseMatrix::_svd_lapack(DenseVector &) -{ - mooseError("No blas/lapack support for type ", demangle(typeid(DualReal).name())); -} - -template <> -void -DenseMatrix::_svd_lapack(DenseVector &, - DenseMatrix &, - DenseMatrix &) -{ - mooseError("No blas/lapack support for type ", demangle(typeid(DualReal).name())); -} - -template <> -void -DenseMatrix::_svd_helper( - char, char, std::vector &, std::vector &, std::vector &) -{ - mooseError("No blas/lapack support for type ", demangle(typeid(DualReal).name())); -} - -template <> -void -DenseMatrix::_svd_solve_lapack(const DenseVector & /*rhs*/, - DenseVector & /*x*/, - Real /*rcond*/) const -{ - mooseError("No blas/lapack support for type ", demangle(typeid(DualReal).name())); -} - -template <> -void -DenseMatrix::_evd_lapack(DenseVector &, - DenseVector &, - DenseMatrix *, - DenseMatrix *) -{ - mooseError("No blas/lapack support for type ", demangle(typeid(DualReal).name())); -} - -template <> -void -DenseMatrix::_lu_back_substitute_lapack(const DenseVector &, - DenseVector &) -{ - mooseError("No blas/lapack support for type ", demangle(typeid(DualReal).name())); -} - -template <> -void -DenseMatrix::_matvec_blas( - DualReal, DualReal, DenseVector &, const DenseVector &, bool) const -{ - mooseError("No blas/lapack support for type ", demangle(typeid(DualReal).name())); -} - -template <> -DenseMatrix::DenseMatrix(const unsigned int new_m, const unsigned int new_n) - : DenseMatrixBase(new_m, new_n), - use_blas_lapack(false), - _val(), - _decomposition_type(NONE) -{ - this->resize(new_m, new_n); -} - -template class DenseMatrixBase; -template class DenseMatrix; - -template void DenseMatrix::vector_mult_add(DenseVector &, - const int, - const DenseVector &) const; -template void DenseMatrix::vector_mult_add(DenseVector &, - const double, - const DenseVector &) const; - -template void DenseMatrix::vector_mult(DenseVector &, - const DenseVector &) const; -template void DenseMatrix::vector_mult(DenseVector &, - const DenseVector &) const; - -template void DenseMatrix::cholesky_solve(const DenseVector & b, - DenseVector & x); -} diff --git a/framework/src/utils/LinearInterpolation.C b/framework/src/utils/LinearInterpolation.C index 32411b472a0a..8b885fe2c5ee 100644 --- a/framework/src/utils/LinearInterpolation.C +++ b/framework/src/utils/LinearInterpolation.C @@ -9,7 +9,6 @@ #include "LinearInterpolation.h" -#include "DualRealOps.h" #include "ChainedReal.h" #include diff --git a/framework/src/utils/MortarUtils.C b/framework/src/utils/MortarUtils.C index 216f421ff25e..d9f80909ecfc 100644 --- a/framework/src/utils/MortarUtils.C +++ b/framework/src/utils/MortarUtils.C @@ -14,6 +14,8 @@ #include "metaphysicl/dualnumberarray.h" #include "Eigen/Dense" +using MetaPhysicL::NumberArray; + typedef DualNumber> Dual2; namespace Moose diff --git a/framework/src/utils/MultiDimensionalInterpolation.C b/framework/src/utils/MultiDimensionalInterpolation.C index c17d1c962a38..1390f6eea7b1 100644 --- a/framework/src/utils/MultiDimensionalInterpolation.C +++ b/framework/src/utils/MultiDimensionalInterpolation.C @@ -9,8 +9,6 @@ #include "MultiDimensionalInterpolation.h" -#include "DualRealOps.h" - #include #include #include @@ -268,4 +266,4 @@ MultiDimensionalInterpolationTempl::multiLinearInterpolation(const std::vecto } template class MultiDimensionalInterpolationTempl; -template class MultiDimensionalInterpolationTempl; +template class MultiDimensionalInterpolationTempl; diff --git a/framework/src/utils_nonunity/RankFourTensor.C b/framework/src/utils_nonunity/RankFourTensor.C index 3e5cfbbf4883..069ec77d3df7 100644 --- a/framework/src/utils_nonunity/RankFourTensor.C +++ b/framework/src/utils_nonunity/RankFourTensor.C @@ -7,11 +7,10 @@ //* Licensed under LGPL 2.1, please see LICENSE for details //* https://www.gnu.org/licenses/lgpl-2.1.html -#include "DualRealOps.h" #include "RankFourTensorImplementation.h" template class RankFourTensorTempl; -template class RankFourTensorTempl; +template class RankFourTensorTempl; namespace MathUtils { @@ -32,8 +31,8 @@ mooseSetToZero(ADRankFourTensor & v) #define RankTwoTensorMultInstantiate(TemplateClass) \ template RankTwoTensor RankFourTensor::operator*(const TemplateClass & a) const; \ template ADRankTwoTensor ADRankFourTensor::operator*(const TemplateClass & a) const; \ - template ADRankTwoTensor RankFourTensor::operator*(const TemplateClass & a) const; \ - template ADRankTwoTensor ADRankFourTensor::operator*(const TemplateClass & a) const + template ADRankTwoTensor RankFourTensor::operator*(const TemplateClass & a) const; \ + template ADRankTwoTensor ADRankFourTensor::operator*(const TemplateClass & a) const RankTwoTensorMultInstantiate(RankTwoTensorTempl); RankTwoTensorMultInstantiate(TensorValue); diff --git a/framework/src/utils_nonunity/RankThreeTensor.C b/framework/src/utils_nonunity/RankThreeTensor.C index 2cf14c1dc4fb..17ccb53557c1 100644 --- a/framework/src/utils_nonunity/RankThreeTensor.C +++ b/framework/src/utils_nonunity/RankThreeTensor.C @@ -7,11 +7,10 @@ //* Licensed under LGPL 2.1, please see LICENSE for details //* https://www.gnu.org/licenses/lgpl-2.1.html -#include "DualRealOps.h" #include "RankThreeTensorImplementation.h" template class RankThreeTensorTempl; -template class RankThreeTensorTempl; +template class RankThreeTensorTempl; namespace MathUtils { diff --git a/framework/src/utils_nonunity/RankTwoTensor.C b/framework/src/utils_nonunity/RankTwoTensor.C index 63bc19a9f12b..e7874af72404 100644 --- a/framework/src/utils_nonunity/RankTwoTensor.C +++ b/framework/src/utils_nonunity/RankTwoTensor.C @@ -7,11 +7,10 @@ //* Licensed under LGPL 2.1, please see LICENSE for details //* https://www.gnu.org/licenses/lgpl-2.1.html -#include "DualRealOps.h" #include "RankTwoTensorImplementation.h" template class RankTwoTensorTempl; -template class RankTwoTensorTempl; +template class RankTwoTensorTempl; namespace MathUtils { diff --git a/framework/src/utils_nonunity/SymmetricRankFourTensor.C b/framework/src/utils_nonunity/SymmetricRankFourTensor.C index 41e94bbfc461..8a90409df004 100644 --- a/framework/src/utils_nonunity/SymmetricRankFourTensor.C +++ b/framework/src/utils_nonunity/SymmetricRankFourTensor.C @@ -7,7 +7,6 @@ //* Licensed under LGPL 2.1, please see LICENSE for details //* https://www.gnu.org/licenses/lgpl-2.1.html -#include "DualRealOps.h" #include "SymmetricRankFourTensorImplementation.h" template class SymmetricRankFourTensorTempl; diff --git a/framework/src/utils_nonunity/SymmetricRankTwoTensor.C b/framework/src/utils_nonunity/SymmetricRankTwoTensor.C index a090f11cbb47..c266a715a794 100644 --- a/framework/src/utils_nonunity/SymmetricRankTwoTensor.C +++ b/framework/src/utils_nonunity/SymmetricRankTwoTensor.C @@ -7,11 +7,10 @@ //* Licensed under LGPL 2.1, please see LICENSE for details //* https://www.gnu.org/licenses/lgpl-2.1.html -#include "DualRealOps.h" #include "SymmetricRankTwoTensorImplementation.h" template class SymmetricRankTwoTensorTempl; -template class SymmetricRankTwoTensorTempl; +template class SymmetricRankTwoTensorTempl; namespace MathUtils { diff --git a/framework/src/variables/MooseVariableData.C b/framework/src/variables/MooseVariableData.C index a5f72eed3e16..2e95ec67de2d 100644 --- a/framework/src/variables/MooseVariableData.C +++ b/framework/src/variables/MooseVariableData.C @@ -15,7 +15,6 @@ #include "TimeIntegrator.h" #include "MooseVariableFE.h" #include "MooseTypes.h" -#include "DualRealOps.h" #include "libmesh/quadrature.h" #include "libmesh/fe_base.h" @@ -1812,14 +1811,14 @@ MooseVariableData::fetchADDoFValues() template <> void -MooseVariableData::assignADNodalValue(const DualReal & value, const unsigned int &) +MooseVariableData::assignADNodalValue(const ADReal & value, const unsigned int &) { _ad_nodal_value = value; } template <> void -MooseVariableData::assignADNodalValue(const DualReal & value, +MooseVariableData::assignADNodalValue(const ADReal & value, const unsigned int & component) { _ad_nodal_value(component) = value; diff --git a/modules/contact/src/constraints/ADMortarLagrangeConstraint.C b/modules/contact/src/constraints/ADMortarLagrangeConstraint.C index 5104406c9325..9fc92f3facba 100644 --- a/modules/contact/src/constraints/ADMortarLagrangeConstraint.C +++ b/modules/contact/src/constraints/ADMortarLagrangeConstraint.C @@ -107,7 +107,7 @@ ADMortarLagrangeConstraint::computeResidual(Moose::MortarType mortar_type) void ADMortarLagrangeConstraint::computeJacobian(Moose::MortarType mortar_type) { - std::vector residuals; + std::vector residuals; size_t test_space_size = 0; typedef Moose::ConstraintJacobianType JType; typedef Moose::MortarType MType; @@ -164,7 +164,7 @@ ADMortarLagrangeConstraint::computeJacobian(Moose::MortarType mortar_type) number_indices_on_lowerd++; } - std::vector residuals_lower; + std::vector residuals_lower; residuals_lower.resize(number_indices_on_lowerd, 0); // Only populate nodal residuals on the primary/secondary surfaces diff --git a/modules/contact/src/constraints/ComputeDynamicFrictionalForceLMMechanicalContact.C b/modules/contact/src/constraints/ComputeDynamicFrictionalForceLMMechanicalContact.C index ea9519bdc362..6a1b21982323 100644 --- a/modules/contact/src/constraints/ComputeDynamicFrictionalForceLMMechanicalContact.C +++ b/modules/contact/src/constraints/ComputeDynamicFrictionalForceLMMechanicalContact.C @@ -12,7 +12,6 @@ #include "Assembly.h" #include "Function.h" #include "MortarContactUtils.h" -#include "DualRealOps.h" #include "metaphysicl/dualsemidynamicsparsenumberarray.h" #include "metaphysicl/parallel_dualnumber.h" diff --git a/modules/contact/src/constraints/ComputeFrictionalForceLMMechanicalContact.C b/modules/contact/src/constraints/ComputeFrictionalForceLMMechanicalContact.C index 30e7784255af..566151ce3d40 100644 --- a/modules/contact/src/constraints/ComputeFrictionalForceLMMechanicalContact.C +++ b/modules/contact/src/constraints/ComputeFrictionalForceLMMechanicalContact.C @@ -12,7 +12,6 @@ #include "Assembly.h" #include "MortarContactUtils.h" #include "WeightedVelocitiesUserObject.h" -#include "DualRealOps.h" #include "metaphysicl/dualsemidynamicsparsenumberarray.h" #include "metaphysicl/parallel_dualnumber.h" diff --git a/modules/fluid_properties/doc/content/syntax/FluidProperties/index.md b/modules/fluid_properties/doc/content/syntax/FluidProperties/index.md index 9cb1bfd13012..8728aaa04503 100644 --- a/modules/fluid_properties/doc/content/syntax/FluidProperties/index.md +++ b/modules/fluid_properties/doc/content/syntax/FluidProperties/index.md @@ -65,13 +65,13 @@ at the quadrature points using the values of `_v[_qp]` and `_e[_qp]`. !listing modules/fluid_properties/src/materials/FluidPropertiesMaterialVE.C start=computeQpProperties In a similar fashion, fluid properties can be accessed using the Automatic Differentiation interface -using the `DualReal` version which provides both the value and derivatives +using the `ADReal` version which provides both the value and derivatives ``` -DualReal rho = _fp.p_from_T_v(T, v); +ADReal rho = _fp.p_from_T_v(T, v); ``` -where $T$ and $v$ are `DualReal`'s. The result (density `rho` in this example) then contains both the +where $T$ and $v$ are `ADReal`'s. The result (density `rho` in this example) then contains both the value of density and its derivatives with respect to the primary variables `T` and `v`. ### Input file syntax diff --git a/modules/fluid_properties/include/fluidproperties/BrineFluidProperties.h b/modules/fluid_properties/include/fluidproperties/BrineFluidProperties.h index 028b922d5362..ec31d6be41e3 100644 --- a/modules/fluid_properties/include/fluidproperties/BrineFluidProperties.h +++ b/modules/fluid_properties/include/fluidproperties/BrineFluidProperties.h @@ -50,7 +50,7 @@ class BrineFluidProperties : public MultiComponentFluidProperties * @return average molar mass (kg/mol) */ Real molarMass(Real xnacl) const; - FPDualReal molarMass(const FPDualReal & xnacl) const; + FPADReal molarMass(const FPADReal & xnacl) const; /** * NaCl molar mass @@ -67,9 +67,9 @@ class BrineFluidProperties : public MultiComponentFluidProperties virtual Real rho_from_p_T_X(Real pressure, Real temperature, Real xnacl) const override; using MultiComponentFluidProperties::rho_from_p_T_X; - FPDualReal rho_from_p_T_X(const FPDualReal & pressure, - const FPDualReal & temperature, - const FPDualReal & xnacl) const; + FPADReal rho_from_p_T_X(const FPADReal & pressure, + const FPADReal & temperature, + const FPADReal & xnacl) const; virtual void rho_from_p_T_X(Real pressure, Real temperature, @@ -90,9 +90,9 @@ class BrineFluidProperties : public MultiComponentFluidProperties Real & dmu_dT, Real & dmu_dx) const override; - FPDualReal h_from_p_T_X(const FPDualReal & pressure, - const FPDualReal & temperature, - const FPDualReal & xnacl) const; + FPADReal h_from_p_T_X(const FPADReal & pressure, + const FPADReal & temperature, + const FPADReal & xnacl) const; virtual Real h_from_p_T_X(Real pressure, Real temperature, Real xnacl) const override; using MultiComponentFluidProperties::h_from_p_T_X; @@ -107,9 +107,9 @@ class BrineFluidProperties : public MultiComponentFluidProperties virtual Real cp_from_p_T_X(Real pressure, Real temperature, Real xnacl) const override; - FPDualReal e_from_p_T_X(const FPDualReal & pressure, - const FPDualReal & temperature, - const FPDualReal & xnacl) const; + FPADReal e_from_p_T_X(const FPADReal & pressure, + const FPADReal & temperature, + const FPADReal & xnacl) const; virtual Real e_from_p_T_X(Real pressure, Real temperature, Real xnacl) const override; @@ -162,7 +162,7 @@ class BrineFluidProperties : public MultiComponentFluidProperties Real henryConstant(Real temperature, const std::vector & coeffs) const; void henryConstant(Real temperature, const std::vector & coeffs, Real & Kh, Real & dKh_dT) const; - DualReal henryConstant(const DualReal & temperature, const std::vector & coeffs) const; + ADReal henryConstant(const ADReal & temperature, const std::vector & coeffs) const; /// Fluid component numbers for water and NaCl static const unsigned int WATER = 0; @@ -184,7 +184,7 @@ class BrineFluidProperties : public MultiComponentFluidProperties * @return mole fraction (mol/mol) */ Real massFractionToMoleFraction(Real xnacl) const; - FPDualReal massFractionToMoleFraction(const FPDualReal & xnacl) const; + FPADReal massFractionToMoleFraction(const FPADReal & xnacl) const; /// Water97FluidProperties UserObject (for Henry's law) const Water97FluidProperties * _water97_fp; diff --git a/modules/fluid_properties/include/fluidproperties/CaloricallyImperfectGas.h b/modules/fluid_properties/include/fluidproperties/CaloricallyImperfectGas.h index 5690001f54ad..a277e2ab2d54 100644 --- a/modules/fluid_properties/include/fluidproperties/CaloricallyImperfectGas.h +++ b/modules/fluid_properties/include/fluidproperties/CaloricallyImperfectGas.h @@ -61,11 +61,11 @@ class CaloricallyImperfectGas : public SinglePhaseFluidProperties, public NaNInt virtual ADReal rho_from_p_T(const ADReal & p, const ADReal & T) const override; virtual void rho_from_p_T(Real p, Real T, Real & rho, Real & drho_dp, Real & drho_dT) const override; - virtual void rho_from_p_T(const DualReal & p, - const DualReal & T, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const override; + virtual void rho_from_p_T(const ADReal & p, + const ADReal & T, + ADReal & rho, + ADReal & drho_dp, + ADReal & drho_dT) const override; propfuncWithDefinitionOverride(e, p, rho); virtual Real e_from_T_v(Real T, Real v) const override; virtual void e_from_T_v(Real T, Real v, Real & e, Real & de_dT, Real & de_dv) const override; diff --git a/modules/fluid_properties/include/fluidproperties/FlibeFluidProperties.h b/modules/fluid_properties/include/fluidproperties/FlibeFluidProperties.h index 0205db650892..a8fb5b825dcd 100644 --- a/modules/fluid_properties/include/fluidproperties/FlibeFluidProperties.h +++ b/modules/fluid_properties/include/fluidproperties/FlibeFluidProperties.h @@ -39,11 +39,11 @@ class FlibeFluidProperties : public SinglePhaseFluidProperties */ virtual Real p_from_v_e(Real v, Real e) const override; virtual void p_from_v_e(Real v, Real e, Real & p, Real & dp_dv, Real & dp_de) const override; - virtual void p_from_v_e(const DualReal & v, - const DualReal & e, - DualReal & p, - DualReal & dp_dv, - DualReal & dp_de) const override; + virtual void p_from_v_e(const ADReal & v, + const ADReal & e, + ADReal & p, + ADReal & dp_dv, + ADReal & dp_de) const override; /** * Temperature and its derivatives from pressure and specific enthalpy @@ -72,11 +72,11 @@ class FlibeFluidProperties : public SinglePhaseFluidProperties * @param[out] dT_de derivative of temperature w.r.t. specific internal energy */ virtual void T_from_v_e(Real v, Real e, Real & T, Real & dT_dv, Real & dT_de) const override; - virtual void T_from_v_e(const DualReal & v, - const DualReal & e, - DualReal & T, - DualReal & dT_dv, - DualReal & dT_de) const override; + virtual void T_from_v_e(const ADReal & v, + const ADReal & e, + ADReal & T, + ADReal & dT_dv, + ADReal & dT_de) const override; /** * Temperature and its derivatives from pressure and specific enthalpy @@ -126,11 +126,11 @@ class FlibeFluidProperties : public SinglePhaseFluidProperties * @param[out] dcv_de derivative of isochoric specific heat w.r.t. specific internal energy */ virtual void cv_from_v_e(Real v, Real e, Real & cv, Real & dcv_dv, Real & dcv_de) const override; - virtual void cv_from_v_e(const DualReal & v, - const DualReal & e, - DualReal & cv, - DualReal & dcv_dv, - DualReal & dcv_de) const override; + virtual void cv_from_v_e(const ADReal & v, + const ADReal & e, + ADReal & cv, + ADReal & dcv_dv, + ADReal & dcv_de) const override; using SinglePhaseFluidProperties::mu_from_v_e; @@ -174,11 +174,11 @@ class FlibeFluidProperties : public SinglePhaseFluidProperties */ virtual void rho_from_p_T(Real p, Real T, Real & rho, Real & drho_dp, Real & drho_dT) const override; - virtual void rho_from_p_T(const DualReal & p, - const DualReal & T, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const override; + virtual void rho_from_p_T(const ADReal & p, + const ADReal & T, + ADReal & rho, + ADReal & drho_dp, + ADReal & drho_dT) const override; /** * Specific volume from pressure and temperature @@ -188,7 +188,7 @@ class FlibeFluidProperties : public SinglePhaseFluidProperties * @return specific volume (m$^3$/kg) */ virtual Real v_from_p_T(Real p, Real T) const override; - virtual DualReal v_from_p_T(const DualReal & p, const DualReal & T) const override; + virtual ADReal v_from_p_T(const ADReal & p, const ADReal & T) const override; /** * Specific volume and its derivatives from pressure and temperature diff --git a/modules/fluid_properties/include/fluidproperties/FlinakFluidProperties.h b/modules/fluid_properties/include/fluidproperties/FlinakFluidProperties.h index 996c0368b482..f2529ecd67f9 100644 --- a/modules/fluid_properties/include/fluidproperties/FlinakFluidProperties.h +++ b/modules/fluid_properties/include/fluidproperties/FlinakFluidProperties.h @@ -49,11 +49,11 @@ class FlinakFluidProperties : public SinglePhaseFluidProperties * @param[out] dp_de derivative of pressure w.r.t. specific internal energy */ virtual void p_from_v_e(Real v, Real e, Real & p, Real & dp_dv, Real & dp_de) const override; - virtual void p_from_v_e(const DualReal & v, - const DualReal & e, - DualReal & p, - DualReal & dp_dv, - DualReal & dp_de) const override; + virtual void p_from_v_e(const ADReal & v, + const ADReal & e, + ADReal & p, + ADReal & dp_dv, + ADReal & dp_de) const override; /** * Temperature from specific volume and specific internal energy @@ -74,11 +74,11 @@ class FlinakFluidProperties : public SinglePhaseFluidProperties * @param[out] dT_de derivative of temperature w.r.t. specific internal energy */ virtual void T_from_v_e(Real v, Real e, Real & T, Real & dT_dv, Real & dT_de) const override; - virtual void T_from_v_e(const DualReal & v, - const DualReal & e, - DualReal & T, - DualReal & dT_dv, - DualReal & dT_de) const override; + virtual void T_from_v_e(const ADReal & v, + const ADReal & e, + ADReal & T, + ADReal & dT_dv, + ADReal & dT_de) const override; /** * Temperature from pressure and specific enthalpy @@ -137,11 +137,11 @@ class FlinakFluidProperties : public SinglePhaseFluidProperties * @param[out] dcv_de derivative of isochoric specific heat w.r.t. specific internal energy */ virtual void cv_from_v_e(Real v, Real e, Real & cv, Real & dcv_dv, Real & dcv_de) const override; - virtual void cv_from_v_e(const DualReal & v, - const DualReal & e, - DualReal & cv, - DualReal & dcv_dv, - DualReal & dcv_de) const override; + virtual void cv_from_v_e(const ADReal & v, + const ADReal & e, + ADReal & cv, + ADReal & dcv_dv, + ADReal & dcv_de) const override; using SinglePhaseFluidProperties::mu_from_v_e; @@ -185,11 +185,11 @@ class FlinakFluidProperties : public SinglePhaseFluidProperties */ virtual void rho_from_p_T(Real p, Real T, Real & rho, Real & drho_dp, Real & drho_dT) const override; - virtual void rho_from_p_T(const DualReal & pressure, - const DualReal & temperature, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const override; + virtual void rho_from_p_T(const ADReal & pressure, + const ADReal & temperature, + ADReal & rho, + ADReal & drho_dp, + ADReal & drho_dT) const override; /** * Specific volume from pressure and temperature @@ -200,7 +200,7 @@ class FlinakFluidProperties : public SinglePhaseFluidProperties */ virtual Real v_from_p_T(Real p, Real T) const override; - virtual DualReal v_from_p_T(const DualReal & p, const DualReal & T) const override; + virtual ADReal v_from_p_T(const ADReal & p, const ADReal & T) const override; /** * Specific volume and its derivatives from pressure and temperature diff --git a/modules/fluid_properties/include/fluidproperties/FluidProperties.h b/modules/fluid_properties/include/fluidproperties/FluidProperties.h index f7450b523618..1599e1e0e482 100644 --- a/modules/fluid_properties/include/fluidproperties/FluidProperties.h +++ b/modules/fluid_properties/include/fluidproperties/FluidProperties.h @@ -14,13 +14,13 @@ // Forward Declarations -// The default DualReal size allows functions of many more variables than +// The default ADReal size allows functions of many more variables than // common in the FluidProperties module. This makes the computations much // slower than necessary, so use a smaller definition in the FluidProperties -// module, FPDualReal, which is suitable for up to five variables. +// module, FPADReal, which is suitable for up to five variables. // This is useful for the cases where we wish to use AD to compute the derivatives // rather than hand-coding them in derived classes. -typedef DualNumber> FPDualReal; +typedef DualNumber> FPADReal; class FluidProperties : public ThreadedGeneralUserObject, public SolutionInvalidInterface { diff --git a/modules/fluid_properties/include/fluidproperties/HeliumFluidProperties.h b/modules/fluid_properties/include/fluidproperties/HeliumFluidProperties.h index 721823fd8dae..06fedcf13f7f 100644 --- a/modules/fluid_properties/include/fluidproperties/HeliumFluidProperties.h +++ b/modules/fluid_properties/include/fluidproperties/HeliumFluidProperties.h @@ -59,11 +59,11 @@ class HeliumFluidProperties : public SinglePhaseFluidProperties */ virtual void p_from_v_e(Real v, Real e, Real & p, Real & dp_dv, Real & dp_de) const override; - void p_from_v_e(const DualReal & v, - const DualReal & e, - DualReal & p, - DualReal & dp_dv, - DualReal & dp_de) const override; + void p_from_v_e(const ADReal & v, + const ADReal & e, + ADReal & p, + ADReal & dp_dv, + ADReal & dp_de) const override; /** * Temperature from specific volume and specific internal energy @@ -94,11 +94,11 @@ class HeliumFluidProperties : public SinglePhaseFluidProperties */ virtual void T_from_v_e(Real v, Real e, Real & T, Real & dT_dv, Real & dT_de) const override; - void T_from_v_e(const DualReal & v, - const DualReal & e, - DualReal & T, - DualReal & dT_dv, - DualReal & dT_de) const override; + void T_from_v_e(const ADReal & v, + const ADReal & e, + ADReal & T, + ADReal & dT_dv, + ADReal & dT_de) const override; /** * Temperature from pressure and specific enthalpy @@ -215,11 +215,11 @@ class HeliumFluidProperties : public SinglePhaseFluidProperties virtual void rho_from_p_T(Real p, Real T, Real & rho, Real & drho_dp, Real & drho_dT) const override; - virtual void rho_from_p_T(const DualReal & p, - const DualReal & T, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const override; + virtual void rho_from_p_T(const ADReal & p, + const ADReal & T, + ADReal & rho, + ADReal & drho_dp, + ADReal & drho_dT) const override; /** * Specific internal energy from pressure and temperature * diff --git a/modules/fluid_properties/include/fluidproperties/IdealGasFluidProperties.h b/modules/fluid_properties/include/fluidproperties/IdealGasFluidProperties.h index 69142efa475d..88bc0f353724 100644 --- a/modules/fluid_properties/include/fluidproperties/IdealGasFluidProperties.h +++ b/modules/fluid_properties/include/fluidproperties/IdealGasFluidProperties.h @@ -30,19 +30,19 @@ class IdealGasFluidProperties : public SinglePhaseFluidProperties, public NaNInt virtual Real p_from_v_e(Real v, Real e) const override; virtual ADReal p_from_v_e(const ADReal & v, const ADReal & e) const override; virtual void p_from_v_e(Real v, Real e, Real & p, Real & dp_dv, Real & dp_de) const override; - virtual void p_from_v_e(const DualReal & v, - const DualReal & e, - DualReal & p, - DualReal & dp_dv, - DualReal & dp_de) const override; + virtual void p_from_v_e(const ADReal & v, + const ADReal & e, + ADReal & p, + ADReal & dp_dv, + ADReal & dp_de) const override; virtual Real T_from_v_e(Real v, Real e) const override; virtual ADReal T_from_v_e(const ADReal & v, const ADReal & e) const override; virtual void T_from_v_e(Real v, Real e, Real & T, Real & dT_dv, Real & dT_de) const override; - virtual void T_from_v_e(const DualReal & v, - const DualReal & e, - DualReal & T, - DualReal & dT_dv, - DualReal & dT_de) const override; + virtual void T_from_v_e(const ADReal & v, + const ADReal & e, + ADReal & T, + ADReal & dT_dv, + ADReal & dT_de) const override; virtual Real c_from_v_e(Real v, Real e) const override; virtual ADReal c_from_v_e(const ADReal & v, const ADReal & e) const override; virtual void c_from_v_e(Real v, Real e, Real & c, Real & dc_dv, Real & dc_de) const override; @@ -69,11 +69,11 @@ class IdealGasFluidProperties : public SinglePhaseFluidProperties, public NaNInt virtual ADReal rho_from_p_T(const ADReal & p, const ADReal & T) const override; virtual void rho_from_p_T(Real p, Real T, Real & rho, Real & drho_dp, Real & drho_dT) const override; - virtual void rho_from_p_T(const DualReal & p, - const DualReal & T, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const override; + virtual void rho_from_p_T(const ADReal & p, + const ADReal & T, + ADReal & rho, + ADReal & drho_dp, + ADReal & drho_dT) const override; virtual Real e_from_p_rho(Real p, Real rho) const override; virtual ADReal e_from_p_rho(const ADReal & p, const ADReal & rho) const override; virtual void diff --git a/modules/fluid_properties/include/fluidproperties/LeadBismuthFluidProperties.h b/modules/fluid_properties/include/fluidproperties/LeadBismuthFluidProperties.h index be7757373dfe..0ad68ec7dc44 100644 --- a/modules/fluid_properties/include/fluidproperties/LeadBismuthFluidProperties.h +++ b/modules/fluid_properties/include/fluidproperties/LeadBismuthFluidProperties.h @@ -61,11 +61,11 @@ class LeadBismuthFluidProperties : public SinglePhaseFluidProperties Real rho_from_p_T(Real p, Real T) const override; void rho_from_p_T(Real p, Real T, Real & rho, Real & drho_dp, Real & drho_dT) const override; - void rho_from_p_T(const DualReal & p, - const DualReal & T, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const override; + void rho_from_p_T(const ADReal & p, + const ADReal & T, + ADReal & rho, + ADReal & drho_dp, + ADReal & drho_dT) const override; Real v_from_p_T(Real p, Real T) const override; void v_from_p_T(Real p, Real T, Real & v, Real & dv_dp, Real & dv_dT) const override; @@ -104,7 +104,7 @@ class LeadBismuthFluidProperties : public SinglePhaseFluidProperties Real bulk_modulus_from_p_T(Real p, Real T) const; Real c_from_v_e(Real v, Real e) const override; - DualReal c_from_v_e(const DualReal & v, const DualReal & e) const override; + ADReal c_from_v_e(const ADReal & v, const ADReal & e) const override; private: /// Melting temperature of 2LiF-BeF2 diff --git a/modules/fluid_properties/include/fluidproperties/LeadFluidProperties.h b/modules/fluid_properties/include/fluidproperties/LeadFluidProperties.h index da12b99b0832..74c75f800a34 100644 --- a/modules/fluid_properties/include/fluidproperties/LeadFluidProperties.h +++ b/modules/fluid_properties/include/fluidproperties/LeadFluidProperties.h @@ -66,11 +66,11 @@ class LeadFluidProperties : public SinglePhaseFluidProperties using SinglePhaseFluidProperties::rho_from_p_T; Real rho_from_p_T(Real p, Real T) const override; void rho_from_p_T(Real p, Real T, Real & rho, Real & drho_dp, Real & drho_dT) const override; - void rho_from_p_T(const DualReal & p, - const DualReal & T, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const override; + void rho_from_p_T(const ADReal & p, + const ADReal & T, + ADReal & rho, + ADReal & drho_dp, + ADReal & drho_dT) const override; Real v_from_p_T(Real p, Real T) const override; @@ -107,7 +107,7 @@ class LeadFluidProperties : public SinglePhaseFluidProperties Real bulk_modulus_from_p_T(Real p, Real T) const; Real c_from_v_e(Real v, Real e) const override; - DualReal c_from_v_e(const DualReal & v, const DualReal & e) const override; + ADReal c_from_v_e(const ADReal & v, const ADReal & e) const override; private: /// Melting temperature of Lead diff --git a/modules/fluid_properties/include/fluidproperties/MultiComponentFluidProperties.h b/modules/fluid_properties/include/fluidproperties/MultiComponentFluidProperties.h index 342537ff356d..0013d08ee580 100644 --- a/modules/fluid_properties/include/fluidproperties/MultiComponentFluidProperties.h +++ b/modules/fluid_properties/include/fluidproperties/MultiComponentFluidProperties.h @@ -37,8 +37,8 @@ val = want##_from_##prop1##_##prop2##_##prop3(prop1, prop2, prop3); \ } \ \ - DualReal want##_from_##prop1##_##prop2##_##prop3( \ - const DualReal & p1, const DualReal & p2, const DualReal & p3) const \ + ADReal want##_from_##prop1##_##prop2##_##prop3( \ + const ADReal & p1, const ADReal & p2, const ADReal & p3) const \ { \ const Real raw1 = p1.value(); \ const Real raw2 = p2.value(); \ @@ -49,7 +49,7 @@ Real dxd3 = 0.0; \ want##_from_##prop1##_##prop2##_##prop3(raw1, raw2, raw3, x, dxd1, dxd2, dxd3); \ \ - DualReal result = x; \ + ADReal result = x; \ result.derivatives() = \ p1.derivatives() * dxd1 + p2.derivatives() * dxd2 + p3.derivatives() * dxd3; \ \ @@ -112,7 +112,7 @@ class MultiComponentFluidProperties : public FluidProperties * your_fluid_properties_object.rho_from_p_T_X(p, T, X, rho, drho_dp, drho_dT, drho_dX); * @endcode * - * Automatic differentiation (AD) support is provided through prop_from_p_T_X(DualReal p, DualReal T, DualReal X) versions + * Automatic differentiation (AD) support is provided through prop_from_p_T_X(ADReal p, ADReal T, ADReal X) versions * of the functions where p, T and X must be ADReal/DualNumber's calculated using all AD-supporting values. */ ///@{ @@ -146,7 +146,7 @@ class MultiComponentFluidProperties : public FluidProperties rho_mu_from_p_T_X(Real pressure, Real temperature, Real xmass, Real & rho, Real & mu) const; virtual void rho_mu_from_p_T_X( - DualReal pressure, DualReal temperature, DualReal xmass, DualReal & rho, DualReal & mu) const; + ADReal pressure, ADReal temperature, ADReal xmass, ADReal & rho, ADReal & mu) const; /** * Density and viscosity and their derivatives wrt pressure, temperature diff --git a/modules/fluid_properties/include/fluidproperties/SimpleFluidProperties.h b/modules/fluid_properties/include/fluidproperties/SimpleFluidProperties.h index ae769259db60..c1f65c2e91b5 100644 --- a/modules/fluid_properties/include/fluidproperties/SimpleFluidProperties.h +++ b/modules/fluid_properties/include/fluidproperties/SimpleFluidProperties.h @@ -95,21 +95,21 @@ class SimpleFluidProperties : public SinglePhaseFluidProperties virtual void rho_from_p_T( Real pressure, Real temperature, Real & rho, Real & drho_dp, Real & drho_dT) const override; - virtual void rho_from_p_T(const DualReal & pressure, - const DualReal & temperature, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const override; + virtual void rho_from_p_T(const ADReal & pressure, + const ADReal & temperature, + ADReal & rho, + ADReal & drho_dp, + ADReal & drho_dT) const override; virtual Real T_from_v_e(Real v, Real e) const override; virtual void T_from_v_e(Real v, Real e, Real & T, Real & dT_dv, Real & dT_de) const override; - virtual void T_from_v_e(const DualReal & v, - const DualReal & e, - DualReal & T, - DualReal & dT_dv, - DualReal & dT_de) const override; + virtual void T_from_v_e(const ADReal & v, + const ADReal & e, + ADReal & T, + ADReal & dT_dv, + ADReal & dT_de) const override; virtual Real T_from_v_h(Real v, Real h) const; @@ -125,11 +125,11 @@ class SimpleFluidProperties : public SinglePhaseFluidProperties virtual void p_from_v_e(Real v, Real e, Real & p, Real & dp_dv, Real & dp_de) const override; - virtual void p_from_v_e(const DualReal & v, - const DualReal & e, - DualReal & p, - DualReal & dp_dv, - DualReal & dp_de) const override; + virtual void p_from_v_e(const ADReal & v, + const ADReal & e, + ADReal & p, + ADReal & dp_dv, + ADReal & dp_de) const override; virtual Real p_from_v_h(Real v, Real h) const; diff --git a/modules/fluid_properties/include/fluidproperties/SinglePhaseFluidProperties.h b/modules/fluid_properties/include/fluidproperties/SinglePhaseFluidProperties.h index 6fb84c57249a..c40cdb1e9fc5 100644 --- a/modules/fluid_properties/include/fluidproperties/SinglePhaseFluidProperties.h +++ b/modules/fluid_properties/include/fluidproperties/SinglePhaseFluidProperties.h @@ -19,7 +19,7 @@ * overriden in derived classes. */ #define propfuncAD(want, prop1, prop2) \ - virtual DualReal want##_from_##prop1##_##prop2(const DualReal & p1, const DualReal & p2) const \ + virtual ADReal want##_from_##prop1##_##prop2(const ADReal & p1, const ADReal & p2) const \ { \ Real x = 0; \ Real raw1 = p1.value(); \ @@ -28,16 +28,16 @@ Real dxd2 = 0; \ want##_from_##prop1##_##prop2(raw1, raw2, x, dxd1, dxd2); \ \ - DualReal result = x; \ + ADReal result = x; \ result.derivatives() = p1.derivatives() * dxd1 + p2.derivatives() * dxd2; \ return result; \ } \ \ - virtual void want##_from_##prop1##_##prop2(const DualReal & prop1, \ - const DualReal & prop2, \ - DualReal & val, \ - DualReal & d##want##d1, \ - DualReal & d##want##d2) const \ + virtual void want##_from_##prop1##_##prop2(const ADReal & prop1, \ + const ADReal & prop2, \ + ADReal & val, \ + ADReal & d##want##d1, \ + ADReal & d##want##d2) const \ { \ unimplementedDerivativeMethod(__PRETTY_FUNCTION__); \ Real dummy, tmp1, tmp2; \ @@ -166,8 +166,8 @@ class SinglePhaseFluidProperties : public FluidProperties * your_fluid_properties_object.p_from_v_e(specific_vol, specific_energy, pressure, dp_dv, dp_de); * @endcode * - * Automatic differentiation (AD) support is provided through x_from_a_b(DualReal a, DualReal b) and - * x_from_a_b(DualReal a, DualReal b, DualReal x, DualReal dx_da, DualReal dx_db) versions of the + * Automatic differentiation (AD) support is provided through x_from_a_b(ADReal a, ADReal b) and + * x_from_a_b(ADReal a, ADReal b, ADReal x, ADReal dx_da, ADReal dx_db) versions of the * functions where a and b must be ADReal/DualNumber's calculated using all AD-supporting values: * * @begincode @@ -298,7 +298,7 @@ class SinglePhaseFluidProperties : public FluidProperties */ virtual Real vaporPressure(Real T) const; virtual void vaporPressure(Real T, Real & psat, Real & dpsat_dT) const; - DualReal vaporPressure(const DualReal & T) const; + ADReal vaporPressure(const ADReal & T) const; /** * Vapor temperature. Used to delineate liquid and gas phases. @@ -311,7 +311,7 @@ class SinglePhaseFluidProperties : public FluidProperties */ virtual Real vaporTemperature(Real p) const; virtual void vaporTemperature(Real p, Real & Tsat, Real & dTsat_dp) const; - DualReal vaporTemperature(const DualReal & p) const; + ADReal vaporTemperature(const ADReal & p) const; /** * Henry's law coefficients for dissolution in water @@ -348,8 +348,7 @@ class SinglePhaseFluidProperties : public FluidProperties Real & mu, Real & dmu_dp, Real & dmu_dT) const; - virtual void - rho_mu_from_p_T(const DualReal & p, const DualReal & T, DualReal & rho, DualReal & mu) const; + virtual void rho_mu_from_p_T(const ADReal & p, const ADReal & T, ADReal & rho, ADReal & mu) const; virtual void rho_e_from_p_T(Real p, Real T, diff --git a/modules/fluid_properties/include/fluidproperties/SodiumSaturationFluidProperties.h b/modules/fluid_properties/include/fluidproperties/SodiumSaturationFluidProperties.h index 7b78965f5e5b..2fee73b1b9c0 100644 --- a/modules/fluid_properties/include/fluidproperties/SodiumSaturationFluidProperties.h +++ b/modules/fluid_properties/include/fluidproperties/SodiumSaturationFluidProperties.h @@ -29,11 +29,11 @@ class SodiumSaturationFluidProperties : public SinglePhaseFluidProperties virtual void rho_from_p_T(Real p, Real T, Real & rho, Real & drho_dp, Real & drho_dT) const override; - virtual void rho_from_p_T(const DualReal & p, - const DualReal & T, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const override; + virtual void rho_from_p_T(const ADReal & p, + const ADReal & T, + ADReal & rho, + ADReal & drho_dp, + ADReal & drho_dT) const override; virtual Real v_from_p_T(Real p, Real T) const override; virtual void v_from_p_T(Real p, Real T, Real & v, Real & dv_dp, Real & dv_dT) const override; diff --git a/modules/fluid_properties/include/fluidproperties/TemperaturePressureFunctionFluidProperties.h b/modules/fluid_properties/include/fluidproperties/TemperaturePressureFunctionFluidProperties.h index 39fc48f49fab..5901ae2a244f 100644 --- a/modules/fluid_properties/include/fluidproperties/TemperaturePressureFunctionFluidProperties.h +++ b/modules/fluid_properties/include/fluidproperties/TemperaturePressureFunctionFluidProperties.h @@ -143,11 +143,11 @@ class TemperaturePressureFunctionFluidProperties : public SinglePhaseFluidProper */ virtual void rho_from_p_T(Real p, Real T, Real & rho, Real & drho_dp, Real & drho_dT) const override; - virtual void rho_from_p_T(const DualReal & pressure, - const DualReal & temperature, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const override; + virtual void rho_from_p_T(const ADReal & pressure, + const ADReal & temperature, + ADReal & rho, + ADReal & drho_dp, + ADReal & drho_dT) const override; /** * Specific volume from pressure and temperature diff --git a/modules/fluid_properties/include/fluidproperties/TwoPhaseFluidProperties.h b/modules/fluid_properties/include/fluidproperties/TwoPhaseFluidProperties.h index 6dc59749068f..8037acfcb1da 100644 --- a/modules/fluid_properties/include/fluidproperties/TwoPhaseFluidProperties.h +++ b/modules/fluid_properties/include/fluidproperties/TwoPhaseFluidProperties.h @@ -52,7 +52,7 @@ class TwoPhaseFluidProperties : public FluidProperties * @param[in] p pressure */ virtual Real T_sat(Real p) const = 0; - virtual DualReal T_sat(const DualReal & p) const; + virtual ADReal T_sat(const ADReal & p) const; /** * Computes the saturation pressure at a temperature @@ -60,7 +60,7 @@ class TwoPhaseFluidProperties : public FluidProperties * @param[in] T temperature */ virtual Real p_sat(Real T) const = 0; - virtual DualReal p_sat(const DualReal & T) const; + virtual ADReal p_sat(const ADReal & T) const; /** * Computes dT/dp along the saturation line @@ -76,7 +76,7 @@ class TwoPhaseFluidProperties : public FluidProperties * @param T temperature */ virtual Real h_lat(Real p, Real T) const; - virtual DualReal h_lat(const DualReal & p, const DualReal & T) const; + virtual ADReal h_lat(const ADReal & p, const ADReal & T) const; /** * Returns the latent heat of fusion @@ -90,7 +90,7 @@ class TwoPhaseFluidProperties : public FluidProperties * @param T temperature */ virtual Real sigma_from_T(Real T) const; - virtual DualReal sigma_from_T(const DualReal & T) const; + virtual ADReal sigma_from_T(const ADReal & T) const; /** * Computes dsigma/dT along the saturation line diff --git a/modules/fluid_properties/include/fluidproperties/TwoPhaseFluidPropertiesIndependent.h b/modules/fluid_properties/include/fluidproperties/TwoPhaseFluidPropertiesIndependent.h index c7c13e363acb..59d0b2a46643 100644 --- a/modules/fluid_properties/include/fluidproperties/TwoPhaseFluidPropertiesIndependent.h +++ b/modules/fluid_properties/include/fluidproperties/TwoPhaseFluidPropertiesIndependent.h @@ -29,13 +29,13 @@ class TwoPhaseFluidPropertiesIndependent : public TwoPhaseFluidProperties virtual Real p_critical() const override; virtual Real T_triple() const override; virtual Real T_sat(Real p) const override; - virtual DualReal T_sat(const DualReal & p) const override; + virtual ADReal T_sat(const ADReal & p) const override; virtual Real p_sat(Real T) const override; - virtual DualReal p_sat(const DualReal & T) const override; + virtual ADReal p_sat(const ADReal & T) const override; virtual Real dT_sat_dp(Real p) const override; virtual Real L_fusion() const override; virtual Real sigma_from_T(Real T) const override; - virtual DualReal sigma_from_T(const DualReal & T) const override; + virtual ADReal sigma_from_T(const ADReal & T) const override; virtual Real dsigma_dT_from_T(Real T) const override; virtual bool supportsPhaseChange() const override { return false; } diff --git a/modules/fluid_properties/include/fluidproperties/VaporMixtureFluidProperties.h b/modules/fluid_properties/include/fluidproperties/VaporMixtureFluidProperties.h index 0db0d46fae2c..bb97effd8e41 100644 --- a/modules/fluid_properties/include/fluidproperties/VaporMixtureFluidProperties.h +++ b/modules/fluid_properties/include/fluidproperties/VaporMixtureFluidProperties.h @@ -18,8 +18,8 @@ */ #define propfuncAD(want, prop1, prop2) \ - virtual DualReal want##_from_##prop1##_##prop2( \ - const DualReal & p1, const DualReal & p2, const std::vector & x) const \ + virtual ADReal want##_from_##prop1##_##prop2( \ + const ADReal & p1, const ADReal & p2, const std::vector & x) const \ { \ Real p1_raw = p1.value(); \ Real p2_raw = p2.value(); \ @@ -33,20 +33,20 @@ std::vector dy_dx(x.size(), 0); \ want##_from_##prop1##_##prop2(p1_raw, p2_raw, x_raw, y_raw, dy_dp1, dy_dp2, dy_dx); \ \ - DualReal result = y_raw; \ + ADReal result = y_raw; \ result.derivatives() = p1.derivatives() * dy_dp1 + p2.derivatives() * dy_dp2; \ for (unsigned int i = 0; i < x.size(); ++i) \ result.derivatives() += x[i].derivatives() * dy_dx[i]; \ return result; \ } \ \ - virtual void want##_from_##prop1##_##prop2(const DualReal & prop1, \ - const DualReal & prop2, \ - std::vector & x, \ - DualReal & val, \ - DualReal & d##want##d1, \ - DualReal & d##want##d2, \ - std::vector & d##want##dx) const \ + virtual void want##_from_##prop1##_##prop2(const ADReal & prop1, \ + const ADReal & prop2, \ + std::vector & x, \ + ADReal & val, \ + ADReal & d##want##d1, \ + ADReal & d##want##d2, \ + std::vector & d##want##dx) const \ { \ fluidPropError( \ name(), ": ", __PRETTY_FUNCTION__, " derivative derivatives not implemented."); \ diff --git a/modules/fluid_properties/include/fluidproperties/Water97FluidProperties.h b/modules/fluid_properties/include/fluidproperties/Water97FluidProperties.h index 052fed0ac99b..28a233e62917 100644 --- a/modules/fluid_properties/include/fluidproperties/Water97FluidProperties.h +++ b/modules/fluid_properties/include/fluidproperties/Water97FluidProperties.h @@ -366,7 +366,7 @@ class Water97FluidProperties : public SinglePhaseFluidProperties Real henryConstant(Real temperature, const std::vector & coeffs) const; void henryConstant(Real temperature, const std::vector & coeffs, Real & Kh, Real & dKh_dT) const; - DualReal henryConstant(const DualReal & temperature, const std::vector & coeffs) const; + ADReal henryConstant(const ADReal & temperature, const std::vector & coeffs) const; /** * Computes the pressure (first member of the pair) and temperature (second member of the pair) as @@ -722,7 +722,7 @@ class Water97FluidProperties : public SinglePhaseFluidProperties * @param enthalpy water enthalpy (J/kg) * @return temperature water temperature (K) */ - FPDualReal T_from_p_h_ad(const FPDualReal & pressure, const FPDualReal & enthalpy) const; + FPADReal T_from_p_h_ad(const FPADReal & pressure, const FPADReal & enthalpy) const; /** * Backwards equation T(p, h) in Region 1 @@ -734,7 +734,7 @@ class Water97FluidProperties : public SinglePhaseFluidProperties * @param enthalpy water enthalpy (J/kg) * @return temperature water temperature (K) */ - FPDualReal temperature_from_ph1(const FPDualReal & pressure, const FPDualReal & enthalpy) const; + FPADReal temperature_from_ph1(const FPADReal & pressure, const FPADReal & enthalpy) const; /** * Backwards equation T(p, h) in Region 2a @@ -746,7 +746,7 @@ class Water97FluidProperties : public SinglePhaseFluidProperties * @param enthalpy water enthalpy (J/kg) * @return temperature water temperature (K) */ - FPDualReal temperature_from_ph2a(const FPDualReal & pressure, const FPDualReal & enthalpy) const; + FPADReal temperature_from_ph2a(const FPADReal & pressure, const FPADReal & enthalpy) const; /** * Backwards equation T(p, h) in Region 2b @@ -758,7 +758,7 @@ class Water97FluidProperties : public SinglePhaseFluidProperties * @param enthalpy water enthalpy (J/kg) * @return temperature water temperature (K) */ - FPDualReal temperature_from_ph2b(const FPDualReal & pressure, const FPDualReal & enthalpy) const; + FPADReal temperature_from_ph2b(const FPADReal & pressure, const FPADReal & enthalpy) const; /** * Backwards equation T(p, h) in Region 2c @@ -770,7 +770,7 @@ class Water97FluidProperties : public SinglePhaseFluidProperties * @param enthalpy water enthalpy (J/kg) * @return temperature water temperature (K) */ - FPDualReal temperature_from_ph2c(const FPDualReal & pressure, const FPDualReal & enthalpy) const; + FPADReal temperature_from_ph2c(const FPADReal & pressure, const FPADReal & enthalpy) const; /** * Backwards equation T(p, h) in Region 3a @@ -783,7 +783,7 @@ class Water97FluidProperties : public SinglePhaseFluidProperties * @param enthalpy water enthalpy (J/kg) * @return temperature water temperature (K) */ - FPDualReal temperature_from_ph3a(const FPDualReal & pressure, const FPDualReal & enthalpy) const; + FPADReal temperature_from_ph3a(const FPADReal & pressure, const FPADReal & enthalpy) const; /** * Backwards equation T(p, h) in Region 3b @@ -796,7 +796,7 @@ class Water97FluidProperties : public SinglePhaseFluidProperties * @param enthalpy water enthalpy (J/kg) * @return temperature water temperature (K) */ - FPDualReal temperature_from_ph3b(const FPDualReal & pressure, const FPDualReal & enthalpy) const; + FPADReal temperature_from_ph3b(const FPADReal & pressure, const FPADReal & enthalpy) const; /** * AD version of saturation temperature as a function of pressure (used internally) @@ -810,7 +810,7 @@ class Water97FluidProperties : public SinglePhaseFluidProperties * @param pressure water pressure (Pa) * @return saturation temperature (K) */ - FPDualReal vaporTemperature_ad(const FPDualReal & pressure) const; + FPADReal vaporTemperature_ad(const FPADReal & pressure) const; /// Water molar mass (kg/mol) const Real _Mh2o; diff --git a/modules/fluid_properties/include/utils/DimensionlessFlowNumbers.h b/modules/fluid_properties/include/utils/DimensionlessFlowNumbers.h index 65418b45d624..9a75e93f003e 100644 --- a/modules/fluid_properties/include/utils/DimensionlessFlowNumbers.h +++ b/modules/fluid_properties/include/utils/DimensionlessFlowNumbers.h @@ -9,9 +9,8 @@ #pragma once -#include "DualReal.h" +#include "ADReal.h" -#include "DualRealOps.h" #include "libmesh/libmesh_common.h" using namespace libMesh; @@ -29,7 +28,7 @@ namespace fp * @return Reynolds number */ Real reynolds(Real rho, Real vel, Real L, Real mu); -DualReal reynolds(DualReal rho, DualReal vel, DualReal L, DualReal mu); +ADReal reynolds(ADReal rho, ADReal vel, ADReal L, ADReal mu); /** * Compute Prandtl number @@ -40,7 +39,7 @@ DualReal reynolds(DualReal rho, DualReal vel, DualReal L, DualReal mu); * @return Prandtl number */ Real prandtl(Real cp, Real mu, Real k); -DualReal prandtl(DualReal cp, DualReal mu, DualReal k); +ADReal prandtl(ADReal cp, ADReal mu, ADReal k); /** * Compute Grashof number @@ -55,13 +54,13 @@ DualReal prandtl(DualReal cp, DualReal mu, DualReal k); * @return Grashof number */ Real grashof(Real beta, Real T_s, Real T_bulk, Real L, Real rho, Real mu, Real gravity_magnitude); -DualReal grashof(DualReal beta, - DualReal T_s, - DualReal T_bulk, - DualReal L, - DualReal rho, - DualReal mu, - DualReal gravity_magnitude); +ADReal grashof(ADReal beta, + ADReal T_s, + ADReal T_bulk, + ADReal L, + ADReal rho, + ADReal mu, + ADReal gravity_magnitude); /** * Compute Laplace number @@ -73,7 +72,7 @@ DualReal grashof(DualReal beta, * @return Laplace number */ Real laplace(Real sigma, Real rho, Real L, Real mu); -DualReal laplace(DualReal sigma, DualReal rho, DualReal L, DualReal mu); +ADReal laplace(ADReal sigma, ADReal rho, ADReal L, ADReal mu); /** * Compute thermal diffusivity @@ -84,7 +83,7 @@ DualReal laplace(DualReal sigma, DualReal rho, DualReal L, DualReal mu); * @return Thermal diffusivity */ Real thermalDiffusivity(Real k, Real rho, Real cp); -DualReal thermalDiffusivity(DualReal k, DualReal rho, DualReal cp); +ADReal thermalDiffusivity(ADReal k, ADReal rho, ADReal cp); /** * Compute Peclet number @@ -95,6 +94,6 @@ DualReal thermalDiffusivity(DualReal k, DualReal rho, DualReal cp); * @return Peclet number */ Real peclet(Real vel, Real L, Real diffusivity); -DualReal peclet(DualReal vel, DualReal L, DualReal diffusivity); +ADReal peclet(ADReal vel, ADReal L, ADReal diffusivity); } // namespace fp diff --git a/modules/fluid_properties/src/fluidproperties/BrineFluidProperties.C b/modules/fluid_properties/src/fluidproperties/BrineFluidProperties.C index f004977ad4e7..2896ba3b5d04 100644 --- a/modules/fluid_properties/src/fluidproperties/BrineFluidProperties.C +++ b/modules/fluid_properties/src/fluidproperties/BrineFluidProperties.C @@ -93,8 +93,8 @@ BrineFluidProperties::fluidName() const return "brine"; } -FPDualReal -BrineFluidProperties::molarMass(const FPDualReal & xnacl) const +FPADReal +BrineFluidProperties::molarMass(const FPADReal & xnacl) const { return 1.0 / (xnacl / _Mnacl + (1.0 - xnacl) / _Mh2o); } @@ -117,39 +117,39 @@ BrineFluidProperties::molarMassH2O() const return _Mh2o; } -FPDualReal -BrineFluidProperties::rho_from_p_T_X(const FPDualReal & pressure, - const FPDualReal & temperature, - const FPDualReal & xnacl) const +FPADReal +BrineFluidProperties::rho_from_p_T_X(const FPADReal & pressure, + const FPADReal & temperature, + const FPADReal & xnacl) const { // The correlation requires the pressure in bar, not Pa. - FPDualReal pbar = pressure * 1.0e-5; - FPDualReal pbar2 = pbar * pbar; - FPDualReal pbar3 = pbar2 * pbar; + FPADReal pbar = pressure * 1.0e-5; + FPADReal pbar2 = pbar * pbar; + FPADReal pbar3 = pbar2 * pbar; // The correlation requires mole fraction - const FPDualReal Xnacl = massFractionToMoleFraction(xnacl); - - const FPDualReal n11 = -54.2958 - 45.7623 * std::exp(-9.44785e-4 * pbar); - const FPDualReal n21 = -2.6142 - 2.39092e-4 * pbar; - const FPDualReal n22 = 0.0356828 + 4.37235e-6 * pbar + 2.0566e-9 * pbar2; - const FPDualReal n1x1 = 330.47 + 0.942876 * std::sqrt(pbar) + 0.0817193 * pbar - - 2.47556e-8 * pbar2 + 3.45052e-10 * pbar3; - const FPDualReal n2x1 = -0.0370751 + 0.00237723 * std::sqrt(pbar) + 5.42049e-5 * pbar + - 5.84709e-9 * pbar2 - 5.99373e-13 * pbar3; - const FPDualReal n12 = -n1x1 - n11; - const FPDualReal n20 = 1.0 - n21 * std::sqrt(n22); - const FPDualReal n23 = n2x1 - n20 - n21 * std::sqrt(1.0 + n22); + const FPADReal Xnacl = massFractionToMoleFraction(xnacl); + + const FPADReal n11 = -54.2958 - 45.7623 * std::exp(-9.44785e-4 * pbar); + const FPADReal n21 = -2.6142 - 2.39092e-4 * pbar; + const FPADReal n22 = 0.0356828 + 4.37235e-6 * pbar + 2.0566e-9 * pbar2; + const FPADReal n1x1 = 330.47 + 0.942876 * std::sqrt(pbar) + 0.0817193 * pbar - + 2.47556e-8 * pbar2 + 3.45052e-10 * pbar3; + const FPADReal n2x1 = -0.0370751 + 0.00237723 * std::sqrt(pbar) + 5.42049e-5 * pbar + + 5.84709e-9 * pbar2 - 5.99373e-13 * pbar3; + const FPADReal n12 = -n1x1 - n11; + const FPADReal n20 = 1.0 - n21 * std::sqrt(n22); + const FPADReal n23 = n2x1 - n20 - n21 * std::sqrt(1.0 + n22); // The temperature Tv where the brine has the same molar volume as pure water // Note: correlation uses temperature in Celcius - const FPDualReal n1 = n1x1 + n11 * (1.0 - Xnacl) + n12 * (1.0 - Xnacl) * (1.0 - Xnacl); - const FPDualReal n2 = n20 + n21 * std::sqrt(Xnacl + n22) + n23 * Xnacl; - const FPDualReal Tv = n1 + n2 * (temperature - _T_c2k); + const FPADReal n1 = n1x1 + n11 * (1.0 - Xnacl) + n12 * (1.0 - Xnacl) * (1.0 - Xnacl); + const FPADReal n2 = n20 + n21 * std::sqrt(Xnacl + n22) + n23 * Xnacl; + const FPADReal Tv = n1 + n2 * (temperature - _T_c2k); // The density of water at temperature Tv // Note: convert Tv to Kelvin to calculate water density - FPDualReal water_density; + FPADReal water_density; if (_water_fp_derivs) { Real rho, drho_dp, drho_dT; @@ -170,12 +170,12 @@ Real BrineFluidProperties::rho_from_p_T_X(Real pressure, Real temperature, Real xnacl) const { // Initialise the AD value (no derivatives required) - FPDualReal p = pressure; - FPDualReal T = temperature; - FPDualReal x = xnacl; + FPADReal p = pressure; + FPADReal T = temperature; + FPADReal x = xnacl; _water_fp_derivs = false; - FPDualReal ad_rho = this->rho_from_p_T_X(p, T, x); + FPADReal ad_rho = this->rho_from_p_T_X(p, T, x); return ad_rho.value(); } @@ -190,15 +190,15 @@ BrineFluidProperties::rho_from_p_T_X(Real pressure, Real & drho_dx) const { // Initialise the AD value and derivatives - FPDualReal p = pressure; + FPADReal p = pressure; Moose::derivInsert(p.derivatives(), 0, 1.0); - FPDualReal T = temperature; + FPADReal T = temperature; Moose::derivInsert(T.derivatives(), 1, 1.0); - FPDualReal x = xnacl; + FPADReal x = xnacl; Moose::derivInsert(x.derivatives(), 2, 1.0); _water_fp_derivs = true; - FPDualReal ad_rho = this->rho_from_p_T_X(p, T, x); + FPADReal ad_rho = this->rho_from_p_T_X(p, T, x); rho = ad_rho.value(); drho_dp = ad_rho.derivatives()[0]; @@ -259,19 +259,19 @@ BrineFluidProperties::mu_from_p_T_X(Real pressure, dmu_dT = da_dT * muw + a * dmuw_dT; } -FPDualReal -BrineFluidProperties::h_from_p_T_X(const FPDualReal & pressure, - const FPDualReal & temperature, - const FPDualReal & xnacl) const +FPADReal +BrineFluidProperties::h_from_p_T_X(const FPADReal & pressure, + const FPADReal & temperature, + const FPADReal & xnacl) const { - FPDualReal q1, q2, q10, q11, q12, q20, q21, q22, q23, q1x1, q2x1, Th; + FPADReal q1, q2, q10, q11, q12, q20, q21, q22, q23, q1x1, q2x1, Th; // The correlation requires the pressure in bar, not Pa. - const FPDualReal pbar = pressure * 1.0e-5; - const FPDualReal pbar2 = pbar * pbar; + const FPADReal pbar = pressure * 1.0e-5; + const FPADReal pbar2 = pbar * pbar; // The correlation requires mole fraction - const FPDualReal Xnacl = massFractionToMoleFraction(xnacl); + const FPADReal Xnacl = massFractionToMoleFraction(xnacl); q11 = -32.1724 + 0.0621255 * pbar; q21 = -1.69513 - 4.52781e-4 * pbar - 6.04279e-8 * pbar2; @@ -294,7 +294,7 @@ BrineFluidProperties::h_from_p_T_X(const FPDualReal & pressure, // The brine enthalpy is then given by the enthalpy of water at temperature Th // Note: water enthalpy requires temperature in Kelvin - FPDualReal enthalpy; + FPADReal enthalpy; if (_water_fp_derivs) { Real h, dh_dp, dh_dT; @@ -313,9 +313,9 @@ Real BrineFluidProperties::h_from_p_T_X(Real pressure, Real temperature, Real xnacl) const { // Initialise the AD value (no derivatives required) - FPDualReal p = pressure; - FPDualReal T = temperature; - FPDualReal x = xnacl; + FPADReal p = pressure; + FPADReal T = temperature; + FPADReal x = xnacl; _water_fp_derivs = false; return h_from_p_T_X(p, T, x).value(); @@ -331,15 +331,15 @@ BrineFluidProperties::h_from_p_T_X(Real pressure, Real & dh_dx) const { // Initialise the AD value and derivatives - FPDualReal p = pressure; + FPADReal p = pressure; Moose::derivInsert(p.derivatives(), 0, 1.0); - FPDualReal T = temperature; + FPADReal T = temperature; Moose::derivInsert(T.derivatives(), 1, 1.0); - FPDualReal x = xnacl; + FPADReal x = xnacl; Moose::derivInsert(x.derivatives(), 2, 1.0); _water_fp_derivs = true; - FPDualReal ad_h = h_from_p_T_X(p, T, x); + FPADReal ad_h = h_from_p_T_X(p, T, x); h = ad_h.value(); dh_dp = ad_h.derivatives()[0]; @@ -384,13 +384,13 @@ BrineFluidProperties::cp_from_p_T_X(Real pressure, Real temperature, Real xnacl) return q2 * _water_fp->cp_from_p_T(pressure, Th + _T_c2k); } -FPDualReal -BrineFluidProperties::e_from_p_T_X(const FPDualReal & pressure, - const FPDualReal & temperature, - const FPDualReal & xnacl) const +FPADReal +BrineFluidProperties::e_from_p_T_X(const FPADReal & pressure, + const FPADReal & temperature, + const FPADReal & xnacl) const { - FPDualReal enthalpy = h_from_p_T_X(pressure, temperature, xnacl); - FPDualReal density = rho_from_p_T_X(pressure, temperature, xnacl); + FPADReal enthalpy = h_from_p_T_X(pressure, temperature, xnacl); + FPADReal density = rho_from_p_T_X(pressure, temperature, xnacl); return enthalpy - pressure / density; } @@ -414,15 +414,15 @@ BrineFluidProperties::e_from_p_T_X(Real pressure, Real & de_dx) const { // Initialise the AD value and derivatives - FPDualReal p = pressure; + FPADReal p = pressure; Moose::derivInsert(p.derivatives(), 0, 1.0); - FPDualReal T = temperature; + FPADReal T = temperature; Moose::derivInsert(T.derivatives(), 1, 1.0); - FPDualReal x = xnacl; + FPADReal x = xnacl; Moose::derivInsert(x.derivatives(), 2, 1.0); _water_fp_derivs = true; - FPDualReal ad_e = e_from_p_T_X(p, T, x); + FPADReal ad_e = e_from_p_T_X(p, T, x); e = ad_e.value(); de_dp = ad_e.derivatives()[0]; @@ -490,11 +490,11 @@ BrineFluidProperties::massFractionToMoleFraction(Real xnacl) const return xnacl * Mbrine / _Mnacl; } -FPDualReal -BrineFluidProperties::massFractionToMoleFraction(const FPDualReal & xnacl) const +FPADReal +BrineFluidProperties::massFractionToMoleFraction(const FPADReal & xnacl) const { // The average molar mass of brine from the mass fraction - FPDualReal Mbrine = molarMass(xnacl); + FPADReal Mbrine = molarMass(xnacl); // The mole fraction is then return xnacl * Mbrine / _Mnacl; } @@ -514,14 +514,14 @@ BrineFluidProperties::henryConstant(Real temperature, _water97_fp->henryConstant(temperature, coeffs, Kh, dKh_dT); } -DualReal -BrineFluidProperties::henryConstant(const DualReal & temperature, +ADReal +BrineFluidProperties::henryConstant(const ADReal & temperature, const std::vector & coeffs) const { Real Kh, dKh_dT; henryConstant(temperature.value(), coeffs, Kh, dKh_dT); - DualReal henry = Kh; + ADReal henry = Kh; henry.derivatives() = temperature.derivatives() * dKh_dT; return henry; diff --git a/modules/fluid_properties/src/fluidproperties/CaloricallyImperfectGas.C b/modules/fluid_properties/src/fluidproperties/CaloricallyImperfectGas.C index 4b627fe2e4b0..95bc725923d6 100644 --- a/modules/fluid_properties/src/fluidproperties/CaloricallyImperfectGas.C +++ b/modules/fluid_properties/src/fluidproperties/CaloricallyImperfectGas.C @@ -270,7 +270,7 @@ CaloricallyImperfectGas::p_from_v_e(const ADReal & v, const ADReal & e) const Real dxd2 = 0; p_from_v_e(raw1, raw2, x, dxd1, dxd2); - DualReal result = x; + ADReal result = x; result.derivatives() = v.derivatives() * dxd1 + e.derivatives() * dxd2; return result; } @@ -304,7 +304,7 @@ CaloricallyImperfectGas::T_from_v_e(const ADReal & v, const ADReal & e) const Real dxd2 = 0; T_from_v_e(raw1, raw2, x, dxd1, dxd2); - DualReal result = x; + ADReal result = x; result.derivatives() = v.derivatives() * dxd1 + e.derivatives() * dxd2; return result; } @@ -415,7 +415,7 @@ CaloricallyImperfectGas::cv_from_v_e(ADReal v, ADReal e) const Real dxd2 = 0; cv_from_v_e(raw1, raw2, x, dxd1, dxd2); - DualReal result = x; + ADReal result = x; result.derivatives() = v.derivatives() * dxd1 + e.derivatives() * dxd2; return result; } @@ -446,7 +446,7 @@ CaloricallyImperfectGas::gamma_from_v_e(ADReal v, ADReal e) const Real dxd2 = 0; gamma_from_v_e(raw1, raw2, x, dxd1, dxd2); - DualReal result = x; + ADReal result = x; result.derivatives() = v.derivatives() * dxd1 + e.derivatives() * dxd2; return result; } @@ -492,7 +492,7 @@ CaloricallyImperfectGas::gamma_from_p_T(ADReal p, ADReal T) const Real dxd1 = 0; Real dxd2 = 0; gamma_from_p_T(raw1, raw2, x, dxd1, dxd2); - DualReal result = x; + ADReal result = x; result.derivatives() = p.derivatives() * dxd1 + T.derivatives() * dxd2; return result; } @@ -630,11 +630,8 @@ CaloricallyImperfectGas::rho_from_p_T(const ADReal & p, const ADReal & T) const } void -CaloricallyImperfectGas::rho_from_p_T(const DualReal & p, - const DualReal & T, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const +CaloricallyImperfectGas::rho_from_p_T( + const ADReal & p, const ADReal & T, ADReal & rho, ADReal & drho_dp, ADReal & drho_dT) const { rho = rho_from_p_T(p, T); drho_dp = _molar_mass / (_R * T); @@ -700,7 +697,7 @@ CaloricallyImperfectGas::e_from_T_v(const ADReal & T, const ADReal & v) const Real dxd2 = 0; e_from_T_v(raw1, raw2, x, dxd1, dxd2); - DualReal result = x; + ADReal result = x; result.derivatives() = T.derivatives() * dxd1 + v.derivatives() * dxd2; return result; } @@ -796,7 +793,7 @@ CaloricallyImperfectGas::e_from_p_T(ADReal p, ADReal T) const Real dxd2 = 0; e_from_p_T(raw1, raw2, x, dxd1, dxd2); - DualReal result = x; + ADReal result = x; result.derivatives() = p.derivatives() * dxd1 + T.derivatives() * dxd2; return result; } diff --git a/modules/fluid_properties/src/fluidproperties/FlibeFluidProperties.C b/modules/fluid_properties/src/fluidproperties/FlibeFluidProperties.C index 637755900527..84493e7e32d0 100644 --- a/modules/fluid_properties/src/fluidproperties/FlibeFluidProperties.C +++ b/modules/fluid_properties/src/fluidproperties/FlibeFluidProperties.C @@ -73,12 +73,12 @@ FlibeFluidProperties::p_from_v_e(Real v, Real e, Real & p, Real & dp_dv, Real & void FlibeFluidProperties::p_from_v_e( - const DualReal & v, const DualReal & e, DualReal & p, DualReal & dp_dv, DualReal & dp_de) const + const ADReal & v, const ADReal & e, ADReal & p, ADReal & dp_dv, ADReal & dp_de) const { p = SinglePhaseFluidProperties::p_from_v_e(v, e); // chain rule, (dp_de)_v = (dp_dT)_v * (dT_de)_v - DualReal T, dT_dv, dT_de; + ADReal T, dT_dv, dT_de; T_from_v_e(v, e, T, dT_dv, dT_de); dp_de = _dp_dT_at_constant_v * dT_de; @@ -127,7 +127,7 @@ FlibeFluidProperties::T_from_v_e(Real v, Real e, Real & T, Real & dT_dv, Real & void FlibeFluidProperties::T_from_v_e( - const DualReal & v, const DualReal & e, DualReal & T, DualReal & dT_dv, DualReal & dT_de) const + const ADReal & v, const ADReal & e, ADReal & T, ADReal & dT_dv, ADReal & dT_de) const { T = SinglePhaseFluidProperties::T_from_v_e(v, e); @@ -175,11 +175,8 @@ FlibeFluidProperties::cv_from_v_e(Real v, Real e, Real & cv, Real & dcv_dv, Real } void -FlibeFluidProperties::cv_from_v_e(const DualReal & v, - const DualReal & e, - DualReal & cv, - DualReal & dcv_dv, - DualReal & dcv_de) const +FlibeFluidProperties::cv_from_v_e( + const ADReal & v, const ADReal & e, ADReal & cv, ADReal & dcv_dv, ADReal & dcv_de) const { cv = SinglePhaseFluidProperties::cv_from_v_e(v, e); dcv_dv = -_dp_dT_at_constant_v; @@ -216,19 +213,19 @@ FlibeFluidProperties::rho_from_p_T( } void -FlibeFluidProperties::rho_from_p_T(const DualReal & pressure, - const DualReal & temperature, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const +FlibeFluidProperties::rho_from_p_T(const ADReal & pressure, + const ADReal & temperature, + ADReal & rho, + ADReal & drho_dp, + ADReal & drho_dT) const { rho = SinglePhaseFluidProperties::rho_from_p_T(pressure, temperature); drho_dp = _drho_dp; drho_dT = _drho_dT; } -DualReal -FlibeFluidProperties::v_from_p_T(const DualReal & pressure, const DualReal & temperature) const +ADReal +FlibeFluidProperties::v_from_p_T(const ADReal & pressure, const ADReal & temperature) const { return 1.0 / (_drho_dT * temperature + _drho_dp * (pressure - _p_atm) + _c0); } diff --git a/modules/fluid_properties/src/fluidproperties/FlinakFluidProperties.C b/modules/fluid_properties/src/fluidproperties/FlinakFluidProperties.C index f3279ee6ccb1..3561b44a9ab5 100644 --- a/modules/fluid_properties/src/fluidproperties/FlinakFluidProperties.C +++ b/modules/fluid_properties/src/fluidproperties/FlinakFluidProperties.C @@ -73,12 +73,12 @@ FlinakFluidProperties::p_from_v_e(Real v, Real e, Real & p, Real & dp_dv, Real & void FlinakFluidProperties::p_from_v_e( - const DualReal & v, const DualReal & e, DualReal & p, DualReal & dp_dv, DualReal & dp_de) const + const ADReal & v, const ADReal & e, ADReal & p, ADReal & dp_dv, ADReal & dp_de) const { p = SinglePhaseFluidProperties::p_from_v_e(v, e); // chain rule, (dp_de)_v = (dp_dT)_v * (dT_de)_v - DualReal T, dT_dv, dT_de; + ADReal T, dT_dv, dT_de; T_from_v_e(v, e, T, dT_dv, dT_de); dp_de = _dp_dT_at_constant_v * dT_de; @@ -127,7 +127,7 @@ FlinakFluidProperties::T_from_v_e(Real v, Real e, Real & T, Real & dT_dv, Real & void FlinakFluidProperties::T_from_v_e( - const DualReal & v, const DualReal & e, DualReal & T, DualReal & dT_dv, DualReal & dT_de) const + const ADReal & v, const ADReal & e, ADReal & T, ADReal & dT_dv, ADReal & dT_de) const { T = SinglePhaseFluidProperties::T_from_v_e(v, e); @@ -182,11 +182,8 @@ FlinakFluidProperties::cv_from_v_e(Real v, Real e, Real & cv, Real & dcv_dv, Rea } void -FlinakFluidProperties::cv_from_v_e(const DualReal & v, - const DualReal & e, - DualReal & cv, - DualReal & dcv_dv, - DualReal & dcv_de) const +FlinakFluidProperties::cv_from_v_e( + const ADReal & v, const ADReal & e, ADReal & cv, ADReal & dcv_dv, ADReal & dcv_de) const { cv = SinglePhaseFluidProperties::cv_from_v_e(v, e); dcv_dv = -_dp_dT_at_constant_v; @@ -223,19 +220,19 @@ FlinakFluidProperties::rho_from_p_T( } void -FlinakFluidProperties::rho_from_p_T(const DualReal & pressure, - const DualReal & temperature, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const +FlinakFluidProperties::rho_from_p_T(const ADReal & pressure, + const ADReal & temperature, + ADReal & rho, + ADReal & drho_dp, + ADReal & drho_dT) const { rho = SinglePhaseFluidProperties::rho_from_p_T(pressure, temperature); drho_dp = _drho_dp; drho_dT = _drho_dT; } -DualReal -FlinakFluidProperties::v_from_p_T(const DualReal & pressure, const DualReal & temperature) const +ADReal +FlinakFluidProperties::v_from_p_T(const ADReal & pressure, const ADReal & temperature) const { return 1.0 / (_drho_dT * temperature + _drho_dp * (pressure - _p_atm) + _c0); } diff --git a/modules/fluid_properties/src/fluidproperties/HeliumFluidProperties.C b/modules/fluid_properties/src/fluidproperties/HeliumFluidProperties.C index e8c77aa210d9..4a1aa7cb7456 100644 --- a/modules/fluid_properties/src/fluidproperties/HeliumFluidProperties.C +++ b/modules/fluid_properties/src/fluidproperties/HeliumFluidProperties.C @@ -121,11 +121,11 @@ HeliumFluidProperties::p_from_v_e(Real v, Real e, Real & p, Real & dp_dv, Real & void HeliumFluidProperties::p_from_v_e( - const DualReal & v, const DualReal & e, DualReal & p, DualReal & dp_dv, DualReal & dp_de) const + const ADReal & v, const ADReal & e, ADReal & p, ADReal & dp_dv, ADReal & dp_de) const { p = p_from_v_e(v, e); - DualReal T, dT_dv, dT_de; + ADReal T, dT_dv, dT_de; T_from_v_e(v, e, T, dT_dv, dT_de); auto val = 48.14 * v - 0.4446 / std::pow(T, 0.2); @@ -203,7 +203,7 @@ HeliumFluidProperties::T_from_v_e(Real v, Real e, Real & T, Real & dT_dv, Real & void HeliumFluidProperties::T_from_v_e( - const DualReal & v, const DualReal & e, DualReal & T, DualReal & dT_dv, DualReal & dT_de) const + const ADReal & v, const ADReal & e, ADReal & T, ADReal & dT_dv, ADReal & dT_de) const { T = SinglePhaseFluidProperties::T_from_v_e(v, e); dT_dv = 0.0; @@ -232,17 +232,17 @@ HeliumFluidProperties::c_from_v_e(Real v, Real e) const void HeliumFluidProperties::c_from_v_e(Real v, Real e, Real & c, Real & dc_dv, Real & dc_de) const { - DualReal myv = v; + ADReal myv = v; Moose::derivInsert(myv.derivatives(), 0, 1); Moose::derivInsert(myv.derivatives(), 1, 0); - DualReal mye = e; + ADReal mye = e; Moose::derivInsert(mye.derivatives(), 0, 0); Moose::derivInsert(mye.derivatives(), 1, 1); auto p = SinglePhaseFluidProperties::p_from_v_e(myv, mye); auto T = SinglePhaseFluidProperties::T_from_v_e(myv, mye); - DualReal rho, drho_dp, drho_dT; + ADReal rho, drho_dp, drho_dT; rho_from_p_T(p, T, rho, drho_dp, drho_dT); auto cc = std::sqrt(-(p / rho / rho - _cv / drho_dT) / (_cv * drho_dp / drho_dT)); @@ -315,11 +315,11 @@ HeliumFluidProperties::rho_from_p_T( } void -HeliumFluidProperties::rho_from_p_T(const DualReal & pressure, - const DualReal & temperature, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const +HeliumFluidProperties::rho_from_p_T(const ADReal & pressure, + const ADReal & temperature, + ADReal & rho, + ADReal & drho_dp, + ADReal & drho_dT) const { rho = SinglePhaseFluidProperties::rho_from_p_T(pressure, temperature); auto val = 1.0 / (temperature + 0.4446e-5 * pressure / std::pow(temperature, 0.2)); diff --git a/modules/fluid_properties/src/fluidproperties/IdealGasFluidProperties.C b/modules/fluid_properties/src/fluidproperties/IdealGasFluidProperties.C index ab7d317bccf1..0ca80a690c84 100644 --- a/modules/fluid_properties/src/fluidproperties/IdealGasFluidProperties.C +++ b/modules/fluid_properties/src/fluidproperties/IdealGasFluidProperties.C @@ -90,7 +90,7 @@ IdealGasFluidProperties::p_from_v_e(Real v, Real e, Real & p, Real & dp_dv, Real void IdealGasFluidProperties::p_from_v_e( - const DualReal & v, const DualReal & e, DualReal & p, DualReal & dp_dv, DualReal & dp_de) const + const ADReal & v, const ADReal & e, ADReal & p, ADReal & dp_dv, ADReal & dp_de) const { p = p_from_v_e(v, e); dp_dv = -(_gamma - 1.0) * e / v / v; @@ -119,7 +119,7 @@ IdealGasFluidProperties::T_from_v_e(Real v, Real e, Real & T, Real & dT_dv, Real void IdealGasFluidProperties::T_from_v_e( - const DualReal & v, const DualReal & e, DualReal & T, DualReal & dT_dv, DualReal & dT_de) const + const ADReal & v, const ADReal & e, ADReal & T, ADReal & dT_dv, ADReal & dT_de) const { T = T_from_v_e(v, e); dT_dv = 0.0; @@ -392,11 +392,8 @@ IdealGasFluidProperties::rho_from_p_T(const ADReal & p, const ADReal & T) const } void -IdealGasFluidProperties::rho_from_p_T(const DualReal & p, - const DualReal & T, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const +IdealGasFluidProperties::rho_from_p_T( + const ADReal & p, const ADReal & T, ADReal & rho, ADReal & drho_dp, ADReal & drho_dT) const { rho = rho_from_p_T(p, T); drho_dp = _molar_mass / (_R * T); diff --git a/modules/fluid_properties/src/fluidproperties/LeadBismuthFluidProperties.C b/modules/fluid_properties/src/fluidproperties/LeadBismuthFluidProperties.C index ff3a6bae5f38..232be96f3587 100644 --- a/modules/fluid_properties/src/fluidproperties/LeadBismuthFluidProperties.C +++ b/modules/fluid_properties/src/fluidproperties/LeadBismuthFluidProperties.C @@ -52,10 +52,10 @@ LeadBismuthFluidProperties::c_from_v_e(Real v, Real e) const return 1855 - 0.212 * T; } -DualReal -LeadBismuthFluidProperties::c_from_v_e(const DualReal & v, const DualReal & e) const +ADReal +LeadBismuthFluidProperties::c_from_v_e(const ADReal & v, const ADReal & e) const { - DualReal T = SinglePhaseFluidProperties::T_from_v_e(v, e); + ADReal T = SinglePhaseFluidProperties::T_from_v_e(v, e); return 1855 - 0.212 * T; } @@ -217,11 +217,8 @@ LeadBismuthFluidProperties::rho_from_p_T( } void -LeadBismuthFluidProperties::rho_from_p_T(const DualReal & p, - const DualReal & T, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const +LeadBismuthFluidProperties::rho_from_p_T( + const ADReal & p, const ADReal & T, ADReal & rho, ADReal & drho_dp, ADReal & drho_dT) const { rho = SinglePhaseFluidProperties::rho_from_p_T(p, T); drho_dp = 0; diff --git a/modules/fluid_properties/src/fluidproperties/LeadFluidProperties.C b/modules/fluid_properties/src/fluidproperties/LeadFluidProperties.C index 5d73a176d90d..670cd42a41a4 100644 --- a/modules/fluid_properties/src/fluidproperties/LeadFluidProperties.C +++ b/modules/fluid_properties/src/fluidproperties/LeadFluidProperties.C @@ -52,10 +52,10 @@ LeadFluidProperties::c_from_v_e(Real v, Real e) const return 1953 - 0.246 * T; } -DualReal -LeadFluidProperties::c_from_v_e(const DualReal & v, const DualReal & e) const +ADReal +LeadFluidProperties::c_from_v_e(const ADReal & v, const ADReal & e) const { - DualReal T = SinglePhaseFluidProperties::T_from_v_e(v, e); + ADReal T = SinglePhaseFluidProperties::T_from_v_e(v, e); return 1953 - 0.246 * T; } @@ -125,11 +125,8 @@ LeadFluidProperties::rho_from_p_T(Real p, Real T, Real & rho, Real & drho_dp, Re } void -LeadFluidProperties::rho_from_p_T(const DualReal & p, - const DualReal & T, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const +LeadFluidProperties::rho_from_p_T( + const ADReal & p, const ADReal & T, ADReal & rho, ADReal & drho_dp, ADReal & drho_dT) const { rho = SinglePhaseFluidProperties::rho_from_p_T(p, T); drho_dp = 0; diff --git a/modules/fluid_properties/src/fluidproperties/MultiComponentFluidProperties.C b/modules/fluid_properties/src/fluidproperties/MultiComponentFluidProperties.C index e662f1e8a3c1..54c7f8bb68e7 100644 --- a/modules/fluid_properties/src/fluidproperties/MultiComponentFluidProperties.C +++ b/modules/fluid_properties/src/fluidproperties/MultiComponentFluidProperties.C @@ -39,7 +39,7 @@ MultiComponentFluidProperties::rho_mu_from_p_T_X( void MultiComponentFluidProperties::rho_mu_from_p_T_X( - DualReal pressure, DualReal temperature, DualReal xmass, DualReal & rho, DualReal & mu) const + ADReal pressure, ADReal temperature, ADReal xmass, ADReal & rho, ADReal & mu) const { rho = rho_from_p_T_X(pressure, temperature, xmass); mu = mu_from_p_T_X(pressure, temperature, xmass); diff --git a/modules/fluid_properties/src/fluidproperties/SimpleFluidProperties.C b/modules/fluid_properties/src/fluidproperties/SimpleFluidProperties.C index d159240bed3d..7cb3273e9532 100644 --- a/modules/fluid_properties/src/fluidproperties/SimpleFluidProperties.C +++ b/modules/fluid_properties/src/fluidproperties/SimpleFluidProperties.C @@ -245,11 +245,11 @@ SimpleFluidProperties::rho_from_p_T( } void -SimpleFluidProperties::rho_from_p_T(const DualReal & pressure, - const DualReal & temperature, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const +SimpleFluidProperties::rho_from_p_T(const ADReal & pressure, + const ADReal & temperature, + ADReal & rho, + ADReal & drho_dp, + ADReal & drho_dT) const { rho = SinglePhaseFluidProperties::rho_from_p_T(pressure, temperature); drho_dp = rho / _bulk_modulus; @@ -294,7 +294,7 @@ SimpleFluidProperties::T_from_v_e(Real v, Real e, Real & T, Real & dT_dv, Real & void SimpleFluidProperties::T_from_v_e( - const DualReal & v, const DualReal & e, DualReal & T, DualReal & dT_dv, DualReal & dT_de) const + const ADReal & v, const ADReal & e, ADReal & T, ADReal & dT_dv, ADReal & dT_de) const { T = SinglePhaseFluidProperties::T_from_v_e(v, e); dT_dv = 0.0; @@ -347,7 +347,7 @@ SimpleFluidProperties::p_from_v_e(Real v, Real e, Real & p, Real & dp_dv, Real & void SimpleFluidProperties::p_from_v_e( - const DualReal & v, const DualReal & e, DualReal & p, DualReal & dp_dv, DualReal & dp_de) const + const ADReal & v, const ADReal & e, ADReal & p, ADReal & dp_dv, ADReal & dp_de) const { p = SinglePhaseFluidProperties::p_from_v_e(v, e); dp_dv = -_bulk_modulus / v; diff --git a/modules/fluid_properties/src/fluidproperties/SinglePhaseFluidProperties.C b/modules/fluid_properties/src/fluidproperties/SinglePhaseFluidProperties.C index 397dfe27fd4c..c0256c7de918 100644 --- a/modules/fluid_properties/src/fluidproperties/SinglePhaseFluidProperties.C +++ b/modules/fluid_properties/src/fluidproperties/SinglePhaseFluidProperties.C @@ -365,8 +365,8 @@ SinglePhaseFluidProperties::vaporPressure(Real T, Real & p, Real & dp_dT) const p = vaporPressure(T); } -DualReal -SinglePhaseFluidProperties::vaporPressure(const DualReal & T) const +ADReal +SinglePhaseFluidProperties::vaporPressure(const ADReal & T) const { Real p = 0.0; Real temperature = T.value(); @@ -374,7 +374,7 @@ SinglePhaseFluidProperties::vaporPressure(const DualReal & T) const vaporPressure(temperature, p, dpdT); - DualReal result = p; + ADReal result = p; result.derivatives() = T.derivatives() * dpdT; return result; @@ -394,8 +394,8 @@ SinglePhaseFluidProperties::vaporTemperature(Real p, Real & T, Real & dT_dp) con T = vaporTemperature(p); } -DualReal -SinglePhaseFluidProperties::vaporTemperature(const DualReal & p) const +ADReal +SinglePhaseFluidProperties::vaporTemperature(const ADReal & p) const { Real T = 0.0; Real pressure = p.value(); @@ -403,7 +403,7 @@ SinglePhaseFluidProperties::vaporTemperature(const DualReal & p) const vaporTemperature(pressure, T, dTdp); - DualReal result = T; + ADReal result = T; result.derivatives() = p.derivatives() * dTdp; return result; @@ -445,10 +445,10 @@ SinglePhaseFluidProperties::rho_mu_from_p_T(Real p, } void -SinglePhaseFluidProperties::rho_mu_from_p_T(const DualReal & p, - const DualReal & T, - DualReal & rho, - DualReal & mu) const +SinglePhaseFluidProperties::rho_mu_from_p_T(const ADReal & p, + const ADReal & T, + ADReal & rho, + ADReal & mu) const { rho = rho_from_p_T(p, T); mu = mu_from_p_T(p, T); diff --git a/modules/fluid_properties/src/fluidproperties/SodiumSaturationFluidProperties.C b/modules/fluid_properties/src/fluidproperties/SodiumSaturationFluidProperties.C index e27ca0f81fce..2b0cb816f7bc 100644 --- a/modules/fluid_properties/src/fluidproperties/SodiumSaturationFluidProperties.C +++ b/modules/fluid_properties/src/fluidproperties/SodiumSaturationFluidProperties.C @@ -52,11 +52,11 @@ SodiumSaturationFluidProperties::rho_from_p_T( } void -SodiumSaturationFluidProperties::rho_from_p_T(const DualReal & pressure, - const DualReal & temperature, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const +SodiumSaturationFluidProperties::rho_from_p_T(const ADReal & pressure, + const ADReal & temperature, + ADReal & rho, + ADReal & drho_dp, + ADReal & drho_dT) const { rho = SinglePhaseFluidProperties::rho_from_p_T(pressure, temperature); drho_dp = 0.0; diff --git a/modules/fluid_properties/src/fluidproperties/TemperaturePressureFunctionFluidProperties.C b/modules/fluid_properties/src/fluidproperties/TemperaturePressureFunctionFluidProperties.C index 764487ec0d68..906968c4957e 100644 --- a/modules/fluid_properties/src/fluidproperties/TemperaturePressureFunctionFluidProperties.C +++ b/modules/fluid_properties/src/fluidproperties/TemperaturePressureFunctionFluidProperties.C @@ -184,11 +184,11 @@ TemperaturePressureFunctionFluidProperties::rho_from_p_T( } void -TemperaturePressureFunctionFluidProperties::rho_from_p_T(const DualReal & pressure, - const DualReal & temperature, - DualReal & rho, - DualReal & drho_dp, - DualReal & drho_dT) const +TemperaturePressureFunctionFluidProperties::rho_from_p_T(const ADReal & pressure, + const ADReal & temperature, + ADReal & rho, + ADReal & drho_dp, + ADReal & drho_dT) const { rho = rho_from_p_T(pressure, temperature); const ADRealVectorValue grad_function = diff --git a/modules/fluid_properties/src/fluidproperties/TwoPhaseFluidProperties.C b/modules/fluid_properties/src/fluidproperties/TwoPhaseFluidProperties.C index 7cd44476ca3d..ddc5d2e1f2f9 100644 --- a/modules/fluid_properties/src/fluidproperties/TwoPhaseFluidProperties.C +++ b/modules/fluid_properties/src/fluidproperties/TwoPhaseFluidProperties.C @@ -64,26 +64,26 @@ TwoPhaseFluidProperties::T_triple() const mooseError(__PRETTY_FUNCTION__, " is not implemented."); } -DualReal -TwoPhaseFluidProperties::T_sat(const DualReal & p) const +ADReal +TwoPhaseFluidProperties::T_sat(const ADReal & p) const { const Real p_real = p.value(); const Real T_sat_real = T_sat(p_real); const Real dT_sat_dp_real = dT_sat_dp(p_real); - DualReal T_sat = T_sat_real; + ADReal T_sat = T_sat_real; T_sat.derivatives() = p.derivatives() * dT_sat_dp_real; return T_sat; } -DualReal -TwoPhaseFluidProperties::p_sat(const DualReal & T) const +ADReal +TwoPhaseFluidProperties::p_sat(const ADReal & T) const { const Real T_real = T.value(); const Real p_sat_real = p_sat(T_real); const Real dp_sat_dT_real = 1.0 / dT_sat_dp(p_sat_real); - DualReal p_sat = p_sat_real; + ADReal p_sat = p_sat_real; p_sat.derivatives() = T.derivatives() * dp_sat_dT_real; return p_sat; } @@ -94,8 +94,8 @@ TwoPhaseFluidProperties::h_lat(Real p, Real T) const return _fp_vapor->h_from_p_T(p, T) - _fp_liquid->h_from_p_T(p, T); } -DualReal -TwoPhaseFluidProperties::h_lat(const DualReal & p, const DualReal & T) const +ADReal +TwoPhaseFluidProperties::h_lat(const ADReal & p, const ADReal & T) const { return _fp_vapor->h_from_p_T(p, T) - _fp_liquid->h_from_p_T(p, T); } @@ -111,14 +111,14 @@ Real TwoPhaseFluidProperties::sigma_from_T(Real /*T*/) const mooseError(__PRETTY_FUNCTION__, " is not implemented."); } -DualReal -TwoPhaseFluidProperties::sigma_from_T(const DualReal & T) const +ADReal +TwoPhaseFluidProperties::sigma_from_T(const ADReal & T) const { const Real T_real = T.value(); const Real sigma_real = sigma_from_T(T_real); const Real dsigma_dT = dsigma_dT_from_T(T_real); - DualReal sigma = sigma_real; + ADReal sigma = sigma_real; sigma.derivatives() = T.derivatives() * dsigma_dT; return sigma; } diff --git a/modules/fluid_properties/src/fluidproperties/TwoPhaseFluidPropertiesIndependent.C b/modules/fluid_properties/src/fluidproperties/TwoPhaseFluidPropertiesIndependent.C index b6c1faab6de9..3063242f5863 100644 --- a/modules/fluid_properties/src/fluidproperties/TwoPhaseFluidPropertiesIndependent.C +++ b/modules/fluid_properties/src/fluidproperties/TwoPhaseFluidPropertiesIndependent.C @@ -68,8 +68,8 @@ Real TwoPhaseFluidPropertiesIndependent::T_sat(Real) const return getTwoPhaseInterfaceDummyValue(); } -DualReal -TwoPhaseFluidPropertiesIndependent::T_sat(const DualReal &) const +ADReal +TwoPhaseFluidPropertiesIndependent::T_sat(const ADReal &) const { return getTwoPhaseInterfaceDummyValue(); } @@ -79,8 +79,8 @@ Real TwoPhaseFluidPropertiesIndependent::p_sat(Real) const return getTwoPhaseInterfaceDummyValue(); } -DualReal -TwoPhaseFluidPropertiesIndependent::p_sat(const DualReal &) const +ADReal +TwoPhaseFluidPropertiesIndependent::p_sat(const ADReal &) const { return getTwoPhaseInterfaceDummyValue(); } @@ -101,8 +101,8 @@ Real TwoPhaseFluidPropertiesIndependent::sigma_from_T(Real) const return getTwoPhaseInterfaceDummyValue(); } -DualReal -TwoPhaseFluidPropertiesIndependent::sigma_from_T(const DualReal &) const +ADReal +TwoPhaseFluidPropertiesIndependent::sigma_from_T(const ADReal &) const { return getTwoPhaseInterfaceDummyValue(); } diff --git a/modules/fluid_properties/src/fluidproperties/Water97FluidProperties.C b/modules/fluid_properties/src/fluidproperties/Water97FluidProperties.C index 09c67fb6f91a..e7a9fd95a386 100644 --- a/modules/fluid_properties/src/fluidproperties/Water97FluidProperties.C +++ b/modules/fluid_properties/src/fluidproperties/Water97FluidProperties.C @@ -508,8 +508,8 @@ Water97FluidProperties::vaporPressure(Real temperature) const return p * 1.e6; } -FPDualReal -Water97FluidProperties::vaporTemperature_ad(const FPDualReal & pressure) const +FPADReal +Water97FluidProperties::vaporTemperature_ad(const FPADReal & pressure) const { // Check whether the input pressure is within the region of validity of this equation. // Valid for 611.213 Pa <= p <= 22.064 MPa @@ -518,12 +518,12 @@ Water97FluidProperties::vaporTemperature_ad(const FPDualReal & pressure) const pressure.value(), " is outside range 611.213 Pa <= p <= 22.064 MPa"); - const FPDualReal beta = std::pow(pressure / 1.e6, 0.25); - const FPDualReal beta2 = beta * beta; - const FPDualReal e = beta2 + _n4[2] * beta + _n4[5]; - const FPDualReal f = _n4[0] * beta2 + _n4[3] * beta + _n4[6]; - const FPDualReal g = _n4[1] * beta2 + _n4[4] * beta + _n4[7]; - const FPDualReal d = 2.0 * g / (-f - std::sqrt(f * f - 4.0 * e * g)); + const FPADReal beta = std::pow(pressure / 1.e6, 0.25); + const FPADReal beta2 = beta * beta; + const FPADReal e = beta2 + _n4[2] * beta + _n4[5]; + const FPADReal f = _n4[0] * beta2 + _n4[3] * beta + _n4[6]; + const FPADReal g = _n4[1] * beta2 + _n4[4] * beta + _n4[7]; + const FPADReal d = 2.0 * g / (-f - std::sqrt(f * f - 4.0 * e * g)); return (_n4[9] + d - std::sqrt((_n4[9] + d) * (_n4[9] + d) - 4.0 * (_n4[8] + _n4[9] * d))) / 2.0; } @@ -531,7 +531,7 @@ Water97FluidProperties::vaporTemperature_ad(const FPDualReal & pressure) const Real Water97FluidProperties::vaporTemperature(Real pressure) const { - const FPDualReal p = pressure; + const FPADReal p = pressure; return vaporTemperature_ad(p).value(); } @@ -539,10 +539,10 @@ Water97FluidProperties::vaporTemperature(Real pressure) const void Water97FluidProperties::vaporTemperature(Real pressure, Real & Tsat, Real & dTsat_dp) const { - FPDualReal p = pressure; + FPADReal p = pressure; Moose::derivInsert(p.derivatives(), 0, 1.0); - const FPDualReal T = vaporTemperature_ad(p); + const FPADReal T = vaporTemperature_ad(p); Tsat = T.value(); dTsat_dp = T.derivatives()[0]; @@ -679,8 +679,8 @@ Water97FluidProperties::b2bc(Real pressure) const Real Water97FluidProperties::T_from_p_h(Real pressure, Real enthalpy) const { - const FPDualReal p = pressure; - const FPDualReal h = enthalpy; + const FPADReal p = pressure; + const FPADReal h = enthalpy; return T_from_p_h_ad(p, h).value(); } @@ -689,23 +689,22 @@ void Water97FluidProperties::T_from_p_h( Real pressure, Real enthalpy, Real & temperature, Real & dT_dp, Real & dT_dh) const { - FPDualReal p = pressure; + FPADReal p = pressure; Moose::derivInsert(p.derivatives(), 0, 1.0); - FPDualReal h = enthalpy; + FPADReal h = enthalpy; Moose::derivInsert(h.derivatives(), 1, 1.0); - const FPDualReal T = T_from_p_h_ad(p, h); + const FPADReal T = T_from_p_h_ad(p, h); temperature = T.value(); dT_dp = T.derivatives()[0]; dT_dh = T.derivatives()[1]; } -FPDualReal -Water97FluidProperties::T_from_p_h_ad(const FPDualReal & pressure, - const FPDualReal & enthalpy) const +FPADReal +Water97FluidProperties::T_from_p_h_ad(const FPADReal & pressure, const FPADReal & enthalpy) const { - FPDualReal temperature = 0.0; + FPADReal temperature = 0.0; // Determine which region the point is in const unsigned int region = inRegionPH(pressure.value(), enthalpy.value()); @@ -753,13 +752,13 @@ Water97FluidProperties::T_from_p_h_ad(const FPDualReal & pressure, return temperature; } -FPDualReal -Water97FluidProperties::temperature_from_ph1(const FPDualReal & pressure, - const FPDualReal & enthalpy) const +FPADReal +Water97FluidProperties::temperature_from_ph1(const FPADReal & pressure, + const FPADReal & enthalpy) const { - const FPDualReal pi = pressure / 1.0e6; - const FPDualReal eta = enthalpy / 2500.0e3; - FPDualReal sum = 0.0; + const FPADReal pi = pressure / 1.0e6; + const FPADReal eta = enthalpy / 2500.0e3; + FPADReal sum = 0.0; for (std::size_t i = 0; i < _nph1.size(); ++i) sum += _nph1[i] * std::pow(pi, _Iph1[i]) * std::pow(eta + 1.0, _Jph1[i]); @@ -767,13 +766,13 @@ Water97FluidProperties::temperature_from_ph1(const FPDualReal & pressure, return sum; } -FPDualReal -Water97FluidProperties::temperature_from_ph2a(const FPDualReal & pressure, - const FPDualReal & enthalpy) const +FPADReal +Water97FluidProperties::temperature_from_ph2a(const FPADReal & pressure, + const FPADReal & enthalpy) const { - const FPDualReal pi = pressure / 1.0e6; - const FPDualReal eta = enthalpy / 2000.0e3; - FPDualReal sum = 0.0; + const FPADReal pi = pressure / 1.0e6; + const FPADReal eta = enthalpy / 2000.0e3; + FPADReal sum = 0.0; // Factor out the negative in std::pow(eta - 2.1, _Jph2a[i]) to avoid fpe in dbg (see #13163) const Real sgn = MathUtils::sign(eta.value() - 2.1); @@ -785,13 +784,13 @@ Water97FluidProperties::temperature_from_ph2a(const FPDualReal & pressure, return sum; } -FPDualReal -Water97FluidProperties::temperature_from_ph2b(const FPDualReal & pressure, - const FPDualReal & enthalpy) const +FPADReal +Water97FluidProperties::temperature_from_ph2b(const FPADReal & pressure, + const FPADReal & enthalpy) const { - const FPDualReal pi = pressure / 1.0e6; - const FPDualReal eta = enthalpy / 2000.0e3; - FPDualReal sum = 0.0; + const FPADReal pi = pressure / 1.0e6; + const FPADReal eta = enthalpy / 2000.0e3; + FPADReal sum = 0.0; // Factor out the negatives in std::pow(pi - 2.0, _Iph2b[i])* std::pow(eta - 2.6, _Jph2b[i]) // to avoid fpe in dbg (see #13163) @@ -805,13 +804,13 @@ Water97FluidProperties::temperature_from_ph2b(const FPDualReal & pressure, return sum; } -FPDualReal -Water97FluidProperties::temperature_from_ph2c(const FPDualReal & pressure, - const FPDualReal & enthalpy) const +FPADReal +Water97FluidProperties::temperature_from_ph2c(const FPADReal & pressure, + const FPADReal & enthalpy) const { - const FPDualReal pi = pressure / 1.0e6; - const FPDualReal eta = enthalpy / 2000.0e3; - FPDualReal sum = 0.0; + const FPADReal pi = pressure / 1.0e6; + const FPADReal eta = enthalpy / 2000.0e3; + FPADReal sum = 0.0; // Factor out the negative in std::pow(eta - 1.8, _Jph2c[i]) to avoid fpe in dbg (see #13163) const Real sgn = MathUtils::sign(eta.value() - 1.8); @@ -838,13 +837,13 @@ Water97FluidProperties::b3ab(Real pressure) const return eta * 1.0e3; } -FPDualReal -Water97FluidProperties::temperature_from_ph3a(const FPDualReal & pressure, - const FPDualReal & enthalpy) const +FPADReal +Water97FluidProperties::temperature_from_ph3a(const FPADReal & pressure, + const FPADReal & enthalpy) const { - const FPDualReal pi = pressure / 100.0e6; - const FPDualReal eta = enthalpy / 2300.0e3; - FPDualReal sum = 0.0; + const FPADReal pi = pressure / 100.0e6; + const FPADReal eta = enthalpy / 2300.0e3; + FPADReal sum = 0.0; for (std::size_t i = 0; i < _nph3a.size(); ++i) sum += _nph3a[i] * std::pow(pi + 0.24, _Iph3a[i]) * std::pow(eta - 0.615, _Jph3a[i]); @@ -852,13 +851,13 @@ Water97FluidProperties::temperature_from_ph3a(const FPDualReal & pressure, return sum * 760.0; } -FPDualReal -Water97FluidProperties::temperature_from_ph3b(const FPDualReal & pressure, - const FPDualReal & enthalpy) const +FPADReal +Water97FluidProperties::temperature_from_ph3b(const FPADReal & pressure, + const FPADReal & enthalpy) const { - const FPDualReal pi = pressure / 100.0e6; - const FPDualReal eta = enthalpy / 2800.0e3; - FPDualReal sum = 0.0; + const FPADReal pi = pressure / 100.0e6; + const FPADReal eta = enthalpy / 2800.0e3; + FPADReal sum = 0.0; for (std::size_t i = 0; i < _nph3b.size(); ++i) sum += _nph3b[i] * std::pow(pi + 0.298, _Iph3b[i]) * std::pow(eta - 0.72, _Jph3b[i]); @@ -935,8 +934,8 @@ Water97FluidProperties::henryConstant(Real temperature, dKh_dT = (p * dlnkh_dT + dp_dT) * std::exp(lnkh); } -DualReal -Water97FluidProperties::henryConstant(const DualReal & temperature, +ADReal +Water97FluidProperties::henryConstant(const ADReal & temperature, const std::vector & coeffs) const { const Real T = temperature.value(); @@ -944,7 +943,7 @@ Water97FluidProperties::henryConstant(const DualReal & temperature, Real dKh_dT_real = 0.0; henryConstant(T, coeffs, Kh_real, dKh_dT_real); - DualReal Kh = Kh_real; + ADReal Kh = Kh_real; Kh.derivatives() = temperature.derivatives() * dKh_dT_real; return Kh; diff --git a/modules/fluid_properties/src/utils/DimensionlessFlowNumbers.C b/modules/fluid_properties/src/utils/DimensionlessFlowNumbers.C index 00703ead0e36..3b15af851bfa 100644 --- a/modules/fluid_properties/src/utils/DimensionlessFlowNumbers.C +++ b/modules/fluid_properties/src/utils/DimensionlessFlowNumbers.C @@ -9,8 +9,6 @@ #include "DimensionlessFlowNumbers.h" -#include "DualRealOps.h" - namespace fp { @@ -20,8 +18,8 @@ reynolds(Real rho, Real vel, Real L, Real mu) return rho * std::fabs(vel) * L / mu; } -DualReal -reynolds(DualReal rho, DualReal vel, DualReal L, DualReal mu) +ADReal +reynolds(ADReal rho, ADReal vel, ADReal L, ADReal mu) { return rho * std::fabs(vel) * L / mu; } @@ -32,8 +30,8 @@ prandtl(Real cp, Real mu, Real k) return cp * mu / k; } -DualReal -prandtl(DualReal cp, DualReal mu, DualReal k) +ADReal +prandtl(ADReal cp, ADReal mu, ADReal k) { return cp * mu / k; } @@ -45,14 +43,14 @@ grashof(Real beta, Real T_s, Real T_bulk, Real L, Real rho, Real mu, Real gravit (mu * mu); } -DualReal -grashof(DualReal beta, - DualReal T_s, - DualReal T_bulk, - DualReal L, - DualReal rho, - DualReal mu, - DualReal gravity_magnitude) +ADReal +grashof(ADReal beta, + ADReal T_s, + ADReal T_bulk, + ADReal L, + ADReal rho, + ADReal mu, + ADReal gravity_magnitude) { return gravity_magnitude * beta * std::abs(T_s - T_bulk) * std::pow(L, 3) * (rho * rho) / (mu * mu); @@ -64,8 +62,8 @@ laplace(Real sigma, Real rho, Real L, Real mu) return sigma * rho * L / (mu * mu); } -DualReal -laplace(DualReal sigma, DualReal rho, DualReal L, DualReal mu) +ADReal +laplace(ADReal sigma, ADReal rho, ADReal L, ADReal mu) { return sigma * rho * L / (mu * mu); } @@ -76,8 +74,8 @@ thermalDiffusivity(Real k, Real rho, Real cp) return k / (rho * cp); } -DualReal -thermalDiffusivity(DualReal k, DualReal rho, DualReal cp) +ADReal +thermalDiffusivity(ADReal k, ADReal rho, ADReal cp) { return k / (rho * cp); } @@ -88,8 +86,8 @@ peclet(Real vel, Real L, Real diffusivity) return std::fabs(vel) * L / diffusivity; } -DualReal -peclet(DualReal vel, DualReal L, DualReal diffusivity) +ADReal +peclet(ADReal vel, ADReal L, ADReal diffusivity) { return std::fabs(vel) * L / diffusivity; } diff --git a/modules/fluid_properties/unit/src/ADFluidPropsTest.C b/modules/fluid_properties/unit/src/ADFluidPropsTest.C index f379cff02e28..ba2689f6807b 100644 --- a/modules/fluid_properties/unit/src/ADFluidPropsTest.C +++ b/modules/fluid_properties/unit/src/ADFluidPropsTest.C @@ -8,7 +8,7 @@ //* https://www.gnu.org/licenses/lgpl-2.1.html #include "ADFluidPropsTest.h" -#include "DualReal.h" +#include "ADReal.h" #include "Moose.h" TEST_F(ADFluidPropsTest, ad_basic) @@ -30,8 +30,8 @@ TEST_F(ADFluidPropsTest, ad_basic) Moose::derivInsert(dedx, 1, 0); Moose::derivInsert(dedx, 2, 2); - DualReal v_ad(v, dvdx); - DualReal e_ad(e, dedx); + ADReal v_ad(v, dvdx); + ADReal e_ad(e, dedx); auto p_ad = _fp->p_from_v_e(v_ad, e_ad); EXPECT_DOUBLE_EQ(p, p_ad.value()); @@ -54,8 +54,8 @@ TEST_F(ADFluidPropsTest, ad_two_phase) Moose::derivInsert(dTdU, 1, 0); Moose::derivInsert(dTdU, 2, 2); - const DualReal p_ad(p, dpdU); - const DualReal T_ad(T, dTdU); + const ADReal p_ad(p, dpdU); + const ADReal T_ad(T, dTdU); const auto & fp_2phase = buildTwoPhaseFluidProperties(); const auto & fp_liquid = _fe_problem->getUserObject(fp_2phase.getLiquidName()); @@ -78,7 +78,7 @@ TEST_F(ADFluidPropsTest, ad_two_phase) const Real dh_lat_dp = dh_vapor_dp - dh_liquid_dp; const Real dh_lat_dT = dh_vapor_dT - dh_liquid_dT; - const DualReal h_lat_ad = fp_2phase.h_lat(p_ad, T_ad); + const ADReal h_lat_ad = fp_2phase.h_lat(p_ad, T_ad); EXPECT_DOUBLE_EQ(h_lat, h_lat_ad.value()); for (size_t i = 0; i < 3; i++) @@ -88,7 +88,7 @@ TEST_F(ADFluidPropsTest, ad_two_phase) const Real sigma = fp_2phase.sigma_from_T(T); const Real dsigma_dT = fp_2phase.dsigma_dT_from_T(T); - const DualReal sigma_ad = fp_2phase.sigma_from_T(T_ad); + const ADReal sigma_ad = fp_2phase.sigma_from_T(T_ad); EXPECT_DOUBLE_EQ(sigma, sigma_ad.value()); for (size_t i = 0; i < 3; i++) @@ -98,7 +98,7 @@ TEST_F(ADFluidPropsTest, ad_two_phase) const Real T_sat = fp_2phase.T_sat(p); const Real dT_sat_dp = fp_2phase.dT_sat_dp(p); - const DualReal T_sat_ad = fp_2phase.T_sat(p_ad); + const ADReal T_sat_ad = fp_2phase.T_sat(p_ad); EXPECT_DOUBLE_EQ(T_sat, T_sat_ad.value()); for (size_t i = 0; i < 3; i++) @@ -108,7 +108,7 @@ TEST_F(ADFluidPropsTest, ad_two_phase) const Real p_sat = fp_2phase.p_sat(T); const Real dp_sat_dT = 1.0 / fp_2phase.dT_sat_dp(p_sat); - const DualReal p_sat_ad = fp_2phase.p_sat(T_ad); + const ADReal p_sat_ad = fp_2phase.p_sat(T_ad); EXPECT_DOUBLE_EQ(p_sat, p_sat_ad.value()); for (size_t i = 0; i < 3; i++) @@ -117,8 +117,8 @@ TEST_F(ADFluidPropsTest, ad_two_phase) TEST_F(ADFluidPropsTest, error_imperfect_jacobian) { - DualReal v = .7; - DualReal e = 214000; + ADReal v = .7; + ADReal e = 214000; // This throws because g_from_v_e has no derivatives version implemented: EXPECT_THROW(_fp->g_from_v_e(v, e), std::runtime_error); diff --git a/modules/fluid_properties/unit/src/TabulatedBicubicFluidPropertiesTest.C b/modules/fluid_properties/unit/src/TabulatedBicubicFluidPropertiesTest.C index 2e701268e77d..92ca17944924 100644 --- a/modules/fluid_properties/unit/src/TabulatedBicubicFluidPropertiesTest.C +++ b/modules/fluid_properties/unit/src/TabulatedBicubicFluidPropertiesTest.C @@ -328,9 +328,9 @@ TEST_F(TabulatedBicubicFluidPropertiesTest, fromFileVE) Moose::derivInsert(dedx, 0, 0); Moose::derivInsert(dedx, 1, 1); - DualReal v_ad(v, dvdx); - DualReal e_ad(e, dedx); - DualReal p_ad = _tab_fp_ve->p_from_v_e(v_ad, e_ad); + ADReal v_ad(v, dvdx); + ADReal e_ad(e, dedx); + ADReal p_ad = _tab_fp_ve->p_from_v_e(v_ad, e_ad); Real pp, dp_dv, dp_de; _tab_fp_ve->p_from_v_e(v, e, pp, dp_dv, dp_de); @@ -351,9 +351,9 @@ TEST_F(TabulatedBicubicFluidPropertiesTest, fromFileVE) Moose::derivInsert(dedx, 0, 0); Moose::derivInsert(dedx, 1, 1); - DualReal v_ad(v, dvdx); - DualReal e_ad(e, dedx); - DualReal T_ad = _tab_fp_ve->T_from_v_e(v_ad, e_ad); + ADReal v_ad(v, dvdx); + ADReal e_ad(e, dedx); + ADReal T_ad = _tab_fp_ve->T_from_v_e(v_ad, e_ad); Real TT, dT_dv, dT_de; _tab_fp_ve->T_from_v_e(v, e, TT, dT_dv, dT_de); diff --git a/modules/fluid_properties/unit/src/Water97FluidPropertiesTest.C b/modules/fluid_properties/unit/src/Water97FluidPropertiesTest.C index 1bad5ca7dd38..830ea52c04eb 100644 --- a/modules/fluid_properties/unit/src/Water97FluidPropertiesTest.C +++ b/modules/fluid_properties/unit/src/Water97FluidPropertiesTest.C @@ -582,13 +582,13 @@ TEST_F(Water97FluidPropertiesTest, derivatives) REL_TEST(dmu_dp, dmu_dp_fd, 1.0e-5); // Check derivatives of temperature calculated using pressure and enthalpy using AD - DualReal adp = 3.0e6; + ADReal adp = 3.0e6; Moose::derivInsert(adp.derivatives(), 0, 1.0); - DualReal adh = 4.0e6; + ADReal adh = 4.0e6; Moose::derivInsert(adh.derivatives(), 1, 1.0); - DualReal adT = _ad_fp->T_from_p_h(adp, adh); + ADReal adT = _ad_fp->T_from_p_h(adp, adh); REL_TEST(adT.value(), 0.101077577e4, 1.0e-8); diff --git a/modules/geochemistry/include/utils/EquilibriumConstantInterpolator.h b/modules/geochemistry/include/utils/EquilibriumConstantInterpolator.h index 63fc3d9ca80c..ef836c00d395 100644 --- a/modules/geochemistry/include/utils/EquilibriumConstantInterpolator.h +++ b/modules/geochemistry/include/utils/EquilibriumConstantInterpolator.h @@ -11,7 +11,6 @@ #include "MooseTypes.h" #include "LeastSquaresFitBase.h" -#include "DualRealOps.h" #include "LinearInterpolation.h" /** @@ -50,7 +49,7 @@ class EquilibriumConstantInterpolator : public LeastSquaresFitBase const Real no_value = 500.0); virtual Real sample(Real T) override; - DualReal sample(DualReal T); + ADReal sample(const ADReal & T); /** * Sample derivative of function at temperature T diff --git a/modules/geochemistry/src/utils/EquilibriumConstantInterpolator.C b/modules/geochemistry/src/utils/EquilibriumConstantInterpolator.C index eac0ea2f5af5..92f2439f4dc8 100644 --- a/modules/geochemistry/src/utils/EquilibriumConstantInterpolator.C +++ b/modules/geochemistry/src/utils/EquilibriumConstantInterpolator.C @@ -167,8 +167,8 @@ EquilibriumConstantInterpolator::sampleDerivative(Real T) } } -DualReal -EquilibriumConstantInterpolator::sample(DualReal T) +ADReal +EquilibriumConstantInterpolator::sample(const ADReal & T) { switch (_fit_type) { diff --git a/modules/geochemistry/unit/src/EquilibriumConstantInterpolatorTest.C b/modules/geochemistry/unit/src/EquilibriumConstantInterpolatorTest.C index 4ede8bc41d5f..65a447e6e1c0 100644 --- a/modules/geochemistry/unit/src/EquilibriumConstantInterpolatorTest.C +++ b/modules/geochemistry/unit/src/EquilibriumConstantInterpolatorTest.C @@ -102,7 +102,7 @@ TEST(EquilibriumConstantInterpolatorTest, linear) EXPECT_NEAR(logk.sampleDerivative(50.0), 0.048, tol); // Check sampleDerivative() with the AD version - DualReal Tad = 50.0; + ADReal Tad = 50.0; Moose::derivInsert(Tad.derivatives(), 0, 1.0); EXPECT_NEAR(logk.sampleDerivative(50.0), logk.sample(Tad).derivatives()[0], tol); @@ -122,7 +122,7 @@ TEST(EquilibriumConstantInterpolatorTest, linear) EXPECT_NEAR(logk2.sampleDerivative(50.0), 0.048, tol); // Check sampleDerivative() with the AD version - DualReal Tad2 = 50.01; + ADReal Tad2 = 50.01; Moose::derivInsert(Tad2.derivatives(), 0, 1.0); EXPECT_NEAR(logk.sampleDerivative(50.01), logk.sample(Tad2).derivatives()[0], tol); } @@ -164,7 +164,7 @@ TEST(EquilibriumConstantInterpolatorTest, fourthOrder) EXPECT_NEAR(logk.sample(125.0), -6.567092778770316, tol); // Check sampleDerivative() with the AD version - DualReal T2 = 50.0; + ADReal T2 = 50.0; Moose::derivInsert(T2.derivatives(), 0, 1.0); EXPECT_NEAR(logk.sampleDerivative(50.0), logk.sample(T2).derivatives()[0], tol); } @@ -206,7 +206,7 @@ TEST(EquilibriumConstantInterpolatorTest, maierKelly) EXPECT_NEAR(logk.sample(125.0), -1.0053697469019622, tol); // Check sampleDerivative() with the AD version - DualReal T2 = 50.0; + ADReal T2 = 50.0; Moose::derivInsert(T2.derivatives(), 0, 1.0); EXPECT_NEAR(logk.sampleDerivative(50.0), logk.sample(T2).derivatives()[0], tol); } @@ -252,7 +252,7 @@ TEST(EquilibriumConstantInterpolatorTest, fourthOrderNullValues) EXPECT_NEAR(logk.sample(300.0), -0.060966149023565674, tol); // Check sampleDerivative() with the AD version - DualReal T2 = 50.0; + ADReal T2 = 50.0; Moose::derivInsert(T2.derivatives(), 0, 1.0); EXPECT_NEAR(logk.sampleDerivative(50.0), logk.sample(T2).derivatives()[0], tol); } @@ -279,7 +279,7 @@ TEST(EquilibriumConstantInterpolatorTest, fourthOrderUserDefinedNullValues) EXPECT_NEAR(logk.sample(300.0), -0.060966149023565674, tol); // Check sampleDerivative() with the AD version - DualReal T2 = 50.0; + ADReal T2 = 50.0; Moose::derivInsert(T2.derivatives(), 0, 1.0); EXPECT_NEAR(logk.sampleDerivative(50.0), logk.sample(T2).derivatives()[0], tol); } @@ -306,7 +306,7 @@ TEST(EquilibriumConstantInterpolatorTest, piecewiselinear) EXPECT_EQ(logk.sampleDerivative(600.0), 0.0); // Check sampleDerivative() with the AD version produces the correct error - DualReal T2 = 5.0; + ADReal T2 = 5.0; Moose::derivInsert(T2.derivatives(), 0, 1.0); try { diff --git a/modules/navier_stokes/include/materials/INSADTauMaterial.h b/modules/navier_stokes/include/materials/INSADTauMaterial.h index c8e81e37ad2f..1da9f39d17e6 100644 --- a/modules/navier_stokes/include/materials/INSADTauMaterial.h +++ b/modules/navier_stokes/include/materials/INSADTauMaterial.h @@ -191,7 +191,7 @@ INSADTauMaterialTempl::computeHMax() for (unsigned int n_outer = 0; n_outer < _current_elem->n_vertices(); n_outer++) for (unsigned int n_inner = n_outer + 1; n_inner < _current_elem->n_vertices(); n_inner++) { - VectorValue diff = (_current_elem->point(n_outer) - _current_elem->point(n_inner)); + VectorValue diff = (_current_elem->point(n_outer) - _current_elem->point(n_inner)); for (const auto i : index_range(disps)) { const auto disp_num = disps[i]; diff --git a/modules/porous_flow/unit/src/PorousFlowBrineCO2Test.C b/modules/porous_flow/unit/src/PorousFlowBrineCO2Test.C index 6aab1c3101ce..f1ea0c371014 100644 --- a/modules/porous_flow/unit/src/PorousFlowBrineCO2Test.C +++ b/modules/porous_flow/unit/src/PorousFlowBrineCO2Test.C @@ -34,13 +34,13 @@ TEST_F(PorousFlowBrineCO2Test, indices) */ TEST_F(PorousFlowBrineCO2Test, equilibriumConstants) { - DualReal T = 350.0; + ADReal T = 350.0; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); const Real dT = 1.0e-6; - DualReal K0H2O = _fs->equilibriumConstantH2O(T); - DualReal K0CO2 = _fs->equilibriumConstantCO2(T); + ADReal K0H2O = _fs->equilibriumConstantH2O(T); + ADReal K0CO2 = _fs->equilibriumConstantCO2(T); ABS_TEST(K0H2O.value(), 0.412597711705, 1.0e-10); ABS_TEST(K0CO2.value(), 74.0435888596, 1.0e-10); @@ -78,18 +78,18 @@ TEST_F(PorousFlowBrineCO2Test, equilibriumConstants) TEST_F(PorousFlowBrineCO2Test, fugacityCoefficients) { // Test the low temperature formulation - DualReal p = 40.0e6; + ADReal p = 40.0e6; Moose::derivInsert(p.derivatives(), _pidx, 1.0); - DualReal T = 350.0; + ADReal T = 350.0; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); - DualReal Xnacl = 0.0; + ADReal Xnacl = 0.0; Moose::derivInsert(Xnacl.derivatives(), _Xidx, 1.0); - DualReal co2_density = _co2_fp->rho_from_p_T(p, T); + ADReal co2_density = _co2_fp->rho_from_p_T(p, T); - DualReal phiH2O, phiCO2; + ADReal phiH2O, phiCO2; _fs->fugacityCoefficientsLowTemp(p, T, co2_density, phiCO2, phiH2O); ABS_TEST(phiCO2.value(), 0.401939386415, 1.0e-8); ABS_TEST(phiH2O.value(), 0.0898968578757, 1.0e-8); @@ -97,7 +97,7 @@ TEST_F(PorousFlowBrineCO2Test, fugacityCoefficients) // Test the high temperature formulation T = 423.15; - DualReal xco2, yh2o; + ADReal xco2, yh2o; co2_density = _co2_fp->rho_from_p_T(p, T); _fs->solveEquilibriumMoleFractionHighTemp( @@ -109,7 +109,7 @@ TEST_F(PorousFlowBrineCO2Test, fugacityCoefficients) ABS_TEST(phiCO2.value(), 0.641936639599, 1.0e-8); // Test that the same results are returned in fugacityCoefficientsHighTemp() - DualReal phiCO2_2, phiH2O_2; + ADReal phiCO2_2, phiH2O_2; _fs->fugacityCoefficientsHighTemp(p, T, co2_density, xco2, yh2o, phiCO2_2, phiH2O_2); ABS_TEST(phiH2O, phiH2O_2, 1.0e-12); @@ -121,11 +121,11 @@ TEST_F(PorousFlowBrineCO2Test, fugacityCoefficients) */ TEST_F(PorousFlowBrineCO2Test, activityCoefficients) { - DualReal xco2 = 0.01; - DualReal T = 350.0; + ADReal xco2 = 0.01; + ADReal T = 350.0; - DualReal gammaH2O = _fs->activityCoefficientH2O(T, xco2); - DualReal gammaCO2 = _fs->activityCoefficientCO2(T, xco2); + ADReal gammaH2O = _fs->activityCoefficientH2O(T, xco2); + ADReal gammaCO2 = _fs->activityCoefficientCO2(T, xco2); ABS_TEST(gammaH2O.value(), 1.0, 1.0e-10); ABS_TEST(gammaCO2.value(), 1.0, 1.0e-10); @@ -145,13 +145,13 @@ TEST_F(PorousFlowBrineCO2Test, activityCoefficients) */ TEST_F(PorousFlowBrineCO2Test, activityCoefficientCO2Brine) { - DualReal p = 10.0e6; + ADReal p = 10.0e6; Moose::derivInsert(p.derivatives(), _pidx, 1.0); - DualReal T = 350.0; + ADReal T = 350.0; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); - DualReal Xnacl = 0.1; + ADReal Xnacl = 0.1; Moose::derivInsert(Xnacl.derivatives(), _Xidx, 1.0); const Real dp = 1.0e-1; @@ -159,10 +159,10 @@ TEST_F(PorousFlowBrineCO2Test, activityCoefficientCO2Brine) const Real dx = 1.0e-8; // Low temperature regime - DualReal gamma = _fs->activityCoefficient(p, T, Xnacl); + ADReal gamma = _fs->activityCoefficient(p, T, Xnacl); ABS_TEST(gamma.value(), 1.43276649338, 1.0e-8); - DualReal gamma_2 = _fs->activityCoefficient(p + dp, T, Xnacl); + ADReal gamma_2 = _fs->activityCoefficient(p + dp, T, Xnacl); Real dgamma_dp_fd = (gamma_2.value() - gamma.value()) / dp; REL_TEST(gamma.derivatives()[_pidx], dgamma_dp_fd, 1.0e-6); @@ -208,15 +208,15 @@ TEST_F(PorousFlowBrineCO2Test, activityCoefficientCO2Brine) */ TEST_F(PorousFlowBrineCO2Test, partialDensity) { - DualReal T = 473.15; + ADReal T = 473.15; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); const Real dT = 1.0e-6; - DualReal partial_density = _fs->partialDensityCO2(T); + ADReal partial_density = _fs->partialDensityCO2(T); ABS_TEST(partial_density.value(), 893.332, 1.0e-3); - DualReal partial_density_2 = _fs->partialDensityCO2(T + dT); + ADReal partial_density_2 = _fs->partialDensityCO2(T + dT); Real dpartial_density_dT_fd = (partial_density_2.value() - partial_density.value()) / dT; REL_TEST(partial_density.derivatives()[_Tidx], dpartial_density_dT_fd, 1.0e-6); @@ -228,27 +228,27 @@ TEST_F(PorousFlowBrineCO2Test, partialDensity) TEST_F(PorousFlowBrineCO2Test, equilibriumMassFraction) { // Low temperature regime - DualReal p = 1.0e6; + ADReal p = 1.0e6; Moose::derivInsert(p.derivatives(), _pidx, 1.0); - DualReal T = 350.0; + ADReal T = 350.0; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); - DualReal Xnacl = 0.1; + ADReal Xnacl = 0.1; Moose::derivInsert(Xnacl.derivatives(), _Xidx, 1.0); const Real dp = 1.0e-2; const Real dT = 1.0e-6; const Real dx = 1.0e-8; - DualReal X, Y; + ADReal X, Y; _fs->equilibriumMassFractions(p, T, Xnacl, X, Y); ABS_TEST(X.value(), 0.0035573020148, 1.0e-10); ABS_TEST(Y.value(), 0.0171977397214, 1.0e-10); // Derivative wrt pressure - DualReal X1, Y1, X2, Y2; + ADReal X1, Y1, X2, Y2; _fs->equilibriumMassFractions(p - dp, T, Xnacl, X1, Y1); _fs->equilibriumMassFractions(p + dp, T, Xnacl, X2, Y2); @@ -297,13 +297,13 @@ TEST_F(PorousFlowBrineCO2Test, equilibriumMassFraction) */ TEST_F(PorousFlowBrineCO2Test, MassFraction) { - DualReal p = 1.0e6; + ADReal p = 1.0e6; Moose::derivInsert(p.derivatives(), _pidx, 1.0); - DualReal T = 350.0; + ADReal T = 350.0; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); - DualReal Xnacl = 0.1; + ADReal Xnacl = 0.1; Moose::derivInsert(Xnacl.derivatives(), _Xidx, 1.0); FluidStatePhaseEnum phase_state; @@ -312,18 +312,18 @@ TEST_F(PorousFlowBrineCO2Test, MassFraction) std::vector fsp(np, FluidStateProperties(nc)); // Liquid region - DualReal Z = 0.0001; + ADReal Z = 0.0001; Moose::derivInsert(Z.derivatives(), _Zidx, 1.0); _fs->massFractions(p, T, Xnacl, Z, phase_state, fsp); EXPECT_EQ(phase_state, FluidStatePhaseEnum::LIQUID); // Verfify mass fraction values - DualReal Xco2 = fsp[0].mass_fraction[1]; - DualReal Yco2 = fsp[1].mass_fraction[1]; - DualReal Xh2o = fsp[0].mass_fraction[0]; - DualReal Yh2o = fsp[1].mass_fraction[0]; - DualReal Xnacl2 = fsp[0].mass_fraction[2]; + ADReal Xco2 = fsp[0].mass_fraction[1]; + ADReal Yco2 = fsp[1].mass_fraction[1]; + ADReal Xh2o = fsp[0].mass_fraction[0]; + ADReal Yh2o = fsp[1].mass_fraction[0]; + ADReal Xnacl2 = fsp[0].mass_fraction[2]; ABS_TEST(Xco2.value(), Z.value(), 1.0e-8); ABS_TEST(Yco2.value(), 0.0, 1.0e-8); ABS_TEST(Xh2o.value(), 1.0 - Z.value(), 1.0e-8); @@ -353,7 +353,7 @@ TEST_F(PorousFlowBrineCO2Test, MassFraction) Yco2 = fsp[1].mass_fraction[1]; Xh2o = fsp[0].mass_fraction[0]; Yh2o = fsp[1].mass_fraction[0]; - DualReal Ynacl = fsp[1].mass_fraction[2]; + ADReal Ynacl = fsp[1].mass_fraction[2]; ABS_TEST(Xco2.value(), 0.0, 1.0e-8); ABS_TEST(Yco2.value(), Z.value(), 1.0e-8); ABS_TEST(Xh2o.value(), 0.0, 1.0e-8); @@ -381,10 +381,10 @@ TEST_F(PorousFlowBrineCO2Test, MassFraction) EXPECT_EQ(phase_state, FluidStatePhaseEnum::TWOPHASE); // Equilibrium mass fractions and derivatives - DualReal Xco2_eq, Yh2o_eq; + ADReal Xco2_eq, Yh2o_eq; _fs->equilibriumMassFractions(p, T, Xnacl, Xco2_eq, Yh2o_eq); - // Verfify mass fraction values - comparing DualReals verifies that derivatives + // Verfify mass fraction values - comparing ADReals verifies that derivatives // are also identical Xco2 = fsp[0].mass_fraction[1]; Yco2 = fsp[1].mass_fraction[1]; @@ -398,11 +398,11 @@ TEST_F(PorousFlowBrineCO2Test, MassFraction) // Use finite differences to verify derivative wrt Z is unaffected by Z const Real dZ = 1.0e-8; _fs->massFractions(p, T, Xnacl, Z + dZ, phase_state, fsp); - DualReal Xco21 = fsp[0].mass_fraction[1]; - DualReal Yco21 = fsp[1].mass_fraction[1]; + ADReal Xco21 = fsp[0].mass_fraction[1]; + ADReal Yco21 = fsp[1].mass_fraction[1]; _fs->massFractions(p, T, Xnacl, Z - dZ, phase_state, fsp); - DualReal Xco22 = fsp[0].mass_fraction[1]; - DualReal Yco22 = fsp[1].mass_fraction[1]; + ADReal Xco22 = fsp[0].mass_fraction[1]; + ADReal Yco22 = fsp[1].mass_fraction[1]; ABS_TEST(Xco2.derivatives()[_Zidx], (Xco21.value() - Xco22.value()) / (2.0 * dZ), 1.0e-8); ABS_TEST(Yco2.derivatives()[_Zidx], (Yco21.value() - Yco22.value()) / (2.0 * dZ), 1.0e-8); @@ -415,13 +415,13 @@ TEST_F(PorousFlowBrineCO2Test, MassFraction) */ TEST_F(PorousFlowBrineCO2Test, gasProperties) { - DualReal p = 1.0e6; + ADReal p = 1.0e6; Moose::derivInsert(p.derivatives(), _pidx, 1.0); - DualReal T = 350.0; + ADReal T = 350.0; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); - DualReal Xnacl = 0.1; + ADReal Xnacl = 0.1; Moose::derivInsert(Xnacl.derivatives(), _Xidx, 1.0); FluidStatePhaseEnum phase_state; @@ -430,7 +430,7 @@ TEST_F(PorousFlowBrineCO2Test, gasProperties) std::vector fsp(np, FluidStateProperties(nc)); // Gas region - DualReal Z = 0.995; + ADReal Z = 0.995; Moose::derivInsert(Z.derivatives(), _Zidx, 1.0); _fs->massFractions(p, T, Xnacl, Z, phase_state, fsp); @@ -438,9 +438,9 @@ TEST_F(PorousFlowBrineCO2Test, gasProperties) // Verify fluid density, viscosity and enthalpy _fs->gasProperties(p, T, fsp); - DualReal gas_density = fsp[1].density; - DualReal gas_viscosity = fsp[1].viscosity; - DualReal gas_enthalpy = fsp[1].enthalpy; + ADReal gas_density = fsp[1].density; + ADReal gas_viscosity = fsp[1].viscosity; + ADReal gas_enthalpy = fsp[1].enthalpy; Real density = _co2_fp->rho_from_p_T(p.value(), T.value()); Real viscosity = _co2_fp->mu_from_p_T(p.value(), T.value()); @@ -505,13 +505,13 @@ TEST_F(PorousFlowBrineCO2Test, gasProperties) */ TEST_F(PorousFlowBrineCO2Test, liquidProperties) { - DualReal p = 1.0e6; + ADReal p = 1.0e6; Moose::derivInsert(p.derivatives(), _pidx, 1.0); - DualReal T = 350.0; + ADReal T = 350.0; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); - DualReal Xnacl = 0.1; + ADReal Xnacl = 0.1; Moose::derivInsert(Xnacl.derivatives(), _Xidx, 1.0); FluidStatePhaseEnum phase_state; @@ -520,7 +520,7 @@ TEST_F(PorousFlowBrineCO2Test, liquidProperties) std::vector fsp(np, FluidStateProperties(nc)); // Liquid region - DualReal Z = 0.0001; + ADReal Z = 0.0001; Moose::derivInsert(Z.derivatives(), _Zidx, 1.0); _fs->massFractions(p, T, Xnacl, Z, phase_state, fsp); @@ -529,9 +529,9 @@ TEST_F(PorousFlowBrineCO2Test, liquidProperties) // Verify fluid density and viscosity _fs->liquidProperties(p, T, Xnacl, fsp); - DualReal liquid_density = fsp[0].density; - DualReal liquid_viscosity = fsp[0].viscosity; - DualReal liquid_enthalpy = fsp[0].enthalpy; + ADReal liquid_density = fsp[0].density; + ADReal liquid_viscosity = fsp[0].viscosity; + ADReal liquid_enthalpy = fsp[0].enthalpy; Real co2_partial_density = _fs->partialDensityCO2(T).value(); Real brine_density = _brine_fp->rho_from_p_T_X(p.value(), T.value(), Xnacl.value()); @@ -704,13 +704,13 @@ TEST_F(PorousFlowBrineCO2Test, liquidProperties) */ TEST_F(PorousFlowBrineCO2Test, saturation) { - DualReal p = 1.0e6; + ADReal p = 1.0e6; Moose::derivInsert(p.derivatives(), _pidx, 1.0); - DualReal T = 350.0; + ADReal T = 350.0; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); - DualReal Xnacl = 0.1; + ADReal Xnacl = 0.1; Moose::derivInsert(Xnacl.derivatives(), _Xidx, 1.0); FluidStatePhaseEnum phase_state; @@ -721,27 +721,27 @@ TEST_F(PorousFlowBrineCO2Test, saturation) // In the two-phase region, the mass fractions are the equilibrium values, so // a temporary value of Z can be used (as long as it corresponds to the two-phase // region) - DualReal Z = 0.45; + ADReal Z = 0.45; Moose::derivInsert(Z.derivatives(), _Zidx, 1.0); _fs->massFractions(p, T, Xnacl, Z, phase_state, fsp); EXPECT_EQ(phase_state, FluidStatePhaseEnum::TWOPHASE); // Calculate Z that gives a saturation of 0.25 - DualReal gas_saturation = 0.25; - DualReal liquid_pressure = p - _pc->capillaryPressure(1.0 - gas_saturation); + ADReal gas_saturation = 0.25; + ADReal liquid_pressure = p - _pc->capillaryPressure(1.0 - gas_saturation); // Calculate gas density and liquid density _fs->gasProperties(p, T, fsp); _fs->liquidProperties(liquid_pressure, T, Xnacl, fsp); // The mass fraction that corresponds to a gas_saturation = 0.25 - DualReal Zc = (gas_saturation * fsp[1].density * fsp[1].mass_fraction[1] + - (1.0 - gas_saturation) * fsp[0].density * fsp[0].mass_fraction[1]) / - (gas_saturation * fsp[1].density + (1.0 - gas_saturation) * fsp[0].density); + ADReal Zc = (gas_saturation * fsp[1].density * fsp[1].mass_fraction[1] + + (1.0 - gas_saturation) * fsp[0].density * fsp[0].mass_fraction[1]) / + (gas_saturation * fsp[1].density + (1.0 - gas_saturation) * fsp[0].density); // Calculate the gas saturation and derivatives - DualReal saturation = _fs->saturation(p, T, Xnacl, Zc, fsp); + ADReal saturation = _fs->saturation(p, T, Xnacl, Zc, fsp); ABS_TEST(saturation.value(), gas_saturation.value(), 1.0e-6); // Test the derivatives of gas saturation @@ -808,14 +808,14 @@ TEST_F(PorousFlowBrineCO2Test, totalMassFraction) const unsigned int nc = _fs->numComponents(); std::vector fsp(np, FluidStateProperties(nc)); - DualReal pressure = p; - DualReal temperature = T; - DualReal z = Z; - DualReal x = Xnacl; + ADReal pressure = p; + ADReal temperature = T; + ADReal z = Z; + ADReal x = Xnacl; _fs->massFractions(pressure, temperature, x, z, phase_state, fsp); EXPECT_EQ(phase_state, FluidStatePhaseEnum::TWOPHASE); - DualReal gas_saturation = _fs->saturation(pressure, temperature, x, z, fsp); + ADReal gas_saturation = _fs->saturation(pressure, temperature, x, z, fsp); ABS_TEST(gas_saturation, s, 1.0e-6); } @@ -827,13 +827,13 @@ TEST_F(PorousFlowBrineCO2Test, totalMassFraction) */ TEST_F(PorousFlowBrineCO2Test, henryConstant) { - DualReal T = 373.15; + ADReal T = 373.15; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); - DualReal Xnacl = 0.1; + ADReal Xnacl = 0.1; Moose::derivInsert(Xnacl.derivatives(), _Xidx, 1.0); - DualReal Kh = _fs->henryConstant(T, Xnacl); + ADReal Kh = _fs->henryConstant(T, Xnacl); REL_TEST(Kh.value(), 7.46559e+08, 1.0e-3); T = 473.15; @@ -847,8 +847,8 @@ TEST_F(PorousFlowBrineCO2Test, henryConstant) // Test the derivative wrt temperature const Real dT = 1.0e-4; - DualReal Kh1 = _fs->henryConstant(T + dT, Xnacl); - DualReal Kh2 = _fs->henryConstant(T - dT, Xnacl); + ADReal Kh1 = _fs->henryConstant(T + dT, Xnacl); + ADReal Kh2 = _fs->henryConstant(T - dT, Xnacl); REL_TEST(Kh.derivatives()[_Tidx], (Kh1.value() - Kh2.value()) / (2.0 * dT), 1.0e-6); @@ -868,14 +868,14 @@ TEST_F(PorousFlowBrineCO2Test, henryConstant) TEST_F(PorousFlowBrineCO2Test, enthalpyOfDissolutionGas) { // T = 50C - DualReal T = 323.15; + ADReal T = 323.15; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); - DualReal Xnacl = 0.1; + ADReal Xnacl = 0.1; Moose::derivInsert(Xnacl.derivatives(), _Xidx, 1.0); // Enthalpy of dissolution of CO2 in brine - DualReal hdis = _fs->enthalpyOfDissolutionGas(T, Xnacl); + ADReal hdis = _fs->enthalpyOfDissolutionGas(T, Xnacl); REL_TEST(hdis, -3.20130e5, 1.0e-3); // T = 350C @@ -910,11 +910,11 @@ TEST_F(PorousFlowBrineCO2Test, enthalpyOfDissolutionGas) TEST_F(PorousFlowBrineCO2Test, enthalpyOfDissolution) { // T = 50C - DualReal T = 323.15; + ADReal T = 323.15; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); // Enthalpy of dissolution of CO2 in water - DualReal hdis = _fs->enthalpyOfDissolution(T); + ADReal hdis = _fs->enthalpyOfDissolution(T); REL_TEST(hdis.value(), -3.38185e5, 1.0e-3); // T = 350C @@ -975,11 +975,11 @@ TEST_F(PorousFlowBrineCO2Test, equilibriumMoleFractions) { // Test pure water (Xnacl = 0) // Low temperature regime - DualReal p = 20.0e6; - DualReal T = 323.15; - DualReal Xnacl = 0.0; + ADReal p = 20.0e6; + ADReal T = 323.15; + ADReal Xnacl = 0.0; - DualReal x, y; + ADReal x, y; _fs->equilibriumMoleFractions(p, T, Xnacl, x, y); ABS_TEST(y.value(), 0.00696393845155, 1.0e-8); ABS_TEST(x.value(), 0.0236554537395, 1.0e-8); diff --git a/modules/porous_flow/unit/src/PorousFlowBrooksCoreyTest.C b/modules/porous_flow/unit/src/PorousFlowBrooksCoreyTest.C index 4a41e3877e34..c652257d2606 100644 --- a/modules/porous_flow/unit/src/PorousFlowBrooksCoreyTest.C +++ b/modules/porous_flow/unit/src/PorousFlowBrooksCoreyTest.C @@ -121,7 +121,7 @@ TEST(PorousFlowBrooksCoreyTest, drelpermnw) TEST(PorousFlowBrooksCoreyTest, adrelpermw) { - DualReal sat = 0.3; + ADReal sat = 0.3; Moose::derivInsert(sat.derivatives(), 0, 1.0); const auto adrelperm = PorousFlowBrooksCorey::relativePermeabilityW(sat, 2.5); @@ -135,7 +135,7 @@ TEST(PorousFlowBrooksCoreyTest, adrelpermw) TEST(PorousFlowBrooksCoreyTest, adrelpermnw) { - DualReal sat = 0.3; + ADReal sat = 0.3; Moose::derivInsert(sat.derivatives(), 0, 1.0); const auto adrelperm = PorousFlowBrooksCorey::relativePermeabilityNW(sat, 2.5); diff --git a/modules/porous_flow/unit/src/PorousFlowVanGenuchtenTest.C b/modules/porous_flow/unit/src/PorousFlowVanGenuchtenTest.C index b49280a4db94..95e87f31b917 100644 --- a/modules/porous_flow/unit/src/PorousFlowVanGenuchtenTest.C +++ b/modules/porous_flow/unit/src/PorousFlowVanGenuchtenTest.C @@ -172,7 +172,7 @@ TEST(PorousFlowVanGenuchtenTest, d2relperm) TEST(PorousFlowVanGenuchtenTest, adrelperm) { - DualReal sat = 0.3; + ADReal sat = 0.3; Moose::derivInsert(sat.derivatives(), 0, 1.0); const auto adrelperm = PorousFlowVanGenuchten::relativePermeability(sat, 0.7); @@ -224,7 +224,7 @@ TEST(PorousFlowVanGenuchtenTest, d2relpermNW) TEST(PorousFlowVanGenuchtenTest, adrelpermnw) { - DualReal sat = 0.3; + ADReal sat = 0.3; Moose::derivInsert(sat.derivatives(), 0, 1.0); const auto adrelperm = PorousFlowVanGenuchten::relativePermeabilityNW(sat, 0.7); diff --git a/modules/porous_flow/unit/src/PorousFlowWaterNCGTest.C b/modules/porous_flow/unit/src/PorousFlowWaterNCGTest.C index 30b79c0f3bb3..9abdde4e66c6 100644 --- a/modules/porous_flow/unit/src/PorousFlowWaterNCGTest.C +++ b/modules/porous_flow/unit/src/PorousFlowWaterNCGTest.C @@ -20,16 +20,16 @@ TEST_F(PorousFlowWaterNCGTest, name) { EXPECT_EQ("water-ncg", _fs->fluidStateNam */ TEST_F(PorousFlowWaterNCGTest, equilibriumMassFraction) { - DualReal p = 1.0e6; + ADReal p = 1.0e6; Moose::derivInsert(p.derivatives(), _pidx, 1.0); - DualReal T = 350.0; + ADReal T = 350.0; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); const Real dp = 1.0e-1; const Real dT = 1.0e-6; - DualReal Xncg, Yh2o, Xncg1, Yh2o1, Xncg2, Yh2o2; + ADReal Xncg, Yh2o, Xncg1, Yh2o1, Xncg2, Yh2o2; _fs->equilibriumMassFractions(p, T, Xncg, Yh2o); _fs->equilibriumMassFractions(p - dp, T, Xncg1, Yh2o1); _fs->equilibriumMassFractions(p + dp, T, Xncg2, Yh2o2); @@ -56,27 +56,27 @@ TEST_F(PorousFlowWaterNCGTest, equilibriumMassFraction) */ TEST_F(PorousFlowWaterNCGTest, MassFraction) { - DualReal p = 1.0e6; + ADReal p = 1.0e6; Moose::derivInsert(p.derivatives(), _pidx, 1.0); - DualReal T = 350.0; + ADReal T = 350.0; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); FluidStatePhaseEnum phase_state; std::vector fsp(2, FluidStateProperties(2)); // Liquid region - DualReal Z = 0.0001; + ADReal Z = 0.0001; Moose::derivInsert(Z.derivatives(), _Zidx, 1.0); _fs->massFractions(p, T, Z, phase_state, fsp); EXPECT_EQ(phase_state, FluidStatePhaseEnum::LIQUID); // Verfify mass fraction values - DualReal Xncg = fsp[0].mass_fraction[1]; - DualReal Yncg = fsp[1].mass_fraction[1]; - DualReal Xh2o = fsp[0].mass_fraction[0]; - DualReal Yh2o = fsp[1].mass_fraction[0]; + ADReal Xncg = fsp[0].mass_fraction[1]; + ADReal Yncg = fsp[1].mass_fraction[1]; + ADReal Xh2o = fsp[0].mass_fraction[0]; + ADReal Yh2o = fsp[1].mass_fraction[0]; ABS_TEST(Xncg.value(), Z.value(), 1.0e-12); ABS_TEST(Yncg.value(), 0.0, 1.0e-12); ABS_TEST(Xh2o.value(), 1.0 - Z.value(), 1.0e-12); @@ -137,7 +137,7 @@ TEST_F(PorousFlowWaterNCGTest, MassFraction) EXPECT_EQ(phase_state, FluidStatePhaseEnum::TWOPHASE); // Equilibrium mass fractions and derivatives - DualReal Xncg_eq, Yh2o_eq; + ADReal Xncg_eq, Yh2o_eq; _fs->equilibriumMassFractions(p, T, Xncg_eq, Yh2o_eq); // Verfify mass fraction values @@ -167,11 +167,11 @@ TEST_F(PorousFlowWaterNCGTest, MassFraction) // Use finite differences to verify derivative wrt Z is unaffected by Z const Real dZ = 1.0e-8; _fs->massFractions(p, T, Z + dZ, phase_state, fsp); - DualReal Xncg1 = fsp[0].mass_fraction[1]; - DualReal Yncg1 = fsp[1].mass_fraction[1]; + ADReal Xncg1 = fsp[0].mass_fraction[1]; + ADReal Yncg1 = fsp[1].mass_fraction[1]; _fs->massFractions(p, T, Z - dZ, phase_state, fsp); - DualReal Xncg2 = fsp[0].mass_fraction[1]; - DualReal Yncg2 = fsp[1].mass_fraction[1]; + ADReal Xncg2 = fsp[0].mass_fraction[1]; + ADReal Yncg2 = fsp[1].mass_fraction[1]; ABS_TEST(dXncg_dZ, (Xncg1 - Xncg2).value() / (2.0 * dZ), 1.0e-8); ABS_TEST(dYncg_dZ, (Yncg1 - Yncg2).value() / (2.0 * dZ), 1.0e-8); @@ -182,25 +182,25 @@ TEST_F(PorousFlowWaterNCGTest, MassFraction) */ TEST_F(PorousFlowWaterNCGTest, gasDensity) { - DualReal p = 1.0e6; + ADReal p = 1.0e6; Moose::derivInsert(p.derivatives(), _pidx, 1.0); - DualReal T = 350.0; + ADReal T = 350.0; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); FluidStatePhaseEnum phase_state; std::vector fsp(2, FluidStateProperties(2)); // Gas region - DualReal Z = 0.995; + ADReal Z = 0.995; Moose::derivInsert(Z.derivatives(), _Zidx, 1.0); _fs->massFractions(p, T, Z, phase_state, fsp); EXPECT_EQ(phase_state, FluidStatePhaseEnum::GAS); - const DualReal gas_density = _fs->gasDensity(p, T, fsp); + const ADReal gas_density = _fs->gasDensity(p, T, fsp); - const DualReal density = + const ADReal density = _ncg_fp->rho_from_p_T(Z * p, T) + _water_fp->rho_from_p_T(_water_fp->vaporPressure(T), T); ABS_TEST(gas_density, density, 1.0e-12); @@ -211,17 +211,17 @@ TEST_F(PorousFlowWaterNCGTest, gasDensity) */ TEST_F(PorousFlowWaterNCGTest, gasProperties) { - DualReal p = 1.0e6; + ADReal p = 1.0e6; Moose::derivInsert(p.derivatives(), _pidx, 1.0); - DualReal T = 350.0; + ADReal T = 350.0; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); FluidStatePhaseEnum phase_state; std::vector fsp(2, FluidStateProperties(2)); // Gas region - DualReal Z = 0.995; + ADReal Z = 0.995; Moose::derivInsert(Z.derivatives(), _Zidx, 1.0); _fs->massFractions(p, T, Z, phase_state, fsp); @@ -229,16 +229,16 @@ TEST_F(PorousFlowWaterNCGTest, gasProperties) // Verify fluid density, viscosity and enthalpy _fs->gasProperties(p, T, fsp); - DualReal gas_density = fsp[1].density; - DualReal gas_viscosity = fsp[1].viscosity; - DualReal gas_enthalpy = fsp[1].enthalpy; + ADReal gas_density = fsp[1].density; + ADReal gas_viscosity = fsp[1].viscosity; + ADReal gas_enthalpy = fsp[1].enthalpy; - DualReal density = + ADReal density = _ncg_fp->rho_from_p_T(Z * p, T) + _water_fp->rho_from_p_T(_water_fp->vaporPressure(T), T); - DualReal viscosity = Z * _ncg_fp->mu_from_p_T(Z * p, T) + - (1.0 - Z) * _water_fp->mu_from_p_T(_water_fp->vaporPressure(T), T); - DualReal enthalpy = Z * _ncg_fp->h_from_p_T(Z * p, T) + - (1.0 - Z) * _water_fp->h_from_p_T(_water_fp->vaporPressure(T), T); + ADReal viscosity = Z * _ncg_fp->mu_from_p_T(Z * p, T) + + (1.0 - Z) * _water_fp->mu_from_p_T(_water_fp->vaporPressure(T), T); + ADReal enthalpy = Z * _ncg_fp->h_from_p_T(Z * p, T) + + (1.0 - Z) * _water_fp->h_from_p_T(_water_fp->vaporPressure(T), T); ABS_TEST(gas_density, density, 1.0e-10); ABS_TEST(gas_viscosity, viscosity, 1.0e-10); @@ -257,14 +257,14 @@ TEST_F(PorousFlowWaterNCGTest, gasProperties) const Real dp = 1.0e-1; _fs->gasProperties(p + dp, T, fsp); - DualReal rho1 = fsp[1].density; - DualReal mu1 = fsp[1].viscosity; - DualReal h1 = fsp[1].enthalpy; + ADReal rho1 = fsp[1].density; + ADReal mu1 = fsp[1].viscosity; + ADReal h1 = fsp[1].enthalpy; _fs->gasProperties(p - dp, T, fsp); - DualReal rho2 = fsp[1].density; - DualReal mu2 = fsp[1].viscosity; - DualReal h2 = fsp[1].enthalpy; + ADReal rho2 = fsp[1].density; + ADReal mu2 = fsp[1].viscosity; + ADReal h2 = fsp[1].enthalpy; REL_TEST(ddensity_dp, (rho1 - rho2).value() / (2.0 * dp), 1.0e-7); REL_TEST(dviscosity_dp, (mu1 - mu2).value() / (2.0 * dp), 1.0e-7); @@ -379,15 +379,15 @@ TEST_F(PorousFlowWaterNCGTest, gasProperties) */ TEST_F(PorousFlowWaterNCGTest, liquidDensity) { - DualReal p = 1.0e6; + ADReal p = 1.0e6; Moose::derivInsert(p.derivatives(), _pidx, 1.0); - DualReal T = 350.0; + ADReal T = 350.0; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); - const DualReal liquid_density = _fs->liquidDensity(p, T); + const ADReal liquid_density = _fs->liquidDensity(p, T); - const DualReal density = _water_fp->rho_from_p_T(p, T); + const ADReal density = _water_fp->rho_from_p_T(p, T); ABS_TEST(liquid_density, density, 1.0e-12); } @@ -399,10 +399,10 @@ TEST_F(PorousFlowWaterNCGTest, liquidDensity) */ TEST_F(PorousFlowWaterNCGTest, liquidProperties) { - DualReal p = 1.0e6; + ADReal p = 1.0e6; Moose::derivInsert(p.derivatives(), _pidx, 1.0); - DualReal T = 350.0; + ADReal T = 350.0; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); FluidStatePhaseEnum phase_state; @@ -410,13 +410,13 @@ TEST_F(PorousFlowWaterNCGTest, liquidProperties) // Verify fluid density and viscosity _fs->liquidProperties(p, T, fsp); - DualReal liquid_density = fsp[0].density; - DualReal liquid_viscosity = fsp[0].viscosity; - DualReal liquid_enthalpy = fsp[0].enthalpy; + ADReal liquid_density = fsp[0].density; + ADReal liquid_viscosity = fsp[0].viscosity; + ADReal liquid_enthalpy = fsp[0].enthalpy; - DualReal density = _water_fp->rho_from_p_T(p, T); - DualReal viscosity = _water_fp->mu_from_p_T(p, T); - DualReal enthalpy = _water_fp->h_from_p_T(p, T); + ADReal density = _water_fp->rho_from_p_T(p, T); + ADReal viscosity = _water_fp->mu_from_p_T(p, T); + ADReal enthalpy = _water_fp->h_from_p_T(p, T); ABS_TEST(liquid_density, density, 1.0e-12); ABS_TEST(liquid_viscosity, viscosity, 1.0e-12); @@ -435,14 +435,14 @@ TEST_F(PorousFlowWaterNCGTest, liquidProperties) const Real dp = 10.0; _fs->liquidProperties(p + dp, T, fsp); - DualReal rho1 = fsp[0].density; - DualReal mu1 = fsp[0].viscosity; - DualReal h1 = fsp[0].enthalpy; + ADReal rho1 = fsp[0].density; + ADReal mu1 = fsp[0].viscosity; + ADReal h1 = fsp[0].enthalpy; _fs->liquidProperties(p - dp, T, fsp); - DualReal rho2 = fsp[0].density; - DualReal mu2 = fsp[0].viscosity; - DualReal h2 = fsp[0].enthalpy; + ADReal rho2 = fsp[0].density; + ADReal mu2 = fsp[0].viscosity; + ADReal h2 = fsp[0].enthalpy; REL_TEST(ddensity_dp, (rho1 - rho2) / (2.0 * dp), 1.0e-6); REL_TEST(dviscosity_dp, (mu1 - mu2) / (2.0 * dp), 1.0e-6); @@ -463,7 +463,7 @@ TEST_F(PorousFlowWaterNCGTest, liquidProperties) REL_TEST(dviscosity_dT, (mu1 - mu2) / (2.0 * dT), 1.0e-8); REL_TEST(denthalpy_dT, (h1 - h2) / (2.0 * dT), 1.0e-8); - DualReal Z = 0.0001; + ADReal Z = 0.0001; Moose::derivInsert(Z.derivatives(), _Zidx, 1.0); const Real dZ = 1.0e-8; @@ -533,10 +533,10 @@ TEST_F(PorousFlowWaterNCGTest, liquidProperties) */ TEST_F(PorousFlowWaterNCGTest, saturation) { - DualReal p = 1.0e6; + ADReal p = 1.0e6; Moose::derivInsert(p.derivatives(), _pidx, 1.0); - DualReal T = 350.0; + ADReal T = 350.0; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); FluidStatePhaseEnum phase_state; @@ -545,14 +545,14 @@ TEST_F(PorousFlowWaterNCGTest, saturation) // In the two-phase region, the mass fractions are the equilibrium values, so // a temporary value of Z can be used (as long as it corresponds to the two-phase // region) - DualReal Z = 0.45; + ADReal Z = 0.45; Moose::derivInsert(Z.derivatives(), _Zidx, 1.0); _fs->massFractions(p, T, Z, phase_state, fsp); EXPECT_EQ(phase_state, FluidStatePhaseEnum::TWOPHASE); // Calculate Z that gives a saturation of 0.25 - DualReal target_gas_saturation = 0.25; + ADReal target_gas_saturation = 0.25; fsp[1].saturation = target_gas_saturation; // Calculate gas density and liquid density @@ -560,13 +560,13 @@ TEST_F(PorousFlowWaterNCGTest, saturation) _fs->liquidProperties(p, T, fsp); // The mass fraction that corresponds to a gas_saturation = 0.25 - DualReal Zc = + ADReal Zc = (target_gas_saturation * fsp[1].density * fsp[1].mass_fraction[1] + (1.0 - target_gas_saturation) * fsp[0].density * fsp[0].mass_fraction[1]) / (target_gas_saturation * fsp[1].density + (1.0 - target_gas_saturation) * fsp[0].density); // Calculate the gas saturation and derivatives - DualReal gas_saturation = _fs->saturation(p, T, Zc, fsp); + ADReal gas_saturation = _fs->saturation(p, T, Zc, fsp); REL_TEST(gas_saturation, target_gas_saturation, 1.0e-6); @@ -579,10 +579,10 @@ TEST_F(PorousFlowWaterNCGTest, saturation) Real dgas_saturation_dZ = gas_saturation.derivatives()[_Zidx]; _fs->massFractions(p + dp, T, Z, phase_state, fsp); - DualReal gsat1 = _fs->saturation(p + dp, T, Z, fsp); + ADReal gsat1 = _fs->saturation(p + dp, T, Z, fsp); _fs->massFractions(p - dp, T, Z, phase_state, fsp); - DualReal gsat2 = _fs->saturation(p - dp, T, Z, fsp); + ADReal gsat2 = _fs->saturation(p - dp, T, Z, fsp); REL_TEST(dgas_saturation_dp, (gsat1 - gsat2).value() / (2.0 * dp), 1.0e-7); @@ -612,16 +612,16 @@ TEST_F(PorousFlowWaterNCGTest, saturation) */ TEST_F(PorousFlowWaterNCGTest, twoPhase) { - DualReal p = 1.0e6; + ADReal p = 1.0e6; Moose::derivInsert(p.derivatives(), _pidx, 1.0); - DualReal T = 350.0; + ADReal T = 350.0; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); FluidStatePhaseEnum phase_state; std::vector fsp(2, FluidStateProperties(2)); - DualReal Z = 0.45; + ADReal Z = 0.45; Moose::derivInsert(Z.derivatives(), _Zidx, 1.0); // Dummy qp value that isn't needed to test this @@ -631,16 +631,16 @@ TEST_F(PorousFlowWaterNCGTest, twoPhase) EXPECT_EQ(phase_state, FluidStatePhaseEnum::TWOPHASE); _fs->twoPhaseProperties(p, T, Z, qp, fsp); - DualReal liquid_density = fsp[0].density; - DualReal liquid_viscosity = fsp[0].viscosity; - DualReal liquid_enthalpy = fsp[0].enthalpy; - DualReal gas_saturation = fsp[1].saturation; - DualReal gas_density = fsp[1].density; - DualReal gas_viscosity = fsp[1].viscosity; - DualReal gas_enthalpy = fsp[1].enthalpy; + ADReal liquid_density = fsp[0].density; + ADReal liquid_viscosity = fsp[0].viscosity; + ADReal liquid_enthalpy = fsp[0].enthalpy; + ADReal gas_saturation = fsp[1].saturation; + ADReal gas_density = fsp[1].density; + ADReal gas_viscosity = fsp[1].viscosity; + ADReal gas_enthalpy = fsp[1].enthalpy; // As all the values are provided by the gasProperties(), liquidProperties() and - // saturation(), we can simply compare the DualReal results are the same (really + // saturation(), we can simply compare the ADReal results are the same (really // only need to make sure that liquid properties are calculated correctly given the saturation) std::vector fsp2(2, FluidStateProperties(2)); @@ -648,7 +648,7 @@ TEST_F(PorousFlowWaterNCGTest, twoPhase) _fs->gasProperties(p, T, fsp2); fsp2[1].saturation = _fs->saturation(p, T, Z, fsp2); - const DualReal pliq = p - _pc->capillaryPressure(1.0 - fsp2[1].saturation, qp); + const ADReal pliq = p - _pc->capillaryPressure(1.0 - fsp2[1].saturation, qp); _fs->liquidProperties(pliq, T, fsp2); ABS_TEST(gas_density, fsp2[1].density, 1.0e-12); @@ -677,13 +677,13 @@ TEST_F(PorousFlowWaterNCGTest, totalMassFraction) FluidStatePhaseEnum phase_state; std::vector fsp(2, FluidStateProperties(2)); - DualReal pressure = p; - DualReal temperature = T; - DualReal z = Z; + ADReal pressure = p; + ADReal temperature = T; + ADReal z = Z; _fs->massFractions(pressure, temperature, z, phase_state, fsp); EXPECT_EQ(phase_state, FluidStatePhaseEnum::TWOPHASE); - DualReal gas_saturation = _fs->saturation(pressure, temperature, z, fsp); + ADReal gas_saturation = _fs->saturation(pressure, temperature, z, fsp); REL_TEST(gas_saturation, s, 1.0e-5); } @@ -695,11 +695,11 @@ TEST_F(PorousFlowWaterNCGTest, totalMassFraction) TEST_F(PorousFlowWaterNCGTest, enthalpyOfDissolution) { // T = 50C - DualReal T = 323.15; + ADReal T = 323.15; Moose::derivInsert(T.derivatives(), _Tidx, 1.0); // Enthalpy of dissolution of NCG in water - DualReal hdis = _fs->enthalpyOfDissolution(T); + ADReal hdis = _fs->enthalpyOfDissolution(T); REL_TEST(hdis.value(), -3.45731e5, 1.0e-5); // T = 350C @@ -712,8 +712,8 @@ TEST_F(PorousFlowWaterNCGTest, enthalpyOfDissolution) // Test the derivative wrt temperature const Real dT = 1.0e-4; - DualReal hdis2 = _fs->enthalpyOfDissolution(T + dT); - DualReal hdis3 = _fs->enthalpyOfDissolution(T - dT); + ADReal hdis2 = _fs->enthalpyOfDissolution(T + dT); + ADReal hdis3 = _fs->enthalpyOfDissolution(T - dT); REL_TEST(hdis.derivatives()[_Tidx], (hdis2 - hdis3) / (2.0 * dT), 1.0e-6); } diff --git a/modules/ray_tracing/include/raykernels/ADRayKernel.h b/modules/ray_tracing/include/raykernels/ADRayKernel.h index 352db6525abf..4d302e909352 100644 --- a/modules/ray_tracing/include/raykernels/ADRayKernel.h +++ b/modules/ray_tracing/include/raykernels/ADRayKernel.h @@ -15,7 +15,6 @@ // MOOSE Includes #include "MooseVariableInterface.h" #include "TaggingInterface.h" -#include "DualRealOps.h" // Forward declarations template diff --git a/modules/scalar_transport/src/kernels/LMKernel.C b/modules/scalar_transport/src/kernels/LMKernel.C index cd8dabd3f408..970a3f92cd16 100644 --- a/modules/scalar_transport/src/kernels/LMKernel.C +++ b/modules/scalar_transport/src/kernels/LMKernel.C @@ -12,7 +12,6 @@ #include "MooseVariable.h" #include "InputParameters.h" #include "MooseArray.h" -#include "DualRealOps.h" #include "SystemBase.h" #include "libmesh/quadrature.h" diff --git a/modules/solid_mechanics/include/materials/GeneralizedReturnMappingSolution.h b/modules/solid_mechanics/include/materials/GeneralizedReturnMappingSolution.h index 9e3df9ea8195..62584e00a585 100644 --- a/modules/solid_mechanics/include/materials/GeneralizedReturnMappingSolution.h +++ b/modules/solid_mechanics/include/materials/GeneralizedReturnMappingSolution.h @@ -9,7 +9,6 @@ #pragma once -#include "DualRealOps.h" #include "InputParameters.h" #include "MooseTypes.h" diff --git a/modules/solid_mechanics/include/materials/SingleVariableReturnMappingSolution.h b/modules/solid_mechanics/include/materials/SingleVariableReturnMappingSolution.h index 7f4e7a47fefb..158a91a2f975 100644 --- a/modules/solid_mechanics/include/materials/SingleVariableReturnMappingSolution.h +++ b/modules/solid_mechanics/include/materials/SingleVariableReturnMappingSolution.h @@ -10,7 +10,6 @@ #pragma once #include "MooseTypes.h" -#include "DualRealOps.h" #include "ChainedReal.h" #include "ChainedADReal.h" #include "InputParameters.h" diff --git a/modules/solid_mechanics/src/materials/GeneralizedReturnMappingSolution.C b/modules/solid_mechanics/src/materials/GeneralizedReturnMappingSolution.C index 6c99e6f4dc5a..08dd7176895a 100644 --- a/modules/solid_mechanics/src/materials/GeneralizedReturnMappingSolution.C +++ b/modules/solid_mechanics/src/materials/GeneralizedReturnMappingSolution.C @@ -16,8 +16,6 @@ #include "Conversion.h" #include "MathUtils.h" -#include "DualRealOps.h" - #include #include #include diff --git a/modules/solid_mechanics/src/materials/SingleVariableReturnMappingSolution.C b/modules/solid_mechanics/src/materials/SingleVariableReturnMappingSolution.C index 04b8c3499a24..a8d264fbf865 100644 --- a/modules/solid_mechanics/src/materials/SingleVariableReturnMappingSolution.C +++ b/modules/solid_mechanics/src/materials/SingleVariableReturnMappingSolution.C @@ -16,8 +16,6 @@ #include "Conversion.h" #include "MathUtils.h" -#include "DualRealOps.h" - #include #include #include diff --git a/modules/solid_properties/include/solidproperties/ThermalSolidProperties.h b/modules/solid_properties/include/solidproperties/ThermalSolidProperties.h index 300364aa9d25..a869ddf3e336 100644 --- a/modules/solid_properties/include/solidproperties/ThermalSolidProperties.h +++ b/modules/solid_properties/include/solidproperties/ThermalSolidProperties.h @@ -17,14 +17,14 @@ * overriden in derived classes. */ #define propfuncAD(want) \ - virtual DualReal want##_from_T(const DualReal & T) const \ + virtual ADReal want##_from_T(const ADReal & T) const \ { \ Real x = 0; \ Real raw = T.value(); \ Real dxdT = 0; \ want##_from_T(raw, x, dxdT); \ \ - DualReal result = x; \ + ADReal result = x; \ result.derivatives() = T.derivatives() * dxdT; \ return result; \ } \ diff --git a/modules/thermal_hydraulics/test/src/materials/ADSmoothTransitionTestMaterial.C b/modules/thermal_hydraulics/test/src/materials/ADSmoothTransitionTestMaterial.C index 441c13d56b33..56536d737492 100644 --- a/modules/thermal_hydraulics/test/src/materials/ADSmoothTransitionTestMaterial.C +++ b/modules/thermal_hydraulics/test/src/materials/ADSmoothTransitionTestMaterial.C @@ -10,7 +10,7 @@ #include "ADSmoothTransitionTestMaterial.h" #include "ADReal.h" -#include "DualReal.h" +#include "ADReal.h" registerMooseObject("ThermalHydraulicsTestApp", ADSmoothTransitionTestMaterial); InputParameters diff --git a/test/src/constraints/GapHeatConductanceTest.C b/test/src/constraints/GapHeatConductanceTest.C index 9030f7336a5e..c54325c0c632 100644 --- a/test/src/constraints/GapHeatConductanceTest.C +++ b/test/src/constraints/GapHeatConductanceTest.C @@ -94,7 +94,7 @@ GapHeatConductanceTest::computeQpResidual(MortarType type) void GapHeatConductanceTest::computeJacobian(MortarType mortar_type) { - std::vector residuals; + std::vector residuals; size_t test_space_size = 0; typedef ConstraintJacobianType JType; typedef MortarType MType; diff --git a/unit/src/ADTypesTest.C b/unit/src/ADTypesTest.C index d2b72f3e5554..38ddee2e33ba 100644 --- a/unit/src/ADTypesTest.C +++ b/unit/src/ADTypesTest.C @@ -27,7 +27,7 @@ public: TEST(ADTypesTest, vector_DenseMatrix_Real) { - std::vector> vm(2); + std::vector> vm(2); auto & m1 = vm[0]; auto & m2 = vm[1]; m1.resize(3, 3); @@ -46,7 +46,7 @@ TEST(ADTypesTest, vector_DenseMatrix_Real) TEST(ADTypesTest, vector_DenseVector_Real) { - std::vector> vv(2); + std::vector> vv(2); auto & v1 = vv[0]; auto & v2 = vv[1]; v1.resize(3); diff --git a/unit/src/DenseMatrixDualRealTest.C b/unit/src/DenseMatrixADRealTest.C similarity index 83% rename from unit/src/DenseMatrixDualRealTest.C rename to unit/src/DenseMatrixADRealTest.C index 205f38875896..49117403c08c 100644 --- a/unit/src/DenseMatrixDualRealTest.C +++ b/unit/src/DenseMatrixADRealTest.C @@ -7,35 +7,33 @@ //* Licensed under LGPL 2.1, please see LICENSE for details //* https://www.gnu.org/licenses/lgpl-2.1.html -#include "DualReal.h" +#include "ADReal.h" #include "DenseMatrix.h" #include "libmesh/dense_vector.h" -#include "DualRealOps.h" - #include "gtest/gtest.h" using namespace libMesh; -TEST(DenseMatrixDualReal, TryOperations) +TEST(DenseMatrixADReal, TryOperations) { - DenseMatrix a(3, 3); - DenseMatrix b(3, 3); + DenseMatrix a(3, 3); + DenseMatrix b(3, 3); a.left_multiply(b); a.left_multiply_transpose(b); a.right_multiply(b); a.right_multiply_transpose(b); - DenseVector vec(3); - DenseVector dest(3); + DenseVector vec(3); + DenseVector dest(3); a.vector_mult(dest, vec); a.vector_mult_transpose(dest, vec); a.vector_mult_add(dest, 1, vec); a.outer_product(vec, dest); - DenseMatrix sub(2, 2); + DenseMatrix sub(2, 2); a.get_principal_submatrix(2, 2, sub); vec(0) = 1; diff --git a/unit/src/LinearInterpolationTest.C b/unit/src/LinearInterpolationTest.C index 778235dca493..5082cecaaa0e 100644 --- a/unit/src/LinearInterpolationTest.C +++ b/unit/src/LinearInterpolationTest.C @@ -10,11 +10,9 @@ #include "gtest/gtest.h" #include "LinearInterpolation.h" -#include "DualReal.h" +#include "ADReal.h" #include "ChainedReal.h" -#include "DualRealOps.h" - #include TEST(LinearInterpolationTest, getSampleSize) diff --git a/unit/src/RankTwoEigenRoutinesTest.C b/unit/src/RankTwoEigenRoutinesTest.C index 8d7cb657b48e..64a797faa6f4 100644 --- a/unit/src/RankTwoEigenRoutinesTest.C +++ b/unit/src/RankTwoEigenRoutinesTest.C @@ -9,10 +9,8 @@ #include "gtest/gtest.h" -#include "DualRealOps.h" - #include "MooseTypes.h" -#include "DualReal.h" +#include "ADReal.h" #include "RankTwoTensor.h" #include "RankFourTensor.h" @@ -33,7 +31,7 @@ } \ \ ADRankTwoTensor m_ad(a11, a22, a33, a23, a13, a12); \ - std::vector eigvals_ad; \ + std::vector eigvals_ad; \ ADRankTwoTensor eigvecs_ad; \ \ m_ad.symmetricEigenvaluesEigenvectors(eigvals_ad, eigvecs_ad); \ @@ -134,36 +132,36 @@ TEST(RankTwoEigenRoutines, symmetricEigenvaluesEigenvectors_dual_number_consiste Moose::derivInsert(da11_dx, 0, 1); Moose::derivInsert(da11_dx, 1, 2); Moose::derivInsert(da11_dx, 2, 3); - DualReal a11(241.6329, da11_dx); + ADReal a11(241.6329, da11_dx); DNDerivativeType da22_dx; Moose::derivInsert(da22_dx, 0, -2); Moose::derivInsert(da22_dx, 1, -5); Moose::derivInsert(da22_dx, 2, 1); - DualReal a22(222.3506, da22_dx); + ADReal a22(222.3506, da22_dx); DNDerivativeType da33_dx; Moose::derivInsert(da33_dx, 0, 2); Moose::derivInsert(da33_dx, 1, 1); Moose::derivInsert(da33_dx, 2, 4); - DualReal a33(236.0164, da33_dx); + ADReal a33(236.0164, da33_dx); DNDerivativeType da23_dx; Moose::derivInsert(da23_dx, 0, 2); Moose::derivInsert(da23_dx, 1, 4); Moose::derivInsert(da23_dx, 2, 6); - DualReal a23(168.9006, da23_dx); + ADReal a23(168.9006, da23_dx); DNDerivativeType da13_dx; Moose::derivInsert(da13_dx, 0, 1); Moose::derivInsert(da13_dx, 1, 3); Moose::derivInsert(da13_dx, 2, 5); - DualReal a13(-73.07, da13_dx); + ADReal a13(-73.07, da13_dx); DNDerivativeType da12_dx; Moose::derivInsert(da12_dx, 0, 2); Moose::derivInsert(da12_dx, 1, 3); Moose::derivInsert(da12_dx, 2, 4); - DualReal a12(96.7902, da12_dx); + ADReal a12(96.7902, da12_dx); ADRankTwoTensor m(a11, a22, a33, a23, a13, a12); ADRankTwoTensor eigvecs; - std::vector eigvals; + std::vector eigvals; m.symmetricEigenvaluesEigenvectors(eigvals, eigvecs); ADRankTwoTensor D_ad;