-
Notifications
You must be signed in to change notification settings - Fork 987
Implementing variable density for unsteady incompressible flow #2641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
509a608
6aeb0a3
79e238c
526b9a1
59979d0
99abfa4
bee5a27
cea69cc
a721a2e
02c03bb
0449bb4
572291f
c9fd0f6
fc33c6a
644a543
fed4892
8e09f7f
1e5008a
2aebc54
3f19c55
f5b3f56
735c27b
f9f98a0
adf7581
cc06d7e
6f2a8eb
fa318d2
3e1b898
87a3381
b278ad6
dda9271
ff74a7f
c194c4f
ac17146
35b018f
d14be6e
6cc4073
83c3416
459e3b4
630856b
35ad976
31f8af3
00ae736
8a47539
4f7a656
df27a84
51f18af
524fd46
acfe778
adedf6b
69833df
89661d4
df28101
2308622
d529abe
02c3311
2364e90
d4c5d18
7899323
b355867
76d652c
100c2cb
1562607
b8e840a
ec308a5
a7ab5b7
4f5cdfa
0f538ea
d12f7b3
de4a95b
f7775f0
7905679
b2a9094
f10305e
f5e0e34
b71c7ff
b359140
5f7e34d
3a7553e
663105f
c25ac53
3573190
110d585
ec56eb3
2e5ccec
3ea82e7
afdc9d5
c40865f
8cc8bbe
879d3ba
c9c2c82
40c4f72
42eee98
6b9c7ac
cffd048
08325f0
dfdba2f
e238ab2
d406376
0a5e693
820cb75
4be14fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -347,6 +347,16 @@ class CSolver { | |
| */ | ||
| inline virtual CFluidModel* GetFluidModel(void) const { return nullptr;} | ||
|
|
||
| /*! | ||
| * \brief Virtual function returning whether this is the species solver. | ||
| */ | ||
| inline virtual bool IsSpeciesSolver() const { return false; } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two virtuals don't belong on the |
||
|
|
||
| /*! | ||
| * \brief Virtual function returning whether this is the turbulent solver. | ||
| */ | ||
| inline virtual bool IsTurbSolver() const { return false; } | ||
|
|
||
| /*! | ||
| * \brief Get number of linear solver iterations. | ||
| * \return Number of linear solver iterations. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -270,4 +270,26 @@ class CFlowVariable : public CVariable { | |
| * \return Vector of magnitudes. | ||
| */ | ||
| inline su2activevector& GetStrainMag() { return StrainMag; } | ||
|
|
||
| /*! | ||
| * \brief Get the density at time level n for dual-time stepping (compressible flows). | ||
| * For compressible flows, density is extracted from the solution container. | ||
| * For incompressible flows, this is overridden. | ||
| * \param[in] iPoint - Point index. | ||
| * \return Density at time level n. | ||
| */ | ||
| inline virtual su2double GetDensity_time_n(unsigned long iPoint) const { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two things here:
|
||
| return GetSolution_time_n(iPoint, 0); // Density is the first component of Solution | ||
| } | ||
|
|
||
| /*! | ||
| * \brief Get the density at time level n-1 for dual-time stepping (compressible flows). | ||
| * For compressible flows, density is extracted from the solution container. | ||
| * For incompressible flows, this is overridden. | ||
| * \param[in] iPoint - Point index. | ||
| * \return Density at time level n-1. | ||
| */ | ||
| inline virtual su2double GetDensity_time_n1(unsigned long iPoint) const { | ||
| return GetSolution_time_n1(iPoint, 0); // Density is the first component of Solution | ||
| } | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,8 @@ class CIncEulerVariable : public CFlowVariable { | |
|
|
||
| VectorType Streamwise_Periodic_RecoveredPressure, /*!< \brief Recovered/Physical pressure [Pa] for streamwise periodic flow. */ | ||
| Streamwise_Periodic_RecoveredTemperature; /*!< \brief Recovered/Physical temperature [K] for streamwise periodic flow. */ | ||
| VectorType Density_time_n, /*!< \brief Density at time n for dual-time stepping. */ | ||
| Density_time_n1; /*!< \brief Density at time n-1 for dual-time stepping. */ | ||
|
pcarruscag marked this conversation as resolved.
|
||
| su2double TemperatureLimits[2]; /*!< \brief Temperature limits [K]. */ | ||
| public: | ||
| /*! | ||
|
|
@@ -87,6 +89,16 @@ class CIncEulerVariable : public CFlowVariable { | |
| CIncEulerVariable(su2double pressure, const su2double *velocity, su2double enthalpy, | ||
| unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig *config); | ||
|
|
||
| /*! | ||
| * \brief Set all the solution at time level n to the current solution value (including density). | ||
| */ | ||
| void Set_Solution_time_n() override; | ||
|
|
||
| /*! | ||
| * \brief Set all the solution at time level n-1 to the solution at time level n (including density). | ||
| */ | ||
| void Set_Solution_time_n1() override; | ||
|
|
||
| /*! | ||
| * \brief Set the value of the pressure. | ||
| * \param[in] iPoint - Point index. | ||
|
|
@@ -291,4 +303,74 @@ class CIncEulerVariable : public CFlowVariable { | |
| for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution(iPoint, iDim+1) = val_vector[iDim]; | ||
| } | ||
|
|
||
| /*! | ||
| * \brief Get the density at time level n for dual-time stepping. | ||
| * \param[in] iPoint - Point index. | ||
| * \return Density at time level n. | ||
| */ | ||
| inline su2double GetDensity_time_n(unsigned long iPoint) const override { | ||
| return Density_time_n.size() > 0 ? Density_time_n(iPoint) : GetDensity(iPoint); | ||
| } | ||
|
Comment on lines
+311
to
+313
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pcarruscag like this? |
||
|
|
||
| /*! | ||
| * \brief Get the density at time level n-1 for dual-time stepping. | ||
| * \param[in] iPoint - Point index. | ||
| * \return Density at time level n-1. | ||
| */ | ||
| inline su2double GetDensity_time_n1(unsigned long iPoint) const override { | ||
| return Density_time_n1.size() > 0 ? Density_time_n1(iPoint) : GetDensity(iPoint); | ||
| } | ||
|
|
||
| /*! | ||
| * \brief Set the density at time level n for dual-time stepping. | ||
| * \param[in] iPoint - Point index. | ||
| * \param[in] val_density - Density value. | ||
| */ | ||
| inline void SetDensity_time_n(unsigned long iPoint, su2double val_density) { Density_time_n(iPoint) = val_density; } | ||
|
|
||
| /*! | ||
| * \brief Set the density at time level n-1 for dual-time stepping. | ||
| * \param[in] iPoint - Point index. | ||
| * \param[in] val_density - Density value. | ||
| */ | ||
| inline void SetDensity_time_n1(unsigned long iPoint, su2double val_density) { Density_time_n1(iPoint) = val_density; } | ||
|
|
||
| /*! | ||
| * \brief Register solution at time n, including the density container for incompressible flows. | ||
| */ | ||
| void RegisterSolution_time_n() override; | ||
|
|
||
| /*! | ||
| * \brief Register solution at time n-1, including the density container for incompressible flows. | ||
| */ | ||
| void RegisterSolution_time_n1() override; | ||
|
|
||
| /*! | ||
| * \brief Get the adjoint of density at time n. | ||
| * Simplified version: directly extracts the AD derivative of Density_time_n, | ||
|
bigfooted marked this conversation as resolved.
|
||
| * analogous to GetAdjointSolution_time_n for the solution vector. | ||
| * The chain-rule contribution d(rho)/d(h) is currently not applied (TODO). | ||
| * \param[in] iPoint - Point index. | ||
| * \return Adjoint of the density at time n. | ||
| */ | ||
| inline su2double GetAdjointDensity_time_n(unsigned long iPoint) const override { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if (Density_time_n.size() == 0) return 0.0; // Constant density - no adjoint contribution | ||
| AD::Identifier index = AD::GetPassiveIndex(); | ||
| AD::SetIndex(index, Density_time_n(iPoint)); | ||
| return AD::GetDerivative(index); | ||
| } | ||
|
|
||
| /*! | ||
| * \brief Get the adjoint of density at time n-1. | ||
| * See GetAdjointDensity_time_n. | ||
| * \param[in] iPoint - Point index. | ||
| * \return Adjoint of the density at time n-1. | ||
| */ | ||
| inline su2double GetAdjointDensity_time_n1(unsigned long iPoint) const override { | ||
| if (Density_time_n1.size() == 0) return 0.0; // Constant density - no adjoint contribution | ||
| AD::Identifier index = AD::GetPassiveIndex(); | ||
| AD::SetIndex(index, Density_time_n1(iPoint)); | ||
| return AD::GetDerivative(index); | ||
| } | ||
|
|
||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.