|
[Sponsors] |
How to get the point coordinates in OpenFOAM? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 30, 2017, 21:38 |
How to get the point coordinates in OpenFOAM?
|
#1 |
New Member
Xu Yiming
Join Date: Jan 2017
Posts: 11
Rep Power: 9 |
hi all
I am new to OpenFOAM programming and I want to get the distance between a specific point on the wall and the boundary-line of the wall. Related operations should be conducted in nutUspalding Wall Function file. To achieve this, it is obviously that (1) I should get the point coordinate (x,y,z) and in .C file (2) get the 3D coordinate of the boundary-line. But I don’t know how to access them in openfoam? Can anyone help me ? thanks. Attached file is the sketch of the problem. Yiming The nutUspalding Wall Function file are list as fellow: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::calcNu t() const { const label patchi = patch().index(); const turbulenceModel& turbModel = db().lookupObject<turbulenceModel> ( IOobject::groupName ( turbulenceModel:ropertiesName, internalField().group() ) ); const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; const scalarField magGradU(mag(Uw.snGrad())); const tmp<scalarField> tnuw = turbModel.nu(patchi); const scalarField& nuw = tnuw(); return max ( scalar(0), sqr(calcUTau(magGradU))/(magGradU + ROOTVSMALL) - nuw ); } tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::calcUT au ( const scalarField& magGradU ) const { const label patchi = patch().index(); const turbulenceModel& turbModel = db().lookupObject<turbulenceModel> ( IOobject::groupName ( turbulenceModel:ropertiesName, internalField().group() ) ); const scalarField& y = turbModel.y()[patchi]; const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; const scalarField magUp(mag(Uw.patchInternalField() - Uw)); const tmp<scalarField> tnuw = turbModel.nu(patchi); const scalarField& nuw = tnuw(); const scalarField& nutw = *this; tmp<scalarField> tuTau(new scalarField(patch().size(), 0.0)); scalarField& uTau = tuTau.ref(); forAll(uTau, facei) { scalar ut = sqrt((nutw[facei] + nuw[facei])*magGradU[facei]); if (ut > ROOTVSMALL) { int iter = 0; scalar err = GREAT; do { scalar kUu = min(kappa_*magUp[facei]/ut, 50); scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu); scalar f = - ut*y[facei]/nuw[facei] + magUp[facei]/ut + 1/(E_*exp(kappa_*0))*(fkUu - 1.0/6.0*kUu*sqr(kUu)); scalar df = y[facei]/nuw[facei] + magUp[facei]/sqr(ut) + 1/(E_*exp(kappa_*0))*kUu*fkUu/ut; scalar uTauNew = ut + f/df; err = mag((ut - uTauNew)/ut); ut = uTauNew; } while (ut > ROOTVSMALL && err > 0.01 && ++iter < 10); uTau[facei] = max(0.0, ut); } } return tuTau; } |
|
April 4, 2017, 07:04 |
|
#2 | |
Member
|
Quote:
The nodal coordinates can be obtained as Code:
mesh.points()[nodeID] Code:
Cf.boundaryField()[patchID][facei] |
||
April 9, 2017, 11:45 |
|
#3 | |
New Member
Xu Yiming
Join Date: Jan 2017
Posts: 11
Rep Power: 9 |
Quote:
With your help,I can get the nodal coordinates by using the code "turbModel.mesh().points()[nodeID]" successfully. But I still don't know how to get the "nodeID" of the current calculation grid point in the USpalding wall function.Can you help me? Thank you again. Yiming |
||
April 10, 2017, 06:59 |
|
#4 | |
Member
|
Quote:
Code:
forAll(mesh.boundary(), patchID) { const word& patchName = mesh.boundary()[patchID].name(); forAll (mesh.boundary()[patchID],facei) { const label& faceID = mesh.boundaryMesh()[patchID].start() + facei; forAll (mesh.faces()[faceID], nodei) { const label& nodeID = mesh.faces()[faceID][nodei]; } } } |
||
April 16, 2017, 22:43 |
|
#5 | |
New Member
Xu Yiming
Join Date: Jan 2017
Posts: 11
Rep Power: 9 |
Quote:
The code what you have written was exactly the right solution! the code I used to get point coordinate in the wall function is: Code:
vector pointX(0,0,0); const label& faceID = patch().boundaryMesh()[patchi].start() + facei; forAll (turbModel.mesh().faces()[faceID], nodei) { const label& nodeID = turbModel.mesh().faces()[faceID][nodei]; } pointX=turbModel.mesh().points()[nodeID]; Yiming |
||
April 18, 2017, 04:07 |
|
#6 | |
Member
|
Quote:
You are most welcome. I am glad that I could be of help. Enjoy! |
||
|
|
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 Training Jan-Jul 2017, Virtual, London, Houston, Berlin | CFDFoundation | OpenFOAM Announcements from Other Sources | 0 | January 4, 2017 06:15 |
OpenFOAM Training Jan-Apr 2017, Virtual, London, Houston, Berlin | cfd.direct | OpenFOAM Announcements from Other Sources | 0 | September 21, 2016 11:50 |
[Gmsh] Gmsh and samplesurface | touf | OpenFOAM Meshing & Mesh Conversion | 2 | December 10, 2007 02:27 |
CFX4.3 -build analysis form | Chie Min | CFX | 5 | July 12, 2001 23:19 |