CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

mixed boundary condition

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

Like Tree1Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 24, 2020, 04:33
Default mixed boundary condition
  #1
Member
 
Yann Guyot
Join Date: Feb 2019
Posts: 30
Rep Power: 3
YannGuyot is on a distinguished road
Dear all,


I have a probably newbie question but i can find the answer by myself
I want to implement convective heat transfer using mixed type BC.
After checking on the web i found that it could be somethink like that:
Code:
 

top
  {
    type            mixed;
    refValue        298;
    refGradient     0;
    valueFraction   1./(1. + 0.6/(1.*deltaCoeffs()));
  }
Unfortunately I am not able to pass properly the expression in valueFraction (the solver seems to take only the "1." in front, so corresponding to dirichlet BC)


So my question is simple (and probably stupid), how to pass an expression in openfoam, (for example fixedValue 273.15+25 instead of 298.15)


Thank you very much for help


Yann
YannGuyot is offline   Reply With Quote

Old   March 24, 2020, 06:10
Default
  #2
New Member
 
peyman havaej
Join Date: Jan 2016
Posts: 8
Rep Power: 6
peyman.havaej is on a distinguished road
Dear Yann
you can use groovyBC.

check the openfoamwiki and find more information and the capabilities of groovyBC.
peyman.havaej is offline   Reply With Quote

Old   March 24, 2020, 06:13
Default
  #3
Member
 
Yann Guyot
Join Date: Feb 2019
Posts: 30
Rep Power: 3
YannGuyot is on a distinguished road
Dear Paymen


I use openfoam7 and it seems that groovyBC is not an option anymore
In the other hand, i tried codedMixed BC typr as the following


Code:
    top
    {
        type            codedMixed;
        refValue        uniform 0;
        refGradient     uniform 0;
        valueFraction   uniform 1;

        name    robin;   // name of generated BC

        code
        #{
            const scalarField& delta = patch().deltaCoeffs();
            this->refValue() = 298;
            this->refGrad() = 0.;
            this->valueFraction() = 1.0/(1+0.6/(1.0*delta));
        #};
    }
Unfortunately it doesnt give ant difference
YannGuyot is offline   Reply With Quote

Old   March 26, 2020, 05:12
Default
  #4
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,922
Rep Power: 34
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

What solver do you use? What is 0.6 (thermal conductivity? thermal diffusivity? just a random number?)?
alexeym is offline   Reply With Quote

Old   March 26, 2020, 09:55
Default
  #5
Member
 
Yann Guyot
Join Date: Feb 2019
Posts: 30
Rep Power: 3
YannGuyot is on a distinguished road
hello,

I am using buoyantPimpleFoam, and the parameter corresponds to water thermal conductivity, I just don't know how to get it properly from thermophysical properties, (If you know I will be glad to know too )

I also realize that I made a mistake, according to this well made document:

https://foamingtime2.files.wordpress...ction-bc_1.pdf

It should be
Code:
    top
    {
        type            codedMixed;
        refValue        uniform 0;
        refGradient     uniform 0;
        valueFraction   uniform 1;

        name    robin;   // name of generated BC

        code
        #{
            const scalarField& delta = patch().deltaCoeffs();
            this->refValue() = 298;
            this->refGrad() = 0.;
            this->valueFraction() = 1.0/(1+0.6/(1.0/delta));
        #};
    }
This seems to work
YannGuyot is offline   Reply With Quote

Old   March 26, 2020, 10:06
Default
  #6
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,922
Rep Power: 34
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Or

Code:
this->valueFraction() = 1.0/(1+0.6*delta);
You can find a way to lookup kappa in, for example, TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C.
alexeym is offline   Reply With Quote

Old   March 26, 2020, 10:22
Default
  #7
Member
 
Yann Guyot
Join Date: Feb 2019
Posts: 30
Rep Power: 3
YannGuyot is on a distinguished road
Sorry i am newbie, I don't really understand how to lookup variables like in the example
YannGuyot is offline   Reply With Quote

Old   March 26, 2020, 10:34
Default
  #8
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,922
Rep Power: 34
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Since the example is general, it has lots of checks, you can get rid of them for your concrete situation. You have mentioned water, so I assume, you use fluidThermo, so the code for kappa lookup is:

Code:
            typedef compressible::turbulenceModel turbulenceModel;

            word turbName(turbulenceModel::propertiesName);

            if
            (
                mesh.foundObject<turbulenceModel>(turbName)
            )
            {
                const turbulenceModel& turbModel =
                    mesh.lookupObject<turbulenceModel>(turbName);

                return turbModel.kappaEff(patchi);
            }
            else if (mesh.foundObject<fluidThermo>(basicThermo::dictName))
            {
                const fluidThermo& thermo =
                    mesh.lookupObject<fluidThermo>(basicThermo::dictName);

                return thermo.kappa(patchi);
            }
First branch gets kappa value from turbulence model, else branch gets it directly from thermo object (if turbulence model is not available). If you use turbulence model, you can get rid of conditionals and directly use corresponding branch.

