CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Howto use scalarCodedSource in fvOptions

Register Blogs Community New Posts Updated Threads Search

Like Tree37Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 14, 2017, 06:55
Default
  #41
New Member
 
Join Date: Dec 2016
Posts: 10
Rep Power: 9
ChrisBa is on a distinguished road
Must I define something in the controlDict?
ChrisBa is offline   Reply With Quote

Old   February 14, 2017, 08:58
Default
  #42
New Member
 
Join Date: Dec 2016
Posts: 10
Rep Power: 9
ChrisBa is on a distinguished road
I changed the fvOptions a little bit and now have this error:

Code:
/*---------------------------------------------------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  4.1                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
Build  : 4.1
Exec   : buoyantBoussinesqSimpleFoam
Date   : Feb 14 2017
Time   : 13:51:56
Host   : "cfd-MEDION"
PID    : 13396
Case   : /home/cfd/OpenFOAM/cfd-4.1/run/elektronen
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0


SIMPLE: convergence criteria
    field p_rgh     tolerance 0.01
    field U     tolerance 0.0001
    field T     tolerance 0.01
    field G     tolerance 1e-06
    field "(k|epsilon|omega)"     tolerance 0.001

Reading thermophysical properties

Reading field T

Reading field p_rgh

Reading field U

Reading/calculating face flux field phi

Selecting incompressible transport model Newtonian
Creating turbulence model

Selecting turbulence model type RAS
Selecting RAS turbulence model kEpsilon
kEpsilonCoeffs
{
    Cmu             0.09;
    C1              1.44;
    C2              1.92;
    C3              -0.33;
    sigmak          1;
    sigmaEps        1.3;
}

Reading field alphat


Reading g

Reading hRef
Calculating field g.h

No MRF models present

Radiation model not active: radiationProperties not found
Selecting radiationModel none
Creating finite volume options from "constant/fvOptions"

Selecting finite volume options model type scalarCodedSource
    Source: heatSource
    - selecting all cells
    - selected 17600 cell(s) with volume 1.8e-10


--> FOAM FATAL IO ERROR: 
keyword fields is undefined in dictionary "/home/cfd/OpenFOAM/cfd-4.1/run/elektronen/constant/fvOptions.heatSource.scalarCodedSourceCoeffs"

file: /home/cfd/OpenFOAM/cfd-4.1/run/elektronen/constant/fvOptions.heatSource.scalarCodedSourceCoeffs from line 27 to line 88.

    From function const Foam::entry& Foam::dictionary::lookupEntry(const Foam::word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 441.

FOAM exiting
The fvOption:

Code:
heatSource
{
    type            scalarCodedSource;

    active          true;
   

    scalarCodedSourceCoeffs
    {
        selectionMode   all;
        fieldNames      (T);
        name            sourceTime;
         
        
        codeAddSup
        {
            scalarField& TSource = eqn.source();


           
            const scalar power = 1000;
            const scalar Radius = 0.5;
            const scalar rho = 1000;
            const scalar Cp = 4.19;
            const scalar Uvol = 400;
            const scalar Iel = 1000;
            const scalar electrons = 10000;
            const scalar xCenter = 3;
            const scalar yCenter = 0.01;
            const scalar zCenter = 2;             
           
           

          
            const List<point>& cf = p.Cf();
            const scalar xCF = cf[c][0];
            const scalar XF = xCenter - xCF;
            const scalar check+ = xCenter + Radius; 
            const scalar check- = xCenter - Radius;

            if ((xCF < check+) && (xCF > check-))
            {
                const scalar r2 = XF * XF; 
                const scalar re2 = Radius * Radius; 
                const scalar factor = r2/re2; 
                const scalar pre = exp(factor); 
                const scalar qfa_ [c] = power * exp;
                const scalar TzuF_ [c] = (1/(rho*Cp))*qfa   
            }
            else 
            {
                const scalar qfa_ [c] = 0;
            };
            
           
            
            
            
            
            
                       
         

            TSource -= Tzuf; 
            Pout << "***codeAddSup***" << endl;

        };
 
        codeSetValue
        {
            Pout<< "**codeSetValue**" << endl;
        };

        // Dummy entry. Make dependent on above to trigger recompilation
        code
        {
           $codeInclude
           $codeCorrect
           $codeAddSup
           $codeSetValue
        };
    }

    sourceTimeCoeffs
    {
        // Dummy entry
    }
}
I don't add something in the controlDict.
I don't use setFields or something like that, because I want to use all cells.

Maybe somebody can help me.
ChrisBa is offline   Reply With Quote

Old   February 15, 2017, 05:23
Default
  #43
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 646
Rep Power: 32
tomf will become famous soon enoughtomf will become famous soon enough
Send a message via MSN to tomf Send a message via Skype™ to tomf
Hi,

This part explains what OpenFOAM is looking for:

Quote:
--> FOAM FATAL IO ERROR:
keyword fields is undefined in dictionary "/home/cfd/OpenFOAM/cfd-4.1/run/elektronen/constant/fvOptions.heatSource.scalarCodedSourceCoeffs"
It looks for a keyword, that is called fields. I only see a fieldNames keyword in your fvOptions file. It should probably be changed to fields and than that error will not show up anymore.

Regards,
Tom
tomf is offline   Reply With Quote

Old   February 15, 2017, 05:33
Default
  #44
New Member
 
Join Date: Dec 2016
Posts: 10
Rep Power: 9
ChrisBa is on a distinguished road
Thanks for your reply tom.
I changed it in fields.
Code:
heatSource
{
    name            sourceTime; //Nur der Name 
    type            scalarCodedSource; // ginge auch Vector
    active          yes;

    scalarCodedSourceCoeffs 
    {
        selectionMode   all; //Alle Zellen werden ausgewählt

        fields          (T); // In welches Feld er etwas hinzufügen soll 
/*
Valid functionEntries are for codeCorrect:

8

inputMode  
codeStream
include
calc
remove
includeIfPresent
includeEtc
includeFunc 
*/
        codeCorrect
        {
        
        };
        
 
        codeAddSup
        {
            scalarField& TSource = eqn.source();


           
            const scalar power = 1000;
            const scalar Radius = 0.5;
            const scalar rho = 1000;
            const scalar Cp = 4.19;
            const scalar Uvol = 400;
            const scalar Iel = 1000;
            const scalar electrons = 10000;
            const scalar xCenter = 3;
            const scalar yCenter = 0.01;
            const scalar zCenter = 2;             
           
           

          
            const List<point>& cf = p.Cf();
            const scalar xCF = cf[c][0];
            const scalar XF = xCenter - xCF;
            const scalar check+ = xCenter + Radius; 
            const scalar check- = xCenter - Radius;

            if ((xCF < check+) && (xCF > check-))
            {
                const scalar r2 = XF * XF; 
                const scalar re2 = Radius * Radius; 
                const scalar factor = r2/re2; 
                const scalar pre = exp(factor); 
                const scalar qfa_ [c] = power * exp;
                const scalar TzuF_ [c] = (1/(rho*Cp))*qfa   
            }
            else 
            {
                const scalar qfa_ [c] = 0;
            };
            
           
            
            
            
            
            
                       
         

            TSource -= Tzuf; 
            Pout << "***codeAddSup***" << endl;

        };
 
        codeSetValue
        {
            Pout<< "**codeSetValue**" << endl;
        };

        // Dummy entry. Make dependent on above to trigger recompilation
        code
        {
           $codeInclude
           $codeCorrect
           $codeAddSup
           $codeSetValue
        };
    }

    sourceTimeCoeffs
    {
        // Dummy entry
    }
}
But I have a new problem.

