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

Reading a list of scalar data as a constant source term in the governing equation

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By zhangyan

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 8, 2018, 20:37
Default Reading a list of scalar data as a constant source term in the governing equation
  #1
Member
 
Lewis
Join Date: Jun 2016
Posts: 34
Rep Power: 10
Lewis Liang is on a distinguished road
Dear Foamers,

I modify the governing equation by adding a source term in a solver, and the source term is a list of scalar which is solved by another solver. But the mesh geometry is kept the same by employing the same blockMeshDict. The source term here call sigma0 as shown below:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  4.0                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volScalarField;
    location    "0.4";
    object      sigma0;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [1 -1 -2 0 0 0 0];

internalField   nonuniform List<scalar> 
1125000
(
187900
187900
187900
187900
187900
187900
187900
187901
187901
187902
187902
187903
187903
187904
187905
187906
187907
187908
187909
187910
187911
187912
187913
187914
187916
187917
187918
187920
....
)
;
    }
}
And I try to add this list of data into the governing equation of new solver, the governing equation is shown:
Code:
fvScalarMatrix p2Eqn
(
fvm::ddt(p2) == fvm::laplacian(Cv, p2) - sigma0
);
And I found solution online, which is applying a dictionary to achieve this purpose, then I make a header file to read this list of data, but I got a error after compiling the solver.
Code:
    
 Info<< "Reading sigma0 field\n" << endl;

 IOdictionary sigmaD0
    (
        IOobject
        (
            "sigmaD0",    // name of the file
            runTime.constant(),
            mesh, 
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    );

    volScalarField  sigma0
   (
        sigmaD0.lookup("sigma0")
   );
Does anyone meet this kind of problem? Thanks in advance!

Cheers!

Lewis
Lewis Liang is offline   Reply With Quote

Old   August 8, 2018, 22:59
Default
  #2
Senior Member
 
zhangyan's Avatar
 
Yan Zhang
Join Date: May 2014
Posts: 120
Rep Power: 12
zhangyan is on a distinguished road
Code:
IOobject sigma0_Header
(
    "sigma0",
    runTime.constant(),
    mesh,
    IOobject::MUST_READ
);          

volScalarField sigma0(sigma0_Header, mesh);
atulkjoy and Lewis Liang like this.
__________________
https://openfoam.top
zhangyan is offline   Reply With Quote

Old   August 9, 2018, 04:24
Default
  #3
Member
 
Lewis
Join Date: Jun 2016
Posts: 34
Rep Power: 10
Lewis Liang is on a distinguished road
Hi!@zhangyan Thanks for your sharing. The solver is compiled successfully, and the list of data seem to be read in the governing equation so far. For this code:
Code:
volScalarField sigma0(sigma0_Header, mesh);
I have tried to figure out the original syntax in OpenFOAM class, but I did't find them from the volScalarField class. Could you please tell the location of the original OpenFOAM code?

Best regards,

Lewis
Lewis Liang 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
polynomial BC srv537 OpenFOAM Pre-Processing 4 December 3, 2016 10:07
[OpenFOAM.org] Error creating ParaView-4.1.0 OpenFOAM 2.3.0 tlcoons OpenFOAM Installation 13 April 20, 2016 18:34
SparceImage v1.7.x Issue on MAC OS X rcarmi OpenFOAM Installation 4 August 14, 2014 07:42
Problem compiling a custom Lagrangian library brbbhatti OpenFOAM Programming & Development 2 July 7, 2014 12:32
[swak4Foam] Error bulding swak4Foam sfigato OpenFOAM Community Contributions 18 August 22, 2013 13:41


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