|
[Sponsors] |
Adding Custom Source Terms to Euler Equations |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 15, 2020, 15:58 |
Adding Custom Source Terms to Euler Equations
|
#1 |
New Member
Gabriel Giampa
Join Date: Jun 2020
Posts: 1
Rep Power: 0 |
Hi all,
I'm new to CFD and su2. I'm trying to modify the c++ code to include the presence of a gravitational source term in the compressible Euler equations (SU2 Solver: EULER). There seems to be some old posts on the forum on the topic, but from many years back, and all point to files in the source code which have either changed name or simply do not exist anymore. I know that CEulerSolver.cpp has a void CEulerSolver::Source_Template method which also informs the programmer to first implement the source term in CNumerics.cpp. Does anyone have any experience with this kind of situation? I'm not sure what kind of syntax I should be using or how exactly to implement this source term. |
|
June 16, 2020, 08:38 |
|
#2 |
Senior Member
Pedro Gomes
Join Date: Dec 2017
Posts: 466
Rep Power: 13 |
The code has that feature already, the relevant options are:
BODY_FORCE= YES BODY_FORCE_VECTOR= ( 0.0, -9.81, 0.0 ) |
|
August 18, 2020, 14:51 |
|
#3 |
New Member
Join Date: Aug 2020
Posts: 4
Rep Power: 6 |
Sorry to make this thread active again. Is there such a functionality for the heat equation?
|
|
August 18, 2020, 17:32 |
|
#4 |
Senior Member
Pedro Gomes
Join Date: Dec 2017
Posts: 466
Rep Power: 13 |
No, I don't think we have anything that acts specifically on the heat equation (of the heat solver) nor on the energy equation (of the flow solvers).
If you are open to modify the code, this is a simple thing to do. |
|
August 19, 2020, 01:26 |
|
#5 |
New Member
Join Date: Aug 2020
Posts: 4
Rep Power: 6 |
I am open to modifying the code. I just need some guidance on what to modify as I am novice at SU2.
|
|
August 19, 2020, 04:40 |
|
#6 |
Senior Member
Pedro Gomes
Join Date: Dec 2017
Posts: 466
Rep Power: 13 |
Ok, describe exactly what you want simulate and I'll tell you what to change.
|
|
August 19, 2020, 13:20 |
|
#7 |
New Member
Join Date: Aug 2020
Posts: 4
Rep Power: 6 |
Thank you for helping me out! I am looking to simulate a solid heat conduction with internal heat generation that is time varying.
|
|
August 20, 2020, 06:12 |
|
#8 |
Senior Member
Pedro Gomes
Join Date: Dec 2017
Posts: 466
Rep Power: 13 |
In CHeatSolver.hpp you need to declare the method
Code:
void Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh) override; The implementation should be placed in CHeatSolver.cpp, something like: Code:
void CHeatSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { /*--- Current time. ---*/ const auto dt = config->GetDelta_UnstTimeND(); const su2double t = config->GetTimeIter() * dt; for (auto iPoint = 0ul; iPoint < nPointDomain; iPoint++) { /*--- Some geometrical properties you may/will need. ---*/ const auto V = geometry->nodes->GetVolume(iPoint); const auto X = geometry->nodes->GetCoord(iPoint); //// x = X[0], y = X[1], z = X[2] (z does not exist in 2D) //// /*--- Temperature at this point. ---*/ const auto T = nodes->GetSolution(iPoint,0); /*--- Compute the source term. ---*/ const su2double source = ... /*--- Add the source to the residual. ---*/ LinSysRes[iPoint] += source; /*--- If your source depends on temperature you can also update the, * Jacobian matrix. Take care not to break diagonal dominance. ---*/ Jacobian.AddVal2Diag(iPoint, dsource_dT); } } If you need more help, join the Slack channel (follow the link above and click the # on the top bar) and come to one of the developers meetings (Wednesdays at 4pm CET, everyone is welcome and usually there is no agenda, so plenty of time for random questions). |
|
August 20, 2020, 13:21 |
|
#9 |
New Member
Join Date: Aug 2020
Posts: 4
Rep Power: 6 |
Wow! This is amazing! Thank you for sharing the code. I will try to implement it and let you know. Also, thank you for sharing the Slack link.
|
|
Tags |
euler equations, source term |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] swak4foam building problem | GGerber | OpenFOAM Community Contributions | 54 | April 24, 2015 17:02 |
Trouble compiling utilities using source-built OpenFOAM | Artur | OpenFOAM Programming & Development | 14 | October 29, 2013 11:59 |
centOS 5.6 : paraFoam not working | yossi | OpenFOAM Installation | 2 | October 9, 2013 02:41 |
friction forces icoFoam | ofslcm | OpenFOAM | 3 | April 7, 2012 11:57 |
Adding source terms to turbulent models | makaveli_lcf | OpenFOAM Running, Solving & CFD | 0 | June 8, 2009 10:34 |