|
[Sponsors] |
How do I execute solve w/in a loop over which the solved variable is changing? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 9, 2013, 15:20 |
How do I execute solve w/in a loop over which the solved variable is changing?
|
#1 |
New Member
Tom Chyczewski
Join Date: Mar 2009
Location: Bethpage, New York, USA
Posts: 15
Rep Power: 17 |
I thought this would be straight forward but it is tripping me up. Any help would be appreciated.
I need to iterate a 2D (geographical space, x and y) equation for each point in wave space (say kx and ky). I thought the following would work: Code:
for (int m=0; m<nkx; ++m) { for (int n=0; n<nky; ++n) { forAll(Umn,i) { Amn[i] = wasd[m][n][i]; Umn[i].x() = U[i].x() + some f(m,n); Umn[i].y() = U[i].y() + some f(m,n); Umn[i].z() = 0.0; Smn[i] = s[m][n][i] } phi = (fvc::interpolate(Umn) & mesh.Sf()); solve ( fvm::ddt(Amn)+fvm::div(phi,Amn) == Smn ) forall(Amn,i) { wasd[m][n][i] = Amn[i]; } } } A simplified version of this problem is Code:
#include "fvCFD.H" #include "fvIOoptionList.H" #include "simpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "createFields.H" #include "createFvOptions.H" simpleControl simple(mesh); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nCalculating scalar transport\n" << endl; #include "CourantNo.H" int l; scalar DD[64]; for (l=0; l<64; ++l) { DD[l] = scalar(l+7); } for (l=0; l<64; ++l) { forAll(U,i) { T[i] = DD[l]; } Info<<"T Before "<<T[56]<<endl; solve ( fvm::ddt(T) ); Info<<"T After "<<T[56]<<endl; } return 0; } (Note that this post is an update to a post I made on 11/19) Tom |
|
December 10, 2013, 15:34 |
|
#2 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37 |
Hi Tom,
What you are running into is a been of underlying OpenFoam thing. When you are calling Code:
fvm::ddt(T) Another detail, which affect you, is that if the old time values do not exist, then they are set equal to T itself, so as you are initialising T with 0 in the solving, you are also initialising the previous time step to 0. And it stays zero for the remaining solutions. You can find the details on old time fields in: GeometricField.C Good luck, Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request. |
|
December 17, 2013, 07:26 |
|
#3 |
New Member
Tom Chyczewski
Join Date: Mar 2009
Location: Bethpage, New York, USA
Posts: 15
Rep Power: 17 |
Niels,
Thanks for your post. It was very helpful. Looks like I have some issues to resolve. Tom |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
changing scheme variable with UDF? | Wagemakers | FLUENT | 17 | September 30, 2015 14:34 |
About storing 'solve' data and changing data | zxj160 | OpenFOAM | 3 | August 1, 2013 13:37 |
Changing the unknown(target) variable in convection;From WallTemperature to HTC! | fshak92 | STAR-CCM+ | 1 | April 28, 2012 08:14 |
emag beta feature: charge density | charlotte | CFX | 4 | March 22, 2011 09:14 |
Replace periodic by inlet-outlet pair | lego | CFX | 3 | November 5, 2002 20:09 |