Skip to content
Permalink
Browse files

waves: Added waveInletOutlet condition

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
Will Bainbridge committed Jan 4, 2019
1 parent 70021b1 commit 7957f3a8fdfccc2326abb6cac1b2ebe0f0d6965a
@@ -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
@@ -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
\*---------------------------------------------------------------------------*/
@@ -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
\*---------------------------------------------------------------------------*/
@@ -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
@@ -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)
{
@@ -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;
@@ -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
@@ -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
(
@@ -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,
@@ -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,
@@ -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
@@ -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)
{
@@ -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;
@@ -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.
You can’t perform that action at this time.