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   November 18, 2022, 11:29
Post
  #61
Member
 
saidc
Join Date: Feb 2020
Location: nowhere
Posts: 62
Rep Power: 6
saidc. is on a distinguished road
Quote:
Originally Posted by massive_turbulence View Post
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.
Attached Files
File Type: c codedFvOptionTemplate.C (5.0 KB, 2 views)
saidc. is offline   Reply With Quote

Old   November 18, 2022, 12:11
Default
  #62
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 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
*/
}


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


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