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

Read properties per component from an input file dictionary

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree4Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   September 2, 2013, 09:31
Default
  #21
Member
 
P.A.
Join Date: Mar 2009
Location: Germany
Posts: 47
Rep Power: 8
blaise is on a distinguished road
Hi Matvej,

I must apologize, this is all rubbish!!! Please forget this, I have to think over it again!

Sorry for wasting your time with this! I will come back to you when I cleared things up.

I wish I could somehow delete a posting...

Thank you,

Cheers,

Pascal.
blaise is offline   Reply With Quote

Old   September 3, 2013, 03:07
Default
  #22
Member
 
P.A.
Join Date: Mar 2009
Location: Germany
Posts: 47
Rep Power: 8
blaise is on a distinguished road
Hi Matvej,

I thought over my whole approach again and again, and I came to the conclusion, that my
posting with the attached flake.tar.gz wasn't as much rubbish as I thought. I thought I mixed
up two different ways to handle the data, but in fact the application I attached in my reply is almost
what I want. To make things clearer:

When we look at the dictionary file:
Code:
setFormat raw;
lambda 2.0;
flakeVelocity (1.9 0 0); 
sym false; 

flakeProps
(
    flakeOne
    {
        flakeD 4.5;
        radii ( 0.1 0.2 0.3 0.4 0.5 );
    }
    flakeTwo
    {
        flakeD 4.5;
        radii ( 0.1 0.2 0.3 0.4 0.5 );
    }
);
I want to load all the data into a single object containing the general data like "setFormat" or "lambda",
and the list "flakeProps" shall go into a list of dictionaries variable. In my code I declare this list of
dictionaries, but I don't do anything with it as I do not know how to get the data into this list using the >>operator.

For the main application the code should be something like this:

Code:
// All the include stuff remains as it is.

IOdictionary flakeProperties
(
    IOobject
        (
            "flakeDict",
            runTime.system(),
            mesh,
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::NO_WRITE
         )
);

flake flakes();
flakeProperties.lookupEntryPtr(".*", false, true)->stream() >> flakes;

Info << "Flakes: " << flakes << nl;

return 0;
This does not compile, but I would like to learn how to make it work. Can you help, or is this a stupid
approach anyway?

Of course I could simply pass the IOdictionary to a constructor and handle the loading of the variables
in this constructor. But I think it would be more elegant to have the >>operator do all this work.

I hope you can help me on this once more!

Thanks and best regards,

Pascal.
blaise is offline   Reply With Quote

Old   May 27, 2015, 08:48
Default
  #23
New Member
 
Milad Ghaderi
Join Date: Feb 2013
Posts: 6
Rep Power: 4
Milad06 is on a distinguished road
Hi,

I am having similar case where I want to change from constant lewis number to using different values for different species. Therefore, I have introduced Lewis number (Le) by using a speciesDict in constant folder for all the species of my case as follow:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  1.6                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "constant";
    object      speciesDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

species
(
  H
  H2
  O
  O2
  OH
  H2O
  N2
  HO2
  H2O2
  AR
  );

H
{
    Le      Le  [0 0 0 0 0 0 0] 0.18;
    D      D  [0 2 -1 0 0 0 0] 1e-5;
    DD   DD [0 2 -1 0 0 0 0] (1.e-5 0 0 0 1.4e-5 0 0 0 1.e-5);
}

H2
{
    Le      Le  [0 0 0 0 0 0 0] 0.29;
    D      D  [0 2 -1 0 0 0 0] 1e-5;
    DD   DD [0 2 -1 0 0 0 0] (1.e-5 0 0 0 1.4e-5 0 0 0 1.e-5);
}

O
{
    Le      Le  [0 0 0 0 0 0 0] 0.70; //assumed
    D      D  [0 2 -1 0 0 0 0] 1e-5;
    DD   DD [0 2 -1 0 0 0 0] (1.e-5 0 0 0 1.4e-5 0 0 0 1.e-5);
}

O2
{
    Le      Le  [0 0 0 0 0 0 0] 1.10;
    D      D  [0 2 -1 0 0 0 0] 1e-5;
    DD   DD [0 2 -1 0 0 0 0] (1.e-5 0 0 0 1.4e-5 0 0 0 1.e-5);
}

OH
{
    Le      Le  [0 0 0 0 0 0 0] 0.71;
    D      D  [0 2 -1 0 0 0 0] 1e-5;
    DD   DD [0 2 -1 0 0 0 0] (1.e-5 0 0 0 1.4e-5 0 0 0 1.e-5);
}

H2O
{
    Le      Le  [0 0 0 0 0 0 0] 0.89;
    D      D  [0 2 -1 0 0 0 0] 1e-5;
    DD   DD [0 2 -1 0 0 0 0] (1.e-5 0 0 0 1.4e-5 0 0 0 1.e-5);
}

