CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Get the area of each wall using to source term only in boundary cell

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 2, 2020, 07:36
Default Get the area of each wall using to source term only in boundary cell
  #1
Senior Member
 
kimy
Join Date: Mar 2019
Location: https://t.me/pump_upp
Posts: 164
Rep Power: 7
qi.yang@polimi.it is on a distinguished road
Send a message via ICQ to qi.yang@polimi.it Send a message via AIM to qi.yang@polimi.it Send a message via Yahoo to qi.yang@polimi.it
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.
Attached Files
File Type: doc log.doc (4.5 KB, 6 views)
qi.yang@polimi.it is offline   Reply With Quote

Old   September 2, 2020, 08:02
Default
  #2
Senior Member
 
kimy
Join Date: Mar 2019
Location: https://t.me/pump_upp
Posts: 164
Rep Power: 7
qi.yang@polimi.it is on a distinguished road
Send a message via ICQ to qi.yang@polimi.it Send a message via AIM to qi.yang@polimi.it Send a message via Yahoo to qi.yang@polimi.it
This is the mesh (blockMesh and extrudeMesh) I used to make a simple calculation.
Attached Images
File Type: png mesh.png (14.0 KB, 7 views)
qi.yang@polimi.it is offline   Reply With Quote

Old   September 2, 2020, 10:47
Default
  #3
New Member
 
Wenyuan Fan
Join Date: Mar 2017
Posts: 27
Rep Power: 9
Wenyuan is on a distinguished road
Hi,

In order to assign values to patchArea, you need to use the index for the cell adjacent to faceI, not faceI.
Wenyuan is offline   Reply With Quote

Old   September 2, 2020, 11:23
Default
  #4
Senior Member
 
kimy
Join Date: Mar 2019
Location: https://t.me/pump_upp
Posts: 164
Rep Power: 7
qi.yang@polimi.it is on a distinguished road
Send a message via ICQ to qi.yang@polimi.it Send a message via AIM to qi.yang@polimi.it Send a message via Yahoo to qi.yang@polimi.it
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.


Quote:
Originally Posted by Wenyuan View Post
Hi,

In order to assign values to patchArea, you need to use the index for the cell adjacent to faceI, not faceI.
qi.yang@polimi.it is offline   Reply With Quote

Old   September 2, 2020, 11:31
Default
  #5
New Member
 
Wenyuan Fan
Join Date: Mar 2017
Posts: 27
Rep Power: 9
Wenyuan is on a distinguished road
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].
Wenyuan is offline   Reply With Quote

Old   September 2, 2020, 11:52
Default
  #6
Senior Member
 
kimy
Join Date: Mar 2019
Location: https://t.me/pump_upp
Posts: 164
Rep Power: 7
qi.yang@polimi.it is on a distinguished road
Send a message via ICQ to qi.yang@polimi.it Send a message via AIM to qi.yang@polimi.it Send a message via Yahoo to qi.yang@polimi.it
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);
    }
}
Note that the size of left matrix and right is not the same.

Quote:
Originally Posted by Wenyuan View Post
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].
qi.yang@polimi.it is offline   Reply With Quote

Old   September 2, 2020, 12:12
Default
  #7
New Member
 
Wenyuan Fan
Join Date: Mar 2017
Posts: 27
Rep Power: 9
Wenyuan is on a distinguished road
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?
Wenyuan is offline   Reply With Quote

Old   September 2, 2020, 12:17
Default
  #8
Senior Member
 
kimy
Join Date: Mar 2019
Location: https://t.me/pump_upp
Posts: 164
Rep Power: 7
qi.yang@polimi.it is on a distinguished road
Send a message via ICQ to qi.yang@polimi.it Send a message via AIM to qi.yang@polimi.it Send a message via Yahoo to qi.yang@polimi.it
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:
Originally Posted by Wenyuan View Post
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?
qi.yang@polimi.it is offline   Reply With Quote

Old   September 2, 2020, 12:32
Default
  #9
New Member
 
Wenyuan Fan
Join Date: Mar 2017
Posts: 27
Rep Power: 9
Wenyuan is on a distinguished road
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];
            }
        }
    }
The following line assigns the U1 value at faceCelli to Uw at the same cell.
Code:
                Uw[faceCelli] = U1[faceCelli];
So you can do similar things to patchArea by substituting Uw with patchArea and using the face area on the right hand side.
Wenyuan is offline   Reply With Quote

Old   September 2, 2020, 12:41
Default
  #10
Senior Member
 
kimy
Join Date: Mar 2019
Location: https://t.me/pump_upp
Posts: 164
Rep Power: 7
qi.yang@polimi.it is on a distinguished road
Send a message via ICQ to qi.yang@polimi.it Send a message via AIM to qi.yang@polimi.it Send a message via Yahoo to qi.yang@polimi.it
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:
Originally Posted by Wenyuan View Post
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];
            }
        }
    }
The following line assigns the U1 value at faceCelli to Uw at the same cell.
Code:
                Uw[faceCelli] = U1[faceCelli];
So you can do similar things to patchArea by substituting Uw with patchArea and using the face area on the right hand side.
qi.yang@polimi.it is offline   Reply With Quote

Old   September 2, 2020, 12:47
Default
  #11
New Member
 
Wenyuan Fan
Join Date: Mar 2017
Posts: 27
Rep Power: 9
Wenyuan is on a distinguished road
Please forget wallList.
Use facei to get face area.
Wenyuan is offline   Reply With Quote

Old   September 2, 2020, 13:12
Default
  #12
Senior Member
 
kimy
Join Date: Mar 2019
Location: https://t.me/pump_upp
Posts: 164
Rep Power: 7
qi.yang@polimi.it is on a distinguished road
Send a message via ICQ to qi.yang@polimi.it Send a message via AIM to qi.yang@polimi.it Send a message via Yahoo to qi.yang@polimi.it
I solved the problem. Thanks a lot.
Quote:
Originally Posted by Wenyuan View Post
Please forget wallList.
Use facei to get face area.
qi.yang@polimi.it is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 07:06.