CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

programming a subroutine inside the time loop

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 14, 2020, 12:20
Default programming a subroutine inside the time loop
  #1
New Member
 
Felix Benz
Join Date: Jan 2020
Posts: 3
Rep Power: 6
FBenz is on a distinguished road
Dear OpenFoam Users,


I am trying to implement a subroutine inside the main time loop which looks something like:



while(runTime.loop())
{
solve first equation
while (some convergence criteria)
{
solve second equation
}
}


The solver compiles and the case is working, but it seems to be that openfoam does not like it if I call solve over and over again in the same time step.



If I run the two pieces of code:

1:


while (runTime.loop())
{
dU *= (0.0,0.0,0.0);
solve
(
fvm::laplacian(mu,dU) + fvc::div(sigma) //mu, dU and sigma are just dummy fields
);
prevTime = time;
time = runTime.elapsedCpuTime();
Info << "Time needed : " << time - prevTime << nl;
}


and
2:


while(true)
{
dU *= (0.0,0.0,0.0);
solve
(
fvm::laplacian(mu,dU) + fvc::div(sigma)
);
prevTime = time;
time = runTime.elapsedCpuTime() ;
Info << "Time needed : " << time - prevTime << nl;
}


the first code will give me a constant "Time needed" as expected, while the second will increase with every iteration.
I guess runTime.loop() will kind of reset the field or the objectRegistry?


Is there a way to circumvent this problem or to access the registry manually?


Thanks in advance
Felix
FBenz is offline   Reply With Quote

Reply

Tags
run time, subroutine


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
LES, Courant Number, Crash, Sudden Alhasan OpenFOAM Running, Solving & CFD 5 November 22, 2019 03:05
Inconsistencies in reading .dat file during run time in new injection model Scram_1 OpenFOAM 0 March 23, 2018 23:29
How to export time series of variables for one point? mary mor OpenFOAM Post-Processing 8 July 19, 2017 11:54
Stuck in a Rut- interDyMFoam! xoitx OpenFOAM Running, Solving & CFD 14 March 25, 2016 08:09
Could anybody help me see this error and give help liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 19:07


All times are GMT -4. The time now is 01:04.