N2
{
    Le      Le  [0 0 0 0 0 0 0] 1.04;
    D      D  [0 2 -1 0 0 0 0] 1e-5;
    DD   DD [0 2 -1 0 0 0 0] (1.e-5 0 0 0 1.4e-5 0 0 0 1.e-5);
}

HO2
{
    Le      Le  [0 0 0 0 0 0 0] 1.08;
    D      D  [0 2 -1 0 0 0 0] 1e-5;
    DD   DD [0 2 -1 0 0 0 0] (1.e-5 0 0 0 1.4e-5 0 0 0 1.e-5);
}

H2O2
{
    Le      Le  [0 0 0 0 0 0 0] 1.09;
    D      D  [0 2 -1 0 0 0 0] 1e-5;
    DD   DD [0 2 -1 0 0 0 0] (1.e-5 0 0 0 1.4e-5 0 0 0 1.e-5);
}

AR
{
    Le      Le  [0 0 0 0 0 0 0] 0.18; //assumed
    D      D  [0 2 -1 0 0 0 0] 1e-5;
    DD   DD [0 2 -1 0 0 0 0] (1.e-5 0 0 0 1.4e-5 0 0 0 1.e-5);
}
and my createFields.H is as follow:

Code:
IOdictionary speciesDict
    (
        IOobject
        (
            "speciesDict",    // dictionary name
            runTime.constant(),     // dict is found in "constant"
            mesh,                   // registry for the dict
            IOobject::MUST_READ,    // must exist, otherwise failure
            IOobject::NO_WRITE      // dict is only read by the solver
        )
    );
    
    wordList speciesNames
    (
        speciesDict.lookup("species")
    );
    forAll(speciesNames, i)
    {
        word currentSpecie = speciesNames[i];
        Info<< "Doing stuff for specie: " << currentSpecie << endl;

        const dictionary& subDict = speciesDict.subDict(currentSpecie);

        dimensionedScalar Le_("Le", dimensionSet(0,0,0,0,0,0,0), scalar(0.0));
                Info<< "uliuli1: "  << endl;

    dimensionedScalar D_("D", dimensionSet(0,2,-1,0,0,0,0), scalar(0.0));
        dimensionedTensor DD_("DD", dimensionSet(0,2,-1,0,0,0,0), tensor(0.0));
        Le_ = subDict.lookup("Le");
        D_ = subDict.lookup("D");
        DD_ = subDict.lookup("DD");
            

    
        Info<< "Le = " << Le_ << endl;
        Info<< "D = " << D_ << endl;
        Info<< "DD = " << DD_ << endl;
    }
    
            Info<< "uliuli2: "  << endl;


    PtrList<dimensionedScalar> Leval(speciesNames.size());

    forAll(speciesNames, i)
    {
        word specieName = speciesNames[i];
        Info<< "uliuli3: " << specieName << endl;

        const dictionary& subDict2 = speciesDict.subDict(specieName);
          Info<< "uliuli4: " << endl;

        Leval.set
        (
             i,
             new dimensionedScalar(subDict2.lookup("Le"))
        );
    }
//end
Info<< "list " << Leval << endl;
So now my Leval is the Lewis number I want however, it gives me both the word ''Le'' and the dimension in addition of the value itself as follow:
Code:
10
(
Le [0 0 0 0 0 0 0] 0.18
Le [0 0 0 0 0 0 0] 0.29
Le [0 0 0 0 0 0 0] 0.7
Le [0 0 0 0 0 0 0] 1.1
Le [0 0 0 0 0 0 0] 0.71
Le [0 0 0 0 0 0 0] 0.89
Le [0 0 0 0 0 0 0] 1.04
Le [0 0 0 0 0 0 0] 1.08
Le [0 0 0 0 0 0 0] 1.09
Le [0 0 0 0 0 0 0] 0.18
)
1. How can I get only the values like (0.18 or 0.29 or ...) and not all the Le and dimensions ?

2. How can I use these 10 species Le numbers in the following equation as I want to divide my alphaEff by Le[i] of each specie in the loop.

Code:
forAll(Y, i)
    {
        if (Y[i].name() != inertSpecie)
        {
            volScalarField& Yi = Y[i];
        
               
        fvScalarMatrix YiEqn
            (
                fvm::ddt(rho, Yi)
              + mvConvection->fvmDiv(phi, Yi)
              - fvm::laplacian(turbulence->alphaEff()/Leval[i] ,Yi)   
             ==
                reaction->R(Yi)
              + fvOptions(rho, Yi)
            );
Thanks guys,
Milad
Milad06 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
1.7.x Environment Variables on Linux 10.04 rasma OpenFOAM Installation 9 July 30, 2010 04:43
Installation of OpenFOAM-1.6 on Ubuntu 9.10 marval OpenFOAM Installation 2 March 17, 2010 09:33
ParaView 33 canbt open OpenFoam file hariya03 OpenFOAM Paraview & paraFoam 7 September 25, 2008 17:33
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 01:24
Results saving in CFD hawk Main CFD Forum 16 July 21, 2005 20:51


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