|
[Sponsors] |
April 20, 2018, 12:39 |
Writing a if loop in the blockMeshDict file
|
#1 |
New Member
Elise
Join Date: Apr 2018
Posts: 1
Rep Power: 0 |
Dear all,
I want to create a if loop in my definition of the inlet, so that it changes according to a user defined Wind Direction. I keep running into errors, and just keep asking why this simple code doesn´t work. I try adding ForAll command, also #Codestream command without no effects. I´m a beginner with OPenFoam, my problem may seem obvious but I´m however yet not able to solve it. Here is the code : /*--------------------------------*- C++ -*----------------------------------*\ | o | | | o o | HELYX-OS | | o O o | Version: v2.2.0 | | o o | Web: http://www.engys.com | | o | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location system; object blockMeshDict; } /*Parameters*/ D 20;/*Size of the buildings*/ M 10;/*Length btw inlet and the buildings*/ Wind 0;/*Wind Direction : from 0 to 315 with a path of 45*/ L #calc "$D*$M";/*Lenght of the Backgroundmesh*/ string FacesInlet; convertToMeters 1; backgroundMesh { x1 #calc "-1.0*$L*cos(0.393)"; x2 #calc "-1.0*$L*cos(3*0.393)"; x3 0; x4 #calc "$L*cos(3*0.393)"; x5 #calc "$L*cos(0.393)"; y1 #calc "-1.0*$L*cos(0.393)"; y2 #calc "-1.0*$L*cos(3*0.393)"; y3 0; y4 #calc "$L*cos(3*0.393)"; y5 #calc "$L*cos(0.393)"; zMin 0; zMax 50; xCells 50; yCells 50; zCells 15; } vertices ( ($:backgroundMesh.x1 $:backgroundMesh.y2 $:backgroundMesh.zMin) ($:backgroundMesh.x1 $:backgroundMesh.y4 $:backgroundMesh.zMin) ($:backgroundMesh.x2 $:backgroundMesh.y5 $:backgroundMesh.zMin) ($:backgroundMesh.x4 $:backgroundMesh.y5 $:backgroundMesh.zMin) ($:backgroundMesh.x5 $:backgroundMesh.y4 $:backgroundMesh.zMin) ($:backgroundMesh.x5 $:backgroundMesh.y2 $:backgroundMesh.zMin) ($:backgroundMesh.x4 $:backgroundMesh.y1 $:backgroundMesh.zMin) ($:backgroundMesh.x2 $:backgroundMesh.y1 $:backgroundMesh.zMin) ($:backgroundMesh.x3 $:backgroundMesh.y3 $:backgroundMesh.zMin) ($:backgroundMesh.x1 $:backgroundMesh.y2 $:backgroundMesh.zMax) ($:backgroundMesh.x1 $:backgroundMesh.y4 $:backgroundMesh.zMax) ($:backgroundMesh.x2 $:backgroundMesh.y5 $:backgroundMesh.zMax) ($:backgroundMesh.x4 $:backgroundMesh.y5 $:backgroundMesh.zMax) ($:backgroundMesh.x5 $:backgroundMesh.y4 $:backgroundMesh.zMax) ($:backgroundMesh.x5 $:backgroundMesh.y2 $:backgroundMesh.zMax) ($:backgroundMesh.x4 $:backgroundMesh.y1 $:backgroundMesh.zMax) ($:backgroundMesh.x2 $:backgroundMesh.y1 $:backgroundMesh.zMax) ($:backgroundMesh.x3 $:backgroundMesh.y3 $:backgroundMesh.zMax) ); blocks ( hex (0 8 2 1 9 17 11 10) ( $:backgroundMesh.xCells $:backgroundMesh.yCells $:backgroundMesh.zCells ) simpleGrading (1 1 1) hex (2 8 4 3 11 17 13 12) ( $:backgroundMesh.xCells $:backgroundMesh.yCells $:backgroundMesh.zCells ) simpleGrading (1 1 1) hex (4 8 6 5 13 17 15 14) ( $:backgroundMesh.xCells $:backgroundMesh.yCells $:backgroundMesh.zCells ) simpleGrading (1 1 1) hex (6 8 0 7 15 17 9 16) ( $:backgroundMesh.xCells $:backgroundMesh.yCells $:backgroundMesh.zCells ) simpleGrading (1 1 1) ); edges ( ); boundary ( inlet { type patch; faces ( /* { forAll(Wind) */ { if (Wind == 0) { FacesInlet = "(7 16 9 0) (0 9 10 1) (1 10 11 2)" } else if (Wind == 90) { FacesInlet = "(1 10 11 2) (2 11 12 3) (3 12 13 4)" } else if (Wind == 180) { FacesInlet = "(3 12 13 4) (4 13 14 5) (5 14 15 6)" } else if (Wind == 270) { FacesInlet = "(5 14 15 6) (6 15 16 7) (7 16 9 0)" } } return FacesInlet; /* } */ ); } outlet { type patch; faces ( (4 13 14 5) (3 12 13 4) (5 14 15 6) ); } ground { type wall; faces ( (0 1 2 8) (2 3 4 8) (4 5 6 8) (6 7 0 8) ); } frontAndBack { type symmetry; faces ( (9 17 11 10) (11 17 13 12) (13 17 15 14) (15 17 9 16) (2 11 12 3) (6 15 16 7) ); } ); mergePatchPairs(); And here is my error : --> FOAM FATAL IO ERROR: incorrect first token, expected '(', found on line 1 the punctuation token '{' file: .inlet.faces at line 1. From function Foam::Istream& Foam:perator>>(Foam::Istream&, Foam::List<T>&) [with T = int] in file /home/ubuntu/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/ListIO.C at line 131. Thank you in advance for any help 😊 |
|
Tags |
blockmeshdict, if loop, inlet, loop |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field | lakeat | OpenFOAM Community Contributions | 58 | December 23, 2021 03:36 |
[foam-extend.org] Problems installing foam-extend-4.0 on openSUSE 42.2 and Ubuntu 16.04 | ordinary | OpenFOAM Installation | 19 | September 3, 2019 19:13 |
polynomial BC | srv537 | OpenFOAM Pre-Processing | 4 | December 3, 2016 10:07 |
centOS 5.6 : paraFoam not working | yossi | OpenFOAM Installation | 2 | October 9, 2013 02:41 |
friction forces icoFoam | ofslcm | OpenFOAM | 3 | April 7, 2012 11:57 |