# Flux Boundary Conditions

 Register Blogs Members List Search Today's Posts Mark Forums Read

 December 2, 2008, 19:05 Hi All, I have a square dom #1 Senior Member   Vishal Nandigana Join Date: Mar 2009 Location: Champaign, Illinois, U.S.A Posts: 208 Rep Power: 10 Hi All, I have a square domain and I am having the following equation fvm::ddt(C1) == fvm::laplacian(D1,C1) + K1 * fvc::laplacian(Phi) * fvm::Sp(1.0,C1)+ K1 * (fvc::grad(Phi) & fvc::grad(C1)) where D1,K1 are constants... Now I want to set b.cs at the wall of my C1 variable. The b.c is to set the flux = 0, which is given as -D1*grad(C1) - K1*C1*grad(Phi) = 0 at the upperwall and lowerwall of the square domain. Can anyone help me out how exactly should I go about doing this. Thanks Regards Vishal ahmmed04 likes this.

 December 3, 2008, 21:07 Hi, I saw your direct email c #2 Super Moderator   Takuya OSHIMA Join Date: Mar 2009 Location: Niigata City, Japan Posts: 518 Blog Entries: 1 Rep Power: 12 Hi, I saw your direct email contact to me. I do not have so much to suggest without the knowledge of the physics you are trying to solve, but what looks strange to me is that you have three sets of equations on the boundaries -D1*dC1/dx - K1*C1*dPhi/dx = 0 -D1*dC1/dy - K1*C1*dPhi/dy = 0 -D1*dC1/dz - K1*C1*dPhi/dz = 0 to determine C1 (assuming C1 is a scalar variable). If that in fact means a surface-normal gradient, you would be able to write a derived b.c. of mixed type. Takuya

 December 4, 2008, 13:13 Hi Takuya, >> "If that in f #3 Senior Member   Vishal Nandigana Join Date: Mar 2009 Location: Champaign, Illinois, U.S.A Posts: 208 Rep Power: 10 Hi Takuya, >> "If that in fact means a surface-normal gradient, you would be able to write a derived b.c. of mixed type. " Thanks a lot for the reply. May I know how exactly should we go about incorporating the above statement. (I am fairly new to OpenFoam). Could you tell me which tutorial I can follow or how exactly should I get started. Kindly do the needful. Thanks Regards Vishal

 December 4, 2008, 15:15 Dear Takuya, I just would l #4 Senior Member   Vishal Nandigana Join Date: Mar 2009 Location: Champaign, Illinois, U.S.A Posts: 208 Rep Power: 10 Dear Takuya, I just would like to add on my previous mail. I would like to make flux in the normal direction to be zero. i.e since my problem is 2-d, i want to make flux in the y direction to be zero. Hence my equation is -D1*dC1/dy - K1*C1*dPhi/dy = 0 or -D1*dC1/dn - K1*C1*dPhi/dn = 0 in general where n is normal direction. Kindly do the needful help. Regards Vishal Nandigana

 December 11, 2008, 10:20 The mixed type bc code is in \$ #5 Super Moderator   Takuya OSHIMA Join Date: Mar 2009 Location: Niigata City, Japan Posts: 518 Blog Entries: 1 Rep Power: 12 The mixed type bc code is in \$FOAM_SRC/finiteVolume/fields/fvPatchFields/basic/mixed. You'll also find several examples of its derived types under \$FOAM_SRC/finiteVolume/fields/fvPatchFields/derived (grep -r mixedFvPatch is your friend). Besides if you have knowledge about basic C++ and a bit of persistence, they just should be more than enough. T

 December 11, 2008, 12:58 Thanks for the tip Takuya. I w #6 Senior Member   Vishal Nandigana Join Date: Mar 2009 Location: Champaign, Illinois, U.S.A Posts: 208 Rep Power: 10 Thanks for the tip Takuya. I will certainly go through it. Vishal

 February 6, 2009, 02:44 Dear Takuya, I have coded m #7 Senior Member   Vishal Nandigana Join Date: Mar 2009 Location: Champaign, Illinois, U.S.A Posts: 208 Rep Power: 10 Dear Takuya, I have coded my flux boundary condition which I had mentioned before. The following is how my code looks, but I don't know why I get an error, I would like to know whether I have coded it in the correct way.. Kindly give your suggestions Boundary condition code looks like this: const polyPatchList& patches = mesh.boundaryMesh(); forAll (patches, patchI){ if(C1.boundaryField()[patchI].type()=="fixedGradient"){ fixedGradientFvPatchScalarField& nameOfYourChoice = refCast(C1.bounda ryField()[patchI]); scalarField& otherNameOfYourChoice = nameOfYourChoice.gradient(); otherNameOfYourChoice = -C1*Z1*fvc::snGrad(Phi); } } Kindly let me know what is the mistake I am making... As the error I get is something like this C1 Residual C2 Residual Phi Residual Begin to solve C11#0 Foam::error::printStack(Foam::-Ostream&) in "/home/vishal/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so" #1 Foam::sigFpe::sigFpeHandler(int) in "/home/vishal/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so" #2 Uninterpreted: [0xb7f12420] #3 Foam::divide(Foam::Field&, Foam::UList const&, Foam::UList const&) in "/home/vishal/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so" #4 Foam::operator/(Foam::UList const&, Foam::UList const&) in "/home/vishal/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so" #5 Foam::fixedGradientFvPatchField::evaluate( Foam::Pstream::commsTypes) in "/home/vishal/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libfiniteVolume.so" #6 Foam::GeometricField::GeometricBoundaryField::evaluate() in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/electroosmoticF oam" #7 Foam::fvMatrix::solve(Foam::Istream&) in "/home/vishal/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libfiniteVolume.so" #8 main in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/electroosmoticF oam" #9 __libc_start_main in "/lib/tls/i686/cmov/libc.so.6" #10 Foam::regIOobject::readIfModified() in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/electroosmoticF oam" Floating point exception Regards Vishal

 February 6, 2009, 10:01 Hi Vishal, Not so sure as I h #8 Super Moderator   Takuya OSHIMA Join Date: Mar 2009 Location: Niigata City, Japan Posts: 518 Blog Entries: 1 Rep Power: 12 Hi Vishal, Not so sure as I have never tried this way, but at least shouldn't otherNameOfYourChoice = -C1*Z1*fvc::snGrad(Phi); be otherNameOfYourChoice = -nameOfYourChoice*Z1*fvc::snGrad(Phi); ? Takuya

 February 6, 2009, 13:34 http://www.cfd-online.com/Ope #9 Senior Member   Vishal Nandigana Join Date: Mar 2009 Location: Champaign, Illinois, U.S.A Posts: 208 Rep Power: 10 ionFluxFvPatchScalarField.H ionFluxFvPatchScalarField.C C1 blockMeshDict Dear Takuya, Thanks a lot for your suggestion. I tried as you have suggested but I get the following error... vishal@kiwi2:~/OpenFOAM/vishal-1.5/run/PNP_code_sending_to_jing/coupledFoam_modified/coupledFoam\$ wmake SOURCE=coupledFoam.C ; g++ -m32 -Dlinux -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/home/vishal/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/vishal/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude -I/home/vishal/OpenFOAM/OpenFOAM-1.5/src/OSspecific/Unix/lnInclude -fPIC -pthread -c \$SOURCE -o Make/linuxGccDPOpt/coupledFoam.o In file included from coupledFoam.C:69: C1Eqn.H: In function 'int main(int, char**)': C1Eqn.H:12: error: no match for 'operator*' in 'Foam::operator-(const Foam::UList&) [with Type = double]() * Z1' /home/vishal/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionSet.H:266: note: candidates are: Foam::dimensionSet Foam::operator*(const Foam::dimensionSet&, const Foam::dimensionSet&) /home/vishal/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedScalar.H:56: note: Foam::dimensionedScalar Foam::operator*(const Foam::dimensionedScalar&, Foam::scalar) /home/vishal/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/scalarField.H:81: note: Foam::tmp > Foam::operator*(const Foam::UList&, const Foam::UList&) /home/vishal/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/scalarField.H:81: note: Foam::tmp > Foam::operator*(const Foam::UList&, const Foam::tmp >&) /home/vishal/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/scalarField.H:81: note: Foam::tmp > Foam::operator*(const Foam::tmp >&, const Foam::UList&) /home/vishal/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/scalarField.H:81: note: Foam::tmp > Foam::operator*(const Foam::tmp >&, const Foam::tmp >&) /home/vishal/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/symmTensorField.H:70: note: Foam::tmp > > Foam::operator*(const Foam::UList >&) /home/vishal/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/symmTensorField.H:70: note: Foam::tmp > > Foam::operator*(const Foam::tmp > >&) /home/vishal/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/tensorField.H:75: note: Foam::tmp > > Foam::operator*(const Foam::UList >&) /home/vishal/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/tensorField.H:75: note: Foam::tmp > > Foam::operator*(const Foam::tmp > >&) /home/vishal/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/tensorField.H:76: note: Foam::tmp > > Foam::operator*(const Foam::UList >&) /home/vishal/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/tensorField.H:76: note: Foam::tmp > > Foam::operator*(const Foam::tmp > >&) /home/vishal/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedSymmTensor.H:68: note: Foam::dimensionedVector Foam::operator*(const Foam::dimensionedSymmTensor&) /home/vishal/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedTensor.H:74: note: Foam::dimensionedVector Foam::operator*(const Foam::dimensionedTensor&) /home/vishal/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/dimensionedTensor.H:77: note: Foam::dimensionedTensor Foam::operator*(const Foam::dimensionedVector&) /home/vishal/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude/initContinuityErrs.H:38: warning: unused variable 'cumulativeContErr' make: *** [Make/linuxGccDPOpt/coupledFoam.o] Error 1 Further, I also tried to incorporate the boundary condition as given in the tutorials where they have incorporated the traction boundary condition or chtmultiregion tutorials... I am attaching those files too... but even there I get some errors like Reading field C1 keyword gradient is undefined in dictionary "/home/vishal/OpenFOAM/vishal-1.5/run/electroosmotic_transient_navier_stokes_jing_code/electroosmoticFoam_Steady/0/C1::upperwall" file: /home/vishal/OpenFOAM/vishal-1.5/run/electroosmotic_transient_navier_stokes_jing_code/electroosmoticFoam_Steady/0/C1::upperwall from line 37 to line 41. From function dictionary::lookupEntry(const word& keyword) const in file db/dictionary/dictionary.C at line 213. FOAM exiting Kindly give your suggestions with regard to this.... Kindly do the needful. Regards Vishal

 February 6, 2009, 21:55 As to your solver complaining #10 Super Moderator   Takuya OSHIMA Join Date: Mar 2009 Location: Niigata City, Japan Posts: 518 Blog Entries: 1 Rep Power: 12 As to your solver complaining about "keyword gradient is undefined in dictionary" in the entry upperwall, I do not see the boundaryField upperwall in your C1 file. Is this really the file in question? Anyway, as your ionNormalFlux BC is a derived type of fixedGradient you need a gradient entry as a placeholder. So the entry should look like upperwall { type ionNormalFlux; gradient uniform ...; ... } . T

 February 6, 2009, 22:10 Yep you need a gradient entry #11 Super Moderator   Takuya OSHIMA Join Date: Mar 2009 Location: Niigata City, Japan Posts: 518 Blog Entries: 1 Rep Power: 12 Yep you need a gradient entry in upperwall as I wrote in my previous post. T

 February 6, 2009, 22:14 Dear Takuya, Thanks for the #12 Senior Member   Vishal Nandigana Join Date: Mar 2009 Location: Champaign, Illinois, U.S.A Posts: 208 Rep Power: 10 Dear Takuya, Thanks for the quick reply. So now does it look something like this... upperwall { type ionNormalFlux; Phi WallElectricField; Zi Z1; Di D1; gradient uniform 0; } Thanks Regards Vishal

 February 7, 2009, 03:53 Hi Vishal, the error says t #13 Member   Luca M. Join Date: Mar 2009 Location: Luzern, Switzerland Posts: 59 Rep Power: 9 Hi Vishal, the error says that you search for an object (i.e. a volScalarField ) that is not yet instantiated. You have to be consistent in your creatFields.H and your class member "void Foam::ionFluxFvPatchScalarField::updateCoeffs()". Moreover in your case you have not a clear coding: you search for a volScalarField Di_ that is defined as a word if I checked right and Di_ is a private data that you can access easily without "lookupPatchField". Foam in this case searches for a Di_ volScalarField defined in the main code that I guess is not what you want. L.

 February 7, 2009, 13:00 Hi Luca, Thanks for the sug #14 Senior Member   Vishal Nandigana Join Date: Mar 2009 Location: Champaign, Illinois, U.S.A Posts: 208 Rep Power: 10 Hi Luca, Thanks for the suggestions.. Di_ is my transport property.. I have two variables D1 and D2 under my transport property... Do could throw some light as to what exactly I have to do to solve my problem.. I am looking to incorporate a boundary condition like grad(C1) = - Z1*C1*snGrad(Phi)/D1 = 0 grad(C2) = - Z2*C2*snGrad(Phi)/D2 = 0 Kindly suggest how I have to make changes in my files to solve my problem.. I am relatively new to OpenFOAM. Regards Vishal

 February 2, 2011, 20:10 #15 New Member   Kelvin Join Date: Jan 2011 Posts: 5 Rep Power: 7 Hi Vishal, I have the same problem. I want to set the same flux BC at the wall. Did you write this type of b.c. in OpenFoam. I am very new to OpenFoam. I have to write this b.c. to solve my problem. I'm ver pleased if you reply to me. Thank you very much...

 September 6, 2012, 13:03 About zero flux boundary condition... #16 Member   M Mallikarjuna Reddy Join Date: Jul 2012 Posts: 91 Rep Power: 6 Hi everyone, I am new to OpenFoam and i am doing my project on flow through channels. For my project i need to give zero flux boundary condition at walls (for variable T). And i applied zero flux in my governing equation and i got an expression like grad(T)=f(T,strainRate) where f=some function. I saw your previous posts. I think you had found solution. please guide me how to write this boundary condition.

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post lucy FLUENT 0 January 5, 2009 05:13 braennstroem OpenFOAM Running, Solving & CFD 7 November 27, 2008 11:44 arkangel OpenFOAM Running, Solving & CFD 1 October 2, 2008 14:48 Abigail FLUENT 2 July 24, 2007 09:34 olesen OpenFOAM Running, Solving & CFD 0 July 27, 2006 07:18

All times are GMT -4. The time now is 09:11.