|
[Sponsors] |
[swak4Foam] access field variables in groovyBC |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 29, 2015, 08:17 |
access field variables in groovyBC
|
#1 |
Member
Mehtab
Join Date: Jan 2015
Posts: 41
Rep Power: 11 |
Hi,
I tried implementing temperature boundary condition at Inlet as: T_s = T_0 + 1/C_p(Q_f/m" - Hv) Here is my files Code:
boundaryField { outlet { type inletOutlet; inletValue uniform 298.15; value uniform 298.15; } sides { type inletOutlet; inletValue uniform 298.15; value uniform 298.15; } base { type zeroGradient; } inlet { type groovyBC; valueExpression "T0+((1/cpi)*((Qf/m)-Hv))"; variables "T0=300;m{inlet}=phi;Hv=8500;Qf{inlet}=Qr;cpi{inlet}=cp;"; value 300; } Code:
application fireFoam; startFrom startTime; startTime 0.0; stopAt endTime; endTime 1.0; deltaT 1.0e-2; writeControl adjustableRunTime; writeInterval 0.01; purgeWrite 0; writeFormat ascii; writePrecision 6; writeCompression uncompressed; timeFormat general; timePrecision 6; graphFormat raw; runTimeModifiable yes; adjustTimeStep yes; maxCo 0.6; maxDeltaT 0.1; functions { fieldAverage { type fieldAverage; functionObjectLibs ( "libfieldFunctionObjects.so" ); enabled true; outputControl outputTime; fields ( U { mean on; prime2Mean on; base time; } T { mean on; prime2Mean on; base time; } CH4 { mean on; prime2Mean on; base time; } CO2 { mean on; prime2Mean on; base time; } H2O { mean on; prime2Mean on; base time; } O2 { mean on; prime2Mean on; base time; } ); } libs ( "libOpenFOAM.so" "libgroovyBC.so" "libgroovyStandardBCs.so" "libsimpleFunctionObjects.so" "libsimpleSwakFunctionObjects.so" "libswakFunctionObjects.so" "libswakPythonIntegration.so" "libswakTransportTurbFunctionPlugin.so" ) ; createFields.H Code:
volScalarField cp ( IOobject ( "cp", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), thermo.Cp() ); Code:
swak4Foam: Setting default mesh swak4Foam: Allocating new repository for sampledGlobalVariables --> FOAM Warning : From function ConcretePluginFunction<DriverType>::exists in file lnInclude/ConcretePluginFunction.C at line 121 Constructor table of plugin functions for PatchValueExpressionDriver is not initialized --> FOAM FATAL ERROR: Parser Error for driver PatchValueExpressionDriver at "1.1-2" :"field Qr not existing or of wrong type" "Qr" ^^ --| Context of the error: - Driver constructed from scratch Evaluating expression "Qr" From function parsingValue in file lnInclude/CommonValueExpressionDriverI.H at line 1189. FOAM exiting Thanks in advance.... [ Moderator note: moved from http://www.cfd-online.com/Forums/ope...-values-2.html ] Last edited by wyldckat; September 21, 2015 at 15:42. Reason: Added [CODE][/CODE] markers and moderator note |
|
May 5, 2015, 14:54 |
access field variables in groovyBC
|
#2 |
Member
Mehtab
Join Date: Jan 2015
Posts: 41
Rep Power: 11 |
Hi,
Is it possible to access field variables (mass flow, temperature, heat flux) in groovyBC? If yes then how? Please help Thanks |
|
September 21, 2015, 16:09 |
|
#3 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128 |
Greetings firefoam,
I've had your questions on my to-do list for quite sometime now and only today did I finally manage to come to it . The first issue I'm not able to reproduce. I used the tutorial case "combustion/fireFoam/les/smallPoolFire2D" as a test case for this and tried this condition: Code:
inlet { type groovyBC; valueExpression "T0+(Qf/m)"; variables "T0=300;m=phi;Qf=Qr;"; value 300; } I'm guessing the second question is related to the same problem, therefore I would need more details in order to be able to answer better to your question, because access to the "T" field should be straight forward and the other calculations could perhaps be achieved by using what's shown here: http://www.cfd-online.com/Forums/ope...tml#post446085 - post #5. Best regards, Bruno
__________________
|
|
September 28, 2015, 14:12 |
|
#4 | |
Member
Mehtab
Join Date: Jan 2015
Posts: 41
Rep Power: 11 |
Dear Bruno,
Thank you very much for looking at my problem. I also checked with OF 2.4.0 and swak4Foam 0.3.2. I took smallpoolfire3D tutorial case in OpenFoam. First I defined my boundary condition exactly same as you and it was working fine. Then I added Cp term into my equation as below. Code:
inlet { type groovyBC; valueExpression "T0+1/Cp*(Qf/m)"; variables "T0=300;m=phi;Qf=Qr;"; value 300; } I referred to the link provided by you : http://www.cfd-online.com/Forums/ope...tml#post446085 I have added the following piece of code into my controlDict and try to run the tutorial. Code:
loadThermo { type loadPsiThermoModel; correctModel false; // correctModel true; allowReload false; failIfModelTypeExists false; outputControl timeStep; outputInterval 1; } cvField { type expressionField; autowrite false; outputControl timeStep; outputInterval 1; expression "thermo_Cv()"; fieldName CRRv; } cpField { type expressionField; autowrite false; outputControl timeStep; outputInterval 1; expression "thermo_Cp()"; fieldName CRRp; } Quote:
Thanks |
||
October 2, 2015, 08:26 |
|
#5 | |
Member
Mehtab
Join Date: Jan 2015
Posts: 41
Rep Power: 11 |
Dear Bruno and Ehsan,
I am facing the same problem from quite a long time. But after reading this thread, I realized that I might be missing some functions in my controlDict file. I am attaching my controlDict file and Temperature Boundary condition file where I am using groovyBC. PS: Bruno, I have referred to your post http://www.cfd-online.com/Forums/ope...-groovybc.html #3 and http://www.cfd-online.com/Forums/ope...-values-2.html #39. I read the full post and think that I must be missing some functions in my controlDict file That is why I am attaching it to have a look for you. Please look at the files. Your guidance will be really helpful. My error message reads as below: Quote:
Thanks in advance. [ Moderator note: Moved from http://www.cfd-online.com/Forums/ope...-values-2.html ] Last edited by wyldckat; October 10, 2015 at 11:59. Reason: see "Moderator note:" |
||
October 4, 2015, 16:50 |
|
#6 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128 |
Quick answer: Please provide the complete "system/controlDict" file. I suspect something might be out-of-place and I can't guess what it is without seeing the full contents of the file.
|
|
October 5, 2015, 06:40 |
|
#7 |
Member
Mehtab
Join Date: Jan 2015
Posts: 41
Rep Power: 11 |
Dear Bruno,
Please find attached my system/controlDict file and Temperature boundary condition file where I am using groovyBC. Thanks in advance Maqs Last edited by mehtab; October 9, 2015 at 11:32. |
|
October 10, 2015, 11:55 |
|
#8 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128 |
Quick answer: My guess was right, you defined the function objects in the wrong place. In theory, the correct content for "controlDict" is this:
Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2.4.0 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // application fireFoam; startFrom startTime; startTime 0.0; stopAt endTime; endTime 4.0; deltaT 0.001; writeControl adjustableRunTime; writeInterval 0.1; purgeWrite 0; writeFormat ascii; writePrecision 6; writeCompression uncompressed; timeFormat general; timePrecision 6; graphFormat raw; runTimeModifiable yes; adjustTimeStep yes; maxCo 0.6; maxDeltaT 0.1; libs ( "libgroovyBC.so" "libsimpleFunctionObjects.so" "libsimpleSwakFunctionObjects.so" "libswakFunctionObjects.so" "libgroovyStandardBCs.so" "libswakThermoTurbFunctionPlugin.so" ); functions { loadThermo { type loadpsiThermoModel; correctModel false; //correctModel true; allowReload false; failIfModelTypeExists false; outputControl timeStep; outputInterval 1; } CvField { type expressionField; dimension [0 2 -2 -1 0 0 0]; autowrite false;//false; outputControl timeStep; outputInterval 1; expression "thermo:Cv()"; fieldName CRRv; } CpField { type expressionField; dimension [0 2 -2 -1 0 0 0]; autowrite false;//false; outputControl timeStep; outputInterval 1; expression "thermo:Cp()"; fieldName CRRp; } } // ************************************************************************* // |
|
October 13, 2015, 11:27 |
|
#9 |
Member
Mehtab
Join Date: Jan 2015
Posts: 41
Rep Power: 11 |
Dear Bruno,
Thank you very much for your support and guidance. I understood from this discussion that "loadPsiThermoModel" will provide all the fields which are defined in createField as thermo.p or thermo.T or thermo.psi etc. (mentioned in below code RoyalBlue color) createFields.H Code:
Info<< "Creating combustion model\n" << endl; autoPtr<combustionModels::psiCombustionModel> combustion ( combustionModels::psiCombustionModel::New ( mesh ) ); Info<< "Reading thermophysical properties\n" << endl; psiReactionThermo& thermo = combustion->thermo(); thermo.validate(args.executable(), "h", "e"); SLGThermo slgThermo(mesh, thermo); basicMultiComponentMixture& composition = thermo.composition(); PtrList<volScalarField>& Y = composition.Y(); const word inertSpecie(thermo.lookup("inertSpecie")); Info<< "Creating field rho\n" << endl; volScalarField rho ( IOobject ( "rho", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), thermo.rho() ); volScalarField& p = thermo.p(); const volScalarField& T = thermo.T(); const volScalarField& psi = thermo.psi(); Code:
Info<< "Creating combustion model\n" << endl; autoPtr<combustionModels::psiCombustionModel> combustion ( combustionModels::psiCombustionModel::New ( mesh ) ); Info<< "Reading thermophysical properties\n" << endl; psiReactionThermo& thermo = combustion->thermo(); thermo.validate(args.executable(), "h", "e"); SLGThermo slgThermo(mesh, thermo); basicMultiComponentMixture& composition = thermo.composition(); PtrList<volScalarField>& Y = composition.Y(); Is there any way to access mass concentration of a particular specie in groovyBC using swak4Foam? Code:
CH4Field { type expressionField; dimension [0 0 0 0 0 0 0]; autowrite false;//false; outputControl timeStep; outputInterval 1; expression "thermo_composition()"; fieldName Ych4; } Please suggest. Thanks Maqs |
|
October 17, 2015, 12:04 |
|
#10 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128 |
Quick answer: If the CH4 field is registered in memory and accessible from the outside, it will show up when you test this function object: http://openfoamwiki.net/index.php/Ti...gisteredObject
|
|
October 23, 2015, 20:59 |
|
#11 |
Member
Mehtab
Join Date: Jan 2015
Posts: 41
Rep Power: 11 |
Dear Bruno,
Thanks a lot for you help and suggestions. With your help, my temperature boundary condition is working now. But I tried to implement groovyBC for velocity BC using CH4 field only and this is not running and shows error. It is not calculating the velocity in first iteration only and stops just after rho calculations. My controlDict file looks fine now. I think the problem is in U file only while defining groovyBC. I have attached the file for your reference. Please suggest, if you point out any error or mistake in files. Thanks Maqs |
|
February 4, 2019, 13:08 |
|
#12 |
Member
Join Date: Oct 2015
Posts: 63
Rep Power: 11 |
Hi Mehtab,
Did you manage to fix your issue? If yes, then can you share your solution? I'm facing a similar problem where my variable is not getting updated with time if I use groovyBC. Best, Scram_1 |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to access the alpha.water field when coding a velocity boundary. | zhxter | OpenFOAM Programming & Development | 4 | December 24, 2021 08:57 |
[Other] dynamicTopoFVMesh and pointDisplacement | RandomUser | OpenFOAM Meshing & Mesh Conversion | 6 | April 26, 2018 08:30 |
[swak4Foam] groovyBC and access to fields of other Regions | ancolli | OpenFOAM Community Contributions | 0 | July 29, 2017 09:41 |
[swak4Foam] groovyBC issue - k and epsilon | sagnikmazumdar | OpenFOAM Community Contributions | 24 | March 1, 2015 08:16 |