CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[Tutorials] OpenFOAM programming tutorials for beginners

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree165Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 19, 2021, 10:51
Default post processing
  #61
New Member
 
Join Date: Feb 2016
Posts: 7
Rep Power: 7
fanny is on a distinguished road
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:bjectRegistry::lookupObject(const Foam::word&) const [with Type = Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>]
in file /home/ubuntu/OpenFOAM/OpenFOAM-7/src/OpenFOAM/lnInclude/objectRegistryTemplates.C at line 193.

FOAM aborting




Thank you !
Fanny
fanny is offline   Reply With Quote

Old   February 19, 2021, 11:23
Default
  #62
Senior Member
 
Artur's Avatar
 
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 362
Rep Power: 17
Artur will become famous soon enough
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
Artur is offline   Reply With Quote

Old   February 19, 2021, 11:31
Default
  #63
New Member
 
Join Date: Feb 2016
Posts: 7
Rep Power: 7
fanny is on a distinguished road
Thank you so much Artur for this quick and clear answer
fanny is offline   Reply With Quote

Old   June 6, 2021, 16:49
Default
  #64
Senior Member
 
Artur's Avatar
 
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 362
Rep Power: 17
Artur will become famous soon enough
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
Artur is offline   Reply With Quote

Old   July 22, 2021, 11:29
Default
  #65
Member
 
JunaidAhmad's Avatar
 
Junaid Ahmad Khan
Join Date: Mar 2010
Location: Islamabad
Posts: 40
Rep Power: 13
JunaidAhmad is on a distinguished road
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
Now question is how can i explor boundaryField name, or all other member functions from doxygen or any other user guide.
JunaidAhmad is offline   Reply With Quote

Old   July 22, 2021, 14:53
Default
  #66
Senior Member
 
Artur's Avatar
 
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 362
Rep Power: 17
Artur will become famous soon enough
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
Artur is offline   Reply With Quote

Old   July 22, 2021, 16:02
Default
  #67
Member
 
JunaidAhmad's Avatar
 
Junaid Ahmad Khan
Join Date: Mar 2010
Location: Islamabad
Posts: 40
Rep Power: 13
JunaidAhmad is on a distinguished road
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.
JunaidAhmad is offline   Reply With Quote

Old   July 22, 2021, 16:10
Default
  #68
Senior Member
 
Artur's Avatar
 
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 362
Rep Power: 17
Artur will become famous soon enough
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
Artur is offline   Reply With Quote

Old   July 23, 2021, 01:20
Default
  #69
Member
 
JunaidAhmad's Avatar
 
Junaid Ahmad Khan
Join Date: Mar 2010
Location: Islamabad
Posts: 40
Rep Power: 13
JunaidAhmad is on a distinguished road
Thanks, can u also share a similar link for volScalarField. And a pdf for doxygen.
JunaidAhmad is offline   Reply With Quote

Old   July 23, 2021, 06:17
Default
  #70
Senior Member
 
Artur's Avatar
 
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 362
Rep Power: 17
Artur will become famous soon enough
There's a list of all the objects on the left and a search button in the top right corner
Artur is offline   Reply With Quote

Old   July 23, 2021, 06:45
Default
  #71
Member
 
JunaidAhmad's Avatar
 
Junaid Ahmad Khan
Join Date: Mar 2010
Location: Islamabad
Posts: 40
Rep Power: 13
JunaidAhmad is on a distinguished road
I figured that out , but thanks to your above link, I found it. Due to some reason my computer got stuck then I searched the volscalarfeild previously in that top right corner. Thanks for all your guidance I learned a lot.
JunaidAhmad is offline   Reply With Quote

Old   July 24, 2021, 12:01
Default OFtutorial7 Error
  #72
New Member
 
Kumar Pushpak
Join Date: Apr 2019
Posts: 6
Rep Power: 4
khool_chelsea is on a distinguished road
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
The library was compiled without any issue so the solver must have access to the function computeR(). I am attaching the Make(files and options) for solver.
For Solver,
Make/file
Code:
OFtutorial7.C

EXE = $(FOAM_USER_APPBIN)/ofTutorial7
Make/options
Code:
EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -IcustomLibrary

EXE_LIBS = \
    -lfiniteVolume \
    -lmeshTools \
     -L$(FOAM_USER_LIBBIN) -lcustomLibrary
For Library,

Make/file
Code:
customLibrary.C

LIB = $(FOAM_USER_LIBBIN)/libcustomLibrary
Make/options
Code:
EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude

LIB_LIBS = \
    -lfiniteVolume \
    -lmeshTools
Any ideas where i might be wrong?
khool_chelsea is online now   Reply With Quote

Old   July 24, 2021, 13:04
Default
  #73
New Member
 
Kumar Pushpak
Join Date: Apr 2019
Posts: 6
Rep Power: 4
khool_chelsea is on a distinguished road
Issue resolved. there was a syntax error in the definition of computeR.
khool_chelsea is online now   Reply With Quote

Old   July 25, 2021, 09:07
Default
  #74
Member
 
JunaidAhmad's Avatar
 
Junaid Ahmad Khan
Join Date: Mar 2010
Location: Islamabad
Posts: 40
Rep Power: 13
JunaidAhmad is on a distinguished road
Quote:
Originally Posted by Artur View Post
There's a list of all the objects on the left and a search button in the top right corner
Dear Artur,
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



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
In GeometricField I found internalField() function
Code:
const Internal & internalField () const
this return internal object which is
Code:
typedef DimensionedField<Type, GeoMesh> Internal
this give us DimensionedField where I found mesh() function
Code:
const Mesh & mesh () const
this return a Mesh object
Code:
typedef GeoMesh::Mesh Mesh
Till this point it was straight forward and here comes the twist. I search Mesh in search bar for typedefs of extended guide and found
In one of basic programming notes I read that Mesh reside in fvMesh so I go to fvMesh and found a function
Code:
tmp< surfaceVectorField > delta () const
I clicked on surfaceVectorField which takes me to
this show that delta() is tmp<surfaceVectorField> type template which is a GeometricField temporary object. in
Code:
tmp< T > Class Template Reference
there I found
Code:
T * ptr () const
pointer of GeometricField type. which contains internalField function which we can access using internalField()[0].x()
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.
JunaidAhmad is offline   Reply With Quote

Reply

Tags
turorial files, tutorial

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
OpenFOAM 4.0 Released CFDFoundation OpenFOAM Announcements from OpenFOAM Foundation 2 October 6, 2017 05:40
Map of the OpenFOAM Forum - Understanding where to post your questions! wyldckat OpenFOAM 9 March 30, 2017 05:19
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


All times are GMT -4. The time now is 13:27.