BUGFIX: Seg-fault in multiphaseInterFoam. Author: Henrik Rusche. Merge: Hrvoje Jasak

This commit is contained in:
Henrik Rusche 2015-06-02 11:09:16 +02:00
commit 7b2e4e547a
9 changed files with 85 additions and 65 deletions

View file

@ -0,0 +1,8 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
set -x
wmakeLnInclude .
wmake
# ----------------------------------------------------------------- end-of-file

View file

@ -1,5 +1,5 @@
multiphaseMixture/phase/phase.C multiphaseMixture/phase/phase.C
multiphaseMixture/alphaContactAngle/alphaContactAngleFvPatchScalarField.C multiphaseMixture/multiphaseAlphaContactAngle/multiphaseAlphaContactAngleFvPatchScalarField.C
multiphaseMixture/multiphaseMixture.C multiphaseMixture/multiphaseMixture.C
multiphaseInterFoam.C multiphaseInterFoam.C

View file

@ -1,8 +1,5 @@
EXE_INC = \ EXE_INC = \
-I../interFoam \ -I../interFoam \
-ImultiphaseMixture \
-ImultiphaseMixture/phase \
-ImultiphaseMixture/alphaContactAngle \
-I$(LIB_SRC)/transportModels \ -I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/lnInclude \ -I$(LIB_SRC)/transportModels/incompressible/lnInclude \
-I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \ -I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \

View file

