CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Howto use scalarCodedSource in fvOptions (https://www.cfd-online.com/Forums/openfoam-solving/123670-howto-use-scalarcodedsource-fvoptions.html)

saidc. November 18, 2022 11:29

1 Attachment(s)
Quote:

Originally Posted by massive_turbulence (Post 839346)
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.


Hi Andrew,

Thanks for your reply. Same output for single CPU, nothing changed. If I can be sure about that syntax is correct I'll try it on another system. Do you think the syntax is correct?

Kind regards,
Said.

massive_turbulence November 18, 2022 12:11

Quote:

Originally Posted by saidc. (Post 839641)
Hi Andrew,

Thanks for your reply. Same output for single CPU, nothing changed. If I can be sure about that syntax is correct I'll try it on another system. Do you think the syntax is correct?

Kind regards,
Said.

What are you trying to do at line 138 through 140?

Code:

//{{{ begin code
    #line 36 "/mnt/c/Users/saidc/Desktop/codedTest/constant/fuelRodsRegion/fvOptions.codedSource"
Pout<< "**codeCorrect**" << endl;
//}}} end code

158 to 166?

Code:

//{{{ begin code - warn/fatal if not implemented?
    #line 41 "/mnt/c/Users/saidc/Desktop/codedTest/constant/fuelRodsRegion/fvOptions.codedSource"
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;       
        }
//}}} end code

184 to 186?

Code:

//{{{ begin code - warn/fatal if not implemented?
    NotImplemented
//}}} end code

and 203 to 206?

Code:

//{{{ begin code
    #line 51 "/mnt/c/Users/saidc/Desktop/codedTest/constant/fuelRodsRegion/fvOptions.codedSource"
Pout<< "**codeCorrect**" << endl;
//}}} end code

If you want to comment multiline you need to use /* */ with the comment inside like this /* comment*/



I commented the code for you so that the syntax is correct but I doubt I could help with the functionality of this code, I haven' t looked over OF functions in a while.


Code:

/*---------------------------------------------------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    |
    \\  /    A nd          | www.openfoam.com
    \\/    M anipulation  |
-------------------------------------------------------------------------------
    Copyright (C) 2019-2021 OpenCFD Ltd.
    Copyright (C) YEAR AUTHOR, AFFILIATION
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

#include "codedFvOptionTemplate.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "unitConversion.H"
#include "fvMatrix.H"

//{{{ begin codeInclude

//}}} end codeInclude


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
namespace fv
{

// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //

//{{{ begin localCode

//}}} end localCode


// * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //

// dynamicCode:
// SHA1 = ecc90b05a445f885e6ec8482cb3441c896bd535d
//
// unique function name that can be checked if the correct library version
// has been loaded
extern "C" void sourceTime_ecc90b05a445f885e6ec8482cb3441c896bd535d(bool load)
{
    if (load)
    {
        // Code that can be explicitly executed after loading
    }
    else
    {
        // Code that can be explicitly executed before unloading
    }
}


// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

defineTypeNameAndDebug(sourceTimeFvOptionscalarSource, 0);
addRemovableToRunTimeSelectionTable
(
    option,
    sourceTimeFvOptionscalarSource,
    dictionary
);

} // End namespace fv
} // End namespace Foam


// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

Foam::fv::
sourceTimeFvOptionscalarSource::
sourceTimeFvOptionscalarSource
(
    const word& name,
    const word& modelType,
    const dictionary& dict,
    const fvMesh& mesh
)
:
    fv::cellSetOption(name, modelType, dict, mesh)
{
    if (false)
    {
        printMessage("Construct sourceTime fvOption from dictionary");
    }
}


// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //

Foam::fv::
sourceTimeFvOptionscalarSource::
~sourceTimeFvOptionscalarSource()
{
    if (false)
    {
        printMessage("Destroy sourceTime");
    }
}


// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

void
Foam::fv::
sourceTimeFvOptionscalarSource::correct
(
    GeometricField<scalar, fvPatchField, volMesh>& fld
)
{
    if (false)
    {
        Info<< "sourceTimeFvOptionscalarSource::correct()\n";
    }

/*begin code
    #line 36 "/mnt/c/Users/saidc/Desktop/codedTest/constant/fuelRodsRegion/fvOptions.codedSource"
Pout<< "**codeCorrect**" << endl;
//}}} end code
*/
}


void
Foam::fv::
sourceTimeFvOptionscalarSource::addSup
(
    fvMatrix<scalar>& eqn,
    const label fieldi
)
{
    if (false)
    {
        Info<< "sourceTimeFvOptionscalarSource::addSup()\n";
    }
/*
//{{{ begin code - warn/fatal if not implemented?
    #line 41 "/mnt/c/Users/saidc/Desktop/codedTest/constant/fuelRodsRegion/fvOptions.codedSource"
*/

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;       
        }
//}}} end code

}


void
Foam::fv::
sourceTimeFvOptionscalarSource::addSup
(
    const volScalarField& rho,
    fvMatrix<scalar>& eqn,
    const label fieldi
)
{
    if (false)
    {
        Info<< "sourceTimeFvOptionscalarSource::addSup(rho)\n";
    }

/*{{{ begin code - warn/fatal if not implemented?
    NotImplemented
//}}} end code
*/
}


void
Foam::fv::
sourceTimeFvOptionscalarSource::constrain
(
    fvMatrix<scalar>& eqn,
    const label fieldi
)
{
    if (false)
    {
        Info<< "sourceTimeFvOptionscalarSource::constrain()\n";
    }
/*
//{{{ begin code
    #line 51 "/mnt/c/Users/saidc/Desktop/codedTest/constant/fuelRodsRegion/fvOptions.codedSource"
Pout<< "**codeCorrect**" << endl;
//}}} end code
*/
}


// ************************************************************************* //



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