CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

Access to the velocity at boundary cells

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   August 21, 2012, 22:37
Default Access to the velocity at boundary cells
  #1
New Member
 
Wei Liu
Join Date: Apr 2011
Location: West Lafayette, IN
Posts: 28
Rep Power: 6
mathslw is on a distinguished road
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
mathslw is offline   Reply With Quote

Old   August 22, 2012, 00:21
Default
  #2
Member
 
Yogesh Bapat
Join Date: Oct 2010
Posts: 41
Rep Power: 6
ybapat is on a distinguished road
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
ybapat is offline   Reply With Quote

Old   August 22, 2012, 02:33
Default
  #3
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 8
Arnoldinho is on a distinguished road
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").
Arnoldinho is offline   Reply With Quote

Old   August 22, 2012, 14:06
Default
  #4
New Member
 
Wei Liu
Join Date: Apr 2011
Location: West Lafayette, IN
Posts: 28
Rep Power: 6
mathslw is on a distinguished road
Quote:
Originally Posted by ybapat View Post
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
Hi Yogesh,

According you your suggestion, I write the following:
const labelList cells = patch().faceCells();
vectorField Uac = Ua[cells];
Is that right?

Thanks!

Wei
mathslw is offline   Reply With Quote

Old   August 22, 2012, 14:08
Default
  #5
New Member
 
Wei Liu
Join Date: Apr 2011
Location: West Lafayette, IN
Posts: 28
Rep Power: 6
mathslw is on a distinguished road
Quote:
Originally Posted by Arnoldinho View Post
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").
Do you mean "U.boundaryField()[patchi].patchInternalField()" is the velocity vector?
Thanks!

Wei
mathslw is offline   Reply With Quote

Old   August 22, 2012, 14:13
Default
  #6
New Member
 
Wei Liu
Join Date: Apr 2011
Location: West Lafayette, IN
Posts: 28
Rep Power: 6
mathslw is on a distinguished road
Quote:
Originally Posted by ybapat View Post
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

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
mathslw is offline   Reply With Quote

Old   August 23, 2012, 00:16
Default
  #7
Member
 
Yogesh Bapat
Join Date: Oct 2010
Posts: 41
Rep Power: 6
ybapat is on a distinguished road
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
ybapat is offline   Reply With Quote

Old   August 23, 2012, 10:53
Default
  #8
New Member
 
Wei Liu
Join Date: Apr 2011
Location: West Lafayette, IN
Posts: 28
Rep Power: 6
mathslw is on a distinguished road
Quote:
Originally Posted by ybapat View Post
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
Hi Yogesh,

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
mathslw is offline   Reply With Quote

Old   August 23, 2012, 14:12
Default
  #9
New Member
 
Wei Liu
Join Date: Apr 2011
Location: West Lafayette, IN
Posts: 28
Rep Power: 6
mathslw is on a distinguished road
Quote:
Originally Posted by ybapat View Post
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
Hi Yogesh,

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
mathslw is offline   Reply With Quote

Old   August 24, 2012, 00:00
Default
  #10
Member
 
Yogesh Bapat
Join Date: Oct 2010
Posts: 41
Rep Power: 6
ybapat is on a distinguished road
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
ybapat is offline   Reply With Quote

Old   August 24, 2012, 12:28
Default
  #11
New Member
 
Wei Liu
Join Date: Apr 2011
Location: West Lafayette, IN
Posts: 28
Rep Power: 6
mathslw is on a distinguished road
Quote:
Originally Posted by ybapat View Post
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
Hi Yogesh,

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
mathslw is offline   Reply With Quote

Old   October 3, 2012, 20:22
Default east and north cell values
  #12
Member
 
,...
Join Date: Apr 2011
Posts: 92
Rep Power: 5
mahdiiowa is an unknown quantity at this point
Is there any way (any function) to get the value of a parameter at the east and north of a specific cell?
mahdiiowa is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wind turbine simulation Saturn CFX 34 October 16, 2014 05:27
SnappyHexMesh for internal Flow vishwa OpenFOAM Native Meshers: snappyHexMesh and Others 23 August 6, 2014 03:50
[ICEM] error analysis despaired student ANSYS Meshing & Geometry 7 June 27, 2012 11: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 02:13


All times are GMT -4. The time now is 11:51.