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/)
-   -   Solving with a variable non defined in 0 directory (https://www.cfd-online.com/Forums/openfoam-programming-development/151247-solving-variable-non-defined-0-directory.html)

kebsiali April 7, 2015 11:04

Solving with a variable non defined in 0 directory
 
Hello Foamers

Im trying to solve over a variable i call X which represents the ration of inital concentration Ci while i need the new C to be written at the end of each step

what i did is the following

1. in createFileds.H
volScalarField COH
(
IOobject
(
"COH",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

volScalarField XOH
(
IOobject
(
"XOH",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
(COH0-COH)/COH0
);


and then i create a .H file to solve for XOH as

fvScalarMatrix XOHEqn
(
fvm::ddt( XOH)
+ fvm::div(phi, XOH)
);

XOHEqn.solve();
COH=COH0*(1.0-XOH);


I thought it would work swiftly, but it shows an error i dont understand which is:

--> FOAM FATAL ERROR:

valueInternalCoeffs cannot be called for a calculatedFvPatchField
on patch atmosphere of field XOH in file "/home/alkebsi/OpenFOAM/alkebsi-2.3.1/run/heatingwater4/0/XOH"
You are probably trying to solve for a field with a default boundary condition.

From function calculatedFvPatchField<Type>::valueInternalCoeffs( const tmp<scalarField>&) const
in file /opt/openfoam231/src/finiteVolume/lnInclude/calculatedFvPatchField.C at line 154.

FOAM exiting

I dont have file called XOH in 0 directory, rather i have a file for COH in which all the boundaries are zeroGradient and i use a setFiled to partially fill the domain (I wrok with interFoam and my COH exists in one phase but this has nothing to do with the current problem)

alexeym April 7, 2015 14:17

Hi,

I guess boundary conditions for XOH should be the same as for COH. So you should use the following constructor for XOH:

Code:

volScalarField XOH
(
    IOobject
    (
        "XOH",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::NO_WRITE
    ),
    (COH0-COH)/COH0,
    COH.boundaryField().types()
);


kebsiali April 8, 2015 06:18

Thank you very much
That was it, it worked.


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