|
[Sponsors] |
How to impose a boundary condition inside a solver |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 20, 2016, 03:51 |
How to impose a boundary condition inside a solver
|
#1 |
New Member
Xiaoqiu HE
Join Date: Mar 2016
Location: Wuhan, China
Posts: 29
Rep Power: 10 |
Hi Dear Foamers~!
I am trying to test a program by prescribing the dirichlet BCs and source terms which are all calculated from the prescribed exact solution: Code:
fvScalarMatrix p1SinEquation ( fvm::Sp(1, p1) + fvc::div(v) ); // v is already known solve( p1SinEquation == p1SourceTerm ) //impose the source term p1SourceTerm = p1_Exact + fvc::div(v); //impose the BC const fvBoundaryMesh & meshBoundary = mesh.boundary(); forAll( meshBoundary, fvPatchID ) { const fvPatch & instantPatch = meshBoundary[ fvPatchID ]; forAll( instantPatch, elmtID ) { p1.boundaryField()[fvPatchID][elmtID] = p1_Exact.boundaryField()[fvPatchID][elmtID]; } } I am open for all advices and thanks in advance! |
|
April 20, 2016, 05:43 |
|
#2 |
Senior Member
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 13 |
You could create a variable inside the solver and create a custom boundary conditions using swak4foam or codexFixed custom BC
|
|
April 20, 2016, 07:10 |
Thank you for your reply!
|
#3 |
New Member
Xiaoqiu HE
Join Date: Mar 2016
Location: Wuhan, China
Posts: 29
Rep Power: 10 |
||
April 27, 2016, 01:53 |
|
#5 |
Member
Zhiheng Wang
Join Date: Mar 2016
Posts: 72
Rep Power: 10 |
Hi Tobi,
I am facing problem to write grrovy BC while the Boundary Condition is coupled/mapped of 0/T and 0/U , can I write a coupled or mapped boundary I have tried by Code stream but it was a disaster. U=(diff*(gradYi)/(1-Yi)) and gradT= rho*U*Hf/kappa Can i write this with groovy BC for inlet ??? |
|
April 28, 2016, 01:35 |
|
#7 |
Member
Zhiheng Wang
Join Date: Mar 2016
Posts: 72
Rep Power: 10 |
||
May 9, 2016, 04:59 |
|
#8 |
New Member
Xiaoqiu HE
Join Date: Mar 2016
Location: Wuhan, China
Posts: 29
Rep Power: 10 |
Hi Dear Foamers~
Here I want to share my solution about this issue. I only use OpenFOAM in order to impose a BC. The field I want to deal is pS, pC, vS, vC. First I implemented codes for imposing the BC Code:
const fvBoundaryMesh & thisBoundary = mesh.boundary(); //here I get the boundary of the mesh forAll( thisBoundary, fvPatchID ) // go through all the patchs of the boundary { const fvPatch & thisPatch = thisBoundary[ fvPatchID ]; Info << "\n Imposing the boundary condition on the fvPatch of " << thisPatch.name() << endl; const vectorField & position = thisPatch.Cf(); // get the cell face centers' positions forAll( thisPatch, elmtID ) // imposing values on the centers of all the cell faces of this patch { const scalar & x = position[elmtID].component(0); const scalar & y = position[elmtID].component(1); //you can replace your function on the right side of the = pS.boundaryField()[fvPatchID][elmtID] = -1 * Foam::exp(-1 * x) * Foam::cos( x ); pC.boundaryField()[fvPatchID][elmtID] = Foam::exp(-1 * x) * Foam::sin( x ); vS.boundaryField()[fvPatchID][elmtID].component(0) = -1 * Foam::exp(-1 * x) * Foam::cos( x ); vS.boundaryField()[fvPatchID][elmtID].component(1) = 2 * Foam::cos( x ) * Foam::sin( y ) ; vC.boundaryField()[fvPatchID][elmtID].component(0) = Foam::exp(-1 * x) * Foam::sin( x ); vC.boundaryField()[fvPatchID][elmtID].component(1) = Foam::sin( x ) * Foam::cos( y ); } } As old saying in China goes, "抛砖引玉", which means "showing a brick on the market in order to motivate others to show sapphire on the market", here I post my solution for dear foamers' reference and I am always open for any advice of improvement. Thanks! |
|
Tags |
boudary condition, dirichlet |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
fluent divergence for no reason | sufjanst | FLUENT | 2 | March 23, 2016 17:08 |
Basic Nozzle-Expander Design | karmavatar | CFX | 20 | March 20, 2016 09:44 |
Question about heat transfer coefficient setting for CFX | Anna Tian | CFX | 1 | June 16, 2013 07:28 |
An error has occurred in cfx5solve: | volo87 | CFX | 5 | June 14, 2013 18:44 |
meshing F1 front wing | Steve | FLUENT | 0 | April 17, 2003 13:37 |