How to write a boundary condition which depends on a seperate patch
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. |
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 |
Hi,
groovyBC should be able to do this. Fabian |
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 |
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 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++ -*----------------------------------*\ Hope this helps! Have a great day ahead! Philippose |
Quote:
Thanks Bernhard |
groovyBC bug???
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 |
BTW, I am using OpenFOAM 1.6.
Ning |
If you don't want to use groovyBC, I'm pretty sure something like this would work:
Code:
label wall1 = mesh.boundaryMesh().findPatchID("wall1"); |
There is outletMappedUniformInlet in 1.7.x, which could be a good base as well...
|
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 |
the below seems to work.
const fvMesh& mesh = this->internalField().mesh(); |
[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 |
All times are GMT -4. The time now is 00:08. |