|
[Sponsors] |
November 13, 2017, 03:50 |
Writing function in OpenFOAM
|
#1 |
Member
Vishwesh Ravi Shrimali
Join Date: Aug 2017
Posts: 43
Rep Power: 8 |
Hi!
I want to write two functions for retrieving properties like velocity, volume, etc. of the cells given their global Cell ID. I have written the following codes in interFoam.C above the main function: Code:
void returnNeighborsFromCell(const DynamicList<label>& Ln, label cellID) { globalIndex globalNumbering (mesh_.nCells()); label localProcID = globalNumbering.whichProcID(cellID); label localCellIDagain = globalNumbering.toLocal(cellID); label neighborCelli; if (localProcID == Pstream::myProcNo()){ label globalCellID_neighbor (0); forAll(mesh_.cellCells()[localCellIDagain],neighborCelli) { globalCellID_neighbor = globalNumbering.toGlobal(mesh_.cellCells()[localCellIDagain][neighborCelli]); Ln.append(globalCellID_neighbor); } } } void returnValuesFromCell (const DynamicList<label>& properties, label cellID) { globalIndex globalNumbering (mesh_.nCells()); scalar alphaVal = 0; scalar volVal = 0; vector velocityVal (0,0,0); vector cellCentres (0,0,0); int properties[8]={0}; label localProcID = globalNumbering.whichProcID(cellID); label localCellIDagain = globalNumbering.toLocal(cellID); if (localProcID == Pstream::myProcNo()){ alphaVal = alpha1[localCellIDagain]; velocityVal = U[localCellIDagain]; volVal = mesh_.V()[localCellIDagain]; cellCentres = mesh_.C()[localCellIDagain]; } properties[0] = alphaVal; properties[1] = volVal; properties[2] = velocityVal[0]; properties[3] = velocityVal[1]; properties[4] = velocityVal[2]; properties[5] = cellCentres[0]; properties[6] = cellCentres[1]; properties[7] = cellCentres[2]; } Code:
interFoam.C: In function ‘void returnNeighborsFromCell(const Foam::DynamicList<long int, 0u, 2u, 1u>&, Foam::label)’: interFoam.C:64: error: ‘mesh_’ was not declared in this scope interFoam.C:73: error: passing ‘const Foam::DynamicList<long int, 0u, 2u, 1u>’ as ‘this’ argument of ‘Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>& Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append(const T&) [with T = long int, unsigned int SizeInc = 0u, unsigned int SizeMult = 2u, unsigned int SizeDiv = 1u]’ discards qualifiers interFoam.C:68: warning: unused variable ‘neighborCelli’ interFoam.C: In function ‘void returnValuesFromCell(const Foam::DynamicList<long int, 0u, 2u, 1u>&, Foam::label)’: interFoam.C:81: error: ‘mesh_’ was not declared in this scope interFoam.C:88: error: declaration of ‘int properties [8]’ shadows a parameter interFoam.C:94: error: ‘alpha1’ was not declared in this scope interFoam.C:95: error: ‘U’ was not declared in this scope Thanks in advance Last edited by vishwesh; November 13, 2017 at 23:13. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Frequently Asked Questions about Installing OpenFOAM | wyldckat | OpenFOAM Installation | 3 | November 14, 2023 11:58 |
OpenFOAM 5.0 Released | CFDFoundation | OpenFOAM Announcements from OpenFOAM Foundation | 11 | June 5, 2018 23:48 |
OpenFOAM 4.0 Released | CFDFoundation | OpenFOAM Announcements from OpenFOAM Foundation | 2 | October 6, 2017 05:40 |
[blockMesh] non-orthogonal faces and incorrect orientation? | nennbs | OpenFOAM Meshing & Mesh Conversion | 7 | April 17, 2013 05:42 |
latest OpenFOAM-1.6.x from git failed to compile | phsieh2005 | OpenFOAM Bugs | 25 | February 9, 2010 04:37 |