In BC you can access mesh object like this, for example:

Code:
const fvMesh& mesh = patch_.boundaryMesh().mesh();
alexeym is offline   Reply With Quote

Old   March 26, 2020, 11:01
Default
  #9
Member
 
Yann Guyot
Join Date: Feb 2019
Posts: 30
Rep Power: 3
YannGuyot is on a distinguished road
I think i miss something (sorry, i am really bad at c++)


Code:
      code
      #{
          const scalarField& delta = patch().deltaCoeffs();
          const fvMesh& mesh = patch_.boundaryMesh().mesh();
          const fluidThermo& thermo = mesh.lookupObject<fluidThermo>(basicThermo::dictName);
          this->refValue() = 298;
          this->refGrad() = 0;
          this->valueFraction() = 1.0/(1.0+thermo.kappa(patchi)/(1.0/delta));
      #};
YannGuyot is offline   Reply With Quote

Old   March 26, 2020, 11:12
Default
  #10
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,922
Rep Power: 34
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
I do not think you have basicThermo in coded BC. You should use codeInclude section to add necessary includes. Something like:

Code:
codeInclude
#{
    #include "fluidThermo.H"
#}
alexeym is offline   Reply With Quote

Old   March 26, 2020, 11:54
Default
  #11
Member
 
Yann Guyot
Join Date: Feb 2019
Posts: 30
Rep Power: 3
YannGuyot is on a distinguished road
It is asking me a system/codeDict, I never have seen file like this so far.
YannGuyot is offline   Reply With Quote

Old   March 26, 2020, 13:22
Default
  #12
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,922
Rep Power: 34
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
It would be easier to figure out a cause of the problem if you post solver/compiler output. "Guess-what-is-wrong" game can take quite a long time.
HPE likes this.
alexeym is offline   Reply With Quote

Old   March 27, 2020, 07:43
Default
  #13
Member
 
Yann Guyot
Join Date: Feb 2019
Posts: 30
Rep Power: 3
YannGuyot is on a distinguished road
Sure


Code:
--> FOAM FATAL ERROR: 
cannot find file "/home/yann/Projet/system/codeDict"
    From function virtual Foam::autoPtr<Foam::ISstream> Foam::fileOperations::uncollatedFileOperation::readStream(Foam::regIOobject&, const Foam::fileName&, const Foam::word&, bool) const
    in file global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C at line 538.

FOAM exiting
YannGuyot is offline   Reply With Quote

Old   March 27, 2020, 08:20
Default
  #14
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,922
Rep Power: 34
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Could you post final version of the BC? It seems, you have lost semi-colon, since:

Code:
A special form is if the 'code' section is not supplied. In this case
the code gets read from a (runTimeModifiable!) dictionary system/codeDict
which would have a corresponding entry
Basically, it looks for system/codeDict only if there is no inline code section.
alexeym is offline   Reply With Quote

Old   March 27, 2020, 08:24
Default
  #15
Member
 
Yann Guyot
Join Date: Feb 2019
Posts: 30
Rep Power: 3
YannGuyot is on a distinguished road
Here you go



Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       volScalarField;
    location    "0";
    object      T;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 0 0 1 0 0 0];

internalField   uniform 283;

boundaryField
{
  top
  {
      type            codedMixed;
      refValue        uniform 0;
      refGradient     uniform 0;
      valueFraction   uniform 1;

      name    robin;   // name of generated BC

      codeInclude
      #{
          #include "fluidThermo.H";
      #}
      
      code
      #{
          const scalarField& delta = patch().deltaCoeffs();
          const fvMesh& mesh = patch_.boundaryMesh().mesh();
          const fluidThermo& thermo = mesh.lookupObject<fluidThermo>(basicThermo::dictName);
          this->refValue() = 298;
          this->refGrad() = 0;
          this->valueFraction() = 1.0/(1.0+thermo.kappa(patchi)/(1.0/delta));
      #};
    }

  ground
  {
      type            zeroGradient;
  }

  sym
  {
      type            zeroGradient;
  }
}
YannGuyot is offline   Reply With Quote

Old   March 27, 2020, 08:31
Default
  #16
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,922
Rep Power: 34
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Semicolon is missing after codeInclude entry (so code entry is eaten by codeInclude). It should be:

Code:
  top
  {
      type            codedMixed;
      refValue        uniform 0;
      refGradient     uniform 0;
      valueFraction   uniform 1;

      name    robin;   // name of generated BC

      codeInclude
      #{
          #include "fluidThermo.H";
      #}; // <-- here
      
      code
      #{
      ...
alexeym is offline   Reply With Quote

Old   March 27, 2020, 08:37
Default
  #17
Member
 
Yann Guyot
Join Date: Feb 2019
Posts: 30
Rep Power: 3
YannGuyot is on a distinguished road
Of course, thank you so much


PS: j'espere que tout va bien pour toi dans l'est
YannGuyot is offline   Reply With Quote

Old   March 27, 2020, 09:33
Default
  #18
Member
 
Yann Guyot
Join Date: Feb 2019
Posts: 30
Rep Power: 3
YannGuyot is on a distinguished road
after adding the semicolon, I have another error:


Code:
Using dynamicCode for patch top on field T at line 26 in "/home/yann/Projet/0/T.boundaryField.top"
Creating new library in "dynamicCode/robin/platforms/linux64GccDPInt32Opt/lib/librobin_53fcadabbc93dcdfc6e8ad4486434b09ccd4ede5.so"
Invoking "wmake -s libso /home/yann/Projet/dynamicCode/robin"
wmake libso /home/yann/Projets/dynamicCode/robin
    ln: ./lnInclude
    wmkdep: mixedFvPatchFieldTemplate.C
could not open file fluidThermo.H for source file mixedFvPatchFieldTemplate.C due to No such file or directory
    Ctoo: mixedFvPatchFieldTemplate.C
/home/yann/Projet/0/T.boundaryField.top:35:25: warning: extra tokens at end of #include directive
/home/yann/Projet/0/T.boundaryField.top:35:10: fatal error: fluidThermo.H: Aucun fichier ou dossier de ce type
compilation terminated.
/opt/openfoam7/wmake/rules/General/transform:25: recipe for target 'Make/linux64GccDPInt32Opt/mixedFvPatchFieldTemplate.o' failed
make: *** [Make/linux64GccDPInt32Opt/mixedFvPatchFieldTemplate.o] Error 1


--> FOAM FATAL IO ERROR: 
Failed wmake "dynamicCode/robin/platforms/linux64GccDPInt32Opt/lib/librobin_53fcadabbc93dcdfc6e8ad4486434b09ccd4ede5.so"


file: /home/yann/Projet/0/T.boundaryField.top from line 26 to line 39.

    From function void Foam::codedBase::createLibrary(Foam::dynamicCode&, const Foam::dynamicCodeContext&) const
    in file db/dynamicLibrary/codedBase/codedBase.C at line 206.

FOAM exiting
Any idea?
YannGuyot is offline   Reply With Quote

Old   March 27, 2020, 09:40
Default
  #19
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,922
Rep Power: 34
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
The warning is self-explanatory, you do not need ; after #include "fluidThermo.H".

The error is due to missing -I flags. You need to add codeOptions section, there you put -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude:

Code:
codeOptions
#{
    -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude
#};
alexeym is offline   Reply With Quote

Old   March 27, 2020, 10:06
Default
  #20
Member
 
Yann Guyot
Join Date: Feb 2019
Posts: 30
Rep Power: 3
YannGuyot is on a distinguished road
Code:
Using dynamicCode for patch top on field T at line 26 in "/home/yann/Projet/0/T.boundaryField.top"
Creating new library in "dynamicCode/robin/platforms/linux64GccDPInt32Opt/lib/librobin_7dab6cfe54673a55a3892dc8057acb21ae82c018.so"
Invoking "wmake -s libso /home/yann/Projet/dynamicCode/robin"
wmake libso /home/yann/Projet/dynamicCode/robin
    ln: ./lnInclude
    wmkdep: mixedFvPatchFieldTemplate.C
could not open file compressibleTransportModel.H for source file mixedFvPatchFieldTemplate.C due to No such file or directory
    Ctoo: mixedFvPatchFieldTemplate.C
In file included from /home/yann/Projet/0/T.boundaryField.top:37:0:
/opt/openfoam7/src/thermophysicalModels/basic/lnInclude/fluidThermo.H:39:10: fatal error: compressibleTransportModel.H: Aucun fichier ou dossier de ce type
 #include "compressibleTransportModel.H"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
/opt/openfoam7/wmake/rules/General/transform:25: recipe for target 'Make/linux64GccDPInt32Opt/mixedFvPatchFieldTemplate.o' failed
make: *** [Make/linux64GccDPInt32Opt/mixedFvPatchFieldTemplate.o] Error 1


--> FOAM FATAL IO ERROR: 
Failed wmake "dynamicCode/robin/platforms/linux64GccDPInt32Opt/lib/librobin_7dab6cfe54673a55a3892dc8057acb21ae82c018.so"


file: /home/yann/Projet/0/T.boundaryField.top from line 26 to line 46.

    From function void Foam::codedBase::createLibrary(Foam::dynamicCode&, const Foam::dynamicCodeContext&) const
    in file db/dynamicLibrary/codedBase/codedBase.C at line 206.

Still not working
YannGuyot is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
My radial inflow turbine Abo Anas CFX 27 May 11, 2018 01:44
Radiation interface hinca CFX 15 January 26, 2014 17:11
An error has occurred in cfx5solve: volo87 CFX 5 June 14, 2013 17:44
asking for Boundary condition in FLUENT Destry FLUENT 0 July 27, 2010 00:55
External Radiation Boundary Condition for Grid Interface CFD XUE FLUENT 0 July 9, 2010 02:53


All times are GMT -4. The time now is 23:34.