Code:
Selecting finite volume options model type scalarCodedSource
    Source: heatSource
    - selecting all cells
    - selected 17600 cell(s) with volume 1.8e-10


--> FOAM FATAL IO ERROR: 
Attempt to return dictionary entry as a primitive

file: /home/cfd/OpenFOAM/cfd-4.1/run/elektronen/constant/fvOptions.heatSource.scalarCodedSourceCoeffs.codeCorrect

    From function virtual Foam::ITstream& Foam::dictionaryEntry::stream() const
    in file db/dictionary/dictionaryEntry/dictionaryEntry.C at line 83.

FOAM aborting

#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::IOerror::abort() at ??:?
#2  Foam::dictionaryEntry::stream() const at ??:?
#3  Foam::fv::CodedSource<double>::read(Foam::dictionary const&) at ??:?
#4  Foam::fv::option::adddictionaryConstructorToTable<Foam::fv::CodedSource<double> >::New(Foam::word const&, Foam::word const&, Foam::dictionary const&, Foam::fvMesh const&) at ??:?
#5  Foam::fv::option::New(Foam::word const&, Foam::dictionary const&, Foam::fvMesh const&) at ??:?
#6  Foam::fv::optionList::reset(Foam::dictionary const&) at ??:?
#7  Foam::fv::optionList::optionList(Foam::fvMesh const&, Foam::dictionary const&) at ??:?
#8  Foam::fv::options::options(Foam::fvMesh const&) at ??:?
#9  Foam::fv::options::New(Foam::fvMesh const&) at ??:?
#10  ? at ??:?
#11  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#12  ? at ??:?
Abgebrochen (Speicherabzug geschrieben)
If i write in fvOptions:

Code:
 
codeCorrect
        {
            # 
        };
I got this message:

Code:
Radiation model not active: radiationProperties not found
Selecting radiationModel none
Creating finite volume options from "constant/fvOptions"



--> FOAM FATAL ERROR: 
Unknown functionEntry '' in "/home/cfd/OpenFOAM/cfd-4.1/run/elektronen/constant/fvOptions" near line 46

Valid functionEntries are :

8
(
inputMode
codeStream
include
calc
remove
includeIfPresent
includeEtc
includeFunc
)


    From function static bool Foam::functionEntry::execute(const Foam::word&, Foam::dictionary&, Foam::Istream&)
    in file db/dictionary/functionEntries/functionEntry/functionEntry.C at line 79.

FOAM exiting
Can someone explain me how I use codeCorrect?

Regards
Chris
ChrisBa is offline   Reply With Quote

Old   February 15, 2017, 12:03
Default
  #45
New Member
 
Join Date: Dec 2016
Posts: 10
Rep Power: 9
ChrisBa is on a distinguished road
Hello all,

I hope somebody can help me with the scalarCodedSource.
I tried many things, but it doesn't work and I can't figure out why.
my fvOptions file:

