|
[Sponsors] |
Get the area of each wall using to source term only in boundary cell |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 2, 2020, 07:36 |
Get the area of each wall using to source term only in boundary cell
|
#1 |
Senior Member
|
Hi guys,
I defined a Uw which has the same size of the total cell numbers to save the velocity only in the boundary cell. Due to the fact that the source term I need to use is Uw times the area of corresponding wall. Thus, I defined a patchArea (patchArea[faceI] = mesh.magSf().boundaryField()[patchID][faceI] used to save that area. Note that the size of patchArea is also same as Uw, however the index is not corresponding to each other. Is there a way to rearrange the order of patchArea, to make the index consistent with Uw? I uploaded a output log file here, as you can see, the index with a non-zero value in Uw means the wall cell index. But the order in patchArea needs to be modified. Thanks for your attention. |
|
September 2, 2020, 08:02 |
|
#2 |
Senior Member
|
This is the mesh (blockMesh and extrudeMesh) I used to make a simple calculation.
|
|
September 2, 2020, 10:47 |
|
#3 |
New Member
Wenyuan Fan
Join Date: Mar 2017
Posts: 27
Rep Power: 9 |
Hi,
In order to assign values to patchArea, you need to use the index for the cell adjacent to faceI, not faceI. |
|
September 2, 2020, 11:23 |
|
#4 |
Senior Member
|
Thanks for reply. I understood your point. the problem is that when I use mesh.magSf().boundaryField()[patchID][faceI] to get the area, the index is not consistent with that of cell.
|
|
September 2, 2020, 11:31 |
|
#5 |
New Member
Wenyuan Fan
Join Date: Mar 2017
Posts: 27
Rep Power: 9 |
Assume cellI is a near-wall cell, faceI is the corresponding face on the wall patch. patchArea[faceI] will assign the surface area to a cell with faceI being its index. What you want is patchArea[cellI].
|
|
September 2, 2020, 11:52 |
|
#6 |
Senior Member
|
I used the following code however the patchArea is wrong.
forAll(myPatch,cellI) { forAll(myPatch, faceI) { patchArea[cellI] = mesh.magSf().boundaryField()[patchID][faceI]; } } Code:
patchArea=dimensions [0 2 0 0 0 0 0]; internalField nonuniform List<scalar> 120 ( 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0.00382683433 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ) ; boundaryField { wall { type calculated; value uniform 0; } inlet { type calculated; value uniform 0; } outlet { type calculated; value uniform 0; } } Uw=dimensions [0 1 -1 0 0 0 0]; internalField uniform (0 0 0); boundaryField { wall { type calculated; value uniform (0 0 0); } inlet { type calculated; value uniform (0 0 0); } outlet { type calculated; value uniform (0 0 0); } } |
|
September 2, 2020, 12:12 |
|
#7 |
New Member
Wenyuan Fan
Join Date: Mar 2017
Posts: 27
Rep Power: 9 |
There is a method called faceCells() that gives you a list of indices of patch-adjacent cells. You call this on the wall patch and get a list, say, cellList. Then cellList[faceI] is the index for the cell adjacent to faceI.
By the way, how did you calculate the Uw field? |
|
September 2, 2020, 12:17 |
|
#8 | |
Senior Member
|
Code:
const fvPatchList& patches = mesh.boundary(); labelList wallList; wallList.clear(); forAll(patches, patchi) { const fvPatch& curPatch = patches[patchi]; if (isType<wallFvPatch>(curPatch)) { forAll(curPatch, facei) { label faceCelli = curPatch.faceCells()[facei]; wallList.resize(wallList.size()+1); wallList[wallList.size()-1]=faceCelli; } } } forAll(wallList,i) { Uw[wallList[i]] = U1[wallList[i]]; } Quote:
|
||
September 2, 2020, 12:32 |
|
#9 |
New Member
Wenyuan Fan
Join Date: Mar 2017
Posts: 27
Rep Power: 9 |
First, your code can be simplified to
Code:
const fvPatchList& patches = mesh.boundary(); forAll(patches, patchi) { const fvPatch& curPatch = patches[patchi]; if (isType<wallFvPatch>(curPatch)) { forAll(curPatch, facei) { label faceCelli = curPatch.faceCells()[facei]; Uw[faceCelli] = U1[faceCelli]; } } } Code:
Uw[faceCelli] = U1[faceCelli]; |
|
September 2, 2020, 12:41 |
|
#10 | |
Senior Member
|
I already tried this code but it was not right.
myArea[wallList[i]]=mesh.magSf().boundaryField()[wallList[i]]; I think the point is the size of left and right. Assign the value of velocity at wall without problem due to Uw and U1 has same size. Quote:
|
||
September 2, 2020, 12:47 |
|
#11 |
New Member
Wenyuan Fan
Join Date: Mar 2017
Posts: 27
Rep Power: 9 |
Please forget wallList.
Use facei to get face area. |
|
September 2, 2020, 13:12 |
|
#12 |
Senior Member
|
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using PengRobinsonGas EoS with sprayFoam | Jabo | OpenFOAM Running, Solving & CFD | 36 | July 16, 2024 04:52 |
Question about adaptive timestepping | Guille1811 | CFX | 25 | November 12, 2017 18:38 |
[swak4Foam] build problem swak4Foam OF 2.2.0 | mcathela | OpenFOAM Community Contributions | 14 | April 23, 2013 14:59 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 18:51 |
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues | michele | OpenFOAM Meshing & Mesh Conversion | 2 | July 15, 2005 05:15 |