Skip to content

Commit

Permalink
mappedFilmPressureFvPatchScalarField: New film BC to map the neighbou…
Browse files Browse the repository at this point in the history
…ring fluid pressure to the film

mappedFilmPressureFvPatchScalarField is derived from the new mappedFvPatchField
base-class for mapped patch fields including mappedValueFvPatchField.

Class
    Foam::mappedFilmPressureFvPatchScalarField

Description
    Film pressure boundary condition which maps the neighbouring fluid patch
    pressure to both the surface patch and internal film pressure field.
  • Loading branch information
Henry Weller committed Mar 3, 2023
1 parent 9df3600 commit 12decc0
Show file tree
Hide file tree
Showing 16 changed files with 817 additions and 206 deletions.
1 change: 1 addition & 0 deletions applications/solvers/modules/isothermalFilm/Make/files
Expand Up @@ -18,6 +18,7 @@ patches/mappedFilmSurface/mappedFilmSurfaceFvPatch/mappedFilmSurfaceFvPatch.C

derivedFvPatchFields/alphaOne/alphaOneFvPatchScalarField.C
derivedFvPatchFields/filmContactAngle/filmContactAngleFvPatchScalarField.C
derivedFvPatchFields/mappedFilmPressure/mappedFilmPressureFvPatchScalarField.C

filmGaussGrad/filmGaussGrads.C

Expand Down
@@ -0,0 +1,145 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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.
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/

#include "mappedFilmPressureFvPatchScalarField.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"

// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

Foam::mappedFilmPressureFvPatchScalarField::mappedFilmPressureFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
zeroGradientFvPatchField<scalar>(p, iF),
mappedFvPatchField<scalar>(p, iF)
{}


Foam::mappedFilmPressureFvPatchScalarField::mappedFilmPressureFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
zeroGradientFvPatchField<scalar>(p, iF, dict),
mappedFvPatchField<scalar>(p, iF, dict)
{}


Foam::mappedFilmPressureFvPatchScalarField::mappedFilmPressureFvPatchScalarField
(
const mappedFilmPressureFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
zeroGradientFvPatchField<scalar>(ptf, p, iF, mapper),
mappedFvPatchField<scalar>(ptf, p, iF, mapper)
{}


Foam::mappedFilmPressureFvPatchScalarField::mappedFilmPressureFvPatchScalarField
(
const mappedFilmPressureFvPatchScalarField& ptf,
const DimensionedField<scalar, volMesh>& iF
)
:
zeroGradientFvPatchField<scalar>(ptf, iF),
mappedFvPatchField<scalar>(ptf, iF)
{}


// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

void Foam::mappedFilmPressureFvPatchScalarField::map
(
const fvPatchField<scalar>& ptf,
const fvPatchFieldMapper& mapper
)
{
zeroGradientFvPatchField<scalar>::map(ptf, mapper);
mappedFvPatchField<scalar>::clearOut();
}


void Foam::mappedFilmPressureFvPatchScalarField::reset
(
const fvPatchField<scalar>& ptf
)
{
zeroGradientFvPatchField<scalar>::reset(ptf);
mappedFvPatchField<scalar>::clearOut();
}


void Foam::mappedFilmPressureFvPatchScalarField::updateCoeffs()
{
if (this->updated())
{
return;
}

// Map the neighbouring fluid patch pressure field to this patch
this->operator==(this->mappedValues(this->nbrPatchField()));

// Map the patch pressure to the internal field
UIndirectList<scalar>
(
const_cast<Field<scalar>&>(this->primitiveField()),
this->patch().faceCells()
) = *this;

zeroGradientFvPatchField<scalar>::updateCoeffs();
}


void Foam::mappedFilmPressureFvPatchScalarField::write(Ostream& os) const
{
fvPatchField<scalar>::write(os);

mappedFvPatchField<scalar>::write(os);

writeEntry(os, "value", *this);
}


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
mappedFilmPressureFvPatchScalarField
);
}


// ************************************************************************* //
@@ -0,0 +1,151 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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.
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::mappedFilmPressureFvPatchScalarField
Description
Film pressure boundary condition which maps the neighbouring fluid patch
pressure to both the surface patch and internal film pressure field.
SourceFiles
mappedFilmPressureFvPatchScalarField.C
\*---------------------------------------------------------------------------*/