Code:
heatSource
{
    name            sourceTime; 
    type            scalarCodedSource; 
    active          yes;

    scalarCodedSourceCoeffs 
    {
        selectionMode   all;

        fields          (T);

        codeCorrect
        #{
            Pout << "***codeCorrect***" << endl;
 
        #};      
 
        codeAddSup
        #{
            scalarField& TSource = eqn.source();


           
            const scalar power = 1000;
            const scalar Radius = 0.5;
            const scalar rho = 1000;
            const scalar Cp = 4.19;
            const scalar Uvol = 400;
            const scalar Iel = 1000;
            const scalar electrons = 10000;
            const scalar xCenter = 3;
            const scalar yCenter = 0.01;
            const scalar zCenter = 2;             
           
           

          
            const List<point>& cf = p.Cf();
            const scalar xCF = cf[c][0];
            const scalar XF = xCenter - xCF;
            const scalar check+ = xCenter + Radius; 
            const scalar check- = xCenter - Radius;

            if ((xCF < check+) && (xCF > check-))
            {
                const scalar r2 = XF * XF; 
                const scalar re2 = Radius * Radius; 
                const scalar factor = r2/re2; 
                const scalar pre = exp(factor); 
                const scalar qfa_ [c] = power * exp;
                const scalar TzuF_ [c] = (1/(rho*Cp))*qfa   
            }
            else 
            {
                const scalar qfa_ [c] = 0;
            };
            
           
            
            
            
            
            
                       
         

            TSource -= Tzuf; 
            Pout << "***codeAddSup***" << endl;

        #};
 
        codeSetValue
        #{
            Pout<< "**codeSetValue**" << endl;
        #};

        // Dummy entry. Make dependent on above to trigger recompilation
        code
        {
           $codeInclude
           $codeCorrect
           $codeAddSup
           $codeSetValue
        };
    }

    sourceTimeCoeffs
    {
        // Dummy entry
    }
}

// ************************************************************************* //
The Error is this one:
Code:
 
Create time

Create mesh for time = 0


SIMPLE: convergence criteria
    field p_rgh     tolerance 0.01
    field U     tolerance 0.0001
    field T     tolerance 0.01
    field G     tolerance 1e-06
    field "(k|epsilon|omega)"     tolerance 0.001

Reading thermophysical properties

Reading field T

Reading field p_rgh

Reading field U

Reading/calculating face flux field phi

Selecting incompressible transport model Newtonian
Creating turbulence model

Selecting turbulence model type RAS
Selecting RAS turbulence model kEpsilon
kEpsilonCoeffs
{
    Cmu             0.09;
    C1              1.44;
    C2              1.92;
    C3              -0.33;
    sigmak          1;
    sigmaEps        1.3;
}

Reading field alphat


Reading g

Reading hRef
Calculating field g.h

No MRF models present

Radiation model not active: radiationProperties not found
Selecting radiationModel none
Creating finite volume options from "constant/fvOptions"



--> FOAM FATAL ERROR: 
Attempt to return primitive entry ITstream : /home/cfd/OpenFOAM/cfd-4.1/run/elektronen/constant/fvOptions.heatSource.scalarCodedSourceCoeffs.codeCorrect, line 31, IOstream: Version 2.0, format ASCII, line 0, OPENED, GOOD
    primitiveEntry 'codeCorrect' comprises 
        on line 31 the verbatim string "\
            Pout << \"***codeCorrect***\" << endl;\
 \
        "
 as a sub-dictionary

    From function virtual const Foam::dictionary& Foam::primitiveEntry::dict() const
    in file db/dictionary/primitiveEntry/primitiveEntry.C at line 189.

FOAM aborting

#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::error::abort() at ??:?
#2  Foam::primitiveEntry::dict() const at primitiveEntry.C:?
#3  Foam::dictionary::substituteScopedKeyword(Foam::word const&) at ??:?
#4  Foam::entry::New(Foam::dictionary&, Foam::Istream&) at ??:?
#5  Foam::dictionary::read(Foam::Istream&, bool) at ??:?
#6  Foam::dictionary::dictionary(Foam::fileName const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#7  Foam::dictionaryEntry::dictionaryEntry(Foam::keyType const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#8  Foam::entry::New(Foam::dictionary&, Foam::Istream&) at ??:?
#9  Foam::dictionary::read(Foam::Istream&, bool) at ??:?
#10  Foam::dictionary::dictionary(Foam::fileName const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#11  Foam::dictionaryEntry::dictionaryEntry(Foam::keyType const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#12  Foam::entry::New(Foam::dictionary&, Foam::Istream&) at ??:?
#13  Foam::dictionary::read(Foam::Istream&, bool) at ??:?
#14  Foam::dictionary::dictionary(Foam::fileName const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#15  Foam::dictionaryEntry::dictionaryEntry(Foam::keyType const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#16  Foam::entry::New(Foam::dictionary&, Foam::Istream&) at ??:?
#17  Foam::dictionary::read(Foam::Istream&, bool) at ??:?
#18  Foam::operator>>(Foam::Istream&, Foam::dictionary&) at ??:?
#19  Foam::IOdictionary::readFile(bool) at ??:?
#20  Foam::IOdictionary::IOdictionary(Foam::IOobject const&) at ??:?
#21  Foam::fv::options::options(Foam::fvMesh const&) at ??:?
#22  Foam::fv::options::New(Foam::fvMesh const&) at ??:?
#23  ? at ??:?
#24  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#25  ? at ??:?
Abgebrochen (Speicherabzug geschrieben)
I can't understand this because I used the example of the headerfile.
Thanks for xour help.

Regards,
Chris
ChrisBa is offline   Reply With Quote

Old   February 16, 2017, 02:51
Default
  #46
New Member
 
Join Date: Dec 2016
Posts: 10
Rep Power: 9
ChrisBa is on a distinguished road
Morning all,

i solved the problem with the "primitive entry". Maybe somebody can help me with the code.
I need 3 zones in z. The first one should be one face of my mesh and for the other two there should be different values for each cell.

