|
[Sponsors] |
foam extend and OpenFOAM reach different results |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 2, 2020, 09:26 |
foam extend and OpenFOAM reach different results
|
#1 |
New Member
Saman Naghavi
Join Date: Feb 2020
Posts: 8
Rep Power: 6 |
I simulated a two-phase VOF flow in a microchannel, using interFoam in OpenFOAM v1912, and it produced acceptable results. However, as my goal is the simulation of viscoelastic droplets, I have to use foam extend.
So, when I try to simulate the simpe two-phase Newtonian VOF flow again (as the first step of my project), this time using interFoam in foam extend 4.1, the result differs from my previous attempt with OpenFOAM v1912. You can see a screenshot of the results here for simulation in OpenFOAM and here for foam-extend. Can anybody suggest what is going wrong? The constantAlphaContactAngle boundary condition at walls with alpha = 180 is the same in both cases, but the result shows that they are probably not. It is my alpha1 initial condition: Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v1912 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "0"; object alpha1; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 0 0 0 0]; internalField uniform 0; boundaryField { inlet { type inletOutlet; value uniform 0; inletValue uniform 0; } outlet1 { type zeroGradient; } outlet2 { type zeroGradient; } walls { type constantAlphaContactAngle; theta0 180; limit gradient; value uniform 0; } frontAndBack { type empty; } } Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v1912 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object setFieldsDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // defaultFieldValues ( volScalarFieldValue alpha1 0.0 ); regions ( cylinderToCell { p1 (0.000120 0 -1); p2 (0.000120 0 1); radius 0.000010; fieldValues ( volScalarFieldValue alpha1 1 ); } ); // ************************************************************************* // |
|
May 8, 2020, 13:30 |
Still unsolved
|
#2 |
New Member
Saman Naghavi
Join Date: Feb 2020
Posts: 8
Rep Power: 6 |
I have not solved this problem yet. To ask my question simpler, why I do not get the same result for the constantAlphaContactAngle boundary condition (theta0 = 180) in foam-extend 4.1 as in OpenFOAM v1912.
You can see the difference between two below: OpenFOAM v1912 result foam-extend 4.1 result |
|
May 8, 2020, 13:36 |
|
#3 |
Senior Member
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13 |
Hi,
>> Can anybody suggest what is going wrong? - I think it is likely due to dissimilar implementation of one of the components of the tools you were using for your simulations. And it can be anything really since both OpenFOAM software may have slightly or largely different implementations for the same functionalities. - Is there any chance for you to compare one of your simulations with an existing benchmark, and proceed from that point? I'm sorry for not being of good help.
__________________
The OpenFOAM community is the biggest contributor to OpenFOAM: User guide/Wiki-1/Wiki-2/Code guide/Code Wiki/Journal Nilsson/Guerrero/Holzinger/Holzmann/Nagy/Santos/Nozaki/Jasak/Primer Governance Bugs/Features: OpenFOAM (ESI-OpenCFD-Trademark) Bugs/Features: FOAM-Extend (Wikki-FSB) Bugs: OpenFOAM.org How to create a MWE New: Forkable OpenFOAM mirror |
|
May 9, 2020, 02:45 |
|
#4 | |
New Member
Saman Naghavi
Join Date: Feb 2020
Posts: 8
Rep Power: 6 |
Quote:
>> - Is there any chance for you to compare one of your simulations with an existing benchmark, and proceed from that point? Many thanks for your consideration. I know that my result in OpenFOAM v1912 is physically correct, and my result in foam-extend 4.1 is not. However, I have to simulate my project in foam-extend, because I want to use a solver which is only implemented in foam-extend (viscoelasticInterFoam). Thus, I have to get acceptable results in foam-extend too. It seems there is a bug in interface properties of foam-extend for contact angle = 180, but I do not know how to solve it. |
||
May 15, 2020, 04:17 |
Update
|
#5 |
New Member
Saman Naghavi
Join Date: Feb 2020
Posts: 8
Rep Power: 6 |
I've found that foam-extend 4.1 does not use any limitation control on the gradient of alpha1 on the wall, and that's why I do not get desirable results.
I've tried to implement limit control by editing alphaContactAngleFvPatchScalarField.C and alphaContactAngleFvPatchScalarField.H, using these two links as my reference: https://cpp.openfoam.org/dev/src_2transportModels_2twoPhaseProperties_2alphaCon tactAngle_2alphaContactAngle_2alphaContactAngleFvP atchScalarField_8C_source.html https://cpp.openfoam.org/dev/src_2tr...8H_source.html and I obtained these two codes: Code:
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | foam-extend: Open Source CFD \\ / O peration | Version: 4.1 \\ / A nd | Web: http://www.foam-extend.org \\/ M anipulation | For copyright notice see file Copyright ------------------------------------------------------------------------------- License This file is part of foam-extend. foam-extend is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. foam-extend is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with foam-extend. If not, see <http://www.gnu.org/licenses/>. Class Foam::alphaContactAngleFvPatchScalarField Description Abstract base class for alphaContactAngle boundary conditions. Derived classes must implement the theta() fuction which returns the wall contact angle field. SourceFiles alphaContactAngleFvPatchScalarField.C \*---------------------------------------------------------------------------*/ #ifndef alphaContactAngleFvPatchScalarField_H #define alphaContactAngleFvPatchScalarField_H #include "fixedGradientFvPatchFields.H" #include "fvsPatchFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { /*---------------------------------------------------------------------------*\ Class alphaContactAngleFvPatch Declaration \*---------------------------------------------------------------------------*/ class alphaContactAngleFvPatchScalarField : public fixedGradientFvPatchScalarField { public: //- Runtime type information TypeName("alphaContactAngle"); //- Alpha limit options enum limitControls { lcNone, lcGradient, lcZeroGradient, lcAlpha }; static const NamedEnum<limitControls, 4> limitControlNames_; limitControls limit_; // Constructors //- Construct from patch and internal field alphaContactAngleFvPatchScalarField ( const fvPatch&, const DimensionedField<scalar, volMesh>& ); //- Construct from patch, internal field and dictionary alphaContactAngleFvPatchScalarField ( const fvPatch&, const DimensionedField<scalar, volMesh>&, const dictionary& ); //- Construct by mapping given alphaContactAngleFvPatchScalarField // onto a new patch alphaContactAngleFvPatchScalarField ( const alphaContactAngleFvPatchScalarField&, const fvPatch&, const DimensionedField<scalar, volMesh>&, const fvPatchFieldMapper& ); //- Construct as copy alphaContactAngleFvPatchScalarField ( const alphaContactAngleFvPatchScalarField& ); //- Construct as copy setting internal field reference alphaContactAngleFvPatchScalarField ( const alphaContactAngleFvPatchScalarField&, const DimensionedField<scalar, volMesh>& ); // Member functions //- Return the contact angle virtual tmp<scalarField> theta ( const fvPatchVectorField& Up, const fvsPatchVectorField& nHat ) const = 0; //- Evaluate the patch field virtual void evaluate ( const Pstream::commsTypes commsType=Pstream::commsTypes::blocking ); //- Write virtual void write(Ostream&) const; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif // ************************************************************************* // Code:
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | foam-extend: Open Source CFD \\ / O peration | Version: 4.1 \\ / A nd | Web: http://www.foam-extend.org \\/ M anipulation | For copyright notice see file Copyright ------------------------------------------------------------------------------- License This file is part of foam-extend. foam-extend is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. foam-extend is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with foam-extend. If not, see <http://www.gnu.org/licenses/>. \*---------------------------------------------------------------------------*/ #include "fvPatchFields.H" #include "alphaContactAngleFvPatchScalarField.H" #include "addToRunTimeSelectionTable.H" #include "volMesh.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(alphaContactAngleFvPatchScalarField, 0); template<> const char* Foam::NamedEnum < Foam::alphaContactAngleFvPatchScalarField::limitControls, 4 >::names[] = { "none", "gradient", "zeroGradient", "alpha" }; } const Foam::NamedEnum < Foam::alphaContactAngleFvPatchScalarField::limitControls, 4 > Foam::alphaContactAngleFvPatchScalarField::limitControlNames_; // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF ) : fixedGradientFvPatchScalarField(p, iF), limit_(lcZeroGradient) {} Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField ( const alphaContactAngleFvPatchScalarField& gcpsf, const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, const fvPatchFieldMapper& mapper ) : fixedGradientFvPatchScalarField(gcpsf, p, iF, mapper), limit_(gcpsf.limit_) {} Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, const dictionary& dict ) : fixedGradientFvPatchScalarField(p, iF), limit_(limitControlNames_.read(dict.lookup("limit"))) { if (dict.found("gradient")) { gradient() = scalarField("gradient", dict, p.size()); fixedGradientFvPatchScalarField::updateCoeffs(); fixedGradientFvPatchScalarField::evaluate(); } else { fvPatchField<scalar>::operator=(patchInternalField()); gradient() = 0.0; } } Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField ( const alphaContactAngleFvPatchScalarField& gcpsf ) : fixedGradientFvPatchScalarField(gcpsf), limit_(gcpsf.limit_) {} Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField ( const alphaContactAngleFvPatchScalarField& gcpsf, const DimensionedField<scalar, volMesh>& iF ) : fixedGradientFvPatchScalarField(gcpsf, iF), limit_(gcpsf.limit_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::alphaContactAngleFvPatchScalarField::evaluate ( const Pstream::commsTypes ) { if (limit_ == lcGradient) { gradient() = patch().deltaCoeffs() *( max(min ( *this + gradient()/patch().deltaCoeffs(), scalar(1)), scalar(0) ) - *this ); } else if (limit_ == lcZeroGradient) { gradient() = 0.0; } fixedGradientFvPatchScalarField::evaluate(); if (limit_ == lcAlpha) { scalarField::operator=(max(min(*this, scalar(1)), scalar(0))); } } void Foam::alphaContactAngleFvPatchScalarField::write ( Ostream& os ) const { fixedGradientFvPatchScalarField::write(os); writeEntry(os, "limit", limitControlNames_[limit_]); } // ************************************************************************* // Code:
alphaContactAngle/alphaContactAngle/alphaContactAngleFvPatchScalarField.C: In member function ‘virtual void Foam::alphaContactAngleFvPatchScalarField::write(Foam::Ostream&) const’: alphaContactAngle/alphaContactAngle/alphaContactAngleFvPatchScalarField.C:168:57: error: no matching function for call to ‘Foam::alphaContactAngleFvPatchScalarField::writeEntry(Foam::Ostream&, const char [6], const char*) const’ writeEntry(os, "limit", limitControlNames_[limit_]); In file included from /home/saman/foam/foam-extend-4.1/src/foam/lnInclude/labelField.H:39:0, from /home/saman/foam/foam-extend-4.1/src/foam/lnInclude/primitiveFields.H:37, from /home/saman/foam/foam-extend-4.1/src/foam/lnInclude/pointField.H:36, from /home/saman/foam/foam-extend-4.1/src/foam/lnInclude/edge.H:40, from /home/saman/foam/foam-extend-4.1/src/foam/lnInclude/edgeList.H:32, from /home/saman/foam/foam-extend-4.1/src/foam/lnInclude/PrimitivePatchTemplate.H:56, from /home/saman/foam/foam-extend-4.1/src/foam/lnInclude/primitivePatch.H:35, from /home/saman/foam/foam-extend-4.1/src/foam/lnInclude/polyPatch.H:51, from /home/saman/foam/foam-extend-4.1/src/finiteVolume/lnInclude/fvPatch.H:39, from /home/saman/foam/foam-extend-4.1/src/finiteVolume/lnInclude/fvPatchField.H:47, from /home/saman/foam/foam-extend-4.1/src/finiteVolume/lnInclude/fvPatchFields.H:29, from alphaContactAngle/alphaContactAngle/alphaContactAngleFvPatchScalarField.C:26: /home/saman/foam/foam-extend-4.1/src/foam/lnInclude/Field.H:320:14: note: candidate: void Foam::Field<Type>::writeEntry(const Foam::word&, Foam::Ostream&) const [with Type = double] void writeEntry(const word& keyword, Ostream& os) const; ^~~~~~~~~~ /home/saman/foam/foam-extend-4.1/src/foam/lnInclude/Field.H:320:14: note: candidate expects 2 arguments, 3 provided |
|
May 15, 2020, 16:35 |
|
#6 |
Senior Member
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13 |
Hi,
- Could you please clarify with which OpenFOAM variant do you do compilation: the Foundation or Foam-Extend? The error seems to be arising mixing the two. - Could you please replace writeEntry(os, "limit", limitControlNames_[limit_]) with os.writeEntry("limit", limitControlNames_[limit_]); Hope it helps.
__________________
The OpenFOAM community is the biggest contributor to OpenFOAM: User guide/Wiki-1/Wiki-2/Code guide/Code Wiki/Journal Nilsson/Guerrero/Holzinger/Holzmann/Nagy/Santos/Nozaki/Jasak/Primer Governance Bugs/Features: OpenFOAM (ESI-OpenCFD-Trademark) Bugs/Features: FOAM-Extend (Wikki-FSB) Bugs: OpenFOAM.org How to create a MWE New: Forkable OpenFOAM mirror |
|
May 16, 2020, 02:03 |
|
#7 |
New Member
Saman Naghavi
Join Date: Feb 2020
Posts: 8
Rep Power: 6 |
I do complitation with Foam-Extend. I replaced 'writeEntry(os, "limit", limitControlNames_[limit_])' with 'os.writeEntry("limit", limitControlNames_[limit_])' and unfortunately, I got this error:
Code:
alphaContactAngle/alphaContactAngle/alphaContactAngleFvPatchScalarField.C: In member function ‘virtual void Foam::alphaContactAngleFvPatchScalarField::write(Foam::Ostream&) const’: alphaContactAngle/alphaContactAngle/alphaContactAngleFvPatchScalarField.C:168:10: error: ‘class Foam::Ostream’ has no member named ‘writeEntry’; did you mean ‘write’? os.writeEntry("limit", limitControlNames_[limit_]); ^~~~~~~~~~ write |
|
May 18, 2020, 17:04 |
|
#8 |
Senior Member
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13 |
Hi,
- OK, then can you try: (limitControlNames_[limit_]).writeEntry("limit", os); (Sorry, I'm not perfectly educated in foam-extend).
__________________
The OpenFOAM community is the biggest contributor to OpenFOAM: User guide/Wiki-1/Wiki-2/Code guide/Code Wiki/Journal Nilsson/Guerrero/Holzinger/Holzmann/Nagy/Santos/Nozaki/Jasak/Primer Governance Bugs/Features: OpenFOAM (ESI-OpenCFD-Trademark) Bugs/Features: FOAM-Extend (Wikki-FSB) Bugs: OpenFOAM.org How to create a MWE New: Forkable OpenFOAM mirror |
|
June 10, 2020, 12:11 |
|
#9 |
New Member
Saman Naghavi
Join Date: Feb 2020
Posts: 8
Rep Power: 6 |
Sorry for my late reply. I really appreciate your consideration.
I used this command: "os.writeKeyword("limit") << limitControlNames_[limit_] << token::END_STATEMENT << nl;" and then the code compiled without any error. However, the results of my simulation did not change at all! I'm trying to figure out what else could have caused the problem. |
|
July 12, 2022, 21:34 |
|
#10 |
Member
Michael Sukham
Join Date: Mar 2020
Location: India
Posts: 80
Rep Power: 6 |
I am also studying the interface capturing in interFoam. The curvature calculation in foam-extend may be the problem. I am also trying to implement the interFoamSSF which in the forum indicates a better curvature calculation and hence the surface tension calculation. I will post after further studies.
|
|
Tags |
contact angle, foam extend 4.1, interfoam |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[blockMesh] blockMesh not working in Foam Extend 4.0 | siddhesh | OpenFOAM Meshing & Mesh Conversion | 3 | April 8, 2020 05:47 |
Difference between OpenFOAM and FOAM extend | ce73stargazer | OpenFOAM | 9 | November 10, 2019 10:00 |
[Other] mergeMeshes in OpenFOAM extend | nwpukaka | OpenFOAM Meshing & Mesh Conversion | 0 | April 19, 2016 23:09 |
cavity 3D in OpenFOAM Extend | alquimista | OpenFOAM Running, Solving & CFD | 7 | May 4, 2013 07:20 |
[Other] cgnsToFoam problems with "QUAD_4" cells | lentschi | OpenFOAM Meshing & Mesh Conversion | 1 | March 9, 2011 04:49 |