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

Creating pre-processing utility

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

Reply
 
LinkBack Thread Tools Display Modes
Old   May 10, 2010, 16:41
Default Creating pre-processing utility
  #1
Member
 
Pascal
Join Date: Jun 2009
Location: Montreal
Posts: 65
Rep Power: 8
Pascal_doran is on a distinguished road
Hi all,

I've created an utility (vit_cond_init_2t_test) and every thing goes right. But now I would like to be able to give parameters (entries) to my utility to customize it like that:

vit_cond_init_2t_test a b c d

where a, b, c and d are input parameters

I would like to modify my utility to do so. Here's what I've tried :

Code:
int main(int argc, char *argv[])  
{  
 
# include "setRootCase.H"  
# include "createTime.H"  
# include "createMesh.H"  
# include "createFields.H" 

  argList::validArgs.append("value");
  argList::validArgs.append("value");
  argList::validArgs.append("value");
  argList::validArgs.append("value");

  scalar a(readScalar(IStringStream(args.args()[1])()));
  scalar b(readScalar(IStringStream(args.args()[2])()));
  scalar c(readScalar(IStringStream(args.args()[3])()));
  scalar d(readScalar(IStringStream(args.args()[4])()));

...

return(0);  
}
I have the following error message when I run the code :

Code:
Wrong number of arguments, expected 0 found 4

FOAM exiting
Thank you,

Pascal
Pascal_doran is offline   Reply With Quote

Old   May 11, 2010, 02:22
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 777
Rep Power: 18
olesen will become famous soon enough
Quote:
Originally Posted by Pascal_doran View Post

I would like to modify my utility to do so. Here's what I've tried :

Code:
int main(int argc, char *argv[])  
{  
 
# include "setRootCase.H"  
# include "createTime.H"  
# include "createMesh.H"  
# include "createFields.H" 

  argList::validArgs.append("value");
  argList::validArgs.append("value");
  argList::validArgs.append("value");
  argList::validArgs.append("value");

  scalar a(readScalar(IStringStream(args.args()[1])()));
  scalar b(readScalar(IStringStream(args.args()[2])()));
  scalar c(readScalar(IStringStream(args.args()[3])()));
  scalar d(readScalar(IStringStream(args.args()[4])()));

...

return(0);  
}
I have the following error message when I run the code :

Code:
Wrong number of arguments, expected 0 found 4

FOAM exiting
Simple to solve. If you see what the #include "setRootCase.H" actually does, you'll see that you've tried to parse the command-line before actually defining which options and arguments it can handle.

You want something like this:

Code:
int main(int argc, char *argv[])  
{  
  // does it work correctly in parallel? If not you need this:
  // argList::noParallel(); 

// define allowable options and arguments
  argList::validArgs.append("valueA");
   argList::validArgs.append("valueB");
   argList::validArgs.append("valueC");
   argList::validArgs.append("valueD");
 
// construct 'args' from command-line, parsing options/arguments:
# include "setRootCase.H"  

# include "createTime.H"  
# include "createMesh.H"  
# include "createFields.H" 

  const scalar a(readScalar(IStringStream(args.args()[1])()));
  const scalar b(readScalar(IStringStream(args.args()[2])()));
  const scalar c(readScalar(IStringStream(args.args()[3])()));
  const  scalar d(readScalar(IStringStream(args.args()[4])()));

...

return 0;  
}
To be especially pedantic, I've added a 'const' in front of the scalars, since they are probably invariant.

This hopefully gets you going.
olesen is offline   Reply With Quote

Old   May 11, 2010, 17:58
Default
  #3
Member
 
Pascal
Join Date: Jun 2009
Location: Montreal
Posts: 65
Rep Power: 8
Pascal_doran is on a distinguished road
Thanks a lot M. Olesen, everything works perfectly!

Pascal
Pascal_doran is offline   Reply With Quote

Reply

Tags
entries, pre-processing, utility

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fluent3DMeshToFoam simvun OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ... 48 May 14, 2012 05:20
BlockMeshmergePatchPairs hjasak OpenFOAM Native Meshers: blockMesh 11 August 15, 2008 07:36
Problems with Meshing: Collapsed Cells Emmanuel Resch CD-adapco 1 July 30, 2007 03:02
Creating new utility Lorentz force calculation adekian OpenFOAM Running, Solving & CFD 0 May 24, 2007 05:16
PRE and POST processing package Astrid Barros Main CFD Forum 6 November 16, 2000 11:31


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