Regards
Chris
ChrisBa is offline   Reply With Quote

Old   February 18, 2017, 17:17
Default
  #47
New Member
 
Join Date: Dec 2016
Posts: 10
Rep Power: 9
ChrisBa is on a distinguished road
Hy all,

sorry to bother you, but I have a problem.
I only want a zone for a heatSource. So I used topoSetDict and cellSet, but in ParaView the whole mesh is used.

Here is my fvOptions:
Code:
harmonic
{   name            sourceTime;
    type            scalarCodedSource;
    active          true;
    selectionMode   cellZone;
    cellZone        heatSource;
    scalarCodedSourceCoeffs
    { 

        fields      (T);
        selectionMode   cellZone;
        cellZone        heatSource;
        codeInclude
        #{

        #};

        codeCorrect
        #{
            Pout<< "**codeCorrect**" << endl;
        #};

        codeAddSup
        #{
            const Time& time = mesh().time();
            const scalarField& V = mesh_.V();
            const vectorField& C = mesh_.C();
            scalarField& TSource = eqn.source();
            forAll(C, i)
            {
                TSource += 1*V[i];
            }
            
            Pout << "***codeAddSup***" << endl;
        #};

        codeSetValue
        #{
            Pout<< "**codeSetValue**" << endl;
        #};

        // Dummy entry. Make dependent on above to trigger recompilation
        code
        #{
            $codeInclude
            $codeCorrect
            $codeAddSup
            $codeSetValue
        #};
    }

    sourceTimeCoeffs
    {
        // Dummy entry
    }
}


// ************************************************************************* //
Here is the topoSetDict:

Code:
actions
(

    {
       name    heatSource;
       type cellSet;
       action  new;
       source boxToCell;
       sourceInfo
       {
            box   (0 0 0) (0.2 0.2 0.2);
       }

    }

    {   
        name    heatSource;
        type    cellZoneSet;
        action  new;
        source  setToCellZone;
        sourceInfo
        {
            set heatSource;
        }
    }

);
I'm using buoyantBoussinesqSimpleFoam and Openfoam 4.1

Can somebody help me or explain me, why this is the result?

regards

Last edited by ChrisBa; March 11, 2019 at 08:49.
ChrisBa is offline   Reply With Quote

Old   February 24, 2017, 07:27
Default
  #48
New Member
 
Join Date: Dec 2016
Posts: 10
Rep Power: 9
ChrisBa is on a distinguished road
Hy All

Can I select the surfaces of my mesh?
Because i want to define a source only on the surface of the mesh.

regards,
Chris
ChrisBa is offline   Reply With Quote

Old   February 24, 2017, 21:45
Default
  #49
Senior Member
 
M. C.
Join Date: May 2013
Location: Italy
Posts: 286
Blog Entries: 6
Rep Power: 17
student666 is on a distinguished road
Instead of a volumetric heat source, I would rather say that you need a heatflux boundary condition on a surface.

Maybe these two bounday condition on the following link can be of help:

buoyantSimpleFoam: fixed wall heat flux

If you use the banana trick on fvOptions for scalarSemiImplctSource
Code:
energySource
{
    type            scalarSemiImplicitSource;
    active on; //to switch or not heat source 
    //timeStart 0;
    //duration  20;
    selectionMode cellZone;
    cellZone c0;

    scalarSemiImplicitSourceCoeffs{
        selectionMode   banana_all;//cellZone;
        cellZone        c0;
    
        volumeMode      absolute;//specific;//
        injectionRateSuSp
        {
            h           (0 0.1); //   q in [W]; or in [W/m³] if you use specific mode
        }
    }
}
openfoam gives you other choices, and you may see that you can select points

Code:
Selecting finite volume options model type scalarSemiImplicitSource
    Source: energySource


--> FOAM FATAL IO ERROR: 
banana_all is not in enumeration: 
4
(
all
cellSet
cellZone
points
)
but It is a volumetric heat source, and I think that "points" means internal points.
I'm not able to figure it out, how manage it on a boundary surface, maybe my thinking is not correct but:
try to think you set only a point, with a volumetric heat source on a surface that is a boundary of your computational domain too; then others points what would be, zeroGradient?
ok, but how the heat will be transfered?
Because other points has zeroGradient so no heat flux along the surface as well as outside of your domain.
So you have a heat flux from your heat point on the surface (that belongs to a volumetric cell) toward the center point of the volumetric cell that it belongs to, but as above you're setting a heat flux, not a heat source. Maybe it works for your purpose.

You may even think to use thermaBaffles:

https://openfoamwiki.net/index.php/F...hermal_baffles
https://openfoam.org/release/2-3-0/thermal/

Hope it helps.

Regards.
altinel likes this.
student666 is offline   Reply With Quote

Old   March 11, 2017, 18:11
Default How to set "injectionRateSuSp" in "scalarSemiImplicitSource"?
  #50
Member
 
Join Date: Sep 2016
Posts: 63
Rep Power: 10
sitajeje is on a distinguished road
Dear Foamers,

I read through the thread and a few other webpages, and found the following to options in injectionRateSuSp to create a heat source by fvOption with scalarSemiImplicitSource:

injectionRateSuSp
{
T (0.1 0); //DT = PHI''' / (rho * cp)
}

or

injectionRateSuSp
{
h (0.1 0); //W absolute, W/m3 specific
}

I wonder which one to choose for chtMultiRegionFoam?