@ -1,9 +1,9 @@
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
========= | ========= |
\\ / F ield | foam-extend: Open Source CFD \\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2 \\ / O peration |
\\ / A nd | Web: http://www.foam-extend.org \\ / A nd | For copyright notice see file Copyright
\\/ M anipulation | For copyright notice see file Copyright \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of foam-extend. This file is part of foam-extend.
@ -23,16 +23,14 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "alphaContactAngleFvPatchScalarField.H" #include "multiphaseAlphaContactAngleFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H" #include "fvPatchFieldMapper.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam Foam::multiphaseAlphaContactAngleFvPatchScalarField::
{ interfaceThetaProps::interfaceThetaProps
alphaContactAngleFvPatchScalarField::interfaceThetaProps::interfaceThetaProps
( (
Istream& is Istream& is
) )
@ -44,10 +42,10 @@ alphaContactAngleFvPatchScalarField::interfaceThetaProps::interfaceThetaProps
{} {}
Istream& operator>> Foam::Istream& Foam::operator>>
( (
Istream& is, Istream& is,
alphaContactAngleFvPatchScalarField::interfaceThetaProps& tp multiphaseAlphaContactAngleFvPatchScalarField::interfaceThetaProps& tp
) )
{ {
is >> tp.theta0_ >> tp.uTheta_ >> tp.thetaA_ >> tp.thetaR_; is >> tp.theta0_ >> tp.uTheta_ >> tp.thetaA_ >> tp.thetaR_;
@ -55,10 +53,11 @@ Istream& operator>>
} }
Ostream& operator<< Foam::Ostream& Foam::operator<<
( (
Ostream& os, Ostream& os,
const alphaContactAngleFvPatchScalarField::interfaceThetaProps& tp const
multiphaseAlphaContactAngleFvPatchScalarField::interfaceThetaProps& tp
) )
{ {
os << tp.theta0_ << token::SPACE os << tp.theta0_ << token::SPACE
@ -72,7 +71,8 @@ Ostream& operator<<
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField Foam::multiphaseAlphaContactAngleFvPatchScalarField::
multiphaseAlphaContactAngleFvPatchScalarField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF const DimensionedField<scalar, volMesh>& iF
@ -82,9 +82,10 @@ alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
{} {}
alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField Foam::multiphaseAlphaContactAngleFvPatchScalarField::
multiphaseAlphaContactAngleFvPatchScalarField
( (
const alphaContactAngleFvPatchScalarField& gcpsf, const multiphaseAlphaContactAngleFvPatchScalarField& gcpsf,
const fvPatch& p, const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF, const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper const fvPatchFieldMapper& mapper
@ -95,7 +96,8 @@ alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
{} {}
alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField Foam::multiphaseAlphaContactAngleFvPatchScalarField::
multiphaseAlphaContactAngleFvPatchScalarField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF, const DimensionedField<scalar, volMesh>& iF,
@ -109,9 +111,10 @@ alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
} }
alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField Foam::multiphaseAlphaContactAngleFvPatchScalarField::
multiphaseAlphaContactAngleFvPatchScalarField
( (
const alphaContactAngleFvPatchScalarField& gcpsf, const multiphaseAlphaContactAngleFvPatchScalarField& gcpsf,
const DimensionedField<scalar, volMesh>& iF const DimensionedField<scalar, volMesh>& iF
) )
: :
@ -122,7 +125,11 @@ alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void alphaContactAngleFvPatchScalarField::write(Ostream& os) const void
Foam::multiphaseAlphaContactAngleFvPatchScalarField::write
(
Ostream& os
) const
{ {
fvPatchScalarField::write(os); fvPatchScalarField::write(os);
os.writeKeyword("thetaProperties") os.writeKeyword("thetaProperties")
@ -133,9 +140,14 @@ void alphaContactAngleFvPatchScalarField::write(Ostream& os) const
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchScalarField, alphaContactAngleFvPatchScalarField); namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // makePatchTypeField
(
fvPatchScalarField,
multiphaseAlphaContactAngleFvPatchScalarField
);
} // End namespace Foam } // End namespace Foam

View file

@ -1,9 +1,9 @@
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
========= | ========= |
\\ / F ield | foam-extend: Open Source CFD \\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2 \\ / O peration |
\\ / A nd | Web: http://www.foam-extend.org \\ / A nd | For copyright notice see file Copyright
\\/ M anipulation | For copyright notice see file Copyright \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of foam-extend. This file is part of foam-extend.
@ -22,19 +22,19 @@ License
along with foam-extend. If not, see <http://www.gnu.org/licenses/>. along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::alphaContactAngleFvPatchScalarField Foam::multiphaseAlphaContactAngleFvPatchScalarField
Description Description
Contact-angle boundary condition for multi-phase interface-capturing Contact-angle boundary condition for multi-phase interface-capturing
simulations. Used in conjuction with multiphaseMixture. simulations. Used in conjuction with multiphaseMixture.
SourceFiles SourceFiles
alphaContactAngleFvPatchScalarField.C multiphaseAlphaContactAngleFvPatchScalarField.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef alphaContactAngleFvPatchScalarField_H #ifndef multiphaseAlphaContactAngleFvPatchScalarField_H
#define alphaContactAngleFvPatchScalarField_H #define multiphaseAlphaContactAngleFvPatchScalarField_H
#include "zeroGradientFvPatchFields.H" #include "zeroGradientFvPatchFields.H"
#include "multiphaseMixture.H" #include "multiphaseMixture.H"
@ -45,10 +45,10 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class alphaContactAngleFvPatch Declaration Class multiphaseAlphaContactAngleFvPatch Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class alphaContactAngleFvPatchScalarField class multiphaseAlphaContactAngleFvPatchScalarField
: :
public zeroGradientFvPatchScalarField public zeroGradientFvPatchScalarField
{ {
@ -132,31 +132,32 @@ private:
public: public:
//- Runtime type information //- Runtime type information
TypeName("alphaContactAngle"); TypeName("multiphaseAlphaContactAngle");
// Constructors // Constructors
//- Construct from patch and internal field //- Construct from patch and internal field
alphaContactAngleFvPatchScalarField multiphaseAlphaContactAngleFvPatchScalarField
( (
const fvPatch&, const fvPatch&,
const DimensionedField<scalar, volMesh>& const DimensionedField<scalar, volMesh>&
); );
//- Construct from patch, internal field and dictionary //- Construct from patch, internal field and dictionary
alphaContactAngleFvPatchScalarField multiphaseAlphaContactAngleFvPatchScalarField
( (
const fvPatch&, const fvPatch&,
const DimensionedField<scalar, volMesh>&, const DimensionedField<scalar, volMesh>&,
const dictionary& const dictionary&
); );
//- Construct by mapping given alphaContactAngleFvPatchScalarField //- Construct by mapping given
// multiphaseAlphaContactAngleFvPatchScalarField
// onto a new patch // onto a new patch
alphaContactAngleFvPatchScalarField multiphaseAlphaContactAngleFvPatchScalarField
( (
const alphaContactAngleFvPatchScalarField&, const multiphaseAlphaContactAngleFvPatchScalarField&,
const fvPatch&, const fvPatch&,
const DimensionedField<scalar, volMesh>&, const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper& const fvPatchFieldMapper&
@ -167,14 +168,14 @@ public:
{ {
return tmp<fvPatchScalarField> return tmp<fvPatchScalarField>
( (
new alphaContactAngleFvPatchScalarField(*this) new multiphaseAlphaContactAngleFvPatchScalarField(*this)
); );
} }
//- Construct as copy setting internal field reference //- Construct as copy setting internal field reference
alphaContactAngleFvPatchScalarField multiphaseAlphaContactAngleFvPatchScalarField
( (
const alphaContactAngleFvPatchScalarField&, const multiphaseAlphaContactAngleFvPatchScalarField&,
const DimensionedField<scalar, volMesh>& const DimensionedField<scalar, volMesh>&
); );
@ -186,7 +187,7 @@ public:
{ {
return tmp<fvPatchScalarField> return tmp<fvPatchScalarField>
( (
new alphaContactAngleFvPatchScalarField(*this, iF) new multiphaseAlphaContactAngleFvPatchScalarField(*this, iF)
); );
} }

View file

@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "multiphaseMixture.H" #include "multiphaseMixture.H"
#include "alphaContactAngleFvPatchScalarField.H" #include "multiphaseAlphaContactAngleFvPatchScalarField.H"
#include "Time.H" #include "Time.H"
#include "subCycle.H" #include "subCycle.H"
#include "fvCFD.H" #include "fvCFD.H"
@ -361,16 +361,20 @@ void Foam::multiphaseMixture::correctContactAngle
surfaceVectorField::GeometricBoundaryField& nHatb surfaceVectorField::GeometricBoundaryField& nHatb
) const ) const
{ {
const volScalarField::GeometricBoundaryField& gbf = refPhase_.boundaryField(); const volScalarField::GeometricBoundaryField& gbf =
refPhase_.boundaryField();
const fvBoundaryMesh& boundary = mesh_.boundary(); const fvBoundaryMesh& boundary = mesh_.boundary();
forAll(boundary, patchi) forAll(boundary, patchi)
{ {
if (typeid(gbf[patchi]) == typeid(alphaContactAngleFvPatchScalarField)) if (isA<multiphaseAlphaContactAngleFvPatchScalarField>(gbf[patchi]))
{ {
const alphaContactAngleFvPatchScalarField& acap = const multiphaseAlphaContactAngleFvPatchScalarField& acap =
refCast<const alphaContactAngleFvPatchScalarField>(gbf[patchi]); refCast<const multiphaseAlphaContactAngleFvPatchScalarField>
(
gbf[patchi]
);
vectorField& nHatPatch = nHatb[patchi]; vectorField& nHatPatch = nHatb[patchi];
@ -378,7 +382,7 @@ void Foam::multiphaseMixture::correctContactAngle
mesh_.Sf().boundaryField()[patchi] mesh_.Sf().boundaryField()[patchi]
/mesh_.magSf().boundaryField()[patchi]; /mesh_.magSf().boundaryField()[patchi];
alphaContactAngleFvPatchScalarField::thetaPropsTable:: multiphaseAlphaContactAngleFvPatchScalarField::thetaPropsTable::
const_iterator tp = const_iterator tp =
acap.thetaProps().find(interfacePair(alpha1, alpha2)); acap.thetaProps().find(interfacePair(alpha1, alpha2));
@ -389,7 +393,8 @@ void Foam::multiphaseMixture::correctContactAngle
"multiphaseMixture::correctContactAngle" "multiphaseMixture::correctContactAngle"
"(const phase& alpha1, const phase& alpha2, " "(const phase& alpha1, const phase& alpha2, "
"fvPatchVectorFieldField& nHatb) const" "fvPatchVectorFieldField& nHatb) const"
) << "Cannot find interface " << interfacePair(alpha1, alpha2) ) << "Cannot find interface "
<< interfacePair(alpha1, alpha2)
<< "\n in table of theta properties for patch " << "\n in table of theta properties for patch "
<< acap.patch().name() << acap.patch().name()
<< exit(FatalError); << exit(FatalError);
@ -408,7 +413,8 @@ void Foam::multiphaseMixture::correctContactAngle
scalar thetaA = convertToRad*tp().thetaA(matched); scalar thetaA = convertToRad*tp().thetaA(matched);
scalar thetaR = convertToRad*tp().thetaR(matched); scalar thetaR = convertToRad*tp().thetaR(matched);
// Calculated the component of the velocity parallel to the wall // Calculated the component of the velocity parallel
// to the wall
vectorField Uwall = vectorField Uwall =
U_.boundaryField()[patchi].patchInternalField() U_.boundaryField()[patchi].patchInternalField()
- U_.boundaryField()[patchi]; - U_.boundaryField()[patchi];

View file

@ -15,19 +15,14 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Select the type of dynamicFvMesh, and load custom library
dynamicFvMesh dynamicMotionSolverFvMesh; dynamicFvMesh dynamicMotionSolverFvMesh;
solver mesquiteMotionSolver; solver mesquiteMotionSolver;
//solver laplace;
//diffusivity uniform 1.0;
//diffusivity quadratic;
//distancePatches (topWall);
//frozenDiffusion off;
mesquiteOptions mesquiteOptions
{ {
standardCellTypes yes; standardCellTypes yes;
// Optimization metric // Optimization metric
// optMetric AspectRatioGamma; // optMetric AspectRatioGamma;
optMetric optMetric
@ -45,7 +40,8 @@ mesquiteOptions
optAlgorithm FeasibleNewton; optAlgorithm FeasibleNewton;
// optAlgorithm ConjugateGradient; // optAlgorithm ConjugateGradient;
// Termination criteria sub-dictionary (takes default values if not specified) // Termination criteria sub-dictionary
// (takes default values if not specified)
// Specifying an empty sub-dictionary terminates with available options // Specifying an empty sub-dictionary terminates with available options
tcInner tcInner
{ {

View file

@ -2294,19 +2294,19 @@ boundaryField
{ {
leftWall leftWall
{ {
type alphaContactAngle; type multiphaseAlphaContactAngle;
thetaProperties ( ( water air ) 90 0 0 0 ( oil air ) 90 0 0 0 ( mercury air ) 90 0 0 0 ( water oil ) 90 0 0 0 ( water mercury ) 90 0 0 0 ( oil mercury ) 90 0 0 0 ); thetaProperties ( ( water air ) 90 0 0 0 ( oil air ) 90 0 0 0 ( mercury air ) 90 0 0 0 ( water oil ) 90 0 0 0 ( water mercury ) 90 0 0 0 ( oil mercury ) 90 0 0 0 );
value uniform 0; value uniform 0;
} }
rightWall rightWall
{ {
type alphaContactAngle; type multiphaseAlphaContactAngle;
thetaProperties ( ( water air ) 90 0 0 0 ( oil air ) 90 0 0 0 ( mercury air ) 90 0 0 0 ( water oil ) 90 0 0 0 ( water mercury ) 90 0 0 0 ( oil mercury ) 90 0 0 0 ); thetaProperties ( ( water air ) 90 0 0 0 ( oil air ) 90 0 0 0 ( mercury air ) 90 0 0 0 ( water oil ) 90 0 0 0 ( water mercury ) 90 0 0 0 ( oil mercury ) 90 0 0 0 );
value uniform 0; value uniform 0;
} }
lowerWall lowerWall
{ {
type alphaContactAngle; type multiphaseAlphaContactAngle;
thetaProperties ( ( water air ) 90 0 0 0 ( oil air ) 90 0 0 0 ( mercury air ) 90 0 0 0 ( water oil ) 90 0 0 0 ( water mercury ) 90 0 0 0 ( oil mercury ) 90 0 0 0 ); thetaProperties ( ( water air ) 90 0 0 0 ( oil air ) 90 0 0 0 ( mercury air ) 90 0 0 0 ( water oil ) 90 0 0 0 ( water mercury ) 90 0 0 0 ( oil mercury ) 90 0 0 0 );
value uniform 0; value uniform 0;
} }

View file

@ -34226,19 +34226,19 @@ boundaryField
{ {
leftWall leftWall
{ {
type alphaContactAngle; type multiphaseAlphaContactAngle;
thetaProperties ( ( water air ) 90 0 0 0 ( oil air ) 90 0 0 0 ( mercury air ) 90 0 0 0 ( water oil ) 90 0 0 0 ( water mercury ) 90 0 0 0 ( oil mercury ) 90 0 0 0 ); thetaProperties ( ( water air ) 90 0 0 0 ( oil air ) 90 0 0 0 ( mercury air ) 90 0 0 0 ( water oil ) 90 0 0 0 ( water mercury ) 90 0 0 0 ( oil mercury ) 90 0 0 0 );
value uniform 0; value uniform 0;
} }
rightWall rightWall
{ {
type alphaContactAngle; type multiphaseAlphaContactAngle;
thetaProperties ( ( water air ) 90 0 0 0 ( oil air ) 90 0 0 0 ( mercury air ) 90 0 0 0 ( water oil ) 90 0 0 0 ( water mercury ) 90 0 0 0 ( oil mercury ) 90 0 0 0 ); thetaProperties ( ( water air ) 90 0 0 0 ( oil air ) 90 0 0 0 ( mercury air ) 90 0 0 0 ( water oil ) 90 0 0 0 ( water mercury ) 90 0 0 0 ( oil mercury ) 90 0 0 0 );
value uniform 0; value uniform 0;
} }
lowerWall lowerWall
{ {
type alphaContactAngle; type multiphaseAlphaContactAngle;
thetaProperties ( ( water air ) 90 0 0 0 ( oil air ) 90 0 0 0 ( mercury air ) 90 0 0 0 ( water oil ) 90 0 0 0 ( water mercury ) 90 0 0 0 ( oil mercury ) 90 0 0 0 ); thetaProperties ( ( water air ) 90 0 0 0 ( oil air ) 90 0 0 0 ( mercury air ) 90 0 0 0 ( water oil ) 90 0 0 0 ( water mercury ) 90 0 0 0 ( oil mercury ) 90 0 0 0 );
value uniform 0; value uniform 0;
} }