CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   acces to createfields-Volscalarfields (https://www.cfd-online.com/Forums/openfoam-programming-development/175303-acces-createfields-volscalarfields.html)

SteveFOAM July 27, 2016 13:51

acces to createfields-Volscalarfields
 
I Have a problem with my driftFluxFoam adaption:

Because of the modular construction of DriftFluxFoam, the viscosity Model has no direct acces to the volScalarFields of createfields. Can somebody help me to initialize a volScalarField out of createFields, or even better, get acces to createFields?

SteveFOAM July 29, 2016 10:11

To solve my problem, i tried to save an load the Objects of a dictionary. Here is my code:

In the end of createfields.H:

Code:

IOdictionary bilineardict
(
    IOobject
    (
        "bilineardict",
        runTime.constant(),
        mesh,
        IOobject::NO_READ,
        IOobject::NO_WRITE
    )
);
volScalarField Konzentration
    (
        IOobject
        (
            "Konzentration",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        alpha1*rho1
    );

In my mixtureViscosityModel:

Code:

const objectRegistry& db = mesh.thisDb();
const dictionary& transportProperties = db().lookupObject<IOdictionary>
(
  "bilineardict"
);

But i got the error-massage: ’mesh’ was not declared in this scope.

Verse July 29, 2016 10:30

Can you post more of your solver (especially the beginning portion)? I presume you have either


Code:

#  include "createMesh.H"
or

Code:

#  include "createDynamicFvMesh.H"
in your code, so mesh should already be declared in one of those two headers.

If you want access to "Konzentration" in the main body of the code, you could use the lines:

Code:

volVectorField Konzentration
    (
        IOobject
        (
            "Konzentration",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );

After the mesh initilization (if I understand your question correctly).

SteveFOAM July 29, 2016 11:03

In my main function the only thing that comes near to your suggestions is
Code:

#include "createMesh.H"
The Includes of bilinear.C in the MixtureViscosityModel are:
Code:

#include "bilinear.H"
#include "addToRunTimeSelectionTable.H"
#include "fvcGrad.H"

I want to Use for example the Konzentration-value in bilinear.C.
If i write
Code:

volVectorField Konzentration
    (
        IOobject
        (
            "Konzentration",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );

in my bilinear.C, I get the error Massages:

error: conflicting declaration ‘Foam::volVectorField Konzentration’
(
^
bilinear/bilinear.C:97:20: error: ‘Konzentration’ has a previous declaration as ‘Foam::volScalarField Konzentration’
volScalarField Konzentration = alpha_*rho_c_;
^
bilinear/bilinear.C:119:13: error: ‘runTime’ was not declared in this scope
runTime.timeName(),
^
bilinear/bilinear.C:120:13: error: ‘mesh’ was not declared in this scope
mesh,

I don´t get these error messages about runTime and mesh in my createFields.H

Verse July 29, 2016 11:21

Did you forget to include bilinear.H in your .dep file perhaps?

teuk July 29, 2016 11:25

Hi SteveFOAM,

Quote:


bilinear/bilinear.C:97:20: error: ‘Konzentration’ has a previous declaration as ‘Foam::volScalarField Konzentration’
volScalarField Konzentration = alpha_*rho_c_;

This menas you already declared the variable Konzentration before. Probably in your bilinear.H ?

Quote:


bilinear/bilinear.C:119:13: error: ‘runTime’ was not declared in this scope
runTime.timeName(),

To use runTime in you object definition you neet the corresponding Header in your .C - file.


Quote:


bilinear/bilinear.C:120:13: error: ‘mesh’ was not declared in this scope
mesh,

Same thing here. Try "fvMesh.H"


regards,
teuk

SteveFOAM August 1, 2016 07:30

The previous declaration of Konzentration was a mistake in the code. The inclusion of "fvMesh.H" had not helped me, same error. I want to be clear: I already defined everything properly in createfields. I just want to read them in bilinear.C.
The mesh and the runTime is within the main, but the inclusion of the mixtureViscosityModels is far before this runtime loop (not my idea, its driftfluxFoam)


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