CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Source Term in chtMultiRegionFoam

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 3 Post By ssss

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 16, 2015, 15:21
Default Source Term in chtMultiRegionFoam
  #1
New Member
 
N/A
Join Date: Jul 2010
Posts: 29
Rep Power: 15
kamakura117 is on a distinguished road
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]
            )
        );
Then I suspect, I could simply add this in solveSolid.H:

Code:
        ==
            fvOptions(rho, h)
            + q
But, I am returned with an exceptionally long compilation error, which looks to be associated with a miss-match in matrix/scalar notion for the solver. However, as defined, the "q" source term is a matrix and the solver loop beings with "tmp<fvScalarMatrix> hEqn" So, I am a bit confused.

Any guidance would be appreciated.
kamakura117 is offline   Reply With Quote

Old   April 19, 2015, 03:58
Default
  #2
Senior Member
 
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 12
ssss is on a distinguished road
Are you sure that the dimensions of q are right?, maybe you should use fvc::div(q).
ssss is offline   Reply With Quote

Old   April 19, 2015, 11:53
Default
  #3
New Member
 
N/A
Join Date: Jul 2010
Posts: 29
Rep Power: 15
kamakura117 is on a distinguished road
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?
kamakura117 is offline   Reply With Quote

Old   April 20, 2015, 13:35
Default
  #4
Senior Member
 
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 12
ssss is on a distinguished road
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.
ssss is offline   Reply With Quote

Old   April 20, 2015, 14:46
Default
  #5
New Member
 
N/A
Join Date: Jul 2010
Posts: 29
Rep Power: 15
kamakura117 is on a distinguished road
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
and

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
Thanks.
kamakura117 is offline   Reply With Quote

Old   April 20, 2015, 15:18
Default
  #6
Senior Member
 
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 12
ssss is on a distinguished road
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];
Then modify the hEqn in the solveSolid.H file:

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
        );
The problem relies in the fact that you are creating an array of q objects, one for each of the solidRegions, so when you discreteza the hEqn, you must select the element of q which relies in the region you are solving. Hope it helps.
kamakura117, stingph and zhuangli like this.
ssss is offline   Reply With Quote

Old   April 21, 2015, 18:50
Default
  #7
New Member
 
N/A
Join Date: Jul 2010
Posts: 29
Rep Power: 15
kamakura117 is on a distinguished road
Excellent! I didn't even notice that header file, and that's exactly what was happening.

Cheers.
kamakura117 is offline   Reply With Quote

Reply


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
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


All times are GMT -4. The time now is 20:07.