View Issue Details

IDProjectCategoryView StatusLast Update
0002361OpenFOAMBugpublic2017-07-13 13:21
Reporterstathisk Assigned Tohenry  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
PlatformGNU/LinuxOSUbuntuOS Version14.04
Summary0002361: 'selectionMode' of 'scalarCodedSource' in 'fvOptions' doesn't work for 'cellzone' or 'points' option
DescriptionIn 'fvOptions', 'scalarCodedSource' treats every option ('all', 'points', 'cellzone') of 'selectionMode' as 'all'. So a source can not be specified on a specific point or zone.
Steps To Reproduce1) Use the 'hotRoom' tutorial of buoyantPimpleFoam.
2) Comment out line 11 of Allrun script (runApplication setFields)
3) Add an fvOption file which describes an energy source to a specific point in the domain using 'scalarCodedSource'. An example is located at /opt/openfoam4/src/fvOptions/sources/general/codedSource/CodedSource.H. (A modified version could be found in the attached files)
4) Results show that the entire domain is heated uniformly instead locally at the specified point
TagsfvOptions, scalarCodedSource

Activities

stathisk

2016-12-01 08:23

reporter  

hotRoom.zip (11,278 bytes)

MattijsJ

2016-12-01 21:20

reporter   ~0007375

The selectionMode is a bit tricky since both the coded and the new fvOption ('sourceTime') need to have it.

It is up to you to actually use the cells that have been selected. I've attached a corrected version of your fvOptions.
fvOptions (2,362 bytes)   
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  4.1                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "constant";
    object      fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


    energySource
    {
        type       scalarCodedSource;
        active     true;
        name       sourceTime;  

        scalarCodedSourceCoeffs
        {
            selectionMode   points;
            points ( 
                   ( 2.0  2.0 2.0)
                                  ); 
//        selectionMode   all;

//        selectionMode   cellZone; 
//        cellZone        heater; 

            fields          (h);

            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;
        }
    }



// ************************************************************************* //
fvOptions (2,362 bytes)   

Issue History

Date Modified Username Field Change
2016-12-01 08:23 stathisk New Issue
2016-12-01 08:23 stathisk File Added: hotRoom.zip
2016-12-01 08:23 stathisk Tag Attached: fvOptions
2016-12-01 08:23 stathisk Tag Attached: scalarCodedSource
2016-12-01 21:20 MattijsJ File Added: fvOptions
2016-12-01 21:20 MattijsJ Note Added: 0007375
2016-12-02 10:27 henry Assigned To => henry
2016-12-02 10:27 henry Status new => closed
2016-12-02 10:27 henry Resolution open => no change required