|
[Sponsors] |
scalarCodedSource Not Implemented Error in OpenFOAM for Enthalpy Field |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 23, 2024, 07:52 |
scalarCodedSource Not Implemented Error in OpenFOAM for Enthalpy Field
|
#1 |
New Member
Mario Javier Rincón
Join Date: Dec 2020
Location: Denmark
Posts: 9
Rep Power: 5 |
Hi everyone,
I'm trying to set up a custom source term for the enthalpy field h in my OpenFOAM-v2212 simulation with buoyantSimpleFoam and using the scalarCodedSource functionality within fvOptions. To troubleshoot, I created an fvOptions file with no custom code, just the basic structure. However, I am consistently encountering the following error: Code:
--> FOAM FATAL ERROR: (openfoam-2212 patch=230110) Not implemented From virtual void Foam::fv::energySourceFvOptionscalarSource::addSup(const volScalarField&, Foam::fvMatrix<double>&, Foam::label) in file codedFvOptionTemplate.C at line 178. Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v2212 | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object fvOptions; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // codedSource { type scalarCodedSource; selectionMode all; active true; fields ( h ); name exampleCodedSource; codeInclude #{ // Empty block #}; codeCorrect #{ // Empty block #}; codeConstrain #{ // Empty block #}; codeAddSup #{ // Empty block #}; } // ************************************************************************* // Has anyone experienced a similar issue or could provide guidance on how to correctly implement a custom source term for the enthalpy field in OpenFOAM? Any insights or examples would be greatly appreciated! Thank you! |
|
May 23, 2024, 08:00 |
|
#2 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
Quote:
There is indeed a bit of confusion there. As well as codeAddSup there is also a coddAddSupRho too. It looks like this is where your "not implemented" is coming from. Unfortunately no way to template and define just a single code block for compressible/incompressible, thus the two different code chunks are needed. |
||
June 3, 2024, 17:35 |
|
#3 |
New Member
Mario Javier Rincón
Join Date: Dec 2020
Location: Denmark
Posts: 9
Rep Power: 5 |
Thanks a lot That was actually what I needed.
It seems like you know quite a bit about coded source terms. Perhaps you can help me with another problem I have encountered: I am trying to retrieve the value of Cp in each cell and calculate its mean, but I cannot retrieve this data from the thermophysical properties. So far, this is what I have achieved (with errors): Code:
enthalpySource { type scalarCodedSource; selectionMode all; active true; fields ( h ); // Applying the source term to the temperature field name enthalpySource; codeInclude #{ #include "fvCFD.H" #include "$FOAM_SRC/thermophysicalModels/basic/basicThermo/basicThermo.H" #}; codeCorrect #{ // Ensure this block is present but empty #}; codeConstrain #{ // Ensure this block is present but empty #}; codeAddSupRho #{ const scalar temperatureTarget = 323.15; // Target temperature provided by the user in Kelvin // Get the temperature and enthalpy fields const volScalarField& T = mesh().lookupObject<volScalarField>("T"); const volScalarField& h = mesh().lookupObject<volScalarField>("h"); const scalarField& V = mesh_.V(); scalarField& heSource = eqn.source(); // Calculate the volumetric mean value of temperature scalar meanT = 0.0; scalar Vtotal = 0.0; forAll(T, celli) { meanT += T[celli] * V[celli]; Vtotal += V[celli]; } meanT /= Vtotal; // Get the specific heat capacity (Cp) for each cell const volScalarField& Cp = basicThermo.Cp(); // ERROR ENCOUNTERED // Calculate the mean Cp across all cells scalar Cp_mean = 0.0; scalar Vtotal = 0.0; forAll(Cp, celli) { Cp_mean += Cp[celli] * V[celli]; Vtotal += V[celli]; } Cp_mean /= Vtotal; const scalar delta_h = Cp_mean * (temperatureTarget - meanT); // Change in enthalpy // Apply the enthalpy source term forAll(h, celli) { // cell volume specific source heSource[celli] += delta_h * V[celli]; } #}; } |
|
June 5, 2024, 08:47 |
|
#4 |
New Member
Join Date: Jun 2024
Posts: 1
Rep Power: 0 |
||
June 7, 2024, 07:46 |
|
#5 |
New Member
Mario Javier Rincón
Join Date: Dec 2020
Location: Denmark
Posts: 9
Rep Power: 5 |
Thank you! You are right, the cellIDs were wrong. Now is corrected as shown below, however, I am still unable to obtain the Cp values at each cell. Any ideas?
Code:
enthalpySource { type scalarCodedSource; selectionMode all; active false; fields ( h ); // Applying the source term to the enthalpy field name enthalpySource; codeInclude #{ #include "fvCFD.H" #include "$FOAM_SRC/thermophysicalModels/basic/basicThermo/basicThermo.H" #}; codeCorrect #{ // Ensure this block is present but empty #}; codeConstrain #{ // Ensure this block is present but empty #}; codeAddSupRho #{ const scalar temperatureTarget = 323.15; // Target temperature provided by the user in Kelvin // Get the temperature, enthalpy, and static pressure fields const volScalarField& T = mesh().lookupObject<volScalarField>("T"); const volScalarField& h = mesh().lookupObject<volScalarField>("h"); // Get the mesh volume and cell IDs const scalarField& V = mesh_.V(); const labelList& cellIDs = cells(); scalarField& heSource = eqn.source(); // Calculate the volumetric mean value of temperature scalar meanT = 0.0; scalar Vtotal = 0.0; forAll(T, i) { label celli = cellIDs[i]; meanT += T[celli] * V[celli]; Vtotal += V[celli]; } meanT /= Vtotal; // Get the specific heat capacity (Cp) for each cell const volScalarField& Cp = basicThermo.Cp(); // ERROR ENCOUNTERED #}; } |
|
June 10, 2024, 05:25 |
|
#6 |
Senior Member
|
Not sure.
Cp(), however, is merely a virtual member function of the basisThermo class, see e.g. (depending on the version you are using) L436 of https://www.openfoam.com/documentati...8H_source.html This implies that the implementation of the Cp() member function is postponed to a child class of the basisThermo parent class. heThermo is an example of such a child class. See e.g. L372 of https://www.openfoam.com/documentati...8C_source.html This implies that in your code block you might (emphasis on "might") be required to 1/ extract your thermo object from the object registry (not sure whether thermo object is stored in object registry - should check) 2/ cast your thermo object to a type that has a Cp() member function explicitly defined (most likely the thermo type used in your simulation); I appreciate learning how it goes. |
|
June 10, 2024, 08:21 |
|
#7 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
||
June 27, 2024, 04:58 |
Same issue
|
#8 |
New Member
Arunkl
Join Date: Jun 2024
Posts: 7
Rep Power: 2 |
I am new to these user defined terms in Openfoam so I am trying to implement the degassing boundary condition using Fvoptions and getting the error of not implemented
can you please help me debug the code degassing bc.txt /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 3.0.0 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "constant"; object fvOptions; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // degassingMassSource { type scalarCodedSource; active yes; selectionMode all; name degassingMassSource; patches (outlet); rhoName thermo:rho.air; alphaName alpha.air; scalarCodedSourceCoeffs { selectionMode all; fields (thermo:rho.air); codeInclude #{ #include "fvm.H" #}; codeCorrect #{ #}; codeAddSup #{ // Get the names of the patches on which to apply the degassing forces DynamicList<word, 1, 0> patches; coeffs().lookup("patches") >> patches; // Get the required fields const word rhoName = coeffs().lookup("rhoName"); const volScalarField& rhoAir = mesh().lookupObject<volScalarField>(rhoName); const word alphaName = coeffs().lookup("alphaName"); const volScalarField& alphaAir = mesh().lookupObject<volScalarField>(alphaName); // Get the timestep const scalar deltaT = mesh().time().deltaT().value(); // Create degassing mass source coefficient and initialize to zero volScalarField degassingMassSourceCoeff ( IOobject ( "degassingMassSourceCoeff", mesh().time().timeName(), mesh(), IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh(), dimensionedScalar("degassingMassSourceCoeff", dimless/dimTime, 0.0) ); // Compute the degassing mass source coefficient for each cell adjacent to the selected patches forAll(patches, iPatch) { // Get the boundary patch const fvPatch& patch = mesh().boundary()[patches[iPatch]]; // Loop through each boundary face and compute degassing force coefficient in adjacent cell forAll(patch, iFace) { label iCell = patch.faceCells()[iFace]; degassingMassSourceCoeff[iCell] = -alphaAir[iCell]/deltaT; } } // Add the degassing force term eqn += fvm::Sp(degassingMassSourceCoeff, rhoAir); #}; codeSetValue #{ #}; // Dummy entry. Make dependent on above to trigger recompilation code #{ $codeInclude $codeCorrect $codeAddSup $codeSetValue #}; } } degassingForce { type vectorCodedSource; active yes; selectionMode all; name degassingForce; patches (outlet); rhoName thermo:rho.air; alphaName alpha.air; UName U.air; vectorCodedSourceCoeffs { selectionMode all; fields (U.air); codeInclude #{ #include "fvm.H" #}; codeCorrect #{ #}; codeAddSup #{ // Get the names of the patches on which to apply the degassing forces DynamicList<word, 1, 0> patches; coeffs().lookup("patches") >> patches; // Get the required fields const word rhoName = coeffs().lookup("rhoName"); const volScalarField& rhoAir = mesh().lookupObject<volScalarField>(rhoName); const word alphaName = coeffs().lookup("alphaName"); const volScalarField& alphaAir = mesh().lookupObject<volScalarField>(alphaName); const word UName = coeffs().lookup("UName"); const volVectorField& UAir = mesh().lookupObject<volVectorField>(UName); // Get the timestep const scalar deltaT = mesh().time().deltaT().value(); // Create degassing force coefficient and initialize to zero volScalarField degassingForceCoeff ( IOobject ( "degassingForceCoeff", mesh().time().timeName(), mesh(), IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh(), dimensionedScalar("degassingForceCoeff", dimDensity/dimTime, 0.0) ); // Compute the degassing force coefficient for each cell adjacent to the selected patches forAll(patches, iPatch) { // Get the boundary patch const fvPatch& patch = mesh().boundary()[patches[iPatch]]; // Loop through each boundary face and compute degassing force coefficient in adjacent cell forAll(patch, iFace) { label iCell = patch.faceCells()[iFace]; degassingForceCoeff[iCell] = -rhoAir[iCell]*alphaAir[iCell]/deltaT; } } // Add the degassing force term eqn += fvm::Sp(degassingForceCoeff, UAir); #}; codeSetValue #{ #}; // Dummy entry. Make dependent on above to trigger recompilation code #{ $codeInclude $codeCorrect $codeAddSup $codeSetValue #}; } } // ************************************************** *********************** // i am also getting varies errors like type conversion and number of variables thankyou in advance please help me |
|
June 27, 2024, 05:02 |
Error message:
|
#9 |
New Member
Arunkl
Join Date: Jun 2024
Posts: 7
Rep Power: 2 |
PIMPLE: iteration 1
MULES: Solving for alpha.air MULES: Solving for alpha.air alpha.air volume fraction = 0.40003 Min(alpha1) = 0.4 Max(alpha1) = 0.5 Using dynamicCode for fvOption::degassingMassSource at line 31 in "/home/arunkl/openFoamFiles/bubbleColumn/constant/fvOptions/degassingMassSource/scalarCodedSourceCoeffs" Selecting finite volume options type degassingMassSource Source: degassingMassSource - selecting all cells - selected 1875 cell(s) with volume 0.015 --> FOAM FATAL ERROR: (openfoam-2312) Not implemented From virtual void Foam::fv::degassingMassSourceFvOptionscalarSource: :addSup(const volScalarField&, Foam::fvMatrix<double>&, Foam::label) in file /home/arunkl/openFoamFiles/bubbleColumn/constant/fvOptions/degassingMassSource/scalarCodedSourceCoeffs at line 109. FOAM aborting [stack trace] ============= #1 Foam::error::simpleExit(int, bool) in /usr/lib/openfoam/openfoam2312/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so #2 ? in /usr/lib/openfoam/openfoam2312/platforms/linux64GccDPInt32Opt/lib/libreactingMultiphaseSystem.so #3 ? in /usr/lib/openfoam/openfoam2312/platforms/linux64GccDPInt32Opt/lib/libreactingMultiphaseSystem.so #4 Foam:haseSystem::correct() in /usr/lib/openfoam/openfoam2312/platforms/linux64GccDPInt32Opt/lib/libreactingMultiphaseSystem.so #5 ? in /usr/lib/openfoam/openfoam2312/platforms/linux64GccDPInt32Opt/lib/libreactingTwoPhaseSystem.so #6 ? in /usr/lib/openfoam/openfoam2312/platforms/linux64GccDPInt32Opt/bin/reactingTwoPhaseEulerFoam #7 ? in /lib/x86_64-linux-gnu/libc.so.6 #8 __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6 #9 ? in /usr/lib/openfoam/openfoam2312/platforms/linux64GccDPInt32Opt/bin/reactingTwoPhaseEulerFoam ============= Aborted |
|
Tags |
buoyantsimplefoam, enthalpy, openfoam, scalarcodedsource, source terms |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Phase Field modeling in OpenFOAM | adona058 | OpenFOAM Running, Solving & CFD | 35 | November 16, 2021 01:16 |
[swak4Foam] swakExpression not writing to log | alexfells | OpenFOAM Community Contributions | 3 | March 16, 2020 19:19 |
Superlinear speedup in OpenFOAM 13 | msrinath80 | OpenFOAM Running, Solving & CFD | 18 | March 3, 2015 06:36 |
Moving mesh | Niklas Wikstrom (Wikstrom) | OpenFOAM Running, Solving & CFD | 122 | June 15, 2014 07:20 |
Problem with rhoSimpleFoam | matteo_gautero | OpenFOAM Running, Solving & CFD | 0 | February 28, 2008 07:51 |