diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C index 85b4ba7b27af55cdb62988913931f71464cbc992..e0fe697e88e437c90713bb15ba378c9b5d1ca30d 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C @@ -1590,7 +1590,11 @@ Foam::conformalVoronoiMesh::collapseFace // collapseToPtI = faceBoundaryPts[0]; // // collapseToPt = -// 0.5*(pts[faceBoundaryPts[0]] + pts[faceBoundaryPts[1]]); +// 0.5 +// *( +// pts[faceBoundaryPts[0]] +// + pts[faceBoundaryPts[1]] +// ); // } // else if (faceBoundaryPts.size() < f.size()) // { @@ -1646,7 +1650,11 @@ Foam::conformalVoronoiMesh::collapseFace // collapseToPtI = faceBoundaryPts[0]; // // collapseToPt = -// 0.5*(pts[faceBoundaryPts[0]] + pts[faceBoundaryPts[1]]); +// 0.5 +// *( +// pts[faceBoundaryPts[0]] +// + pts[faceBoundaryPts[1]] +// ); // } // else if (faceBoundaryPts.size() < f.size()) // { diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 3652bea89a44b4caf93d16ac97cd4e3ff58eb7f4..0e2de76c07e9afe4c38740a43dfcbf49a9079ec8 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -124,6 +124,7 @@ $(derivedFvPatchFields)/mappedFixedPushedInternalValue/mappedFixedPushedInternal $(derivedFvPatchFields)/mappedFixedValue/mappedFixedValueFvPatchFields.C $(derivedFvPatchFields)/mappedVelocityFluxFixedValue/mappedVelocityFluxFixedValueFvPatchField.C $(derivedFvPatchFields)/mappedFlowRate/mappedFlowRateFvPatchVectorField.C +$(derivedFvPatchFields)/fixedMean/fixedMeanFvPatchFields.C $(derivedFvPatchFields)/fan/fanFvPatchFields.C $(derivedFvPatchFields)/fanPressure/fanPressureFvPatchScalarField.C $(derivedFvPatchFields)/buoyantPressure/buoyantPressureFvPatchScalarField.C diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedMean/fixedMeanFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedMean/fixedMeanFvPatchField.C new file mode 100644 index 0000000000000000000000000000000000000000..e59f98910eb8a1f23cdaf39b7f48f59205b09a73 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedMean/fixedMeanFvPatchField.C @@ -0,0 +1,142 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 "fixedMeanFvPatchField.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type> +fixedMeanFvPatchField<Type>::fixedMeanFvPatchField +( + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF +) +: + fixedValueFvPatchField<Type>(p, iF), + meanValue_(pTraits<Type>::zero) +{} + + +template<class Type> +fixedMeanFvPatchField<Type>::fixedMeanFvPatchField +( + const fixedMeanFvPatchField<Type>& ptf, + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchField<Type>(ptf, p, iF, mapper), + meanValue_(ptf.meanValue_) +{} + + +template<class Type> +fixedMeanFvPatchField<Type>::fixedMeanFvPatchField +( + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF, + const dictionary& dict +) +: + fixedValueFvPatchField<Type>(p, iF, dict), + meanValue_(pTraits<Type>(dict.lookup("meanValue"))) +{} + + +template<class Type> +fixedMeanFvPatchField<Type>::fixedMeanFvPatchField +( + const fixedMeanFvPatchField<Type>& ptf +) +: + fixedValueFvPatchField<Type>(ptf), + meanValue_(ptf.meanValue_) +{} + + +template<class Type> +fixedMeanFvPatchField<Type>::fixedMeanFvPatchField +( + const fixedMeanFvPatchField<Type>& ptf, + const DimensionedField<Type, volMesh>& iF +) +: + fixedValueFvPatchField<Type>(ptf, iF), + meanValue_(ptf.meanValue_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +void fixedMeanFvPatchField<Type>::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + Field<Type> newValues(this->patchInternalField()); + + Type meanValuePsi = + gSum(this->patch().magSf()*newValues) + /gSum(this->patch().magSf()); + + if (mag(meanValue_) > SMALL && mag(meanValuePsi)/mag(meanValue_) > 0.5) + { + newValues *= mag(meanValue_)/mag(meanValuePsi); + } + else + { + newValues += (meanValue_ - meanValuePsi); + } + + this->operator==(newValues); + + fixedValueFvPatchField<Type>::updateCoeffs(); +} + + +template<class Type> +void fixedMeanFvPatchField<Type>::write(Ostream& os) const +{ + fvPatchField<Type>::write(os); + os.writeKeyword("meanValue") << meanValue_ << token::END_STATEMENT << nl; + this->writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedMean/fixedMeanFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedMean/fixedMeanFvPatchField.H new file mode 100644 index 0000000000000000000000000000000000000000..b59969a967210d0a31a76751e57fbf2996cb6301 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedMean/fixedMeanFvPatchField.H @@ -0,0 +1,158 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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::fixedMeanFvPatchField + +Description + Extrapolates field to the patch using the near-cell values and adjusts + the distribution to match the specified meanValue. + +SourceFiles + fixedMeanFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fixedMeanFvPatchField_H +#define fixedMeanFvPatchField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class fixedMeanFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type> +class fixedMeanFvPatchField +: + public fixedValueFvPatchField<Type> +{ + +protected: + + // Protected data + + //- MeanValue value the field is adjusted to maintain + Type meanValue_; + + +public: + + //- Runtime type information + TypeName("fixedMean"); + + + // Constructors + + //- Construct from patch and internal field + fixedMeanFvPatchField + ( + const fvPatch&, + const DimensionedField<Type, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + fixedMeanFvPatchField + ( + const fvPatch&, + const DimensionedField<Type, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given fixedMeanFvPatchField + // onto a new patch + fixedMeanFvPatchField + ( + const fixedMeanFvPatchField<Type>&, + const fvPatch&, + const DimensionedField<Type, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + fixedMeanFvPatchField + ( + const fixedMeanFvPatchField<Type>& + ); + + //- Construct and return a clone + virtual tmp<fvPatchField<Type> > clone() const + { + return tmp<fvPatchField<Type> > + ( + new fixedMeanFvPatchField<Type>(*this) + ); + } + + //- Construct as copy setting internal field reference + fixedMeanFvPatchField + ( + const fixedMeanFvPatchField<Type>&, + const DimensionedField<Type, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchField<Type> > clone + ( + const DimensionedField<Type, volMesh>& iF + ) const + { + return tmp<fvPatchField<Type> > + ( + new fixedMeanFvPatchField<Type>(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "fixedMeanFvPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedMean/fixedMeanFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedMean/fixedMeanFvPatchFields.C new file mode 100644 index 0000000000000000000000000000000000000000..e8e269c8a5b4689fdf26d1306f6b5cf0ce59f834 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedMean/fixedMeanFvPatchFields.C @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 "fixedMeanFvPatchFields.H" +#include "volMesh.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makePatchFields(fixedMean); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedMean/fixedMeanFvPatchFields.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedMean/fixedMeanFvPatchFields.H new file mode 100644 index 0000000000000000000000000000000000000000..64996c3a682db52980833172f8c9104cc9862fee --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedMean/fixedMeanFvPatchFields.H @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef fixedMeanFvPatchFields_H +#define fixedMeanFvPatchFields_H + +#include "fixedMeanFvPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeFieldTypedefs(fixedMean); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedMean/fixedMeanFvPatchFieldsFwd.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedMean/fixedMeanFvPatchFieldsFwd.H new file mode 100644 index 0000000000000000000000000000000000000000..9f04dc965bfe98be0cb1e99fcc22a644c4613a1f --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedMean/fixedMeanFvPatchFieldsFwd.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef fixedMeanFvPatchFieldsFwd_H +#define fixedMeanFvPatchFieldsFwd_H + +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type> class fixedMeanFvPatchField; + +makePatchTypeFieldTypedefs(fixedMean); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //