|
[Sponsors] |
Add a scalar "transport" equation to BuoyantBoussinesqPimpleFoam |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 2, 2017, 11:21 |
Add a scalar "transport" equation to BuoyantBoussinesqPimpleFoam
|
#1 |
Member
Lilian Chabannes
Join Date: Apr 2017
Posts: 58
Rep Power: 9 |
Hello everyone,
I'm trying to implement the calculation of a scalar "sumti" in BuoyantBoussinesqPimpleFoam The goal is to calculate the induction time in a liquid silicone rubber flow. Silicone goes from liquid (or rubber) to solid with a chemical reaction, and the induction time is the time before the reaction occurs when the silicone is heated. So, for a constant temperature the induction time is : , t0 and T0 are constant. And because the process is non-isothermal : When sumti = 1, the induction is over. I don't understand how to implement this in the solver. When I just implement Code:
volScalarField ti(t0*Foam::exp(T0/T)); sumti += runTime.deltaT()/ti; I understand this is doing the calculation like that with the implementation I did, but I don't know how to transport the value with the flow. I hope I'm clear. Lilian |
|
June 4, 2017, 06:15 |
|
#2 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51 |
Hi Lilian,
your quantity is not been transported in the way you are talking about (by advection) based on the fact that we do not solve any kind of equation. The only thing that - somhow - transport this quantity is related to the temperature field T because this one can be advected. If you would like to transport your quantity based on the flow, you have to make sure to solve an equation for that, like: Code:
fvScalarMatrix sumLiEqn ( fvm::ddt(sumLi) + fvm::div(phi,sumLi) ); sumLiEqn.relax(); sumLiEqn.solve();
__________________
Keep foaming, Tobias Holzmann |
|
June 6, 2017, 05:49 |
|
#3 |
Member
Lilian Chabannes
Join Date: Apr 2017
Posts: 58
Rep Power: 9 |
Hi Tobi,
I tried this before and had a problem when trying to run the calculation : Code:
--> FOAM FATAL ERROR: cannot be called for a calculatedFvPatchField on patch inlet of field sumti in file "/home/lilian/OpenFOAM/lilian-4.1/run/mybuoyantBoussinesqPimpleFoam/tip2D/0/sumti" You are probably trying to solve for a field with a default boundary condition. From function Foam::tmp<Foam::Field<Type> > Foam::calculatedFvPatchField<Type>::valueInternalCoeffs(const Foam::tmp<Foam::Field<double> >&) const [with Type = double] in file fields/fvPatchFields/basic/calculated/calculatedFvPatchField.C at line 150. FOAM aborting Here is the .C file : Code:
Info<< "\nStarting time loop\n" << endl; while (runTime.run()) { #include "readTimeControls.H" #include "CourantNo.H" #include "setDeltaT.H" runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { #include "UEqn.H" #include "TEqn.H" // --- Pressure corrector loop while (pimple.correct()) { #include "pEqn.H" } if (pimple.turbCorr()) { laminarTransport.correct(); turbulence->correct(); } } //added volScalarField ti(t0*Foam::exp(T0/T)); sumti += runTime.deltaT()/ti; fvScalarMatrix sumtiEqn ( fvm::ddt(sumti) + fvm::div(phi, sumti) ); sumtiEqn.relax(); sumtiEqn.solve(); //endadded runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; } |
|
June 6, 2017, 05:55 |
|
#4 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51 |
This problem is related to the boundary condition. You cannot solve the system with calculated. Normally this BC is used if one calculate this field based on other (without solving any equation; e.g. p in bouyancy solver -> here we solve for p_rgh and build p based on that field.
__________________
Keep foaming, Tobias Holzmann |
|
June 6, 2017, 06:01 |
|
#5 |
Member
Lilian Chabannes
Join Date: Apr 2017
Posts: 58
Rep Power: 9 |
I'm not using the "calculated" BC. I put zeroGradient everywhere (this works fine if I don't add the Matrix in the solver), and tried with fixedvalue or even calculated to see what happens but the the same error appears everytime.
Isn't the problem in the .C file ? |
|
June 7, 2017, 02:31 |
|
#6 |
Senior Member
|
Hi all,
@Lookid With high probability your sumti field uses default BC, which is calculated. How do you construct sumti? |
|
June 7, 2017, 02:38 |
|
#7 |
Member
Lilian Chabannes
Join Date: Apr 2017
Posts: 58
Rep Power: 9 |
Hello alexeym,
sumti is constructed like that : Code:
volScalarField sumti ( IOobject ( "sumti", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh, dimensionedScalar("sumti", dimless, 0.0) ); Code:
Info<< "\nStarting time loop\n" << endl; while (runTime.run()) { #include "readTimeControls.H" #include "CourantNo.H" #include "setDeltaT.H" runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { #include "UEqn.H" #include "TEqn.H" // --- Pressure corrector loop while (pimple.correct()) { #include "pEqn.H" } if (pimple.turbCorr()) { laminarTransport.correct(); turbulence->correct(); } } //added volScalarField ti(t0*Foam::exp(T0/T)); sumti += runTime.deltaT()/ti; fvScalarMatrix sumtiEqn ( fvm::ddt(sumti) + fvm::div(phi, sumti) ); sumtiEqn.relax(); sumtiEqn.solve(); //endadded runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; } |
|
June 7, 2017, 02:51 |
|
#8 |
Senior Member
|
Hi,
You are using this constructor - https://cpp.openfoam.org/v4/classFoa...0d8f8a5fec0dc8 - to create sumti. As you can see all boundary conditions for the field are set to calculated type. You can create sumti as Code:
volScalarField sumti ( IOobject ( "sumti", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh, dimensionedScalar("sumti", dimless, 0.0), "zeroGradient" ); Also solution order is not quite physical. I think you should first transport sumti and then accumulate. |
|
June 7, 2017, 02:54 |
|
#9 |
Senior Member
|
You are using read constructor. I have missed it.
How sumti is defined in 0 folder? |
|
June 7, 2017, 03:06 |
|
#10 |
Member
Lilian Chabannes
Join Date: Apr 2017
Posts: 58
Rep Power: 9 |
I put zeroGradient on all boundaries and 0 in internalField, but it's already defined in CreateFields, right ?
So I changed it to NO_READ and deleted the 0/sumti file. It works, thank you very much ! |
|
June 7, 2017, 07:20 |
|
#11 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51 |
If removing the MUST_READ option and define the BC explicitly by calling the appropriate constructor will solve your problem, then you did something wrong in the first approach. However, nice to know that it is working now. Good luck.
PS: Maybe you were calling the wrong constructor because your implementation was: Code:
volScalarField sumti ( Oobject ( "sumti", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh, dimensionedScalar("sumti", dimless, 0.0) //- Not needed and thus, you might call another constructor which was not reading your 0/sumit file or overwrite the BC you set );
__________________
Keep foaming, Tobias Holzmann |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Setting the height of the stream in the free channel | kevinmccartin | CFX | 12 | October 13, 2022 21:43 |
How to add a passive scalar to the simpleFoam solver | Uyan | OpenFOAM Running, Solving & CFD | 6 | June 22, 2017 17:36 |
Add Work due to body force in the energy equation for a lagrangian solver | mneben | OpenFOAM Programming & Development | 6 | January 19, 2016 05:30 |
dieselFoam problem!! trying to introduce a new heat transfer model | vivek070176 | OpenFOAM Programming & Development | 10 | December 23, 2014 23:48 |