|
[Sponsors] |
![]() |
![]() |
#1 |
New Member
Jose
Join Date: Dec 2017
Location: Madrid
Posts: 6
Rep Power: 9 ![]() |
Hello,
I'm trying to code the adjoint method for the unsteady heat equation in OpenFOAM. I am able to solve the forward problem, but I'm having some trouble with the backwards problem. Actually, I don't know how to tell OpenFoam to solve a problem backwards in time, I've tried something like runTime--, but apparently this doesn't make sense to OF. Any idea on this? Another option I'm thinking about is to solve the adjoint problem forward in time by means of a change of variable like tau = T - t. However, in this case I have to reverse the contents in the time folders, so that data files in folder 0 go to folder T, data files in folder 1 go to folder T - 1, and so on... How could I achieve this? Thank you. |
|
![]() |
![]() |
![]() |
![]() |
#2 |
New Member
Jose
Join Date: Dec 2017
Location: Madrid
Posts: 6
Rep Power: 9 ![]() |
I have tried the second option, reading the volScalarFields in reverse direction and saving the result. This way I can solve the adjoint problem in forward direction. However, probably there are more elegant ways of doing so, I would appreciate if someone could give some hints.
By the way, maybe this thread should go in the "Programming & Development" sub-forum, but I don't know how to move it. writeAdjointSourceTerm.H Code:
// Reverse source term in the adjoint equation instantList Times = runTime.times(); scalar nTimes = Times.size() - 1; for (label i = 1; i <= nTimes; i++) { runTime.setTime(Times[nTimes - i + 1], nTimes - i + 1); volScalarField T ( IOobject ( "T", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ), mesh ); volScalarField Td ( IOobject ( "Td", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ), mesh ); runTime.setTime(Times[i], i); volScalarField g ( IOobject ( "g", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), T - Td ); g.write(); }
__________________
Jose |
|
![]() |
![]() |
![]() |
![]() |
#3 | |
New Member
Chuangxin HE
Join Date: Apr 2016
Posts: 3
Rep Power: 10 ![]() |
Did you try using a negative time step? I find it works.
Quote:
|
||
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
AMI speed performance | danny123 | OpenFOAM | 21 | October 24, 2020 05:13 |
pressure in incompressible solvers e.g. simpleFoam | chrizzl | OpenFOAM Running, Solving & CFD | 13 | March 28, 2017 06:49 |
Micro Scale Pore, icoFoam | gooya_kabir | OpenFOAM Running, Solving & CFD | 2 | November 2, 2013 14:58 |
How to write k and epsilon before the abnormal end | xiuying | OpenFOAM Running, Solving & CFD | 8 | August 27, 2013 16:33 |
plot over time | fferroni | OpenFOAM Post-Processing | 7 | June 8, 2012 08:56 |