I chose the second one get the computation result as shown in the photo. The case with OpenFOAM 4.0 is also attached. It is a long thin cuboid with heat source of 10W and a flat large cuboid lying above. There is no thermal contact resistance between each other. The solid is located in the middle of a closed (noSlip for U boundary condition) and insulated box (zeroGradient for T). Only a quarter is simulated, thus two faces of the computation domain are symmetry, and the internal temperature and velocity field can be observed.

I simulated for two seconds, so that 20J heat was generated. However the increase of the total internal energy of the two solid cuboids increased only 5J (taking the temperature of the solids is uniform at the highest temperature in domain, and the thermal properties are given in the case). I wonder where are the other 75% of energy? Is it due to the symmetry boundary condition that only 25% of the heat was generated?

Thank you very much for any help in advance!

Sitajeje
Attached Images
File Type: jpg Screenshot from 2017-03-11 22_23_36.jpg (102.8 KB, 82 views)
Attached Files
File Type: gz HSPinBox.tar.gz (6.7 KB, 15 views)
sitajeje is offline   Reply With Quote

Old   March 12, 2017, 02:50
Default
  #51
Senior Member
 
piu58's Avatar
 
Uwe Pilz
Join Date: Feb 2017
Location: Leipzig, Germany
Posts: 744
Rep Power: 15
piu58 is on a distinguished road
I don't think your problem is due to the b.c. Symmetric simply generates a slip boundary and does not expand the region in any way.

Sent from my HTC One SV using CFD Online Forum mobile app
__________________
Uwe Pilz
--
Die der Hauptbewegung überlagerte Schwankungsbewegung ist in ihren Einzelheiten so hoffnungslos kompliziert, daß ihre theoretische Berechnung aussichtslos erscheint. (Hermann Schlichting, 1950)
piu58 is offline   Reply With Quote

Old   March 12, 2017, 11:51
Default
  #52
Member
 
Join Date: Sep 2016
Posts: 63
Rep Power: 10
sitajeje is on a distinguished road
Hallo Uwe,

thank you very much for your quick reply! I figured out by trial and error that it is the second option is correct:

injectionRateSuSp
{
h (0.1 0); //W absolute, W/m3 specific
}

It is true that it is nothing to do with the boundary condition. I made the symmetryPlane as Wall, so that it is a complete insulated box. But the temperature is the same, i.e. only 5J emerges in the solid domain, and 15J was missing.

Sorry everyone,

It was a wrong estimation of the internal energy. I checked with a simpler geometry, it was correct.

Sitajeje

Last edited by sitajeje; March 12, 2017 at 13:45.
sitajeje is offline   Reply With Quote

Old   March 13, 2017, 10:32
Default
  #53
Senior Member
 
Alex
Join Date: Oct 2013
Posts: 337
Rep Power: 22
zfaraday will become famous soon enough
Hi Sitajeje,

