From b9c33449a9c2868f29078e155ea92b31b44f6588 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Mon, 8 Apr 2024 19:31:20 +0200 Subject: [PATCH 01/45] [PL/TH2M] Introduce separate derivatives update The assembleWithJacobian additionally to and after the updateConstitutiveRelations function calls computation of the derivatives. This separation is two-fold: - on the constitutive relations data, the derivatives are stored separately, - on the top-level the derivatives are computed only when needed. --- .../ConstitutiveRelations/ConstitutiveData.h | 8 +++ ProcessLib/TH2M/TH2MFEM-impl.h | 69 +++++++++++++++++++ ProcessLib/TH2M/TH2MFEM.h | 10 +++ 3 files changed, 87 insertions(+) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 7c4611cea70..5a7b609ae4b 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -209,5 +209,13 @@ struct ConstitutiveTempData double dfW_3a_dp_cap = std::numeric_limits::quiet_NaN(); double dfW_3a_dT = std::numeric_limits::quiet_NaN(); }; + +/// Data that stores intermediate values (derivatives), which are not needed +/// outside the constitutive setting. +template +struct DerivativesData +{ +}; + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 2f14daaaeeb..1eba36dc5c5 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -721,6 +721,68 @@ TH2MLocalAssembler +std::vector> +TH2MLocalAssembler:: + updateConstitutiveVariablesDerivatives( + Eigen::VectorXd const& local_x, Eigen::VectorXd const& local_x_prev, + double const t, double const dt, + std::vector< + ConstitutiveRelations::ConstitutiveTempData> const& + ip_constitutive_variables, + ConstitutiveRelations::ConstitutiveModels const& + models) +{ + [[maybe_unused]] auto const matrix_size = + gas_pressure_size + capillary_pressure_size + temperature_size + + displacement_size; + + assert(local_x.size() == matrix_size); + + auto const temperature = + local_x.template segment(temperature_index); + auto const temperature_prev = + local_x_prev.template segment(temperature_index); + + auto const& medium = + *this->process_data_.media_map.getMedium(this->element_.getID()); + ConstitutiveRelations::MediaData media_data{medium}; + + unsigned const n_integration_points = + this->integration_method_.getNumberOfPoints(); + + std::vector> + ip_d_data(n_integration_points); + + for (unsigned ip = 0; ip < n_integration_points; ip++) + { + auto const& ip_data = _ip_data[ip]; + auto& ip_dd = ip_d_data[ip]; + auto const& ip_cv = ip_constitutive_variables[ip]; + auto const& ip_out = this->output_data_[ip]; + auto const& current_state = this->current_states_[ip]; + + auto const& Nu = ip_data.N_u; + auto const& Np = ip_data.N_p; + auto const& NT = Np; + + ParameterLib::SpatialPosition const pos{ + std::nullopt, this->element_.getID(), ip, + MathLib::Point3d( + NumLib::interpolateCoordinates( + this->element_, Nu))}; + + double const T = NT.dot(temperature); + double const T_prev = NT.dot(temperature_prev); + ConstitutiveRelations::TemperatureData const T_data{T, T_prev}; + } + + return ip_d_data; +} + template std::size_t TH2MLocalAssembler< @@ -1515,10 +1577,17 @@ void TH2MLocalAssembler(local_x.data(), local_x.size()), + Eigen::Map(local_x_prev.data(), + local_x_prev.size()), + t, dt, ip_constitutive_variables, models); + for (unsigned int_point = 0; int_point < n_integration_points; int_point++) { auto& ip = _ip_data[int_point]; auto& ip_cd = ip_constitutive_data[int_point]; + auto& ip_dd = ip_d_data[int_point]; auto& ip_cv = ip_constitutive_variables[int_point]; auto& ip_out = this->output_data_[int_point]; auto& current_state = this->current_states_[int_point]; diff --git a/ProcessLib/TH2M/TH2MFEM.h b/ProcessLib/TH2M/TH2MFEM.h index 0d88646ae1f..1ea5fcb3559 100644 --- a/ProcessLib/TH2M/TH2MFEM.h +++ b/ProcessLib/TH2M/TH2MFEM.h @@ -198,6 +198,16 @@ class TH2MLocalAssembler : public LocalAssemblerInterface ConstitutiveRelations::ConstitutiveModels const& models); + std::vector> + updateConstitutiveVariablesDerivatives( + Eigen::VectorXd const& local_x, Eigen::VectorXd const& local_x_prev, + double const t, double const dt, + std::vector< + ConstitutiveRelations::ConstitutiveTempData> const& + ip_constitutive_variables, + ConstitutiveRelations::ConstitutiveModels const& + models); + private: using BMatricesType = BMatrixPolicyType; From 3533861fa9108a1cc4ffc034ae26eb39c45d5800 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Sat, 6 Apr 2024 14:07:20 +0200 Subject: [PATCH 02/45] [PL/TH2M] Extract advection storage and model Deduplicates Picard and Newton implementations --- .../TH2M/ConstitutiveRelations/Advection.cpp | 75 ++++++++++++ .../TH2M/ConstitutiveRelations/Advection.h | 61 ++++++++++ .../ConstitutiveRelations/ConstitutiveData.h | 5 +- .../ConstitutiveModels.h | 2 + ProcessLib/TH2M/TH2MFEM-impl.h | 114 ++++++++---------- 5 files changed, 192 insertions(+), 65 deletions(-) create mode 100644 ProcessLib/TH2M/ConstitutiveRelations/Advection.cpp create mode 100644 ProcessLib/TH2M/ConstitutiveRelations/Advection.h diff --git a/ProcessLib/TH2M/ConstitutiveRelations/Advection.cpp b/ProcessLib/TH2M/ConstitutiveRelations/Advection.cpp new file mode 100644 index 00000000000..a236f888782 --- /dev/null +++ b/ProcessLib/TH2M/ConstitutiveRelations/Advection.cpp @@ -0,0 +1,75 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#include "Advection.h" + +namespace ProcessLib::TH2M +{ +namespace ConstitutiveRelations +{ +template +void AdvectionModel::eval( + ConstituentDensityData const& constituent_density_data, + PermeabilityData const& permeability_data, + PureLiquidDensityData const& rho_W_LR, + ViscosityData const& viscosity_data, + AdvectionData& advection_data) const +{ + GlobalDimMatrix const k_over_mu_G = + permeability_data.Ki * permeability_data.k_rel_G / viscosity_data.mu_GR; + GlobalDimMatrix const k_over_mu_L = + permeability_data.Ki * permeability_data.k_rel_L / viscosity_data.mu_LR; + + advection_data.advection_C_G = + constituent_density_data.rho_C_GR * k_over_mu_G; + advection_data.advection_C_L = + constituent_density_data.rho_C_LR * k_over_mu_L; + advection_data.advection_W_G = + constituent_density_data.rho_W_GR * k_over_mu_G; + advection_data.advection_W_L = rho_W_LR() * k_over_mu_L; +} + +template +void AdvectionModel::dEval( + ConstituentDensityData const& constituent_density_data, + PermeabilityData const& permeability_data, + ViscosityData const& viscosity_data, + SaturationDataDeriv const& dS_L_dp_cap, + PhaseTransitionData const& phase_transition_data, + AdvectionDerivativeData& advection_d_data) const +{ + GlobalDimMatrix const k_over_mu_G = + permeability_data.Ki * permeability_data.k_rel_G / viscosity_data.mu_GR; + GlobalDimMatrix const k_over_mu_L = + permeability_data.Ki * permeability_data.k_rel_L / viscosity_data.mu_LR; + + GlobalDimMatrix const dk_over_mu_G_dp_cap = + permeability_data.Ki * permeability_data.dk_rel_G_dS_L * dS_L_dp_cap() / + viscosity_data.mu_GR; + GlobalDimMatrix const dk_over_mu_L_dp_cap = + permeability_data.Ki * permeability_data.dk_rel_L_dS_L * dS_L_dp_cap() / + viscosity_data.mu_LR; + + advection_d_data.dadvection_C_dp_GR = + phase_transition_data.drho_C_GR_dp_GR * k_over_mu_G + // + rhoCGR * (dk_over_mu_G_dp_GR = 0) + // + rhoCLR * (dk_over_mu_L_dp_GR = 0) + + phase_transition_data.drho_C_LR_dp_GR * k_over_mu_L; + + advection_d_data.dadvection_C_dp_cap = + //(drho_C_GR_dp_cap = 0) * k_over_mu_G + constituent_density_data.rho_C_GR * dk_over_mu_G_dp_cap + + (-phase_transition_data.drho_C_LR_dp_LR) * k_over_mu_L + + constituent_density_data.rho_C_LR * dk_over_mu_L_dp_cap; +} + +template struct AdvectionModel<2>; +template struct AdvectionModel<3>; +} // namespace ConstitutiveRelations +} // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/Advection.h b/ProcessLib/TH2M/ConstitutiveRelations/Advection.h new file mode 100644 index 00000000000..316f52b82ab --- /dev/null +++ b/ProcessLib/TH2M/ConstitutiveRelations/Advection.h @@ -0,0 +1,61 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#pragma once + +#include "Base.h" +#include "ConstitutiveDensity.h" +#include "PermeabilityData.h" +#include "PhaseTransitionData.h" +#include "PureLiquidDensity.h" +#include "Saturation.h" +#include "Viscosity.h" + +namespace ProcessLib::TH2M +{ +namespace ConstitutiveRelations +{ +template +struct AdvectionData +{ + GlobalDimMatrix advection_C_G; + GlobalDimMatrix advection_C_L; + GlobalDimMatrix advection_W_G; + GlobalDimMatrix advection_W_L; +}; + +template +struct AdvectionDerivativeData +{ + GlobalDimMatrix dadvection_C_dp_GR; + GlobalDimMatrix dadvection_C_dp_cap; +}; + +template +struct AdvectionModel +{ + void eval(ConstituentDensityData const& constituent_density_data, + PermeabilityData const& permeability_data, + PureLiquidDensityData const& rho_W_LR, + ViscosityData const& viscosity_data, + AdvectionData& advection_data) const; + + void dEval( + ConstituentDensityData const& constituent_density_data, + PermeabilityData const& permeability_data, + ViscosityData const& viscosity_data, + SaturationDataDeriv const& dS_L_dp_cap, + PhaseTransitionData const& phase_transition_data, + AdvectionDerivativeData& advection_d_data) const; +}; + +extern template struct AdvectionModel<2>; +extern template struct AdvectionModel<3>; +} // namespace ConstitutiveRelations +} // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 5a7b609ae4b..84c6c8ceffc 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -9,6 +9,7 @@ #pragma once +#include "Advection.h" #include "Biot.h" #include "Bishops.h" #include "ConstitutiveDensity.h" @@ -156,6 +157,7 @@ struct ConstitutiveTempData EffectiveVolumetricEnthalpyDerivatives effective_volumetric_enthalpy_d_data; EffectiveVolumetricInternalEnergyDerivatives effective_volumetric_internal_energy_d_data; + AdvectionData advection_data; using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = @@ -185,8 +187,6 @@ struct ConstitutiveTempData DisplacementDimMatrix dfC_4_LCpC_d_dp_GR; DisplacementDimMatrix dfC_4_LCpC_d_dp_cap; DisplacementDimMatrix dfC_4_LCpC_d_dT; - DisplacementDimMatrix dadvection_C_dp_GR; - DisplacementDimMatrix dadvection_C_dp_cap; DisplacementDimMatrix dk_over_mu_G_dp_cap; DisplacementDimMatrix dk_over_mu_L_dp_cap; double dfC_4_MCpG_dp_GR = std::numeric_limits::quiet_NaN(); @@ -215,6 +215,7 @@ struct ConstitutiveTempData template struct DerivativesData { + AdvectionDerivativeData advection_d_data; }; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index e37d7c906d2..6e21587f9dc 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -9,6 +9,7 @@ #pragma once +#include "Advection.h" #include "Biot.h" #include "Bishops.h" #include "ElasticTangentStiffnessModel.h" @@ -74,6 +75,7 @@ struct ConstitutiveModels #endif // NON_CONSTANT_SOLID_PHASE_VOLUME_FRACTION SolidHeatCapacityModel solid_heat_capacity_model; ThermalConductivityModel thermal_conductivity_model; + AdvectionModel advection_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 1eba36dc5c5..7a9327e4655 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -254,6 +254,12 @@ TH2MLocalAssembler; - DisplacementDimMatrix const advection_C_G = - current_state.constituent_density_data.rho_C_GR * k_over_mu_G; - DisplacementDimMatrix const advection_C_L = - current_state.constituent_density_data.rho_C_LR * k_over_mu_L; - DisplacementDimMatrix const diffusion_CGpGR = -phi_G * rhoGR * D_C_G * ip_cv.phase_transition_data.dxmWG_dpGR; DisplacementDimMatrix const diffusion_CLpGR = @@ -1259,7 +1247,9 @@ void TH2MLocalAssembler< DisplacementDimMatrix const diffusion_CLT = -phi_L * rhoLR * D_C_L * ip_cv.phase_transition_data.dxmWL_dT; - DisplacementDimMatrix const advection_C = advection_C_G + advection_C_L; + DisplacementDimMatrix const advection_C = + ip_cv.advection_data.advection_C_G + + ip_cv.advection_data.advection_C_L; DisplacementDimMatrix const diffusion_C_pGR = diffusion_CGpGR + diffusion_CLpGR; DisplacementDimMatrix const diffusion_C_pCap = @@ -1272,12 +1262,15 @@ void TH2MLocalAssembler< gradNpT * (advection_C + diffusion_C_pGR) * gradNp * w; LCpC.noalias() += - gradNpT * (diffusion_C_pCap - advection_C_L) * gradNp * w; + gradNpT * (diffusion_C_pCap - ip_cv.advection_data.advection_C_L) * + gradNp * w; LCT.noalias() += gradNpT * (diffusion_C_T)*gradNp * w; - fC.noalias() += - gradNpT * (advection_C_G * rhoGR + advection_C_L * rhoLR) * b * w; + fC.noalias() += gradNpT * + (ip_cv.advection_data.advection_C_G * rhoGR + + ip_cv.advection_data.advection_C_L * rhoLR) * + b * w; if (!this->process_data_.apply_mass_lumping) { @@ -1325,11 +1318,6 @@ void TH2MLocalAssembler< MWu.noalias() += NpT * rho_W_FR * alpha_B * mT * Bu * w; - DisplacementDimMatrix const advection_W_G = - current_state.constituent_density_data.rho_W_GR * k_over_mu_G; - DisplacementDimMatrix const advection_W_L = - current_state.rho_W_LR() * k_over_mu_L; - DisplacementDimMatrix const diffusion_WGpGR = phi_G * rhoGR * D_W_G * ip_cv.phase_transition_data.dxmWG_dpGR; DisplacementDimMatrix const diffusion_WLpGR = @@ -1345,7 +1333,9 @@ void TH2MLocalAssembler< DisplacementDimMatrix const diffusion_WLT = phi_L * rhoLR * D_W_L * ip_cv.phase_transition_data.dxmWL_dT; - DisplacementDimMatrix const advection_W = advection_W_G + advection_W_L; + DisplacementDimMatrix const advection_W = + ip_cv.advection_data.advection_W_G + + ip_cv.advection_data.advection_W_L; DisplacementDimMatrix const diffusion_W_pGR = diffusion_WGpGR + diffusion_WLpGR; DisplacementDimMatrix const diffusion_W_pCap = @@ -1358,12 +1348,15 @@ void TH2MLocalAssembler< gradNpT * (advection_W + diffusion_W_pGR) * gradNp * w; LWpC.noalias() += - gradNpT * (diffusion_W_pCap - advection_W_L) * gradNp * w; + gradNpT * (diffusion_W_pCap - ip_cv.advection_data.advection_W_L) * + gradNp * w; LWT.noalias() += gradNpT * (diffusion_W_T)*gradNp * w; - fW.noalias() += - gradNpT * (advection_W_G * rhoGR + advection_W_L * rhoLR) * b * w; + fW.noalias() += gradNpT * + (ip_cv.advection_data.advection_W_G * rhoGR + + ip_cv.advection_data.advection_W_L * rhoLR) * + b * w; if (!this->process_data_.apply_mass_lumping) { @@ -1704,13 +1697,6 @@ void TH2MLocalAssembler(C_index, C_index).noalias() += gradNpT * - (ip_cv.dadvection_C_dp_GR + (ip_dd.advection_d_data.dadvection_C_dp_GR // + ip_cv.ddiffusion_C_p_dp_GR TODO (naumov) ) * gradpGR * Np * w; @@ -1784,7 +1768,7 @@ void TH2MLocalAssembler(C_index, W_index).noalias() += gradNpT * - (ip_cv.dadvection_C_dp_cap + (ip_dd.advection_d_data.dadvection_C_dp_cap // + ip_cv.ddiffusion_C_p_dp_GR TODO (naumov) ) * gradpGR * Np * w; @@ -1807,7 +1791,8 @@ void TH2MLocalAssemblerprocess_data_.apply_mass_lumping) { @@ -1921,10 +1908,6 @@ void TH2MLocalAssembler(W_index, C_index).noalias() -= @@ -1980,8 +1966,10 @@ void TH2MLocalAssemblerprocess_data_.apply_mass_lumping) From b96ad4c27c38ffad4f7daf39df11ae0831893137 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Mon, 8 Apr 2024 22:58:40 +0200 Subject: [PATCH 03/45] [PL/TH2M] Separate thermal cond. derivatives --- .../ConstitutiveRelations/ConstitutiveData.h | 2 ++ .../ThermalConductivity.cpp | 8 +++++--- .../ThermalConductivity.h | 20 ++++++++++++------- ProcessLib/TH2M/TH2MFEM-impl.h | 9 +++++---- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 84c6c8ceffc..07c89991dab 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -153,6 +153,8 @@ struct ConstitutiveTempData SolidDensityDerivativeData solid_density_d_data; SolidHeatCapacityData solid_heat_capacity_data; ThermalConductivityData thermal_conductivity_data; + ThermalConductivityDerivativeData + thermal_conductivity_d_data; EffectiveVolumetricEnthalpy effective_volumetric_enthalpy_data; EffectiveVolumetricEnthalpyDerivatives effective_volumetric_enthalpy_d_data; EffectiveVolumetricInternalEnergyDerivatives diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.cpp b/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.cpp index abd9e0cc9f3..e9276418678 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.cpp @@ -21,7 +21,9 @@ void ThermalConductivityModel::eval( TemperatureData const& T_data, PorosityData const& porosity_data, PorosityDerivativeData const& porosity_d_data, SaturationData const& S_L_data, SaturationDataDeriv const& dS_L_dp_cap, - ThermalConductivityData& thermal_conductivity_data) const + ThermalConductivityData& thermal_conductivity_data, + ThermalConductivityDerivativeData& + thermal_conductivity_d_data) const { namespace MPL = MaterialPropertyLib; MPL::VariableArray variables; @@ -88,7 +90,7 @@ void ThermalConductivityModel::eval( // dphi_L_dp_GR = ds_L_dp_GR * phi = 0; double const dphi_L_dp_cap = dS_L_dp_cap() * porosity_data.phi; - thermal_conductivity_data.dlambda_dp_cap = + thermal_conductivity_d_data.dlambda_dp_cap = dphi_G_dp_cap * lambdaGR + dphi_L_dp_cap * lambdaLR; double const phi_L = S_L_data.S_L * porosity_data.phi; @@ -99,7 +101,7 @@ void ThermalConductivityModel::eval( // dphi_G_dT = -dS_L/dT * phi + (1 - S_L) * dphi_dT = (1 - S_L) * dphi_dT // dphi_L_dT = dS_L/dT * phi + S_L * dphi_dT S_L * dphi_dT // dphi_S_dT = -dphi_dT -dphi_dT - thermal_conductivity_data.dlambda_dT = + thermal_conductivity_d_data.dlambda_dT = (1 - S_L_data.S_L) * porosity_d_data.dphi_dT * lambdaGR + phi_G * dlambda_GR_dT + S_L_data.S_L * porosity_d_data.dphi_dT * lambdaLR + diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.h b/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.h index fbf34021e55..384f43cc760 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.h @@ -22,6 +22,11 @@ template struct ThermalConductivityData { GlobalDimMatrix lambda; +}; + +template +struct ThermalConductivityDerivativeData +{ // Currently unused, but there is a comment in TH2MFEM-impl.h referring to // this matrix // GlobalDimMatrix dlambda_dp_GR; @@ -32,13 +37,14 @@ struct ThermalConductivityData template struct ThermalConductivityModel { - void eval(SpaceTimeData const& x_t, MediaData const& media_data, - TemperatureData const& T_data, PorosityData const& porosity_data, - PorosityDerivativeData const& porosity_d_data, - SaturationData const& S_L_data, - SaturationDataDeriv const& dS_L_dp_cap, - ThermalConductivityData& - thermal_conductivity_data) const; + void eval( + SpaceTimeData const& x_t, MediaData const& media_data, + TemperatureData const& T_data, PorosityData const& porosity_data, + PorosityDerivativeData const& porosity_d_data, + SaturationData const& S_L_data, SaturationDataDeriv const& dS_L_dp_cap, + ThermalConductivityData& thermal_conductivity_data, + ThermalConductivityDerivativeData& + thermal_conductivity_d_data) const; }; extern template struct ThermalConductivityModel<2>; diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 7a9327e4655..7818e657d70 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -252,7 +252,7 @@ TH2MLocalAssembler(temperature_index, W_index) .noalias() += gradNTT * - ip_cv.thermal_conductivity_data.dlambda_dp_cap * + ip_cv.thermal_conductivity_d_data.dlambda_dp_cap * gradT * Np * w; // d KTT/dT * T local_Jac .template block( temperature_index, temperature_index) - .noalias() += gradNTT * ip_cv.thermal_conductivity_data.dlambda_dT * - gradT * NT * w; + .noalias() += gradNTT * + ip_cv.thermal_conductivity_d_data.dlambda_dT * gradT * + NT * w; // fT_1 auto const rho_u_eff_dot = (current_state.internal_energy_data() - From 27652141ca4d27b2fdef51fdd7a95fbc15dbe51d Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Mon, 8 Apr 2024 23:21:46 +0200 Subject: [PATCH 04/45] [PL/TH2M] Move thermal cond. derivative comput. evaluate only for Jacobian. --- .../ConstitutiveRelations/ConstitutiveData.h | 4 ++-- .../ThermalConductivity.cpp | 24 +++++++++++++++---- .../ThermalConductivity.h | 21 +++++++++------- ProcessLib/TH2M/TH2MFEM-impl.h | 12 ++++++---- 4 files changed, 42 insertions(+), 19 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 07c89991dab..135b533074b 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -153,8 +153,6 @@ struct ConstitutiveTempData SolidDensityDerivativeData solid_density_d_data; SolidHeatCapacityData solid_heat_capacity_data; ThermalConductivityData thermal_conductivity_data; - ThermalConductivityDerivativeData - thermal_conductivity_d_data; EffectiveVolumetricEnthalpy effective_volumetric_enthalpy_data; EffectiveVolumetricEnthalpyDerivatives effective_volumetric_enthalpy_d_data; EffectiveVolumetricInternalEnergyDerivatives @@ -218,6 +216,8 @@ template struct DerivativesData { AdvectionDerivativeData advection_d_data; + ThermalConductivityDerivativeData + thermal_conductivity_d_data; }; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.cpp b/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.cpp index e9276418678..60002a217fb 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.cpp @@ -19,11 +19,8 @@ template void ThermalConductivityModel::eval( SpaceTimeData const& x_t, MediaData const& media_data, TemperatureData const& T_data, PorosityData const& porosity_data, - PorosityDerivativeData const& porosity_d_data, - SaturationData const& S_L_data, SaturationDataDeriv const& dS_L_dp_cap, - ThermalConductivityData& thermal_conductivity_data, - ThermalConductivityDerivativeData& - thermal_conductivity_d_data) const + SaturationData const& S_L_data, + ThermalConductivityData& thermal_conductivity_data) const { namespace MPL = MaterialPropertyLib; MPL::VariableArray variables; @@ -36,6 +33,22 @@ void ThermalConductivityModel::eval( thermal_conductivity_data.lambda = MPL::formEigenTensor( mpl_thermal_conductivity.value(variables, x_t.x, x_t.t, x_t.dt)); +} + +template +void ThermalConductivityModel::dEval( + SpaceTimeData const& x_t, MediaData const& media_data, + TemperatureData const& T_data, PorosityData const& porosity_data, + PorosityDerivativeData const& porosity_d_data, + SaturationData const& S_L_data, SaturationDataDeriv const& dS_L_dp_cap, + ThermalConductivityDerivativeData& + thermal_conductivity_d_data) const +{ + namespace MPL = MaterialPropertyLib; + MPL::VariableArray variables; + variables.temperature = T_data.T; + variables.porosity = porosity_data.phi; + variables.liquid_saturation = S_L_data.S_L; // Derivatives computed here and not in the MPL property because various // derivatives are not available in the VariableArray. @@ -108,6 +121,7 @@ void ThermalConductivityModel::eval( +phi_L * dlambda_LR_dT - porosity_d_data.dphi_dT * lambdaSR + phi_S * dlambda_SR_dT; } + template struct ThermalConductivityModel<2>; template struct ThermalConductivityModel<3>; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.h b/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.h index 384f43cc760..eefb94ef707 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.h @@ -37,14 +37,19 @@ struct ThermalConductivityDerivativeData template struct ThermalConductivityModel { - void eval( - SpaceTimeData const& x_t, MediaData const& media_data, - TemperatureData const& T_data, PorosityData const& porosity_data, - PorosityDerivativeData const& porosity_d_data, - SaturationData const& S_L_data, SaturationDataDeriv const& dS_L_dp_cap, - ThermalConductivityData& thermal_conductivity_data, - ThermalConductivityDerivativeData& - thermal_conductivity_d_data) const; + void eval(SpaceTimeData const& x_t, MediaData const& media_data, + TemperatureData const& T_data, PorosityData const& porosity_data, + SaturationData const& S_L_data, + ThermalConductivityData& + thermal_conductivity_data) const; + + void dEval(SpaceTimeData const& x_t, MediaData const& media_data, + TemperatureData const& T_data, PorosityData const& porosity_data, + PorosityDerivativeData const& porosity_d_data, + SaturationData const& S_L_data, + SaturationDataDeriv const& dS_L_dp_cap, + ThermalConductivityDerivativeData& + thermal_conductivity_d_data) const; }; extern template struct ThermalConductivityModel<2>; diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 7818e657d70..ebc9440114b 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -251,8 +251,7 @@ TH2MLocalAssembler(temperature_index, W_index) .noalias() += gradNTT * - ip_cv.thermal_conductivity_d_data.dlambda_dp_cap * + ip_dd.thermal_conductivity_d_data.dlambda_dp_cap * gradT * Np * w; // d KTT/dT * T @@ -2087,7 +2091,7 @@ void TH2MLocalAssembler( temperature_index, temperature_index) .noalias() += gradNTT * - ip_cv.thermal_conductivity_d_data.dlambda_dT * gradT * + ip_dd.thermal_conductivity_d_data.dlambda_dT * gradT * NT * w; // fT_1 From 1a6ac0af3ff2badf2ef328faef917a740dc7faae Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Tue, 9 Apr 2024 16:55:24 +0200 Subject: [PATCH 05/45] [PL/TH2M] Extract internal energy model --- .../ConstitutiveRelations/ConstitutiveData.h | 4 +- .../ConstitutiveModels.h | 2 + .../ConstitutiveRelations/InternalEnergy.cpp | 95 +++++++++++++++++++ .../ConstitutiveRelations/InternalEnergy.h | 31 ++++++ ProcessLib/TH2M/TH2MFEM-impl.h | 56 +++++------ 5 files changed, 153 insertions(+), 35 deletions(-) create mode 100644 ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.cpp diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 135b533074b..d4f288f9003 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -155,8 +155,6 @@ struct ConstitutiveTempData ThermalConductivityData thermal_conductivity_data; EffectiveVolumetricEnthalpy effective_volumetric_enthalpy_data; EffectiveVolumetricEnthalpyDerivatives effective_volumetric_enthalpy_d_data; - EffectiveVolumetricInternalEnergyDerivatives - effective_volumetric_internal_energy_d_data; AdvectionData advection_data; using DisplacementDimVector = Eigen::Matrix; @@ -218,6 +216,8 @@ struct DerivativesData AdvectionDerivativeData advection_d_data; ThermalConductivityDerivativeData thermal_conductivity_d_data; + EffectiveVolumetricInternalEnergyDerivatives + effective_volumetric_internal_energy_d_data; }; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index 6e21587f9dc..232426518bc 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -13,6 +13,7 @@ #include "Biot.h" #include "Bishops.h" #include "ElasticTangentStiffnessModel.h" +#include "InternalEnergy.h" #include "MechanicalStrain.h" #include "PermeabilityModel.h" #include "PhaseTransitionModel.h" @@ -76,6 +77,7 @@ struct ConstitutiveModels SolidHeatCapacityModel solid_heat_capacity_model; ThermalConductivityModel thermal_conductivity_model; AdvectionModel advection_model; + InternalEnergyModel internal_energy_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.cpp b/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.cpp new file mode 100644 index 00000000000..7911510ab47 --- /dev/null +++ b/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.cpp @@ -0,0 +1,95 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#include "InternalEnergy.h" + +namespace ProcessLib::TH2M +{ +namespace ConstitutiveRelations +{ +void InternalEnergyModel::eval(EnthalpyData const& enthalpy_data, + FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + SolidDensityData const& solid_density_data, + InternalEnergyData& internal_energy_data) const +{ + auto const phi_L = S_L_data.S_L * porosity_data.phi; + auto const phi_G = (1. - S_L_data.S_L) * porosity_data.phi; + double const phi_S = 1. - porosity_data.phi; + + auto const u_S = enthalpy_data.h_S; + + internal_energy_data() = + phi_G * fluid_density_data.rho_GR * phase_transition_data.uG + + phi_L * fluid_density_data.rho_LR * phase_transition_data.uL + + phi_S * solid_density_data.rho_SR * u_S; +} + +void InternalEnergyModel::dEval( + EnthalpyData const& enthalpy_data, + FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + PorosityDerivativeData const& porosity_d_data, + SaturationData const& S_L_data, + SaturationDataDeriv const& dS_L_dp_cap, + SolidDensityData const& solid_density_data, + SolidDensityDerivativeData const& solid_density_d_data, + SolidHeatCapacityData const& solid_heat_capacity_data, + EffectiveVolumetricInternalEnergyDerivatives& + effective_volumetric_internal_energy_d_data) const +{ + auto const phi_L = S_L_data.S_L * porosity_data.phi; + auto const phi_G = (1. - S_L_data.S_L) * porosity_data.phi; + double const phi_S = 1. - porosity_data.phi; + + auto const u_S = enthalpy_data.h_S; + effective_volumetric_internal_energy_d_data.drho_u_eff_dT = + phi_G * phase_transition_data.drho_GR_dT * phase_transition_data.uG + + phi_G * fluid_density_data.rho_GR * phase_transition_data.du_G_dT + + phi_L * phase_transition_data.drho_LR_dT * phase_transition_data.uL + + phi_L * fluid_density_data.rho_LR * phase_transition_data.du_L_dT + + phi_S * solid_density_d_data.drho_SR_dT * u_S + + phi_S * solid_density_data.rho_SR * solid_heat_capacity_data() - + porosity_d_data.dphi_dT * solid_density_data.rho_SR * u_S; + + // dphi_G_dp_GR = -ds_L_dp_GR * porosity_data.phi = 0; + double const dphi_G_dp_cap = -dS_L_dp_cap() * porosity_data.phi; + // dphi_L_dp_GR = ds_L_dp_GR * porosity_data.phi = 0; + double const dphi_L_dp_cap = dS_L_dp_cap() * porosity_data.phi; + + // From p_LR = p_GR - p_cap it follows for + // drho_LR/dp_GR = drho_LR/dp_LR * dp_LR/dp_GR + // = drho_LR/dp_LR * (dp_GR/dp_GR - dp_cap/dp_GR) + // = drho_LR/dp_LR * (1 - 0) + double const drho_LR_dp_GR = phase_transition_data.drho_LR_dp_LR; + double const drho_LR_dp_cap = -phase_transition_data.drho_LR_dp_LR; + // drho_GR_dp_cap = 0; + + effective_volumetric_internal_energy_d_data.drho_u_eff_dp_GR = + /*(dphi_G_dp_GR = 0) * fluid_density_data.rho_GR * + phase_transition_data.uG +*/ + phi_G * phase_transition_data.drho_GR_dp_GR * phase_transition_data.uG + + phi_G * fluid_density_data.rho_GR * phase_transition_data.du_G_dp_GR + + /*(dphi_L_dp_GR = 0) * fluid_density_data.rho_LR * + phase_transition_data.uL +*/ + phi_L * drho_LR_dp_GR * phase_transition_data.uL + + phi_L * fluid_density_data.rho_LR * phase_transition_data.du_L_dp_GR; + + effective_volumetric_internal_energy_d_data.drho_u_eff_dp_cap = + dphi_G_dp_cap * fluid_density_data.rho_GR * phase_transition_data.uG + + /*phi_G * (drho_GR_dp_cap = 0) * phase_transition_data.uG +*/ + dphi_L_dp_cap * fluid_density_data.rho_LR * phase_transition_data.uL + + phi_L * drho_LR_dp_cap * phase_transition_data.uL + + phi_L * fluid_density_data.rho_LR * phase_transition_data.du_L_dp_cap; +} +} // namespace ConstitutiveRelations +} // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.h b/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.h index 73644146b34..727010140bc 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.h @@ -11,6 +11,13 @@ #include "Base.h" #include "BaseLib/StrongType.h" +#include "Enthalpy.h" +#include "FluidDensity.h" +#include "PhaseTransitionData.h" +#include "Porosity.h" +#include "Saturation.h" +#include "SolidDensity.h" +#include "SolidHeatCapacity.h" namespace ProcessLib::TH2M { @@ -25,5 +32,29 @@ struct EffectiveVolumetricInternalEnergyDerivatives double drho_u_eff_dp_GR = nan; double drho_u_eff_dp_cap = nan; }; + +struct InternalEnergyModel +{ + void eval(EnthalpyData const& enthalpy_data, + FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + SolidDensityData const& solid_density_data, + InternalEnergyData& internal_energy_data) const; + + void dEval(EnthalpyData const& enthalpy_data, + FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + PorosityDerivativeData const& porosity_d_data, + SaturationData const& S_L_data, + SaturationDataDeriv const& dS_L_dp_cap, + SolidDensityData const& solid_density_data, + SolidDensityDerivativeData const& solid_density_d_data, + SolidHeatCapacityData const& solid_heat_capacity_data, + EffectiveVolumetricInternalEnergyDerivatives& + effective_volumetric_internal_energy_d_data) const; +}; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index ebc9440114b..15cef2ccdbb 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -268,12 +268,14 @@ TH2MLocalAssemblerprocess_data_.specific_body_force; GlobalDimMatrixType const k_over_mu_G = ip_out.permeability_data.Ki * ip_out.permeability_data.k_rel_G / @@ -782,6 +759,19 @@ TH2MLocalAssembler(temperature_index, C_index) .noalias() += NpT * Np * - (ip_cv.effective_volumetric_internal_energy_d_data + (ip_dd.effective_volumetric_internal_energy_d_data .drho_u_eff_dp_GR / dt * w); @@ -2114,7 +2104,7 @@ void TH2MLocalAssembler(temperature_index, W_index) .noalias() += NpT * Np * - (ip_cv.effective_volumetric_internal_energy_d_data + (ip_dd.effective_volumetric_internal_energy_d_data .drho_u_eff_dp_cap / dt * w); @@ -2125,7 +2115,7 @@ void TH2MLocalAssembler Date: Tue, 9 Apr 2024 18:14:45 +0200 Subject: [PATCH 06/45] [PL/TH2M] Extract effective vol. enthalpy model separating the rho_h_eff evaluation and their derivatives. --- .../ConstitutiveRelations/ConstitutiveData.h | 2 +- .../ConstitutiveModels.h | 2 + .../TH2M/ConstitutiveRelations/Enthalpy.cpp | 95 +++++++++++++++++++ .../TH2M/ConstitutiveRelations/Enthalpy.h | 30 ++++++ ProcessLib/TH2M/TH2MFEM-impl.h | 94 ++++++------------ 5 files changed, 159 insertions(+), 64 deletions(-) create mode 100644 ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.cpp diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index d4f288f9003..def77685938 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -154,7 +154,6 @@ struct ConstitutiveTempData SolidHeatCapacityData solid_heat_capacity_data; ThermalConductivityData thermal_conductivity_data; EffectiveVolumetricEnthalpy effective_volumetric_enthalpy_data; - EffectiveVolumetricEnthalpyDerivatives effective_volumetric_enthalpy_d_data; AdvectionData advection_data; using DisplacementDimVector = Eigen::Matrix; @@ -218,6 +217,7 @@ struct DerivativesData thermal_conductivity_d_data; EffectiveVolumetricInternalEnergyDerivatives effective_volumetric_internal_energy_d_data; + EffectiveVolumetricEnthalpyDerivatives effective_volumetric_enthalpy_d_data; }; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index 232426518bc..af8f4b33870 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -13,6 +13,7 @@ #include "Biot.h" #include "Bishops.h" #include "ElasticTangentStiffnessModel.h" +#include "Enthalpy.h" #include "InternalEnergy.h" #include "MechanicalStrain.h" #include "PermeabilityModel.h" @@ -78,6 +79,7 @@ struct ConstitutiveModels ThermalConductivityModel thermal_conductivity_model; AdvectionModel advection_model; InternalEnergyModel internal_energy_model; + EffectiveVolumetricEnthalpyModel effective_volumetric_enthalpy_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.cpp b/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.cpp new file mode 100644 index 00000000000..a6c4acb2f03 --- /dev/null +++ b/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.cpp @@ -0,0 +1,95 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#include "InternalEnergy.h" + +namespace ProcessLib::TH2M +{ +namespace ConstitutiveRelations +{ +void EffectiveVolumetricEnthalpyModel::eval( + EnthalpyData const& enthalpy_data, + FluidDensityData const& fluid_density_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + SolidDensityData const& solid_density_data, + EffectiveVolumetricEnthalpy& effective_volumetric_enthalpy_data) const +{ + auto const phi_L = S_L_data.S_L * porosity_data.phi; + auto const phi_G = (1. - S_L_data.S_L) * porosity_data.phi; + double const phi_S = 1. - porosity_data.phi; + + effective_volumetric_enthalpy_data.rho_h_eff = + phi_G * fluid_density_data.rho_GR * enthalpy_data.h_G + + phi_L * fluid_density_data.rho_LR * enthalpy_data.h_L + + phi_S * solid_density_data.rho_SR * enthalpy_data.h_S; +} + +void EffectiveVolumetricEnthalpyModel::dEval( + EnthalpyData const& enthalpy_data, + FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + PorosityDerivativeData const& porosity_d_data, + SaturationData const& S_L_data, + SaturationDataDeriv const& dS_L_dp_cap, + SolidDensityData const& solid_density_data, + SolidDensityDerivativeData const& solid_density_d_data, + SolidHeatCapacityData const& solid_heat_capacity_data, + EffectiveVolumetricEnthalpyDerivatives& + effective_volumetric_enthalpy_d_data) const +{ + auto const phi_L = S_L_data.S_L * porosity_data.phi; + auto const phi_G = (1. - S_L_data.S_L) * porosity_data.phi; + double const phi_S = 1. - porosity_data.phi; + + // dphi_G_dp_GR = -ds_L_dp_GR * porosity_data.phi = 0; + double const dphi_G_dp_cap = -dS_L_dp_cap() * porosity_data.phi; + // dphi_L_dp_GR = ds_L_dp_GR * porosity_data.phi = 0; + double const dphi_L_dp_cap = dS_L_dp_cap() * porosity_data.phi; + + // From p_LR = p_GR - p_cap it follows for + // drho_LR/dp_GR = drho_LR/dp_LR * dp_LR/dp_GR + // = drho_LR/dp_LR * (dp_GR/dp_GR - dp_cap/dp_GR) + // = drho_LR/dp_LR * (1 - 0) + double const drho_LR_dp_GR = phase_transition_data.drho_LR_dp_LR; + double const drho_LR_dp_cap = -phase_transition_data.drho_LR_dp_LR; + // drho_GR_dp_cap = 0; + + effective_volumetric_enthalpy_d_data.drho_h_eff_dp_GR = + /*(dphi_G_dp_GR = 0) * fluid_density_data.rho_GR * + enthalpy_data.h_G +*/ + phi_G * phase_transition_data.drho_GR_dp_GR * enthalpy_data.h_G + + /*(dphi_L_dp_GR = 0) * fluid_density_data.rho_LR * + enthalpy_data.h_L +*/ + phi_L * drho_LR_dp_GR * enthalpy_data.h_L; + effective_volumetric_enthalpy_d_data.drho_h_eff_dp_cap = + dphi_G_dp_cap * fluid_density_data.rho_GR * enthalpy_data.h_G + + /*phi_G * (drho_GR_dp_cap = 0) * enthalpy_data.h_G +*/ + dphi_L_dp_cap * fluid_density_data.rho_LR * enthalpy_data.h_L + + phi_L * drho_LR_dp_cap * enthalpy_data.h_L; + + // TODO (naumov) Extend for temperature dependent porosities. + constexpr double dphi_G_dT = 0; + constexpr double dphi_L_dT = 0; + effective_volumetric_enthalpy_d_data.drho_h_eff_dT = + dphi_G_dT * fluid_density_data.rho_GR * enthalpy_data.h_G + + phi_G * phase_transition_data.drho_GR_dT * enthalpy_data.h_G + + phi_G * fluid_density_data.rho_GR * phase_transition_data.dh_G_dT + + dphi_L_dT * fluid_density_data.rho_LR * enthalpy_data.h_L + + phi_L * phase_transition_data.drho_LR_dT * enthalpy_data.h_L + + phi_L * fluid_density_data.rho_LR * phase_transition_data.dh_L_dT - + porosity_d_data.dphi_dT * solid_density_data.rho_SR * + enthalpy_data.h_S + + phi_S * solid_density_d_data.drho_SR_dT * enthalpy_data.h_S + + phi_S * solid_density_data.rho_SR * solid_heat_capacity_data(); +} + +} // namespace ConstitutiveRelations +} // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.h b/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.h index b7a1686618b..3c8d8182984 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.h @@ -10,7 +10,14 @@ #pragma once #include "Base.h" +#include "Enthalpy.h" +#include "FluidDensity.h" +#include "PhaseTransitionData.h" +#include "Porosity.h" #include "ProcessLib/Reflection/ReflectionData.h" +#include "Saturation.h" +#include "SolidDensity.h" +#include "SolidHeatCapacity.h" namespace ProcessLib::TH2M { @@ -45,5 +52,28 @@ struct EffectiveVolumetricEnthalpyDerivatives double drho_h_eff_dp_cap = nan; }; +struct EffectiveVolumetricEnthalpyModel +{ + void eval( + EnthalpyData const& enthalpy_data, + FluidDensityData const& fluid_density_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + SolidDensityData const& solid_density_data, + EffectiveVolumetricEnthalpy& effective_volumetric_enthalpy_data) const; + + void dEval(EnthalpyData const& enthalpy_data, + FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + PorosityDerivativeData const& porosity_d_data, + SaturationData const& S_L_data, + SaturationDataDeriv const& dS_L_dp_cap, + SolidDensityData const& solid_density_data, + SolidDensityDerivativeData const& solid_density_d_data, + SolidHeatCapacityData const& solid_heat_capacity_data, + EffectiveVolumetricEnthalpyDerivatives& + effective_volumetric_enthalpy_d_data) const; +}; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 15cef2ccdbb..bc705bdc9f2 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -265,7 +265,6 @@ TH2MLocalAssemblerprocess_data_.specific_body_force; GlobalDimMatrixType const k_over_mu_G = ip_out.permeability_data.Ki * ip_out.permeability_data.k_rel_G / @@ -429,6 +376,12 @@ TH2MLocalAssembler(temperature_index, C_index) .noalias() += - NTT * ip_cv.effective_volumetric_enthalpy_d_data.drho_h_eff_dp_GR * + NTT * ip_dd.effective_volumetric_enthalpy_d_data.drho_h_eff_dp_GR * div_u_dot * NT * w; // dfT_4/dp_cap @@ -2039,7 +2007,7 @@ void TH2MLocalAssembler(temperature_index, W_index) .noalias() -= - NTT * ip_cv.effective_volumetric_enthalpy_d_data.drho_h_eff_dp_cap * + NTT * ip_dd.effective_volumetric_enthalpy_d_data.drho_h_eff_dp_cap * div_u_dot * NT * w; // dfT_4/dT @@ -2048,7 +2016,7 @@ void TH2MLocalAssembler( temperature_index, temperature_index) .noalias() += - NTT * ip_cv.effective_volumetric_enthalpy_d_data.drho_h_eff_dT * + NTT * ip_dd.effective_volumetric_enthalpy_d_data.drho_h_eff_dT * div_u_dot * NT * w; KTT.noalias() += From f07fd3b1ef7c90eb8f01584923569bd0c3b137c1 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Tue, 9 Apr 2024 18:36:16 +0200 Subject: [PATCH 07/45] [PL/TH2M] Split off solid density derivative model --- .../ConstitutiveRelations/ConstitutiveData.h | 2 +- .../ConstitutiveRelations/SolidDensity.cpp | 49 ++++++++++++++++--- .../TH2M/ConstitutiveRelations/SolidDensity.h | 18 +++++-- ProcessLib/TH2M/TH2MFEM-impl.h | 19 ++++--- 4 files changed, 71 insertions(+), 17 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index def77685938..11b0ef268e6 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -150,7 +150,6 @@ struct ConstitutiveTempData ViscosityData viscosity_data; PhaseTransitionData phase_transition_data; PorosityDerivativeData porosity_d_data; - SolidDensityDerivativeData solid_density_d_data; SolidHeatCapacityData solid_heat_capacity_data; ThermalConductivityData thermal_conductivity_data; EffectiveVolumetricEnthalpy effective_volumetric_enthalpy_data; @@ -215,6 +214,7 @@ struct DerivativesData AdvectionDerivativeData advection_d_data; ThermalConductivityDerivativeData thermal_conductivity_d_data; + SolidDensityDerivativeData solid_density_d_data; EffectiveVolumetricInternalEnergyDerivatives effective_volumetric_internal_energy_d_data; EffectiveVolumetricEnthalpyDerivatives effective_volumetric_enthalpy_d_data; diff --git a/ProcessLib/TH2M/ConstitutiveRelations/SolidDensity.cpp b/ProcessLib/TH2M/ConstitutiveRelations/SolidDensity.cpp index 9978c151690..5a764bc2015 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/SolidDensity.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/SolidDensity.cpp @@ -14,11 +14,25 @@ namespace ProcessLib::TH2M namespace ConstitutiveRelations { -void SolidDensityModel::eval( +void SolidDensityModel::eval(SpaceTimeData const& x_t, + MediaData const& media_data, + TemperatureData const& T_data, + SolidDensityData& solid_density_data) const +{ + MaterialPropertyLib::VariableArray variables; + variables.temperature = T_data.T; + + auto const& mpl_solid_density = + media_data.solid[MaterialPropertyLib::PropertyType::density]; + + solid_density_data.rho_SR = mpl_solid_density.template value( + variables, x_t.x, x_t.t, x_t.dt); +} + +void SolidDensityModel::dEval( SpaceTimeData const& x_t, MediaData const& media_data, TemperatureData const& T_data, - SolidDensityData& solid_density_data, SolidDensityDerivativeData& solid_density_d_data) const { MaterialPropertyLib::VariableArray variables; @@ -27,9 +41,6 @@ void SolidDensityModel::eval( auto const& mpl_solid_density = media_data.solid[MaterialPropertyLib::PropertyType::density]; - solid_density_data.rho_SR = mpl_solid_density.template value( - variables, x_t.x, x_t.t, x_t.dt); - solid_density_d_data.drho_SR_dT = mpl_solid_density.template dValue( variables, MaterialPropertyLib::Variable::temperature, x_t.x, x_t.t, x_t.dt); @@ -43,8 +54,7 @@ void SolidDensityModelNonConstantSolidPhaseVolumeFraction:: BiotData const& biot, StrainData const& strain_data, SolidThermalExpansionData const& s_therm_exp_data, - SolidDensityData& solid_density_data, - SolidDensityDerivativeData& solid_density_d_data) const + SolidDensityData& solid_density_data) const { MaterialPropertyLib::VariableArray variables; variables.temperature = T_data.T; @@ -63,6 +73,31 @@ void SolidDensityModelNonConstantSolidPhaseVolumeFraction:: solid_density_data.rho_SR = rho_ref_SR * (1. - s_therm_exp_data.thermal_volume_strain + (biot() - 1.) * div_u); +} + +template +void SolidDensityModelNonConstantSolidPhaseVolumeFraction:: + dEval(SpaceTimeData const& x_t, + MediaData const& media_data, + TemperatureData const& T_data, + BiotData const& biot, + StrainData const& strain_data, + SolidThermalExpansionData const& s_therm_exp_data, + SolidDensityDerivativeData& solid_density_d_data) const +{ + MaterialPropertyLib::VariableArray variables; + variables.temperature = T_data.T; + + static int const KelvinVectorSize = + MathLib::KelvinVector::kelvin_vector_dimensions(DisplacementDim); + using Invariants = MathLib::KelvinVector::Invariants; + double const div_u = Invariants::trace(strain_data.eps); + + auto const& mpl_solid_density = + media_data.solid[MaterialPropertyLib::PropertyType::density]; + + auto const rho_ref_SR = mpl_solid_density.template value( + variables, x_t.x, x_t.t, x_t.dt); solid_density_d_data.drho_SR_dT = mpl_solid_density.template dValue( diff --git a/ProcessLib/TH2M/ConstitutiveRelations/SolidDensity.h b/ProcessLib/TH2M/ConstitutiveRelations/SolidDensity.h index ad14ab20ff8..d9f2d4890c4 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/SolidDensity.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/SolidDensity.h @@ -43,8 +43,12 @@ struct SolidDensityModel void eval(SpaceTimeData const& x_t, MediaData const& media_data, TemperatureData const& T_data, - SolidDensityData& solid_density_data, - SolidDensityDerivativeData& solid_density_d_data) const; + SolidDensityData& solid_density_data) const; + + void dEval(SpaceTimeData const& x_t, + MediaData const& media_data, + TemperatureData const& T_data, + SolidDensityDerivativeData& solid_density_d_data) const; }; template @@ -57,7 +61,15 @@ struct SolidDensityModelNonConstantSolidPhaseVolumeFraction BiotData const& biot, StrainData const& strain_data, SolidThermalExpansionData const& s_therm_exp_data, - SolidDensityData& solid_density_data, + SolidDensityData& solid_density_data) const; + + void dEval( + SpaceTimeData const& x_t, + MediaData const& media_data, + TemperatureData const& T_data, + BiotData const& biot, + StrainData const& strain_data, + SolidThermalExpansionData const& s_therm_exp_data, SolidDensityDerivativeData& solid_density_d_data) const; }; diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index bc705bdc9f2..3b39927adfa 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -239,12 +239,12 @@ TH2MLocalAssembler Date: Tue, 9 Apr 2024 19:09:19 +0200 Subject: [PATCH 08/45] [PL/TH2M] Extract part of C2 equation data & model --- .../TH2M/ConstitutiveRelations/CEquation.cpp | 90 +++++++++++++++++ .../TH2M/ConstitutiveRelations/CEquation.h | 59 ++++++++++++ .../ConstitutiveRelations/ConstitutiveData.h | 6 +- .../ConstitutiveModels.h | 2 + ProcessLib/TH2M/TH2MFEM-impl.h | 96 ++++++++----------- 5 files changed, 195 insertions(+), 58 deletions(-) create mode 100644 ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp create mode 100644 ProcessLib/TH2M/ConstitutiveRelations/CEquation.h diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp new file mode 100644 index 00000000000..817122f1819 --- /dev/null +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp @@ -0,0 +1,90 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#include "CEquation.h" + +namespace ProcessLib::TH2M +{ +namespace ConstitutiveRelations +{ +void FC2aModel::eval(BiotData const biot_data, + CapillaryPressureData const pCap, + ConstituentDensityData const& constituent_density_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + SolidCompressibilityData const beta_p_SR, + FC2aData& fC_2a) const +{ + auto const S_L = S_L_data.S_L; + auto const S_G = 1. - S_L; + double const rho_C_FR = S_G * constituent_density_data.rho_C_GR + + S_L * constituent_density_data.rho_C_LR; + fC_2a.a = + porosity_data.phi * (constituent_density_data.rho_C_LR - + constituent_density_data.rho_C_GR) - + rho_C_FR * pCap() * (biot_data() - porosity_data.phi) * beta_p_SR(); +} + +void FC2aModel::dEval(BiotData const& biot_data, + CapillaryPressureData const pCap, + ConstituentDensityData const& constituent_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + PorosityDerivativeData const& porosity_d_data, + SaturationData const& S_L_data, + SaturationDataDeriv const& dS_L_dp_cap, + SolidCompressibilityData const& beta_p_SR, + FC2aDerivativeData& dfC_2a) const +{ + double const S_L = S_L_data.S_L; + double const S_G = 1. - S_L; + + double const drho_C_FR_dp_GR = + /*(dS_G_dp_GR = 0) * constituent_density_data.rho_C_GR +*/ + S_G * phase_transition_data.drho_C_GR_dp_GR + + /*(dS_L_dp_GR = 0) * constituent_density_data.rho_C_LR +*/ + S_L * phase_transition_data.drho_C_LR_dp_GR; + + dfC_2a.dp_GR = -porosity_data.phi * phase_transition_data.drho_C_GR_dp_GR - + drho_C_FR_dp_GR * pCap() * + (biot_data() - porosity_data.phi) * beta_p_SR(); + + double const dS_G_dp_cap = -dS_L_dp_cap(); + double const rho_C_FR = S_G * constituent_density_data.rho_C_GR + + S_L * constituent_density_data.rho_C_LR; + + // TODO (naumov) Extend for partially saturated media. + constexpr double drho_C_GR_dp_cap = 0; + + double const drho_C_FR_dp_cap = + dS_G_dp_cap * constituent_density_data.rho_C_GR + + S_G * drho_C_GR_dp_cap + + dS_L_dp_cap() * constituent_density_data.rho_C_LR - + S_L * phase_transition_data.drho_C_LR_dp_LR; + + dfC_2a.dp_cap = + porosity_data.phi * + (-phase_transition_data.drho_C_LR_dp_LR - drho_C_GR_dp_cap) - + drho_C_FR_dp_cap * pCap() * (biot_data() - porosity_data.phi) * + beta_p_SR() + + rho_C_FR * (biot_data() - porosity_data.phi) * beta_p_SR(); + + double const drho_C_FR_dT = S_G * phase_transition_data.drho_C_GR_dT + + S_L * phase_transition_data.drho_C_LR_dT; + dfC_2a.dT = porosity_d_data.dphi_dT * (constituent_density_data.rho_C_LR - + constituent_density_data.rho_C_GR) + + porosity_data.phi * (phase_transition_data.drho_C_LR_dT - + phase_transition_data.drho_C_GR_dT) - + drho_C_FR_dT * pCap() * (biot_data() - porosity_data.phi) * + beta_p_SR() + + rho_C_FR * pCap() * porosity_d_data.dphi_dT * beta_p_SR(); +} + +} // namespace ConstitutiveRelations +} // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h new file mode 100644 index 00000000000..213c2e99325 --- /dev/null +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h @@ -0,0 +1,59 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#pragma once + +#include "Base.h" +#include "Biot.h" +#include "ConstitutiveDensity.h" +#include "PhaseTransitionData.h" +#include "Porosity.h" +#include "Saturation.h" +#include "SolidCompressibility.h" + +namespace ProcessLib::TH2M +{ +namespace ConstitutiveRelations +{ +struct FC2aData +{ + double a = nan; +}; + +struct FC2aDerivativeData +{ + double dp_GR = nan; + double dp_cap = nan; + double dT = nan; +}; + +struct FC2aModel +{ + void eval(BiotData const biot_data, + CapillaryPressureData const pCap, + ConstituentDensityData const& constituent_density_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + SolidCompressibilityData const beta_p_SR, + FC2aData& fC_2a) const; + + void dEval(BiotData const& biot_data, + CapillaryPressureData const pCap, + ConstituentDensityData const& constituent_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + PorosityDerivativeData const& porosity_d_data, + SaturationData const& S_L_data, + SaturationDataDeriv const& dS_L_dp_cap, + SolidCompressibilityData const& beta_p_SR, + FC2aDerivativeData& dfC_2a) const; +}; + +} // namespace ConstitutiveRelations +} // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 11b0ef268e6..4abbba127f1 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -12,6 +12,7 @@ #include "Advection.h" #include "Biot.h" #include "Bishops.h" +#include "CEquation.h" #include "ConstitutiveDensity.h" #include "DarcyVelocity.h" #include "DiffusionVelocity.h" @@ -154,6 +155,7 @@ struct ConstitutiveTempData ThermalConductivityData thermal_conductivity_data; EffectiveVolumetricEnthalpy effective_volumetric_enthalpy_data; AdvectionData advection_data; + FC2aData fC_2a; using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = @@ -192,9 +194,6 @@ struct ConstitutiveTempData double dfC_3a_dp_GR = std::numeric_limits::quiet_NaN(); double dfC_3a_dp_cap = std::numeric_limits::quiet_NaN(); double dfC_3a_dT = std::numeric_limits::quiet_NaN(); - double dfC_2a_dp_GR = std::numeric_limits::quiet_NaN(); - double dfC_2a_dp_cap = std::numeric_limits::quiet_NaN(); - double dfC_2a_dT = std::numeric_limits::quiet_NaN(); double dfW_2a_dp_GR = std::numeric_limits::quiet_NaN(); double dfW_2b_dp_GR = std::numeric_limits::quiet_NaN(); double dfW_2a_dp_cap = std::numeric_limits::quiet_NaN(); @@ -218,6 +217,7 @@ struct DerivativesData EffectiveVolumetricInternalEnergyDerivatives effective_volumetric_internal_energy_d_data; EffectiveVolumetricEnthalpyDerivatives effective_volumetric_enthalpy_d_data; + FC2aDerivativeData dfC_2a; }; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index af8f4b33870..709cfcdbcc6 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -12,6 +12,7 @@ #include "Advection.h" #include "Biot.h" #include "Bishops.h" +#include "CEquation.h" #include "ElasticTangentStiffnessModel.h" #include "Enthalpy.h" #include "InternalEnergy.h" @@ -80,6 +81,7 @@ struct ConstitutiveModels AdvectionModel advection_model; InternalEnergyModel internal_energy_model; EffectiveVolumetricEnthalpyModel effective_volumetric_enthalpy_model; + FC2aModel fC_2a_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 3b39927adfa..214e89d267b 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -284,6 +284,17 @@ TH2MLocalAssemblerprocess_data_.apply_mass_lumping) + { + models.fC_2a_model.eval(ip_cv.biot_data, + pCap_data, + current_state.constituent_density_data, + ip_out.porosity_data, + current_state.S_L_data, + ip_cv.beta_p_SR, + ip_cv.fC_2a); + } + // for variable output auto const xmCL = 1. - ip_out.mass_mole_fractions_data.xmWL; @@ -475,37 +486,6 @@ TH2MLocalAssembler(temperature_index); + auto const capillary_pressure = + local_x.template segment( + capillary_pressure_index); + auto const& medium = *this->process_data_.media_map.getMedium(this->element_.getID()); ConstitutiveRelations::MediaData media_data{medium}; @@ -702,6 +686,8 @@ TH2MLocalAssemblerprocess_data_.apply_mass_lumping) + { + models.fC_2a_model.dEval(ip_cv.biot_data, + pCap_data, + current_state.constituent_density_data, + ip_cv.phase_transition_data, + ip_out.porosity_data, + ip_cv.porosity_d_data, + current_state.S_L_data, + ip_cv.dS_L_dp_cap, + ip_cv.beta_p_SR, + ip_dd.dfC_2a); + } } return ip_d_data; @@ -1243,14 +1242,7 @@ void TH2MLocalAssembler< if (!this->process_data_.apply_mass_lumping) { - fC.noalias() -= - NpT * - (ip_out.porosity_data.phi * - (current_state.constituent_density_data.rho_C_LR - - current_state.constituent_density_data.rho_C_GR) - - rho_C_FR * pCap * (alpha_B - ip_out.porosity_data.phi) * - beta_p_SR) * - s_L_dot * w; + fC.noalias() -= NpT * ip_cv.fC_2a.a * s_L_dot * w; } // fC_III fC.noalias() -= NpT * ip_out.porosity_data.phi * @@ -1800,30 +1792,24 @@ void TH2MLocalAssemblerprocess_data_.apply_mass_lumping) { // fC_2 = \int a * s_L_dot - auto const a = - ip_out.porosity_data.phi * - (current_state.constituent_density_data.rho_C_LR - - current_state.constituent_density_data.rho_C_GR) - - rho_C_FR * pCap * (alpha_B - ip_out.porosity_data.phi) * - beta_p_SR; - fC.noalias() -= NpT * a * s_L_dot * w; + fC.noalias() -= NpT * ip_cv.fC_2a.a * s_L_dot * w; local_Jac.template block(C_index, C_index) - .noalias() += - NpT * - (ip_cv.dfC_2a_dp_GR * s_L_dot /*- a * (ds_L_dp_GR = 0) / dt*/) * - Np * w; + .noalias() += NpT * + (ip_dd.dfC_2a.dp_GR * s_L_dot + /*- ip_cv.fC_2a.a * (ds_L_dp_GR = 0) / dt*/) * + Np * w; local_Jac.template block(C_index, W_index) - .noalias() += - NpT * - (ip_cv.dfC_2a_dp_cap * s_L_dot + a * ip_cv.dS_L_dp_cap() / dt) * - Np * w; + .noalias() += NpT * + (ip_dd.dfC_2a.dp_cap * s_L_dot + + ip_cv.fC_2a.a * ip_cv.dS_L_dp_cap() / dt) * + Np * w; local_Jac .template block(C_index, temperature_index) - .noalias() += NpT * ip_cv.dfC_2a_dT * s_L_dot * NT * w; + .noalias() += NpT * ip_dd.dfC_2a.dT * s_L_dot * NT * w; } { // fC_3 = \int phi * a From a71633df1bf040cf1e9d087fb5e47a054ec4ffab Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Wed, 10 Apr 2024 16:07:24 +0200 Subject: [PATCH 09/45] [PL/TH2M] Extract part of C3 equation data & model --- .../TH2M/ConstitutiveRelations/CEquation.cpp | 66 +++++++++++++++++ .../TH2M/ConstitutiveRelations/CEquation.h | 31 ++++++++ .../ConstitutiveRelations/ConstitutiveData.h | 5 +- .../ConstitutiveModels.h | 1 + ProcessLib/TH2M/TH2MFEM-impl.h | 74 +++++-------------- 5 files changed, 119 insertions(+), 58 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp index 817122f1819..7366aee6543 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp @@ -86,5 +86,71 @@ void FC2aModel::dEval(BiotData const& biot_data, rho_C_FR * pCap() * porosity_d_data.dphi_dT * beta_p_SR(); } +void FC3aModel::eval( + double const dt, + ConstituentDensityData const& constituent_density_data, + PrevState const& constituent_density_data_prev, + SaturationData const& S_L_data, + FC3aData& fC_3a) const +{ + if (dt == 0.) + { + fC_3a.a = 0; + return; + } + + double const rho_C_GR_dot = (constituent_density_data.rho_C_GR - + constituent_density_data_prev->rho_C_GR) / + dt; + double const rho_C_LR_dot = (constituent_density_data.rho_C_LR - + constituent_density_data_prev->rho_C_LR) / + dt; + auto const S_L = S_L_data.S_L; + auto const S_G = 1. - S_L; + fC_3a.a = S_G * rho_C_GR_dot + S_L * rho_C_LR_dot; +} + +void FC3aModel::dEval( + double const dt, + ConstituentDensityData const& constituent_density_data, + PrevState const& constituent_density_data_prev, + PhaseTransitionData const& phase_transition_data, + SaturationData const& S_L_data, + SaturationDataDeriv const& dS_L_dp_cap, + FC3aDerivativeData& dfC_3a) const +{ + if (dt == 0.) + { + dfC_3a.dp_GR = 0.; + dfC_3a.dp_cap = 0.; + dfC_3a.dT = 0.; + return; + } + double const rho_C_GR_dot = (constituent_density_data.rho_C_GR - + constituent_density_data_prev->rho_C_GR) / + dt; + double const rho_C_LR_dot = (constituent_density_data.rho_C_LR - + constituent_density_data_prev->rho_C_LR) / + dt; + + auto const S_L = S_L_data.S_L; + auto const S_G = 1. - S_L; + dfC_3a.dp_GR = + /*(dS_G_dp_GR = 0) * rho_C_GR_dot +*/ + S_G * phase_transition_data.drho_C_GR_dp_GR / dt + + /*(dS_L_dp_GR = 0) * rho_C_LR_dot +*/ + S_L * phase_transition_data.drho_C_LR_dp_GR / dt; + + double const dS_G_dp_cap = -dS_L_dp_cap(); + // TODO (naumov) Extend for partially saturated media. + constexpr double drho_C_GR_dp_cap = 0; + + dfC_3a.dp_cap = dS_G_dp_cap * rho_C_GR_dot + S_G * drho_C_GR_dp_cap / dt + + dS_L_dp_cap() * rho_C_LR_dot - + S_L * phase_transition_data.drho_C_LR_dp_LR / dt; + + dfC_3a.dT = S_G * phase_transition_data.drho_C_GR_dT / dt + + S_L * phase_transition_data.drho_C_LR_dT / dt; +} } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h index 213c2e99325..046ad18a65b 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h @@ -55,5 +55,36 @@ struct FC2aModel FC2aDerivativeData& dfC_2a) const; }; +struct FC3aData +{ + double a = nan; +}; + +struct FC3aDerivativeData +{ + double dp_GR = nan; + double dp_cap = nan; + double dT = nan; +}; + +struct FC3aModel +{ + void eval( + double const dt, + ConstituentDensityData const& constituent_density_data, + PrevState const& constituent_density_data_prev, + SaturationData const& S_L_data, + FC3aData& fC_3a) const; + + void dEval( + double const dt, + ConstituentDensityData const& constituent_density_data, + PrevState const& constituent_density_data_prev, + PhaseTransitionData const& phase_transition_data, + SaturationData const& S_L_data, + SaturationDataDeriv const& dS_L_dp_cap, + FC3aDerivativeData& dfC_3a) const; +}; + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 4abbba127f1..2660aaaccdd 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -156,6 +156,7 @@ struct ConstitutiveTempData EffectiveVolumetricEnthalpy effective_volumetric_enthalpy_data; AdvectionData advection_data; FC2aData fC_2a; + FC3aData fC_3a; using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = @@ -191,9 +192,6 @@ struct ConstitutiveTempData double dfC_4_MCpG_dT = std::numeric_limits::quiet_NaN(); double dfC_4_MCT_dT = std::numeric_limits::quiet_NaN(); double dfC_4_MCu_dT = std::numeric_limits::quiet_NaN(); - double dfC_3a_dp_GR = std::numeric_limits::quiet_NaN(); - double dfC_3a_dp_cap = std::numeric_limits::quiet_NaN(); - double dfC_3a_dT = std::numeric_limits::quiet_NaN(); double dfW_2a_dp_GR = std::numeric_limits::quiet_NaN(); double dfW_2b_dp_GR = std::numeric_limits::quiet_NaN(); double dfW_2a_dp_cap = std::numeric_limits::quiet_NaN(); @@ -218,6 +216,7 @@ struct DerivativesData effective_volumetric_internal_energy_d_data; EffectiveVolumetricEnthalpyDerivatives effective_volumetric_enthalpy_d_data; FC2aDerivativeData dfC_2a; + FC3aDerivativeData dfC_3a; }; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index 709cfcdbcc6..3def73d0d98 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -82,6 +82,7 @@ struct ConstitutiveModels InternalEnergyModel internal_energy_model; EffectiveVolumetricEnthalpyModel effective_volumetric_enthalpy_model; FC2aModel fC_2a_model; + FC3aModel fC_3a_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 214e89d267b..cbd0b238ec7 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -294,6 +294,11 @@ TH2MLocalAssemblerrho_C_GR) / - dt; - double const rho_C_LR_dot = - (current_state.constituent_density_data.rho_C_LR - - prev_state.constituent_density_data->rho_C_LR) / - dt; - ip_cv.dfC_3a_dp_GR = - /*(ds_G_dp_GR = 0) * rho_C_GR_dot +*/ s_G * c.drho_C_GR_dp_GR / - dt + - /*(ds_L_dp_GR = 0) * rho_C_LR_dot +*/ s_L * c.drho_C_LR_dp_GR / - dt; - - ip_cv.dfC_3a_dp_cap = ds_G_dp_cap * rho_C_GR_dot + - s_G * drho_C_GR_dp_cap / dt + - ip_cv.dS_L_dp_cap() * rho_C_LR_dot - - s_L * c.drho_C_LR_dp_LR / dt; - ip_cv.dfC_3a_dT = - s_G * c.drho_C_GR_dT / dt + s_L * c.drho_C_LR_dT / dt; - } double const drho_C_FR_dp_GR = /*(ds_G_dp_GR = 0) * current_state.constituent_density_data.rho_C_GR @@ -671,6 +645,7 @@ TH2MLocalAssembleroutput_data_[ip]; auto const& current_state = this->current_states_[ip]; + auto const& prev_state = this->prev_states_[ip]; auto const& Nu = ip_data.N_u; auto const& Np = ip_data.N_p; @@ -746,6 +721,13 @@ TH2MLocalAssemblerrho_C_GR) / - dt; - auto const rho_C_LR_dot = - (current_state.constituent_density_data.rho_C_LR - - prev_state.constituent_density_data->rho_C_LR) / - dt; auto const rho_W_GR_dot = (current_state.constituent_density_data.rho_W_GR - prev_state.constituent_density_data->rho_W_GR) / @@ -1245,8 +1219,7 @@ void TH2MLocalAssembler< fC.noalias() -= NpT * ip_cv.fC_2a.a * s_L_dot * w; } // fC_III - fC.noalias() -= NpT * ip_out.porosity_data.phi * - (s_G * rho_C_GR_dot + s_L * rho_C_LR_dot) * w; + fC.noalias() -= NpT * ip_out.porosity_data.phi * ip_cv.fC_3a.a * w; // --------------------------------------------------------------------- // W-component equation @@ -1643,14 +1616,6 @@ void TH2MLocalAssemblerrho_C_GR) / - dt; - auto const rho_C_LR_dot = - (current_state.constituent_density_data.rho_C_LR - - prev_state.constituent_density_data->rho_C_LR) / - dt; auto const rho_W_GR_dot = (current_state.constituent_density_data.rho_W_GR - prev_state.constituent_density_data->rho_W_GR) / @@ -1813,23 +1778,22 @@ void TH2MLocalAssembler(C_index, C_index) .noalias() += - NpT * ip_out.porosity_data.phi * ip_cv.dfC_3a_dp_GR * Np * w; + NpT * ip_out.porosity_data.phi * ip_dd.dfC_3a.dp_GR * Np * w; local_Jac.template block(C_index, W_index) .noalias() += - NpT * ip_out.porosity_data.phi * ip_cv.dfC_3a_dp_cap * Np * w; + NpT * ip_out.porosity_data.phi * ip_dd.dfC_3a.dp_cap * Np * w; local_Jac .template block(C_index, temperature_index) .noalias() += NpT * - (ip_cv.porosity_d_data.dphi_dT * a + - ip_out.porosity_data.phi * ip_cv.dfC_3a_dT) * + (ip_cv.porosity_d_data.dphi_dT * ip_cv.fC_3a.a + + ip_out.porosity_data.phi * ip_dd.dfC_3a.dT) * NT * w; } // --------------------------------------------------------------------- From ae6acccd66b2eff7bbcbacc61da605575035aa6a Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Wed, 10 Apr 2024 17:55:15 +0200 Subject: [PATCH 10/45] [PL/TH2M] Extract LCpG part of C4 equation data and model. Small optimization in diffusion_C_pGR evaluation; moved identity multiplication to the end. --- .../TH2M/ConstitutiveRelations/CEquation.cpp | 60 +++++++++++++++++++ .../TH2M/ConstitutiveRelations/CEquation.h | 37 ++++++++++++ .../ConstitutiveRelations/ConstitutiveData.h | 3 +- .../ConstitutiveModels.h | 1 + ProcessLib/TH2M/TH2MFEM-impl.h | 47 ++++++--------- 5 files changed, 118 insertions(+), 30 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp index 7366aee6543..b943c617427 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp @@ -152,5 +152,65 @@ void FC3aModel::dEval( dfC_3a.dT = S_G * phase_transition_data.drho_C_GR_dT / dt + S_L * phase_transition_data.drho_C_LR_dT / dt; } + +template +void FC4LCpGModel::eval( + AdvectionData const& advection_data, + FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + FC4LCpGData& fC_4_LCpG) const +{ + GlobalDimMatrix const advection_C = + advection_data.advection_C_G + advection_data.advection_C_L; + + double const sD_G = phase_transition_data.diffusion_coefficient_vapour; + double const sD_L = phase_transition_data.diffusion_coefficient_solute; + + double const phi_G = (1 - S_L_data.S_L) * porosity_data.phi; + double const phi_L = S_L_data.S_L * porosity_data.phi; + + double const diffusion_CGpGR = -phi_G * fluid_density_data.rho_GR * sD_G * + phase_transition_data.dxmWG_dpGR; + double const diffusion_CLpGR = -phi_L * fluid_density_data.rho_LR * sD_L * + phase_transition_data.dxmWL_dpGR; + + double const diffusion_C_pGR = diffusion_CGpGR + diffusion_CLpGR; + + auto const I = + Eigen::Matrix::Identity(); + fC_4_LCpG.L.noalias() = diffusion_C_pGR * I + advection_C; +} + +template +void FC4LCpGModel::dEval( + PermeabilityData const& permeability_data, + ViscosityData const& viscosity_data, + PhaseTransitionData const& phase_transition_data, + AdvectionDerivativeData const& advection_d_data, + FC4LCpGDerivativeData& dfC_4_LCpG) const +{ + dfC_4_LCpG.dp_GR = advection_d_data.dadvection_C_dp_GR + // + ddiffusion_C_p_dp_GR TODO (naumov) + ; + + dfC_4_LCpG.dp_cap = advection_d_data.dadvection_C_dp_cap + // + ddiffusion_C_p_dp_cap TODO (naumov) + ; + + GlobalDimMatrix const k_over_mu_G = + permeability_data.Ki * permeability_data.k_rel_G / viscosity_data.mu_GR; + GlobalDimMatrix const k_over_mu_L = + permeability_data.Ki * permeability_data.k_rel_L / viscosity_data.mu_LR; + + dfC_4_LCpG.dT = phase_transition_data.drho_C_GR_dT * k_over_mu_G + + phase_transition_data.drho_C_LR_dT * k_over_mu_L + // + ddiffusion_C_p_dT TODO (naumov) + ; +} + +template struct FC4LCpGModel<2>; +template struct FC4LCpGModel<3>; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h index 046ad18a65b..14440b9eecb 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h @@ -9,13 +9,17 @@ #pragma once +#include "Advection.h" #include "Base.h" #include "Biot.h" #include "ConstitutiveDensity.h" +#include "FluidDensity.h" +#include "PermeabilityData.h" #include "PhaseTransitionData.h" #include "Porosity.h" #include "Saturation.h" #include "SolidCompressibility.h" +#include "Viscosity.h" namespace ProcessLib::TH2M { @@ -86,5 +90,38 @@ struct FC3aModel FC3aDerivativeData& dfC_3a) const; }; +template +struct FC4LCpGData +{ + GlobalDimMatrix L; +}; + +template +struct FC4LCpGDerivativeData +{ + GlobalDimMatrix dp_GR; + GlobalDimMatrix dp_cap; + GlobalDimMatrix dT; +}; + +template +struct FC4LCpGModel +{ + void eval(AdvectionData const& advection_data, + FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + FC4LCpGData& fC_4_LCpG) const; + + void dEval(PermeabilityData const& permeability_data, + ViscosityData const& viscosity_data, + PhaseTransitionData const& phase_transition_data, + AdvectionDerivativeData const& advection_d_data, + FC4LCpGDerivativeData& dfC_4_LCpG) const; +}; + +extern template struct FC4LCpGModel<2>; +extern template struct FC4LCpGModel<3>; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 2660aaaccdd..e8cf6fdd973 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -157,6 +157,7 @@ struct ConstitutiveTempData AdvectionData advection_data; FC2aData fC_2a; FC3aData fC_3a; + FC4LCpGData fC_4_LCpG; using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = @@ -179,7 +180,6 @@ struct ConstitutiveTempData DisplacementDimMatrix dfW_4_LWpC_d_dp_GR; DisplacementDimMatrix dfW_4_LWpC_d_dp_cap; DisplacementDimMatrix dfW_4_LWpC_d_dT; - DisplacementDimMatrix dfC_4_LCpG_dT; DisplacementDimMatrix dfC_4_LCpC_a_dp_GR; DisplacementDimMatrix dfC_4_LCpC_a_dp_cap; DisplacementDimMatrix dfC_4_LCpC_a_dT; @@ -217,6 +217,7 @@ struct DerivativesData EffectiveVolumetricEnthalpyDerivatives effective_volumetric_enthalpy_d_data; FC2aDerivativeData dfC_2a; FC3aDerivativeData dfC_3a; + FC4LCpGDerivativeData dfC_4_LCpG; }; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index 3def73d0d98..adc5bada1b8 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -83,6 +83,7 @@ struct ConstitutiveModels EffectiveVolumetricEnthalpyModel effective_volumetric_enthalpy_model; FC2aModel fC_2a_model; FC3aModel fC_3a_model; + FC4LCpGModel fC_4_LCpG_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index cbd0b238ec7..e27fac0e904 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -300,6 +300,13 @@ TH2MLocalAssembler; - DisplacementDimMatrix const diffusion_CGpGR = - -phi_G * rhoGR * D_C_G * ip_cv.phase_transition_data.dxmWG_dpGR; - DisplacementDimMatrix const diffusion_CLpGR = - -phi_L * rhoLR * D_C_L * ip_cv.phase_transition_data.dxmWL_dpGR; - DisplacementDimMatrix const diffusion_CGpCap = -phi_G * rhoGR * D_C_G * ip_cv.phase_transition_data.dxmWG_dpCap; DisplacementDimMatrix const diffusion_CLpCap = @@ -1189,19 +1192,13 @@ void TH2MLocalAssembler< DisplacementDimMatrix const diffusion_CLT = -phi_L * rhoLR * D_C_L * ip_cv.phase_transition_data.dxmWL_dT; - DisplacementDimMatrix const advection_C = - ip_cv.advection_data.advection_C_G + - ip_cv.advection_data.advection_C_L; - DisplacementDimMatrix const diffusion_C_pGR = - diffusion_CGpGR + diffusion_CLpGR; DisplacementDimMatrix const diffusion_C_pCap = diffusion_CGpCap + diffusion_CLpCap; DisplacementDimMatrix const diffusion_C_T = diffusion_CGT + diffusion_CLT; - LCpG.noalias() += - gradNpT * (advection_C + diffusion_C_pGR) * gradNp * w; + LCpG.noalias() += gradNpT * ip_cv.fC_4_LCpG.L * gradNp * w; LCpC.noalias() += gradNpT * (diffusion_C_pCap - ip_cv.advection_data.advection_C_L) * @@ -1681,29 +1678,21 @@ void TH2MLocalAssembler(C_index, C_index).noalias() += - gradNpT * - (ip_dd.advection_d_data.dadvection_C_dp_GR - // + ip_cv.ddiffusion_C_p_dp_GR TODO (naumov) - ) * - gradpGR * Np * w; + gradNpT * ip_dd.dfC_4_LCpG.dp_GR * gradpGR * Np * w; // d (fC_4_LCpG * grad p_GR)/d p_cap local_Jac.template block(C_index, W_index).noalias() += - gradNpT * - (ip_dd.advection_d_data.dadvection_C_dp_cap - // + ip_cv.ddiffusion_C_p_dp_GR TODO (naumov) - ) * - gradpGR * Np * w; + gradNpT * ip_dd.dfC_4_LCpG.dp_cap * gradpGR * Np * w; // d (fC_4_LCpG * grad p_GR)/d T local_Jac .template block(C_index, temperature_index) - .noalias() += gradNpT * ip_cv.dfC_4_LCpG_dT * gradpGR * NT * w; + .noalias() += gradNpT * ip_dd.dfC_4_LCpG.dT * gradpGR * NT * w; // d (fC_4_MCpG * p_GR_dot)/d p_GR local_Jac.template block(C_index, C_index).noalias() += From 2a719c557e280b3eb90867b82222a7d916dd7f76 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Wed, 10 Apr 2024 18:37:50 +0200 Subject: [PATCH 11/45] [PL/TH2M] Extract LCpC part of C4 equation data and model. Small optimization in diffusion_C_pCap evaluation; moved identity multiplication to the end. --- .../TH2M/ConstitutiveRelations/CEquation.cpp | 63 +++++++++++++++ .../TH2M/ConstitutiveRelations/CEquation.h | 35 +++++++++ .../ConstitutiveRelations/ConstitutiveData.h | 8 +- .../ConstitutiveModels.h | 1 + ProcessLib/TH2M/TH2MFEM-impl.h | 76 +++++-------------- 5 files changed, 120 insertions(+), 63 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp index b943c617427..7e5bebf6153 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp @@ -212,5 +212,68 @@ void FC4LCpGModel::dEval( template struct FC4LCpGModel<2>; template struct FC4LCpGModel<3>; + +template +void FC4LCpCModel::eval( + AdvectionData const& advection_data, + FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + FC4LCpCData& fC_4_LCpC) const +{ + double const sD_G = phase_transition_data.diffusion_coefficient_vapour; + double const sD_L = phase_transition_data.diffusion_coefficient_solute; + + double const phi_G = (1 - S_L_data.S_L) * porosity_data.phi; + double const phi_L = S_L_data.S_L * porosity_data.phi; + + double const diffusion_CGpCap = -phi_G * fluid_density_data.rho_GR * sD_G * + phase_transition_data.dxmWG_dpCap; + double const diffusion_CLpCap = -phi_L * fluid_density_data.rho_LR * sD_L * + phase_transition_data.dxmWL_dpCap; + + double const diffusion_C_pCap = diffusion_CGpCap + diffusion_CLpCap; + + auto const I = + Eigen::Matrix::Identity(); + + fC_4_LCpC.L.noalias() = diffusion_C_pCap * I - advection_data.advection_C_L; +} + +template +void FC4LCpCModel::dEval( + ConstituentDensityData const& constituent_density_data, + PermeabilityData const& permeability_data, + PhaseTransitionData const& phase_transition_data, + SaturationDataDeriv const& dS_L_dp_cap, + ViscosityData const& viscosity_data, + FC4LCpCDerivativeData& dfC_4_LCpC) const +{ + ////// Diffusion Part ///// + // TODO (naumov) d(diffusion_C_pCap)/dX for dxmW*/d* != 0 + + ////// Advection part ///// + GlobalDimMatrix const k_over_mu_L = + permeability_data.Ki * permeability_data.k_rel_L / viscosity_data.mu_LR; + + dfC_4_LCpC.dp_GR = phase_transition_data.drho_C_LR_dp_GR * k_over_mu_L + //+ rhoCLR * (dk_over_mu_L_dp_GR = 0) + ; + + auto const dk_over_mu_L_dp_cap = permeability_data.Ki * + permeability_data.dk_rel_L_dS_L * + dS_L_dp_cap() / viscosity_data.mu_LR; + + dfC_4_LCpC.dp_cap = -phase_transition_data.drho_C_LR_dp_LR * k_over_mu_L + + constituent_density_data.rho_C_LR * dk_over_mu_L_dp_cap; + + dfC_4_LCpC.dT = phase_transition_data.drho_W_LR_dT * k_over_mu_L + //+ rhoWLR * (dk_over_mu_L_dT != 0 TODO for mu_L(T)) + ; +} + +template struct FC4LCpCModel<2>; +template struct FC4LCpCModel<3>; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h index 14440b9eecb..44d0f4f519b 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h @@ -123,5 +123,40 @@ struct FC4LCpGModel extern template struct FC4LCpGModel<2>; extern template struct FC4LCpGModel<3>; + +template +struct FC4LCpCData +{ + GlobalDimMatrix L; +}; + +template +struct FC4LCpCDerivativeData +{ + GlobalDimMatrix dp_GR; + GlobalDimMatrix dp_cap; + GlobalDimMatrix dT; +}; + +template +struct FC4LCpCModel +{ + void eval(AdvectionData const& advection_data, + FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + FC4LCpCData& fC_4_LCpC) const; + + void dEval(ConstituentDensityData const& constituent_density_data, + PermeabilityData const& permeability_data, + PhaseTransitionData const& phase_transition_data, + SaturationDataDeriv const& dS_L_dp_cap, + ViscosityData const& viscosity_data, + FC4LCpCDerivativeData& dfC_4_LCpC) const; +}; + +extern template struct FC4LCpCModel<2>; +extern template struct FC4LCpCModel<3>; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index e8cf6fdd973..fdd260c64fd 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -158,6 +158,7 @@ struct ConstitutiveTempData FC2aData fC_2a; FC3aData fC_3a; FC4LCpGData fC_4_LCpG; + FC4LCpCData fC_4_LCpC; using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = @@ -180,12 +181,6 @@ struct ConstitutiveTempData DisplacementDimMatrix dfW_4_LWpC_d_dp_GR; DisplacementDimMatrix dfW_4_LWpC_d_dp_cap; DisplacementDimMatrix dfW_4_LWpC_d_dT; - DisplacementDimMatrix dfC_4_LCpC_a_dp_GR; - DisplacementDimMatrix dfC_4_LCpC_a_dp_cap; - DisplacementDimMatrix dfC_4_LCpC_a_dT; - DisplacementDimMatrix dfC_4_LCpC_d_dp_GR; - DisplacementDimMatrix dfC_4_LCpC_d_dp_cap; - DisplacementDimMatrix dfC_4_LCpC_d_dT; DisplacementDimMatrix dk_over_mu_G_dp_cap; DisplacementDimMatrix dk_over_mu_L_dp_cap; double dfC_4_MCpG_dp_GR = std::numeric_limits::quiet_NaN(); @@ -218,6 +213,7 @@ struct DerivativesData FC2aDerivativeData dfC_2a; FC3aDerivativeData dfC_3a; FC4LCpGDerivativeData dfC_4_LCpG; + FC4LCpCDerivativeData dfC_4_LCpC; }; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index adc5bada1b8..82b819134dd 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -84,6 +84,7 @@ struct ConstitutiveModels FC2aModel fC_2a_model; FC3aModel fC_3a_model; FC4LCpGModel fC_4_LCpG_model; + FC4LCpCModel fC_4_LCpC_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index e27fac0e904..185b7a5f961 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -307,6 +307,13 @@ TH2MLocalAssembler::Zero(); ip_cv.dfW_4_LWpC_d_dT = Eigen::Matrix::Zero(); - - ip_cv.dfC_4_LCpC_a_dp_GR = c.drho_C_LR_dp_GR * k_over_mu_L - //+ rhoCLR * (dk_over_mu_L_dp_GR = 0) - ; - ip_cv.dfC_4_LCpC_a_dp_cap = - -c.drho_C_LR_dp_LR * k_over_mu_L + - current_state.constituent_density_data.rho_C_LR * - ip_cv.dk_over_mu_L_dp_cap; - ip_cv.dfC_4_LCpC_a_dT = c.drho_W_LR_dT * k_over_mu_L - //+ rhoWLR * (dk_over_mu_L_dT != 0 TODO for mu_L(T)) - ; - - // TODO (naumov) for dxmW*/d* != 0 - ip_cv.dfC_4_LCpC_d_dp_GR = - Eigen::Matrix::Zero(); - ip_cv.dfC_4_LCpC_d_dp_cap = - Eigen::Matrix::Zero(); - ip_cv.dfC_4_LCpC_d_dT = - Eigen::Matrix::Zero(); } return {ip_constitutive_data, ip_constitutive_variables}; @@ -736,6 +724,13 @@ TH2MLocalAssembler; - DisplacementDimMatrix const diffusion_CGpCap = - -phi_G * rhoGR * D_C_G * ip_cv.phase_transition_data.dxmWG_dpCap; - DisplacementDimMatrix const diffusion_CLpCap = - -phi_L * rhoLR * D_C_L * ip_cv.phase_transition_data.dxmWL_dpCap; - DisplacementDimMatrix const diffusion_CGT = -phi_G * rhoGR * D_C_G * ip_cv.phase_transition_data.dxmWG_dT; DisplacementDimMatrix const diffusion_CLT = -phi_L * rhoLR * D_C_L * ip_cv.phase_transition_data.dxmWL_dT; - DisplacementDimMatrix const diffusion_C_pCap = - diffusion_CGpCap + diffusion_CLpCap; - DisplacementDimMatrix const diffusion_C_T = diffusion_CGT + diffusion_CLT; LCpG.noalias() += gradNpT * ip_cv.fC_4_LCpG.L * gradNp * w; - LCpC.noalias() += - gradNpT * (diffusion_C_pCap - ip_cv.advection_data.advection_C_L) * - gradNp * w; + LCpC.noalias() += gradNpT * ip_cv.fC_4_LCpC.L * gradNp * w; LCT.noalias() += gradNpT * (diffusion_C_T)*gradNp * w; @@ -1661,20 +1646,11 @@ void TH2MLocalAssembler(C_index, C_index).noalias() += - gradNpT * - (ip_cv.dfC_4_LCpC_a_dp_GR - // + ip_cv.dfC_4_LCpC_d_dp_GR TODO (naumov) - ) * - gradpCap * Np * w; + gradNpT * ip_dd.dfC_4_LCpC.dp_GR * gradpCap * Np * w; // d (fC_4_LCpC * grad p_cap)/d p_cap local_Jac.template block(C_index, W_index).noalias() += - gradNpT * - (ip_cv.dfC_4_LCpC_a_dp_cap - // + ip_cv.dfC_4_LCpC_d_dp_cap TODO (naumov) - ) * - gradpCap * Np * w; + gradNpT * ip_dd.dfC_4_LCpC.dp_cap * gradpCap * Np * w; local_Jac .template block(C_index, temperature_index) - .noalias() += gradNpT * - (ip_cv.dfC_4_LCpC_a_dT - // + ip_cv.dfC_4_LCpC_d_dT TODO (naumov) - ) * - gradpCap * Np * w; + .noalias() += gradNpT * ip_dd.dfC_4_LCpC.dT * gradpCap * Np * w; */ LCT.noalias() += gradNpT * diffusion_C_T * gradNp * w; From 4a0039590252828c69bb0ea3533787b58b596381 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Wed, 10 Apr 2024 19:11:25 +0200 Subject: [PATCH 12/45] [PL/TH2M] Extract LCT part of C4 equation data and model. Small optimization in diffusion_C_T evaluation; moved identity multiplication to the end. This one contains only the residuum contribution and the derivatives are not calculated. --- .../TH2M/ConstitutiveRelations/CEquation.cpp | 30 ++++++++++++++++ .../TH2M/ConstitutiveRelations/CEquation.h | 16 +++++++++ .../ConstitutiveRelations/ConstitutiveData.h | 1 + .../ConstitutiveModels.h | 1 + ProcessLib/TH2M/TH2MFEM-impl.h | 36 ++++++------------- 5 files changed, 59 insertions(+), 25 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp index 7e5bebf6153..de8c81f03fa 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp @@ -275,5 +275,35 @@ void FC4LCpCModel::dEval( template struct FC4LCpCModel<2>; template struct FC4LCpCModel<3>; + +template +void FC4LCTModel::eval( + FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + FC4LCTData& fC_4_LCT) const +{ + double const sD_G = phase_transition_data.diffusion_coefficient_vapour; + double const sD_L = phase_transition_data.diffusion_coefficient_solute; + + double const phi_G = (1 - S_L_data.S_L) * porosity_data.phi; + double const phi_L = S_L_data.S_L * porosity_data.phi; + + double const diffusion_C_G_T = -phi_G * fluid_density_data.rho_GR * sD_G * + phase_transition_data.dxmWG_dT; + double const diffusion_C_L_T = -phi_L * fluid_density_data.rho_LR * sD_L * + phase_transition_data.dxmWL_dT; + + double const diffusion_C_T = diffusion_C_G_T + diffusion_C_L_T; + + auto const I = + Eigen::Matrix::Identity(); + + fC_4_LCT.L.noalias() = diffusion_C_T * I; +} + +template struct FC4LCTModel<2>; +template struct FC4LCTModel<3>; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h index 44d0f4f519b..eea017b07b3 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h @@ -158,5 +158,21 @@ struct FC4LCpCModel extern template struct FC4LCpCModel<2>; extern template struct FC4LCpCModel<3>; + +template +struct FC4LCTData +{ + GlobalDimMatrix L; +}; + +template +struct FC4LCTModel +{ + void eval(FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + FC4LCTData& fC_4_LCT) const; +}; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index fdd260c64fd..2bdd411dd35 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -159,6 +159,7 @@ struct ConstitutiveTempData FC3aData fC_3a; FC4LCpGData fC_4_LCpG; FC4LCpCData fC_4_LCpC; + FC4LCTData fC_4_LCT; using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index 82b819134dd..9b15943effc 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -85,6 +85,7 @@ struct ConstitutiveModels FC3aModel fC_3a_model; FC4LCpGModel fC_4_LCpG_model; FC4LCpCModel fC_4_LCpC_model; + FC4LCTModel fC_4_LCT_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 185b7a5f961..4a1202aa07f 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -314,6 +314,12 @@ TH2MLocalAssembler; - - DisplacementDimMatrix const diffusion_CGT = - -phi_G * rhoGR * D_C_G * ip_cv.phase_transition_data.dxmWG_dT; - DisplacementDimMatrix const diffusion_CLT = - -phi_L * rhoLR * D_C_L * ip_cv.phase_transition_data.dxmWL_dT; - - DisplacementDimMatrix const diffusion_C_T = - diffusion_CGT + diffusion_CLT; - LCpG.noalias() += gradNpT * ip_cv.fC_4_LCpG.L * gradNp * w; LCpC.noalias() += gradNpT * ip_cv.fC_4_LCpC.L * gradNp * w; - LCT.noalias() += gradNpT * (diffusion_C_T)*gradNp * w; + LCT.noalias() += gradNpT * ip_cv.fC_4_LCT.L * gradNp * w; fC.noalias() += gradNpT * (ip_cv.advection_data.advection_C_G * rhoGR + @@ -1234,6 +1227,9 @@ void TH2MLocalAssembler< MWu.noalias() += NpT * rho_W_FR * alpha_B * mT * Bu * w; + using DisplacementDimMatrix = + Eigen::Matrix; + DisplacementDimMatrix const diffusion_WGpGR = phi_G * rhoGR * D_W_G * ip_cv.phase_transition_data.dxmWG_dpGR; DisplacementDimMatrix const diffusion_WLpGR = @@ -1564,9 +1560,7 @@ void TH2MLocalAssembler Date: Wed, 10 Apr 2024 19:41:03 +0200 Subject: [PATCH 13/45] [PL/TH2M] Extract MCpG part of C4 equation data and model. --- .../TH2M/ConstitutiveRelations/CEquation.cpp | 45 +++++++++++++++++++ .../TH2M/ConstitutiveRelations/CEquation.h | 30 +++++++++++++ .../ConstitutiveRelations/ConstitutiveData.h | 4 +- .../ConstitutiveModels.h | 1 + ProcessLib/TH2M/TH2MFEM-impl.h | 43 +++++++++--------- 5 files changed, 98 insertions(+), 25 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp index de8c81f03fa..eb0d2100036 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp @@ -305,5 +305,50 @@ void FC4LCTModel::eval( template struct FC4LCTModel<2>; template struct FC4LCTModel<3>; + +void FC4MCpGModel::eval(BiotData const& biot_data, + ConstituentDensityData const& constituent_density_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + SolidCompressibilityData const& beta_p_SR, + FC4MCpGData& fC_4_MCpG) const +{ + auto const S_L = S_L_data.S_L; + auto const S_G = 1. - S_L; + double const rho_C_FR = S_G * constituent_density_data.rho_C_GR + + S_L * constituent_density_data.rho_C_LR; + + fC_4_MCpG.m = rho_C_FR * (biot_data() - porosity_data.phi) * beta_p_SR(); +} + +void FC4MCpGModel::dEval(BiotData const& biot_data, + ConstituentDensityData const& constituent_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + PorosityDerivativeData const& porosity_d_data, + SaturationData const& S_L_data, + SolidCompressibilityData const& beta_p_SR, + FC4MCpGDerivativeData& dfC_4_MCpG) const +{ + auto const S_L = S_L_data.S_L; + auto const S_G = 1. - S_L; + double const rho_C_FR = S_G * constituent_density_data.rho_C_GR + + S_L * constituent_density_data.rho_C_LR; + + double const drho_C_FR_dp_GR = + /*(dS_G_dp_GR = 0) * constituent_density_data.rho_C_GR +*/ + S_G * phase_transition_data.drho_C_GR_dp_GR + + /*(dS_L_dp_GR = 0) * constituent_density_data.rho_C_LR +*/ + S_L * phase_transition_data.drho_C_LR_dp_GR; + + dfC_4_MCpG.dp_GR = + drho_C_FR_dp_GR * (biot_data() - porosity_data.phi) * beta_p_SR(); + + double const drho_C_FR_dT = S_G * phase_transition_data.drho_C_GR_dT + + S_L * phase_transition_data.drho_C_LR_dT; + dfC_4_MCpG.dT = + drho_C_FR_dT * (biot_data() - porosity_data.phi) * beta_p_SR() - + rho_C_FR * porosity_d_data.dphi_dT * beta_p_SR(); +} } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h index eea017b07b3..a3261d0d6ce 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h @@ -174,5 +174,35 @@ struct FC4LCTModel SaturationData const& S_L_data, FC4LCTData& fC_4_LCT) const; }; + +struct FC4MCpGData +{ + double m = nan; +}; + +struct FC4MCpGDerivativeData +{ + double dp_GR = nan; + double dT = nan; +}; + +struct FC4MCpGModel +{ + void eval(BiotData const& biot_data, + ConstituentDensityData const& constituent_density_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + SolidCompressibilityData const& beta_p_SR, + FC4MCpGData& fC_4_MCpG) const; + + void dEval(BiotData const& biot_data, + ConstituentDensityData const& constituent_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + PorosityDerivativeData const& porosity_d_data, + SaturationData const& S_L_data, + SolidCompressibilityData const& beta_p_SR, + FC4MCpGDerivativeData& dfC_4_MCpG) const; +}; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 2bdd411dd35..5572518ed8c 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -160,6 +160,7 @@ struct ConstitutiveTempData FC4LCpGData fC_4_LCpG; FC4LCpCData fC_4_LCpC; FC4LCTData fC_4_LCT; + FC4MCpGData fC_4_MCpG; using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = @@ -184,8 +185,6 @@ struct ConstitutiveTempData DisplacementDimMatrix dfW_4_LWpC_d_dT; DisplacementDimMatrix dk_over_mu_G_dp_cap; DisplacementDimMatrix dk_over_mu_L_dp_cap; - double dfC_4_MCpG_dp_GR = std::numeric_limits::quiet_NaN(); - double dfC_4_MCpG_dT = std::numeric_limits::quiet_NaN(); double dfC_4_MCT_dT = std::numeric_limits::quiet_NaN(); double dfC_4_MCu_dT = std::numeric_limits::quiet_NaN(); double dfW_2a_dp_GR = std::numeric_limits::quiet_NaN(); @@ -215,6 +214,7 @@ struct DerivativesData FC3aDerivativeData dfC_3a; FC4LCpGDerivativeData dfC_4_LCpG; FC4LCpCDerivativeData dfC_4_LCpC; + FC4MCpGDerivativeData dfC_4_MCpG; }; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index 9b15943effc..14bbf0c54c1 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -86,6 +86,7 @@ struct ConstitutiveModels FC4LCpGModel fC_4_LCpG_model; FC4LCpCModel fC_4_LCpC_model; FC4LCTModel fC_4_LCT_model; + FC4MCpGModel fC_4_MCpG_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 4a1202aa07f..2a757589da7 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -320,6 +320,13 @@ TH2MLocalAssembler(C_index, C_index).noalias() += - NpT * ip_cv.dfC_4_MCpG_dp_GR * (pGR - pGR_prev) / dt * Np * w; + NpT * ip_dd.dfC_4_MCpG.dp_GR * (pGR - pGR_prev) / dt * Np * w; // d (fC_4_MCpG * p_GR_dot)/d T local_Jac .template block(C_index, temperature_index) .noalias() += - NpT * ip_cv.dfC_4_MCpG_dT * (pGR - pGR_prev) / dt * NT * w; + NpT * ip_dd.dfC_4_MCpG.dT * (pGR - pGR_prev) / dt * NT * w; LCpC.noalias() -= gradNpT * ip_cv.fC_4_LCpC.L * gradNp * w; From bf5e2089e792787c143e4721cfd568771de0afcc Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Fri, 12 Apr 2024 13:18:07 +0200 Subject: [PATCH 14/45] [PL/TH2M] Extract MCpC part of C4 equation data and model. --- .../TH2M/ConstitutiveRelations/CEquation.cpp | 25 ++++++++++++++ .../TH2M/ConstitutiveRelations/CEquation.h | 18 ++++++++++ .../ConstitutiveRelations/ConstitutiveData.h | 1 + .../ConstitutiveModels.h | 1 + ProcessLib/TH2M/TH2MFEM-impl.h | 33 ++++++++----------- 5 files changed, 58 insertions(+), 20 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp index eb0d2100036..f11ef805548 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp @@ -350,5 +350,30 @@ void FC4MCpGModel::dEval(BiotData const& biot_data, drho_C_FR_dT * (biot_data() - porosity_data.phi) * beta_p_SR() - rho_C_FR * porosity_d_data.dphi_dT * beta_p_SR(); } + +void FC4MCpCModel::eval(BiotData const& biot_data, + CapillaryPressureData const pCap, + ConstituentDensityData const& constituent_density_data, + PorosityData const& porosity_data, + PrevState const& S_L_data_prev, + SaturationData const& S_L_data, + SolidCompressibilityData const& beta_p_SR, + FC4MCpCData& fC_4_MCpC) const +{ + auto const S_L = S_L_data.S_L; + auto const S_G = 1. - S_L; + double const rho_C_FR = S_G * constituent_density_data.rho_C_GR + + S_L * constituent_density_data.rho_C_LR; + + fC_4_MCpC.m = + -rho_C_FR * (biot_data() - porosity_data.phi) * beta_p_SR() * S_L; + + fC_4_MCpC.ml = + (porosity_data.phi * (constituent_density_data.rho_C_LR - + constituent_density_data.rho_C_GR) - + rho_C_FR * pCap() * (biot_data() - porosity_data.phi) * beta_p_SR()) * + (S_L - S_L_data_prev->S_L); +} + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h index a3261d0d6ce..54d889936d7 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h @@ -204,5 +204,23 @@ struct FC4MCpGModel SolidCompressibilityData const& beta_p_SR, FC4MCpGDerivativeData& dfC_4_MCpG) const; }; + +struct FC4MCpCData +{ + double m = nan; + double ml = nan; +}; + +struct FC4MCpCModel +{ + void eval(BiotData const& biot_data, + CapillaryPressureData const pCap, + ConstituentDensityData const& constituent_density_data, + PorosityData const& porosity_data, + PrevState const& S_L_data_prev, + SaturationData const& S_L_data, + SolidCompressibilityData const& beta_p_SR, + FC4MCpCData& fC_4_MCpC) const; +}; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 5572518ed8c..8fe1d6f8d99 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -161,6 +161,7 @@ struct ConstitutiveTempData FC4LCpCData fC_4_LCpC; FC4LCTData fC_4_LCT; FC4MCpGData fC_4_MCpG; + FC4MCpCData fC_4_MCpC; using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index 14bbf0c54c1..40aaa30463f 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -87,6 +87,7 @@ struct ConstitutiveModels FC4LCpCModel fC_4_LCpC_model; FC4LCTModel fC_4_LCT_model; FC4MCpGModel fC_4_MCpG_model; + FC4MCpCModel fC_4_MCpC_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 2a757589da7..924e7c65849 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -327,6 +327,15 @@ TH2MLocalAssemblerprocess_data_.apply_mass_lumping) { if (pCap - pCap_prev != 0.) // avoid division by Zero { MCpC.noalias() += - NpT * - (ip_out.porosity_data.phi * - (current_state.constituent_density_data.rho_C_LR - - current_state.constituent_density_data.rho_C_GR) - - rho_C_FR * pCap * (alpha_B - ip_out.porosity_data.phi) * - beta_p_SR) * - s_L_dot * dt / (pCap - pCap_prev) * Np * w; + NpT * ip_cv.fC_4_MCpC.ml / (pCap - pCap_prev) * Np * w; } } @@ -1603,22 +1604,14 @@ void TH2MLocalAssemblerprocess_data_.apply_mass_lumping) { if (pCap - pCap_prev != 0.) // avoid division by Zero { MCpC.noalias() += - NpT * - (ip_out.porosity_data.phi * - (current_state.constituent_density_data.rho_C_LR - - current_state.constituent_density_data.rho_C_GR) - - rho_C_FR * pCap * (alpha_B - ip_out.porosity_data.phi) * - beta_p_SR) * - s_L_dot * dt / (pCap - pCap_prev) * Np * w; + NpT * ip_cv.fC_4_MCpC.ml / (pCap - pCap_prev) * Np * w; } } From 8f3ecb633946dfeaffdb0005560992bc8985f233 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Fri, 12 Apr 2024 14:22:55 +0200 Subject: [PATCH 15/45] [PL/TH2M] Extract MCT part of C4 equation data and model. --- .../TH2M/ConstitutiveRelations/CEquation.cpp | 50 +++++++++++++++++++ .../TH2M/ConstitutiveRelations/CEquation.h | 35 +++++++++++++ .../ConstitutiveRelations/ConstitutiveData.h | 3 +- .../ConstitutiveModels.h | 1 + ProcessLib/TH2M/TH2MFEM-impl.h | 36 ++++++------- 5 files changed, 107 insertions(+), 18 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp index f11ef805548..c3c7453a7f6 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp @@ -375,5 +375,55 @@ void FC4MCpCModel::eval(BiotData const& biot_data, (S_L - S_L_data_prev->S_L); } +template +void FC4MCTModel::eval( + BiotData const& biot_data, + ConstituentDensityData const& constituent_density_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + SolidThermalExpansionData const& s_therm_exp_data, + FC4MCTData& fC_4_MCT) const +{ + auto const S_L = S_L_data.S_L; + auto const S_G = 1. - S_L; + double const rho_C_FR = S_G * constituent_density_data.rho_C_GR + + S_L * constituent_density_data.rho_C_LR; + + fC_4_MCT.m = -rho_C_FR * (biot_data() - porosity_data.phi) * + s_therm_exp_data.beta_T_SR; +} + +template +void FC4MCTModel::dEval( + BiotData const& biot_data, + [[maybe_unused]] ConstituentDensityData const& constituent_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + [[maybe_unused]] PorosityDerivativeData const& porosity_d_data, + SaturationData const& S_L_data, + SolidThermalExpansionData const& s_therm_exp_data, + FC4MCTDerivativeData& dfC_4_MCT) const +{ + auto const S_L = S_L_data.S_L; + auto const S_G = 1. - S_L; +#ifdef NON_CONSTANT_SOLID_PHASE_VOLUME_FRACTION + double const rho_C_FR = S_G * constituent_density_data.rho_C_GR + + S_L * constituent_density_data.rho_C_LR; +#endif + + double const drho_C_FR_dT = S_G * phase_transition_data.drho_C_GR_dT + + S_L * phase_transition_data.drho_C_LR_dT; + + dfC_4_MCT.dT = drho_C_FR_dT * (biot_data() - porosity_data.phi) * + s_therm_exp_data.beta_T_SR +#ifdef NON_CONSTANT_SOLID_PHASE_VOLUME_FRACTION + + rho_C_FR * (biot_data() - porosity_d_data.dphi_dT) * + s_therm_exp_data.beta_T_SR +#endif + ; +} + +template struct FC4MCTModel<2>; +template struct FC4MCTModel<3>; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h index 54d889936d7..5036cb8f005 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h @@ -222,5 +222,40 @@ struct FC4MCpCModel SolidCompressibilityData const& beta_p_SR, FC4MCpCData& fC_4_MCpC) const; }; + +struct FC4MCTData +{ + double m = nan; +}; + +struct FC4MCTDerivativeData +{ + double dT = nan; +}; + +template +struct FC4MCTModel +{ + void eval( + BiotData const& biot_data, + ConstituentDensityData const& constituent_density_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + SolidThermalExpansionData const& s_therm_exp_data, + FC4MCTData& fC_4_MCT) const; + + void dEval( + BiotData const& biot_data, + ConstituentDensityData const& constituent_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + PorosityDerivativeData const& porosity_d_data, + SaturationData const& S_L_data, + SolidThermalExpansionData const& s_therm_exp_data, + FC4MCTDerivativeData& dfC_4_MCT) const; +}; + +extern template struct FC4MCTModel<2>; +extern template struct FC4MCTModel<3>; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 8fe1d6f8d99..aebc584e08f 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -162,6 +162,7 @@ struct ConstitutiveTempData FC4LCTData fC_4_LCT; FC4MCpGData fC_4_MCpG; FC4MCpCData fC_4_MCpC; + FC4MCTData fC_4_MCT; using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = @@ -186,7 +187,6 @@ struct ConstitutiveTempData DisplacementDimMatrix dfW_4_LWpC_d_dT; DisplacementDimMatrix dk_over_mu_G_dp_cap; DisplacementDimMatrix dk_over_mu_L_dp_cap; - double dfC_4_MCT_dT = std::numeric_limits::quiet_NaN(); double dfC_4_MCu_dT = std::numeric_limits::quiet_NaN(); double dfW_2a_dp_GR = std::numeric_limits::quiet_NaN(); double dfW_2b_dp_GR = std::numeric_limits::quiet_NaN(); @@ -216,6 +216,7 @@ struct DerivativesData FC4LCpGDerivativeData dfC_4_LCpG; FC4LCpCDerivativeData dfC_4_LCpC; FC4MCpGDerivativeData dfC_4_MCpG; + FC4MCTDerivativeData dfC_4_MCT; }; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index 40aaa30463f..f6653ff190a 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -88,6 +88,7 @@ struct ConstitutiveModels FC4LCTModel fC_4_LCT_model; FC4MCpGModel fC_4_MCpG_model; FC4MCpCModel fC_4_MCpC_model; + FC4MCTModel fC_4_MCT_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 924e7c65849..768360ec154 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -336,6 +336,13 @@ TH2MLocalAssembler(C_index, temperature_index) - .noalias() += NpT * ip_cv.dfC_4_MCT_dT * (T - T_prev) / dt * NT * w; + .noalias() += NpT * ip_dd.dfC_4_MCT.dT * (T - T_prev) / dt * NT * w; MCu.noalias() += NpT * rho_C_FR * alpha_B * mT * Bu * w; // d (fC_4_MCu * u_dot)/d T From 1c20d8e41a0a0c59293c56ebc5fb7fe2b0d5407f Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Fri, 12 Apr 2024 15:13:51 +0200 Subject: [PATCH 16/45] [PL/TH2M] Extract MCu part of C4 equation data and model. --- .../TH2M/ConstitutiveRelations/CEquation.cpp | 25 ++++++++++++++++++ .../TH2M/ConstitutiveRelations/CEquation.h | 23 ++++++++++++++++ .../ConstitutiveRelations/ConstitutiveData.h | 3 ++- .../ConstitutiveModels.h | 1 + ProcessLib/TH2M/TH2MFEM-impl.h | 26 +++++++++---------- 5 files changed, 64 insertions(+), 14 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp index c3c7453a7f6..2ca35bcabd7 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp @@ -425,5 +425,30 @@ void FC4MCTModel::dEval( template struct FC4MCTModel<2>; template struct FC4MCTModel<3>; + +void FC4MCuModel::eval(BiotData const& biot_data, + ConstituentDensityData const& constituent_density_data, + SaturationData const& S_L_data, + FC4MCuData& fC_4_MCu) const +{ + auto const S_L = S_L_data.S_L; + auto const S_G = 1. - S_L; + double const rho_C_FR = S_G * constituent_density_data.rho_C_GR + + S_L * constituent_density_data.rho_C_LR; + + fC_4_MCu.m = rho_C_FR * biot_data(); +} + +void FC4MCuModel::dEval(BiotData const& biot_data, + PhaseTransitionData const& phase_transition_data, + SaturationData const& S_L_data, + FC4MCuDerivativeData& dfC_4_MCu) const +{ + auto const S_L = S_L_data.S_L; + auto const S_G = 1. - S_L; + double const drho_C_FR_dT = S_G * phase_transition_data.drho_C_GR_dT + + S_L * phase_transition_data.drho_C_LR_dT; + dfC_4_MCu.dT = drho_C_FR_dT * biot_data(); +} } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h index 5036cb8f005..14a3852e800 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h @@ -255,6 +255,29 @@ struct FC4MCTModel FC4MCTDerivativeData& dfC_4_MCT) const; }; +struct FC4MCuData +{ + double m = nan; +}; + +struct FC4MCuDerivativeData +{ + double dT = nan; +}; + +struct FC4MCuModel +{ + void eval(BiotData const& biot_data, + ConstituentDensityData const& constituent_density_data, + SaturationData const& S_L_data, + FC4MCuData& fC_4_MCu) const; + + void dEval(BiotData const& biot_data, + PhaseTransitionData const& phase_transition_data, + SaturationData const& S_L_data, + FC4MCuDerivativeData& dfC_4_MCu) const; +}; + extern template struct FC4MCTModel<2>; extern template struct FC4MCTModel<3>; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index aebc584e08f..818a59a8f65 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -163,6 +163,7 @@ struct ConstitutiveTempData FC4MCpGData fC_4_MCpG; FC4MCpCData fC_4_MCpC; FC4MCTData fC_4_MCT; + FC4MCuData fC_4_MCu; using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = @@ -187,7 +188,6 @@ struct ConstitutiveTempData DisplacementDimMatrix dfW_4_LWpC_d_dT; DisplacementDimMatrix dk_over_mu_G_dp_cap; DisplacementDimMatrix dk_over_mu_L_dp_cap; - double dfC_4_MCu_dT = std::numeric_limits::quiet_NaN(); double dfW_2a_dp_GR = std::numeric_limits::quiet_NaN(); double dfW_2b_dp_GR = std::numeric_limits::quiet_NaN(); double dfW_2a_dp_cap = std::numeric_limits::quiet_NaN(); @@ -217,6 +217,7 @@ struct DerivativesData FC4LCpCDerivativeData dfC_4_LCpC; FC4MCpGDerivativeData dfC_4_MCpG; FC4MCTDerivativeData dfC_4_MCT; + FC4MCuDerivativeData dfC_4_MCu; }; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index f6653ff190a..bf27bce4a8a 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -89,6 +89,7 @@ struct ConstitutiveModels FC4MCpGModel fC_4_MCpG_model; FC4MCpCModel fC_4_MCpC_model; FC4MCTModel fC_4_MCT_model; + FC4MCuModel fC_4_MCu_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 768360ec154..68b8a59227c 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -343,6 +343,11 @@ TH2MLocalAssembler(C_index, temperature_index) - .noalias() += NpT * ip_cv.dfC_4_MCu_dT * div_u_dot * NT * w; + .noalias() += NpT * ip_dd.dfC_4_MCu.dT * div_u_dot * NT * w; LCpG.noalias() += gradNpT * ip_cv.fC_4_LCpG.L * gradNp * w; From 65a5d524d6fbe0aed7377c4da70c3c0297a4b555 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Fri, 12 Apr 2024 15:36:27 +0200 Subject: [PATCH 17/45] [PL/TH2M] Extract data and model of C1 equation --- .../TH2M/ConstitutiveRelations/CEquation.cpp | 13 +++++++++++++ .../TH2M/ConstitutiveRelations/CEquation.h | 17 +++++++++++++++++ .../ConstitutiveRelations/ConstitutiveData.h | 1 + .../ConstitutiveRelations/ConstitutiveModels.h | 1 + ProcessLib/TH2M/TH2MFEM-impl.h | 13 +++++-------- 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp index 2ca35bcabd7..6242c36efd4 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.cpp @@ -13,6 +13,19 @@ namespace ProcessLib::TH2M { namespace ConstitutiveRelations { +template +void FC1Model::eval( + AdvectionData const& advection_data, + FluidDensityData const& fluid_density_data, + FC1Data& fC_1) const +{ + fC_1.A = advection_data.advection_C_G * fluid_density_data.rho_GR + + advection_data.advection_C_L * fluid_density_data.rho_LR; +} + +template struct FC1Model<2>; +template struct FC1Model<3>; + void FC2aModel::eval(BiotData const biot_data, CapillaryPressureData const pCap, ConstituentDensityData const& constituent_density_data, diff --git a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h index 14a3852e800..c4de9c36a64 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/CEquation.h @@ -25,6 +25,23 @@ namespace ProcessLib::TH2M { namespace ConstitutiveRelations { +template +struct FC1Data +{ + GlobalDimMatrix A; +}; + +template +struct FC1Model +{ + void eval(AdvectionData const& advection_data, + FluidDensityData const& fluid_density_data, + FC1Data& fC_1) const; +}; + +extern template struct FC1Model<2>; +extern template struct FC1Model<3>; + struct FC2aData { double a = nan; diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 818a59a8f65..5eb444f4e86 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -155,6 +155,7 @@ struct ConstitutiveTempData ThermalConductivityData thermal_conductivity_data; EffectiveVolumetricEnthalpy effective_volumetric_enthalpy_data; AdvectionData advection_data; + FC1Data fC_1; FC2aData fC_2a; FC3aData fC_3a; FC4LCpGData fC_4_LCpG; diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index bf27bce4a8a..b258e3980fd 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -81,6 +81,7 @@ struct ConstitutiveModels AdvectionModel advection_model; InternalEnergyModel internal_energy_model; EffectiveVolumetricEnthalpyModel effective_volumetric_enthalpy_model; + FC1Model fC_1_model; FC2aModel fC_2a_model; FC3aModel fC_3a_model; FC4LCpGModel fC_4_LCpG_model; diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 68b8a59227c..de5f308dd42 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -284,6 +284,9 @@ TH2MLocalAssemblerprocess_data_.apply_mass_lumping) { models.fC_2a_model.eval(ip_cv.biot_data, @@ -1190,10 +1193,7 @@ void TH2MLocalAssembler< LCT.noalias() += gradNpT * ip_cv.fC_4_LCT.L * gradNp * w; - fC.noalias() += gradNpT * - (ip_cv.advection_data.advection_C_G * rhoGR + - ip_cv.advection_data.advection_C_L * rhoLR) * - b * w; + fC.noalias() += gradNpT * ip_cv.fC_1.A * b * w; if (!this->process_data_.apply_mass_lumping) { @@ -1678,10 +1678,7 @@ void TH2MLocalAssemblerprocess_data_.apply_mass_lumping) { From 93605f107f0a6ae5ba3756c16a3937bb0de55155 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Fri, 12 Apr 2024 16:00:12 +0200 Subject: [PATCH 18/45] [PL/TH2M] Extract data and model of W1 equation --- .../ConstitutiveRelations/ConstitutiveData.h | 3 ++ .../ConstitutiveModels.h | 3 ++ .../TH2M/ConstitutiveRelations/WEquation.cpp | 29 ++++++++++++ .../TH2M/ConstitutiveRelations/WEquation.h | 45 +++++++++++++++++++ ProcessLib/TH2M/TH2MFEM-impl.h | 13 +++--- 5 files changed, 85 insertions(+), 8 deletions(-) create mode 100644 ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp create mode 100644 ProcessLib/TH2M/ConstitutiveRelations/WEquation.h diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 5eb444f4e86..c4afbab2673 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -41,6 +41,7 @@ #include "TotalStress.h" #include "VapourPartialPressure.h" #include "Viscosity.h" +#include "WEquation.h" namespace ProcessLib::TH2M { @@ -166,6 +167,8 @@ struct ConstitutiveTempData FC4MCTData fC_4_MCT; FC4MCuData fC_4_MCu; + FW1Data fW_1; + using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = Eigen::Matrix; diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index b258e3980fd..d74056b26f3 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -31,6 +31,7 @@ #include "ThermalConductivity.h" #include "TotalStress.h" #include "Viscosity.h" +#include "WEquation.h" namespace ProcessLib::TH2M { @@ -91,6 +92,8 @@ struct ConstitutiveModels FC4MCpCModel fC_4_MCpC_model; FC4MCTModel fC_4_MCT_model; FC4MCuModel fC_4_MCu_model; + + FW1Model fW_1_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp new file mode 100644 index 00000000000..8f8666acc27 --- /dev/null +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp @@ -0,0 +1,29 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#include "WEquation.h" + +namespace ProcessLib::TH2M +{ +namespace ConstitutiveRelations +{ +template +void FW1Model::eval( + AdvectionData const& advection_data, + FluidDensityData const& fluid_density_data, + FW1Data& fW_1) const +{ + fW_1.A = advection_data.advection_W_G * fluid_density_data.rho_GR + + advection_data.advection_W_L * fluid_density_data.rho_LR; +} + +template struct FW1Model<2>; +template struct FW1Model<3>; +} // namespace ConstitutiveRelations +} // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h new file mode 100644 index 00000000000..bf360e95fdf --- /dev/null +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h @@ -0,0 +1,45 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#pragma once + +#include "Advection.h" +#include "Base.h" +#include "Biot.h" +#include "ConstitutiveDensity.h" +#include "FluidDensity.h" +#include "PermeabilityData.h" +#include "PhaseTransitionData.h" +#include "Porosity.h" +#include "Saturation.h" +#include "SolidCompressibility.h" +#include "Viscosity.h" + +namespace ProcessLib::TH2M +{ +namespace ConstitutiveRelations +{ +template +struct FW1Data +{ + GlobalDimMatrix A; +}; + +template +struct FW1Model +{ + void eval(AdvectionData const& advection_data, + FluidDensityData const& fluid_density_data, + FW1Data& fW_1) const; +}; + +extern template struct FW1Model<2>; +extern template struct FW1Model<3>; +} // namespace ConstitutiveRelations +} // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index de5f308dd42..c09298ff4f6 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -351,6 +351,9 @@ TH2MLocalAssemblerprocess_data_.apply_mass_lumping) { @@ -1811,10 +1811,7 @@ void TH2MLocalAssemblerprocess_data_.apply_mass_lumping) From 8b32a17bda4bc96b38dda0d7182eab088b783791 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Fri, 12 Apr 2024 16:25:17 +0200 Subject: [PATCH 19/45] [PL/TH2M] Extract data and model of W2 equation --- .../ConstitutiveRelations/ConstitutiveData.h | 8 +- .../ConstitutiveModels.h | 1 + .../TH2M/ConstitutiveRelations/WEquation.cpp | 79 ++++++++++++ .../TH2M/ConstitutiveRelations/WEquation.h | 36 ++++++ ProcessLib/TH2M/TH2MFEM-impl.h | 112 +++++++----------- 5 files changed, 158 insertions(+), 78 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index c4afbab2673..22819055f0f 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -168,6 +168,7 @@ struct ConstitutiveTempData FC4MCuData fC_4_MCu; FW1Data fW_1; + FW2Data fW_2; using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = @@ -192,12 +193,6 @@ struct ConstitutiveTempData DisplacementDimMatrix dfW_4_LWpC_d_dT; DisplacementDimMatrix dk_over_mu_G_dp_cap; DisplacementDimMatrix dk_over_mu_L_dp_cap; - double dfW_2a_dp_GR = std::numeric_limits::quiet_NaN(); - double dfW_2b_dp_GR = std::numeric_limits::quiet_NaN(); - double dfW_2a_dp_cap = std::numeric_limits::quiet_NaN(); - double dfW_2b_dp_cap = std::numeric_limits::quiet_NaN(); - double dfW_2a_dT = std::numeric_limits::quiet_NaN(); - double dfW_2b_dT = std::numeric_limits::quiet_NaN(); double dfW_3a_dp_GR = std::numeric_limits::quiet_NaN(); double dfW_3a_dp_cap = std::numeric_limits::quiet_NaN(); double dfW_3a_dT = std::numeric_limits::quiet_NaN(); @@ -222,6 +217,7 @@ struct DerivativesData FC4MCpGDerivativeData dfC_4_MCpG; FC4MCTDerivativeData dfC_4_MCT; FC4MCuDerivativeData dfC_4_MCu; + FW2DerivativeData dfW_2; }; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index d74056b26f3..b7ad8b0d356 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -94,6 +94,7 @@ struct ConstitutiveModels FC4MCuModel fC_4_MCu_model; FW1Model fW_1_model; + FW2Model fW_2_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp index 8f8666acc27..57d4a9a1d71 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp @@ -25,5 +25,84 @@ void FW1Model::eval( template struct FW1Model<2>; template struct FW1Model<3>; + +void FW2Model::eval(BiotData const biot_data, + CapillaryPressureData const pCap, + ConstituentDensityData const& constituent_density_data, + PorosityData const& porosity_data, + PureLiquidDensityData const& rho_W_LR, + SaturationData const& S_L_data, + SolidCompressibilityData const beta_p_SR, + FW2Data& fW_2) const +{ + auto const S_L = S_L_data.S_L; + auto const S_G = 1. - S_L; + double const rho_W_FR = + S_G * constituent_density_data.rho_W_GR + S_L * rho_W_LR(); + + fW_2.a = + porosity_data.phi * (rho_W_LR() - constituent_density_data.rho_W_GR) - + rho_W_FR * pCap() * (biot_data() - porosity_data.phi) * beta_p_SR(); +} + +void FW2Model::dEval(BiotData const& biot_data, + CapillaryPressureData const pCap, + ConstituentDensityData const& constituent_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + PorosityDerivativeData const& porosity_d_data, + PureLiquidDensityData const& rho_W_LR, + SaturationData const& S_L_data, + SaturationDataDeriv const& dS_L_dp_cap, + SolidCompressibilityData const& beta_p_SR, + FW2DerivativeData& dfW_2) const +{ + double const S_L = S_L_data.S_L; + double const S_G = 1. - S_L; + + double const drho_C_FR_dp_GR = + /*(dS_G_dp_GR = 0) * constituent_density_data.rho_C_GR +*/ + S_G * phase_transition_data.drho_C_GR_dp_GR + + /*(dS_L_dp_GR = 0) * constituent_density_data.rho_C_LR +*/ + S_L * phase_transition_data.drho_C_LR_dp_GR; + + dfW_2.dp_GR = -porosity_data.phi * phase_transition_data.drho_C_GR_dp_GR - + drho_C_FR_dp_GR * pCap() * (biot_data() - porosity_data.phi) * + beta_p_SR(); + + double const dfW_2a_dp_cap = + porosity_data.phi * (-phase_transition_data.drho_W_LR_dp_LR - + phase_transition_data.drho_W_GR_dp_cap); + double const rho_W_FR = + S_G * constituent_density_data.rho_W_GR + S_L * rho_W_LR(); + + double const drho_W_FR_dp_cap = + -dS_L_dp_cap() * constituent_density_data.rho_W_GR + + S_G * phase_transition_data.drho_W_GR_dp_cap + + dS_L_dp_cap() * rho_W_LR() - + S_L * phase_transition_data.drho_W_LR_dp_LR; + + double const dfW_2b_dp_cap = + drho_W_FR_dp_cap * pCap() * (biot_data() - porosity_data.phi) * + beta_p_SR() + + rho_W_FR * (biot_data() - porosity_data.phi) * beta_p_SR(); + + dfW_2.dp_cap = dfW_2a_dp_cap - dfW_2b_dp_cap; + + double const drho_W_FR_dT = S_G * phase_transition_data.drho_W_GR_dT + + S_L * phase_transition_data.drho_W_LR_dT; + + double const dfW_2a_dT = + porosity_d_data.dphi_dT * + (rho_W_LR() - constituent_density_data.rho_W_GR) + + porosity_data.phi * (phase_transition_data.drho_W_LR_dT - + phase_transition_data.drho_W_GR_dT); + double const dfW_2b_dT = + drho_W_FR_dT * pCap() * (biot_data() - porosity_data.phi) * + beta_p_SR() - + rho_W_FR * pCap() * porosity_d_data.dphi_dT * beta_p_SR(); + + dfW_2.dT = dfW_2a_dT - dfW_2b_dT; +} } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h index bf360e95fdf..364e4e59d63 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h @@ -41,5 +41,41 @@ struct FW1Model extern template struct FW1Model<2>; extern template struct FW1Model<3>; + +struct FW2Data +{ + double a = nan; +}; + +struct FW2DerivativeData +{ + double dp_GR = nan; + double dp_cap = nan; + double dT = nan; +}; + +struct FW2Model +{ + void eval(BiotData const biot_data, + CapillaryPressureData const pCap, + ConstituentDensityData const& constituent_density_data, + PorosityData const& porosity_data, + PureLiquidDensityData const& rho_W_LR, + SaturationData const& S_L_data, + SolidCompressibilityData const beta_p_SR, + FW2Data& fW_2) const; + + void dEval(BiotData const& biot_data, + CapillaryPressureData const pCap, + ConstituentDensityData const& constituent_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + PorosityDerivativeData const& porosity_d_data, + PureLiquidDensityData const& rho_W_LR, + SaturationData const& S_L_data, + SaturationDataDeriv const& dS_L_dp_cap, + SolidCompressibilityData const& beta_p_SR, + FW2DerivativeData& dfW_2) const; +}; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index c09298ff4f6..796e8be1ac3 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -354,6 +354,18 @@ TH2MLocalAssemblerprocess_data_.apply_mass_lumping) + { + models.fW_2_model.eval(ip_cv.biot_data, + pCap_data, + current_state.constituent_density_data, + ip_out.porosity_data, + current_state.rho_W_LR, + current_state.S_L_data, + ip_cv.beta_p_SR, + ip_cv.fW_2); + } + // for variable output auto const xmCL = 1. - ip_out.mass_mole_fractions_data.xmWL; @@ -474,53 +486,6 @@ TH2MLocalAssemblerrho_W_GR) / @@ -763,6 +732,21 @@ TH2MLocalAssemblerprocess_data_.apply_mass_lumping) + { + models.fW_2_model.dEval(ip_cv.biot_data, + pCap_data, + current_state.constituent_density_data, + ip_cv.phase_transition_data, + ip_out.porosity_data, + ip_cv.porosity_d_data, + current_state.rho_W_LR, + current_state.S_L_data, + ip_cv.dS_L_dp_cap, + ip_cv.beta_p_SR, + ip_dd.dfW_2); + } } return ip_d_data; @@ -1278,14 +1262,7 @@ void TH2MLocalAssembler< if (!this->process_data_.apply_mass_lumping) { - fW.noalias() -= - NpT * - (ip_out.porosity_data.phi * - (current_state.rho_W_LR() - - current_state.constituent_density_data.rho_W_GR) - - rho_W_FR * pCap * (alpha_B - ip_out.porosity_data.phi) * - beta_p_SR) * - s_L_dot * w; + fW.noalias() -= NpT * ip_cv.fW_2.a * s_L_dot * w; } fW.noalias() -= NpT * ip_out.porosity_data.phi * @@ -1813,36 +1790,27 @@ void TH2MLocalAssemblerprocess_data_.apply_mass_lumping) { - double const f = ip_out.porosity_data.phi * - (current_state.rho_W_LR() - - current_state.constituent_density_data.rho_W_GR); - double const g = rho_W_FR * pCap * - (alpha_B - ip_out.porosity_data.phi) * beta_p_SR; - - fW.noalias() -= NpT * (f - g) * s_L_dot * w; + fW.noalias() -= NpT * ip_cv.fW_2.a * s_L_dot * w; local_Jac.template block(W_index, C_index) - .noalias() += NpT * (ip_cv.dfW_2a_dp_GR - ip_cv.dfW_2b_dp_GR) * - s_L_dot * Np * w; + .noalias() += NpT * ip_dd.dfW_2.dp_GR * s_L_dot * Np * w; // sign negated because of dp_cap = -dp_LR // TODO (naumov) Had to change the sign to get equal Jacobian WW // blocks in A2 Test. Where is the error? local_Jac.template block(W_index, W_index) - .noalias() += - NpT * - ((ip_cv.dfW_2a_dp_cap - ip_cv.dfW_2b_dp_cap) * s_L_dot + - (f - g) * ip_cv.dS_L_dp_cap() / dt) * - Np * w; + .noalias() += NpT * + (ip_dd.dfW_2.dp_cap * s_L_dot + + ip_cv.fW_2.a * ip_cv.dS_L_dp_cap() / dt) * + Np * w; local_Jac .template block(W_index, temperature_index) - .noalias() += - NpT * (ip_cv.dfW_2a_dT - ip_cv.dfW_2b_dT) * s_L_dot * Np * w; + .noalias() += NpT * ip_dd.dfW_2.dT * s_L_dot * Np * w; } // fW_3 = \int phi * a From 1dafae3b65421b60afb08d90a8341baea2671dfb Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Fri, 12 Apr 2024 18:53:14 +0200 Subject: [PATCH 20/45] [PL/TH2M] Extract data and model of W3 equation --- .../ConstitutiveRelations/ConstitutiveData.h | 5 +- .../ConstitutiveModels.h | 1 + .../TH2M/ConstitutiveRelations/WEquation.cpp | 65 ++++++++++++++++ .../TH2M/ConstitutiveRelations/WEquation.h | 36 +++++++++ ProcessLib/TH2M/TH2MFEM-impl.h | 78 ++++++------------- 5 files changed, 127 insertions(+), 58 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 22819055f0f..be2416cf10a 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -169,6 +169,7 @@ struct ConstitutiveTempData FW1Data fW_1; FW2Data fW_2; + FW3aData fW_3a; using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = @@ -193,9 +194,6 @@ struct ConstitutiveTempData DisplacementDimMatrix dfW_4_LWpC_d_dT; DisplacementDimMatrix dk_over_mu_G_dp_cap; DisplacementDimMatrix dk_over_mu_L_dp_cap; - double dfW_3a_dp_GR = std::numeric_limits::quiet_NaN(); - double dfW_3a_dp_cap = std::numeric_limits::quiet_NaN(); - double dfW_3a_dT = std::numeric_limits::quiet_NaN(); }; /// Data that stores intermediate values (derivatives), which are not needed @@ -218,6 +216,7 @@ struct DerivativesData FC4MCTDerivativeData dfC_4_MCT; FC4MCuDerivativeData dfC_4_MCu; FW2DerivativeData dfW_2; + FW3aDerivativeData dfW_3a; }; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index b7ad8b0d356..6b24788d09e 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -95,6 +95,7 @@ struct ConstitutiveModels FW1Model fW_1_model; FW2Model fW_2_model; + FW3aModel fW_3a_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp index 57d4a9a1d71..4613b256931 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp @@ -104,5 +104,70 @@ void FW2Model::dEval(BiotData const& biot_data, dfW_2.dT = dfW_2a_dT - dfW_2b_dT; } + +void FW3aModel::eval( + double const dt, + ConstituentDensityData const& constituent_density_data, + PrevState const& constituent_density_data_prev, + PrevState const& rho_W_LR_prev, + PureLiquidDensityData const& rho_W_LR, + SaturationData const& S_L_data, + FW3aData& fW_3a) const +{ + if (dt == 0.) + { + fW_3a.a = 0; + return; + } + + double const rho_W_GR_dot = (constituent_density_data.rho_W_GR - + constituent_density_data_prev->rho_W_GR) / + dt; + double const rho_W_LR_dot = (rho_W_LR() - **rho_W_LR_prev) / dt; + auto const S_L = S_L_data.S_L; + auto const S_G = 1. - S_L; + fW_3a.a = S_G * rho_W_GR_dot + S_L * rho_W_LR_dot; +} + +void FW3aModel::dEval( + double const dt, + ConstituentDensityData const& constituent_density_data, + PhaseTransitionData const& phase_transition_data, + PrevState const& constituent_density_data_prev, + PrevState const& rho_W_LR_prev, + PureLiquidDensityData const& rho_W_LR, + SaturationData const& S_L_data, + SaturationDataDeriv const& dS_L_dp_cap, + FW3aDerivativeData& dfW_3a) const +{ + if (dt == 0.) + { + dfW_3a.dp_GR = 0.; + dfW_3a.dp_cap = 0.; + dfW_3a.dT = 0.; + return; + } + + auto const S_L = S_L_data.S_L; + auto const S_G = 1. - S_L; + + double const rho_W_GR_dot = (constituent_density_data.rho_W_GR - + constituent_density_data_prev->rho_W_GR) / + dt; + double const rho_W_LR_dot = (rho_W_LR() - **rho_W_LR_prev) / dt; + + dfW_3a.dp_GR = /*(ds_G_dp_GR = 0) * rho_W_GR_dot +*/ + S_G * phase_transition_data.drho_W_GR_dp_GR / dt + + /*(ds_L_dp_GR = 0) * rho_W_LR_dot +*/ + S_L * phase_transition_data.drho_W_LR_dp_GR / dt; + + dfW_3a.dp_cap = -dS_L_dp_cap() * rho_W_GR_dot + + S_G * phase_transition_data.drho_W_GR_dp_cap / dt + + dS_L_dp_cap() * rho_W_LR_dot - + S_L * phase_transition_data.drho_W_LR_dp_LR / dt; + dfW_3a.dT = S_G * phase_transition_data.drho_W_GR_dT / dt + + S_L * phase_transition_data.drho_W_LR_dT / dt; +} + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h index 364e4e59d63..a1da6b1ebc2 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h @@ -77,5 +77,41 @@ struct FW2Model SolidCompressibilityData const& beta_p_SR, FW2DerivativeData& dfW_2) const; }; + +struct FW3aData +{ + double a = nan; +}; + +struct FW3aDerivativeData +{ + double dp_GR = nan; + double dp_cap = nan; + double dT = nan; +}; + +struct FW3aModel +{ + void eval( + double const dt, + ConstituentDensityData const& constituent_density_data, + PrevState const& constituent_density_data_prev, + PrevState const& rho_W_LR_prev, + PureLiquidDensityData const& rho_W_LR, + SaturationData const& S_L_data, + FW3aData& fW_3a) const; + + void dEval( + double const dt, + ConstituentDensityData const& constituent_density_data, + PhaseTransitionData const& phase_transition_data, + PrevState const& constituent_density_data_prev, + PrevState const& rho_W_LR_prev, + PureLiquidDensityData const& rho_W_LR, + SaturationData const& S_L_data, + SaturationDataDeriv const& dS_L_dp_cap, + FW3aDerivativeData& dfW_3a) const; +}; + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 796e8be1ac3..4866f4a5e4e 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -365,6 +365,13 @@ TH2MLocalAssemblerrho_W_GR) / - dt; - double const rho_W_LR_dot = - (current_state.rho_W_LR() - **prev_state.rho_W_LR) / dt; - - ip_cv.dfW_3a_dp_GR = - /*(ds_G_dp_GR = 0) * rho_W_GR_dot +*/ s_G * c.drho_W_GR_dp_GR / - dt + - /*(ds_L_dp_GR = 0) * rho_W_LR_dot +*/ s_L * c.drho_W_LR_dp_GR / - dt; - ip_cv.dfW_3a_dp_cap = ds_G_dp_cap * rho_W_GR_dot + - s_G * c.drho_W_GR_dp_cap / dt + - ip_cv.dS_L_dp_cap() * rho_W_LR_dot - - s_L * c.drho_W_LR_dp_LR / dt; - ip_cv.dfW_3a_dT = - s_G * c.drho_W_GR_dT / dt + s_L * c.drho_W_LR_dT / dt; - } - ip_cv.dfW_4_LWpG_a_dp_GR = c.drho_W_GR_dp_GR * k_over_mu_G // + rhoWGR * (dk_over_mu_G_dp_GR = 0) + c.drho_W_LR_dp_GR * k_over_mu_L @@ -747,6 +722,16 @@ TH2MLocalAssemblerrho_W_GR) / - dt; - auto const rho_W_LR_dot = - (current_state.rho_W_LR() - **prev_state.rho_W_LR) / dt; - // --------------------------------------------------------------------- // C-component equation // --------------------------------------------------------------------- @@ -1265,8 +1243,7 @@ void TH2MLocalAssembler< fW.noalias() -= NpT * ip_cv.fW_2.a * s_L_dot * w; } - fW.noalias() -= NpT * ip_out.porosity_data.phi * - (s_G * rho_W_GR_dot + s_L * rho_W_LR_dot) * w; + fW.noalias() -= NpT * ip_out.porosity_data.phi * ip_cv.fW_3a.a * w; // --------------------------------------------------------------------- // - temperature equation @@ -1572,13 +1549,6 @@ void TH2MLocalAssemblerrho_W_GR) / - dt; - auto const rho_W_LR_dot = - (current_state.rho_W_LR() - **prev_state.rho_W_LR) / dt; - // --------------------------------------------------------------------- // C-component equation // --------------------------------------------------------------------- @@ -1814,22 +1784,20 @@ void TH2MLocalAssembler(W_index, C_index).noalias() += - NpT * ip_out.porosity_data.phi * ip_cv.dfW_3a_dp_GR * Np * w; + NpT * ip_out.porosity_data.phi * ip_dd.dfW_3a.dp_GR * Np * w; local_Jac.template block(W_index, W_index).noalias() += - NpT * ip_out.porosity_data.phi * ip_cv.dfW_3a_dp_cap * Np * w; + NpT * ip_out.porosity_data.phi * ip_dd.dfW_3a.dp_cap * Np * w; local_Jac .template block(W_index, temperature_index) .noalias() += NpT * - (ip_cv.porosity_d_data.dphi_dT * - (s_G * rho_W_GR_dot + s_L * rho_W_LR_dot) + - ip_out.porosity_data.phi * ip_cv.dfW_3a_dT) * + (ip_cv.porosity_d_data.dphi_dT * ip_cv.fW_3a.a + + ip_out.porosity_data.phi * ip_dd.dfW_3a.dT) * NT * w; // --------------------------------------------------------------------- From d3d6de6e75dd0b55ff73bb5ca77d7665f1664e9e Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Fri, 12 Apr 2024 19:19:20 +0200 Subject: [PATCH 21/45] [PL/TH2M] Extract LWpG part of W4 equation data and model. Small optimization in diffusion_W_p evaluation; moved identity multiplication to the end. --- .../ConstitutiveRelations/ConstitutiveData.h | 9 +- .../ConstitutiveModels.h | 1 + .../TH2M/ConstitutiveRelations/WEquation.cpp | 85 ++++++++++++++++++ .../TH2M/ConstitutiveRelations/WEquation.h | 36 ++++++++ ProcessLib/TH2M/TH2MFEM-impl.h | 86 +++++-------------- 5 files changed, 144 insertions(+), 73 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index be2416cf10a..fc9b04d0fea 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -170,6 +170,7 @@ struct ConstitutiveTempData FW1Data fW_1; FW2Data fW_2; FW3aData fW_3a; + FW4LWpGData fW_4_LWpG; using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = @@ -180,19 +181,12 @@ struct ConstitutiveTempData DisplacementDimVector drho_LR_h_w_eff_dp_cap_Npart; DisplacementDimMatrix drho_LR_h_w_eff_dp_cap_gradNpart; DisplacementDimVector drho_GR_h_w_eff_dT; - DisplacementDimMatrix dfW_4_LWpG_a_dp_GR; - DisplacementDimMatrix dfW_4_LWpG_a_dp_cap; - DisplacementDimMatrix dfW_4_LWpG_a_dT; - DisplacementDimMatrix dfW_4_LWpG_d_dp_GR; - DisplacementDimMatrix dfW_4_LWpG_d_dp_cap; - DisplacementDimMatrix dfW_4_LWpG_d_dT; DisplacementDimMatrix dfW_4_LWpC_a_dp_GR; DisplacementDimMatrix dfW_4_LWpC_a_dp_cap; DisplacementDimMatrix dfW_4_LWpC_a_dT; DisplacementDimMatrix dfW_4_LWpC_d_dp_GR; DisplacementDimMatrix dfW_4_LWpC_d_dp_cap; DisplacementDimMatrix dfW_4_LWpC_d_dT; - DisplacementDimMatrix dk_over_mu_G_dp_cap; DisplacementDimMatrix dk_over_mu_L_dp_cap; }; @@ -217,6 +211,7 @@ struct DerivativesData FC4MCuDerivativeData dfC_4_MCu; FW2DerivativeData dfW_2; FW3aDerivativeData dfW_3a; + FW4LWpGDerivativeData dfW_4_LWpG; }; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index 6b24788d09e..33c1eaf495e 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -96,6 +96,7 @@ struct ConstitutiveModels FW1Model fW_1_model; FW2Model fW_2_model; FW3aModel fW_3a_model; + FW4LWpGModel fW_4_LWpG_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp index 4613b256931..dc127ce8621 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp @@ -169,5 +169,90 @@ void FW3aModel::dEval( S_L * phase_transition_data.drho_W_LR_dT / dt; } +template +void FW4LWpGModel::eval( + AdvectionData const& advection_data, + FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + FW4LWpGData& fW_4_LWpG) const +{ + GlobalDimMatrix const advection_W = + advection_data.advection_W_G + advection_data.advection_W_L; + + double const sD_G = phase_transition_data.diffusion_coefficient_vapour; + double const sD_L = phase_transition_data.diffusion_coefficient_solute; + + double const phi_G = (1 - S_L_data.S_L) * porosity_data.phi; + double const phi_L = S_L_data.S_L * porosity_data.phi; + + double const diffusion_WGpGR = phi_G * fluid_density_data.rho_GR * sD_G * + phase_transition_data.dxmWG_dpGR; + double const diffusion_WLpGR = phi_L * fluid_density_data.rho_LR * sD_L * + phase_transition_data.dxmWL_dpGR; + double const diffusion_W_pGR = diffusion_WGpGR + diffusion_WLpGR; + + auto const I = + Eigen::Matrix::Identity(); + fW_4_LWpG.L.noalias() = diffusion_W_pGR * I + advection_W; +} + +template +void FW4LWpGModel::dEval( + ConstituentDensityData const& constituent_density_data, + PermeabilityData const& permeability_data, + PhaseTransitionData const& phase_transition_data, + PureLiquidDensityData const& rho_W_LR, + SaturationDataDeriv const& dS_L_dp_cap, + ViscosityData const& viscosity_data, + FW4LWpGDerivativeData& dfW_4_LWpG) const +{ + ////// Diffusion Part ///// + // TODO (naumov) d(diffusion_W_p)/dX for dxmW*/d* != 0 + + auto const k_over_mu_G = + permeability_data.Ki * permeability_data.k_rel_G / viscosity_data.mu_GR; + auto const k_over_mu_L = + permeability_data.Ki * permeability_data.k_rel_L / viscosity_data.mu_LR; + + // dk_over_mu_G_dp_GR = ip_out.permeability_data.Ki * + // ip_out.permeability_data.dk_rel_G_dS_L * + // (ds_L_dp_GR = 0) / + // ip_cv.viscosity_data.mu_GR = 0; + // dk_over_mu_L_dp_GR = ip_out.permeability_data.Ki * + // ip_out.permeability_data.dk_rel_L_dS_L * + // (ds_L_dp_GR = 0) / + // ip_cv.viscosity_data.mu_LR = 0; + auto const dk_over_mu_G_dp_cap = permeability_data.Ki * + permeability_data.dk_rel_G_dS_L * + dS_L_dp_cap() / viscosity_data.mu_GR; + + auto const dk_over_mu_L_dp_cap = permeability_data.Ki * + permeability_data.dk_rel_L_dS_L * + dS_L_dp_cap() / viscosity_data.mu_LR; + + dfW_4_LWpG.dp_GR = phase_transition_data.drho_W_GR_dp_GR * k_over_mu_G + // + rhoWGR * (dk_over_mu_G_dp_GR = 0) + + phase_transition_data.drho_W_LR_dp_GR * k_over_mu_L + // + rhoWLR * (dk_over_mu_L_dp_GR = 0) + ; + + dfW_4_LWpG.dp_cap = + phase_transition_data.drho_W_GR_dp_cap * k_over_mu_G + + constituent_density_data.rho_W_GR * dk_over_mu_G_dp_cap + + -phase_transition_data.drho_W_LR_dp_LR * k_over_mu_L + + rho_W_LR() * dk_over_mu_L_dp_cap; + + dfW_4_LWpG.dT = phase_transition_data.drho_W_GR_dT * k_over_mu_G + //+ rhoWGR * (dk_over_mu_G_dT != 0 TODO for mu_G(T)) + + phase_transition_data.drho_W_LR_dT * k_over_mu_L + //+ rhoWLR * (dk_over_mu_L_dT != 0 TODO for mu_G(T)) + ; +} + +template struct FW4LWpGModel<2>; +template struct FW4LWpGModel<3>; + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h index a1da6b1ebc2..8d88c9e7eff 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h @@ -113,5 +113,41 @@ struct FW3aModel FW3aDerivativeData& dfW_3a) const; }; +template +struct FW4LWpGData +{ + GlobalDimMatrix L; +}; + +template +struct FW4LWpGDerivativeData +{ + GlobalDimMatrix dp_GR; + GlobalDimMatrix dp_cap; + GlobalDimMatrix dT; +}; + +template +struct FW4LWpGModel +{ + void eval(AdvectionData const& advection_data, + FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + FW4LWpGData& fW_4_LWpG) const; + + void dEval(ConstituentDensityData const& constituent_density_data, + PermeabilityData const& permeability_data, + PhaseTransitionData const& phase_transition_data, + PureLiquidDensityData const& rho_W_LR, + SaturationDataDeriv const& dS_L_dp_cap, + ViscosityData const& viscosity_data, + FW4LWpGDerivativeData& dfW_4_LWpG) const; +}; + +extern template struct FW4LWpGModel<2>; +extern template struct FW4LWpGModel<3>; + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 4866f4a5e4e..934bf873412 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -373,6 +373,13 @@ TH2MLocalAssembler::Zero(); - ip_cv.dfW_4_LWpG_d_dp_cap = - Eigen::Matrix::Zero(); - ip_cv.dfW_4_LWpG_d_dT = - Eigen::Matrix::Zero(); - ip_cv.dfW_4_LWpC_a_dp_GR = c.drho_W_LR_dp_GR * k_over_mu_L //+ rhoWLR * (dk_over_mu_L_dp_GR = 0) ; @@ -732,6 +700,14 @@ TH2MLocalAssembler; - DisplacementDimMatrix const diffusion_WGpGR = - phi_G * rhoGR * D_W_G * ip_cv.phase_transition_data.dxmWG_dpGR; - DisplacementDimMatrix const diffusion_WLpGR = - phi_L * rhoLR * D_W_L * ip_cv.phase_transition_data.dxmWL_dpGR; - DisplacementDimMatrix const diffusion_WGpCap = phi_G * rhoGR * D_W_G * ip_cv.phase_transition_data.dxmWG_dpCap; DisplacementDimMatrix const diffusion_WLpCap = @@ -1216,19 +1187,13 @@ void TH2MLocalAssembler< DisplacementDimMatrix const diffusion_WLT = phi_L * rhoLR * D_W_L * ip_cv.phase_transition_data.dxmWL_dT; - DisplacementDimMatrix const advection_W = - ip_cv.advection_data.advection_W_G + - ip_cv.advection_data.advection_W_L; - DisplacementDimMatrix const diffusion_W_pGR = - diffusion_WGpGR + diffusion_WLpGR; DisplacementDimMatrix const diffusion_W_pCap = diffusion_WGpCap + diffusion_WLpCap; DisplacementDimMatrix const diffusion_W_T = diffusion_WGT + diffusion_WLT; - LWpG.noalias() += - gradNpT * (advection_W + diffusion_W_pGR) * gradNp * w; + LWpG.noalias() += gradNpT * ip_cv.fW_4_LWpG.L * gradNp * w; LWpC.noalias() += gradNpT * (diffusion_W_pCap - ip_cv.advection_data.advection_W_L) * @@ -1700,8 +1665,6 @@ void TH2MLocalAssembler(W_index, C_index).noalias() += - gradNpT * (ip_cv.dfW_4_LWpG_a_dp_GR + ip_cv.dfW_4_LWpG_d_dp_GR) * - gradpGR * Np * w; + gradNpT * ip_dd.dfW_4_LWpG.dp_GR * gradpGR * Np * w; local_Jac.template block(W_index, W_index).noalias() += - gradNpT * (ip_cv.dfW_4_LWpG_a_dp_cap + ip_cv.dfW_4_LWpG_d_dp_cap) * - gradpGR * Np * w; + gradNpT * ip_dd.dfW_4_LWpG.dp_cap * gradpGR * Np * w; local_Jac .template block(W_index, temperature_index) - .noalias() += gradNpT * - (ip_cv.dfW_4_LWpG_a_dT + ip_cv.dfW_4_LWpG_d_dT) * - gradpGR * NT * w; + .noalias() += gradNpT * ip_dd.dfW_4_LWpG.dT * gradpGR * NT * w; LWpC.noalias() -= gradNpT * (ip_cv.advection_data.advection_W_L + diffusion_W_L_p) * From ab602ab220f6905439c46b5f68d97eab680c258c Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Sun, 14 Apr 2024 12:28:11 +0200 Subject: [PATCH 22/45] [PL/TH2M] Extract LWpC part of W4 equation data and model. Small optimization in diffusion_W_p evaluation; moved identity multiplication to the end. --- .../ConstitutiveRelations/ConstitutiveData.h | 9 +- .../ConstitutiveModels.h | 1 + .../TH2M/ConstitutiveRelations/WEquation.cpp | 91 +++++++++++++++++++ .../TH2M/ConstitutiveRelations/WEquation.h | 39 ++++++++ ProcessLib/TH2M/TH2MFEM-impl.h | 69 +++++--------- 5 files changed, 156 insertions(+), 53 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index fc9b04d0fea..3860d4374c6 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -171,6 +171,7 @@ struct ConstitutiveTempData FW2Data fW_2; FW3aData fW_3a; FW4LWpGData fW_4_LWpG; + FW4LWpCData fW_4_LWpC; using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = @@ -181,13 +182,6 @@ struct ConstitutiveTempData DisplacementDimVector drho_LR_h_w_eff_dp_cap_Npart; DisplacementDimMatrix drho_LR_h_w_eff_dp_cap_gradNpart; DisplacementDimVector drho_GR_h_w_eff_dT; - DisplacementDimMatrix dfW_4_LWpC_a_dp_GR; - DisplacementDimMatrix dfW_4_LWpC_a_dp_cap; - DisplacementDimMatrix dfW_4_LWpC_a_dT; - DisplacementDimMatrix dfW_4_LWpC_d_dp_GR; - DisplacementDimMatrix dfW_4_LWpC_d_dp_cap; - DisplacementDimMatrix dfW_4_LWpC_d_dT; - DisplacementDimMatrix dk_over_mu_L_dp_cap; }; /// Data that stores intermediate values (derivatives), which are not needed @@ -212,6 +206,7 @@ struct DerivativesData FW2DerivativeData dfW_2; FW3aDerivativeData dfW_3a; FW4LWpGDerivativeData dfW_4_LWpG; + FW4LWpCDerivativeData dfW_4_LWpC; }; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index 33c1eaf495e..3f0ee616b7b 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -97,6 +97,7 @@ struct ConstitutiveModels FW2Model fW_2_model; FW3aModel fW_3a_model; FW4LWpGModel fW_4_LWpG_model; + FW4LWpCModel fW_4_LWpC_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp index dc127ce8621..27495f7dbe0 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp @@ -254,5 +254,96 @@ void FW4LWpGModel::dEval( template struct FW4LWpGModel<2>; template struct FW4LWpGModel<3>; +template +void FW4LWpCModel::eval( + AdvectionData const& advection_data, + FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + FW4LWpCData& fW_4_LWpC) const +{ + double const sD_G = phase_transition_data.diffusion_coefficient_vapour; + double const sD_L = phase_transition_data.diffusion_coefficient_solute; + + double const phi_G = (1 - S_L_data.S_L) * porosity_data.phi; + double const phi_L = S_L_data.S_L * porosity_data.phi; + + double const diffusion_WGpCap = phi_G * fluid_density_data.rho_GR * sD_G * + phase_transition_data.dxmWG_dpCap; + double const diffusion_WLpCap = phi_L * fluid_density_data.rho_LR * sD_L * + phase_transition_data.dxmWL_dpCap; + + double const diffusion_W_pCap = diffusion_WGpCap + diffusion_WLpCap; + + auto const I = + Eigen::Matrix::Identity(); + + fW_4_LWpC.L.noalias() = diffusion_W_pCap * I - advection_data.advection_W_L; + + // Jac wrong? + // double const diffusion_W_L_p = phi_L * fluid_density_data.rho_LR * sD_L * + // phase_transition_data.dxmWL_dpLR; + // + // fW_4_LWpC.L.noalias() = diffusion_W_L_p * I + + // advection_data.advection_W_L; +} + +template +void FW4LWpCModel::dEval( + AdvectionData const& advection_data, + FluidDensityData const& fluid_density_data, + PermeabilityData const& permeability_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + PureLiquidDensityData const& rho_W_LR, + SaturationData const& S_L_data, + SaturationDataDeriv const& dS_L_dp_cap, + ViscosityData const& viscosity_data, + FW4LWpCDerivativeData& dfW_4_LWpC) const +{ + ////// Diffusion Part ///// + // TODO (naumov) d(diffusion_W_pCap)/dX for dxmW*/d* != 0 + + ////// Advection part ///// + GlobalDimMatrix const k_over_mu_L = + permeability_data.Ki * permeability_data.k_rel_L / viscosity_data.mu_LR; + + dfW_4_LWpC.dp_GR = phase_transition_data.drho_W_LR_dp_GR * k_over_mu_L + //+ rhoWLR * (dk_over_mu_L_dp_GR = 0) + ; + + double const sD_G = phase_transition_data.diffusion_coefficient_vapour; + double const sD_L = phase_transition_data.diffusion_coefficient_solute; + + double const phi_G = (1 - S_L_data.S_L) * porosity_data.phi; + double const phi_L = S_L_data.S_L * porosity_data.phi; + + double const diffusion_WGpCap = phi_G * fluid_density_data.rho_GR * sD_G * + phase_transition_data.dxmWG_dpCap; + double const diffusion_WLpCap = phi_L * fluid_density_data.rho_LR * sD_L * + phase_transition_data.dxmWL_dpCap; + + double const diffusion_W_pCap = diffusion_WGpCap + diffusion_WLpCap; + + auto const I = + Eigen::Matrix::Identity(); + + dfW_4_LWpC.dp_cap = diffusion_W_pCap * I - advection_data.advection_W_L; + + auto const dk_over_mu_L_dp_cap = permeability_data.Ki * + permeability_data.dk_rel_L_dS_L * + dS_L_dp_cap() / viscosity_data.mu_LR; + dfW_4_LWpC.dp_cap = -phase_transition_data.drho_W_LR_dp_LR * k_over_mu_L + + rho_W_LR() * dk_over_mu_L_dp_cap; + + dfW_4_LWpC.dT = phase_transition_data.drho_W_LR_dT * k_over_mu_L + //+ rhoWLR * (dk_over_mu_L_dT != 0 TODO for mu_L(T)) + ; +} + +template struct FW4LWpCModel<2>; +template struct FW4LWpCModel<3>; + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h index 8d88c9e7eff..206d3fedafe 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h @@ -149,5 +149,44 @@ struct FW4LWpGModel extern template struct FW4LWpGModel<2>; extern template struct FW4LWpGModel<3>; +template +struct FW4LWpCData +{ + GlobalDimMatrix L; +}; + +template +struct FW4LWpCDerivativeData +{ + GlobalDimMatrix dp_GR; + GlobalDimMatrix dp_cap; + GlobalDimMatrix dT; +}; + +template +struct FW4LWpCModel +{ + void eval(AdvectionData const& advection_data, + FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + FW4LWpCData& fW_4_LWpC) const; + + void dEval(AdvectionData const& advection_data, + FluidDensityData const& fluid_density_data, + PermeabilityData const& permeability_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + PureLiquidDensityData const& rho_W_LR, + SaturationData const& S_L_data, + SaturationDataDeriv const& dS_L_dp_cap, + ViscosityData const& viscosity_data, + FW4LWpCDerivativeData& dfW_4_LWpC) const; +}; + +extern template struct FW4LWpCModel<2>; +extern template struct FW4LWpCModel<3>; + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 934bf873412..394beeabb9b 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -380,6 +380,13 @@ TH2MLocalAssembler::Zero(); - ip_cv.dfW_4_LWpC_d_dp_cap = - Eigen::Matrix::Zero(); - ip_cv.dfW_4_LWpC_d_dT = - Eigen::Matrix::Zero(); } return {ip_constitutive_data, ip_constitutive_variables}; @@ -708,6 +692,17 @@ TH2MLocalAssembler; - DisplacementDimMatrix const diffusion_WGpCap = - phi_G * rhoGR * D_W_G * ip_cv.phase_transition_data.dxmWG_dpCap; - DisplacementDimMatrix const diffusion_WLpCap = - phi_L * rhoLR * D_W_L * ip_cv.phase_transition_data.dxmWL_dpCap; - DisplacementDimMatrix const diffusion_WGT = phi_G * rhoGR * D_W_G * ip_cv.phase_transition_data.dxmWG_dT; DisplacementDimMatrix const diffusion_WLT = phi_L * rhoLR * D_W_L * ip_cv.phase_transition_data.dxmWL_dT; - DisplacementDimMatrix const diffusion_W_pCap = - diffusion_WGpCap + diffusion_WLpCap; - DisplacementDimMatrix const diffusion_W_T = diffusion_WGT + diffusion_WLT; LWpG.noalias() += gradNpT * ip_cv.fW_4_LWpG.L * gradNp * w; - LWpC.noalias() += - gradNpT * (diffusion_W_pCap - ip_cv.advection_data.advection_W_L) * - gradNp * w; + LWpC.noalias() += gradNpT * ip_cv.fW_4_LWpC.L * gradNp * w; LWT.noalias() += gradNpT * (diffusion_W_T)*gradNp * w; @@ -1665,8 +1650,6 @@ void TH2MLocalAssembler(W_index, C_index).noalias() -= - gradNpT * (ip_cv.dfW_4_LWpC_a_dp_GR + ip_cv.dfW_4_LWpC_d_dp_GR) * - gradpCap * Np * w; + gradNpT * ip_dd.dfW_4_LWpC.dp_GR * gradpCap * Np * w; local_Jac.template block(W_index, W_index).noalias() -= - gradNpT * (ip_cv.dfW_4_LWpC_a_dp_cap + ip_cv.dfW_4_LWpC_d_dp_cap) * - gradpCap * Np * w; + gradNpT * ip_dd.dfW_4_LWpC.dp_cap * gradpCap * Np * w; local_Jac .template block(W_index, temperature_index) - .noalias() -= gradNpT * - (ip_cv.dfW_4_LWpC_a_dT + ip_cv.dfW_4_LWpC_d_dT) * - gradpCap * NT * w; + .noalias() -= gradNpT * ip_dd.dfW_4_LWpC.dT * gradpCap * NT * w; LWT.noalias() += gradNpT * (diffusion_W_T)*gradNp * w; From a1a0e9c75b4cfe3c769440b7ee3fe5646a0fc7b1 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Sun, 14 Apr 2024 13:11:23 +0200 Subject: [PATCH 23/45] [PL/TH2M] Extract LWT part of W4 equation data and model. Small optimization in diffusion_W_T evaluation; moved identity multiplication to the end. --- .../ConstitutiveRelations/ConstitutiveData.h | 1 + .../ConstitutiveModels.h | 1 + .../TH2M/ConstitutiveRelations/WEquation.cpp | 30 +++++++++++ .../TH2M/ConstitutiveRelations/WEquation.h | 16 ++++++ ProcessLib/TH2M/TH2MFEM-impl.h | 51 +++---------------- 5 files changed, 56 insertions(+), 43 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 3860d4374c6..78a648ac6c2 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -172,6 +172,7 @@ struct ConstitutiveTempData FW3aData fW_3a; FW4LWpGData fW_4_LWpG; FW4LWpCData fW_4_LWpC; + FW4LWTData fW_4_LWT; using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index 3f0ee616b7b..4acaa507183 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -98,6 +98,7 @@ struct ConstitutiveModels FW3aModel fW_3a_model; FW4LWpGModel fW_4_LWpG_model; FW4LWpCModel fW_4_LWpC_model; + FW4LWTModel fW_4_LWT_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp index 27495f7dbe0..44b2b7acdb0 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp @@ -345,5 +345,35 @@ void FW4LWpCModel::dEval( template struct FW4LWpCModel<2>; template struct FW4LWpCModel<3>; +template +void FW4LWTModel::eval( + FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + FW4LWTData& fW_4_LWT) const +{ + double const sD_G = phase_transition_data.diffusion_coefficient_vapour; + double const sD_L = phase_transition_data.diffusion_coefficient_solute; + + double const phi_G = (1 - S_L_data.S_L) * porosity_data.phi; + double const phi_L = S_L_data.S_L * porosity_data.phi; + + double const diffusion_W_G_T = phi_G * fluid_density_data.rho_GR * sD_G * + phase_transition_data.dxmWG_dT; + double const diffusion_W_L_T = phi_L * fluid_density_data.rho_LR * sD_L * + phase_transition_data.dxmWL_dT; + + double const diffusion_W_T = diffusion_W_G_T + diffusion_W_L_T; + + auto const I = + Eigen::Matrix::Identity(); + + fW_4_LWT.L.noalias() = diffusion_W_T * I; +} + +template struct FW4LWTModel<2>; +template struct FW4LWTModel<3>; + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h index 206d3fedafe..e4bccfd1705 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h @@ -188,5 +188,21 @@ struct FW4LWpCModel extern template struct FW4LWpCModel<2>; extern template struct FW4LWpCModel<3>; +template +struct FW4LWTData +{ + GlobalDimMatrix L; +}; + +template +struct FW4LWTModel +{ + void eval(FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + FW4LWTData& fW_4_LWT) const; +}; + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 394beeabb9b..944598803b6 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -387,6 +387,12 @@ TH2MLocalAssembler::Identity(); - - double const sD_G = - ip_cv.phase_transition_data.diffusion_coefficient_vapour; - double const sD_L = - ip_cv.phase_transition_data.diffusion_coefficient_solute; - - GlobalDimMatrixType const D_W_G = sD_G * I; - GlobalDimMatrixType const D_W_L = sD_L * I; - auto const s_L = current_state.S_L_data.S_L; auto const s_G = 1. - s_L; auto const s_L_dot = (s_L - prev_state.S_L_data->S_L) / dt; @@ -1169,22 +1164,11 @@ void TH2MLocalAssembler< MWu.noalias() += NpT * rho_W_FR * alpha_B * mT * Bu * w; - using DisplacementDimMatrix = - Eigen::Matrix; - - DisplacementDimMatrix const diffusion_WGT = - phi_G * rhoGR * D_W_G * ip_cv.phase_transition_data.dxmWG_dT; - DisplacementDimMatrix const diffusion_WLT = - phi_L * rhoLR * D_W_L * ip_cv.phase_transition_data.dxmWL_dT; - - DisplacementDimMatrix const diffusion_W_T = - diffusion_WGT + diffusion_WLT; - LWpG.noalias() += gradNpT * ip_cv.fW_4_LWpG.L * gradNp * w; LWpC.noalias() += gradNpT * ip_cv.fW_4_LWpC.L * gradNp * w; - LWT.noalias() += gradNpT * (diffusion_W_T)*gradNp * w; + LWT.noalias() += gradNpT * ip_cv.fW_4_LWT.L * gradNp * w; fW.noalias() += gradNpT * ip_cv.fW_1.A * b * w; @@ -1462,17 +1446,6 @@ void TH2MLocalAssembler::Identity(); - - double const sD_G = - ip_cv.phase_transition_data.diffusion_coefficient_vapour; - double const sD_L = - ip_cv.phase_transition_data.diffusion_coefficient_solute; - - GlobalDimMatrixType const D_W_G = sD_G * I; - GlobalDimMatrixType const D_W_L = sD_L * I; - auto& s_L = current_state.S_L_data.S_L; auto const s_G = 1. - s_L; auto const s_L_dot = (s_L - prev_state.S_L_data->S_L) / dt; @@ -1650,14 +1623,6 @@ void TH2MLocalAssembler Date: Sun, 14 Apr 2024 16:18:47 +0200 Subject: [PATCH 24/45] [PL/TH2M] Extract MWpG part of W4 equation --- .../ConstitutiveRelations/ConstitutiveData.h | 1 + .../ConstitutiveRelations/ConstitutiveModels.h | 1 + .../TH2M/ConstitutiveRelations/WEquation.cpp | 17 +++++++++++++++++ .../TH2M/ConstitutiveRelations/WEquation.h | 16 ++++++++++++++++ ProcessLib/TH2M/TH2MFEM-impl.h | 16 ++++++++++------ 5 files changed, 45 insertions(+), 6 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 78a648ac6c2..6c7a0cab1af 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -173,6 +173,7 @@ struct ConstitutiveTempData FW4LWpGData fW_4_LWpG; FW4LWpCData fW_4_LWpC; FW4LWTData fW_4_LWT; + FW4MWpGData fW_4_MWpG; using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index 4acaa507183..c5e975961a2 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -99,6 +99,7 @@ struct ConstitutiveModels FW4LWpGModel fW_4_LWpG_model; FW4LWpCModel fW_4_LWpC_model; FW4LWTModel fW_4_LWT_model; + FW4MWpGModel fW_4_MWpG_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp index 44b2b7acdb0..65056b82bf9 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp @@ -375,5 +375,22 @@ void FW4LWTModel::eval( template struct FW4LWTModel<2>; template struct FW4LWTModel<3>; +void FW4MWpGModel::eval(BiotData const& biot_data, + ConstituentDensityData const& constituent_density_data, + PorosityData const& porosity_data, + PureLiquidDensityData const& rho_W_LR, + SaturationData const& S_L_data, + SolidCompressibilityData const& beta_p_SR, + FW4MWpGData& fW_4_MWpG) const +{ + double const S_L = S_L_data.S_L; + double const S_G = 1. - S_L; + + double const rho_W_FR = + S_G * constituent_density_data.rho_W_GR + S_L * rho_W_LR(); + + fW_4_MWpG.m = rho_W_FR * (biot_data() - porosity_data.phi) * beta_p_SR(); +} + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h index e4bccfd1705..a574fda04c7 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h @@ -204,5 +204,21 @@ struct FW4LWTModel FW4LWTData& fW_4_LWT) const; }; +struct FW4MWpGData +{ + double m = nan; +}; + +struct FW4MWpGModel +{ + void eval(BiotData const& biot_data, + ConstituentDensityData const& constituent_density_data, + PorosityData const& porosity_data, + PureLiquidDensityData const& rho_W_LR, + SaturationData const& S_L_data, + SolidCompressibilityData const& beta_p_SR, + FW4MWpGData& fW_4_MWpG) const; +}; + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 944598803b6..fe608037f39 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -393,6 +393,14 @@ TH2MLocalAssembler Date: Sun, 14 Apr 2024 23:10:49 +0200 Subject: [PATCH 25/45] [PL/TH2M] Extract MWpC part of W4 equation --- .../ConstitutiveRelations/ConstitutiveData.h | 1 + .../ConstitutiveModels.h | 1 + .../TH2M/ConstitutiveRelations/WEquation.cpp | 24 +++++++++++++ .../TH2M/ConstitutiveRelations/WEquation.h | 19 ++++++++++ ProcessLib/TH2M/TH2MFEM-impl.h | 36 ++++++++----------- 5 files changed, 59 insertions(+), 22 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 6c7a0cab1af..7312f86bc8c 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -174,6 +174,7 @@ struct ConstitutiveTempData FW4LWpCData fW_4_LWpC; FW4LWTData fW_4_LWT; FW4MWpGData fW_4_MWpG; + FW4MWpCData fW_4_MWpC; using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index c5e975961a2..4c4eec3ad79 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -100,6 +100,7 @@ struct ConstitutiveModels FW4LWpCModel fW_4_LWpC_model; FW4LWTModel fW_4_LWT_model; FW4MWpGModel fW_4_MWpG_model; + FW4MWpCModel fW_4_MWpC_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp index 65056b82bf9..c269bad6fd8 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp @@ -392,5 +392,29 @@ void FW4MWpGModel::eval(BiotData const& biot_data, fW_4_MWpG.m = rho_W_FR * (biot_data() - porosity_data.phi) * beta_p_SR(); } +void FW4MWpCModel::eval(BiotData const& biot_data, + CapillaryPressureData const pCap, + ConstituentDensityData const& constituent_density_data, + PorosityData const& porosity_data, + PrevState const& S_L_data_prev, + PureLiquidDensityData const& rho_W_LR, + SaturationData const& S_L_data, + SolidCompressibilityData const& beta_p_SR, + FW4MWpCData& fW_4_MWpC) const +{ + auto const S_L = S_L_data.S_L; + auto const S_G = 1. - S_L; + double const rho_W_FR = + S_G * constituent_density_data.rho_W_GR + S_L * rho_W_LR(); + + fW_4_MWpC.m = + -rho_W_FR * (biot_data() - porosity_data.phi) * beta_p_SR() * S_L; + + fW_4_MWpC.ml = + (porosity_data.phi * (rho_W_LR() - constituent_density_data.rho_W_GR) - + rho_W_FR * pCap() * (biot_data() - porosity_data.phi) * beta_p_SR()) * + (S_L - S_L_data_prev->S_L); +} + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h index a574fda04c7..ac2644843b0 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h @@ -220,5 +220,24 @@ struct FW4MWpGModel FW4MWpGData& fW_4_MWpG) const; }; +struct FW4MWpCData +{ + double m = nan; + double ml = nan; +}; + +struct FW4MWpCModel +{ + void eval(BiotData const& biot_data, + CapillaryPressureData const pCap, + ConstituentDensityData const& constituent_density_data, + PorosityData const& porosity_data, + PrevState const& S_L_data_prev, + PureLiquidDensityData const& rho_W_LR, + SaturationData const& S_L_data, + SolidCompressibilityData const& beta_p_SR, + FW4MWpCData& fW_4_MWpC) const; +}; + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index fe608037f39..c4dc4dc316c 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -401,6 +401,16 @@ TH2MLocalAssemblerS_L) / dt; auto& alpha_B = ip_cv.biot_data(); - auto& beta_p_SR = ip_cv.beta_p_SR(); auto const& b = this->process_data_.specific_body_force; @@ -1146,22 +1155,14 @@ void TH2MLocalAssembler< // --------------------------------------------------------------------- MWpG.noalias() += NpT * ip_cv.fW_4_MWpG.m * Np * w; - MWpC.noalias() -= NpT * rho_W_FR * - (alpha_B - ip_out.porosity_data.phi) * beta_p_SR * - s_L * Np * w; + MWpC.noalias() += NpT * ip_cv.fW_4_MWpC.m * Np * w; if (this->process_data_.apply_mass_lumping) { if (pCap - pCap_prev != 0.) // avoid division by Zero { MWpC.noalias() += - NpT * - (ip_out.porosity_data.phi * - (current_state.rho_W_LR() - - current_state.constituent_density_data.rho_W_GR) - - rho_W_FR * pCap * (alpha_B - ip_out.porosity_data.phi) * - beta_p_SR) * - s_L_dot * dt / (pCap - pCap_prev) * Np * w; + NpT * ip_cv.fW_4_MWpC.ml / (pCap - pCap_prev) * Np * w; } } @@ -1457,7 +1458,6 @@ void TH2MLocalAssemblerS_L) / dt; auto const alpha_B = ip_cv.biot_data(); - auto const beta_p_SR = ip_cv.beta_p_SR(); auto const& b = this->process_data_.specific_body_force; @@ -1603,22 +1603,14 @@ void TH2MLocalAssemblerprocess_data_.apply_mass_lumping) { if (pCap - pCap_prev != 0.) // avoid division by Zero { MWpC.noalias() += - NpT * - (ip_out.porosity_data.phi * - (current_state.rho_W_LR() - - current_state.constituent_density_data.rho_W_GR) - - rho_W_FR * pCap * (alpha_B - ip_out.porosity_data.phi) * - beta_p_SR) * - s_L_dot * dt / (pCap - pCap_prev) * Np * w; + NpT * ip_cv.fW_4_MWpC.ml / (pCap - pCap_prev) * Np * w; } } From 0ff7aa0cd60e72843dc7d0cf5c8e1a675a259e96 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Mon, 15 Apr 2024 14:19:43 +0200 Subject: [PATCH 26/45] [PL/TH2M] Extract MWT part of W4 equation --- .../ConstitutiveRelations/ConstitutiveData.h | 1 + .../ConstitutiveModels.h | 1 + .../TH2M/ConstitutiveRelations/WEquation.cpp | 22 +++++++++++++++++++ .../TH2M/ConstitutiveRelations/WEquation.h | 21 ++++++++++++++++++ ProcessLib/TH2M/TH2MFEM-impl.h | 17 ++++++++------ 5 files changed, 55 insertions(+), 7 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 7312f86bc8c..582d8f8215b 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -175,6 +175,7 @@ struct ConstitutiveTempData FW4LWTData fW_4_LWT; FW4MWpGData fW_4_MWpG; FW4MWpCData fW_4_MWpC; + FW4MWTData fW_4_MWT; using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index 4c4eec3ad79..01b100cbe32 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -101,6 +101,7 @@ struct ConstitutiveModels FW4LWTModel fW_4_LWT_model; FW4MWpGModel fW_4_MWpG_model; FW4MWpCModel fW_4_MWpC_model; + FW4MWTModel fW_4_MWT_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp index c269bad6fd8..721c36ad78d 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp @@ -416,5 +416,27 @@ void FW4MWpCModel::eval(BiotData const& biot_data, (S_L - S_L_data_prev->S_L); } +template +void FW4MWTModel::eval( + BiotData const& biot_data, + ConstituentDensityData const& constituent_density_data, + PorosityData const& porosity_data, + PureLiquidDensityData const& rho_W_LR, + SaturationData const& S_L_data, + SolidThermalExpansionData const& s_therm_exp_data, + FW4MWTData& fW_4_MWT) const +{ + auto const S_L = S_L_data.S_L; + auto const S_G = 1. - S_L; + double const rho_W_FR = + S_G * constituent_density_data.rho_W_GR + S_L * rho_W_LR(); + + fW_4_MWT.m = -rho_W_FR * (biot_data() - porosity_data.phi) * + s_therm_exp_data.beta_T_SR; +} + +template struct FW4MWTModel<2>; +template struct FW4MWTModel<3>; + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h index ac2644843b0..e2f99341be5 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h @@ -239,5 +239,26 @@ struct FW4MWpCModel FW4MWpCData& fW_4_MWpC) const; }; +struct FW4MWTData +{ + double m = nan; +}; + +template +struct FW4MWTModel +{ + void eval( + BiotData const& biot_data, + ConstituentDensityData const& constituent_density_data, + PorosityData const& porosity_data, + PureLiquidDensityData const& rho_W_LR, + SaturationData const& S_L_data, + SolidThermalExpansionData const& s_therm_exp_data, + FW4MWTData& fW_4_MWT) const; +}; + +extern template struct FW4MWTModel<2>; +extern template struct FW4MWTModel<3>; + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index c4dc4dc316c..df7288e7eeb 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -411,6 +411,14 @@ TH2MLocalAssemblerS_L) / dt; @@ -1166,8 +1172,7 @@ void TH2MLocalAssembler< } } - MWT.noalias() -= NpT * rho_W_FR * (alpha_B - ip_out.porosity_data.phi) * - beta_T_SR * Np * w; + MWT.noalias() += NpT * ip_cv.fW_4_MWT.m * Np * w; MWu.noalias() += NpT * rho_W_FR * alpha_B * mT * Bu * w; @@ -1451,7 +1456,6 @@ void TH2MLocalAssembler Date: Mon, 15 Apr 2024 14:49:35 +0200 Subject: [PATCH 27/45] [PL/TH2M] Extract MWu part of W4 equation --- .../ConstitutiveRelations/ConstitutiveData.h | 1 + .../ConstitutiveModels.h | 1 + .../TH2M/ConstitutiveRelations/WEquation.cpp | 14 +++++++++++++ .../TH2M/ConstitutiveRelations/WEquation.h | 13 ++++++++++++ ProcessLib/TH2M/TH2MFEM-impl.h | 20 ++++++++----------- 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 582d8f8215b..bf724bd08b0 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -176,6 +176,7 @@ struct ConstitutiveTempData FW4MWpGData fW_4_MWpG; FW4MWpCData fW_4_MWpC; FW4MWTData fW_4_MWT; + FW4MWuData fW_4_MWu; using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index 01b100cbe32..c8868c12bf5 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -102,6 +102,7 @@ struct ConstitutiveModels FW4MWpGModel fW_4_MWpG_model; FW4MWpCModel fW_4_MWpC_model; FW4MWTModel fW_4_MWT_model; + FW4MWuModel fW_4_MWu_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp index 721c36ad78d..8f8d2121976 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp @@ -438,5 +438,19 @@ void FW4MWTModel::eval( template struct FW4MWTModel<2>; template struct FW4MWTModel<3>; +void FW4MWuModel::eval(BiotData const& biot_data, + ConstituentDensityData const& constituent_density_data, + PureLiquidDensityData const& rho_W_LR, + SaturationData const& S_L_data, + FW4MWuData& fW_4_MWu) const +{ + auto const S_L = S_L_data.S_L; + auto const S_G = 1. - S_L; + double const rho_W_FR = + S_G * constituent_density_data.rho_W_GR + S_L * rho_W_LR(); + + fW_4_MWu.m = rho_W_FR * biot_data(); +} + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h index e2f99341be5..09f1b09fc44 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.h @@ -260,5 +260,18 @@ struct FW4MWTModel extern template struct FW4MWTModel<2>; extern template struct FW4MWTModel<3>; +struct FW4MWuData +{ + double m = nan; +}; + +struct FW4MWuModel +{ + void eval(BiotData const& biot_data, + ConstituentDensityData const& constituent_density_data, + PureLiquidDensityData const& rho_W_LR, + SaturationData const& S_L_data, + FW4MWuData& fW_4_MWu) const; +}; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index df7288e7eeb..f3f3d45bdba 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -419,6 +419,12 @@ TH2MLocalAssembler Date: Mon, 15 Apr 2024 15:12:45 +0200 Subject: [PATCH 28/45] [PL/TH2M] Extract T1 equation --- .../ConstitutiveRelations/ConstitutiveData.h | 4 ++ .../ConstitutiveModels.h | 3 + .../TH2M/ConstitutiveRelations/TEquation.cpp | 56 +++++++++++++++++++ .../TH2M/ConstitutiveRelations/TEquation.h | 45 +++++++++++++++ ProcessLib/TH2M/TH2MFEM-impl.h | 33 +++++------ 5 files changed, 121 insertions(+), 20 deletions(-) create mode 100644 ProcessLib/TH2M/ConstitutiveRelations/TEquation.cpp create mode 100644 ProcessLib/TH2M/ConstitutiveRelations/TEquation.h diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index bf724bd08b0..f3c7cb0f037 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -37,6 +37,7 @@ #include "SolidMechanics.h" #include "SolidThermalExpansion.h" #include "Swelling.h" +#include "TEquation.h" #include "ThermalConductivity.h" #include "TotalStress.h" #include "VapourPartialPressure.h" @@ -178,6 +179,8 @@ struct ConstitutiveTempData FW4MWTData fW_4_MWT; FW4MWuData fW_4_MWu; + FT1Data fT_1; + using DisplacementDimVector = Eigen::Matrix; using DisplacementDimMatrix = Eigen::Matrix; @@ -212,6 +215,7 @@ struct DerivativesData FW3aDerivativeData dfW_3a; FW4LWpGDerivativeData dfW_4_LWpG; FW4LWpCDerivativeData dfW_4_LWpC; + FT1DerivativeData dfT_1; }; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index c8868c12bf5..f16ef551363 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -28,6 +28,7 @@ #include "SolidMechanics.h" #include "SolidThermalExpansion.h" #include "Swelling.h" +#include "TEquation.h" #include "ThermalConductivity.h" #include "TotalStress.h" #include "Viscosity.h" @@ -103,6 +104,8 @@ struct ConstitutiveModels FW4MWpCModel fW_4_MWpC_model; FW4MWTModel fW_4_MWT_model; FW4MWuModel fW_4_MWu_model; + + FT1Model fT_1_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/TEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/TEquation.cpp new file mode 100644 index 00000000000..905576dc5cc --- /dev/null +++ b/ProcessLib/TH2M/ConstitutiveRelations/TEquation.cpp @@ -0,0 +1,56 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#include "TEquation.h" + +namespace ProcessLib::TH2M +{ +namespace ConstitutiveRelations +{ +void FT1Model::eval( + double const dt, + InternalEnergyData const& internal_energy_data, + PrevState const& internal_energy_data_prev, + FT1Data& fT_1) const +{ + if (dt == 0) + { + fT_1.m = 0; + return; + } + + auto const rho_u_eff_dot = + (internal_energy_data() - **internal_energy_data_prev) / dt; + fT_1.m = rho_u_eff_dot; +} + +void FT1Model::dEval(double const dt, + EffectiveVolumetricInternalEnergyDerivatives const& + effective_volumetric_internal_energy_d_data, + FT1DerivativeData& dfT_1) const +{ + if (dt == 0) + { + dfT_1.dp_GR = 0; + dfT_1.dp_cap = 0; + dfT_1.dT = 0; + return; + } + + dfT_1.dp_GR = + effective_volumetric_internal_energy_d_data.drho_u_eff_dp_GR / dt; + + dfT_1.dp_cap = + effective_volumetric_internal_energy_d_data.drho_u_eff_dp_cap / dt; + + dfT_1.dT = effective_volumetric_internal_energy_d_data.drho_u_eff_dT / dt; +} + +} // namespace ConstitutiveRelations +} // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/TEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/TEquation.h new file mode 100644 index 00000000000..4c3bf969ed3 --- /dev/null +++ b/ProcessLib/TH2M/ConstitutiveRelations/TEquation.h @@ -0,0 +1,45 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#pragma once + +#include "Base.h" +#include "InternalEnergy.h" + +namespace ProcessLib::TH2M +{ +namespace ConstitutiveRelations +{ +struct FT1Data +{ + double m = nan; +}; + +struct FT1DerivativeData +{ + double dp_GR = nan; + double dp_cap = nan; + double dT = nan; +}; + +struct FT1Model +{ + void eval(double const dt, + InternalEnergyData const& internal_energy_data, + PrevState const& internal_energy_data_prev, + FT1Data& fT_1) const; + + void dEval(double const dt, + EffectiveVolumetricInternalEnergyDerivatives const& + effective_volumetric_internal_energy_d_data, + FT1DerivativeData& dfT_1) const; +}; + +} // namespace ConstitutiveRelations +} // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index f3f3d45bdba..2f3b0988490 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -425,6 +425,11 @@ TH2MLocalAssembler(temperature_index, C_index) - .noalias() += NpT * Np * - (ip_dd.effective_volumetric_internal_energy_d_data - .drho_u_eff_dp_GR / - dt * w); + .noalias() += NpT * Np * (ip_dd.dfT_1.dp_GR * w); // dfT_1/dp_cap local_Jac .template block(temperature_index, W_index) - .noalias() += NpT * Np * - (ip_dd.effective_volumetric_internal_energy_d_data - .drho_u_eff_dp_cap / - dt * w); + .noalias() += NpT * Np * (ip_dd.dfT_1.dp_cap * w); // dfT_1/dT // MTT local_Jac .template block( temperature_index, temperature_index) - .noalias() += - NTT * NT * - (ip_dd.effective_volumetric_internal_energy_d_data.drho_u_eff_dT / - dt * w); + .noalias() += NTT * NT * (ip_dd.dfT_1.dT * w); // fT_2 fT.noalias() += gradNTT * From 248159afd733a45f0edf85adc1a03a57436f4488 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Tue, 16 Apr 2024 14:09:35 +0200 Subject: [PATCH 29/45] [PL/TH2M] Strong type for specific body force --- ProcessLib/TH2M/ConstitutiveRelations/Base.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/Base.h b/ProcessLib/TH2M/ConstitutiveRelations/Base.h index 0667e3730d9..8739cfbab38 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/Base.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/Base.h @@ -60,5 +60,10 @@ using GasPressureData = BaseLib::StrongType; using CapillaryPressureData = BaseLib::StrongType; +template +using SpecificBodyForceData = + BaseLib::StrongType, + struct SpecificBodyForceTag>; + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M From 1531007e4948f61d734e94ac9656d5d514ef2e0d Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Mon, 15 Apr 2024 17:01:58 +0200 Subject: [PATCH 30/45] [PL/TH2M] Extract T2 equation --- .../ConstitutiveRelations/ConstitutiveData.h | 12 +-- .../ConstitutiveModels.h | 1 + .../TH2M/ConstitutiveRelations/TEquation.cpp | 66 ++++++++++++++++ .../TH2M/ConstitutiveRelations/TEquation.h | 42 ++++++++++ ProcessLib/TH2M/TH2MFEM-impl.h | 77 ++++++------------- 5 files changed, 133 insertions(+), 65 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index f3c7cb0f037..79370d92e4f 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -180,16 +180,7 @@ struct ConstitutiveTempData FW4MWuData fW_4_MWu; FT1Data fT_1; - - using DisplacementDimVector = Eigen::Matrix; - using DisplacementDimMatrix = - Eigen::Matrix; - - DisplacementDimVector drho_GR_h_w_eff_dp_GR_Npart; - DisplacementDimMatrix drho_GR_h_w_eff_dp_GR_gradNpart; - DisplacementDimVector drho_LR_h_w_eff_dp_cap_Npart; - DisplacementDimMatrix drho_LR_h_w_eff_dp_cap_gradNpart; - DisplacementDimVector drho_GR_h_w_eff_dT; + FT2Data fT_2; }; /// Data that stores intermediate values (derivatives), which are not needed @@ -216,6 +207,7 @@ struct DerivativesData FW4LWpGDerivativeData dfW_4_LWpG; FW4LWpCDerivativeData dfW_4_LWpC; FT1DerivativeData dfT_1; + FT2DerivativeData dfT_2; }; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index f16ef551363..6c26076eca8 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -106,6 +106,7 @@ struct ConstitutiveModels FW4MWuModel fW_4_MWu_model; FT1Model fT_1_model; + FT2Model fT_2_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/TEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/TEquation.cpp index 905576dc5cc..8f4eb2cce43 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/TEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/TEquation.cpp @@ -52,5 +52,71 @@ void FT1Model::dEval(double const dt, dfT_1.dT = effective_volumetric_internal_energy_d_data.drho_u_eff_dT / dt; } +template +void FT2Model::eval( + DarcyVelocityData const& darcy_velocity_data, + EnthalpyData const& enthalpy_data, + FluidDensityData const& fluid_density_data, + FT2Data& fT_2) const +{ + fT_2.A.noalias() = fluid_density_data.rho_GR * enthalpy_data.h_G * + darcy_velocity_data.w_GS + + fluid_density_data.rho_LR * enthalpy_data.h_L * + darcy_velocity_data.w_LS; +} + +template +void FT2Model::dEval( + DarcyVelocityData const& darcy_velocity_data, + EnthalpyData const& enthalpy_data, + FluidDensityData const& fluid_density_data, + PermeabilityData const& permeability_data, + PhaseTransitionData const& phase_transition_data, + SpecificBodyForceData const& specific_body_force, + ViscosityData const& viscosity_data, + FT2DerivativeData& dfT_2) const +{ + auto const k_over_mu_G = + permeability_data.Ki * permeability_data.k_rel_G / viscosity_data.mu_GR; + auto const k_over_mu_L = + permeability_data.Ki * permeability_data.k_rel_L / viscosity_data.mu_LR; + + dfT_2.dp_GR_Npart = phase_transition_data.drho_GR_dp_GR * + enthalpy_data.h_G * darcy_velocity_data.w_GS + + fluid_density_data.rho_GR * enthalpy_data.h_G * + k_over_mu_G * phase_transition_data.drho_GR_dp_GR * + specific_body_force(); + dfT_2.dp_GR_gradNpart = + fluid_density_data.rho_GR * enthalpy_data.h_G * k_over_mu_G - + fluid_density_data.rho_LR * enthalpy_data.h_L * k_over_mu_L; + + // From p_LR = p_GR - p_cap it follows for + // drho_LR/dp_GR = drho_LR/dp_LR * dp_LR/dp_GR + // = drho_LR/dp_LR * (dp_GR/dp_GR - dp_cap/dp_GR) + // = drho_LR/dp_LR * (1 - 0) + double const drho_LR_dp_cap = -phase_transition_data.drho_LR_dp_LR; + + dfT_2.dp_cap_Npart = + -drho_LR_dp_cap * enthalpy_data.h_L * darcy_velocity_data.w_LS - + fluid_density_data.rho_LR * enthalpy_data.h_L * k_over_mu_L * + drho_LR_dp_cap * specific_body_force(); + dfT_2.dp_cap_gradNpart = + fluid_density_data.rho_LR * enthalpy_data.h_L * k_over_mu_L; + + dfT_2.dT = phase_transition_data.drho_GR_dT * enthalpy_data.h_G * + darcy_velocity_data.w_GS + + fluid_density_data.rho_GR * phase_transition_data.dh_G_dT * + darcy_velocity_data.w_GS + + phase_transition_data.drho_LR_dT * enthalpy_data.h_L * + darcy_velocity_data.w_LS + + fluid_density_data.rho_LR * phase_transition_data.dh_L_dT * + darcy_velocity_data.w_LS; + // TODO (naumov) + k_over_mu_G * drho_GR_dT * b + k_over_mu_L * + // drho_LR_dT * b +} + +template struct FT2Model<2>; +template struct FT2Model<3>; + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/TEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/TEquation.h index 4c3bf969ed3..71894c6cc54 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/TEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/TEquation.h @@ -10,7 +10,12 @@ #pragma once #include "Base.h" +#include "DarcyVelocity.h" +#include "Enthalpy.h" +#include "FluidDensity.h" #include "InternalEnergy.h" +#include "PermeabilityData.h" +#include "Viscosity.h" namespace ProcessLib::TH2M { @@ -41,5 +46,42 @@ struct FT1Model FT1DerivativeData& dfT_1) const; }; +template +struct FT2Data +{ + GlobalDimVector A; +}; + +template +struct FT2DerivativeData +{ + GlobalDimVector dp_GR_Npart; + GlobalDimMatrix dp_GR_gradNpart; + GlobalDimVector dp_cap_Npart; + GlobalDimMatrix dp_cap_gradNpart; + GlobalDimVector dT; +}; + +template +struct FT2Model +{ + void eval(DarcyVelocityData const& darcy_velocity_data, + EnthalpyData const& enthalpy_data, + FluidDensityData const& fluid_density_data, + FT2Data& fT_2) const; + + void dEval( + DarcyVelocityData const& darcy_velocity_data, + EnthalpyData const& enthalpy_data, + FluidDensityData const& fluid_density_data, + PermeabilityData const& permeability_data, + PhaseTransitionData const& phase_transition_data, + SpecificBodyForceData const& specific_body_force, + ViscosityData const& viscosity_data, + FT2DerivativeData& dfT_2) const; +}; + +extern template struct FT2Model<2>; +extern template struct FT2Model<3>; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 2f3b0988490..d5d5683faf5 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -494,44 +494,10 @@ TH2MLocalAssembler{ + this->process_data_.specific_body_force}, + ip_cv.viscosity_data, + ip_dd.dfT_2); } return ip_d_data; @@ -1213,12 +1190,7 @@ void TH2MLocalAssembler< fT.noalias() -= NTT * ip_cv.fT_1.m * w; - fT.noalias() += gradNTT * - (rhoGR * ip_out.enthalpy_data.h_G * - ip_out.darcy_velocity_data.w_GS + - rhoLR * ip_out.enthalpy_data.h_L * - ip_out.darcy_velocity_data.w_LS) * - w; + fT.noalias() += gradNTT * ip_cv.fT_2.A * w; fT.noalias() += gradNTT * (current_state.constituent_density_data.rho_C_GR * @@ -1787,12 +1759,7 @@ void TH2MLocalAssembler( temperature_index, temperature_index) - .noalias() -= gradNTT * ip_cv.drho_GR_h_w_eff_dT * NT * w; + .noalias() -= gradNTT * ip_dd.dfT_2.dT * NT * w; // fT_3 fT.noalias() += NTT * From f04f74c291a7503e229083ff441e061e20d65ee3 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Tue, 16 Apr 2024 17:17:20 +0200 Subject: [PATCH 31/45] [PL/TH2M] Extract T3 equation --- .../ConstitutiveRelations/ConstitutiveData.h | 1 + .../ConstitutiveModels.h | 1 + .../TH2M/ConstitutiveRelations/TEquation.cpp | 25 ++++++++++++ .../TH2M/ConstitutiveRelations/TEquation.h | 25 ++++++++++++ ProcessLib/TH2M/TH2MFEM-impl.h | 40 +++++++------------ 5 files changed, 67 insertions(+), 25 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 79370d92e4f..3171263e249 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -181,6 +181,7 @@ struct ConstitutiveTempData FT1Data fT_1; FT2Data fT_2; + FT3Data fT_3; }; /// Data that stores intermediate values (derivatives), which are not needed diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index 6c26076eca8..1fb329654da 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -107,6 +107,7 @@ struct ConstitutiveModels FT1Model fT_1_model; FT2Model fT_2_model; + FT3Model fT_3_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/TEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/TEquation.cpp index 8f4eb2cce43..25782dc1d8f 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/TEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/TEquation.cpp @@ -118,5 +118,30 @@ void FT2Model::dEval( template struct FT2Model<2>; template struct FT2Model<3>; +template +void FT3Model::eval( + ConstituentDensityData const& constituent_density_data, + DarcyVelocityData const& darcy_velocity_data, + DiffusionVelocityData const& diffusion_velocity_data, + FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + SpecificBodyForceData const& specific_body_force, + FT3Data& fT_3) const +{ + fT_3.N = + (fluid_density_data.rho_GR * darcy_velocity_data.w_GS.transpose() + + fluid_density_data.rho_LR * darcy_velocity_data.w_LS.transpose()) * + specific_body_force(); + + fT_3.gradN.noalias() = + constituent_density_data.rho_C_GR * phase_transition_data.hCG * + diffusion_velocity_data.d_CG + + constituent_density_data.rho_W_GR * phase_transition_data.hWG * + diffusion_velocity_data.d_WG; +} + +template struct FT3Model<2>; +template struct FT3Model<3>; + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/TEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/TEquation.h index 71894c6cc54..b638a754a22 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/TEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/TEquation.h @@ -10,7 +10,9 @@ #pragma once #include "Base.h" +#include "ConstitutiveDensity.h" #include "DarcyVelocity.h" +#include "DiffusionVelocity.h" #include "Enthalpy.h" #include "FluidDensity.h" #include "InternalEnergy.h" @@ -83,5 +85,28 @@ struct FT2Model extern template struct FT2Model<2>; extern template struct FT2Model<3>; + +template +struct FT3Data +{ + double N = nan; + GlobalDimVector gradN; +}; + +template +struct FT3Model +{ + void eval( + ConstituentDensityData const& constituent_density_data, + DarcyVelocityData const& darcy_velocity_data, + DiffusionVelocityData const& diffusion_velocity_data, + FluidDensityData const& fluid_density_data, + PhaseTransitionData const& phase_transition_data, + SpecificBodyForceData const& specific_body_force, + FT3Data& fT_3) const; +}; + +extern template struct FT3Model<2>; +extern template struct FT3Model<3>; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index d5d5683faf5..42610ef3881 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -498,6 +498,16 @@ TH2MLocalAssembler{ + this->process_data_.specific_body_force}, + ip_cv.fT_3); } return {ip_constitutive_data, ip_constitutive_variables}; @@ -1192,19 +1202,9 @@ void TH2MLocalAssembler< fT.noalias() += gradNTT * ip_cv.fT_2.A * w; - fT.noalias() += gradNTT * - (current_state.constituent_density_data.rho_C_GR * - ip_cv.phase_transition_data.hCG * - ip_out.diffusion_velocity_data.d_CG + - current_state.constituent_density_data.rho_W_GR * - ip_cv.phase_transition_data.hWG * - ip_out.diffusion_velocity_data.d_WG) * - w; + fT.noalias() += gradNTT * ip_cv.fT_3.gradN * w; - fT.noalias() += NTT * - (rhoGR * ip_out.darcy_velocity_data.w_GS.transpose() + - rhoLR * ip_out.darcy_velocity_data.w_LS.transpose()) * - b * w; + fT.noalias() += NTT * ip_cv.fT_3.N * w; // --------------------------------------------------------------------- // - displacement equation @@ -1788,19 +1788,9 @@ void TH2MLocalAssembler Date: Tue, 16 Apr 2024 18:57:38 +0200 Subject: [PATCH 32/45] [PL/TH2M] Extract gravity model computes volumetric body force. --- .../ConstitutiveRelations/ConstitutiveData.h | 2 + .../ConstitutiveModels.h | 2 + .../TH2M/ConstitutiveRelations/Gravity.cpp | 39 ++++++++++++++ .../TH2M/ConstitutiveRelations/Gravity.h | 42 +++++++++++++++ ProcessLib/TH2M/TH2MFEM-impl.h | 51 +++++++------------ 5 files changed, 103 insertions(+), 33 deletions(-) create mode 100644 ProcessLib/TH2M/ConstitutiveRelations/Gravity.cpp create mode 100644 ProcessLib/TH2M/ConstitutiveRelations/Gravity.h diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 3171263e249..68ebf146b5a 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -20,6 +20,7 @@ #include "Enthalpy.h" #include "EquivalentPlasticStrainData.h" #include "FluidDensity.h" +#include "Gravity.h" #include "InternalEnergy.h" #include "MassMoleFractions.h" #include "MechanicalStrain.h" @@ -157,6 +158,7 @@ struct ConstitutiveTempData ThermalConductivityData thermal_conductivity_data; EffectiveVolumetricEnthalpy effective_volumetric_enthalpy_data; AdvectionData advection_data; + VolumetricBodyForce volumetric_body_force; FC1Data fC_1; FC2aData fC_2a; FC3aData fC_3a; diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index 1fb329654da..df7bee1cd8a 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -15,6 +15,7 @@ #include "CEquation.h" #include "ElasticTangentStiffnessModel.h" #include "Enthalpy.h" +#include "Gravity.h" #include "InternalEnergy.h" #include "MechanicalStrain.h" #include "PermeabilityModel.h" @@ -83,6 +84,7 @@ struct ConstitutiveModels AdvectionModel advection_model; InternalEnergyModel internal_energy_model; EffectiveVolumetricEnthalpyModel effective_volumetric_enthalpy_model; + GravityModel gravity_model; FC1Model fC_1_model; FC2aModel fC_2a_model; FC3aModel fC_3a_model; diff --git a/ProcessLib/TH2M/ConstitutiveRelations/Gravity.cpp b/ProcessLib/TH2M/ConstitutiveRelations/Gravity.cpp new file mode 100644 index 00000000000..8a4e994a876 --- /dev/null +++ b/ProcessLib/TH2M/ConstitutiveRelations/Gravity.cpp @@ -0,0 +1,39 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#include "Gravity.h" + +namespace ProcessLib::TH2M +{ +namespace ConstitutiveRelations +{ +template +void GravityModel::eval( + FluidDensityData const& fluid_density_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + SolidDensityData const& solid_density_data, + SpecificBodyForceData const& specific_body_force, + VolumetricBodyForce& volumetric_body_force) const +{ + auto const phi_G = (1. - S_L_data.S_L) * porosity_data.phi; + auto const phi_L = S_L_data.S_L * porosity_data.phi; + auto const phi_S = 1. - porosity_data.phi; + + auto const rhoGR = fluid_density_data.rho_GR; + auto const rhoLR = fluid_density_data.rho_LR; + auto const rho = + phi_G * rhoGR + phi_L * rhoLR + phi_S * solid_density_data.rho_SR; + *volumetric_body_force = rho * specific_body_force(); +} + +template struct GravityModel<2>; +template struct GravityModel<3>; +} // namespace ConstitutiveRelations +} // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/Gravity.h b/ProcessLib/TH2M/ConstitutiveRelations/Gravity.h new file mode 100644 index 00000000000..dc1aac245e6 --- /dev/null +++ b/ProcessLib/TH2M/ConstitutiveRelations/Gravity.h @@ -0,0 +1,42 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#pragma once + +#include "Base.h" +#include "FluidDensity.h" +#include "Porosity.h" +#include "Saturation.h" +#include "SolidDensity.h" + +namespace ProcessLib::TH2M +{ +namespace ConstitutiveRelations +{ +template +using VolumetricBodyForce = + BaseLib::StrongType, + struct VolumetricBodyForceTag>; + +template +struct GravityModel +{ + void eval( + FluidDensityData const& fluid_density_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + SolidDensityData const& solid_density_data, + SpecificBodyForceData const& specific_body_force, + VolumetricBodyForce& volumetric_body_force) const; +}; + +extern template struct GravityModel<2>; +extern template struct GravityModel<3>; +} // namespace ConstitutiveRelations +} // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 42610ef3881..cc118746435 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -259,6 +259,15 @@ TH2MLocalAssembler{ + this->process_data_.specific_body_force}, + ip_cv.volumetric_body_force); + auto const& c = ip_cv.phase_transition_data; auto const phi_L = @@ -1099,25 +1108,12 @@ void TH2MLocalAssembler< double const pCap_prev = Np.dot(capillary_pressure_prev); auto const s_L = current_state.S_L_data.S_L; - auto const s_G = 1. - s_L; auto const s_L_dot = (s_L - prev_state.S_L_data->S_L) / dt; auto& alpha_B = ip_cv.biot_data(); auto const& b = this->process_data_.specific_body_force; - // volume fraction - auto const phi_G = s_G * ip_out.porosity_data.phi; - auto const phi_L = s_L * ip_out.porosity_data.phi; - auto const phi_S = 1. - ip_out.porosity_data.phi; - - auto const rhoGR = ip_out.fluid_density_data.rho_GR; - auto const rhoLR = ip_out.fluid_density_data.rho_LR; - - // effective density - auto const rho = phi_G * rhoGR + phi_L * rhoLR + - phi_S * ip_out.solid_density_data.rho_SR; - // --------------------------------------------------------------------- // C-component equation // --------------------------------------------------------------------- @@ -1214,9 +1210,10 @@ void TH2MLocalAssembler< KUpC.noalias() += (BuT * alpha_B * ip_cv.chi_S_L.chi_S_L * m * Np) * w; - fU.noalias() -= (BuT * current_state.eff_stress_data.sigma - - N_u_op(Nu).transpose() * rho * b) * - w; + fU.noalias() -= + (BuT * current_state.eff_stress_data.sigma - + N_u_op(Nu).transpose() * ip_cv.volumetric_body_force()) * + w; if (this->process_data_.apply_mass_lumping) { @@ -1435,26 +1432,13 @@ void TH2MLocalAssemblerS_L) / dt; auto const alpha_B = ip_cv.biot_data(); auto const& b = this->process_data_.specific_body_force; - // volume fraction - auto const phi_G = s_G * ip_out.porosity_data.phi; - auto const phi_L = s_L * ip_out.porosity_data.phi; - auto const phi_S = 1. - ip_out.porosity_data.phi; - - auto const rhoGR = ip_out.fluid_density_data.rho_GR; - auto const rhoLR = ip_out.fluid_density_data.rho_LR; - - // effective density - auto const rho = phi_G * rhoGR + phi_L * rhoLR + - phi_S * ip_out.solid_density_data.rho_SR; - // --------------------------------------------------------------------- // C-component equation // --------------------------------------------------------------------- @@ -1817,9 +1801,10 @@ void TH2MLocalAssembler Date: Tue, 16 Apr 2024 19:31:46 +0200 Subject: [PATCH 33/45] [PL/TH2M] Extract darcy velocity model --- ProcessLib/TH2M/ConstitutiveRelations/Base.h | 8 ++++ .../ConstitutiveModels.h | 1 + .../ConstitutiveRelations/DarcyVelocity.cpp | 43 +++++++++++++++++++ .../ConstitutiveRelations/DarcyVelocity.h | 18 ++++++++ ProcessLib/TH2M/TH2MFEM-impl.h | 28 ++++++------ 5 files changed, 83 insertions(+), 15 deletions(-) create mode 100644 ProcessLib/TH2M/ConstitutiveRelations/DarcyVelocity.cpp diff --git a/ProcessLib/TH2M/ConstitutiveRelations/Base.h b/ProcessLib/TH2M/ConstitutiveRelations/Base.h index 8739cfbab38..e5ec55f00b4 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/Base.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/Base.h @@ -59,6 +59,14 @@ using ReferenceTemperatureData = using GasPressureData = BaseLib::StrongType; using CapillaryPressureData = BaseLib::StrongType; +template +using GasPressureGradientData = + BaseLib::StrongType, + struct GasPressureGradientTag>; +template +using CapillaryPressureGradientData = + BaseLib::StrongType, + struct CapillaryPressureGradientTag>; template using SpecificBodyForceData = diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index df7bee1cd8a..3ac2a484076 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -85,6 +85,7 @@ struct ConstitutiveModels InternalEnergyModel internal_energy_model; EffectiveVolumetricEnthalpyModel effective_volumetric_enthalpy_model; GravityModel gravity_model; + DarcyVelocityModel darcy_velocity_model; FC1Model fC_1_model; FC2aModel fC_2a_model; FC3aModel fC_3a_model; diff --git a/ProcessLib/TH2M/ConstitutiveRelations/DarcyVelocity.cpp b/ProcessLib/TH2M/ConstitutiveRelations/DarcyVelocity.cpp new file mode 100644 index 00000000000..5083d8c65c2 --- /dev/null +++ b/ProcessLib/TH2M/ConstitutiveRelations/DarcyVelocity.cpp @@ -0,0 +1,43 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#include "DarcyVelocity.h" + +namespace ProcessLib::TH2M +{ +namespace ConstitutiveRelations +{ +template +void DarcyVelocityModel::eval( + CapillaryPressureGradientData const& grad_p_cap, + FluidDensityData const& fluid_density_data, + GasPressureGradientData const& grad_p_GR, + PermeabilityData const& permeability_data, + SpecificBodyForceData const& specific_body_force, + ViscosityData const& viscosity_data, + DarcyVelocityData& darcy_velocity_data) const +{ + auto const k_over_mu_G = + permeability_data.Ki * permeability_data.k_rel_G / viscosity_data.mu_GR; + auto const k_over_mu_L = + permeability_data.Ki * permeability_data.k_rel_L / viscosity_data.mu_LR; + + darcy_velocity_data.w_GS = + k_over_mu_G * fluid_density_data.rho_GR * specific_body_force() - + k_over_mu_G * grad_p_GR(); + darcy_velocity_data.w_LS = + k_over_mu_L * grad_p_cap() + + k_over_mu_L * fluid_density_data.rho_LR * specific_body_force() - + k_over_mu_L * grad_p_GR(); +} + +template struct DarcyVelocityModel<2>; +template struct DarcyVelocityModel<3>; +} // namespace ConstitutiveRelations +} // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/DarcyVelocity.h b/ProcessLib/TH2M/ConstitutiveRelations/DarcyVelocity.h index 84e66d31d02..91751b830f4 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/DarcyVelocity.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/DarcyVelocity.h @@ -10,7 +10,10 @@ #pragma once #include "Base.h" +#include "FluidDensity.h" +#include "PermeabilityData.h" #include "ProcessLib/Reflection/ReflectionData.h" +#include "Viscosity.h" namespace ProcessLib::TH2M { @@ -32,5 +35,20 @@ struct DarcyVelocityData R::makeReflectionData("velocity_liquid", &Self::w_LS)}; } }; + +template +struct DarcyVelocityModel +{ + void eval(CapillaryPressureGradientData const& grad_p_cap, + FluidDensityData const& fluid_density_data, + GasPressureGradientData const& grad_p_GR, + PermeabilityData const& permeability_data, + SpecificBodyForceData const& specific_body_force, + ViscosityData const& viscosity_data, + DarcyVelocityData& darcy_velocity_data) const; +}; + +extern template struct DarcyVelocityModel<2>; +extern template struct DarcyVelocityModel<3>; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index cc118746435..c87165fd500 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -162,6 +162,10 @@ TH2MLocalAssembler const + grad_p_GR{gradpGR}; + ConstitutiveRelations::CapillaryPressureGradientData< + DisplacementDim> const grad_p_cap{gradpCap}; // medium properties models.elastic_tangent_stiffness_model.eval({pos, t, dt}, T_data, @@ -487,21 +491,15 @@ TH2MLocalAssemblerprocess_data_.specific_body_force; - GlobalDimMatrixType const k_over_mu_G = - ip_out.permeability_data.Ki * ip_out.permeability_data.k_rel_G / - ip_cv.viscosity_data.mu_GR; - GlobalDimMatrixType const k_over_mu_L = - ip_out.permeability_data.Ki * ip_out.permeability_data.k_rel_L / - ip_cv.viscosity_data.mu_LR; - - ip_out.darcy_velocity_data.w_GS = - k_over_mu_G * ip_out.fluid_density_data.rho_GR * b - - k_over_mu_G * gradpGR; - ip_out.darcy_velocity_data.w_LS = - k_over_mu_L * gradpCap + - k_over_mu_L * ip_out.fluid_density_data.rho_LR * b - - k_over_mu_L * gradpGR; + models.darcy_velocity_model.eval( + grad_p_cap, + ip_out.fluid_density_data, + grad_p_GR, + ip_out.permeability_data, + ConstitutiveRelations::SpecificBodyForceData{ + this->process_data_.specific_body_force}, + ip_cv.viscosity_data, + ip_out.darcy_velocity_data); models.fT_2_model.eval(ip_out.darcy_velocity_data, ip_out.enthalpy_data, From 4ebed42ece5639688ef5e94174b9638b18e98ad2 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Wed, 17 Apr 2024 15:33:17 +0200 Subject: [PATCH 34/45] [PL/TH2M] Extract diffusion velocity model --- ProcessLib/TH2M/ConstitutiveRelations/Base.h | 4 + .../ConstitutiveModels.h | 2 + .../DiffusionVelocity.cpp | 90 +++++++++++++++++++ .../ConstitutiveRelations/DiffusionVelocity.h | 21 +++++ ProcessLib/TH2M/TH2MFEM-impl.h | 60 +++---------- 5 files changed, 127 insertions(+), 50 deletions(-) create mode 100644 ProcessLib/TH2M/ConstitutiveRelations/DiffusionVelocity.cpp diff --git a/ProcessLib/TH2M/ConstitutiveRelations/Base.h b/ProcessLib/TH2M/ConstitutiveRelations/Base.h index e5ec55f00b4..70c0467e6cf 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/Base.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/Base.h @@ -67,6 +67,10 @@ template using CapillaryPressureGradientData = BaseLib::StrongType, struct CapillaryPressureGradientTag>; +template +using TemperatureGradientData = + BaseLib::StrongType, + struct TemperatureGradientTag>; template using SpecificBodyForceData = diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index 3ac2a484076..6c80e242c27 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -13,6 +13,7 @@ #include "Biot.h" #include "Bishops.h" #include "CEquation.h" +#include "DiffusionVelocity.h" #include "ElasticTangentStiffnessModel.h" #include "Enthalpy.h" #include "Gravity.h" @@ -85,6 +86,7 @@ struct ConstitutiveModels InternalEnergyModel internal_energy_model; EffectiveVolumetricEnthalpyModel effective_volumetric_enthalpy_model; GravityModel gravity_model; + DiffusionVelocityModel diffusion_velocity_model; DarcyVelocityModel darcy_velocity_model; FC1Model fC_1_model; FC2aModel fC_2a_model; diff --git a/ProcessLib/TH2M/ConstitutiveRelations/DiffusionVelocity.cpp b/ProcessLib/TH2M/ConstitutiveRelations/DiffusionVelocity.cpp new file mode 100644 index 00000000000..20bd5917026 --- /dev/null +++ b/ProcessLib/TH2M/ConstitutiveRelations/DiffusionVelocity.cpp @@ -0,0 +1,90 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#include "DiffusionVelocity.h" + +namespace ProcessLib::TH2M +{ +namespace ConstitutiveRelations +{ +template +void DiffusionVelocityModel::eval( + CapillaryPressureGradientData const& grad_p_cap, + GasPressureGradientData const& grad_p_GR, + MassMoleFractionsData const& mass_mole_fractions_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + TemperatureGradientData const& grad_T, + DiffusionVelocityData& diffusion_velocity_data) const +{ + auto const gradxmWG = phase_transition_data.dxmWG_dpGR * grad_p_GR() + + phase_transition_data.dxmWG_dpCap * grad_p_cap() + + phase_transition_data.dxmWG_dT * grad_T(); + auto const gradxmCG = -gradxmWG; + + auto const gradxmWL = phase_transition_data.dxmWL_dpGR * grad_p_GR() + + phase_transition_data.dxmWL_dpCap * grad_p_cap() + + phase_transition_data.dxmWL_dT * grad_T(); + auto const gradxmCL = -gradxmWL; + + double const phi_L = S_L_data.S_L * porosity_data.phi; + double const phi_G = (1. - S_L_data.S_L) * porosity_data.phi; + + double const phi_G_D_vapour = + phi_G * phase_transition_data.diffusion_coefficient_vapour; + double const phi_L_D_solute = + phi_L * phase_transition_data.diffusion_coefficient_solute; + + if (mass_mole_fractions_data.xmCG == 0) + { + diffusion_velocity_data.d_CG = GlobalDimVector::Zero(); + } + else + { + diffusion_velocity_data.d_CG = + -phi_G_D_vapour / mass_mole_fractions_data.xmCG * gradxmCG; + } + + if (mass_mole_fractions_data.xmCG == 1) + { + diffusion_velocity_data.d_WG = GlobalDimVector::Zero(); + } + else + { + diffusion_velocity_data.d_WG = + -phi_G_D_vapour / (1 - mass_mole_fractions_data.xmCG) * gradxmWG; + } + + if (mass_mole_fractions_data.xmWL == 1) + + { + diffusion_velocity_data.d_CL = GlobalDimVector::Zero(); + } + else + { + diffusion_velocity_data.d_CL = + -phi_L_D_solute / (1. - mass_mole_fractions_data.xmWL) * gradxmCL; + } + + if (mass_mole_fractions_data.xmWL == 0) + { + diffusion_velocity_data.d_WL = GlobalDimVector::Zero(); + } + else + { + diffusion_velocity_data.d_WL = + -phi_L_D_solute / mass_mole_fractions_data.xmWL * gradxmWL; + } +} + +template struct DiffusionVelocityModel<2>; +template struct DiffusionVelocityModel<3>; +} // namespace ConstitutiveRelations +} // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/DiffusionVelocity.h b/ProcessLib/TH2M/ConstitutiveRelations/DiffusionVelocity.h index 25a203ca2c0..7ec45405ed8 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/DiffusionVelocity.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/DiffusionVelocity.h @@ -10,7 +10,11 @@ #pragma once #include "Base.h" +#include "MassMoleFractions.h" +#include "PhaseTransitionData.h" +#include "Porosity.h" #include "ProcessLib/Reflection/ReflectionData.h" +#include "Saturation.h" namespace ProcessLib::TH2M { @@ -38,5 +42,22 @@ struct DiffusionVelocityData &Self::d_WL)}; } }; + +template +struct DiffusionVelocityModel +{ + void eval( + CapillaryPressureGradientData const& grad_p_cap, + GasPressureGradientData const& grad_p_GR, + MassMoleFractionsData const& mass_mole_fractions_data, + PhaseTransitionData const& phase_transition_data, + PorosityData const& porosity_data, + SaturationData const& S_L_data, + TemperatureGradientData const& grad_T, + DiffusionVelocityData& diffusion_velocity_data) const; +}; + +extern template struct DiffusionVelocityModel<2>; +extern template struct DiffusionVelocityModel<3>; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index c87165fd500..f354e92facd 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -166,6 +166,8 @@ TH2MLocalAssembler const grad_p_cap{gradpCap}; + ConstitutiveRelations::TemperatureGradientData const + grad_T{gradT}; // medium properties models.elastic_tangent_stiffness_model.eval({pos, t, dt}, T_data, @@ -272,12 +274,14 @@ TH2MLocalAssemblerprocess_data_.specific_body_force}, ip_cv.volumetric_body_force); - auto const& c = ip_cv.phase_transition_data; - - auto const phi_L = - current_state.S_L_data.S_L * ip_out.porosity_data.phi; - auto const phi_G = - (1. - current_state.S_L_data.S_L) * ip_out.porosity_data.phi; + models.diffusion_velocity_model.eval(grad_p_cap, + grad_p_GR, + ip_out.mass_mole_fractions_data, + ip_cv.phase_transition_data, + ip_out.porosity_data, + current_state.S_L_data, + grad_T, + ip_out.diffusion_velocity_data); ip_out.enthalpy_data.h_S = ip_cv.solid_heat_capacity_data() * T; @@ -443,50 +447,6 @@ TH2MLocalAssembler Date: Wed, 17 Apr 2024 15:41:22 +0200 Subject: [PATCH 35/45] [PL/TH2M] Initialize strong types data directly For pressures, gradients, and strain use only strong typed values. --- ProcessLib/TH2M/TH2MFEM-impl.h | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index f354e92facd..9fd439fc353 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -152,22 +152,19 @@ TH2MLocalAssemblerprocess_data_.reference_temperature(t, pos)[0]}; - GlobalDimVectorType const gradpGR = gradNp * gas_pressure; - GlobalDimVectorType const gradpCap = gradNp * capillary_pressure; - GlobalDimVectorType const gradT = gradNp * temperature; ConstitutiveRelations::GasPressureGradientData const - grad_p_GR{gradpGR}; + grad_p_GR{gradNp * gas_pressure}; ConstitutiveRelations::CapillaryPressureGradientData< - DisplacementDim> const grad_p_cap{gradpCap}; + DisplacementDim> const grad_p_cap{gradNp * capillary_pressure}; ConstitutiveRelations::TemperatureGradientData const - grad_T{gradT}; + grad_T{gradNp * temperature}; // medium properties models.elastic_tangent_stiffness_model.eval({pos, t, dt}, T_data, @@ -181,8 +178,7 @@ TH2MLocalAssembler( gradNu, Nu, x_coord, this->is_axially_symmetric_); - auto& eps = ip_out.eps_data.eps; - eps.noalias() = Bu * displacement; + ip_out.eps_data.eps.noalias() = Bu * displacement; models.S_L_model.eval({pos, t, dt}, media_data, pCap_data, current_state.S_L_data, ip_cv.dS_L_dp_cap); From 454d2b470552cfced66776406c188c95e455d7ab Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Wed, 17 Apr 2024 15:55:35 +0200 Subject: [PATCH 36/45] [PL/TH2M] Extract solid enthalpy model and data This requires separation of enthalpies into FluidEnthalpyData and SolidEnthalpyData, hence the many changes. --- .../ConstitutiveRelations/ConstitutiveData.h | 6 ++- .../ConstitutiveModels.h | 1 + .../TH2M/ConstitutiveRelations/Enthalpy.cpp | 48 +++++++++++-------- .../TH2M/ConstitutiveRelations/Enthalpy.h | 36 ++++++++++---- .../ConstitutiveRelations/InternalEnergy.cpp | 10 ++-- .../ConstitutiveRelations/InternalEnergy.h | 8 ++-- .../NoPhaseTransition.cpp | 10 ++-- .../ConstitutiveRelations/NoPhaseTransition.h | 2 +- .../ConstitutiveRelations/PhaseTransition.cpp | 11 +++-- .../ConstitutiveRelations/PhaseTransition.h | 2 +- .../PhaseTransitionModel.h | 2 +- .../TH2M/ConstitutiveRelations/TEquation.cpp | 26 +++++----- .../TH2M/ConstitutiveRelations/TEquation.h | 4 +- ProcessLib/TH2M/TH2MFEM-impl.h | 21 ++++---- .../TH2M/TestTH2MNoPhaseTransition.cpp | 2 +- .../TH2M/TestTH2MPhaseTransition.cpp | 4 +- 16 files changed, 115 insertions(+), 78 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 68ebf146b5a..7bcdc10f117 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -104,7 +104,8 @@ struct OutputData { ProcessLib::ConstitutiveRelations::StrainData eps_data; PermeabilityData permeability_data; - EnthalpyData enthalpy_data; + FluidEnthalpyData fluid_enthalpy_data; + SolidEnthalpyData solid_enthalpy_data; MassMoleFractionsData mass_mole_fractions_data; FluidDensityData fluid_density_data; VapourPartialPressureData vapour_pressure_data; @@ -119,7 +120,8 @@ struct OutputData return Reflection::reflectWithoutName(&Self::eps_data, &Self::permeability_data, - &Self::enthalpy_data, + &Self::fluid_enthalpy_data, + &Self::solid_enthalpy_data, &Self::mass_mole_fractions_data, &Self::fluid_density_data, &Self::vapour_pressure_data, diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index 6c80e242c27..73d5a7c922d 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -87,6 +87,7 @@ struct ConstitutiveModels EffectiveVolumetricEnthalpyModel effective_volumetric_enthalpy_model; GravityModel gravity_model; DiffusionVelocityModel diffusion_velocity_model; + SolidEnthalpyModel solid_enthalpy_model; DarcyVelocityModel darcy_velocity_model; FC1Model fC_1_model; FC2aModel fC_2a_model; diff --git a/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.cpp b/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.cpp index a6c4acb2f03..d6d1e4a8078 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.cpp @@ -14,11 +14,12 @@ namespace ProcessLib::TH2M namespace ConstitutiveRelations { void EffectiveVolumetricEnthalpyModel::eval( - EnthalpyData const& enthalpy_data, FluidDensityData const& fluid_density_data, + FluidEnthalpyData const& fluid_enthalpy_data, PorosityData const& porosity_data, SaturationData const& S_L_data, SolidDensityData const& solid_density_data, + SolidEnthalpyData const& solid_enthalpy_data, EffectiveVolumetricEnthalpy& effective_volumetric_enthalpy_data) const { auto const phi_L = S_L_data.S_L * porosity_data.phi; @@ -26,14 +27,14 @@ void EffectiveVolumetricEnthalpyModel::eval( double const phi_S = 1. - porosity_data.phi; effective_volumetric_enthalpy_data.rho_h_eff = - phi_G * fluid_density_data.rho_GR * enthalpy_data.h_G + - phi_L * fluid_density_data.rho_LR * enthalpy_data.h_L + - phi_S * solid_density_data.rho_SR * enthalpy_data.h_S; + phi_G * fluid_density_data.rho_GR * fluid_enthalpy_data.h_G + + phi_L * fluid_density_data.rho_LR * fluid_enthalpy_data.h_L + + phi_S * solid_density_data.rho_SR * solid_enthalpy_data.h_S; } void EffectiveVolumetricEnthalpyModel::dEval( - EnthalpyData const& enthalpy_data, FluidDensityData const& fluid_density_data, + FluidEnthalpyData const& fluid_enthalpy_data, PhaseTransitionData const& phase_transition_data, PorosityData const& porosity_data, PorosityDerivativeData const& porosity_d_data, @@ -41,6 +42,7 @@ void EffectiveVolumetricEnthalpyModel::dEval( SaturationDataDeriv const& dS_L_dp_cap, SolidDensityData const& solid_density_data, SolidDensityDerivativeData const& solid_density_d_data, + SolidEnthalpyData const& solid_enthalpy_data, SolidHeatCapacityData const& solid_heat_capacity_data, EffectiveVolumetricEnthalpyDerivatives& effective_volumetric_enthalpy_d_data) const @@ -64,32 +66,40 @@ void EffectiveVolumetricEnthalpyModel::dEval( effective_volumetric_enthalpy_d_data.drho_h_eff_dp_GR = /*(dphi_G_dp_GR = 0) * fluid_density_data.rho_GR * - enthalpy_data.h_G +*/ - phi_G * phase_transition_data.drho_GR_dp_GR * enthalpy_data.h_G + + fluid_enthalpy_data.h_G +*/ + phi_G * phase_transition_data.drho_GR_dp_GR * fluid_enthalpy_data.h_G + /*(dphi_L_dp_GR = 0) * fluid_density_data.rho_LR * - enthalpy_data.h_L +*/ - phi_L * drho_LR_dp_GR * enthalpy_data.h_L; + fluid_enthalpy_data.h_L +*/ + phi_L * drho_LR_dp_GR * fluid_enthalpy_data.h_L; effective_volumetric_enthalpy_d_data.drho_h_eff_dp_cap = - dphi_G_dp_cap * fluid_density_data.rho_GR * enthalpy_data.h_G + - /*phi_G * (drho_GR_dp_cap = 0) * enthalpy_data.h_G +*/ - dphi_L_dp_cap * fluid_density_data.rho_LR * enthalpy_data.h_L + - phi_L * drho_LR_dp_cap * enthalpy_data.h_L; + dphi_G_dp_cap * fluid_density_data.rho_GR * fluid_enthalpy_data.h_G + + /*phi_G * (drho_GR_dp_cap = 0) * fluid_enthalpy_data.h_G +*/ + dphi_L_dp_cap * fluid_density_data.rho_LR * fluid_enthalpy_data.h_L + + phi_L * drho_LR_dp_cap * fluid_enthalpy_data.h_L; // TODO (naumov) Extend for temperature dependent porosities. constexpr double dphi_G_dT = 0; constexpr double dphi_L_dT = 0; effective_volumetric_enthalpy_d_data.drho_h_eff_dT = - dphi_G_dT * fluid_density_data.rho_GR * enthalpy_data.h_G + - phi_G * phase_transition_data.drho_GR_dT * enthalpy_data.h_G + + dphi_G_dT * fluid_density_data.rho_GR * fluid_enthalpy_data.h_G + + phi_G * phase_transition_data.drho_GR_dT * fluid_enthalpy_data.h_G + phi_G * fluid_density_data.rho_GR * phase_transition_data.dh_G_dT + - dphi_L_dT * fluid_density_data.rho_LR * enthalpy_data.h_L + - phi_L * phase_transition_data.drho_LR_dT * enthalpy_data.h_L + + dphi_L_dT * fluid_density_data.rho_LR * fluid_enthalpy_data.h_L + + phi_L * phase_transition_data.drho_LR_dT * fluid_enthalpy_data.h_L + phi_L * fluid_density_data.rho_LR * phase_transition_data.dh_L_dT - porosity_d_data.dphi_dT * solid_density_data.rho_SR * - enthalpy_data.h_S + - phi_S * solid_density_d_data.drho_SR_dT * enthalpy_data.h_S + + solid_enthalpy_data.h_S + + phi_S * solid_density_d_data.drho_SR_dT * solid_enthalpy_data.h_S + phi_S * solid_density_data.rho_SR * solid_heat_capacity_data(); } +void SolidEnthalpyModel::eval( + SolidHeatCapacityData const& solid_heat_capacity_data, + TemperatureData const& T_data, + SolidEnthalpyData& solid_enthalpy_data) const +{ + solid_enthalpy_data.h_S = solid_heat_capacity_data() * T_data.T; +} + } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.h b/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.h index 3c8d8182984..7778ec5da52 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.h @@ -23,20 +23,31 @@ namespace ProcessLib::TH2M { namespace ConstitutiveRelations { -struct EnthalpyData +struct FluidEnthalpyData { double h_G = nan; double h_L = nan; - double h_S = nan; static auto reflect() { - using Self = EnthalpyData; + using Self = FluidEnthalpyData; namespace R = ProcessLib::Reflection; return std::tuple{R::makeReflectionData("enthalpy_gas", &Self::h_G), - R::makeReflectionData("enthalpy_liquid", &Self::h_L), - R::makeReflectionData("enthalpy_solid", &Self::h_S)}; + R::makeReflectionData("enthalpy_liquid", &Self::h_L)}; + } +}; + +struct SolidEnthalpyData +{ + double h_S = nan; + + static auto reflect() + { + using Self = SolidEnthalpyData; + namespace R = ProcessLib::Reflection; + + return std::tuple{R::makeReflectionData("enthalpy_solid", &Self::h_S)}; } }; @@ -55,15 +66,16 @@ struct EffectiveVolumetricEnthalpyDerivatives struct EffectiveVolumetricEnthalpyModel { void eval( - EnthalpyData const& enthalpy_data, FluidDensityData const& fluid_density_data, + FluidEnthalpyData const& fluid_enthalpy_data, PorosityData const& porosity_data, SaturationData const& S_L_data, SolidDensityData const& solid_density_data, + SolidEnthalpyData const& solid_enthalpy_data, EffectiveVolumetricEnthalpy& effective_volumetric_enthalpy_data) const; - void dEval(EnthalpyData const& enthalpy_data, - FluidDensityData const& fluid_density_data, + void dEval(FluidDensityData const& fluid_density_data, + FluidEnthalpyData const& fluid_enthalpy_data, PhaseTransitionData const& phase_transition_data, PorosityData const& porosity_data, PorosityDerivativeData const& porosity_d_data, @@ -71,9 +83,17 @@ struct EffectiveVolumetricEnthalpyModel SaturationDataDeriv const& dS_L_dp_cap, SolidDensityData const& solid_density_data, SolidDensityDerivativeData const& solid_density_d_data, + SolidEnthalpyData const& solid_enthalpy_data, SolidHeatCapacityData const& solid_heat_capacity_data, EffectiveVolumetricEnthalpyDerivatives& effective_volumetric_enthalpy_d_data) const; }; + +struct SolidEnthalpyModel +{ + void eval(SolidHeatCapacityData const& solid_heat_capacity_data, + TemperatureData const& T_data, + SolidEnthalpyData& solid_enthalpy_data) const; +}; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.cpp b/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.cpp index 7911510ab47..36f740a8594 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.cpp @@ -13,19 +13,19 @@ namespace ProcessLib::TH2M { namespace ConstitutiveRelations { -void InternalEnergyModel::eval(EnthalpyData const& enthalpy_data, - FluidDensityData const& fluid_density_data, +void InternalEnergyModel::eval(FluidDensityData const& fluid_density_data, PhaseTransitionData const& phase_transition_data, PorosityData const& porosity_data, SaturationData const& S_L_data, SolidDensityData const& solid_density_data, + SolidEnthalpyData const& solid_enthalpy_data, InternalEnergyData& internal_energy_data) const { auto const phi_L = S_L_data.S_L * porosity_data.phi; auto const phi_G = (1. - S_L_data.S_L) * porosity_data.phi; double const phi_S = 1. - porosity_data.phi; - auto const u_S = enthalpy_data.h_S; + auto const u_S = solid_enthalpy_data.h_S; internal_energy_data() = phi_G * fluid_density_data.rho_GR * phase_transition_data.uG + @@ -34,7 +34,6 @@ void InternalEnergyModel::eval(EnthalpyData const& enthalpy_data, } void InternalEnergyModel::dEval( - EnthalpyData const& enthalpy_data, FluidDensityData const& fluid_density_data, PhaseTransitionData const& phase_transition_data, PorosityData const& porosity_data, @@ -43,6 +42,7 @@ void InternalEnergyModel::dEval( SaturationDataDeriv const& dS_L_dp_cap, SolidDensityData const& solid_density_data, SolidDensityDerivativeData const& solid_density_d_data, + SolidEnthalpyData const& solid_enthalpy_data, SolidHeatCapacityData const& solid_heat_capacity_data, EffectiveVolumetricInternalEnergyDerivatives& effective_volumetric_internal_energy_d_data) const @@ -51,7 +51,7 @@ void InternalEnergyModel::dEval( auto const phi_G = (1. - S_L_data.S_L) * porosity_data.phi; double const phi_S = 1. - porosity_data.phi; - auto const u_S = enthalpy_data.h_S; + auto const u_S = solid_enthalpy_data.h_S; effective_volumetric_internal_energy_d_data.drho_u_eff_dT = phi_G * phase_transition_data.drho_GR_dT * phase_transition_data.uG + phi_G * fluid_density_data.rho_GR * phase_transition_data.du_G_dT + diff --git a/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.h b/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.h index 727010140bc..fcfd77f9c2e 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.h @@ -35,16 +35,15 @@ struct EffectiveVolumetricInternalEnergyDerivatives struct InternalEnergyModel { - void eval(EnthalpyData const& enthalpy_data, - FluidDensityData const& fluid_density_data, + void eval(FluidDensityData const& fluid_density_data, PhaseTransitionData const& phase_transition_data, PorosityData const& porosity_data, SaturationData const& S_L_data, SolidDensityData const& solid_density_data, + SolidEnthalpyData const& solid_enthalpy_data, InternalEnergyData& internal_energy_data) const; - void dEval(EnthalpyData const& enthalpy_data, - FluidDensityData const& fluid_density_data, + void dEval(FluidDensityData const& fluid_density_data, PhaseTransitionData const& phase_transition_data, PorosityData const& porosity_data, PorosityDerivativeData const& porosity_d_data, @@ -52,6 +51,7 @@ struct InternalEnergyModel SaturationDataDeriv const& dS_L_dp_cap, SolidDensityData const& solid_density_data, SolidDensityDerivativeData const& solid_density_d_data, + SolidEnthalpyData const& solid_enthalpy_data, SolidHeatCapacityData const& solid_heat_capacity_data, EffectiveVolumetricInternalEnergyDerivatives& effective_volumetric_internal_energy_d_data) const; diff --git a/ProcessLib/TH2M/ConstitutiveRelations/NoPhaseTransition.cpp b/ProcessLib/TH2M/ConstitutiveRelations/NoPhaseTransition.cpp index 782b8b60ecb..72e475c0434 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/NoPhaseTransition.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/NoPhaseTransition.cpp @@ -43,7 +43,7 @@ void NoPhaseTransition::eval(SpaceTimeData const& x_t, CapillaryPressureData const& p_cap, TemperatureData const& T_data, PureLiquidDensityData const& rho_W_LR, - EnthalpyData& enthalpy_data, + FluidEnthalpyData& fluid_enthalpy_data, MassMoleFractionsData& mass_mole_fractions_data, FluidDensityData& fluid_density_data, VapourPartialPressureData& vapour_pressure_data, @@ -108,14 +108,14 @@ void NoPhaseTransition::eval(SpaceTimeData const& x_t, .template value(variables, x_t.x, x_t.t, x_t.dt); // specific phase enthalpies - enthalpy_data.h_G = cpG * T; - enthalpy_data.h_L = cpL * T; + fluid_enthalpy_data.h_G = cpG * T; + fluid_enthalpy_data.h_L = cpL * T; cv.dh_G_dT = cpG; cv.dh_L_dT = cpL; // specific inner energies - cv.uG = enthalpy_data.h_G - pGR / fluid_density_data.rho_GR; - cv.uL = enthalpy_data.h_L; + cv.uG = fluid_enthalpy_data.h_G - pGR / fluid_density_data.rho_GR; + cv.uL = fluid_enthalpy_data.h_L; cv.drho_GR_dT = gas_phase[MaterialPropertyLib::PropertyType::density] diff --git a/ProcessLib/TH2M/ConstitutiveRelations/NoPhaseTransition.h b/ProcessLib/TH2M/ConstitutiveRelations/NoPhaseTransition.h index 918723e9060..102443321b9 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/NoPhaseTransition.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/NoPhaseTransition.h @@ -28,7 +28,7 @@ struct NoPhaseTransition : PhaseTransitionModel GasPressureData const& p_GR, CapillaryPressureData const& p_cap, TemperatureData const& T_data, PureLiquidDensityData const& rho_W_LR, - EnthalpyData& enthalpy_data, + FluidEnthalpyData& fluid_enthalpy_data, MassMoleFractionsData& mass_mole_fractions_data, FluidDensityData& fluid_density_data, VapourPartialPressureData& vapour_pressure_data, diff --git a/ProcessLib/TH2M/ConstitutiveRelations/PhaseTransition.cpp b/ProcessLib/TH2M/ConstitutiveRelations/PhaseTransition.cpp index 7f71fcb2492..597bdca0440 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/PhaseTransition.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/PhaseTransition.cpp @@ -139,7 +139,7 @@ void PhaseTransition::eval(SpaceTimeData const& x_t, CapillaryPressureData const& p_cap, TemperatureData const& T_data, PureLiquidDensityData const& rho_W_LR, - EnthalpyData& enthalpy_data, + FluidEnthalpyData& fluid_enthalpy_data, MassMoleFractionsData& mass_mole_fractions_data, FluidDensityData& fluid_density_data, VapourPartialPressureData& vapour_pressure_data, @@ -333,11 +333,12 @@ void PhaseTransition::eval(SpaceTimeData const& x_t, cv.hWG = cpWG * T + dh_evap; // specific enthalpy of gas phase - enthalpy_data.h_G = mass_mole_fractions_data.xmCG * cv.hCG + xmWG * cv.hWG; + fluid_enthalpy_data.h_G = + mass_mole_fractions_data.xmCG * cv.hCG + xmWG * cv.hWG; cv.dh_G_dT = 0; // specific inner energies of gas phase - cv.uG = enthalpy_data.h_G - pGR / fluid_density_data.rho_GR; + cv.uG = fluid_enthalpy_data.h_G - pGR / fluid_density_data.rho_GR; cv.du_G_dT = 0; cv.du_G_dp_GR = 0; @@ -505,11 +506,11 @@ void PhaseTransition::eval(SpaceTimeData const& x_t, // specific enthalpy of liquid phase and its components double const hCL = cpCL * T + dh_sol; double const hWL = cpWL * T; - enthalpy_data.h_L = xmCL * hCL + mass_mole_fractions_data.xmWL * hWL; + fluid_enthalpy_data.h_L = xmCL * hCL + mass_mole_fractions_data.xmWL * hWL; cv.dh_L_dT = 0; // specific inner energies of liquid phase - cv.uL = enthalpy_data.h_L; + cv.uL = fluid_enthalpy_data.h_L; cv.du_L_dT = 0; // diffusion diff --git a/ProcessLib/TH2M/ConstitutiveRelations/PhaseTransition.h b/ProcessLib/TH2M/ConstitutiveRelations/PhaseTransition.h index 69d621b3dad..58766650f53 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/PhaseTransition.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/PhaseTransition.h @@ -28,7 +28,7 @@ struct PhaseTransition : PhaseTransitionModel GasPressureData const& p_GR, CapillaryPressureData const& p_cap, TemperatureData const& T_data, PureLiquidDensityData const& rho_W_LR, - EnthalpyData& enthalpy_data, + FluidEnthalpyData& fluid_enthalpy_data, MassMoleFractionsData& mass_mole_fractions_data, FluidDensityData& fluid_density_data, VapourPartialPressureData& vapour_pressure_data, diff --git a/ProcessLib/TH2M/ConstitutiveRelations/PhaseTransitionModel.h b/ProcessLib/TH2M/ConstitutiveRelations/PhaseTransitionModel.h index 8cf92e94f7e..0642ce42ca8 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/PhaseTransitionModel.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/PhaseTransitionModel.h @@ -52,7 +52,7 @@ struct PhaseTransitionModel CapillaryPressureData const& p_cap, TemperatureData const& T_data, PureLiquidDensityData const& rho_W_LR, - EnthalpyData& enthalpy_data, + FluidEnthalpyData& fluid_enthalpy_data, MassMoleFractionsData& mass_mole_fractions_data, FluidDensityData& fluid_density_data, VapourPartialPressureData& vapour_pressure_data, diff --git a/ProcessLib/TH2M/ConstitutiveRelations/TEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/TEquation.cpp index 25782dc1d8f..0dd5b7b814b 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/TEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/TEquation.cpp @@ -55,21 +55,21 @@ void FT1Model::dEval(double const dt, template void FT2Model::eval( DarcyVelocityData const& darcy_velocity_data, - EnthalpyData const& enthalpy_data, FluidDensityData const& fluid_density_data, + FluidEnthalpyData const& fluid_enthalpy_data, FT2Data& fT_2) const { - fT_2.A.noalias() = fluid_density_data.rho_GR * enthalpy_data.h_G * + fT_2.A.noalias() = fluid_density_data.rho_GR * fluid_enthalpy_data.h_G * darcy_velocity_data.w_GS + - fluid_density_data.rho_LR * enthalpy_data.h_L * + fluid_density_data.rho_LR * fluid_enthalpy_data.h_L * darcy_velocity_data.w_LS; } template void FT2Model::dEval( DarcyVelocityData const& darcy_velocity_data, - EnthalpyData const& enthalpy_data, FluidDensityData const& fluid_density_data, + FluidEnthalpyData const& fluid_enthalpy_data, PermeabilityData const& permeability_data, PhaseTransitionData const& phase_transition_data, SpecificBodyForceData const& specific_body_force, @@ -82,13 +82,13 @@ void FT2Model::dEval( permeability_data.Ki * permeability_data.k_rel_L / viscosity_data.mu_LR; dfT_2.dp_GR_Npart = phase_transition_data.drho_GR_dp_GR * - enthalpy_data.h_G * darcy_velocity_data.w_GS + - fluid_density_data.rho_GR * enthalpy_data.h_G * + fluid_enthalpy_data.h_G * darcy_velocity_data.w_GS + + fluid_density_data.rho_GR * fluid_enthalpy_data.h_G * k_over_mu_G * phase_transition_data.drho_GR_dp_GR * specific_body_force(); dfT_2.dp_GR_gradNpart = - fluid_density_data.rho_GR * enthalpy_data.h_G * k_over_mu_G - - fluid_density_data.rho_LR * enthalpy_data.h_L * k_over_mu_L; + fluid_density_data.rho_GR * fluid_enthalpy_data.h_G * k_over_mu_G - + fluid_density_data.rho_LR * fluid_enthalpy_data.h_L * k_over_mu_L; // From p_LR = p_GR - p_cap it follows for // drho_LR/dp_GR = drho_LR/dp_LR * dp_LR/dp_GR @@ -97,17 +97,17 @@ void FT2Model::dEval( double const drho_LR_dp_cap = -phase_transition_data.drho_LR_dp_LR; dfT_2.dp_cap_Npart = - -drho_LR_dp_cap * enthalpy_data.h_L * darcy_velocity_data.w_LS - - fluid_density_data.rho_LR * enthalpy_data.h_L * k_over_mu_L * + -drho_LR_dp_cap * fluid_enthalpy_data.h_L * darcy_velocity_data.w_LS - + fluid_density_data.rho_LR * fluid_enthalpy_data.h_L * k_over_mu_L * drho_LR_dp_cap * specific_body_force(); dfT_2.dp_cap_gradNpart = - fluid_density_data.rho_LR * enthalpy_data.h_L * k_over_mu_L; + fluid_density_data.rho_LR * fluid_enthalpy_data.h_L * k_over_mu_L; - dfT_2.dT = phase_transition_data.drho_GR_dT * enthalpy_data.h_G * + dfT_2.dT = phase_transition_data.drho_GR_dT * fluid_enthalpy_data.h_G * darcy_velocity_data.w_GS + fluid_density_data.rho_GR * phase_transition_data.dh_G_dT * darcy_velocity_data.w_GS + - phase_transition_data.drho_LR_dT * enthalpy_data.h_L * + phase_transition_data.drho_LR_dT * fluid_enthalpy_data.h_L * darcy_velocity_data.w_LS + fluid_density_data.rho_LR * phase_transition_data.dh_L_dT * darcy_velocity_data.w_LS; diff --git a/ProcessLib/TH2M/ConstitutiveRelations/TEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/TEquation.h index b638a754a22..94d80aaf05f 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/TEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/TEquation.h @@ -68,14 +68,14 @@ template struct FT2Model { void eval(DarcyVelocityData const& darcy_velocity_data, - EnthalpyData const& enthalpy_data, FluidDensityData const& fluid_density_data, + FluidEnthalpyData const& fluid_enthalpy_data, FT2Data& fT_2) const; void dEval( DarcyVelocityData const& darcy_velocity_data, - EnthalpyData const& enthalpy_data, FluidDensityData const& fluid_density_data, + FluidEnthalpyData const& fluid_enthalpy_data, PermeabilityData const& permeability_data, PhaseTransitionData const& phase_transition_data, SpecificBodyForceData const& specific_body_force, diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 9fd439fc353..31e8e89f011 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -225,7 +225,7 @@ TH2MLocalAssemblerprocess_data_.apply_mass_lumping) @@ -691,8 +694,8 @@ TH2MLocalAssembler{ diff --git a/Tests/ProcessLib/TH2M/TestTH2MNoPhaseTransition.cpp b/Tests/ProcessLib/TH2M/TestTH2MNoPhaseTransition.cpp index bc74bda9cf0..7fd5c61d739 100644 --- a/Tests/ProcessLib/TH2M/TestTH2MNoPhaseTransition.cpp +++ b/Tests/ProcessLib/TH2M/TestTH2MNoPhaseTransition.cpp @@ -108,7 +108,7 @@ TEST(ProcessLib, TH2MNoPhaseTransition) rhoWLR); ASSERT_NEAR(density_water, rhoWLR(), 1e-10); - CR::EnthalpyData enthalpy; + CR::FluidEnthalpyData enthalpy; CR::MassMoleFractionsData mass_mole_fractions; CR::FluidDensityData fluid_density; CR::VapourPartialPressureData vapour_pressure; diff --git a/Tests/ProcessLib/TH2M/TestTH2MPhaseTransition.cpp b/Tests/ProcessLib/TH2M/TestTH2MPhaseTransition.cpp index f636edf49f6..5dcc72fe30c 100644 --- a/Tests/ProcessLib/TH2M/TestTH2MPhaseTransition.cpp +++ b/Tests/ProcessLib/TH2M/TestTH2MPhaseTransition.cpp @@ -218,7 +218,7 @@ TEST(ProcessLib, TH2MPhaseTransition) CR::PureLiquidDensityData rhoWLR; CR::PureLiquidDensityModel rhoWLR_model; - CR::EnthalpyData enthalpy; + CR::FluidEnthalpyData enthalpy; CR::MassMoleFractionsData mass_mole_fractions; CR::FluidDensityData fluid_density; CR::VapourPartialPressureData vapour_pressure; @@ -480,7 +480,7 @@ TEST(ProcessLib, TH2MPhaseTransitionConstRho) CR::PureLiquidDensityData rhoWLR; CR::PureLiquidDensityModel rhoWLR_model; - CR::EnthalpyData enthalpy; + CR::FluidEnthalpyData enthalpy; CR::MassMoleFractionsData mass_mole_fractions; CR::FluidDensityData fluid_density; CR::VapourPartialPressureData vapour_pressure; From f452a003ba3d4d7f5055f57022ab9874e66655cf Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Wed, 17 Apr 2024 17:06:32 +0200 Subject: [PATCH 37/45] [PL/TH2M] Extract KUpC part of U2 equation --- .../ConstitutiveRelations/ConstitutiveData.h | 4 ++ .../ConstitutiveModels.h | 3 ++ .../TH2M/ConstitutiveRelations/UEquation.cpp | 34 ++++++++++++++ .../TH2M/ConstitutiveRelations/UEquation.h | 44 +++++++++++++++++++ ProcessLib/TH2M/TH2MFEM-impl.h | 23 +++++++--- 5 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 ProcessLib/TH2M/ConstitutiveRelations/UEquation.cpp create mode 100644 ProcessLib/TH2M/ConstitutiveRelations/UEquation.h diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 7bcdc10f117..2cd3860282d 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -41,6 +41,7 @@ #include "TEquation.h" #include "ThermalConductivity.h" #include "TotalStress.h" +#include "UEquation.h" #include "VapourPartialPressure.h" #include "Viscosity.h" #include "WEquation.h" @@ -186,6 +187,8 @@ struct ConstitutiveTempData FT1Data fT_1; FT2Data fT_2; FT3Data fT_3; + + FU2KUpCData fu_2_KupC; }; /// Data that stores intermediate values (derivatives), which are not needed @@ -213,6 +216,7 @@ struct DerivativesData FW4LWpCDerivativeData dfW_4_LWpC; FT1DerivativeData dfT_1; FT2DerivativeData dfT_2; + FU2KUpCDerivativeData dfu_2_KupC; }; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index 73d5a7c922d..c79d9e81fa8 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -33,6 +33,7 @@ #include "TEquation.h" #include "ThermalConductivity.h" #include "TotalStress.h" +#include "UEquation.h" #include "Viscosity.h" #include "WEquation.h" @@ -114,6 +115,8 @@ struct ConstitutiveModels FT1Model fT_1_model; FT2Model fT_2_model; FT3Model fT_3_model; + + FU2KUpCModel fu_2_KupC_model; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/UEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/UEquation.cpp new file mode 100644 index 00000000000..07f391f74d8 --- /dev/null +++ b/ProcessLib/TH2M/ConstitutiveRelations/UEquation.cpp @@ -0,0 +1,34 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#include "UEquation.h" + +namespace ProcessLib::TH2M +{ +namespace ConstitutiveRelations +{ +void FU2KUpCModel::eval(BiotData const& biot_data, + BishopsData const& chi_S_L, + FU2KUpCData& fu_2_KupC) const +{ + fu_2_KupC.m = biot_data() * chi_S_L.chi_S_L; +} + +void FU2KUpCModel::dEval(BiotData const& biot_data, + BishopsData const& chi_S_L, + CapillaryPressureData const& p_cap, + SaturationDataDeriv const& dS_L_dp_cap, + FU2KUpCDerivativeData& dfu_2_KupC) const +{ + dfu_2_KupC.dp_cap = + biot_data() * chi_S_L.dchi_dS_L * dS_L_dp_cap() * p_cap(); +} + +} // namespace ConstitutiveRelations +} // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/ConstitutiveRelations/UEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/UEquation.h new file mode 100644 index 00000000000..bffa79f508b --- /dev/null +++ b/ProcessLib/TH2M/ConstitutiveRelations/UEquation.h @@ -0,0 +1,44 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#pragma once + +#include "Base.h" +#include "Biot.h" +#include "Bishops.h" +#include "Saturation.h" + +namespace ProcessLib::TH2M +{ +namespace ConstitutiveRelations +{ +struct FU2KUpCData +{ + double m = nan; +}; + +struct FU2KUpCDerivativeData +{ + double dp_cap = nan; +}; + +struct FU2KUpCModel +{ + void eval(BiotData const& biot_data, + BishopsData const& chi_S_L, + FU2KUpCData& fu_2_KupC) const; + + void dEval(BiotData const& biot_data, + BishopsData const& chi_S_L, + CapillaryPressureData const& p_cap, + SaturationDataDeriv const& dS_L_dp_cap, + FU2KUpCDerivativeData& dfu_2_KupC) const; +}; +} // namespace ConstitutiveRelations +} // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 31e8e89f011..2f2fe779e7a 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -473,6 +473,9 @@ TH2MLocalAssembler{ this->process_data_.specific_body_force}, ip_cv.fT_3); + + models.fu_2_KupC_model.eval(ip_cv.biot_data, ip_cv.chi_S_L, + ip_cv.fu_2_KupC); } return {ip_constitutive_data, ip_constitutive_variables}; @@ -540,8 +543,8 @@ TH2MLocalAssemblerprocess_data_.specific_body_force}, ip_cv.viscosity_data, ip_dd.dfT_2); + + models.fu_2_KupC_model.dEval(ip_cv.biot_data, + ip_cv.chi_S_L, + pCap_data, + ip_cv.dS_L_dp_cap, + ip_dd.dfu_2_KupC); } return ip_d_data; @@ -1165,7 +1174,8 @@ void TH2MLocalAssembler< KUpG.noalias() -= (BuT * alpha_B * m * Np) * w; - KUpC.noalias() += (BuT * alpha_B * ip_cv.chi_S_L.chi_S_L * m * Np) * w; + KUpC.noalias() += + BuT * Invariants::identity2 * Np * (ip_cv.fu_2_KupC.m * w); fU.noalias() -= (BuT * current_state.eff_stress_data.sigma - @@ -1742,15 +1752,16 @@ void TH2MLocalAssembler(displacement_index, W_index) - .noalias() += BuT * alpha_B * ip_cv.chi_S_L.dchi_dS_L * - ip_cv.dS_L_dp_cap() * pCap * m * Np * w; + .noalias() += + BuT * Invariants::identity2 * Np * (ip_dd.dfu_2_KupC.dp_cap * w); local_Jac .template block( From f2eaf73bab7f0ae8e2be260367a40d05644f256a Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Wed, 17 Apr 2024 12:48:29 +0200 Subject: [PATCH 38/45] [PL/TH2M] Replace alpha_B alias with biot_data --- ProcessLib/TH2M/TH2MFEM-impl.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 2f2fe779e7a..7899b27f5bc 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -1076,8 +1076,6 @@ void TH2MLocalAssembler< auto const s_L = current_state.S_L_data.S_L; auto const s_L_dot = (s_L - prev_state.S_L_data->S_L) / dt; - auto& alpha_B = ip_cv.biot_data(); - auto const& b = this->process_data_.specific_body_force; // --------------------------------------------------------------------- @@ -1172,7 +1170,7 @@ void TH2MLocalAssembler< // - displacement equation // --------------------------------------------------------------------- - KUpG.noalias() -= (BuT * alpha_B * m * Np) * w; + KUpG.noalias() -= (BuT * ip_cv.biot_data() * m * Np) * w; KUpC.noalias() += BuT * Invariants::identity2 * Np * (ip_cv.fu_2_KupC.m * w); @@ -1402,8 +1400,6 @@ void TH2MLocalAssemblerS_L) / dt; - auto const alpha_B = ip_cv.biot_data(); - auto const& b = this->process_data_.specific_body_force; // --------------------------------------------------------------------- @@ -1747,7 +1743,7 @@ void TH2MLocalAssembler Date: Wed, 17 Apr 2024 17:10:33 +0200 Subject: [PATCH 39/45] [PL/TH2M] Remove identity2 alias; reorder terms ... for hopefully faster compilation. --- ProcessLib/TH2M/TH2MFEM-impl.h | 37 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 7899b27f5bc..4eff6a4203e 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -1053,10 +1053,6 @@ void TH2MLocalAssembler< auto const& w = ip.integration_weight; - auto const& m = Invariants::identity2; - - auto const mT = m.transpose().eval(); - auto const x_coord = NumLib::interpolateXCoordinate( @@ -1095,7 +1091,8 @@ void TH2MLocalAssembler< } MCT.noalias() += NpT * ip_cv.fC_4_MCT.m * Np * w; - MCu.noalias() += NpT * ip_cv.fC_4_MCu.m * mT * Bu * w; + MCu.noalias() += NpT * Invariants::identity2.transpose() * Bu * + (ip_cv.fC_4_MCu.m * w); LCpG.noalias() += gradNpT * ip_cv.fC_4_LCpG.L * gradNp * w; @@ -1130,7 +1127,8 @@ void TH2MLocalAssembler< MWT.noalias() += NpT * ip_cv.fW_4_MWT.m * Np * w; - MWu.noalias() += NpT * ip_cv.fW_4_MWu.m * mT * Bu * w; + MWu.noalias() += NpT * Invariants::identity2.transpose() * Bu * + (ip_cv.fW_4_MWu.m * w); LWpG.noalias() += gradNpT * ip_cv.fW_4_LWpG.L * gradNp * w; @@ -1151,9 +1149,9 @@ void TH2MLocalAssembler< // - temperature equation // --------------------------------------------------------------------- - MTu.noalias() += NTT * - ip_cv.effective_volumetric_enthalpy_data.rho_h_eff * - mT * Bu * w; + MTu.noalias() += + NTT * Invariants::identity2.transpose() * Bu * + (ip_cv.effective_volumetric_enthalpy_data.rho_h_eff * w); KTT.noalias() += gradNTT * ip_cv.thermal_conductivity_data.lambda * gradNT * w; @@ -1170,7 +1168,8 @@ void TH2MLocalAssembler< // - displacement equation // --------------------------------------------------------------------- - KUpG.noalias() -= (BuT * ip_cv.biot_data() * m * Np) * w; + KUpG.noalias() -= + BuT * Invariants::identity2 * Np * (ip_cv.biot_data() * w); KUpC.noalias() += BuT * Invariants::identity2 * Np * (ip_cv.fu_2_KupC.m * w); @@ -1366,9 +1365,6 @@ void TH2MLocalAssembler( @@ -1425,7 +1421,8 @@ void TH2MLocalAssembler(C_index, @@ -1540,7 +1537,8 @@ void TH2MLocalAssembler Date: Wed, 17 Apr 2024 17:21:06 +0200 Subject: [PATCH 40/45] [PL/TH2M] Separate saturation derivative eval --- .../ConstitutiveRelations/ConstitutiveData.h | 2 +- .../TH2M/ConstitutiveRelations/Saturation.cpp | 15 +++++++-- .../TH2M/ConstitutiveRelations/Saturation.h | 8 +++-- ProcessLib/TH2M/TH2MFEM-impl.h | 33 ++++++++++--------- 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index 2cd3860282d..bbb0a042679 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -149,7 +149,6 @@ struct ConstitutiveTempData ElasticTangentStiffnessData C_el_data; BiotData biot_data; SolidCompressibilityData beta_p_SR; - SaturationDataDeriv dS_L_dp_cap; BishopsData chi_S_L; SolidThermalExpansionData s_therm_exp_data; TotalStressData total_stress_data; @@ -196,6 +195,7 @@ struct ConstitutiveTempData template struct DerivativesData { + SaturationDataDeriv dS_L_dp_cap; AdvectionDerivativeData advection_d_data; ThermalConductivityDerivativeData thermal_conductivity_d_data; diff --git a/ProcessLib/TH2M/ConstitutiveRelations/Saturation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/Saturation.cpp index 5f4693174a6..8ca73adaa1b 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/Saturation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/Saturation.cpp @@ -16,8 +16,7 @@ namespace ConstitutiveRelations void SaturationModel::eval(SpaceTimeData const& x_t, MediaData const& media_data, CapillaryPressureData const& p_cap, - SaturationData& S_L_data, - SaturationDataDeriv& dS_L_data) const + SaturationData& S_L_data) const { namespace MPL = MaterialPropertyLib; MPL::VariableArray variables; @@ -27,6 +26,18 @@ void SaturationModel::eval(SpaceTimeData const& x_t, S_L_data.S_L = medium.property(MPL::PropertyType::saturation) .template value(variables, x_t.x, x_t.t, x_t.dt); +} + +void SaturationModel::dEval(SpaceTimeData const& x_t, + MediaData const& media_data, + CapillaryPressureData const& p_cap, + SaturationDataDeriv& dS_L_data) const +{ + namespace MPL = MaterialPropertyLib; + MPL::VariableArray variables; + variables.capillary_pressure = p_cap(); + + auto const& medium = media_data.medium; dS_L_data() = medium.property(MPL::PropertyType::saturation) .template dValue( diff --git a/ProcessLib/TH2M/ConstitutiveRelations/Saturation.h b/ProcessLib/TH2M/ConstitutiveRelations/Saturation.h index f8ab3071673..66dbbea5dcc 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/Saturation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/Saturation.h @@ -34,8 +34,12 @@ using SaturationDataDeriv = struct SaturationModel { void eval(SpaceTimeData const& x_t, MediaData const& media_data, - CapillaryPressureData const& p_cap, SaturationData& S_L_data, - SaturationDataDeriv& dS_L_data) const; + CapillaryPressureData const& p_cap, + SaturationData& S_L_data) const; + + void dEval(SpaceTimeData const& x_t, MediaData const& media_data, + CapillaryPressureData const& p_cap, + SaturationDataDeriv& dS_L_data) const; }; } // namespace ConstitutiveRelations } // namespace ProcessLib::TH2M diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 4eff6a4203e..bfadf134ba2 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -180,7 +180,7 @@ TH2MLocalAssembler(C_index, W_index) .noalias() += NpT * (ip_dd.dfC_2a.dp_cap * s_L_dot + - ip_cv.fC_2a.a * ip_cv.dS_L_dp_cap() / dt) * + ip_cv.fC_2a.a * ip_dd.dS_L_dp_cap() / dt) * Np * w; local_Jac @@ -1587,7 +1590,7 @@ void TH2MLocalAssembler(W_index, W_index) .noalias() += NpT * (ip_dd.dfW_2.dp_cap * s_L_dot + - ip_cv.fW_2.a * ip_cv.dS_L_dp_cap() / dt) * + ip_cv.fW_2.a * ip_dd.dS_L_dp_cap() / dt) * Np * w; local_Jac From ee510eac3147b6caa2214285226299112536841a Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Wed, 17 Apr 2024 17:27:58 +0200 Subject: [PATCH 41/45] [PL/TH2M] Separate porosity derivative eval --- .../ConstitutiveRelations/ConstitutiveData.h | 2 +- .../TH2M/ConstitutiveRelations/Porosity.cpp | 39 +++++++++++++++++-- .../TH2M/ConstitutiveRelations/Porosity.h | 16 ++++++-- ProcessLib/TH2M/TH2MFEM-impl.h | 27 ++++++++----- 4 files changed, 66 insertions(+), 18 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index bbb0a042679..fa7c57299a8 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -155,7 +155,6 @@ struct ConstitutiveTempData EquivalentPlasticStrainData equivalent_plastic_strain_data; ViscosityData viscosity_data; PhaseTransitionData phase_transition_data; - PorosityDerivativeData porosity_d_data; SolidHeatCapacityData solid_heat_capacity_data; ThermalConductivityData thermal_conductivity_data; EffectiveVolumetricEnthalpy effective_volumetric_enthalpy_data; @@ -197,6 +196,7 @@ struct DerivativesData { SaturationDataDeriv dS_L_dp_cap; AdvectionDerivativeData advection_d_data; + PorosityDerivativeData porosity_d_data; ThermalConductivityDerivativeData thermal_conductivity_d_data; SolidDensityDerivativeData solid_density_d_data; diff --git a/ProcessLib/TH2M/ConstitutiveRelations/Porosity.cpp b/ProcessLib/TH2M/ConstitutiveRelations/Porosity.cpp index 508dc689d3a..f43cef3cf6e 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/Porosity.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/Porosity.cpp @@ -16,8 +16,7 @@ namespace ConstitutiveRelations void PorosityModel::eval(SpaceTimeData const& x_t, MediaData const& media_data, - PorosityData& porosity_data, - PorosityDerivativeData& porosity_d_data) const + PorosityData& porosity_data) const { MaterialPropertyLib::VariableArray variables; @@ -26,6 +25,16 @@ void PorosityModel::eval(SpaceTimeData const& x_t, porosity_data.phi = mpl_porosity.template value(variables, x_t.x, x_t.t, x_t.dt); +} + +void PorosityModel::dEval(SpaceTimeData const& x_t, + MediaData const& media_data, + PorosityDerivativeData& porosity_d_data) const +{ + MaterialPropertyLib::VariableArray variables; + + auto const& mpl_porosity = + media_data.medium[MaterialPropertyLib::PropertyType::porosity]; porosity_d_data.dphi_dT = mpl_porosity.template dValue( variables, MaterialPropertyLib::Variable::temperature, x_t.x, x_t.t, @@ -39,8 +48,7 @@ void PorosityModelNonConstantSolidPhaseVolumeFraction::eval( BiotData const& biot, StrainData const& strain_data, SolidThermalExpansionData const& s_therm_exp_data, - PorosityData& porosity_data, - PorosityDerivativeData& porosity_d_data) const + PorosityData& porosity_data) const { MaterialPropertyLib::VariableArray variables; @@ -60,6 +68,29 @@ void PorosityModelNonConstantSolidPhaseVolumeFraction::eval( (1. + s_therm_exp_data.thermal_volume_strain - biot() * div_u); porosity_data.phi = 1. - phi_S; +} + +template +void PorosityModelNonConstantSolidPhaseVolumeFraction::dEval( + SpaceTimeData const& x_t, + MediaData const& media_data, + BiotData const& biot, + StrainData const& strain_data, + SolidThermalExpansionData const& s_therm_exp_data, + PorosityDerivativeData& porosity_d_data) const +{ + MaterialPropertyLib::VariableArray variables; + + auto const& mpl_porosity = + media_data.medium[MaterialPropertyLib::PropertyType::porosity]; + + double const phi_0 = + mpl_porosity.template value(variables, x_t.x, x_t.t, x_t.dt); + + static int const KelvinVectorSize = + MathLib::KelvinVector::kelvin_vector_dimensions(DisplacementDim); + using Invariants = MathLib::KelvinVector::Invariants; + double const div_u = Invariants::trace(strain_data.eps); auto const dphi_0_dT = mpl_porosity.template dValue( variables, MaterialPropertyLib::Variable::temperature, x_t.x, x_t.t, diff --git a/ProcessLib/TH2M/ConstitutiveRelations/Porosity.h b/ProcessLib/TH2M/ConstitutiveRelations/Porosity.h index f7e0d5d8f09..aecbd306262 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/Porosity.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/Porosity.h @@ -41,8 +41,11 @@ struct PorosityModel { void eval(SpaceTimeData const& x_t, MediaData const& media_data, - PorosityData& porosity_data, - PorosityDerivativeData& porosity_d_data) const; + PorosityData& porosity_data) const; + + void dEval(SpaceTimeData const& x_t, + MediaData const& media_data, + PorosityDerivativeData& porosity_d_data) const; }; template @@ -54,7 +57,14 @@ struct PorosityModelNonConstantSolidPhaseVolumeFraction BiotData const& biot, StrainData const& strain_data, SolidThermalExpansionData const& s_therm_exp_data, - PorosityData& porosity_data, + PorosityData& porosity_data) const; + + void dEval( + SpaceTimeData const& x_t, + MediaData const& media_data, + BiotData const& biot, + StrainData const& strain_data, + SolidThermalExpansionData const& s_therm_exp_data, PorosityDerivativeData& porosity_d_data) const; }; diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index bfadf134ba2..5098124c862 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -239,7 +239,7 @@ TH2MLocalAssembler(C_index, temperature_index) .noalias() += NpT * - (ip_cv.porosity_d_data.dphi_dT * ip_cv.fC_3a.a + + (ip_dd.porosity_d_data.dphi_dT * ip_cv.fC_3a.a + ip_out.porosity_data.phi * ip_dd.dfC_3a.dT) * NT * w; } @@ -1612,7 +1619,7 @@ void TH2MLocalAssembler(W_index, temperature_index) .noalias() += NpT * - (ip_cv.porosity_d_data.dphi_dT * ip_cv.fW_3a.a + + (ip_dd.porosity_d_data.dphi_dT * ip_cv.fW_3a.a + ip_out.porosity_data.phi * ip_dd.dfW_3a.dT) * NT * w; From 5e5c71b7b3b1ccba8f667d21d248bdefb8068066 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Thu, 25 Apr 2024 18:48:01 +0200 Subject: [PATCH 42/45] [PL/TH2M] Move dphi_L/dp_cap into porosity model This simplifies some calls and avoids two recomputations of the same quantity. --- ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.cpp | 12 ++++-------- ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.h | 1 - .../TH2M/ConstitutiveRelations/InternalEnergy.cpp | 12 ++++-------- .../TH2M/ConstitutiveRelations/InternalEnergy.h | 1 - ProcessLib/TH2M/ConstitutiveRelations/Porosity.cpp | 13 ++++++++++--- ProcessLib/TH2M/ConstitutiveRelations/Porosity.h | 11 ++++++++++- .../ConstitutiveRelations/ThermalConductivity.cpp | 10 +++------- .../ConstitutiveRelations/ThermalConductivity.h | 1 - ProcessLib/TH2M/TH2MFEM-impl.h | 12 +++++------- 9 files changed, 36 insertions(+), 37 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.cpp b/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.cpp index d6d1e4a8078..046bb5eb2fb 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.cpp @@ -39,7 +39,6 @@ void EffectiveVolumetricEnthalpyModel::dEval( PorosityData const& porosity_data, PorosityDerivativeData const& porosity_d_data, SaturationData const& S_L_data, - SaturationDataDeriv const& dS_L_dp_cap, SolidDensityData const& solid_density_data, SolidDensityDerivativeData const& solid_density_d_data, SolidEnthalpyData const& solid_enthalpy_data, @@ -51,11 +50,6 @@ void EffectiveVolumetricEnthalpyModel::dEval( auto const phi_G = (1. - S_L_data.S_L) * porosity_data.phi; double const phi_S = 1. - porosity_data.phi; - // dphi_G_dp_GR = -ds_L_dp_GR * porosity_data.phi = 0; - double const dphi_G_dp_cap = -dS_L_dp_cap() * porosity_data.phi; - // dphi_L_dp_GR = ds_L_dp_GR * porosity_data.phi = 0; - double const dphi_L_dp_cap = dS_L_dp_cap() * porosity_data.phi; - // From p_LR = p_GR - p_cap it follows for // drho_LR/dp_GR = drho_LR/dp_LR * dp_LR/dp_GR // = drho_LR/dp_LR * (dp_GR/dp_GR - dp_cap/dp_GR) @@ -72,9 +66,11 @@ void EffectiveVolumetricEnthalpyModel::dEval( fluid_enthalpy_data.h_L +*/ phi_L * drho_LR_dp_GR * fluid_enthalpy_data.h_L; effective_volumetric_enthalpy_d_data.drho_h_eff_dp_cap = - dphi_G_dp_cap * fluid_density_data.rho_GR * fluid_enthalpy_data.h_G + + porosity_d_data.dphi_L_dp_cap * fluid_density_data.rho_GR * + fluid_enthalpy_data.h_G + /*phi_G * (drho_GR_dp_cap = 0) * fluid_enthalpy_data.h_G +*/ - dphi_L_dp_cap * fluid_density_data.rho_LR * fluid_enthalpy_data.h_L + + porosity_d_data.dphi_L_dp_cap * fluid_density_data.rho_LR * + fluid_enthalpy_data.h_L + phi_L * drho_LR_dp_cap * fluid_enthalpy_data.h_L; // TODO (naumov) Extend for temperature dependent porosities. diff --git a/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.h b/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.h index 7778ec5da52..4bff673ce9a 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/Enthalpy.h @@ -80,7 +80,6 @@ struct EffectiveVolumetricEnthalpyModel PorosityData const& porosity_data, PorosityDerivativeData const& porosity_d_data, SaturationData const& S_L_data, - SaturationDataDeriv const& dS_L_dp_cap, SolidDensityData const& solid_density_data, SolidDensityDerivativeData const& solid_density_d_data, SolidEnthalpyData const& solid_enthalpy_data, diff --git a/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.cpp b/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.cpp index 36f740a8594..2aa2b1d7552 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.cpp @@ -39,7 +39,6 @@ void InternalEnergyModel::dEval( PorosityData const& porosity_data, PorosityDerivativeData const& porosity_d_data, SaturationData const& S_L_data, - SaturationDataDeriv const& dS_L_dp_cap, SolidDensityData const& solid_density_data, SolidDensityDerivativeData const& solid_density_d_data, SolidEnthalpyData const& solid_enthalpy_data, @@ -61,11 +60,6 @@ void InternalEnergyModel::dEval( phi_S * solid_density_data.rho_SR * solid_heat_capacity_data() - porosity_d_data.dphi_dT * solid_density_data.rho_SR * u_S; - // dphi_G_dp_GR = -ds_L_dp_GR * porosity_data.phi = 0; - double const dphi_G_dp_cap = -dS_L_dp_cap() * porosity_data.phi; - // dphi_L_dp_GR = ds_L_dp_GR * porosity_data.phi = 0; - double const dphi_L_dp_cap = dS_L_dp_cap() * porosity_data.phi; - // From p_LR = p_GR - p_cap it follows for // drho_LR/dp_GR = drho_LR/dp_LR * dp_LR/dp_GR // = drho_LR/dp_LR * (dp_GR/dp_GR - dp_cap/dp_GR) @@ -85,9 +79,11 @@ void InternalEnergyModel::dEval( phi_L * fluid_density_data.rho_LR * phase_transition_data.du_L_dp_GR; effective_volumetric_internal_energy_d_data.drho_u_eff_dp_cap = - dphi_G_dp_cap * fluid_density_data.rho_GR * phase_transition_data.uG + + -porosity_d_data.dphi_L_dp_cap * fluid_density_data.rho_GR * + phase_transition_data.uG + /*phi_G * (drho_GR_dp_cap = 0) * phase_transition_data.uG +*/ - dphi_L_dp_cap * fluid_density_data.rho_LR * phase_transition_data.uL + + porosity_d_data.dphi_L_dp_cap * fluid_density_data.rho_LR * + phase_transition_data.uL + phi_L * drho_LR_dp_cap * phase_transition_data.uL + phi_L * fluid_density_data.rho_LR * phase_transition_data.du_L_dp_cap; } diff --git a/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.h b/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.h index fcfd77f9c2e..d74dfd71677 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/InternalEnergy.h @@ -48,7 +48,6 @@ struct InternalEnergyModel PorosityData const& porosity_data, PorosityDerivativeData const& porosity_d_data, SaturationData const& S_L_data, - SaturationDataDeriv const& dS_L_dp_cap, SolidDensityData const& solid_density_data, SolidDensityDerivativeData const& solid_density_d_data, SolidEnthalpyData const& solid_enthalpy_data, diff --git a/ProcessLib/TH2M/ConstitutiveRelations/Porosity.cpp b/ProcessLib/TH2M/ConstitutiveRelations/Porosity.cpp index f43cef3cf6e..2688dd02698 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/Porosity.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/Porosity.cpp @@ -27,8 +27,9 @@ void PorosityModel::eval(SpaceTimeData const& x_t, mpl_porosity.template value(variables, x_t.x, x_t.t, x_t.dt); } -void PorosityModel::dEval(SpaceTimeData const& x_t, - MediaData const& media_data, +void PorosityModel::dEval(SpaceTimeData const& x_t, MediaData const& media_data, + PorosityData const& porosity_data, + SaturationDataDeriv const& dS_L_dp_cap, PorosityDerivativeData& porosity_d_data) const { MaterialPropertyLib::VariableArray variables; @@ -39,6 +40,8 @@ void PorosityModel::dEval(SpaceTimeData const& x_t, porosity_d_data.dphi_dT = mpl_porosity.template dValue( variables, MaterialPropertyLib::Variable::temperature, x_t.x, x_t.t, x_t.dt); + + porosity_d_data.dphi_L_dp_cap = dS_L_dp_cap() * porosity_data.phi; } template @@ -74,9 +77,11 @@ template void PorosityModelNonConstantSolidPhaseVolumeFraction::dEval( SpaceTimeData const& x_t, MediaData const& media_data, + PorosityData const& porosity_data, + SaturationDataDeriv const& dS_L_dp_cap, BiotData const& biot, - StrainData const& strain_data, SolidThermalExpansionData const& s_therm_exp_data, + StrainData const& strain_data, PorosityDerivativeData& porosity_d_data) const { MaterialPropertyLib::VariableArray variables; @@ -100,6 +105,8 @@ void PorosityModelNonConstantSolidPhaseVolumeFraction::dEval( dphi_0_dT * (1. + s_therm_exp_data.thermal_volume_strain - biot() * div_u) - (1. - phi_0) * s_therm_exp_data.beta_T_SR; + + porosity_d_data.dphi_L_dp_cap = dS_L_dp_cap() * porosity_data.phi; } template struct PorosityModelNonConstantSolidPhaseVolumeFraction<2>; diff --git a/ProcessLib/TH2M/ConstitutiveRelations/Porosity.h b/ProcessLib/TH2M/ConstitutiveRelations/Porosity.h index aecbd306262..49884ed45ed 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/Porosity.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/Porosity.h @@ -13,6 +13,7 @@ #include "Biot.h" #include "ProcessLib/ConstitutiveRelations/StrainData.h" #include "ProcessLib/Reflection/ReflectionData.h" +#include "Saturation.h" #include "SolidThermalExpansion.h" namespace ProcessLib::TH2M @@ -22,6 +23,10 @@ namespace ConstitutiveRelations struct PorosityDerivativeData { double dphi_dT = nan; + // dphi_G_dp_GR = -ds_L_dp_GR * phi = 0; + // dphi_L_dp_GR = ds_L_dp_GR * phi = 0; + double dphi_L_dp_cap = nan; + // dphi_G_dp_cap = -dphi_L_dp_cap }; struct PorosityData @@ -45,6 +50,8 @@ struct PorosityModel void dEval(SpaceTimeData const& x_t, MediaData const& media_data, + PorosityData const& porosity_data, + SaturationDataDeriv const& dS_L_dp_cap, PorosityDerivativeData& porosity_d_data) const; }; @@ -62,9 +69,11 @@ struct PorosityModelNonConstantSolidPhaseVolumeFraction void dEval( SpaceTimeData const& x_t, MediaData const& media_data, + PorosityData const& porosity_data, + SaturationDataDeriv const& dS_L_dp_cap, BiotData const& biot, - StrainData const& strain_data, SolidThermalExpansionData const& s_therm_exp_data, + StrainData const& strain_data, PorosityDerivativeData& porosity_d_data) const; }; diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.cpp b/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.cpp index 60002a217fb..358ee797cc7 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.cpp @@ -40,7 +40,7 @@ void ThermalConductivityModel::dEval( SpaceTimeData const& x_t, MediaData const& media_data, TemperatureData const& T_data, PorosityData const& porosity_data, PorosityDerivativeData const& porosity_d_data, - SaturationData const& S_L_data, SaturationDataDeriv const& dS_L_dp_cap, + SaturationData const& S_L_data, ThermalConductivityDerivativeData& thermal_conductivity_d_data) const { @@ -98,13 +98,9 @@ void ThermalConductivityModel::dEval( x_t.t, x_t.dt)) : MPL::formEigenTensor(0.); - // dphi_G_dp_GR = -ds_L_dp_GR * phi = 0; - double const dphi_G_dp_cap = -dS_L_dp_cap() * porosity_data.phi; - // dphi_L_dp_GR = ds_L_dp_GR * phi = 0; - double const dphi_L_dp_cap = dS_L_dp_cap() * porosity_data.phi; - thermal_conductivity_d_data.dlambda_dp_cap = - dphi_G_dp_cap * lambdaGR + dphi_L_dp_cap * lambdaLR; + -porosity_d_data.dphi_L_dp_cap * lambdaGR + + porosity_d_data.dphi_L_dp_cap * lambdaLR; double const phi_L = S_L_data.S_L * porosity_data.phi; double const phi_G = (1. - S_L_data.S_L) * porosity_data.phi; diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.h b/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.h index eefb94ef707..35720adac3f 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ThermalConductivity.h @@ -47,7 +47,6 @@ struct ThermalConductivityModel TemperatureData const& T_data, PorosityData const& porosity_data, PorosityDerivativeData const& porosity_d_data, SaturationData const& S_L_data, - SaturationDataDeriv const& dS_L_dp_cap, ThermalConductivityDerivativeData& thermal_conductivity_d_data) const; }; diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 5098124c862..3e0beb96ac3 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -556,16 +556,16 @@ TH2MLocalAssembler Date: Wed, 17 Apr 2024 19:08:58 +0200 Subject: [PATCH 43/45] [PL/TH2M] Extract KuT part of U1 equation --- .../ConstitutiveRelations/ConstitutiveData.h | 1 + .../ConstitutiveModels.h | 1 + .../TH2M/ConstitutiveRelations/UEquation.cpp | 13 ++++++++++++ .../TH2M/ConstitutiveRelations/UEquation.h | 20 +++++++++++++++++++ ProcessLib/TH2M/TH2MFEM-impl.h | 15 ++++++++------ ProcessLib/TH2M/TH2MFEM.h | 3 +++ 6 files changed, 47 insertions(+), 6 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h index fa7c57299a8..38f09a60085 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveData.h @@ -216,6 +216,7 @@ struct DerivativesData FW4LWpCDerivativeData dfW_4_LWpC; FT1DerivativeData dfT_1; FT2DerivativeData dfT_2; + FU1KUTDerivativeData dfu_1_KuT; FU2KUpCDerivativeData dfu_2_KupC; }; diff --git a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h index c79d9e81fa8..277093d023f 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/ConstitutiveModels.h @@ -116,6 +116,7 @@ struct ConstitutiveModels FT2Model fT_2_model; FT3Model fT_3_model; + FU1KUTModel fu_1_KuT_model; FU2KUpCModel fu_2_KupC_model; }; } // namespace ConstitutiveRelations diff --git a/ProcessLib/TH2M/ConstitutiveRelations/UEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/UEquation.cpp index 07f391f74d8..dcea844e0a4 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/UEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/UEquation.cpp @@ -13,6 +13,19 @@ namespace ProcessLib::TH2M { namespace ConstitutiveRelations { +template +void FU1KUTModel::dEval( + SolidMechanicsDataStateless const& s_mech_data, + SolidThermalExpansionData const& s_therm_exp_data, + FU1KUTDerivativeData& dfu_1_KuT) const +{ + dfu_1_KuT.dT = s_mech_data.stiffness_tensor * + s_therm_exp_data.solid_linear_thermal_expansivity_vector; +} + +template struct FU1KUTModel<2>; +template struct FU1KUTModel<3>; + void FU2KUpCModel::eval(BiotData const& biot_data, BishopsData const& chi_S_L, FU2KUpCData& fu_2_KupC) const diff --git a/ProcessLib/TH2M/ConstitutiveRelations/UEquation.h b/ProcessLib/TH2M/ConstitutiveRelations/UEquation.h index bffa79f508b..70388bf50d2 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/UEquation.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/UEquation.h @@ -13,11 +13,31 @@ #include "Biot.h" #include "Bishops.h" #include "Saturation.h" +#include "SolidMechanics.h" +#include "SolidThermalExpansion.h" namespace ProcessLib::TH2M { namespace ConstitutiveRelations { +template +struct FU1KUTDerivativeData +{ + KelvinVector dT; +}; + +template +struct FU1KUTModel +{ + void dEval( + SolidMechanicsDataStateless const& s_mech_data, + SolidThermalExpansionData const& s_therm_exp_data, + FU1KUTDerivativeData& dfu_1_KuT) const; +}; + +extern template struct FU1KUTModel<2>; +extern template struct FU1KUTModel<3>; + struct FU2KUpCData { double m = nan; diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index 3e0beb96ac3..a571f7ff8ea 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -489,6 +489,9 @@ TH2MLocalAssembler> const& + ip_constitutive_data, std::vector< ConstitutiveRelations::ConstitutiveTempData> const& ip_constitutive_variables, @@ -524,6 +527,7 @@ TH2MLocalAssembleroutput_data_[ip]; auto const& current_state = this->current_states_[ip]; @@ -714,6 +718,9 @@ TH2MLocalAssembler(local_x.data(), local_x.size()), Eigen::Map(local_x_prev.data(), local_x_prev.size()), - t, dt, ip_constitutive_variables, models); + t, dt, ip_constitutive_data, ip_constitutive_variables, models); for (unsigned int_point = 0; int_point < n_integration_points; int_point++) { @@ -1781,11 +1788,7 @@ void TH2MLocalAssembler( displacement_index, temperature_index) - .noalias() -= - BuT * - (ip_cd.s_mech_data.stiffness_tensor * - ip_cv.s_therm_exp_data.solid_linear_thermal_expansivity_vector) * - NT * w; + .noalias() -= BuT * ip_dd.dfu_1_KuT.dT * NT * w; /* TODO (naumov) Test with gravity needed to check this Jacobian part. local_Jac diff --git a/ProcessLib/TH2M/TH2MFEM.h b/ProcessLib/TH2M/TH2MFEM.h index 1ea5fcb3559..bad9ef32fd5 100644 --- a/ProcessLib/TH2M/TH2MFEM.h +++ b/ProcessLib/TH2M/TH2MFEM.h @@ -202,6 +202,9 @@ class TH2MLocalAssembler : public LocalAssemblerInterface updateConstitutiveVariablesDerivatives( Eigen::VectorXd const& local_x, Eigen::VectorXd const& local_x_prev, double const t, double const dt, + std::vector< + ConstitutiveRelations::ConstitutiveData> const& + ip_constitutive_data, std::vector< ConstitutiveRelations::ConstitutiveTempData> const& ip_constitutive_variables, From f7addd7476c57b4854188b8b3029bc1d92f38da0 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Wed, 17 Apr 2024 20:11:47 +0200 Subject: [PATCH 44/45] [PL/TH2M] Extract Bu^T*m*N and N^T*N products This reduces number of Eigen's template instantiations and also significantly helps with the runtime performance. --- ProcessLib/TH2M/TH2MFEM-impl.h | 183 ++++++++++++++++----------------- 1 file changed, 89 insertions(+), 94 deletions(-) diff --git a/ProcessLib/TH2M/TH2MFEM-impl.h b/ProcessLib/TH2M/TH2MFEM-impl.h index a571f7ff8ea..154248a716b 100644 --- a/ProcessLib/TH2M/TH2MFEM-impl.h +++ b/ProcessLib/TH2M/TH2MFEM-impl.h @@ -1079,7 +1079,8 @@ void TH2MLocalAssembler< typename BMatricesType::BMatrixType>( gradNu, Nu, x_coord, this->is_axially_symmetric_); - auto const BuT = Bu.transpose().eval(); + auto const NTN = (Np.transpose() * Np).eval(); + auto const BTI2N = (Bu.transpose() * Invariants::identity2 * Np).eval(); double const pCap = Np.dot(capillary_pressure); double const pCap_prev = Np.dot(capillary_pressure_prev); @@ -1093,21 +1094,20 @@ void TH2MLocalAssembler< // C-component equation // --------------------------------------------------------------------- - MCpG.noalias() += NpT * ip_cv.fC_4_MCpG.m * Np * w; - MCpC.noalias() += NpT * ip_cv.fC_4_MCpC.m * Np * w; + MCpG.noalias() += NTN * (ip_cv.fC_4_MCpG.m * w); + MCpC.noalias() += NTN * (ip_cv.fC_4_MCpC.m * w); if (this->process_data_.apply_mass_lumping) { if (pCap - pCap_prev != 0.) // avoid division by Zero { MCpC.noalias() += - NpT * ip_cv.fC_4_MCpC.ml / (pCap - pCap_prev) * Np * w; + NTN * (ip_cv.fC_4_MCpC.ml / (pCap - pCap_prev) * w); } } - MCT.noalias() += NpT * ip_cv.fC_4_MCT.m * Np * w; - MCu.noalias() += NpT * Invariants::identity2.transpose() * Bu * - (ip_cv.fC_4_MCu.m * w); + MCT.noalias() += NTN * (ip_cv.fC_4_MCT.m * w); + MCu.noalias() += BTI2N.transpose() * (ip_cv.fC_4_MCu.m * w); LCpG.noalias() += gradNpT * ip_cv.fC_4_LCpG.L * gradNp * w; @@ -1119,31 +1119,30 @@ void TH2MLocalAssembler< if (!this->process_data_.apply_mass_lumping) { - fC.noalias() -= NpT * ip_cv.fC_2a.a * s_L_dot * w; + fC.noalias() -= NpT * (ip_cv.fC_2a.a * s_L_dot * w); } // fC_III - fC.noalias() -= NpT * ip_out.porosity_data.phi * ip_cv.fC_3a.a * w; + fC.noalias() -= NpT * (ip_out.porosity_data.phi * ip_cv.fC_3a.a * w); // --------------------------------------------------------------------- // W-component equation // --------------------------------------------------------------------- - MWpG.noalias() += NpT * ip_cv.fW_4_MWpG.m * Np * w; - MWpC.noalias() += NpT * ip_cv.fW_4_MWpC.m * Np * w; + MWpG.noalias() += NTN * (ip_cv.fW_4_MWpG.m * w); + MWpC.noalias() += NTN * (ip_cv.fW_4_MWpC.m * w); if (this->process_data_.apply_mass_lumping) { if (pCap - pCap_prev != 0.) // avoid division by Zero { MWpC.noalias() += - NpT * ip_cv.fW_4_MWpC.ml / (pCap - pCap_prev) * Np * w; + NTN * (ip_cv.fW_4_MWpC.ml / (pCap - pCap_prev) * w); } } - MWT.noalias() += NpT * ip_cv.fW_4_MWT.m * Np * w; + MWT.noalias() += NTN * (ip_cv.fW_4_MWT.m * w); - MWu.noalias() += NpT * Invariants::identity2.transpose() * Bu * - (ip_cv.fW_4_MWu.m * w); + MWu.noalias() += BTI2N.transpose() * (ip_cv.fW_4_MWu.m * w); LWpG.noalias() += gradNpT * ip_cv.fW_4_LWpG.L * gradNp * w; @@ -1155,42 +1154,40 @@ void TH2MLocalAssembler< if (!this->process_data_.apply_mass_lumping) { - fW.noalias() -= NpT * ip_cv.fW_2.a * s_L_dot * w; + fW.noalias() -= NpT * (ip_cv.fW_2.a * s_L_dot * w); } - fW.noalias() -= NpT * ip_out.porosity_data.phi * ip_cv.fW_3a.a * w; + fW.noalias() -= NpT * (ip_out.porosity_data.phi * ip_cv.fW_3a.a * w); // --------------------------------------------------------------------- // - temperature equation // --------------------------------------------------------------------- MTu.noalias() += - NTT * Invariants::identity2.transpose() * Bu * + BTI2N.transpose() * (ip_cv.effective_volumetric_enthalpy_data.rho_h_eff * w); KTT.noalias() += gradNTT * ip_cv.thermal_conductivity_data.lambda * gradNT * w; - fT.noalias() -= NTT * ip_cv.fT_1.m * w; + fT.noalias() -= NTT * (ip_cv.fT_1.m * w); fT.noalias() += gradNTT * ip_cv.fT_2.A * w; fT.noalias() += gradNTT * ip_cv.fT_3.gradN * w; - fT.noalias() += NTT * ip_cv.fT_3.N * w; + fT.noalias() += NTT * (ip_cv.fT_3.N * w); // --------------------------------------------------------------------- // - displacement equation // --------------------------------------------------------------------- - KUpG.noalias() -= - BuT * Invariants::identity2 * Np * (ip_cv.biot_data() * w); + KUpG.noalias() -= BTI2N * (ip_cv.biot_data() * w); - KUpC.noalias() += - BuT * Invariants::identity2 * Np * (ip_cv.fu_2_KupC.m * w); + KUpC.noalias() += BTI2N * (ip_cv.fu_2_KupC.m * w); fU.noalias() -= - (BuT * current_state.eff_stress_data.sigma - + (Bu.transpose() * current_state.eff_stress_data.sigma - N_u_op(Nu).transpose() * ip_cv.volumetric_body_force()) * w; @@ -1391,7 +1388,8 @@ void TH2MLocalAssembler( gradNu, Nu, x_coord, this->is_axially_symmetric_); - auto const BuT = Bu.transpose().eval(); + auto const NTN = (Np.transpose() * Np).eval(); + auto const BTI2N = (Bu.transpose() * Invariants::identity2 * Np).eval(); double const div_u_dot = Invariants::trace(Bu * (displacement - displacement_prev) / dt); @@ -1417,32 +1415,31 @@ void TH2MLocalAssemblerprocess_data_.apply_mass_lumping) { if (pCap - pCap_prev != 0.) // avoid division by Zero { MCpC.noalias() += - NpT * ip_cv.fC_4_MCpC.ml / (pCap - pCap_prev) * Np * w; + NTN * (ip_cv.fC_4_MCpC.ml / (pCap - pCap_prev) * w); } } - MCT.noalias() += NpT * ip_cv.fC_4_MCT.m * Np * w; + MCT.noalias() += NTN * (ip_cv.fC_4_MCT.m * w); // d (fC_4_MCT * T_dot)/d T local_Jac .template block(C_index, temperature_index) - .noalias() += NpT * ip_dd.dfC_4_MCT.dT * (T - T_prev) / dt * NT * w; + .noalias() += NTN * (ip_dd.dfC_4_MCT.dT * (T - T_prev) / dt * w); - MCu.noalias() += NpT * Invariants::identity2.transpose() * Bu * - (ip_cv.fC_4_MCu.m * w); + MCu.noalias() += BTI2N.transpose() * (ip_cv.fC_4_MCu.m * w); // d (fC_4_MCu * u_dot)/d T local_Jac .template block(C_index, temperature_index) - .noalias() += NpT * ip_dd.dfC_4_MCu.dT * div_u_dot * NT * w; + .noalias() += NTN * (ip_dd.dfC_4_MCu.dT * div_u_dot * w); LCpG.noalias() += gradNpT * ip_cv.fC_4_LCpG.L * gradNp * w; @@ -1462,14 +1459,14 @@ void TH2MLocalAssembler(C_index, C_index).noalias() += - NpT * ip_dd.dfC_4_MCpG.dp_GR * (pGR - pGR_prev) / dt * Np * w; + NTN * (ip_dd.dfC_4_MCpG.dp_GR * (pGR - pGR_prev) / dt * w); // d (fC_4_MCpG * p_GR_dot)/d T local_Jac .template block(C_index, temperature_index) .noalias() += - NpT * ip_dd.dfC_4_MCpG.dT * (pGR - pGR_prev) / dt * NT * w; + NTN * (ip_dd.dfC_4_MCpG.dT * (pGR - pGR_prev) / dt * w); LCpC.noalias() -= gradNpT * ip_cv.fC_4_LCpC.L * gradNp * w; @@ -1495,65 +1492,65 @@ void TH2MLocalAssemblerprocess_data_.apply_mass_lumping) { // fC_2 = \int a * s_L_dot - fC.noalias() -= NpT * ip_cv.fC_2a.a * s_L_dot * w; + fC.noalias() -= NpT * (ip_cv.fC_2a.a * s_L_dot * w); local_Jac.template block(C_index, C_index) - .noalias() += NpT * - (ip_dd.dfC_2a.dp_GR * s_L_dot - /*- ip_cv.fC_2a.a * (ds_L_dp_GR = 0) / dt*/) * - Np * w; + .noalias() += + NTN * ((ip_dd.dfC_2a.dp_GR * s_L_dot + /*- ip_cv.fC_2a.a * (ds_L_dp_GR = 0) / dt*/) * + w); local_Jac.template block(C_index, W_index) - .noalias() += NpT * - (ip_dd.dfC_2a.dp_cap * s_L_dot + - ip_cv.fC_2a.a * ip_dd.dS_L_dp_cap() / dt) * - Np * w; + .noalias() += + NTN * ((ip_dd.dfC_2a.dp_cap * s_L_dot + + ip_cv.fC_2a.a * ip_dd.dS_L_dp_cap() / dt) * + w); local_Jac .template block(C_index, temperature_index) - .noalias() += NpT * ip_dd.dfC_2a.dT * s_L_dot * NT * w; + .noalias() += NTN * (ip_dd.dfC_2a.dT * s_L_dot * w); } { // fC_3 = \int phi * a - fC.noalias() -= NpT * ip_out.porosity_data.phi * ip_cv.fC_3a.a * w; + fC.noalias() -= + NpT * (ip_out.porosity_data.phi * ip_cv.fC_3a.a * w); local_Jac.template block(C_index, C_index) .noalias() += - NpT * ip_out.porosity_data.phi * ip_dd.dfC_3a.dp_GR * Np * w; + NTN * (ip_out.porosity_data.phi * ip_dd.dfC_3a.dp_GR * w); local_Jac.template block(C_index, W_index) .noalias() += - NpT * ip_out.porosity_data.phi * ip_dd.dfC_3a.dp_cap * Np * w; + NTN * (ip_out.porosity_data.phi * ip_dd.dfC_3a.dp_cap * w); local_Jac .template block(C_index, temperature_index) - .noalias() += NpT * - (ip_dd.porosity_d_data.dphi_dT * ip_cv.fC_3a.a + - ip_out.porosity_data.phi * ip_dd.dfC_3a.dT) * - NT * w; + .noalias() += + NTN * ((ip_dd.porosity_d_data.dphi_dT * ip_cv.fC_3a.a + + ip_out.porosity_data.phi * ip_dd.dfC_3a.dT) * + w); } // --------------------------------------------------------------------- // W-component equation // --------------------------------------------------------------------- - MWpG.noalias() += NpT * ip_cv.fW_4_MWpG.m * Np * w; - MWpC.noalias() += NpT * ip_cv.fW_4_MWpC.m * Np * w; + MWpG.noalias() += NTN * (ip_cv.fW_4_MWpG.m * w); + MWpC.noalias() += NTN * (ip_cv.fW_4_MWpC.m * w); if (this->process_data_.apply_mass_lumping) { if (pCap - pCap_prev != 0.) // avoid division by Zero { MWpC.noalias() += - NpT * ip_cv.fW_4_MWpC.ml / (pCap - pCap_prev) * Np * w; + NTN * (ip_cv.fW_4_MWpC.ml / (pCap - pCap_prev) * w); } } - MWT.noalias() += NpT * ip_cv.fW_4_MWT.m * Np * w; + MWT.noalias() += NTN * (ip_cv.fW_4_MWT.m * w); - MWu.noalias() += NpT * Invariants::identity2.transpose() * Bu * - (ip_cv.fW_4_MWu.m * w); + MWu.noalias() += BTI2N.transpose() * (ip_cv.fW_4_MWu.m * w); LWpG.noalias() += gradNpT * ip_cv.fW_4_LWpG.L * gradNp * w; @@ -1591,49 +1588,48 @@ void TH2MLocalAssemblerprocess_data_.apply_mass_lumping) { - fW.noalias() -= NpT * ip_cv.fW_2.a * s_L_dot * w; + fW.noalias() -= NpT * (ip_cv.fW_2.a * s_L_dot * w); local_Jac.template block(W_index, C_index) - .noalias() += NpT * ip_dd.dfW_2.dp_GR * s_L_dot * Np * w; + .noalias() += NTN * (ip_dd.dfW_2.dp_GR * s_L_dot * w); // sign negated because of dp_cap = -dp_LR // TODO (naumov) Had to change the sign to get equal Jacobian WW // blocks in A2 Test. Where is the error? local_Jac.template block(W_index, W_index) - .noalias() += NpT * - (ip_dd.dfW_2.dp_cap * s_L_dot + - ip_cv.fW_2.a * ip_dd.dS_L_dp_cap() / dt) * - Np * w; + .noalias() += NTN * ((ip_dd.dfW_2.dp_cap * s_L_dot + + ip_cv.fW_2.a * ip_dd.dS_L_dp_cap() / dt) * + w); local_Jac .template block(W_index, temperature_index) - .noalias() += NpT * ip_dd.dfW_2.dT * s_L_dot * Np * w; + .noalias() += NTN * (ip_dd.dfW_2.dT * s_L_dot * w); } // fW_3 = \int phi * a - fW.noalias() -= NpT * ip_out.porosity_data.phi * ip_cv.fW_3a.a * w; + fW.noalias() -= NpT * (ip_out.porosity_data.phi * ip_cv.fW_3a.a * w); local_Jac.template block(W_index, C_index).noalias() += - NpT * ip_out.porosity_data.phi * ip_dd.dfW_3a.dp_GR * Np * w; + NTN * (ip_out.porosity_data.phi * ip_dd.dfW_3a.dp_GR * w); local_Jac.template block(W_index, W_index).noalias() += - NpT * ip_out.porosity_data.phi * ip_dd.dfW_3a.dp_cap * Np * w; + NTN * (ip_out.porosity_data.phi * ip_dd.dfW_3a.dp_cap * w); local_Jac .template block(W_index, temperature_index) - .noalias() += NpT * - (ip_dd.porosity_d_data.dphi_dT * ip_cv.fW_3a.a + - ip_out.porosity_data.phi * ip_dd.dfW_3a.dT) * - NT * w; + .noalias() += + NTN * ((ip_dd.porosity_d_data.dphi_dT * ip_cv.fW_3a.a + + ip_out.porosity_data.phi * ip_dd.dfW_3a.dT) * + w); // --------------------------------------------------------------------- // - temperature equation // --------------------------------------------------------------------- MTu.noalias() += - NTT * Invariants::identity2.transpose() * Bu * + BTI2N.transpose() * (ip_cv.effective_volumetric_enthalpy_data.rho_h_eff * w); // dfT_4/dp_GR @@ -1642,8 +1638,8 @@ void TH2MLocalAssembler(temperature_index, C_index) .noalias() += - NTT * ip_dd.effective_volumetric_enthalpy_d_data.drho_h_eff_dp_GR * - div_u_dot * NT * w; + NTN * (ip_dd.effective_volumetric_enthalpy_d_data.drho_h_eff_dp_GR * + div_u_dot * w); // dfT_4/dp_cap // d (MTu * u_dot)/dp_cap @@ -1651,8 +1647,9 @@ void TH2MLocalAssembler(temperature_index, W_index) .noalias() -= - NTT * ip_dd.effective_volumetric_enthalpy_d_data.drho_h_eff_dp_cap * - div_u_dot * NT * w; + NTN * + (ip_dd.effective_volumetric_enthalpy_d_data.drho_h_eff_dp_cap * + div_u_dot * w); // dfT_4/dT // d (MTu * u_dot)/dT @@ -1660,8 +1657,8 @@ void TH2MLocalAssembler( temperature_index, temperature_index) .noalias() += - NTT * ip_dd.effective_volumetric_enthalpy_d_data.drho_h_eff_dT * - div_u_dot * NT * w; + NTN * (ip_dd.effective_volumetric_enthalpy_d_data.drho_h_eff_dT * + div_u_dot * w); KTT.noalias() += gradNTT * ip_cv.thermal_conductivity_data.lambda * gradNT * w; @@ -1697,26 +1694,26 @@ void TH2MLocalAssembler(temperature_index, C_index) - .noalias() += NpT * Np * (ip_dd.dfT_1.dp_GR * w); + .noalias() += NTN * (ip_dd.dfT_1.dp_GR * w); // dfT_1/dp_cap local_Jac .template block(temperature_index, W_index) - .noalias() += NpT * Np * (ip_dd.dfT_1.dp_cap * w); + .noalias() += NTN * (ip_dd.dfT_1.dp_cap * w); // dfT_1/dT // MTT local_Jac .template block( temperature_index, temperature_index) - .noalias() += NTT * NT * (ip_dd.dfT_1.dT * w); + .noalias() += NTN * (ip_dd.dfT_1.dT * w); // fT_2 fT.noalias() += gradNTT * ip_cv.fT_2.A * w; @@ -1748,7 +1745,7 @@ void TH2MLocalAssembler(displacement_index, W_index) - .noalias() += - BuT * Invariants::identity2 * Np * (ip_dd.dfu_2_KupC.dp_cap * w); + .noalias() += BTI2N * (ip_dd.dfu_2_KupC.dp_cap * w); local_Jac .template block( displacement_index, displacement_index) - .noalias() += BuT * ip_cd.s_mech_data.stiffness_tensor * Bu * w; + .noalias() += + Bu.transpose() * ip_cd.s_mech_data.stiffness_tensor * Bu * w; // fU_1 fU.noalias() -= - (BuT * current_state.eff_stress_data.sigma - + (Bu.transpose() * current_state.eff_stress_data.sigma - N_u_op(Nu).transpose() * ip_cv.volumetric_body_force()) * w; @@ -1788,7 +1783,7 @@ void TH2MLocalAssembler( displacement_index, temperature_index) - .noalias() -= BuT * ip_dd.dfu_1_KuT.dT * NT * w; + .noalias() -= Bu.transpose() * ip_dd.dfu_1_KuT.dT * NT * w; /* TODO (naumov) Test with gravity needed to check this Jacobian part. local_Jac From 28210bb9be062c69f7fb4d17bd169799edb92c19 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Sun, 21 Apr 2024 13:05:04 +0200 Subject: [PATCH 45/45] [PL/TH2M] Remove incorrect commented fW_2_LWpC The original implementation in the assembleWithJacobian sneaked in erroneously. Though the dmxWL/dpLR is possible, but through the code only primary variables derivatives are used, p_GR and p_cap. --- .../TH2M/ConstitutiveRelations/PhaseTransitionData.h | 4 ---- ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp | 7 ------- 2 files changed, 11 deletions(-) diff --git a/ProcessLib/TH2M/ConstitutiveRelations/PhaseTransitionData.h b/ProcessLib/TH2M/ConstitutiveRelations/PhaseTransitionData.h index a0042c6afbb..b6e27f07574 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/PhaseTransitionData.h +++ b/ProcessLib/TH2M/ConstitutiveRelations/PhaseTransitionData.h @@ -51,10 +51,6 @@ struct PhaseTransitionData double dxmWL_dpGR = nan; double dxmWL_dpCap = nan; double dxmWL_dT = nan; - // TODO (naumov) This is zero in both models but used in the assembly. - // Remove it and simplify assembly or correct the expressions in the phase - // transition models? - static constexpr double dxmWL_dpLR = 0.; double diffusion_coefficient_vapour = nan; double diffusion_coefficient_solute = nan; diff --git a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp index 8f8d2121976..370e22cd5d0 100644 --- a/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp +++ b/ProcessLib/TH2M/ConstitutiveRelations/WEquation.cpp @@ -280,13 +280,6 @@ void FW4LWpCModel::eval( Eigen::Matrix::Identity(); fW_4_LWpC.L.noalias() = diffusion_W_pCap * I - advection_data.advection_W_L; - - // Jac wrong? - // double const diffusion_W_L_p = phi_L * fluid_density_data.rho_LR * sD_L * - // phase_transition_data.dxmWL_dpLR; - // - // fW_4_LWpC.L.noalias() = diffusion_W_L_p * I + - // advection_data.advection_W_L; } template