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

Declare new volScalarField

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 5, 2019, 12:00
Default Declare new volScalarField
  #1
Member
 
Farshad
Join Date: Sep 2010
Posts: 31
Rep Power: 10
farshadexp is on a distinguished road
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()
);
No compile error.
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.
Your helps are appreciated, in advance.
farshadexp is offline   Reply With Quote

Old   July 8, 2019, 03:11
Default
  #2
New Member
 
Adam
Join Date: Jan 2019
Posts: 9
Rep Power: 2
boundary93 is on a distinguished road
I think you should do the calculaton not where you create the field but Im not sure
boundary93 is offline   Reply With Quote

Old   July 8, 2019, 14:43
Default
  #3
Member
 
Farshad
Join Date: Sep 2010
Posts: 31
Rep Power: 10
farshadexp is on a distinguished road
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.
farshadexp is offline   Reply With Quote

Old   July 9, 2019, 15:00
Default
  #4
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Maryland, United States
Posts: 116
Rep Power: 10
adhiraj is on a distinguished road
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.
adhiraj is offline   Reply With Quote

Old   July 9, 2019, 15:33
Default
  #5
Member
 
Farshad
Join Date: Sep 2010
Posts: 31
Rep Power: 10
farshadexp is on a distinguished road
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
farshadexp is offline   Reply With Quote

Old   July 9, 2019, 16:28
Default
  #6
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Maryland, United States
Posts: 116
Rep Power: 10
adhiraj is on a distinguished road
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?
adhiraj is offline   Reply With Quote

Old   July 12, 2019, 02:00
Default
  #7
Member
 
Farshad
Join Date: Sep 2010
Posts: 31
Rep Power: 10
farshadexp is on a distinguished road
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?!
farshadexp is offline   Reply With Quote

Old   July 12, 2019, 17:15
Default
  #8
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Maryland, United States
Posts: 116
Rep Power: 10
adhiraj is on a distinguished road
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.
adhiraj is offline   Reply With Quote

Old   July 13, 2019, 11:06
Default
  #9
Member
 
Farshad
Join Date: Sep 2010
Posts: 31
Rep Power: 10
farshadexp is on a distinguished road
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;
Declaring in createFields.H:


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;
farshadexp is offline   Reply With Quote

Old   July 15, 2019, 13:16
Default
  #10
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Maryland, United States
Posts: 116
Rep Power: 10
adhiraj is on a distinguished road
Sorry if my last reply was not clear, my bad

When I wrote

Quote:
Implement the new variable as rhohe = rho*he.
I did not mean that the line should be directly used in code, since that would not work. I was suggesting a thought process. You will need to figure out how to implement that thought into meaningful code. Unfortunately I have not studied the code part where he is defined and boundaries set, so I cannot help you with the implementation.
adhiraj is offline   Reply With Quote

Reply

Tags
openfoam

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
[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


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