|
[Sponsors] |
How to write a boundary condition which depends on a seperate patch |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 29, 2010, 21:15 |
How to write a boundary condition which depends on a seperate patch
|
#1 |
Member
Ning Yang
Join Date: Mar 2009
Location: University Park, PA, USA
Posts: 84
Rep Power: 17 |
I am trying to write a new BC (for species A on wall 1) in OpenFOAM which is dependent on the data from a different patch (species B on wall 2), simply expressed as:
A_species_concentration_gradient_at_wall_1 = B_species_concentration_gradient_at_wall_2 Is there any way to obtain B_species concentration at wall 2 while writing a BC for A species on wall 1? Thank you. |
|
June 30, 2010, 04:39 |
|
#2 |
Senior Member
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 17 |
Hi,
did you take a look at the directMappedFixedValue-BC in Foam? There are also data from another patch needed. For getting access to the other field you should be able to use db().lookupObject<volScalarField>("B_species"). Regards, Stefan |
|
June 30, 2010, 10:46 |
|
#3 |
Senior Member
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19 |
Hi,
groovyBC should be able to do this. Fabian |
|
June 30, 2010, 19:57 |
|
#4 |
Member
Ning Yang
Join Date: Mar 2009
Location: University Park, PA, USA
Posts: 84
Rep Power: 17 |
Fabian:
I looked through the groovyBC demo and here is one example I found from average-t-junction: outlet1 { type groovyBC; valueExpression "0.5*(pInlet+pOutlet2)"; variables "pInlet@inlet=sum(p*mag(Sf()))/sum(mag(Sf())); pOutlet2@outlet2=p;"; value uniform 100010; } here what does @ work? for example, @outlet2 means p value taken from patch outlet2? I tested it and found it is not the case. Do u have any idea how to get data from a different patch? Thank you. Ning |
|
July 1, 2010, 08:02 |
|
#5 |
Senior Member
Philippose Rajan
Join Date: Mar 2009
Location: Germany
Posts: 552
Rep Power: 25 |
Hello Ning,
A Good Day to you!! As Fabian correctly pointed out, the best and easiest solution for you is to use the groovyBC library. I use it routinely, and it fulfills the requirement of making one patch dependent on another beautifully :-)! The dictionary that you found in the example is what you are looking for, and it works fine.... Code:
outlet1 { type groovyBC; valueExpression "0.5*(pInlet+pOutlet2)"; variables "pInlet@inlet=sum(p*mag(Sf()))/sum(mag(Sf())); pOutlet2@outlet2=p;"; value uniform 100010; } Now... in the example above, the variables entry can be explained up as: "Create a variable called pInlet on the patch with the name inlet whose value is calculated as the area weighted average of the pressure (p) on that patch" This variable pInlet is then later used in the valueExpression entry to actually define how the pressure on the current patch outlet1 depends on the patch inlet and any other patches (In this case, also the pressure on patch outlet2 via the variable pOutlet2) This method works fine.... an example from me which works looks like this: Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 1.4.1 | | \\ / A nd | Web: http://www.openfoam.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; root "/home/cfduser/OpenFOAM/cfduser-1.4.1/run"; case ""; instance "0"; local ""; class volScalarField; object p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 2 -2 0 0 0 0]; internalField uniform 2352.9411; // 20 bar boundaryField { fixedWalls { type zeroGradient; } inlet { type groovyBC; variables "pLS@outletLS=sum(p*mag(Sf()))/sum(mag(Sf()));"; valueExpression "pLS + (9.5*100000/850)"; value uniform 2352.9411; } outlet { type fixedValue; value $internalField; } outletLS { type zeroGradient; } } // ************************************************************************* // Hope this helps! Have a great day ahead! Philippose |
|
July 1, 2010, 13:22 |
|
#6 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Thanks Bernhard |
||
July 6, 2010, 18:46 |
groovyBC bug???
|
#7 |
Member
Ning Yang
Join Date: Mar 2009
Location: University Park, PA, USA
Posts: 84
Rep Power: 17 |
Hi Philippose:
I used the groovyBC to apply a constant gradient bc, to test the accuracy of the code. Here is the bc setup: working { type groovyBC; value uniform 0; valueExpression "0"; gradientExpression "100"; //"-Deff1*grad"; fractionExpression "0"; // variables "grad=snGrad(C_peroxide);Deff1=0.3827;"; } Then I used wallMassFlux (modified from wallHeatFlux utility) to calculate the species gradient on the wall and found that the gradient is a lot higher than 100. The type of error has been reported by elcovv (http://www.cfd-online.com/Forums/ope...r-restart.html) previously. I tried to rename groovyBC as a random name according to elcovv's suggestion but it does not help. I am 100% sure that my wallMassFlux utility works properly because I tested it using a fixedGradient bc instead. The results has been consistent. Have u ever met similar problems? Thank you. Ning |
|
July 6, 2010, 18:50 |
|
#8 |
Member
Ning Yang
Join Date: Mar 2009
Location: University Park, PA, USA
Posts: 84
Rep Power: 17 |
BTW, I am using OpenFOAM 1.6.
Ning |
|
August 5, 2010, 11:25 |
|
#9 |
Senior Member
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19 |
If you don't want to use groovyBC, I'm pretty sure something like this would work:
Code:
label wall1 = mesh.boundaryMesh().findPatchID("wall1"); fixedGradientFvPatchScalarField& buffer_speciesA = refCast<fixedGradientFvPatchScalarField>(speciesA.boundaryField()[wall1]); scalarField& grad_speciesA = buffer_speciesA.gradient(); label wall2 = mesh.boundaryMesh().findPatchID("wall2"); fixedGradientFvPatchScalarField& buffer_speciesB = refCast<fixedGradientFvPatchScalarField>(speciesB.boundaryField()[wall2]); scalarField& grad_speciesB = buffer_speciesB.gradient(); forAll(grad_speciesA,i) { grad_speciesA[i] = grad_speciesB[i] } |
|
August 8, 2010, 12:55 |
|
#10 |
Senior Member
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19 |
There is outletMappedUniformInlet in 1.7.x, which could be a good base as well...
|
|
March 8, 2022, 09:03 |
|
#11 |
New Member
Hongbin Wang
Join Date: Feb 2020
Posts: 20
Rep Power: 6 |
I have the same problem.
i like to try the code. but an error shows below. how to declare mesh and does it need to include any header file? many thanks. atmBoundaryLayerInletVelocity_test2FvPatchVectorFi eld.C:201:53: error: ‘mesh’ was not declared in this scope |
|
March 8, 2022, 11:07 |
|
#12 |
New Member
Hongbin Wang
Join Date: Feb 2020
Posts: 20
Rep Power: 6 |
the below seems to work.
const fvMesh& mesh = this->internalField().mesh(); |
|
March 10, 2022, 20:40 |
|
#13 |
New Member
陈清泉
Join Date: Mar 2022
Posts: 2
Rep Power: 0 |
[QUOTE=Origami;823785]the below seems to work.
Hi,my boy I am new in civil engineer, I have same problem in groovyBC, can you have a full discussion about the BC. Best wishes to u. chen |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mixed/Robin boundary condition | aaev | OpenFOAM Bugs | 2 | December 15, 2011 14:03 |
CheckMeshbs errors | ivanyao | OpenFOAM Running, Solving & CFD | 2 | March 11, 2009 02:34 |
Airfoil boundary condition | Frank | Main CFD Forum | 1 | April 21, 2008 18:36 |
Slip boundary condition what is inside | normunds | OpenFOAM Running, Solving & CFD | 2 | June 4, 2007 06:45 |
How to write the boundary condition for round free jet | Jason | Main CFD Forum | 8 | July 26, 1999 16:15 |