|
[Sponsors] |
December 30, 2012, 21:27 |
Operations during iterations
|
#1 |
Member
Martin
Join Date: Dec 2011
Location: Latvia
Posts: 54
Rep Power: 15 |
Greetings, FOAMers!
I have magnetic problem solver Code:
1. B=fvc::curl(A); 2. B2=B&B; 3. //--> calculate reluctivity (viR) using some algorithm 4. solve (viconst*viR*fvm::laplacian(A)==-fvc::curl(Hc)); 5. // move to point 1. using new A values Basically I want that these 5 steps are done during each iteration, so I could get an output similar to this Code:
DICPCG: Solving for Ax, Initial residual = 1, Final residual = 8.67698e-06, No Iterations 96 DICPCG: Solving for Ay, Initial residual = 1, Final residual = 9.81058e-06, No Iterations 101 DICPCG: Solving for Az, Initial residual = 0, Final residual = 0, No Iterations 0 Any hint would be much appreciated! Yours, Martin |
|
January 1, 2013, 07:15 |
|
#2 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 |
I do not fully understand what sets of equations you are trying to solve. Is it a time-dependent problem?
Short answer: A while loop does the job. Long answer: In case of a steady-state problem, you can just use the time-iteration as iteration over your set of equations. This is what is done in the simpleFoam solver. You can look at some of these cases and check how iterative convergence is controlled in these examples. (using residualControl). (Now rechecking the code, and simpleFoam in 2.1.1 does not explicitly call it a time-loop anymore, although the output does) If your problem is transient, you cannot misuse the time loop for that, and you should build an additional loop around your five lines of code. This what is done in the pimpleFoam solver. |
|
January 4, 2013, 13:24 |
|
#3 |
Member
Martin
Join Date: Dec 2011
Location: Latvia
Posts: 54
Rep Power: 15 |
Sweet, thanks Bernhard! I tried this before but calculation was blowing up so I was looking for different ways. Just had to rearrange order of equations and then follow your advice.
I don't want to start a new thread for a new simple question as I hope someone will reply in here. How can I write a field? But not simply like Code:
volScalarField T ( IOobject ( "T", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); Code:
volScalarField T ( IOobject ( "T", runTime.timeName(), mesh ) ); Sadly it doesn't work this simple as I understand there is need for some argument (equation). Like Code:
volScalarField T ( IOobject ( "T", runTime.timeName(), mesh ) b+a (or what ever) ); |
|
January 4, 2013, 14:28 |
|
#4 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 |
I don't understand your follow-up question. Also, writing all on one line doesn't make it clearer to read. I thought it was possible to do just something like T.write() or something like that (see e.g. the source code of potentialFoam)
|
|
January 5, 2013, 16:23 |
|
#5 |
Member
Martin
Join Date: Dec 2011
Location: Latvia
Posts: 54
Rep Power: 15 |
Sorry, was a bit tired when I wrote this question.
Lets say I define a field B in createFields.H. Code:
volVectorField B ( IOobject ( "B", runTime.timeName(), mesh ), fvc::curl(A) ); B = fvc::curl(A) and solver knows that here I want to calculate my field and afterwards it creates a nice file with all values. But I can't do this: Code:
volVectorField A ( IOobject ( "A", runTime.timeName(), mesh ) //and put nothing here ); Sorry if question seems too trivial, and I hope I explained it better. Yours, Martin |
|
January 7, 2013, 04:46 |
|
#6 |
Senior Member
Olivier
Join Date: Jun 2009
Location: France, grenoble
Posts: 272
Rep Power: 18 |
hello,
The value in createFields, like your "fvc::curl(A)" are only for initialisation, so you can put what you want (should be dimensioned correctly through). So try to provide a "good" initial guess. regards, olivier |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
High Courant Number @ icoFoam | Artex85 | OpenFOAM Running, Solving & CFD | 11 | February 16, 2017 14:40 |
Extrusion with OpenFoam problem No. Iterations 0 | Lord Kelvin | OpenFOAM Running, Solving & CFD | 8 | March 28, 2016 12:08 |
pimpleFoam: turbulence->correct(); is not executed when using residualControl | hfs | OpenFOAM Running, Solving & CFD | 3 | October 29, 2013 09:35 |
Orifice Plate with a fully developed flow - Problems with convergence | jonmec | OpenFOAM Running, Solving & CFD | 3 | July 28, 2011 06:24 |
Differences between serial and parallel runs | carsten | OpenFOAM Bugs | 11 | September 12, 2008 12:16 |