First of all, both implementations should give you the same results since the only difference between them is the comment (the characters behind //), so it has no impact on the calculations.

Can you, please, upload your fvSolution specification? Or at least tell us the tolerancies you used for enthalpy for all your regions. Convergence is usually very slow in chtMultiregion* solvers and you would need to set a very low tolerance and let the solver run during several iterations. You can use non ortogonal correctors in order to force the solver to take more iterations.

Best regards,

Alex
__________________
Web site where I present my Master's Thesis: foamingtime.wordpress.com

The case I talk about in this site was solved with chtMultiRegionSimpleFoam solver and involves radiation. Some basic tutorials are also resolved step by step in the web. If you are interested in these matters, you are invited to come in!
zfaraday is offline   Reply With Quote

Old   March 13, 2017, 12:27
Default
  #54
Member
 
Join Date: Sep 2016
Posts: 63
Rep Power: 10
sitajeje is on a distinguished road
Alex,

thank you very much for your reply! I tried
injectionRateSuSp
{
T (0.1 0); //DT = PHI''' / (rho * cp)
}
but there was no heat generated. I checked the solveSolid.H in applications/solvers/heatTransfer/chtMultiRegionFoam/solid, and it is written "fvScalarMatrix hEqn" there. I suppose that is the reason. What is your experience?

I used the following:
h
tolerance 1e-7;
relTol 0.1

hFinal
tolerance 1e-7;
relTol 0;

Can you download my file? I uploaded it in my last input.

The velocity and temperature didn't need many iterations. But the pressure frequently needed 1000 iterations. So I changed the "p_rghFinal relTol" from 0 to 0.01. The results were the same.

What is your experience? I didn't understand your comments on tolerance and convergence.

Thank you very much in advance!

Best regards,

Sitajeje
sitajeje is offline   Reply With Quote

Old   March 31, 2017, 03:02
Default Question about fvOptions
  #55
New Member
 
Join Date: Dec 2016
Posts: 10
Rep Power: 9
ChrisBa is on a distinguished road
Hy Foamers,

I work with scalarCodedSource.
My solver is buoyantBoussinesqSimpleFoam and I use the version OpenFoam 4.1.
I would like to create a volumentric source that uses a constant power.
I have deduced from the energy equation that I need the specific power first.
This value I then divide by the density rho [kg / m^3] and the heat capacity Cp [J / (kgK)].
By integrating the equation, I would have to multiply this value by the cell volume.

My questions are the following:

1. How does the solver handle the fvOptions value?
2. Does the fvOptions(T) function return the calculated value?
3. Is my derivation correct?
4. Is it correct if I use eqn.source() as my variable, if my performance is constant?
5. Can I use this fvOptions also for the solver buoyantBoussinesqPimpleFoam?

Thanks in advance for your help.

Regards,
ChrisBa
ChrisBa is offline   Reply With Quote

Old   November 1, 2018, 14:20
Default
  #56
gu1
Senior Member
 
Guilherme
Join Date: Apr 2017
Posts: 245
Rep Power: 10
gu1 is on a distinguished road
Hello, I hope someone can help me ...

If I want to set a fixed pressure gradient, can I? to a cyclic domain (pipe).

Could anyone teach me how to configure these options in my fvOptions?

Thanks.
gu1 is offline   Reply With Quote

Old   November 30, 2018, 05:37
Default Coded Source table input
  #57
New Member
 
Calum Roberts
Join Date: Nov 2018
Posts: 3
Rep Power: 8
CalumR is on a distinguished road
Hi there


I am trying to implement a heat sink through scalarCodedSource using a table of calculated Heat fluxes as my input. Can anyone give me any advice on the implementation of this? I am familiar with using tables to specify boundary conditions but am unsure how to implement them in the source.


Any help would be appreciated!
CalumR is offline   Reply With Quote

Old   September 5, 2019, 09:06
Default
  #58
Member
 
Vishnu
Join Date: May 2019
Location: Tamilnadu, India
Posts: 55
Rep Power: 7
Vishsel is on a distinguished road
Hi all,

My case was porous medium with heat transfer. But I only need to generate heat source on wall of the solid body (ie. on surface). Not from fluid body.

These are my BC for wall surface which i have to create heat source (at this BC's)
wall-mp-1
wall-mp-2
wall-dp-1
wall-dp-2

And I have used cyclicAMI type for interfacing the fluid regions and for measure the pressure values.

So I succeed with cyclicAMI, now i have to create a heat source at wall(ie @surface). I need to only check heat distribution from those BC's.

Solver
i am using is porousSimpleFoam..
Running mpirun -np no.ofprocessor porousSimpleFoam -parallel

Now my case is with heat transfer,incompressible fluid, steady state

I have an input like heat flux (W/m2) and heat generation (W) value.

I am getting this error while running. I know i have to include energy equation.. I don't have an idea about header file creation..

Code:
--> FOAM Warning :
From function void option::checkApplied() const
in file fvOptions/fvOption.c at line 368
Source wall-mp-1 defined for field h but never used
please view this comment for fvOptions,fvSchemes & fvSolution files
energy equation for porousSimpleFoam

Please correct me what i have to modify in this EEqn.H file

Code:
{
    volScalarField& he = thermo.he();

    fvScalarMatrix EEqn
    (
        fvm::div(phi, he)
      + fvc::div(phi, K)
      + (
            he.name() == "e"
          ? fvc::div
            (
                fvc::absolute(phi/fvc::interpolate(rho), U),
                p,
                "div(phiv,p)"
            )
          : -dpdt
        )
      - fvm::laplacian(turbulence->alphaEff(), he)
     ==
      + fvOptions(rho, he)
    );

    EEqn.relax();

    fvOptions.constrain(EEqn);

    EEqn.solve();

    fvOptions.correct(he);

    thermo.correct();
    radiation->correct();
}
Thankyou in advance
Vishsel
Vishsel is offline   Reply With Quote

Old   November 12, 2022, 16:38
Post
  #59
Member
 
cal
Join Date: Feb 2020
Location: nowhere
Posts: 65
Rep Power: 6
saidc. is on a distinguished road
Hi,

I'm trying to import a source term which depends on height of the rode.
Code:
z: height (0 to 0.3 meter)
profile: 0.00000444*z^4 - 0.00025507*z^3 + 0.00144848*z^2 + 0.07409711*z + 1.64833117
Code:
codedSource
{
    type            scalarCodedSource;
    selectionMode   cellZone;
    cellZone        MYREGION;

    fields          (h);
    name            sourceTime;

    codeInclude
    #{
    #};
    codeCorrect
    #{
    Pout<< "**codeCorrect**" << endl;
    #};

    codeAddSup
    #{
    const scalarField& Zcoord = mesh.C().component(Vector::Z);
    scalarField& heSource = eqn.source();
    forAll(Zcoord, i)
    {
        heSource += (0.00000444*pow(Zcoord[i],4)) - (0.00025507*pow(Zcoord[i],3)) + (0.00144848*pow(Zcoord[i],2)) + (0.07409711*Zcoord[i]) + 1.64833117;    
    }
    #};

    codeConstrain
    #{
    Pout<< "**codeCorrect**" << endl;
    #};
    code
    #{
            $codeInclude
            $codeCorrect
            $codeAddSup
            $codeSetValue
    #};
    sourceTimeCoeffs
    {
    // Dummy entry
    }
It gives this error:
Code:
Selecting finite volume options type scalarCodedSource
    Source: codedSource
    - selecting cells using cellZone MYREGION
    - selected 80339 cell(s) with volume 0.074947679



...



 Solving for solid region heatPipesRegion
DICPCG:  Solving for h, Initial residual = 1, Final residual = 8.5586193e-07, No Iterations 50
Min/max T:293.14761 305.44315
Using dynamicCode for fvOption::sourceTime at line 24 in "/mnt/c/Users/saidc/Desktop/codedTest/constant/MYREGION/fvOptions.codedSource"
Could not load "/mCould not load "/mnt/c/Users/saidCould not load "/mnt/c/Users/saidc/DeskCould not load "/mnt/c/Users/saidc/Desktop/codedTnt/c/Users/saidc/Desktop/codedTest/dynamicCc/Desktop/codedTest/dynamicCode/platforms/linux64GccDPIntop/codedTest/dynamicCode/platforms/linux64GccDPInt32Opt/liode/platforms/linux64GccDPInt32Opt/lib/est/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libsourceTime_ecc90b0libsourceTimeb/libsourceTime_t32Opt/lib/libsourceT5a445f885e6ec8482cb3441c896bime_ecc90b05a445f885e6ec8482cb3441c896bd_ecc90b05a445f885e6ec8482cb3441c896bd535d.so"
/mnt/c/Users/saidc/Desktop/codedTest/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libsourceTime_ecc90b05a445f885e6ec8482cb3441c896bd535d.so: cannot open shared object file: No such file or directory
ecc90b05a445f885e6ec8482cb3441c896bd535d.so"
/mnt/c/Users/saidc/Desktop/codedTest/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libsourceTime_ecc90b05a445f885e6ec8482cb3441c896bd535d.so: cannot open shared object file: No such file or directory
d535d.so"
/mnt/c/Users/saidc/Desktop/codedTest/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libsourceTime_ecc90b05a445f885e6ec8482cb3441c896bd535d.so: cannot open shared object file: No such file or directory
535d.so"
/mnt/c/Users/saidc/Desktop/codedTest/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libsourceTime_ecc90b05a445f885e6ec8482cb3441c896bd535d.so: cannot open shared object file: No such file or directory
Creating new library in "dynamicCode/sourceTime/platforms/linux64GccDPInt32Opt/lib/libsourceTime_ecc90b05a445f885e6ec8482cb3441c896bd535d.so"
Invoking wmake libso /mnt/c/Users/saidc/Desktop/codedTest/dynamicCode/sourceTime
wmake libso /mnt/c/Users/saidc/Desktop/codedTest/dynamicCode/sourceTime
    ln: ./lnInclude
    dep: codedFvOptionTemplate.C
    Ctoo: codedFvOptionTemplate.C
[DESKTOP-5Q0IUMJ:04407] 3 more processes have sent help message help-btl-vader.txt / cma-permission-denied
[DESKTOP-5Q0IUMJ:04407] Set MCA parameter "orte_base_help_aggregate" to 0 to see all help / error messages
/mnt/c/Users/saidc/Desktop/codedTest/constant/MYREGION/fvOptions.codedSource: In member function ‘virtual void Foam::fv::sourceTimeFvOptionscalarSource::addSup(Foam::fvMatrix<double>&, Foam::label)’:
/mnt/c/Users/saidc/Desktop/codedTest/constant/MYREGION/fvOptions.codedSource:41:29: error: invalid use of member function ‘const Foam::fvMesh& Foam::fv::option::mesh() const’ (did you forget the ‘()’ ?)
make: *** [/usr/lib/openfoam/openfoam2112/wmake/rules/General/transform:35: Make/linux64GccDPInt32Opt/codedFvOptionTemplate.o] Error 1
[0] 
[0] 
[0] --> FOAM FATAL IO ERROR: (openfoam-2112 patch=220610)
[0] Failed wmake "dynamicCode/sourceTime/platforms/linux64GccDPInt32Opt/lib/libsourceTime_ecc90b05a445f885e6ec8482cb3441c896bd535d.so"
[0] 
[0] 
[0] file: constant/MYREGION/fvOptions.codedSource at line 24.
[0] 
[0]     From void Foam::codedBase::createLibrary(Foam::dynamicCode&, const Foam::dynamicCodeContext&) const
[0]     in file db/dynamicLibrary/codedBase/codedBase.C at line 240.
[0] 
FOAM parallel run exiting
The code didn't compiled. Any help will be appreciated.

Kind regards,
saidc. is offline   Reply With Quote

Old   November 14, 2022, 11:53
Default
  #60
Senior Member
 
Andrew Somorjai
Join Date: May 2013
Posts: 175
Rep Power: 13
massive_turbulence is on a distinguished road
Quote:
Originally Posted by saidc. View Post
Hi,

I'm trying to import a source term which depends on height of the rode.
Code:
z: height (0 to 0.3 meter)
profile: 0.00000444*z^4 - 0.00025507*z^3 + 0.00144848*z^2 + 0.07409711*z + 1.64833117
Code:
codedSource
{
    type            scalarCodedSource;
    selectionMode   cellZone;
    cellZone        MYREGION;

    fields          (h);
    name            sourceTime;

    codeInclude
    #{
    #};
    codeCorrect
    #{
    Pout<< "**codeCorrect**" << endl;
    #};

    codeAddSup
    #{
    const scalarField& Zcoord = mesh.C().component(Vector::Z);
    scalarField& heSource = eqn.source();
    forAll(Zcoord, i)
    {
        heSource += (0.00000444*pow(Zcoord[i],4)) - (0.00025507*pow(Zcoord[i],3)) + (0.00144848*pow(Zcoord[i],2)) + (0.07409711*Zcoord[i]) + 1.64833117;    
    }
    #};

    codeConstrain
    #{
    Pout<< "**codeCorrect**" << endl;
    #};
    code
    #{
            $codeInclude
            $codeCorrect
            $codeAddSup
            $codeSetValue
    #};
    sourceTimeCoeffs
    {
    // Dummy entry
    }
It gives this error:
Code:
Selecting finite volume options type scalarCodedSource
    Source: codedSource
    - selecting cells using cellZone MYREGION
    - selected 80339 cell(s) with volume 0.074947679



...



 Solving for solid region heatPipesRegion
DICPCG:  Solving for h, Initial residual = 1, Final residual = 8.5586193e-07, No Iterations 50
Min/max T:293.14761 305.44315
Using dynamicCode for fvOption::sourceTime at line 24 in "/mnt/c/Users/saidc/Desktop/codedTest/constant/MYREGION/fvOptions.codedSource"
Could not load "/mCould not load "/mnt/c/Users/saidCould not load "/mnt/c/Users/saidc/DeskCould not load "/mnt/c/Users/saidc/Desktop/codedTnt/c/Users/saidc/Desktop/codedTest/dynamicCc/Desktop/codedTest/dynamicCode/platforms/linux64GccDPIntop/codedTest/dynamicCode/platforms/linux64GccDPInt32Opt/liode/platforms/linux64GccDPInt32Opt/lib/est/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libsourceTime_ecc90b0libsourceTimeb/libsourceTime_t32Opt/lib/libsourceT5a445f885e6ec8482cb3441c896bime_ecc90b05a445f885e6ec8482cb3441c896bd_ecc90b05a445f885e6ec8482cb3441c896bd535d.so"
/mnt/c/Users/saidc/Desktop/codedTest/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libsourceTime_ecc90b05a445f885e6ec8482cb3441c896bd535d.so: cannot open shared object file: No such file or directory
ecc90b05a445f885e6ec8482cb3441c896bd535d.so"
/mnt/c/Users/saidc/Desktop/codedTest/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libsourceTime_ecc90b05a445f885e6ec8482cb3441c896bd535d.so: cannot open shared object file: No such file or directory
d535d.so"
/mnt/c/Users/saidc/Desktop/codedTest/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libsourceTime_ecc90b05a445f885e6ec8482cb3441c896bd535d.so: cannot open shared object file: No such file or directory
535d.so"
/mnt/c/Users/saidc/Desktop/codedTest/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libsourceTime_ecc90b05a445f885e6ec8482cb3441c896bd535d.so: cannot open shared object file: No such file or directory
Creating new library in "dynamicCode/sourceTime/platforms/linux64GccDPInt32Opt/lib/libsourceTime_ecc90b05a445f885e6ec8482cb3441c896bd535d.so"
Invoking wmake libso /mnt/c/Users/saidc/Desktop/codedTest/dynamicCode/sourceTime
wmake libso /mnt/c/Users/saidc/Desktop/codedTest/dynamicCode/sourceTime
    ln: ./lnInclude
    dep: codedFvOptionTemplate.C
    Ctoo: codedFvOptionTemplate.C
[DESKTOP-5Q0IUMJ:04407] 3 more processes have sent help message help-btl-vader.txt / cma-permission-denied
[DESKTOP-5Q0IUMJ:04407] Set MCA parameter "orte_base_help_aggregate" to 0 to see all help / error messages
/mnt/c/Users/saidc/Desktop/codedTest/constant/MYREGION/fvOptions.codedSource: In member function ‘virtual void Foam::fv::sourceTimeFvOptionscalarSource::addSup(Foam::fvMatrix<double>&, Foam::label)’:
/mnt/c/Users/saidc/Desktop/codedTest/constant/MYREGION/fvOptions.codedSource:41:29: error: invalid use of member function ‘const Foam::fvMesh& Foam::fv::option::mesh() const’ (did you forget the ‘()’ ?)
make: *** [/usr/lib/openfoam/openfoam2112/wmake/rules/General/transform:35: Make/linux64GccDPInt32Opt/codedFvOptionTemplate.o] Error 1
[0] 
[0] 
[0] --> FOAM FATAL IO ERROR: (openfoam-2112 patch=220610)
[0] Failed wmake "dynamicCode/sourceTime/platforms/linux64GccDPInt32Opt/lib/libsourceTime_ecc90b05a445f885e6ec8482cb3441c896bd535d.so"
[0] 
[0] 
[0] file: constant/MYREGION/fvOptions.codedSource at line 24.
[0] 
[0]     From void Foam::codedBase::createLibrary(Foam::dynamicCode&, const Foam::dynamicCodeContext&) const
[0]     in file db/dynamicLibrary/codedBase/codedBase.C at line 240.
[0] 
FOAM parallel run exiting
The code didn't compiled. Any help will be appreciated.

Kind regards,
If you could post the snippets of the lines below that might help more. Can you run this on a single CPU or thread? Start small and work up from it.

file: constant/MYREGION/fvOptions.codedSource at line 24.
[0]
[0] From void Foam::codedBase::createLibrary(Foam::dynamicCode&, const Foam::dynamicCodeContext&) const
[0] in file db/dynamicLibrary/codedBase/codedBase.C at line 240.
massive_turbulence is offline   Reply With Quote

Reply

Tags
fvoptions, heat source, scalarcodedsource


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
OpenFoam 2.2 fvOptions temperature limits fredo490 OpenFOAM Running, Solving & CFD 12 January 17, 2020 00:59
Building a solver with fixedTemperatureConstraint using fvOptions Fluido OpenFOAM Programming & Development 9 February 15, 2018 01:30
How to set fvOptions yurifrey OpenFOAM Pre-Processing 5 February 22, 2016 19:14
[swak4Foam] Setting BC for a passive scalar (groovy vs fvOptions) Tobi OpenFOAM Community Contributions 0 May 23, 2013 15:53
A new Howto on the OpenFOAM Wiki Compiling OpenFOAM under Unix mbeaudoin OpenFOAM Installation 2 April 28, 2006 09:54


All times are GMT -4. The time now is 07:29.