|
[Sponsors] |
Accessing a field value in a boundary condition |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 22, 2015, 10:32 |
Accessing a field value in a boundary condition
|
#1 |
Senior Member
Join Date: Jul 2013
Posts: 124
Rep Power: 13 |
Hi, I am trying to solve a convection-diffusion problem in which my viscosity and diffusivity are both functions of the local concentration, C, and I need a fixedFlux boundary condition. Normally we could use the fixedGradient boundary condition and just set the gradient as flux/diffusivity, but in this case the diffusivity is not a constant.
So, I am trying to edit the fixedGradient b.c. to allow me to divide by the local diffusivity. What is the proper way to access a field variable inside a boundary condition? This compiles with no errors, but it gives hanging pointer errors when I try to run the solver. template<class Type> void myfixedFluxFvPatchField<Type>::evaluate(const Pstream::commsTypes) { // THIS IS THE LINE OF INTEREST const fvPatchField<scalar>& Cp = this->patch().template lookupPatchField<surfaceScalarField, scalar>("C"); if (!this->updated()) { this->updateCoeffs(); } Field<Type>::operator= ( this->patchInternalField() + gradient_/this->patch().deltaCoeffs() ); fvPatchField<Type>::evaluate(); } Does anyone know the proper way to access my concentration, C (a volScalarField) in my boundary condition? Thanks, Jesse |
|
July 22, 2015, 12:22 |
|
#2 |
Senior Member
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 13 |
You can use groovyBC form that. Declare C as a volScalarObject with an IOobject in the solver code and then use groovyBC to set the boundary condition
|
|
July 22, 2015, 13:25 |
|
#3 |
Senior Member
Join Date: Jul 2013
Posts: 124
Rep Power: 13 |
Hi, thanks for your suggestion. I am not familiar with the groovyBC, but it seems it should be implemented something like as follows:
inlet { type groovyBC; refValue uniform 1; gradientExpression "J/D"; variables "J=10; D=C*1e-4;"; } So the gradient I want to set is essentially J/D, where D is my diffusivity and is a function of the concentration C (here I've said that D=C*1e-4 for example). Is this the appropriate way to handle this? I'm unclear, because C is a volScalarField, so I'm not sure what that makes gradientExpression, nor if this is truly what I want. As is, it seems to through a floating point error: #0 Foam::error:rintStack(Foam::Ostream&) at ??:? #1 Foam::sigFpe::sigHandler(int) at ??:? #2 in "/lib64/libc.so.6" #3 at ??:? #4 __libc_start_main in "/lib64/libc.so.6" #5 at ??:? Floating point exception Do you have any suggestions? Thanks again. |
|
July 22, 2015, 13:49 |
|
#4 |
Senior Member
Join Date: Jul 2013
Posts: 124
Rep Power: 13 |
Sorry, that was an unrelated problem with the solver.
|
|
July 22, 2015, 18:11 |
|
#5 |
Senior Member
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 13 |
It should be enough with the approach you are using in the code you have shown. If you declare a volScalarField with an IOobject in the constructor, inside your solver, groovyBC will be able to access to its values. It will iterate through each face of the patch and it will set the gradient according to the value of C in each face.
|
|
July 22, 2015, 18:44 |
|
#6 |
Senior Member
Join Date: Jul 2013
Posts: 124
Rep Power: 13 |
Thanks, I think you're right. groovyBC looks like a very useful tool.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Field value inside a boundary condition class | pcaron | OpenFOAM Programming & Development | 14 | October 17, 2022 10:40 |
Question about heat transfer coefficient setting for CFX | Anna Tian | CFX | 1 | June 16, 2013 07:28 |
Error finding variable "THERMX" | sunilpatil | CFX | 8 | April 26, 2013 08:00 |
vorticity boundary condition | bearcharge | Main CFD Forum | 0 | May 14, 2010 12:32 |
Boundary condition vector field gradient from two sides of patch face | quba | OpenFOAM | 0 | December 12, 2007 06:26 |