|
[Sponsors] |
April 16, 2015, 15:21 |
Source Term in chtMultiRegionFoam
|
#1 |
New Member
N/A
Join Date: Jul 2010
Posts: 29
Rep Power: 15 |
Hello,
I am beginning the development of another solver, but I'm pretty amateur at C++. The solver I am writing requires a bit more detailed source term than is possible, currently, with fvOption. In this effect, I am just beginning my baby steps. I have scoured the forum for an avenue forward, but I'm having some problems. I am starting with OpenFoam 2.3.1. So, simply speaking, I create a new scalar field in createSolidFields.H: Code:
PtrList<volScalarField> q(solidRegions.size()); ... forAll(solidRegions, i) { .... Info<< " Add source\n" << endl; q.set ( i, new volScalarField ( IOobject ( "q", runTime.timeName(), solidRegions[i], IOobject::MUST_READ, IOobject::NO_WRITE ), solidRegions[i] ) ); Code:
== fvOptions(rho, h) + q Any guidance would be appreciated. |
|
April 19, 2015, 03:58 |
|
#2 |
Senior Member
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 12 |
Are you sure that the dimensions of q are right?, maybe you should use fvc::div(q).
|
|
April 19, 2015, 11:53 |
|
#3 |
New Member
N/A
Join Date: Jul 2010
Posts: 29
Rep Power: 15 |
Thanks for the response.
The dimensions of "q" are J/kg. It should be a scalar value. I don't think that a divergence makes sense here, or am I misinterpreting the result of the operation? |
|
April 20, 2015, 13:35 |
|
#4 |
Senior Member
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 12 |
So if q is a scalar value, then you shouldn't be reading it as an IOobject, you should read it from as a dimensioned scalar from the transportProperties and then create a volScalarField from it if you want.
I meant that q must have the correct dimensions, as I see you are introducing the source term in the energy equation and thus it must have [J]/([m^3][s]) dimensions if I've done the operations correctly. |
|
April 20, 2015, 14:46 |
|
#5 |
New Member
N/A
Join Date: Jul 2010
Posts: 29
Rep Power: 15 |
Hello,
I need to multiply by the density; however, I am just taking the source term one step at a time. Currently, I can't compile, so implicitly the dimensions don't matter too much until it reads in the initial conditions. The IOobject is necessary. The computation of "q" will be done with an external code and I want it to be read from a file where I am writing a dictionary for all of the volumes. For each volume, it is a scalar, it is not a vector. For completeness, the compilation error that I receive is a lot of something like: Code:
/solid/solveSolid.H:17:26: note: cannot convert ‘q’ (type ‘Foam::PtrList<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’) to type ‘const Foam::zero&’ ) - q Code:
./solid/solveSolid.H:17:26: note: cannot convert ‘q’ (type ‘Foam::PtrList<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’) to type ‘const Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >&’ ) - q |
|
April 20, 2015, 15:18 |
|
#6 |
Senior Member
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 12 |
I think I might have an answer for your errors. Open the setRegionSolidFields.H file and add this line:
Code:
const volScalarField& qRegionI = q[i]; Code:
tmp<fvScalarMatrix> hEqn ( fvm::ddt(betav*rho, h) - ( thermo.isotropic() ? fvm::laplacian(betav*thermo.alpha(), h, "laplacian(alpha,h)") : fvm::laplacian(betav*taniAlpha(), h, "laplacian(alpha,h)") ) == fvOptions(rho, h) +qRegionI ); |
|
April 21, 2015, 18:50 |
|
#7 |
New Member
N/A
Join Date: Jul 2010
Posts: 29
Rep Power: 15 |
Excellent! I didn't even notice that header file, and that's exactly what was happening.
Cheers. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Source Term due to evaporation in energy transport equation | styleworker | OpenFOAM Programming & Development | 3 | September 7, 2022 03:09 |
GPU Linear Solvers for OpenFOAM | gocarts | OpenFOAM Announcements from Other Sources | 37 | August 17, 2022 14:22 |
[swak4Foam] Swak4FOAM 0.2.3 / OF2.2.x installation error | FerdiFuchs | OpenFOAM Community Contributions | 27 | April 16, 2014 15:14 |
[swak4Foam] build problem swak4Foam OF 2.2.0 | mcathela | OpenFOAM Community Contributions | 14 | April 23, 2013 13:59 |
UDFs for Scalar Eqn - Fluid/Solid HT | Greg Perkins | FLUENT | 0 | October 11, 2000 03:43 |