|
[Sponsors] |
accessing internal cell gradient field at boundary when applying boundary condition |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 |
Member
Vishal Achasrya
Join Date: Nov 2011
Posts: 38
Rep Power: 14 ![]() |
Hi,
I am looking at implementing a generic BC that also involves a second gradient at the boundary. Typically, if you look at zeroGradient or fixedGradient BC, the this->internalField value is available and then used to apply the values at the patch. For a second gradient, I need to take the gradient in the cell and then change its value first to a new gradient and then take the new gradient along with this->internalField to change the value at the patch. How do you generate gradient values in boundary cells only at the time of BC application so that there is low memory usage? A simple starting point is a zero second gradient BC upon which the generic BC can be built, but I am unsure how to get the gradient at the boundary internal field cells first. Also, the boundary patch face Sf() vector and the cell center C() at the boundary are also needed so that the correct component of the gradient along the cell-center-to-patch-center is used when applying/making changes. Thanks in advance! |
|
![]() |
![]() |
![]() |
![]() |
#2 | |
Senior Member
Andrew Somorjai
Join Date: May 2013
Posts: 175
Rep Power: 13 ![]() |
Quote:
|
||
![]() |
![]() |
![]() |
![]() |
#3 | |
Member
Vishal Achasrya
Join Date: Nov 2011
Posts: 38
Rep Power: 14 ![]() |
Quote:
|
||
![]() |
![]() |
![]() |
![]() |
#4 | |
Senior Member
Andrew Somorjai
Join Date: May 2013
Posts: 175
Rep Power: 13 ![]() |
Quote:
Code:
//- Return gradient at boundary virtual Field<Type>& gradient() { return gradient_; } I would assume you make the gradient initially a fixedGradient. There are other patch fields as well. You just have to find the right type and inherit from its class. |
||
![]() |
![]() |
![]() |
![]() |
#5 | |
Member
Vishal Achasrya
Join Date: Nov 2011
Posts: 38
Rep Power: 14 ![]() |
Quote:
|
||
![]() |
![]() |
![]() |
![]() |
#6 | |
Senior Member
Andrew Somorjai
Join Date: May 2013
Posts: 175
Rep Power: 13 ![]() |
Quote:
|
||
![]() |
![]() |
![]() |
![]() |
#7 |
Member
Vishal Achasrya
Join Date: Nov 2011
Posts: 38
Rep Power: 14 ![]() |
Let us say we are looking at a quantity 'f' and solving for this and I want to apply BC to this.
I want to do d/dx(df/dx) = 0 at the boundary. To apply this, I need to first know the df/dx (gradient) at cell center in cell next to boundary and then use this value along with value of f at cell center to update f at the patch. d/dx(df/dx) = 0 is the same as applying f_patch = f_cell + df/dx_cell * (x_patch-x_cell) |
|
![]() |
![]() |
![]() |
![]() |
#8 |
Member
Vishal Achasrya
Join Date: Nov 2011
Posts: 38
Rep Power: 14 ![]() |
I figured it out.
The best way is to compute gradient and store it in a variable and then pass it as a word to this BC. You can then use lookup object to fund the value of the gradient and then apply it. The other faster way is to do it in the main code, after solve() has completed. For this, the BC must be set to calculated first and then you can access the boundaryField and internalFieldRef() values and update as needed. For some reason this way of applying BC is much faster computationally... ? |
|
![]() |
![]() |
![]() |
Tags |
boundary condition, second gradient |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Foam::error::PrintStack | almir | OpenFOAM Running, Solving & CFD | 92 | May 21, 2024 07:56 |
My radial inflow turbine | Abo Anas | CFX | 27 | May 11, 2018 01:44 |
Internal field boundary condition confusion | cleoo | OpenFOAM Pre-Processing | 3 | September 6, 2016 06:58 |
Low Mixing time Problem | Mavier | CFX | 5 | April 29, 2013 00:00 |
CFX fails to calculate a diffuser pipe flow | shenying0710 | CFX | 7 | March 26, 2013 04:13 |