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

scalarCodedSource and cellZones in OF 4.x

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 13, 2017, 09:21
Default scalarCodedSource and cellZones in OF 4.x
  #1
New Member
 
Xavier Lamboley
Join Date: Jan 2015
Location: Bordeaux, France
Posts: 13
Rep Power: 11
tilasoldo is on a distinguished road
Hi everyone,

I am currently setting up a case with a time-varying volumetric energy source in OpenFOAM 4.x; I use scalarCodedSource fvOptions to achieve that, and after some research (in particular here…), I have managed to write this fvOptions file :
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  4.x                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "constant";
    object      fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

heatSource
{
    type            scalarCodedSource;
    active          true;
    name            sourceTime;
 
    scalarCodedSourceCoeffs
    {
        selectionMode   cellSet;
        cellSet         heaterCellSet;
        fields          (e);

        codeInclude
        #{
        #};

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

        codeAddSup
        #{
            const Time& time = mesh().time();
            const scalarField& V = mesh_.V();
            scalarField& heSource = eqn.source();

            const labelList& cellIDs = cells();

            forAll(cellIDs, i)
            {
                label cellI = cellIDs[i];
                heSource[cellI] -= 0.0001*sqr(time.value())*V[cellI];
            }
        #};

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

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

    sourceTimeCoeffs
    {
        $scalarCodedSourceCoeffs;
    }
}
 
// ************************************************************************* //
Source term indeed needs to be applied only on cellSet cells, as does
Code:
const labelList& cellIDs = cells();
.
However, I get the following error :
Code:
.../fvOptions.heatSource.scalarCodedSourceCoeffs:45:40: error: use of undeclared identifier 'cells'
, even if I found this solution in the OpenFOAM issue tracker (!) for version 4.1. Am I doing this right? Do I miss an include?
I also tried to replace cells() by mesh_.cells(), which does not work any better since it returns a cellList instead of a labelList.

If anyone knows about this please share it with me
Regards,
X. Lamboley
tilasoldo is offline   Reply With Quote

Reply


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



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