|
[Sponsors] |
January 20, 2016, 18:21 |
Mathematical expressions in a FoamFile
|
#1 |
New Member
Brad Perfect
Join Date: Jan 2014
Posts: 8
Rep Power: 12 |
This one's a two-parter:
First, the implementation. In the definitions section in blockMeshDict, I want to define and discretize the domain. So I define >back -600; >front 250; Cool. Now, I'd like to define the number of grid cells along this dimension. Previously I had been doing >nx 40; But now I'm playing around with changing the domain size. I would like to be able to say something like, >nx floor((front-back)/8); How can I accomplish this? OpenFOAM gets angry at me whenever I try to insert a math expression. Now, for the second part: I can't find any information about how these FoamFile definitions are stored. Do they stay local to whatever application calls the file that it's in, or could I, for example, define all of my parameters that might change in my executable file? Going with the same example as above, is there a way to define 'front' and 'back' in my executable so that I only have to edit one file every time I do a run? |
|
January 21, 2016, 08:21 |
|
#2 |
Senior Member
|
Hi,
You know, you can search forums: http://www.cfd-online.com/Forums/ope...constants.html http://www.cfd-online.com/Forums/ope...variables.html http://www.cfd-online.com/Forums/ope...kmeshdict.html Also you can use grep: Code:
$ cd $FOAM_TUTORIALS $ grep -r '#calc' * incompressible/simpleFoam/pipeCyclic/constant/polyMesh/blockMeshDict:radHalfAngle #calc "degToRad($halfAngle)"; incompressible/simpleFoam/pipeCyclic/constant/polyMesh/blockMeshDict:y #calc "$radius*sin($radHalfAngle)"; incompressible/simpleFoam/pipeCyclic/constant/polyMesh/blockMeshDict:minY #calc "-1.0*$y"; incompressible/simpleFoam/pipeCyclic/constant/polyMesh/blockMeshDict:z #calc "$radius*cos($radHalfAngle)"; incompressible/simpleFoam/pipeCyclic/constant/polyMesh/blockMeshDict:minZ #calc "-1.0*$z"; multiphase/interDyMFoam/ras/floatingObject/constant/dynamicMeshDict: mass #calc "$rho*$Lx*$Ly*$Lz"; |
|
January 21, 2016, 17:37 |
|
#3 |
New Member
Brad Perfect
Join Date: Jan 2014
Posts: 8
Rep Power: 12 |
Code:
FoamFile { version 2.0; format ascii; class dictionary; object blockMeshDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // convertToMeters 1; back -600; front 250; side -215; z1 -40; //40m depth permits waves up to 80m long to propagate as deep water waves z2 3.87; z3 5.87; z4 50; hsize 8; vsize 6; nx #calc "std::ceil(($front-$back)/$hsize)"; #calc "Info<< $nx << endl" ny #calc "std::ceil(-$side/$hsize)"; Code:
/*---------------------------------------------------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2.3.0 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ Build : 2.3.0-f5222ca19ce6 Exec : blockMesh Date : Jan 21 2016 Time : 14:30:39 Host : "fourier" PID : 17214 Case : /home/bperfect/OpenFOAM/bperfect-2.3.0/run/small nProcs : 1 sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE). fileModificationChecking : Monitoring run-time modified files using timeStampMaster allowSystemOperations : Allowing user-supplied system call operations // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time Creating block mesh from "/home/bperfect/OpenFOAM/bperfect-2.3.0/run/small/constant/polyMesh/blockMeshDict" Using #calcEntry at line 29 in file "/home/bperfect/OpenFOAM/bperfect-2.3.0/run/small/constant/polyMesh/blockMeshDict" Using #codeStream with "/home/bperfect/OpenFOAM/bperfect-2.3.0/run/small/dynamicCode/platforms/linux64GccDPOpt/lib/libcodeStream_d8e5566d16e6b658bc2352d18ed09d52db601d72.so" Invoking "wmake -s libso /home/bperfect/OpenFOAM/bperfect-2.3.0/run/small/dynamicCode/_d8e5566d16e6b658bc2352d18ed09d52db601d72" : In function ‘void Foam::codeStream_d8e5566d16e6b658bc2352d18ed09d52db601d72(Foam::Ostream&, const Foam::dictionary&)’: :1:22: error: lvalue required as decrement operand :1:24: error: expected ‘)’ before numeric constant :1:32: error: expected ‘)’ before ‘;’ token make: *** [Make/linux64GccDPOpt/codeStreamTemplate.o] Error 1 --> FOAM FATAL IO ERROR: Failed wmake "dynamicCode/_d8e5566d16e6b658bc2352d18ed09d52db601d72/platforms/linux64GccDPOpt/lib/libcodeStream_d8e5566d16e6b658bc2352d18ed09d52db601d72.so" file: /home/bperfect/OpenFOAM/bperfect-2.3.0/run/small/constant/polyMesh/blockMeshDict from line 17 to line 26. From function functionEntries::codeStream::execute(..) in file db/dictionary/functionEntries/codeStream/codeStream.C at line 177. FOAM exiting |
|
January 21, 2016, 18:06 |
|
#4 |
Senior Member
|
Hi,
Though strictly speaking it is just shitty Gcc diagnostics, but try to control your expansions. Here is clang output: Code:
[CC] codeStreamTemplate.C :1:22: error: expression is not assignable os << (std::ceil((250--600)/8)); ~~~^ 1 error generated. make: *** [Make/darwin64ClangDPInt64Opt/codeStreamTemplate.o] Error 1 |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[cfMesh] Regular expressions in cfMesh | rama13 | OpenFOAM Community Contributions | 6 | June 7, 2015 17:01 |
Mathematical Expressions at Boundaries | AeroJay | CFX | 5 | May 26, 2013 20:19 |
Average of Expressions in Transient Run for Parameter Study | BigPapi34 | CFX | 1 | August 7, 2012 05:34 |
Grouping expressions in CEL | foo7 | CFX | 4 | September 21, 2011 09:15 |
Cel expressions for trasient problem | Jervds | CFX | 0 | March 4, 2008 10:03 |