Skip to content
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

[WIP] Coupled solver for thermoelasticity #2404

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

Vaish-W
Copy link

@Vaish-W Vaish-W commented Dec 26, 2024

Proposed Changes

This pull request implements integration of a heat solver coupling with the FEA solver for thermoelasticity simulations.

Key Changes:

  1. CSolverFactory:

    • Added logic to instantiate the heat solver (HEAT_SOL) conditionally when WEAKLY_COUPLED_HEAT_EQUATION is enabled in the configuration.
  2. CFEAIteration:

    • Modified the Iterate function to invoke the SingleGrid_Iteration method of the heat solver before solving the FEA equations.
  3. CFEASolver:

    • Updated Preprocessing to store a pointer to the heat solver for use in FEA computations.
    • Integrated temperature handling from the heat solver in stiffness matrix and stress computations:
      • Compute_StiffMatrix
      • Compute_StiffMatrix_NodalStressRes
      • Compute_NodalStressRes
      • Compute_NodalStress
  4. Output Enhancements:

    • Extended CElasticityOutput to include temperature-related fields for coupled simulations.
    • Adapted LoadVolumeData and LoadHistoryData in CElasticityOutput to retrieve and display heat solver output such as nodal temperatures and thermal residuals.

Related Work

Continuation of work from PR #2398 and #2399

PR Checklist

Put an X by all that apply. You can fill this out after submitting the PR. If you have any questions, don't hesitate to ask! We want to help. These are a guide for you to know what the reviewers will be looking for in your contribution.

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
  • My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
  • I used the pre-commit hook to prevent dirty commits and used pre-commit run --all to format old commits.
  • I have added a test case that demonstrates my contribution, if necessary.
  • I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary.

@Vaish-W
Copy link
Author

Vaish-W commented Jan 2, 2025

While working on Compute_StiffMatrix, I noticed that NodalTemperature is not being recognized in some parts of the code. Could you clarify how NodalTemperature should be properly defined or accessed in the context of CElement or other relevant classes?

Comment on lines 697 to 698
auto nodal_temperatures = dynamic_cast<CSolver *>(heat_solver)->GetNodalTemperature();
element->SetTemperature(iNode, nodal_temperatures[indexNode[iNode]]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temperature is the solution of the heat solver, the "solution" (and other fields) are stored in CVariable classes which are the "nodes" member of the solvers.

Suggested change
auto nodal_temperatures = dynamic_cast<CSolver *>(heat_solver)->GetNodalTemperature();
element->SetTemperature(iNode, nodal_temperatures[indexNode[iNode]]);
const su2double temperature = heat_solver->GetNodes()->GetSolution(indexNode[iNode], 0);
element->SetTemperature(iNode, nodal_temperature);

@@ -28,6 +28,7 @@
#pragma once

#include "CFEASolverBase.hpp"
#include "CHeatSolver.hpp"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to include CHeatSolver anymore because you are only using the virtual interface (CSolver).

Suggested change
#include "CHeatSolver.hpp"

@Vaish-W Vaish-W force-pushed the coupled_thermoelasticity branch from f48826a to 60d7b6c Compare January 3, 2025 11:01
@Vaish-W Vaish-W requested a review from pcarruscag January 3, 2025 12:34
Tutorials Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you added this by mistake

Copy link
Member

@pcarruscag pcarruscag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, does it work?

Comment on lines 810 to 813

if (de_effects) {
de_elem->SetTemperature(iNode, temperature);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DE elements don't use temperature

Suggested change
if (de_effects) {
de_elem->SetTemperature(iNode, temperature);
}

@@ -37,6 +37,7 @@
class CElasticityOutput final: public COutput {
protected:

const CSolver *heat_solver = nullptr; //!< Pointer to the heat solver
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be a member variable, the output function have access to the solver container, see CElasticityOutput::LoadHistoryData

Comment on lines 88 to 95
/*!
* \brief Set the heat solver pointer for output integration.
* \param[in] solver - Pointer to the heat solver.
*/
void SetHeatSolver(const CSolver *solver) {
heat_solver = solver;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also not necessary

Suggested change
/*!
* \brief Set the heat solver pointer for output integration.
* \param[in] solver - Pointer to the heat solver.
*/
void SetHeatSolver(const CSolver *solver) {
heat_solver = solver;
}

Comment on lines 201 to 205
AddHistoryOutput("RMS_TEMPERATURE", "rms[T]", ScreenOutputFormat::FIXED, "RMS_RES", "Root mean square residual of the temperature", HistoryFieldType::RESIDUAL);
AddHistoryOutput("MAX_TEMPERATURE", "max[T]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the temperature", HistoryFieldType::RESIDUAL);
AddHistoryOutput("AVG_TEMPERATURE", "avg[T]", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Average temperature on all surfaces", HistoryFieldType::COEFFICIENT);
AddHistoryOutput("TOTAL_HEATFLUX", "HF", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Total heat flux on all surfaces", HistoryFieldType::COEFFICIENT);
AddHistoryOutput("MAXIMUM_HEATFLUX", "MaxHF", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Maximum heat flux on all surfaces", HistoryFieldType::COEFFICIENT);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to check if the heat solver exists here too

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also in volume output fields right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants