|
[Sponsors] |
August 21, 2012, 23:37 |
Access to the velocity at boundary cells
|
#1 |
New Member
Wei Liu
Join Date: Apr 2011
Location: West Lafayette, IN
Posts: 29
Rep Power: 15 |
Hi all,
I want to use the velocity at boundary cells and velocity at the boundary face. I found that this code "const fvPatchField<vector>& Up = patch().lookupPatchField<volVectorField, vector>("U");" could obtain the velocity vector at the boundary face. Is there any similar code to obtain the velocity vector at the boundary cell? or other methods? Many thanks! Mathslw |
|
August 22, 2012, 01:21 |
|
#2 |
Senior Member
Yogesh Bapat
Join Date: Oct 2010
Posts: 102
Rep Power: 16 |
Hello,
patch.faceCells() will give you list of cells adjecent to boundary. To get adjecent cell for a face, do patch.faceCells()[facei]. Using this cell id and volVectorField U you can access value of velocity in the cell. Regards, -Yogesh |
|
August 22, 2012, 03:33 |
|
#3 |
Senior Member
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 18 |
Another way to directly access the patch-nearest cells is to use U.boundaryField()[patchi].patchInternalField(), whereas patchi is your patch id which is found using const label patchi = mesh.boundaryMesh().findPatchID("bottom").
|
|
August 22, 2012, 15:06 |
|
#4 | |
New Member
Wei Liu
Join Date: Apr 2011
Location: West Lafayette, IN
Posts: 29
Rep Power: 15 |
Quote:
According you your suggestion, I write the following: const labelList cells = patch().faceCells(); vectorField Uac = Ua[cells]; Is that right? Thanks! Wei |
||
August 22, 2012, 15:08 |
|
#5 | |
New Member
Wei Liu
Join Date: Apr 2011
Location: West Lafayette, IN
Posts: 29
Rep Power: 15 |
Quote:
Thanks! Wei |
||
August 22, 2012, 15:13 |
|
#6 | |
New Member
Wei Liu
Join Date: Apr 2011
Location: West Lafayette, IN
Posts: 29
Rep Power: 15 |
Quote:
Hi Yogesh, According you your suggestion, I write the following: const fvPatchField<vector>& Uf = patch().lookupPatchField<volVectorField, vector>("U"); const labelList cells = patch().faceCells(); vectorField Uc = U[cells]; Is that right? Thanks! Wei |
||
August 23, 2012, 01:16 |
|
#7 |
Senior Member
Yogesh Bapat
Join Date: Oct 2010
Posts: 102
Rep Power: 16 |
Hello Wei,
You need to loop over cellList to access value of individual cell. forAll(cells,celli) { vector Ui = U[celli] } If you need directly field of boundary velocities, better option is suggested by Arne in his post. Regards, -Yogesh |
|
August 23, 2012, 11:53 |
|
#8 | |
New Member
Wei Liu
Join Date: Apr 2011
Location: West Lafayette, IN
Posts: 29
Rep Power: 15 |
Quote:
Actually, I want to modify the boudary condition define in the adjointShapeOptimizationFoam. The original code is as following: const fvsPatchField<scalar>& phiap = patch().lookupPatchField<surfaceScalarField, scalar>("phia"); const fvPatchField<vector>& Up = patch().lookupPatchField<volVectorField, vector>("U"); scalarField Un(mag(patch().nf() & Up)); vectorField UtHat((Up - patch().nf()*Un)/(Un + SMALL)); vectorField Uan(patch().nf()*(patch().nf() & patchInternalField())); vectorField:perator=(phiap*patch().Sf()/sqr(patch().magSf()) + UtHat); In this code, it uses the velocity on the boundary face and there is no loop. Then I want to use the velocity at the boundary cell, in the same way, I think there should not have any loop. Do you have any idea about that? Moreover, I also need the gradient of the velocity at the boundary cell, can I use volTensorField gradUc=fvc::grad(Uc) if Uc is the velocity at the boundary cell. Many thanks! Wei |
||
August 23, 2012, 15:12 |
|
#9 | |
New Member
Wei Liu
Join Date: Apr 2011
Location: West Lafayette, IN
Posts: 29
Rep Power: 15 |
Quote:
Actually, I am trying to program a BC class. I found that the following code could obtain the velocity at the boundary cell: const volVectorField& Uc = db().lookupObject<volVectorField>("U"); What about if I want the gradient of this velocity at the boundary cell? Thanks! Wei |
||
August 24, 2012, 01:00 |
|
#10 |
Senior Member
Yogesh Bapat
Join Date: Oct 2010
Posts: 102
Rep Power: 16 |
Hello Wei,
const volVectorField& Uc = db().lookupObject<volVectorField>("U") would give you velocity field over entire domain. To get at boundary you need to do as Arne suggested in his post U.boundaryField()[patchi].patchInternalField(). About gradient I am not very sure, but I think you need to calculate it and then use it by accessing its patch internalField in the same way as for velocity. Regards, -Yogesh |
|
August 24, 2012, 13:28 |
|
#11 | |
New Member
Wei Liu
Join Date: Apr 2011
Location: West Lafayette, IN
Posts: 29
Rep Power: 15 |
Quote:
Thanks for your reply! If I use U.boundaryField()[patchi].patchInternalField(), the code would be: vectorField& Uac = U.boundaryField()[patch()].patchInternalField();? Since this is in the BC class, can I use patch() here? When I compiled, I was told ‘U’ was not declared in this scope. Then how can I declare the U here. Many thanks! Wei |
||
October 3, 2012, 21:22 |
east and north cell values
|
#12 |
Member
,...
Join Date: Apr 2011
Posts: 92
Rep Power: 14 |
Is there any way (any function) to get the value of a parameter at the east and north of a specific cell?
|
|
November 22, 2017, 10:10 |
access to value of a quantity
|
#13 |
Senior Member
A. Min
Join Date: Mar 2015
Posts: 308
Rep Power: 12 |
Hi
Basikly, how can I access to value of a quantity like U in a cell? thanks |
|
January 9, 2018, 19:17 |
|
#14 |
Member
Join Date: Oct 2013
Posts: 92
Rep Power: 13 |
||
January 10, 2018, 00:31 |
|
#15 |
Senior Member
A. Min
Join Date: Mar 2015
Posts: 308
Rep Power: 12 |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Wind turbine simulation | Saturn | CFX | 60 | July 17, 2024 06:45 |
[snappyHexMesh] SnappyHexMesh for internal Flow | vishwa | OpenFOAM Meshing & Mesh Conversion | 24 | June 27, 2016 09:54 |
[ICEM] error analysis | despaired student | ANSYS Meshing & Geometry | 7 | June 27, 2012 12:57 |
Velocity inlet boundary condition for porous medium | Chander | CFX | 3 | March 11, 2012 22:18 |
Variables Definition in CFX Solver 5.6 | R P | CFX | 2 | October 26, 2004 03:13 |