diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/Make/files b/applications/solvers/stressAnalysis/solidDisplacementFoam/Make/files index 85e28b8521..74c395c479 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/Make/files +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/Make/files @@ -1,4 +1,5 @@ -tractionDisplacement/tractionDisplacementFvPatchVectorField.C +derivedFvPatchFields/tractionDisplacement/tractionDisplacementFvPatchVectorField.C +derivedFvPatchFields/hydrostaticDisplacement/hydrostaticDisplacementFvPatchVectorField.C solidDisplacementFoam.C EXE = $(FOAM_APPBIN)/solidDisplacementFoam diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/Make/options b/applications/solvers/stressAnalysis/solidDisplacementFoam/Make/options index 3a6868f80a..b2de349d96 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/Make/options +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/Make/options @@ -1,6 +1,6 @@ EXE_INC = \ -I. \ - -ItractionDisplacement \ + -IderivedFvPatchFields/tractionDisplacement \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/derivedFvPatchFields/hydrostaticDisplacement/hydrostaticDisplacementFvPatchVectorField.C b/applications/solvers/stressAnalysis/solidDisplacementFoam/derivedFvPatchFields/hydrostaticDisplacement/hydrostaticDisplacementFvPatchVectorField.C new file mode 100644 index 0000000000..570034d162 --- /dev/null +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/derivedFvPatchFields/hydrostaticDisplacement/hydrostaticDisplacementFvPatchVectorField.C @@ -0,0 +1,149 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2018 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 . + +\*---------------------------------------------------------------------------*/ + +#include "hydrostaticDisplacementFvPatchVectorField.H" +#include "uniformDimensionedFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::hydrostaticDisplacementFvPatchVectorField:: +hydrostaticDisplacementFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF +) +: + tractionDisplacementFvPatchVectorField(p, iF), + rhoLiquid_(0.0), + liquidSurfacePressure_(0.0), + liquidSurfacePoint_(Zero) +{} + + +Foam::hydrostaticDisplacementFvPatchVectorField:: +hydrostaticDisplacementFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + tractionDisplacementFvPatchVectorField(p, iF), + rhoLiquid_(readScalar(dict.lookup("rhoLiquid"))), + liquidSurfacePressure_(readScalar(dict.lookup("liquidSurfacePressure"))), + liquidSurfacePoint_(dict.lookup("liquidSurfacePoint")) +{} + + +Foam::hydrostaticDisplacementFvPatchVectorField:: +hydrostaticDisplacementFvPatchVectorField +( + const hydrostaticDisplacementFvPatchVectorField& tdpvf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + tractionDisplacementFvPatchVectorField(tdpvf, p, iF, mapper), + rhoLiquid_(tdpvf.rhoLiquid_), + liquidSurfacePressure_(tdpvf.liquidSurfacePressure_), + liquidSurfacePoint_(tdpvf.liquidSurfacePoint_) +{} + + +Foam::hydrostaticDisplacementFvPatchVectorField:: +hydrostaticDisplacementFvPatchVectorField +( + const hydrostaticDisplacementFvPatchVectorField& tdpvf +) +: + tractionDisplacementFvPatchVectorField(tdpvf), + rhoLiquid_(tdpvf.rhoLiquid_), + liquidSurfacePressure_(tdpvf.liquidSurfacePressure_), + liquidSurfacePoint_(tdpvf.liquidSurfacePoint_) +{} + + +Foam::hydrostaticDisplacementFvPatchVectorField:: +hydrostaticDisplacementFvPatchVectorField +( + const hydrostaticDisplacementFvPatchVectorField& tdpvf, + const DimensionedField& iF +) +: + tractionDisplacementFvPatchVectorField(tdpvf, iF), + rhoLiquid_(tdpvf.rhoLiquid_), + liquidSurfacePressure_(tdpvf.liquidSurfacePressure_), + liquidSurfacePoint_(tdpvf.liquidSurfacePoint_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::hydrostaticDisplacementFvPatchVectorField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const uniformDimensionedVectorField& g = + db().lookupObject("g"); + + pressure() = + liquidSurfacePressure_ + + rhoLiquid_ + *max(g.value() & (patch().Cf() - liquidSurfacePoint_), scalar(0)); + + tractionDisplacementFvPatchVectorField::updateCoeffs(); +} + + +void Foam::hydrostaticDisplacementFvPatchVectorField::write(Ostream& os) const +{ + fvPatchVectorField::write(os); + os.writeKeyword("rhoLiquid") << rhoLiquid_ << token::END_STATEMENT << nl; + os.writeKeyword("liquidSurfacePressure") + << liquidSurfacePressure_ << token::END_STATEMENT << nl; + os.writeKeyword("liquidSurfacePoint") + << liquidSurfacePoint_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchVectorField, + hydrostaticDisplacementFvPatchVectorField + ); +} + + +// ************************************************************************* // diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/derivedFvPatchFields/hydrostaticDisplacement/hydrostaticDisplacementFvPatchVectorField.H b/applications/solvers/stressAnalysis/solidDisplacementFoam/derivedFvPatchFields/hydrostaticDisplacement/hydrostaticDisplacementFvPatchVectorField.H new file mode 100644 index 0000000000..ecbb333c3c --- /dev/null +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/derivedFvPatchFields/hydrostaticDisplacement/hydrostaticDisplacementFvPatchVectorField.H @@ -0,0 +1,153 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2018 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 . + +Class + Foam::hydrostaticDisplacementFvPatchVectorField + +Description + Fixed traction boundary condition for the standard linear elastic, fixed + coefficient displacement equation in which the traction is caused by + the hydrostatic pressure of an external liquid reservoir. + +SourceFiles + hydrostaticDisplacementFvPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef hydrostaticDisplacementFvPatchVectorField_H +#define hydrostaticDisplacementFvPatchVectorField_H + +#include "tractionDisplacementFvPatchVectorField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class hydrostaticDisplacementFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class hydrostaticDisplacementFvPatchVectorField +: + public tractionDisplacementFvPatchVectorField +{ + // Private Data + + //- Density of surrounding liquid + scalar rhoLiquid_; + + //- Pressure above the liquid + scalar liquidSurfacePressure_; + + //- Point on liquid surface + vector liquidSurfacePoint_; + + +public: + + //- Runtime type information + TypeName("hydrostaticDisplacement"); + + + // Constructors + + //- Construct from patch and internal field + hydrostaticDisplacementFvPatchVectorField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + hydrostaticDisplacementFvPatchVectorField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // hydrostaticDisplacementFvPatchVectorField onto a new patch + hydrostaticDisplacementFvPatchVectorField + ( + const hydrostaticDisplacementFvPatchVectorField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + hydrostaticDisplacementFvPatchVectorField + ( + const hydrostaticDisplacementFvPatchVectorField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new hydrostaticDisplacementFvPatchVectorField(*this) + ); + } + + //- Construct as copy setting internal field reference + hydrostaticDisplacementFvPatchVectorField + ( + const hydrostaticDisplacementFvPatchVectorField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new hydrostaticDisplacementFvPatchVectorField(*this, iF) + ); + } + + + // Member functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/tractionDisplacement/tractionDisplacementFvPatchVectorField.C b/applications/solvers/stressAnalysis/solidDisplacementFoam/derivedFvPatchFields/tractionDisplacement/tractionDisplacementFvPatchVectorField.C similarity index 88% rename from applications/solvers/stressAnalysis/solidDisplacementFoam/tractionDisplacement/tractionDisplacementFvPatchVectorField.C rename to applications/solvers/stressAnalysis/solidDisplacementFoam/derivedFvPatchFields/tractionDisplacement/tractionDisplacementFvPatchVectorField.C index 22cbcb5fd3..2f7158c195 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/tractionDisplacement/tractionDisplacementFvPatchVectorField.C +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/derivedFvPatchFields/tractionDisplacement/tractionDisplacementFvPatchVectorField.C @@ -24,17 +24,12 @@ License \*---------------------------------------------------------------------------*/ #include "tractionDisplacementFvPatchVectorField.H" -#include "addToRunTimeSelectionTable.H" #include "volFields.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -tractionDisplacementFvPatchVectorField:: +Foam::tractionDisplacementFvPatchVectorField:: tractionDisplacementFvPatchVectorField ( const fvPatch& p, @@ -50,7 +45,7 @@ tractionDisplacementFvPatchVectorField } -tractionDisplacementFvPatchVectorField:: +Foam::tractionDisplacementFvPatchVectorField:: tractionDisplacementFvPatchVectorField ( const tractionDisplacementFvPatchVectorField& tdpvf, @@ -65,7 +60,7 @@ tractionDisplacementFvPatchVectorField {} -tractionDisplacementFvPatchVectorField:: +Foam::tractionDisplacementFvPatchVectorField:: tractionDisplacementFvPatchVectorField ( const fvPatch& p, @@ -82,7 +77,7 @@ tractionDisplacementFvPatchVectorField } -tractionDisplacementFvPatchVectorField:: +Foam::tractionDisplacementFvPatchVectorField:: tractionDisplacementFvPatchVectorField ( const tractionDisplacementFvPatchVectorField& tdpvf @@ -94,7 +89,7 @@ tractionDisplacementFvPatchVectorField {} -tractionDisplacementFvPatchVectorField:: +Foam::tractionDisplacementFvPatchVectorField:: tractionDisplacementFvPatchVectorField ( const tractionDisplacementFvPatchVectorField& tdpvf, @@ -109,7 +104,7 @@ tractionDisplacementFvPatchVectorField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void tractionDisplacementFvPatchVectorField::autoMap +void Foam::tractionDisplacementFvPatchVectorField::autoMap ( const fvPatchFieldMapper& m ) @@ -120,7 +115,7 @@ void tractionDisplacementFvPatchVectorField::autoMap } -void tractionDisplacementFvPatchVectorField::rmap +void Foam::tractionDisplacementFvPatchVectorField::rmap ( const fvPatchVectorField& ptf, const labelList& addr @@ -136,7 +131,7 @@ void tractionDisplacementFvPatchVectorField::rmap } -void tractionDisplacementFvPatchVectorField::updateCoeffs() +void Foam::tractionDisplacementFvPatchVectorField::updateCoeffs() { if (updated()) { @@ -202,7 +197,7 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs() } -void tractionDisplacementFvPatchVectorField::write(Ostream& os) const +void Foam::tractionDisplacementFvPatchVectorField::write(Ostream& os) const { fvPatchVectorField::write(os); traction_.writeEntry("traction", os); @@ -213,14 +208,14 @@ void tractionDisplacementFvPatchVectorField::write(Ostream& os) const // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField -( - fvPatchVectorField, - tractionDisplacementFvPatchVectorField -); +namespace Foam +{ + makePatchTypeField + ( + fvPatchVectorField, + tractionDisplacementFvPatchVectorField + ); +} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam // ************************************************************************* // diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/tractionDisplacement/tractionDisplacementFvPatchVectorField.H b/applications/solvers/stressAnalysis/solidDisplacementFoam/derivedFvPatchFields/tractionDisplacement/tractionDisplacementFvPatchVectorField.H similarity index 98% rename from applications/solvers/stressAnalysis/solidDisplacementFoam/tractionDisplacement/tractionDisplacementFvPatchVectorField.H rename to applications/solvers/stressAnalysis/solidDisplacementFoam/derivedFvPatchFields/tractionDisplacement/tractionDisplacementFvPatchVectorField.H index 5d55d24a06..eab4c046a4 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/tractionDisplacement/tractionDisplacementFvPatchVectorField.H +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/derivedFvPatchFields/tractionDisplacement/tractionDisplacementFvPatchVectorField.H @@ -36,7 +36,6 @@ SourceFiles #ifndef tractionDisplacementFvPatchVectorField_H #define tractionDisplacementFvPatchVectorField_H -#include "fvPatchFields.H" #include "fixedGradientFvPatchFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -52,7 +51,6 @@ class tractionDisplacementFvPatchVectorField : public fixedGradientFvPatchVectorField { - // Private Data vectorField traction_; @@ -146,7 +144,7 @@ public: return pressure_; } - virtual scalarField& pressure() + virtual scalarField& pressure() { return pressure_; }