|
[Sponsors] |
[Tutorials] OpenFOAM programming tutorials for beginners |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#61 |
New Member
Join Date: Feb 2016
Posts: 13
Rep Power: 10 ![]() |
Hi Artur. Thank you very much for that great tutorial. It helps very much !
I have two questions concerning the postprocessing functions (tutorial 09). - Why we have a 0 directory inside the directory postProcessing ? - How can I use the postProcess utility ? When specified without additional arguments, the postProcess utility should execute all function objects defined in the system/controlDict file for all time directories but I have the error message --> FOAM FATAL ERROR: request for volVectorField U from objectRegistry region0 failed available objects of type volVectorField are 0() From function const Type& Foam: ![]() in file /home/ubuntu/OpenFOAM/OpenFOAM-7/src/OpenFOAM/lnInclude/objectRegistryTemplates.C at line 193. FOAM aborting Thank you ! Fanny |
|
![]() |
![]() |
![]() |
![]() |
#62 |
Senior Member
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 372
Rep Power: 20 ![]() |
Hi,
The 0 folder follows OF convention whereby subsequent restarts or calls write data to a specific time (in this case iteration) directory. The utility doesn't even specify this explicitly, it gets done automatically. The only thing done here is appending the name of the object to the existing file names inside Code:
Foam::wordList Foam::functionObjects::pipeCalc::createFileNames I am not sure where the second error is coming from. The main point here is that the utility has been written to be executed in parallel with the solver and not after this has been run. Hence, it works fine within simpleFoam but apparently some fields do not get read properly when it is run with postProcess. My hunch is that the velocity field would need to be explicitly requested somehow, but it's beyond the scope of the tutorial as I intended it. If you do figure it out, please do share ![]() Kind regards, A |
|
![]() |
![]() |
![]() |
![]() |
#63 |
New Member
Join Date: Feb 2016
Posts: 13
Rep Power: 10 ![]() |
Thank you so much Artur for this quick and clear answer
![]() |
|
![]() |
![]() |
![]() |
![]() |
#64 |
Senior Member
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 372
Rep Power: 20 ![]() |
Hello everyone,
I recently completed a tutorial on discretisation schemes after a request from the community. Hope you'll find it useful! Happy foaming, A cellCentreValues.jpg tutorial15.jpg |
|
![]() |
![]() |
![]() |
![]() |
#65 |
Member
Junaid Ahmad Khan
Join Date: Mar 2010
Location: Islamabad
Posts: 43
Rep Power: 16 ![]() |
I have a question how can I explore member function of "volScalarField"
Code:
volScalarField T ( IOobject( "T", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh ); e.g. the output of Code:
Info<< T << nl; is Code:
dimensions [0 0 0 1 0 0 0]; internalField uniform 0; boundaryField { left_sides { type zeroGradient; } right_sides { type fixedValue; value uniform 1; } empty { type empty; } } the output of Code:
Info<< T.dimensions() << endl; is Code:
[0 0 0 1 0 0 0] and output of Code:
Info<<T.boundaryField() << endl; is Code:
3 ( type zeroGradient; type fixedValue; value uniform 1; type empty; ) output of Code:
forAll(T.internalField(), cellI) { Info<<"T.internalField()["<<cellI<<"]: "<<T.internalField()[cellI]<<nl ; } is Code:
T.internalField()[0]: 0 T.internalField()[1]: 0 |
|
![]() |
![]() |
![]() |
![]() |
#66 |
Senior Member
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 372
Rep Power: 20 ![]() |
Hi,
I'm not really sure what you're asking - do you mean printing text representation of various objects / output of functions? If so, then there isn't much more to say than what you've just demonstrated, beyond that not every object has the relevant formatting functions included in its definition. If you want to know more about input/output in general, tutorial 01 is the place to look. As this is a very generic question not related to the tutorials, please consider making a separate thread for it. Happy foaming, A |
|
![]() |
![]() |
![]() |
![]() |
#67 |
Member
Junaid Ahmad Khan
Join Date: Mar 2010
Location: Islamabad
Posts: 43
Rep Power: 16 ![]() |
Thanks for your response, I want to know a systematic way to explore attributes and functions of classes in C++ or openfoam. Like in python there is a dir() function. If there isn't then we need one. As I just started foam so was wondering if some senior can develop one.
|
|
![]() |
![]() |
![]() |
![]() |
#68 |
Senior Member
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 372
Rep Power: 20 ![]() |
Hmm, that seems like a pretty involved C++ question rather than an OpenFOAM-specific one, to be honest. I have no answer to it myself, I'm afraid. Personally, I tend to rely on the auto-generated dependency graphs like the one at the bottom of this page whenever I get stuck:
https://cpp.openfoam.org/v9/classFoa...ionCoeffs.html |
|
![]() |
![]() |
![]() |
![]() |
#69 |
Member
Junaid Ahmad Khan
Join Date: Mar 2010
Location: Islamabad
Posts: 43
Rep Power: 16 ![]() |
Thanks, can u also share a similar link for volScalarField. And a pdf for doxygen.
|
|
![]() |
![]() |
![]() |
![]() |
#70 |
Senior Member
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 372
Rep Power: 20 ![]() |
There's a list of all the objects on the left and a search button in the top right corner
![]() |
|
![]() |
![]() |
![]() |
![]() |
#71 |
Member
Junaid Ahmad Khan
Join Date: Mar 2010
Location: Islamabad
Posts: 43
Rep Power: 16 ![]() |
I figured that out
![]() ![]() ![]() |
|
![]() |
![]() |
![]() |
![]() |
#72 |
New Member
Kumar Pushpak
Join Date: Apr 2019
Posts: 9
Rep Power: 7 ![]() |
I am using OpenFOAM -v1906. I am getting an error in compiling the solver.
Code:
Make/linux64GccDPInt32Opt/OFtutorial7.o: In function `main': OFtutorial7.C:(.text.startup+0xaeb): undefined reference to `computeR(Foam::fvMesh const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>, Foam::dimensioned<Foam::Vector<double> >)' collect2: error: ld returned 1 exit status /home/administrator/OpenFOAM/OpenFOAM-v1906/wmake/makefiles/general:140: recipe for target '/home/administrator/OpenFOAM/administrator-v1906/platforms/linux64GccDPInt32Opt/bin/ofTutorial7' failed For Solver, Make/file Code:
OFtutorial7.C EXE = $(FOAM_USER_APPBIN)/ofTutorial7 Code:
EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -IcustomLibrary EXE_LIBS = \ -lfiniteVolume \ -lmeshTools \ -L$(FOAM_USER_LIBBIN) -lcustomLibrary Make/file Code:
customLibrary.C LIB = $(FOAM_USER_LIBBIN)/libcustomLibrary Code:
EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude LIB_LIBS = \ -lfiniteVolume \ -lmeshTools |
|
![]() |
![]() |
![]() |
![]() |
#73 |
New Member
Kumar Pushpak
Join Date: Apr 2019
Posts: 9
Rep Power: 7 ![]() |
Issue resolved. there was a syntax error in the definition of computeR.
|
|
![]() |
![]() |
![]() |
![]() |
#74 | |
Member
Junaid Ahmad Khan
Join Date: Mar 2010
Location: Islamabad
Posts: 43
Rep Power: 16 ![]() |
Quote:
I finally got the hang of this top right corner button. Thanks for you guidance again. I thought to let the new users like me to know how to go about to find there way using extended guide. Below is the problem statement and its solution. Problem: I had a volScalarField T and I want to find the dx or delta x of first node in mesh from object T. Here is the procedure. Code:
volScalarField T( IOobject( "T", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh); I started by searching volScalarField in extended guide the search gave me Code:
typedef GeometricField<scalar, fvPatchField, volMesh> volScalarField This shows that volScalarField is an object of GeometricField. I clicked on GeometricField it lead me to Code:
GeometricField< Type, PatchField, GeoMesh > Class Template Reference Code:
const Internal & internalField () const Code:
typedef DimensionedField<Type, GeoMesh> Internal Code:
typedef GeoMesh::Mesh Mesh Code:
Foam::fvMesh::Mesh() Foam::DimensionedField::Mesh() Foam::GeometricField::Mesh() Foam::SlicedGeometricField::Mesh() Foam::GeoMesh::Mesh() Foam::pointMesh::Mesh() Foam::polyMesh::Mesh() Foam::surfMesh::Mesh() Code:
tmp< surfaceVectorField > delta () const Code:
typedef GeometricField<vector, fvsPatchField, surfaceMesh> surfaceVectorField Code:
tmp< T > Class Template Reference Using all the knowledge above we can print the dx by the following expression. Code:
Info << T.internalField().mesh().delta().ptr()->internalField()[0].x()<< nl; PS: Dear Seniors if you can suggest a better way of doing this please guide. |
||
![]() |
![]() |
![]() |
![]() |
#75 |
Senior Member
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 372
Rep Power: 20 ![]() |
Dear All,
I have updated the tutorials to work with OpenFOAM 9. The changes required were pretty minimal - the only part that was significantly affected was tutorial 12 which used to use the old fvOption infrastructure that has now become fvModels. I have also added a new tutorial originally contributed by Ramkumar that demonstrates how an existing flow solution can be used in order to perform very simple Lagrangian particle tracking. This particular topic is quite dear to me (which you'll know if you've read my thesis ![]() As always, happy foaming! Artur |
|
![]() |
![]() |
![]() |
![]() |
#76 |
New Member
irengclenk
Join Date: Feb 2021
Posts: 5
Rep Power: 5 ![]() |
Hi Arthur,
First of all, thank you so much for the exercise, very helpful. I am a beginner and use your exercises to learn Openfoam programming I'm currently doing postprocessing exercise (Tutorial 9) using OF2012. However I got this error: Code:
pipeCalc.C:71:31: error: no matching function for call to \u2018Foam::functionObjects::pipeCalc::file(const label&)\u2019 writeHeader(file(i), "Flow rate through face zone"); ^ In file included from /home/u0142217/OpenFOAM/OpenFOAM-v2012/src/OpenFOAM/lnInclude/logFiles.H:46:0, from pipeCalc.H:43, from pipeCalc.C:26: /home/u0142217/OpenFOAM/OpenFOAM-v2012/src/OpenFOAM/lnInclude/writeFile.H:206:27: note: candidate: virtual Foam::OFstream& Foam::functionObjects::writeFile::file() virtual OFstream& file(); Thanks! |
|
![]() |
![]() |
![]() |
![]() |
#77 |
Senior Member
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 372
Rep Power: 20 ![]() |
Hi,
I haven't tried the code with other versions of OpenFOAM, but indeed this seems like something that might be related to compatibility issues. Worth having a quick go at installing the recommended version to double check, of course, but this tutorials has been around for a while so it's unlikely to not function properly. BEst wishes, A |
|
![]() |
![]() |
![]() |
![]() |
#78 |
New Member
Bill
Join Date: Jun 2017
Posts: 13
Rep Power: 9 ![]() |
Dear all,
I am a new user of openfoam. This is a very good tutorial for learning openfoam programming. I am writing this reply just to show the experience or issue I have when running the tutorial. 1) openfoam and ubuntu I am using openfoam 8 and windows 10 based ubuntu 20. 2) (tutorial 00, helloworld) I type in the following command to run the case at the top-level directory: : wmake : ofTutorial0 The case is running OK. 3) (tutorial 01, inputoutput) I type in the following command to run the case at the top-level directory: : wmake : ofTutorial1 There is an error. It reminds me there is no mesh files found. This is how I solve this error (may be a stupid way): : So, I enter the testCase directory, then type: blockMesh : Then I go back to the top-level directory and copy all the case files into the top-level directory. : run 'ofTutorial 1' again. The tutorial is running OK. I think there should be a better way to do this. If anyone else can share this would be very useful. A sgguestion from Artur and it works for me: Code:
./Allwmake cd testCase ./Allrun Code:
chmod +x Allwmake ./Allwmake cd testCase chmod +x Allrun ./Allrun (tutorial 02, command line argument and options) This following codes work for me: Code:
chmod +x Allwmake ./Allwmake cd testCase chmod +x Allrun ./Allrun 5) (tutorial 03, understand the mesh) The above code works. Note: This tutorial presents how to get access the mesh info using the openfoam in-built class functions. It is very useful. 6) (tutorial 04, basic field operations) The above code works. According to the suggestions in the tutorial, we could try to replace the for loop in the tutorial by first commenting the for loop command lines and then adding the following code: Code:
/*replacement of the for loop*/ volScalarField r2 = (mag(dimensionedVector("x0", dimLength, originVector) - mesh.C()) / rFarCell); volScalarField rR2 = (1. / (r2 + dimensionedScalar("tmp1", dimLength, 1e-12))); scalar f2 (1.); p = Foam::sin(2. * Foam::constant::mathematical::pi * f2 * runTime.time().value()) * rR2 * dimensionedScalar("tmp2", dimVolume, 1.) / (dimensionedScalar("tmp3", dimTime, 1.) * dimensionedScalar("tmp3", dimTime, 1.)); (tutorial 05, basic parallel computing) Note: if you need to view the computational results, please remove the following code in Allrun: Code:
rm -r processor* 2>/dev/null Code:
3 more processes have sent help message help-btl-vader.txt / cma-permission-denied Set MCA parameter "orte_base_help_aggregate" to 0 to see all help / error messages Last edited by Bill_Yang; November 2, 2021 at 13:50. Reason: Update |
|
![]() |
![]() |
![]() |
![]() |
#79 |
Senior Member
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 372
Rep Power: 20 ![]() |
Hi Bill,
Indeed, there is an easier way ![]() Code:
./Allwmake cd testCase ./Allrun Code:
blockMesh > log.blockMesh ofTutorial1 Artur |
|
![]() |
![]() |
![]() |
![]() |
#80 | |
New Member
Bill
Join Date: Jun 2017
Posts: 13
Rep Power: 9 ![]() |
Quote:
|
||
![]() |
![]() |
![]() |
Tags |
turorial files, tutorial |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Map of the OpenFOAM Forum - Understanding where to post your questions! | wyldckat | OpenFOAM | 10 | September 2, 2021 05:29 |
OpenFOAM 4.0 Released | CFDFoundation | OpenFOAM Announcements from OpenFOAM Foundation | 2 | October 6, 2017 05:40 |
OpenFOAM Training: Programming CFD Course 12-13 and 19-20 April 2016 | cfd.direct | OpenFOAM Announcements from Other Sources | 0 | January 14, 2016 10:19 |
OpenFOAM v3.0.1 Training, London, Houston, Berlin, Jan-Mar 2016 | cfd.direct | OpenFOAM Announcements from Other Sources | 0 | January 5, 2016 03:18 |
Openfoam Programming from scratch | shovan | OpenFOAM Programming & Development | 1 | July 9, 2015 12:38 |