#ifndef mappedFilmPressureFvPatchScalarField_H
#define mappedFilmPressureFvPatchScalarField_H

#include "zeroGradientFvPatchFields.H"
#include "mappedFvPatchField.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

/*---------------------------------------------------------------------------*\
Class mappedFilmPressureFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/

class mappedFilmPressureFvPatchScalarField
:
public zeroGradientFvPatchField<scalar>,
public mappedFvPatchField<scalar>
{

public:

//- Runtime type information
TypeName("mappedFilmPressure");


// Constructors

//- Construct from patch and internal field
mappedFilmPressureFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);

//- Construct from patch, internal field and dictionary
mappedFilmPressureFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);

//- Construct by mapping given mappedFilmPressureFvPatchScalarField
// onto a new patch
mappedFilmPressureFvPatchScalarField
(
const mappedFilmPressureFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);

//- Disallow copy without setting internal field reference
mappedFilmPressureFvPatchScalarField
(
const mappedFilmPressureFvPatchScalarField&
) = delete;

//- Copy constructor setting internal field reference
mappedFilmPressureFvPatchScalarField
(
const mappedFilmPressureFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);

//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchField<scalar>> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchField<scalar>>
(
new mappedFilmPressureFvPatchScalarField(*this, iF)
);
}


// Member Functions

// Mapping functions

//- Map the given fvPatchField onto this fvPatchField
virtual void map
(
const fvPatchField<scalar>&,
const fvPatchFieldMapper&
);

//- Reset the fvPatchField to the given fvPatchField
// Used for mesh to mesh mapping
virtual void reset(const fvPatchField<scalar>&);


// Evaluation functions

//- Update the coefficients associated with the patch field
virtual void updateCoeffs();


//- Write
virtual void write(Ostream&) const;
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //
Expand Up @@ -240,6 +240,7 @@ Foam::solvers::isothermalFilm::isothermalFilm
thermo_(thermoPtr),
thermo(thermo_()),

p(thermo.p()),
rho(thermo.rho()),

nHat
Expand Down
3 changes: 3 additions & 0 deletions applications/solvers/modules/isothermalFilm/isothermalFilm.H
Expand Up @@ -98,6 +98,9 @@ protected:
//- Reference to the fluid thermophysical properties
fluidThermo& thermo;

//- The thermodynamic pressure field
volScalarField& p;

//- The thermodynamic density field
const volScalarField& rho;

Expand Down
11 changes: 4 additions & 7 deletions applications/solvers/modules/isothermalFilm/momentumPredictor.C
Expand Up @@ -66,13 +66,10 @@ Foam::solvers::isothermalFilm::pc(const volScalarField& sigma) const
Foam::tmp<Foam::volScalarField>
Foam::solvers::isothermalFilm::pe() const
{
// Currently there is no transfer of pressure from the adjacent fluid
return volScalarField::New
(
"pExternal",
mesh,
dimensionedScalar(dimPressure, 0)
);
// Update the pressure, mapping from the fluid region as required
p.correctBoundaryConditions();

return p;
}


Expand Down
1 change: 1 addition & 0 deletions src/finiteVolume/Make/files
Expand Up @@ -192,6 +192,7 @@ $(derivedFvPatchFields)/inletOutlet/inletOutletFvPatchFields.C
$(derivedFvPatchFields)/inletOutletTotalTemperature/inletOutletTotalTemperatureFvPatchScalarField.C
$(derivedFvPatchFields)/mappedFlowRateVelocity/mappedFlowRateVelocityFvPatchVectorField.C
$(derivedFvPatchFields)/mappedInternalValue/mappedInternalValueFvPatchFields.C
$(derivedFvPatchFields)/mapped/mappedFvPatchFields.C
$(derivedFvPatchFields)/mappedValue/mappedValueFvPatchFields.C
$(derivedFvPatchFields)/mappedValueAndPatchInternalValue/mappedValueAndPatchInternalValueFvPatchFields.C
$(derivedFvPatchFields)/mappedVelocityFlux/mappedVelocityFluxFvPatchField.C
Expand Down

0 comments on commit 12decc0

Please sign in to comment.