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

How to use argList::addOption correctly?

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 18, 2020, 14:49
Default How to use argList::addOption correctly?
  #1
New Member
 
Ziqu Cao
Join Date: Aug 2019
Location: The University of Glasgow
Posts: 10
Rep Power: 2
Kevin Cao is on a distinguished road
Hi,


I use OpenFOAM-2.4.0-MNF to add a new usage option in my user defined utility based on vorticity. The make/options file of my utility is the same as the one of vorticity.
As the make/options file in vorticity has been linked to postCalc so I just go into postCalc.C and add Foam::argList::addOption
Here is part of the code in postCalc.C
Code:
int main(int argc, char *argv[])
{

    Foam::timeSelector::addOptions();
    #include "addRegionOption.H"
    Foam::argList::addBoolOption
    (
        "noWrite",
        "suppress writing results"
    );
    #include "addDictOption.H"
    Foam::argList::addOption
    (
        "fieldName",
        "name",
        "specify a fieldName for the velocity"
        "example: -fieldName N2"
    );
    #include "setRootCase.H"
    #include "createTime.H"
    Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args);
    #include "createNamedMesh.H"
    ...
Here is part of the code of my utility

Code:
#include "calc.H"
#include "fvc.H"
#include "argList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
{   
    bool writeResults = !args.optionFound("noWrite");
    
    word fieldName;
    if (args.optionFound("fieldName"))
    {
        args.optionLookup("fieldName")() >> fieldName;
    }
    else
    {
        FatalErrorIn("vorticity::calc")
        << "fieldName option must be used with this tool"
        << nl
        << exit(FatalError);
    }
The utility and postCalc.C are all compiled successfully but when I use it, it shows:
--> FOAM FATAL ERROR:
Invalid option: -fieldName

I also put argList::addOption part into my utility but it still does not work

What did I miss? Can anyone help me please?


Thanks in advance.
Kevin Cao is offline   Reply With Quote

Reply

Tags
post procesing

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] How to correctly show the result of #codeStream# internalField? chengdi ParaView 22 July 3, 2020 07:02
How to correctly use cyclic BCs ? Roxxor91 OpenFOAM Running, Solving & CFD 0 September 30, 2019 17:24
SIMPLER Code Temperatures not coming correctly Dharma Vedula Main CFD Forum 5 July 5, 2017 21:34
SU2 optimization does not work correctly with CGNS format Andrei SU2 Shape Design 1 April 22, 2016 10:35
interFoam running blowing up sandy13 OpenFOAM Running, Solving & CFD 2 May 5, 2015 07:16


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