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

macro substitution with negative symbol

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By alfiogn

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 23, 2015, 05:51
Default macro substitution with negative symbol
  #1
Senior Member
 
Robert Castilla
Join Date: Apr 2009
Location: Spain
Posts: 109
Rep Power: 17
rcastilla is on a distinguished road
Hi,

when I try to make a macro susbtitution in blockMeshDict, like

a 10;

vertices
(
...
($a -$a 0)
...
)

it is not working. It gives the error

wrong token type - expected Scalar, found on line 37 the punctuation token '-'

It works with a code like

($a #calc "-$a" 0)

but I find it very anoying. I am not able to find an easy way to do that. Any suggestion?

Thanks

Robert
rcastilla is offline   Reply With Quote

Old   September 1, 2020, 11:06
Default
  #2
New Member
 
Giorgio Negrini
Join Date: Feb 2020
Location: Milan
Posts: 13
Rep Power: 6
alfiogn is on a distinguished road
Very old post, but may be useful to give an answer for who will read.

To make a negative macro you can easily write:
a 1;
ma #neg $a;

and it doesn't need compilation!
alfiogn is offline   Reply With Quote

Old   September 2, 2020, 09:53
Default
  #3
Member
 
Rodrigo
Join Date: Mar 2010
Posts: 98
Rep Power: 16
guin is on a distinguished road
Quote:
Originally Posted by alfiogn View Post
Very old post, but may be useful to give an answer for who will read.

To make a negative macro you can easily write:
Code:
a      1;
ma    #neg $a;
and it doesn't need compilation!
Right, this works for current OpenFOAM-dev, OpenFOAM-8 & OpenFOAM-7.

In case you are dealing with an older version you may need to do something like this instead (needs runtime compilation):
Code:
a        1;
ma      #calc "-$a";

Last edited by guin; September 3, 2020 at 03:49. Reason: EDIT: ensuring correctness in the answer thanks to Giorgio's feedback.
guin is offline   Reply With Quote

Old   September 2, 2020, 10:04
Default
  #4
New Member
 
Giorgio Negrini
Join Date: Feb 2020
Location: Milan
Posts: 13
Rep Power: 6
alfiogn is on a distinguished road
Quote:
Originally Posted by guin View Post
Right, this works for current OpenFOAM-dev & OpenFOAM-8 at least (not sure about OpenFOAM-7).
I'm actually using v7 so it is ok!
guin likes this.
alfiogn is offline   Reply With Quote

Reply


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
[Other] mesh airfoil NACA0012 anand_30 OpenFOAM Meshing & Mesh Conversion 13 March 7, 2022 17:22
using METIS functions in fortran dokeun Main CFD Forum 7 January 29, 2013 04:06
POSDAT problem piotka STAR-CD 4 June 12, 2009 08:43
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug unoder OpenFOAM Installation 11 January 30, 2008 20:30
[blockMesh] Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Meshing & Mesh Conversion 10 April 2, 2007 14:00


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