|
[Sponsors] |
Can I get OpenFOAM to Calculate Energy Flux for me? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 13, 2016, 09:21 |
Can I get OpenFOAM to Calculate Energy Flux for me?
|
#1 |
New Member
Evan
Join Date: May 2016
Posts: 23
Rep Power: 10 |
Hi all,
I'm running a simulation that propagates internal waves through a stratified fluid and I want to calculate the energy flux at various points throughout my domain over time. The formula for energy flux is simply J = pU and I already have output files for p and U for each time step. My question is, how do I get OpenFOAM to multiply pressure and velocity and generate a new output file called "energyFlux"? Thanks |
|
September 13, 2016, 09:40 |
|
#2 |
New Member
Evan
Join Date: May 2016
Posts: 23
Rep Power: 10 |
So far I have:
Code:
volVectorField ( IOobject ( "energyFlux", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), p*U ); Last edited by k13113y; September 13, 2016 at 09:41. Reason: code blocks |
|
September 13, 2016, 10:18 |
|
#3 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
foamCalc multiply p U:
https://openfoamwiki.net/index.php/Contrib_foamCalcEx
__________________
*On twitter @akidTwit *Spend as much time formulating your questions as you expect people to spend on their answer. |
|
September 13, 2016, 10:22 |
|
#4 | |
New Member
Join Date: May 2016
Posts: 28
Rep Power: 10 |
Quote:
Code:
const vector energyFlux = p*U volVectorField energyFlux ( IOobject ( "energyFlux", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), dimensionedScalar("energyFlux",p.dimension*U.dimension,) ); Hope this is useful for you |
||
September 13, 2016, 10:24 |
|
#5 |
New Member
Evan
Join Date: May 2016
Posts: 23
Rep Power: 10 |
hey this is great!! Many thanks
My only question now is: does it matter where I place it in the createFields.H file? I'm assuming it must be after p and U... |
|
September 13, 2016, 10:37 |
|
#6 | |
New Member
Join Date: May 2016
Posts: 28
Rep Power: 10 |
Quote:
In the past I've never cared where I write and it has always worked EDIT: there's a mistake in the last line of the code: after p.dimension()*U.dimension(), after the comma you need to write 0.0. Code:
dimensionedScalar('energyFlux",p.dimension()*U.dimension(),0.0) |
||
September 13, 2016, 10:45 |
|
#7 |
New Member
Evan
Join Date: May 2016
Posts: 23
Rep Power: 10 |
Hmm I seem to be getting an error when I try to compile.
Code:
Info<< "Reading field energyFlux\n" <<endl; const vector energyFlux=p_rgh*U; volVectorField energyFlux ( IOobject ( "energyFlux", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), dimensionedScalar("energyFlux",p_rgh.dimension*U.dimension,) ); Code:
In file included from /opt/openfoam4/src/OpenFOAM/lnInclude/postProcess.H:129:0, from interEnergyFluxFoam.C:58: ./createFields.H: In function ‘int main(int, char**)’: ./createFields.H:32:30: error: conversion from ‘Foam::tmp<Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> >’ to non-scalar type ‘const vector {aka const Foam::Vector<double>}’ requested const vector energyFlux=p_rgh*U; ^ ./createFields.H:36:5: error: conflicting declaration ‘Foam::volVectorField energyFlux’ ( ^ ./createFields.H:32:14: note: previous declaration as ‘const vector energyFlux’ const vector energyFlux=p_rgh*U; ^ ./createFields.H:43:42: error: ‘Foam::volScalarField {aka class Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ has no member named ‘dimension’ dimensionedScalar("energyFlux",p_rgh.dimension*U.dimension,) ^ ./createFields.H:43:54: error: ‘Foam::volVectorField {aka class Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>}’ has no member named ‘dimension’ dimensionedScalar("energyFlux",p_rgh.dimension*U.dimension,) ^ ./createFields.H:43:22: error: expected primary-expression before ‘(’ token dimensionedScalar("energyFlux",p_rgh.dimension*U.dimension,) ^ ./createFields.H:43:42: error: ‘Foam::volScalarField {aka class Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ has no member named ‘dimension’ dimensionedScalar("energyFlux",p_rgh.dimension*U.dimension,) ^ ./createFields.H:43:54: error: ‘Foam::volVectorField {aka class Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>}’ has no member named ‘dimension’ dimensionedScalar("energyFlux",p_rgh.dimension*U.dimension,) ^ ./createFields.H:43:64: error: expected primary-expression before ‘)’ token dimensionedScalar("energyFlux",p_rgh.dimension*U.dimension,) ^ In file included from interEnergyFluxFoam.C:67:0: createFields.H:32:30: error: conversion from ‘Foam::tmp<Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> >’ to non-scalar type ‘const vector {aka const Foam::Vector<double>}’ requested const vector energyFlux=p_rgh*U; ^ createFields.H:36:5: error: conflicting declaration ‘Foam::volVectorField energyFlux’ ( ^ createFields.H:32:14: note: previous declaration as ‘const vector energyFlux’ const vector energyFlux=p_rgh*U; ^ createFields.H:43:42: error: ‘Foam::volScalarField {aka class Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ has no member named ‘dimension’ dimensionedScalar("energyFlux",p_rgh.dimension*U.dimension,) ^ createFields.H:43:54: error: ‘Foam::volVectorField {aka class Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>}’ has no member named ‘dimension’ dimensionedScalar("energyFlux",p_rgh.dimension*U.dimension,) ^ createFields.H:43:22: error: expected primary-expression before ‘(’ token dimensionedScalar("energyFlux",p_rgh.dimension*U.dimension,) ^ createFields.H:43:42: error: ‘Foam::volScalarField {aka class Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ has no member named ‘dimension’ dimensionedScalar("energyFlux",p_rgh.dimension*U.dimension,) ^ createFields.H:43:54: error: ‘Foam::volVectorField {aka class Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>}’ has no member named ‘dimension’ dimensionedScalar("energyFlux",p_rgh.dimension*U.dimension,) ^ createFields.H:43:64: error: expected primary-expression before ‘)’ token dimensionedScalar("energyFlux",p_rgh.dimension*U.dimension,) ^ /opt/openfoam4/wmake/rules/General/transform:8: recipe for target 'Make/linux64GccDPInt32Opt/interEnergyFluxFoam.o' failed make: *** [Make/linux64GccDPInt32Opt/interEnergyFluxFoam.o] Error 1 |
|
September 13, 2016, 10:49 |
|
#8 |
New Member
Join Date: May 2016
Posts: 28
Rep Power: 10 |
I think it is because one argument in dimensionedScalar function is missing, check the edit at my last post
|
|
September 13, 2016, 10:56 |
|
#9 |
New Member
Evan
Join Date: May 2016
Posts: 23
Rep Power: 10 |
ah sorry, it still has a similar error. I'm using OF 4.0 but I don't think that should matter.
Code:
In file included from /opt/openfoam4/src/OpenFOAM/lnInclude/postProcess.H:129:0, from interEnergyFluxFoam.C:58: ./createFields.H: In function ‘int main(int, char**)’: ./createFields.H:32:30: error: conversion from ‘Foam::tmp<Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> >’ to non-scalar type ‘const vector {aka const Foam::Vector<double>}’ requested const vector energyFlux=p_rgh*U; ^ ./createFields.H:36:5: error: conflicting declaration ‘Foam::volVectorField energyFlux’ ( ^ ./createFields.H:32:14: note: previous declaration as ‘const vector energyFlux’ const vector energyFlux=p_rgh*U; ^ ./createFields.H:43:42: error: ‘Foam::volScalarField {aka class Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ has no member named ‘dimension’ dimensionedScalar("energyFlux",p_rgh.dimension()*U.dimension(),0.0) ^ ./createFields.H:43:56: error: ‘Foam::volVectorField {aka class Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>}’ has no member named ‘dimension’ dimensionedScalar("energyFlux",p_rgh.dimension()*U.dimension(),0.0) ^ In file included from interEnergyFluxFoam.C:67:0: createFields.H:32:30: error: conversion from ‘Foam::tmp<Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> >’ to non-scalar type ‘const vector {aka const Foam::Vector<double>}’ requested const vector energyFlux=p_rgh*U; ^ createFields.H:36:5: error: conflicting declaration ‘Foam::volVectorField energyFlux’ ( ^ createFields.H:32:14: note: previous declaration as ‘const vector energyFlux’ const vector energyFlux=p_rgh*U; ^ createFields.H:43:42: error: ‘Foam::volScalarField {aka class Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ has no member named ‘dimension’ dimensionedScalar("energyFlux",p_rgh.dimension()*U.dimension(),0.0) ^ createFields.H:43:56: error: ‘Foam::volVectorField {aka class Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>}’ has no member named ‘dimension’ dimensionedScalar("energyFlux",p_rgh.dimension()*U.dimension(),0.0) ^ /opt/openfoam4/wmake/rules/General/transform:8: recipe for target 'Make/linux64GccDPInt32Opt/interEnergyFluxFoam.o' failed make: *** [Make/linux64GccDPInt32Opt/interEnergyFluxFoam.o] Error 1 |
|
September 13, 2016, 13:15 |
|
#10 |
New Member
Evan
Join Date: May 2016
Posts: 23
Rep Power: 10 |
Okay I have managed to make it work.
Here is what I added to my createFields.H file: Code:
// Adding a new field: energyFlux Info<< "Reading field energyFlux\n" <<endl; volVectorField energyFlux ( IOobject ( "energyFlux", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), p_rgh*U ); Code:
{ energyFlux == p_rgh * U; } Code:
wclean wmake |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to calculate the flux of this term grad(alpha1)*alphaf*U? | keepfit | OpenFOAM Running, Solving & CFD | 2 | June 9, 2016 16:08 |
How to calculate the flux of this term grad(alpha1)*alphaf*U? | keepfit | OpenFOAM | 0 | June 6, 2016 11:42 |
Not able to calculate wall heat flux in cfd post | vikasy123 | FLUENT | 1 | November 21, 2015 01:44 |
Compare 2D axi-symmetric and 3D. Is OpenFOAM calculate the velocity wrong? | RalphS | OpenFOAM | 6 | November 13, 2010 21:51 |
Why FVM for high-Re flows? | Zhong Lei | Main CFD Forum | 23 | May 14, 1999 14:22 |