OpenFOAM function defaults to delete case directory

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

OpenFOAM function defaults to delete case directory

mgriffith
Hello,

I'm using the following function call to use the OpenFOAM solver.

[fea.sol.u,~,fea.vars] = openfoam( fea, 'application', 'simpleFoam', 'ddtScheme', 'steadyState', 'deltaT', 0.1, 'endTime', 20, 'tolres', 1e-04, 'upwind', 'linearUpwind', 'bound', 2, 'turb', struct( 'model', 'kOmegaSST', 'inlet', [0.00322804,7.72379], 'wallfcn', 1 ),'control',true,'hax',axes(),'casedir',[pwd '\Run']);

I'm looking for a steady state solution, but my residuals are pretty high 1e-3. I need to look at the max pressure and max sqrt(u^2+w^2) and see how they are changing with the number of iterations to see if they are stable and not changing to help me evaluate if the solution has converged, or is at least stable enough for my purposes. At the end of the day all I really need is the pressure drop.

I know in OpenFOAM I can set it up to store solutions however often I want, so I can inspect them while the simulation is running, but after it stops then the whole casedir is deleted, so I can't plot inspect, etc after it completes. Is there some way to prevent the deletion of the casedir? I see that I'm supposed to be able to start from a previous solution, but I can't get that to work either, because none of the previous solutions are stored.

As always thank you for your help,

Matt
Reply | Threaded
Open this post in threaded view
|

Re: OpenFOAM function defaults to delete case directory

Precise Simulation
Administrator
This argument has not been documented but I think it sould be enough to set the "clean" argument to false, as

    [...] = openfoam( fea, ..., 'clean' ,0 );

you can then either postprocess the solutions with an external tool, such as ParaView, or re-import into FEATool and Matlab by using the import mode as

    [ u, tlist, vars ] = openfoam( fea, ..., 'mode', 'import', 'casedir', 'path_to_casedir_with_solution_files' ); 
Reply | Threaded
Open this post in threaded view
|

Re: OpenFOAM function defaults to delete case directory

mgriffith
Ok. The first part worked great. After the run finished it left everything in the casedir and imported the last result. After that I tried to import a specific time, for example 10:

[ u, tlist, vars ] = openfoam( fea, 'mode', 'import', 'casedir', 'C:\Users\mgrif\Documents\eMatrix\NOHM\StructuredGrid\Straight5Channel\10' )
Array indices must be positive integers or logical values.

Error in featool

Error in featool

Error in featool

Error in featool

Error in openfoam (line 152)
[varargout{:}] = featool( 'feval', 'openfoam', varargin{:} );
 

That error is the same error I get If I try to import a folder with nothing in it. So I tried importing one level up to see what would happen maybe it would import all of the times? Well it didn't. What it did do was correctly import one of the times I don't know which one, I'm assuming the last time, and then deleted everything in the directory :( I'm guessing I would have had to add 'clean', 0 again?

before I tried this I opened up the files and took a quick look to verify the pressure had been stable for quite a while, so it is not too big of a deal, but it would be really nice to animate the steady state results like you can when I run time dependent simulation.

Maybe that is the easiest way to do what I want. Can I call openfoam so featool treats it like a transient sim, but I force it to use the simple solver instead of pimple?

Thanks for the help,

Matt
Reply | Threaded
Open this post in threaded view
|

Re: OpenFOAM function defaults to delete case directory

Precise Simulation
Administrator
The openfoam( fea, ..., 'mode', 'import' ) call looks in the (given) case directory for solutions indicated by numeric sub-directories (So you can't give a solution directory as 'casedir' parameter). If you want to import all solutions (instead of only the last one), you have to specify a non-steady state (default) analysis type (which will work during import even if your simulation is of steadyState/localEuler type), for example:

    [u,tlist,vars] = openfoam( fea, ...
                               'mode', 'import', ...
                               'ddtScheme', '', ...
                               'casedir', 'C:\temp\oftest', ...
                               'clean', 0 );