|
[Sponsors] |
July 5, 2019, 12:00 |
Declare new volScalarField
|
#1 |
Member
Farshad
Join Date: Sep 2010
Posts: 36
Rep Power: 15 |
Hi FOAMers...
I'm trying to declare a new volScalarField based on an existing volScalarField, as followong: Code:
volScalarField rhohe ( IOobject ( "rhohe", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), rho*thermo.he() ); But during run, following error is being shown: Code:
--> FOAM FATAL ERROR: cannot be called for a calculatedFvPatchField on patch base of field rhohe in file "/home/farshad/OpenFOAM/farshad-v1812/run/fireFoam/LES/smallPoolFire2D/0/rhohe" You are probably trying to solve for a field with a default boundary condition. From function Foam::tmp<Foam::Field<Type> > Foam::calculatedFvPatchField<Type>::gradientInternalCoeffs() const [with Type = double] in file fields/fvPatchFields/basic/calculated/calculatedFvPatchField.C at line 186. |
|
July 8, 2019, 03:11 |
|
#2 |
New Member
Adam
Join Date: Jan 2019
Posts: 21
Rep Power: 7 |
I think you should do the calculaton not where you create the field but Im not sure
|
|
July 8, 2019, 14:43 |
|
#3 |
Member
Farshad
Join Date: Sep 2010
Posts: 36
Rep Power: 15 |
Thanks boundary93 for your response...
I declare that in Createfields.H and also YEEqn.H. But in both cases the result is same, runtime error. |
|
July 9, 2019, 15:00 |
|
#4 |
Senior Member
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 15 |
Are you creating a field rhohe and then also trying to solve an equation for it?
If so, you will need to explicitly set boundary conditions for rhohe. As far as I recall, when you multiply two fields to produce a new field, you get "calculated" boundary conditions for the new field. Solvers don't know what to do with the "calculated" boundary condition. Hope this helps. |
|
July 9, 2019, 15:33 |
|
#5 |
Member
Farshad
Join Date: Sep 2010
Posts: 36
Rep Power: 15 |
Dear Adhiraj
You are right, that's the point. But, I am trying to solve "rhohe" instead of "he" in the same manner. For "he" we need no BC, and also for rho, so why we need to specify BC for new "rhohe"?? And, what's the solution |
|
July 9, 2019, 16:28 |
|
#6 |
Senior Member
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 15 |
Keep in mind that he is a 'special' variable, in that it is generated internally, and is not provided by the user. This variable also comes with special boundary conditions, and it is taken care of by the code internally.
The variable rho does not seem to be so special, and so I am not 100% sure of what is happening. I think this is what happens with rho (someone more familiar with the code can explain more? ): If you look at the rho equation, it does not seem to directly use boundary values of rho. So maybe that is why the function gradientInternalCoeffs is not called for rho? |
|
July 12, 2019, 02:00 |
|
#7 |
Member
Farshad
Join Date: Sep 2010
Posts: 36
Rep Power: 15 |
Thanks for explanation Adhiraj, right!
I'm looking for a solution to declare a volSacalarField based on "he", which do not need a boundary condition, because I think it's hard to specify a BC. What is the solution? do you have any idea?! |
|
July 12, 2019, 17:15 |
|
#8 |
Senior Member
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 15 |
I guess there are two options here:
1. Implement the new variable as rhohe = rho*he. For the boundary conditions, have a look at what is done for he, and maybe you can use that as a guide. Here your goal is to come up with a boundary condition that is consistent with the corresponding temperature boundary condition. 2. Reformulate the problem so that you know what boundary conditions to use, and simply read them in during simulation. So you will need to provide a rhohe file in the initial time directory. |
|
July 13, 2019, 11:06 |
|
#9 |
Member
Farshad
Join Date: Sep 2010
Posts: 36
Rep Power: 15 |
appreciated Adhiraj...
for the first option, declaring rhohe=rho*he leads to compile error. Declaring in YEEqn.H: Code:
YEEqn.H:58:32: error: invalid user-defined conversion from ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ to ‘Foam::volScalarField& {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&}’ [-fpermissive] volScalarField& rhohe = rho*he; Code:
createFields.H:177:29: error: conversion from ‘const Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>’ to ‘Foam::volScalarField& {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&}’ discards qualifiers [-fpermissive] volScalarField& rhohe = rho*he; |
|
July 15, 2019, 13:16 |
|
#10 | |
Senior Member
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 15 |
Sorry if my last reply was not clear, my bad
When I wrote Quote:
|
||
July 26, 2019, 13:18 |
|
#11 |
New Member
Join Date: Jun 2017
Posts: 9
Rep Power: 0 |
Farshad,
In case you have some simple boundary condition then you can use this format but this only works very few boundary types. Info<< "Reading field h\n" << endl; volScalarField h ( IOobject ( "h", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), Cp*T + fl*L, T.boundaryField().types(), fl.boundaryField().types() ); If this doesn't help then you can either define your field in normal ways and calculate your boundary values somewhere in the solver. or you can predefine your varible in you 0 directory then modify the internal field in the code given you have simple BC. |
|
July 26, 2019, 13:22 |
|
#12 | |
Member
Farshad
Join Date: Sep 2010
Posts: 36
Rep Power: 15 |
Hi Adhiraj
that was my fault. thanks for your guidance. I will try and hopefully find a solution... Quote:
|
||
July 26, 2019, 13:29 |
|
#13 | |
Member
Farshad
Join Date: Sep 2010
Posts: 36
Rep Power: 15 |
Hi Scientist
Based on your explanations, I will define variable. It need some manipilations (I guess). I will tell you the results. Quote:
|
||
July 28, 2019, 15:57 |
|
#14 | |
Member
Farshad
Join Date: Sep 2010
Posts: 36
Rep Power: 15 |
Quote:
Hi, I tried your solution and declared a field as followings: Code:
volScalarField rhohe ( IOobject ( "rhohe", runTime.timeName(), mesh, IOobject::MUST_READ, //NO_READ, IOobject::AUTO_WRITE ), rho*he, rho.boundaryField().types(), he.boundaryField().types() ); Code:
FoamFile { version 2.0; format ascii; class volScalarField; location "0"; object rhohe; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [2 -1 -2 0 0 0 0]; internalField uniform 300; boundaryField { "(outlet|sides)" { type inletOutlet; inletValue $internalField; value $internalField; } base { type zeroGradient; //calculated; //value $internalField; } inlet { type fixedValue; value uniform 300; } frontAndBack { type empty; } } Code:
--> FOAM FATAL ERROR: cannot be called for a calculatedFvPatchField on patch base of field rhohe in file "/home/farshad/OpenFOAM/farshad-v1812/run/fireFoam/LES/smallPoolFire2D/0.00144928/rhohe" You are probably trying to solve for a field with a default boundary condition. From function Foam::tmp<Foam::Field<Type> > Foam::calculatedFvPatchField<Type>::gradientInternalCoeffs() const [with Type = double] in file fields/fvPatchFields/basic/calculated/calculatedFvPatchField.C at line 186. |
||
July 28, 2019, 18:23 |
|
#15 |
Senior Member
Daniel
Join Date: Mar 2013
Location: Noshahr, Iran
Posts: 348
Rep Power: 21 |
try this:
1- Declare your variable to be read from 0 directory: Code:
volScalarField rhohe ( IOobject ( "rhohe", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); Code:
rhohe = rho * he; rhohe.correctBoundaryConditions(); |
|
Tags |
openfoam |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[OpenFOAM.org] OpenFOAM 2.3.1 installation on SUSE Linux Enterprise 12 | harsha_kulkarni | OpenFOAM Installation | 17 | November 16, 2015 03:06 |
[OpenFOAM.org] Installation problem 2.4.0 on Centos 6.6 | luke_skywalker | OpenFOAM Installation | 8 | November 13, 2015 08:15 |
writing execFlowFunctionObjects | immortality | OpenFOAM Post-Processing | 30 | September 15, 2013 06:16 |
Sgimpi | pere | OpenFOAM | 27 | September 24, 2011 07:57 |
Ld_library_path | scottneh | OpenFOAM | 9 | November 21, 2009 09:15 |