|
[Sponsors] |
March 22, 2020, 14:47 |
Calculating liquid volume in interFoam
|
#1 |
Senior Member
Josh McCraney
Join Date: Jun 2018
Posts: 220
Rep Power: 8 |
Hi FOAMers!
A tank partially filled with liquid has a hole at the bottom where liquid drains. In searching for how to do this, I found this thread. Specifically, post #13, which states to post this code Code:
dimensionedScalar totalLiquidVolume = sum(mesh.V()*gamma); Info << "Total Liquid Volume, Value: " << totalLiquidVolume.value() << ", Dimensions = " << totalLiquidVolume.dimensions() << endl; runTime.write(); and recompile your solver. The post also says to check it first on a single processor because you might need to change sum() with gSum(). Before I ask if this works, I don't know how to recompile my solver. Is it as simple as backing up a few folders to /applications and then executing ./Allwmake ? |
|
March 22, 2020, 18:08 |
|
#2 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 14 |
You can recompile interFoam by running "wclean" then "wmake" in the folder after editing. As for the code, alpha is used now (instead of gamma) in the VoF solvers. gSum is likely the safer option as it should work for single and multiple processor cases.
Caelan |
|
March 23, 2020, 13:05 |
|
#3 | |
Senior Member
Josh McCraney
Join Date: Jun 2018
Posts: 220
Rep Power: 8 |
Quote:
Code:
alphaSuSp.H correctPhi.H createFields.H initCorrectPhi.H interFoam.C interMixingFoam Make pEqn.H rhofs.H UEqn.H Any idea how to proceed? |
||
March 23, 2020, 13:08 |
|
#4 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 14 |
If "wclean" is not found, that suggests you have not sourced OpenFOAM correctly.
Caelan |
|
March 23, 2020, 13:17 |
|
#5 | |
Senior Member
Josh McCraney
Join Date: Jun 2018
Posts: 220
Rep Power: 8 |
Quote:
Is there a way to check that it's sourced correctly? How can I fix this issue? EDIT: so i was running as root, because without root "wclean" runs fine (I think, as there are no outputs in the terminal) but when I run "wmake" I get the following error: Code:
mkdir: cannot create directory ‘/opt/openfoam6/platforms/linux64GccDPInt32Opt/applications’: Permission denied /bin/sh: 1: cannot create /opt/openfoam6/platforms/linux64GccDPInt32Opt/applications/solvers/multiphase/interFoam/options: Directory nonexistent make: *** No rule to make target '/opt/openfoam6/platforms/linux64GccDPInt32Opt/applications/solvers/multiphase/interFoam/options'. Stop. /bin/sh: 1: cannot create /opt/openfoam6/platforms/linux64GccDPInt32Opt/applications/solvers/multiphase/interFoam/options: Directory nonexistent make: *** No rule to make target '/opt/openfoam6/platforms/linux64GccDPInt32Opt/applications/solvers/multiphase/interFoam/options', needed by 'all'. Stop. wmake error: file '/opt/openfoam6/platforms/linux64GccDPInt32Opt/applications/solvers/multiphase/interFoam/sourceFiles' could not be created in /opt/openfoam6/applications/solvers/multiphase/interFoam |
||
March 23, 2020, 13:35 |
|
#6 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 14 |
I've never installed openfoam in /opt and not sure how that impacts everything (and also not sure which flavor of openfoam you're using nor how you installed it) but not recognizing a compilation command is fishy. Since you're having trouble with that why not just post process with e.g. paraview to compute the quantity you're after? You would just need to find a way (e.g. with a function object) to write cell volumes in a way paraview could read them.
Caelan |
|
March 23, 2020, 13:44 |
|
#7 | |
Senior Member
Josh McCraney
Join Date: Jun 2018
Posts: 220
Rep Power: 8 |
Quote:
|
||
March 24, 2020, 11:09 |
|
#8 |
Senior Member
Josh McCraney
Join Date: Jun 2018
Posts: 220
Rep Power: 8 |
Hi Caelan
Someone was able to help we run the wmake command. However, when I run it I get the error Code:
Making dependency list for source file interFoam.C g++ -std=c++11 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -DNoRepository -ftemplate-depth-100 -I../VoF -I/opt/openfoam6/src/transportModels/twoPhaseMixture/lnInclude -I/opt/openfoam6/src/transportModels -I/opt/openfoam6/src/transportModels/incompressible/lnInclude -I/opt/openfoam6/src/transportModels/interfaceProperties/lnInclude -I/opt/openfoam6/src/TurbulenceModels/turbulenceModels/lnInclude -I/opt/openfoam6/src/TurbulenceModels/incompressible/lnInclude -I/opt/openfoam6/src/transportModels/immiscibleIncompressibleTwoPhaseMixture/lnInclude -I/opt/openfoam6/src/finiteVolume/lnInclude -I/opt/openfoam6/src/dynamicFvMesh/lnInclude -I/opt/openfoam6/src/meshTools/lnInclude -I/opt/openfoam6/src/sampling/lnInclude -IlnInclude -I. -I/opt/openfoam6/src/OpenFOAM/lnInclude -I/opt/openfoam6/src/OSspecific/POSIX/lnInclude -fPIC -c interFoam.C -o /opt/openfoam6/platforms/linux64GccDPInt32Opt/applications/solvers/multiphase/interFoam/interFoam.o interFoam.C: In function ‘int main(int, char**)’: interFoam.C:157:54: error: ‘alpha’ was not declared in this scope dimensionedScalar totalLiquidVolume = gsum(mesh.V()*alpha); ^~~~~ interFoam.C:157:54: note: suggested alternative: In file included from /opt/openfoam6/src/OpenFOAM/lnInclude/constants.H:46:0, from /opt/openfoam6/src/finiteVolume/lnInclude/fvCFD.H:23, from interFoam.C:35: /opt/openfoam6/src/OpenFOAM/lnInclude/atomicConstants.H:52:36: note: ‘Foam::constant::atomic::alpha’ extern const dimensionedScalar alpha; ^~~~~ interFoam.C:157:40: error: ‘gsum’ was not declared in this scope dimensionedScalar totalLiquidVolume = gsum(mesh.V()*alpha); ^~~~ interFoam.C:157:40: note: suggested alternative: ‘enum’ dimensionedScalar totalLiquidVolume = gsum(mesh.V()*alpha); ^~~~ enum /opt/openfoam6/wmake/rules/General/transform:25: recipe for target '/opt/openfoam6/platforms/linux64GccDPInt32Opt/applications/solvers/multiphase/interFoam/interFoam.o' failed make: *** [/opt/openfoam6/platforms/linux64GccDPInt32Opt/applications/solvers/multiphase/interFoam/interFoam.o] Error 1 Code:
dimensionedScalar totalLiquidVolume = gsum(mesh.V()*alpha); Info << "Total Liquid Volume, Value: "<< totalLiquidVolume.value() << ", Dimensions = " << totalLiquidVolume.dimensions() << endl; |
|
March 24, 2020, 11:19 |
|
#9 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 14 |
Newer openfoam versions use alpha to represent volume fraction; older ones may have used gamma. I do not know what version of openfoam you are using, but you can check your source code (probably createFields) to see. As for the second error, it is gSum (not gsum).
Caelan |
|
March 24, 2020, 11:32 |
|
#10 | |
Senior Member
Josh McCraney
Join Date: Jun 2018
Posts: 220
Rep Power: 8 |
Quote:
|
||
March 24, 2020, 11:50 |
|
#11 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 14 |
In that case try alpha1 -- it will either be what you're looking for, or the volume of "not" fluid (and you'll thus want alpha2).
Caelan |
|
March 24, 2020, 11:51 |
|
#12 |
Senior Member
Josh McCraney
Join Date: Jun 2018
Posts: 220
Rep Power: 8 |
I have liquid and air: are you saying alpha1 is the liquid, and alpha2 is the air? If so, not that I doubt you, but how can I tell which is which?
|
|
March 24, 2020, 11:56 |
|
#13 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 14 |
I don't know how you set up your simulation, so I can't tell you. But if you compare your computed liquid volume to what you set for the simulation (e.g. initially, with setFields) you should be able to figure it out.
Caelan |
|
March 24, 2020, 12:26 |
|
#14 |
Senior Member
Josh McCraney
Join Date: Jun 2018
Posts: 220
Rep Power: 8 |
I changed alpha to alpha1 but now I get the error
Code:
interFoam.C:157:60: error: no matching function for call to ‘gSum(Foam::tmp<Foam::DimensionedField<double, Foam::volMesh> >)’ dimensionedScalar totalLiquidVolume = gSum(mesh.V()*alpha1); Code:
dimensionedScalar totalLiquidVolume = gSum(mesh.V()*alpha1); Code:
Making dependency list for source file interFoam.C g++ -std=c++11 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -DNoRepository -ftemplate-depth-100 -I../VoF -I/opt/openfoam6/src/transportModels/twoPhaseMixture/lnInclude -I/opt/openfoam6/src/transportModels -I/opt/openfoam6/src/transportModels/incompressible/lnInclude -I/opt/openfoam6/src/transportModels/interfaceProperties/lnInclude -I/opt/openfoam6/src/TurbulenceModels/turbulenceModels/lnInclude -I/opt/openfoam6/src/TurbulenceModels/incompressible/lnInclude -I/opt/openfoam6/src/transportModels/immiscibleIncompressibleTwoPhaseMixture/lnInclude -I/opt/openfoam6/src/finiteVolume/lnInclude -I/opt/openfoam6/src/dynamicFvMesh/lnInclude -I/opt/openfoam6/src/meshTools/lnInclude -I/opt/openfoam6/src/sampling/lnInclude -IlnInclude -I. -I/opt/openfoam6/src/OpenFOAM/lnInclude -I/opt/openfoam6/src/OSspecific/POSIX/lnInclude -fPIC -c interFoam.C -o /opt/openfoam6/platforms/linux64GccDPInt32Opt/applications/solvers/multiphase/interFoam/interFoam.o interFoam.C: In function ‘int main(int, char**)’: interFoam.C:157:60: error: no matching function for call to ‘gSum(Foam::tmp<Foam::DimensionedField<double, Foam::volMesh> >)’ dimensionedScalar totalLiquidVolume = gSum(mesh.V()*alpha1); ^ In file included from /opt/openfoam6/src/OpenFOAM/lnInclude/Field.C:877:0, from /opt/openfoam6/src/OpenFOAM/lnInclude/Field.H:408, from /opt/openfoam6/src/OpenFOAM/lnInclude/scalarField.H:38, from /opt/openfoam6/src/OpenFOAM/lnInclude/dimensionSet.H:46, from /opt/openfoam6/src/OpenFOAM/lnInclude/dimensionedType.H:40, from /opt/openfoam6/src/OpenFOAM/lnInclude/dimensionedScalar.H:38, from /opt/openfoam6/src/OpenFOAM/lnInclude/TimeState.H:38, from /opt/openfoam6/src/OpenFOAM/lnInclude/Time.H:47, from /opt/openfoam6/src/finiteVolume/lnInclude/fvCFD.H:6, from interFoam.C:35: /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFunctions.C:543:24: note: candidate: template<class Type> Type Foam::gSum(const Foam::UList<T>&, Foam::label) G_UNARY_FUNCTION(Type, gSum, sum, sum) ^ /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFunctions.C:533:12: note: in definition of macro ‘G_UNARY_FUNCTION’ ReturnType gFunc(const UList<Type>& f, const label comm) \ ^~~~~ /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFunctions.C:543:24: note: template argument deduction/substitution failed: G_UNARY_FUNCTION(Type, gSum, sum, sum) ^ /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFunctions.C:533:12: note: in definition of macro ‘G_UNARY_FUNCTION’ ReturnType gFunc(const UList<Type>& f, const label comm) \ ^~~~~ interFoam.C:157:60: note: ‘Foam::tmp<Foam::DimensionedField<double, Foam::volMesh> >’ is not derived from ‘const Foam::UList<T>’ dimensionedScalar totalLiquidVolume = gSum(mesh.V()*alpha1); ^ In file included from /opt/openfoam6/src/OpenFOAM/lnInclude/Field.C:877:0, from /opt/openfoam6/src/OpenFOAM/lnInclude/Field.H:408, from /opt/openfoam6/src/OpenFOAM/lnInclude/scalarField.H:38, from /opt/openfoam6/src/OpenFOAM/lnInclude/dimensionSet.H:46, from /opt/openfoam6/src/OpenFOAM/lnInclude/dimensionedType.H:40, from /opt/openfoam6/src/OpenFOAM/lnInclude/dimensionedScalar.H:38, from /opt/openfoam6/src/OpenFOAM/lnInclude/TimeState.H:38, from /opt/openfoam6/src/OpenFOAM/lnInclude/Time.H:47, from /opt/openfoam6/src/finiteVolume/lnInclude/fvCFD.H:6, from interFoam.C:35: /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFunctions.C:543:24: note: candidate: template<class Type> Type Foam::gSum(const Foam::tmp<Foam::Field<Type> >&) G_UNARY_FUNCTION(Type, gSum, sum, sum) ^ /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFunctions.C:303:12: note: in definition of macro ‘TMP_UNARY_FUNCTION’ ReturnType Func(const tmp<Field<Type>>& tf1) \ ^~~~ /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFunctions.C:543:1: note: in expansion of macro ‘G_UNARY_FUNCTION’ G_UNARY_FUNCTION(Type, gSum, sum, sum) ^~~~~~~~~~~~~~~~ /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFunctions.C:543:24: note: template argument deduction/substitution failed: G_UNARY_FUNCTION(Type, gSum, sum, sum) ^ /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFunctions.C:303:12: note: in definition of macro ‘TMP_UNARY_FUNCTION’ ReturnType Func(const tmp<Field<Type>>& tf1) \ ^~~~ /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFunctions.C:543:1: note: in expansion of macro ‘G_UNARY_FUNCTION’ G_UNARY_FUNCTION(Type, gSum, sum, sum) ^~~~~~~~~~~~~~~~ interFoam.C:157:60: note: mismatched types ‘Foam::Field<Type>’ and ‘Foam::DimensionedField<double, Foam::volMesh>’ dimensionedScalar totalLiquidVolume = gSum(mesh.V()*alpha1); ^ In file included from /opt/openfoam6/src/OpenFOAM/lnInclude/FieldField.C:390:0, from /opt/openfoam6/src/OpenFOAM/lnInclude/FieldField.H:198, from /opt/openfoam6/src/OpenFOAM/lnInclude/GeometricField.H:45, from /opt/openfoam6/src/OpenFOAM/lnInclude/GeometricScalarField.H:38, from /opt/openfoam6/src/OpenFOAM/lnInclude/GeometricFields.H:34, from /opt/openfoam6/src/finiteVolume/lnInclude/volFields.H:37, from /opt/openfoam6/src/finiteVolume/lnInclude/surfaceInterpolationScheme.C:27, from /opt/openfoam6/src/finiteVolume/lnInclude/surfaceInterpolationScheme.H:307, from /opt/openfoam6/src/finiteVolume/lnInclude/surfaceInterpolate.H:41, from /opt/openfoam6/src/finiteVolume/lnInclude/fvc.H:39, from /opt/openfoam6/src/finiteVolume/lnInclude/fvCFD.H:8, from interFoam.C:35: /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:559:24: note: candidate: template<template<class> class Field, class Type> Type Foam::gSum(const Foam::FieldField<Field, Type>&) G_UNARY_FUNCTION(Type, gSum, sum, sum) ^ /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:549:12: note: in definition of macro ‘G_UNARY_FUNCTION’ returnType gFunc(const FieldField<Field, Type>& f) \ ^~~~~ /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:559:24: note: template argument deduction/substitution failed: G_UNARY_FUNCTION(Type, gSum, sum, sum) ^ /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:549:12: note: in definition of macro ‘G_UNARY_FUNCTION’ returnType gFunc(const FieldField<Field, Type>& f) \ ^~~~~ interFoam.C:157:60: note: ‘Foam::tmp<Foam::DimensionedField<double, Foam::volMesh> >’ is not derived from ‘const Foam::FieldField<Field, Type>’ dimensionedScalar totalLiquidVolume = gSum(mesh.V()*alpha1); ^ In file included from /opt/openfoam6/src/OpenFOAM/lnInclude/FieldField.C:390:0, from /opt/openfoam6/src/OpenFOAM/lnInclude/FieldField.H:198, from /opt/openfoam6/src/OpenFOAM/lnInclude/GeometricField.H:45, from /opt/openfoam6/src/OpenFOAM/lnInclude/GeometricScalarField.H:38, from /opt/openfoam6/src/OpenFOAM/lnInclude/GeometricFields.H:34, from /opt/openfoam6/src/finiteVolume/lnInclude/volFields.H:37, from /opt/openfoam6/src/finiteVolume/lnInclude/surfaceInterpolationScheme.C:27, from /opt/openfoam6/src/finiteVolume/lnInclude/surfaceInterpolationScheme.H:307, from /opt/openfoam6/src/finiteVolume/lnInclude/surfaceInterpolate.H:41, from /opt/openfoam6/src/finiteVolume/lnInclude/fvc.H:39, from /opt/openfoam6/src/finiteVolume/lnInclude/fvCFD.H:8, from interFoam.C:35: /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:559:24: note: candidate: template<template<class> class Field, class Type> Type Foam::gSum(const Foam::tmp<Foam::FieldField<Field, Type> >&) G_UNARY_FUNCTION(Type, gSum, sum, sum) ^ /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:400:12: note: in definition of macro ‘TMP_UNARY_FUNCTION’ returnType func(const tmp<FieldField<Field, Type>>& tf1) \ ^~~~ /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:559:1: note: in expansion of macro ‘G_UNARY_FUNCTION’ G_UNARY_FUNCTION(Type, gSum, sum, sum) ^~~~~~~~~~~~~~~~ /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:559:24: note: template argument deduction/substitution failed: G_UNARY_FUNCTION(Type, gSum, sum, sum) ^ /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:400:12: note: in definition of macro ‘TMP_UNARY_FUNCTION’ returnType func(const tmp<FieldField<Field, Type>>& tf1) \ ^~~~ /opt/openfoam6/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:559:1: note: in expansion of macro ‘G_UNARY_FUNCTION’ G_UNARY_FUNCTION(Type, gSum, sum, sum) ^~~~~~~~~~~~~~~~ interFoam.C:157:60: note: mismatched types ‘Foam::FieldField<Field, Type>’ and ‘Foam::DimensionedField<double, Foam::volMesh>’ dimensionedScalar totalLiquidVolume = gSum(mesh.V()*alpha1); ^ /opt/openfoam6/wmake/rules/General/transform:25: recipe for target '/opt/openfoam6/platforms/linux64GccDPInt32Opt/applications/solvers/multiphase/interFoam/interFoam.o' failed make: *** [/opt/openfoam6/platforms/linux64GccDPInt32Opt/applications/solvers/multiphase/interFoam/interFoam.o] Error 1 |
|
March 24, 2020, 12:38 |
|
#15 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 14 |
The product inside gSum() is clearly not going to work. I vaguely recall using something like mesh.V().value() before. But using gSum may take some more work.... fvc::volumeIntegrate is another option.
Caelan |
|
March 24, 2020, 14:16 |
|
#16 | |
Senior Member
Josh McCraney
Join Date: Jun 2018
Posts: 220
Rep Power: 8 |
Quote:
Again, thanks for your time Caelan! |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to use "translation" in solidBodyMotionFunction in OpenFOAM | rupesh_w | OpenFOAM Running, Solving & CFD | 5 | August 16, 2016 04:27 |
multiphase turbulance case floating error | harsha_kulkarni | OpenFOAM Running, Solving & CFD | 3 | February 18, 2016 05:06 |
How to calculate liquid volume as the interface moves for interFoam Solver | asaha | OpenFOAM Running, Solving & CFD | 25 | October 21, 2009 04:34 |
Calculating volume of Phase | Pavan | FLUENT | 2 | March 5, 2008 10:04 |
fluent add additional zones for the mesh file | SSL | FLUENT | 2 | January 26, 2008 11:55 |