Skip to content

Commit

Permalink
waves: Added waveInletOutlet condition
Browse files Browse the repository at this point in the history
This is an inlet-outlet condition where the inlet value differs above
and below a wave interface. It can be used as follows:

    inlet
    {
        type    waveInletOutlet;
        inletValueAbove 0.01;
        inletValueBelow 0.1;
    }
  • Loading branch information
Will Bainbridge committed Jan 4, 2019
1 parent 70021b1 commit 7957f3a
Show file tree
Hide file tree
Showing 10 changed files with 607 additions and 21 deletions.
90 changes: 89 additions & 1 deletion src/OpenFOAM/meshes/primitiveShapes/cut/cut.H
Expand Up @@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
Expand Down Expand Up @@ -177,6 +177,51 @@ public:
};


/*---------------------------------------------------------------------------*\
Class areaMagOp Declaration
\*---------------------------------------------------------------------------*/

class areaMagOp
:
public uniformOp<nil>
{
public:

// Typedefs

//- Result type
typedef scalar result;


// Constructors

//- Construct null
areaMagOp()
{}

//- Construct from base
areaMagOp(const uniformOp<nil>& op)
:
uniformOp<nil>(op)
{}


// Member operators

//- Operate on nothing
result operator()() const
{
return 0;
}

//- Operate on a triangle
result operator()(const FixedList<point, 3>& p) const
{
return result(triPointRef(p[0], p[1], p[2]).mag());
}
};


/*---------------------------------------------------------------------------*\
Class volumeOp Declaration
\*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -265,6 +310,49 @@ public:
};


/*---------------------------------------------------------------------------*\
Class areaMagIntegrateOp Declaration
\*---------------------------------------------------------------------------*/

template<class Type>
class areaMagIntegrateOp
:
public FixedList<Type, 3>
{
public:

// Typedefs

//- Result type
typedef Type result;


// Constructors

//- Construct from base
areaMagIntegrateOp(const FixedList<Type, 3>& x)
:
FixedList<Type, 3>(x)
{}


// Member operators

//- Operate on nothing
result operator()() const
{
return pTraits<result>::zero;
}

//- Operate on a triangle
result operator()(const FixedList<point, 3>& p) const
{
const FixedList<Type, 3>& x = *this;
return result(areaMagOp()(p)*(x[0] + x[1] + x[2])/3);
}
};


/*---------------------------------------------------------------------------*\
Class volumeIntegrateOp Declaration
\*---------------------------------------------------------------------------*/
Expand Down
12 changes: 6 additions & 6 deletions src/finiteVolume/cfdTools/general/levelSet/levelSet.C
Expand Up @@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
Expand Down Expand Up @@ -103,7 +103,7 @@ Foam::tmp<Foam::scalarField> Foam::levelSetFraction
{
const face& f = patch.patch().localFaces()[fI];

vector a = vector::zero, r = vector::zero;
scalar a = 0, r = 0;

for(label eI = 0; eI < f.size(); ++ eI)
{
Expand All @@ -124,19 +124,19 @@ Foam::tmp<Foam::scalarField> Foam::levelSetFraction
levelP[e[1]]
};

a += cut::areaOp()(tri);
a += cut::areaMagOp()(tri);

if (above)
{
r += triCut(tri, level, cut::areaOp(), cut::noOp());
r += triCut(tri, level, cut::areaMagOp(), cut::noOp());
}
else
{
r += triCut(tri, level, cut::noOp(), cut::areaOp());
r += triCut(tri, level, cut::noOp(), cut::areaMagOp());
}
}

result[fI] = a/magSqr(a) & r;
result[fI] = r/a;
}

return tResult;
Expand Down
8 changes: 4 additions & 4 deletions src/finiteVolume/cfdTools/general/levelSet/levelSet.H
Expand Up @@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
Expand Down Expand Up @@ -71,7 +71,7 @@ tmp<Field<Type>> levelSetAverage
const Field<Type>& negativeP
);

//- As the above oveload, but both in cells and on patch faces
//- As the above overload, but both in cells and on patch faces
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> levelSetAverage
(
Expand All @@ -94,7 +94,7 @@ tmp<scalarField> levelSetFraction
const bool above
);

//- As the above oveload, but on the faces of a patch
//- As the above overload, but on the faces of a patch
tmp<scalarField> levelSetFraction
(
const fvPatch& patch,
Expand All @@ -103,7 +103,7 @@ tmp<scalarField> levelSetFraction
const bool above
);

//- As the above oveload, but both in cells and on patch faces
//- As the above overload, but both in cells and on patch faces
tmp<volScalarField> levelSetFraction
(
const volScalarField& levelC,
Expand Down
16 changes: 7 additions & 9 deletions src/finiteVolume/cfdTools/general/levelSet/levelSetTemplates.C
Expand Up @@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
Expand Down Expand Up @@ -114,17 +114,15 @@ Foam::tmp<Foam::Field<Type>> Foam::levelSetAverage
const Field<Type>& negativeP
)
{
typedef typename outerProduct<Type, vector>::type sumType;

tmp<Field<Type>> tResult(new Field<Type>(patch.size(), Zero));
Field<Type>& result = tResult.ref();

forAll(result, fI)
{
const face& f = patch.patch().localFaces()[fI];

vector a = vector::zero;
sumType r = Zero;
scalar a = 0;
Type r = Zero;

for(label eI = 0; eI < f.size(); ++ eI)
{
Expand All @@ -144,27 +142,27 @@ Foam::tmp<Foam::Field<Type>> Foam::levelSetAverage
levelP[e[0]],
levelP[e[1]]
};
const cut::areaIntegrateOp<Type>
const cut::areaMagIntegrateOp<Type>
positive = FixedList<Type, 3>
({
positiveF[fI],
positiveP[e[0]],
positiveP[e[1]]
});
const cut::areaIntegrateOp<Type>
const cut::areaMagIntegrateOp<Type>
negative = FixedList<Type, 3>
({
negativeF[fI],
negativeP[e[0]],
negativeP[e[1]]
});

a += cut::areaOp()(tri);
a += cut::areaMagOp()(tri);

r += triCut(tri, level, positive, negative);
}

result[fI] = a/magSqr(a) & r;
result[fI] = r/a;
}

return tResult;
Expand Down
3 changes: 2 additions & 1 deletion src/waves/Make/files
Expand Up @@ -10,7 +10,8 @@ waveSuperpositions/waveSuperposition/newWaveSuperposition.C
waveSuperpositions/waveAtmBoundaryLayerSuperposition/waveAtmBoundaryLayerSuperposition.C

derivedFvPatchFields/waveAlpha/waveAlphaFvPatchScalarField.C
derivedFvPatchFields/waveVelocity/waveVelocityFvPatchVectorField.C
derivedFvPatchFields/waveInletOutlet/waveInletOutletFvPatchFields.C
derivedFvPatchFields/wavePressure/wavePressureFvPatchScalarField.C
derivedFvPatchFields/waveVelocity/waveVelocityFvPatchVectorField.C

LIB = $(FOAM_LIBBIN)/libwaves

0 comments on commit 7957f3a

Please sign in to comment.