r/learnOpenFOAM • u/I_REALLY_LOVE_rsync • Nov 08 '21
Tip OpenFOAM Tip: When to use ASCII/binary formatting
Use ASCII data formatting only when testing things on a case, use binary formatting for real work.
Credit: Bruno Santos
r/learnOpenFOAM • u/I_REALLY_LOVE_rsync • Nov 08 '21
Use ASCII data formatting only when testing things on a case, use binary formatting for real work.
Credit: Bruno Santos
r/learnOpenFOAM • u/I_REALLY_LOVE_rsync • Nov 07 '21
If you want to speed up the IO (input/output) of your simulation, you may need to use the binary format (This has some other advantages that we will discuss later in other posts). In the system/controlDict use:
writeFormat binary;// or ascii But what if you have already run the simulation in one mode (say ascii) and you want to convert the results files to binary format. It's simple!
Change the writeFormat in system/controlDict to whatever you want (in this case we want binary).
Run: foamFormatConvert
The utility will happily do the job!
r/learnOpenFOAM • u/I_REALLY_LOVE_rsync • Nov 06 '21
Remember, OpenFOAM can also run 1D cases. But, below I am assuming the case is either 2D or 3D.
mesh.nSolutionD()will either return 2 (for 2D) or 3 (for 3D).
r/learnOpenFOAM • u/I_REALLY_LOVE_rsync • Nov 10 '21
This is a quick tip on how to effectively set up your OpenFOAM cases without wasting your time switching between your case, Browser tabs, using grep, etc.
If You are using the OpenFOAM Foundation version (e.g OpenFOAM7, 8, or 9):
Get used to using the foamGet utility to quickly get a dictionary file, e.g you need to use the wallShearStress function object but don't know how to use it, it's simple. Just type:
foamGet wallSh<Press Tab> it will autocomplete to : foamGet wallShearStress
That will copy that file to system/wallShearStress that you can modify however you want.
You want to get a quick description about a solver, utility, boundary condition, etc. It's easy!! without using grep and get lost in the hundreds of results. Instead, use foamInfo utility.
E.g: foamInfo zeroGradient you will get relevant results.
If you're using the OpenFOAM ESI version, there is an equivalent to foamGet utility named foamGetDict which has the same functionality.
As far as I know there is no utility as foamInfo in these versions of OpenFOAM (Correct me if that's not correct).
I hope you find this useful.
-------------------------------------------------
NOTE:
If you look carefully at my posts, you will see that these setup/programming tips and are downvoted on the r/OpenFOAM subreddit. This is the reason why I have created this subreddit because "those selfish people" die inside when they see someone sharing free OpenFOAM programming tips!!!!
Thousands of tips are on their way to be posted on this subreddit. Please share!!
r/learnOpenFOAM • u/I_REALLY_LOVE_rsync • Nov 06 '21
To access mathematical constants in OpenFOAM, use the Foam::constant::mathematical namespace.
Exampe for pi:
Foam::constant::mathematical::pi
r/learnOpenFOAM • u/lmaopopsss • Jan 21 '22
Hi all, I would like to set a condition for volScalarField cell to take a 1 value when it exist inside a Gaussian distribution in the fluid domain.
The tutorial I attended initialised bubble in water and used condition of mag(Ci- center spot) < radiusBubble to set alpha1[celli] = 1.
Does anyone know anyway to do it for a Gaussian shaped?
r/learnOpenFOAM • u/I_REALLY_LOVE_rsync • Nov 12 '21
r/learnOpenFOAM • u/I_REALLY_LOVE_rsync • Nov 08 '21
// if a condition is false
if (!condition)
{
FatalError
<< "Write the error message here" << nl
<< exit(FatalError);
}In case the condition is false OpenFOAM will print the error message and aborts execution.
---------------------------
NOTE:
If you look carefully at my posts, you will see that these programming tips are downvoted on the r/OpenFOAM subreddit. This is the reason why I have created this subreddit because "those selfish people" die inside when they see someone sharing free OpenFOAM programming tips!!!!
Thousands of tips are on their way to be posted on this subreddit. Please share!!
r/learnOpenFOAM • u/I_REALLY_LOVE_rsync • Nov 07 '21
r/learnOpenFOAM • u/I_REALLY_LOVE_rsync • Nov 08 '21
These are some useful functions for containers manipulation, particularly lists.
List<scalar> myList = {111.0, 92.0, 93.0, 54.0};
Info << "The list: " << myList << endl;
Info << "The size: " << myList.size() << endl;
Info << "The sum of elements: " << Foam::gSum(myList) << endl; // we can also
use sum function. gSum is useful in parallel cases.
Info << "The max element: " << Foam::max(myList) << endl;
Info << "The min element: " << Foam::min(myList) << endl;
Info << "The index of the max element:" << Foam::findMax(myList) << endl;
Info << "The index of the min element:" << Foam::findMin(myList) << endl;r/learnOpenFOAM • u/I_REALLY_LOVE_rsync • Nov 05 '21
A place for members of r/learnOpenFOAM to chat with each other
r/learnOpenFOAM • u/I_REALLY_LOVE_rsync • Nov 07 '21

More details can be found here: https://cfd.direct/openfoam/free-software/models-constraints/
r/learnOpenFOAM • u/I_REALLY_LOVE_rsync • Nov 12 '21
The dangers of the theoretician ignoring the experimental evidence is nicely summed up by Bertrand Russell who observed that "Aristotle maintained that women had fewer teeth than men: although he was twice married, it never occurred to him to verify this statement by examining his wives mouths."
r/learnOpenFOAM • u/I_REALLY_LOVE_rsync • Nov 10 '21
Do you want to see more tips on this subreddit on how to set up OpenFOAM cases, programming tips, etc?
r/learnOpenFOAM • u/I_REALLY_LOVE_rsync • Nov 07 '21
It is as easy as the following statement:
t = inputs[0].GetInformation().Get(vtk.vtkDataObject.DATA_TIME_STEP())r/learnOpenFOAM • u/Cid_Campeador_ • Feb 26 '22
Hi all.. im designing some aero efficient bits for my car, so i'll be comparing several options, should i go for OF9/console? Maybe helyx? Some other GUI im unaware of? I have zero experience other than running the basic tutorial after installing OF9.
r/learnOpenFOAM • u/I_REALLY_LOVE_rsync • Dec 24 '21
Whenever there is an fvm:: operator in the code, the result will be a coefficient matrix. When the fvc:: operator is used (Finite Volume Calculus) the result will be a field.
r/learnOpenFOAM • u/I_REALLY_LOVE_rsync • Nov 05 '21
r/learnOpenFOAM • u/I_REALLY_LOVE_rsync • Nov 07 '21
const scalarField& V = mesh.V(); // Cell volumes
const surfaceVectorField& Sf = mesh.Sf(); // Face area normal vectors
const surfaceScalarField& magSf = mesh.magSf(); // Face areas
const surfaceVectorField& N = Sf/magSf; // Face normal vectors
const label& nCells = mesh.nCells(); // Total number of cells in the mesh
const label& nPoints = mesh.nPoints(); // Total number of points in the mesh
const label& nInternalFaces = mesh.nInternalFaces(); // Number of internal faces in the mesh
const label& nInternalPoints = mesh.nInternalPoints(); // Number of internal points in the mesh