From 089e593907af5088885bf6c75a1fdc497987b9c1 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 13 Apr 2010 11:27:11 +0100 Subject: [PATCH 1/6] BUG: Was never calculating the patch-patch points. --- .../interpolation/volPointInterpolation/volPointInterpolation.C | 1 + 1 file changed, 1 insertion(+) diff --git a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolation.C b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolation.C index 37e61081ed..36a92ca66b 100644 --- a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolation.C +++ b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolation.C @@ -620,6 +620,7 @@ volPointInterpolation::~volPointInterpolation() void volPointInterpolation::updateMesh() { makeWeights(); + makePatchPatchAddressing(); } From 8d2e5df846628e68f36c4d1b992fac6463bad723 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 13 Apr 2010 16:46:35 +0100 Subject: [PATCH 2/6] ENH: Allow pointPatchFields derived from constrained pointPatchField types. --- .../basicSymmetryPointPatchField.H | 7 ++ .../constraint/cyclic/cyclicPointPatchField.H | 8 ++ .../constraint/empty/emptyPointPatchField.H | 11 +++ .../processor/processorPointPatchField.H | 9 +++ .../constraint/wedge/wedgePointPatchField.H | 8 ++ .../pointPatchField/newPointPatchField.C | 76 +++++++++++++------ .../pointPatchField/pointPatchField.H | 8 +- .../constraint/cyclic/cyclicPointPatch.H | 6 ++ .../constraint/empty/emptyPointPatch.H | 6 ++ .../processor/processorPointPatch.H | 6 ++ .../constraint/symmetry/symmetryPointPatch.H | 6 ++ .../constraint/wedge/wedgePointPatch.H | 6 ++ .../pointPatches/pointPatch/pointPatch.H | 6 ++ 13 files changed, 137 insertions(+), 26 deletions(-) diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/basicSymmetry/basicSymmetryPointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/basic/basicSymmetry/basicSymmetryPointPatchField.H index 445a67281f..5d77b05804 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/basicSymmetry/basicSymmetryPointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/basic/basicSymmetry/basicSymmetryPointPatchField.H @@ -36,6 +36,7 @@ SourceFiles #define basicSymmetryPointPatchField_H #include "pointPatchField.H" +#include "symmetryPointPatch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -120,6 +121,12 @@ public: // Evaluation functions + //- Return the constraint type this pointPatchField implements + virtual const word& constraintType() const + { + return symmetryPointPatch::typeName; + } + //- Update the patch field virtual void evaluate ( diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/cyclic/cyclicPointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/constraint/cyclic/cyclicPointPatchField.H index 14785b36eb..72eabdaaf9 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/cyclic/cyclicPointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/cyclic/cyclicPointPatchField.H @@ -127,6 +127,14 @@ public: // Member functions + //- Constraint handling + + //- Return the constraint type this pointPatchField implements + virtual const word& constraintType() const + { + return cyclicPointPatch::typeName; + } + //- Cyclic coupled interface functions //- Does the patch field perform the transfromation diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/empty/emptyPointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/constraint/empty/emptyPointPatchField.H index cc578731a0..bb58e0eeea 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/empty/emptyPointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/empty/emptyPointPatchField.H @@ -119,6 +119,17 @@ public: ) ); } + + // Member functions + + //- Constraint handling + + //- Return the constraint type this pointPatchField implements + virtual const word& constraintType() const + { + return type(); + } + }; diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.H index 17bcfc1cb8..7f6f7b7173 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.H @@ -159,6 +159,15 @@ public: } + //- Constraint handling + + //- Return the constraint type this pointPatchField implements + virtual const word& constraintType() const + { + return type(); + } + + // Evaluation functions //- Evaluate the patch field diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/wedge/wedgePointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/constraint/wedge/wedgePointPatchField.H index 5f01f592e5..8c62f3e47b 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/wedge/wedgePointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/wedge/wedgePointPatchField.H @@ -122,6 +122,14 @@ public: // Member functions + //- Constraint handling + + //- Return the constraint type this pointPatchField implements + virtual const word& constraintType() const + { + return type(); + } + // Evaluation functions //- Update the patch field diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/newPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/newPointPatchField.C index c77236f80d..b14fbeac8f 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/newPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/newPointPatchField.C @@ -50,7 +50,7 @@ Foam::autoPtr > Foam::pointPatchField::New ( "PointPatchField::New" "(const word&, const pointPatch&, const Field&)" - ) << "Unknown patchTypefield type " + ) << "Unknown patchFieldType type " << patchFieldType << endl << endl << "Valid patchField types are :" << endl @@ -58,16 +58,32 @@ Foam::autoPtr > Foam::pointPatchField::New << exit(FatalError); } - typename pointPatchConstructorTable::iterator patchTypeCstrIter = - pointPatchConstructorTablePtr_->find(p.type()); + autoPtr > pfPtr(cstrIter()(p, iF)); - if (patchTypeCstrIter != pointPatchConstructorTablePtr_->end()) + if (pfPtr().constraintType() == p.constraintType()) { - return autoPtr >(patchTypeCstrIter()(p, iF)); + // Compatible (constraint-wise) with the patch type + return pfPtr; } else { - return autoPtr >(cstrIter()(p, iF)); + // Use default constraint type + typename pointPatchConstructorTable::iterator patchTypeCstrIter = + pointPatchConstructorTablePtr_->find(p.type()); + + if (patchTypeCstrIter == pointPatchConstructorTablePtr_->end()) + { + FatalErrorIn + ( + "PointPatchField::New" + "(const word&, const pointPatch&, const Field&)" + ) << "inconsistent patch and patchField types for \n" + << " patch type " << p.type() + << " and patchField type " << patchFieldType + << exit(FatalError); + } + + return patchTypeCstrIter()(p, iF); } } @@ -115,34 +131,44 @@ Foam::autoPtr > Foam::pointPatchField::New } } + // Construct (but not necesarily returned) + autoPtr > pfPtr(cstrIter()(p, iF, dict)); + if ( !dict.found("patchType") || word(dict.lookup("patchType")) != p.type() ) { - typename dictionaryConstructorTable::iterator patchTypeCstrIter - = dictionaryConstructorTablePtr_->find(p.type()); - - if - ( - patchTypeCstrIter != dictionaryConstructorTablePtr_->end() - && patchTypeCstrIter() != cstrIter() - ) + if (pfPtr().constraintType() == p.constraintType()) { - FatalIOErrorIn - ( - "PointPatchFieldconst pointPatch&, " - "const Field&, const dictionary&)", - dict - ) << "inconsistent patch and patchField types for \n" - << " patch type " << p.type() - << " and patchField type " << patchFieldType - << exit(FatalIOError); + // Compatible (constraint-wise) with the patch type + return pfPtr; + } + else + { + // Use default constraint type + typename dictionaryConstructorTable::iterator patchTypeCstrIter + = dictionaryConstructorTablePtr_->find(p.type()); + + if (patchTypeCstrIter == pointPatchConstructorTablePtr_->end()) + { + FatalIOErrorIn + ( + "PointPatchFieldconst pointPatch&, " + "const Field&, const dictionary&)", + dict + ) << "inconsistent patch and patchField types for \n" + << " patch type " << p.type() + << " and patchField type " << patchFieldType + << exit(FatalIOError); + } + + return patchTypeCstrIter()(p, iF, dict); } } - return autoPtr >(cstrIter()(p, iF, dict)); + return cstrIter()(p, iF, dict); } @@ -185,7 +211,7 @@ Foam::autoPtr > Foam::pointPatchField::New << exit(FatalError); } - return autoPtr >(cstrIter()(ptf, p, iF, pfMapper)); + return cstrIter()(ptf, p, iF, pfMapper); } diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H index ae6ce5eb93..297b1c5370 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H @@ -337,9 +337,15 @@ public: const Field& pF ) const; - //- Return the type of the calculated for of pointPatchField + //- Return the type of the calculated form of pointPatchField static const word& calculatedType(); + //- Return the constraint type this pointPatchField implements. + virtual const word& constraintType() const + { + return word::null; + } + // Mapping functions diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/cyclic/cyclicPointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/cyclic/cyclicPointPatch.H index 91fdb1cf84..df11e9cf3e 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/cyclic/cyclicPointPatch.H +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/cyclic/cyclicPointPatch.H @@ -114,6 +114,12 @@ public: // Access + //- Return the constraint type this pointPatch implements. + virtual const word& constraintType() const + { + return type(); + } + //- Return the underlying cyclicPolyPatch const cyclicPolyPatch& cyclicPatch() const { diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/empty/emptyPointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/empty/emptyPointPatch.H index c0450f1ce7..1352a71aa3 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/empty/emptyPointPatch.H +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/empty/emptyPointPatch.H @@ -73,6 +73,12 @@ public: // Member Functions + //- Return the constraint type this pointPatch implements. + virtual const word& constraintType() const + { + return type(); + } + //- Accumulate the effect of constraint direction of this patch virtual void applyConstraint ( diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.H index 9cdb82b2e3..6224e0c947 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.H +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.H @@ -130,6 +130,12 @@ public: } } + //- Return the constraint type this pointPatch implements. + virtual const word& constraintType() const + { + return type(); + } + //- Return processor number int myProcNo() const { diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/symmetry/symmetryPointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/symmetry/symmetryPointPatch.H index 16d66dccf8..cc66f9c505 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/symmetry/symmetryPointPatch.H +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/symmetry/symmetryPointPatch.H @@ -73,6 +73,12 @@ public: // Member Functions + //- Return the constraint type this pointPatch implements. + virtual const word& constraintType() const + { + return type(); + } + //- Accumulate the effect of constraint direction of this patch virtual void applyConstraint ( diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/wedge/wedgePointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/wedge/wedgePointPatch.H index 0de34e8661..0841de7f9c 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/wedge/wedgePointPatch.H +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/wedge/wedgePointPatch.H @@ -73,6 +73,12 @@ public: // Member Functions + //- Return the constraint type this pointPatch implements. + virtual const word& constraintType() const + { + return type(); + } + //- Accumulate the effect of constraint direction of this patch virtual void applyConstraint ( diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatch.H index 482c10128f..0bd6842743 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatch.H +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatch.H @@ -158,6 +158,12 @@ public: //- Return point normals virtual const vectorField& pointNormals() const = 0; + //- Return the constraint type this pointPatch implements. + virtual const word& constraintType() const + { + return word::null; + } + //- Accumulate the effect of constraint direction of this patch virtual void applyConstraint ( From 1cdcfd729192c5f049ce286d6b61beda8d1f5ada Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 13 Apr 2010 16:49:18 +0100 Subject: [PATCH 3/6] ENH: new pointPatchField type cyclicSlip. --- src/OpenFOAM/Make/files | 1 + .../cyclicSlip/cyclicSlipPointPatchField.C | 122 ++++++++++++++ .../cyclicSlip/cyclicSlipPointPatchField.H | 154 ++++++++++++++++++ .../cyclicSlip/cyclicSlipPointPatchFields.C | 43 +++++ .../cyclicSlip/cyclicSlipPointPatchFields.H | 49 ++++++ 5 files changed, 369 insertions(+) create mode 100644 src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchField.C create mode 100644 src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchField.H create mode 100644 src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchFields.C create mode 100644 src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchFields.H diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 17da5aefef..ed23f471d5 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -506,6 +506,7 @@ $(constraintPointPatchFields)/empty/emptyPointPatchFields.C $(constraintPointPatchFields)/symmetry/symmetryPointPatchFields.C $(constraintPointPatchFields)/wedge/wedgePointPatchFields.C $(constraintPointPatchFields)/cyclic/cyclicPointPatchFields.C +$(constraintPointPatchFields)/cyclicSlip/cyclicSlipPointPatchFields.C $(constraintPointPatchFields)/processor/processorPointPatchFields.C derivedPointPatchFields = $(pointPatchFields)/derived diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchField.C new file mode 100644 index 0000000000..7db347c5a6 --- /dev/null +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchField.C @@ -0,0 +1,122 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 "cyclicSlipPointPatchField.H" +#include "pointConstraint.H" +#include "transformField.H" +#include "symmTransformField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +cyclicSlipPointPatchField::cyclicSlipPointPatchField +( + const pointPatch& p, + const DimensionedField& iF +) +: + cyclicPointPatchField(p, iF) +{} + + +template +cyclicSlipPointPatchField::cyclicSlipPointPatchField +( + const pointPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + cyclicPointPatchField(p, iF, dict) +{} + + +template +cyclicSlipPointPatchField::cyclicSlipPointPatchField +( + const cyclicSlipPointPatchField& ptf, + const pointPatch& p, + const DimensionedField& iF, + const pointPatchFieldMapper& mapper +) +: + cyclicPointPatchField(ptf, p, iF, mapper) +{} + + +template +cyclicSlipPointPatchField::cyclicSlipPointPatchField +( + const cyclicSlipPointPatchField& ptf, + const DimensionedField& iF +) +: + cyclicPointPatchField(ptf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void cyclicSlipPointPatchField::evaluate(const Pstream::commsTypes) +{ + const vectorField& nHat = this->patch().pointNormals(); + + tmp > tvalues = + ( + ( + this->patchInternalField() + + transform(I - 2.0*sqr(nHat), this->patchInternalField()) + )/2.0 + ); + + // Get internal field to insert values into + Field& iF = const_cast&>(this->internalField()); + + setInInternalField(iF, tvalues()); +} + + +template +void cyclicSlipPointPatchField::applyConstraint +( + const label pointi, + pointConstraint& pc +) const +{ + pc.applyConstraint(this->patch().pointNormals()[pointi]); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchField.H new file mode 100644 index 0000000000..52c59ab1b6 --- /dev/null +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchField.H @@ -0,0 +1,154 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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::cyclicSlipPointPatchField + +Description + Specialisation of cyclic that constrains to the patch + +SourceFiles + cyclicSlipPointPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicSlipPointPatchField_H +#define cyclicSlipPointPatchField_H + +#include "cyclicPointPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class cyclicSlipPointPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template +class cyclicSlipPointPatchField +: + public cyclicPointPatchField +{ + +public: + + //- Runtime type information + TypeName("cyclicSlip"); + + + // Constructors + + //- Construct from patch and internal field + cyclicSlipPointPatchField + ( + const pointPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + cyclicSlipPointPatchField + ( + const pointPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given patchField onto a new patch + cyclicSlipPointPatchField + ( + const cyclicSlipPointPatchField&, + const pointPatch&, + const DimensionedField&, + const pointPatchFieldMapper& + ); + + //- Construct and return a clone + virtual autoPtr > clone() const + { + return autoPtr > + ( + new cyclicSlipPointPatchField + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + cyclicSlipPointPatchField + ( + const cyclicSlipPointPatchField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual autoPtr > clone + ( + const DimensionedField& iF + ) const + { + return autoPtr > + ( + new cyclicSlipPointPatchField + ( + *this, iF + ) + ); + } + + + // Member functions + + //- Update the patch field + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::blocking + ); + + //- Accumulate the effect of constraint direction of this patch + virtual void applyConstraint + ( + const label pointi, + pointConstraint& + ) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "cyclicSlipPointPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchFields.C b/src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchFields.C new file mode 100644 index 0000000000..71e09f575f --- /dev/null +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchFields.C @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 "cyclicSlipPointPatchFields.H" +#include "pointPatchFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makePointPatchFields(cyclicSlip); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchFields.H b/src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchFields.H new file mode 100644 index 0000000000..da2196d9be --- /dev/null +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchFields.H @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicSlipPointPatchFields_H +#define cyclicSlipPointPatchFields_H + +#include "cyclicSlipPointPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePointPatchFieldTypedefs(cyclicSlip); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // From 3c060421798a05412c4e982e2facee9c2192e61a Mon Sep 17 00:00:00 2001 From: graham Date: Tue, 13 Apr 2010 18:24:54 +0100 Subject: [PATCH 4/6] ENH: particleForces. Adding paramagnetic force. Adding d to calcCoupled/calcNonCoupled arguments and call. --- .../KinematicParcel/KinematicParcel.C | 25 +++++- .../particleForces/particleForces.C | 90 +++++++++++++++++-- .../particleForces/particleForces.H | 31 ++++++- 3 files changed, 133 insertions(+), 13 deletions(-) diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C index a381c9d431..e17e7138d6 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C @@ -160,10 +160,27 @@ const Foam::vector Foam::KinematicParcel::calcVelocity const scalar utc = td.cloud().drag().utc(Re, d, mu) + ROOTVSMALL; // Momentum source due to particle forces - const vector FCoupled = - mass*td.cloud().forces().calcCoupled(cellI, dt, rhoc_, rho, Uc_, U); - const vector FNonCoupled = - mass*td.cloud().forces().calcNonCoupled(cellI, dt, rhoc_, rho, Uc_, U); + const vector FCoupled = mass*td.cloud().forces().calcCoupled + ( + cellI, + dt, + rhoc_, + rho, + Uc_, + U, + d + ); + + const vector FNonCoupled = mass*td.cloud().forces().calcNonCoupled + ( + cellI, + dt, + rhoc_, + rho, + Uc_, + U, + d + ); // New particle velocity diff --git a/src/lagrangian/intermediate/particleForces/particleForces.C b/src/lagrangian/intermediate/particleForces/particleForces.C index 265f9b59ae..938549a734 100644 --- a/src/lagrangian/intermediate/particleForces/particleForces.C +++ b/src/lagrangian/intermediate/particleForces/particleForces.C @@ -27,6 +27,8 @@ License #include "fvMesh.H" #include "volFields.H" #include "fvcGrad.H" +#include "mathematicalConstants.H" +#include "electromagneticConstants.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -41,16 +43,25 @@ Foam::particleForces::particleForces dict_(dict.subDict("particleForces")), g_(g), gradUPtr_(NULL), + gradHPtr_(NULL), gravity_(dict_.lookup("gravity")), virtualMass_(dict_.lookup("virtualMass")), Cvm_(0.0), pressureGradient_(dict_.lookup("pressureGradient")), - UName_(dict_.lookupOrDefault("U", "U")) + paramagnetic_(dict_.lookup("paramagnetic")), + chi_(0.0), + UName_(dict_.lookupOrDefault("U", "U")), + HName_(dict_.lookupOrDefault("H", "H")) { if (virtualMass_) { dict_.lookup("Cvm") >> Cvm_; } + + if (paramagnetic_) + { + dict_.lookup("chi") >> chi_; + } } @@ -60,11 +71,15 @@ Foam::particleForces::particleForces(const particleForces& f) dict_(f.dict_), g_(f.g_), gradUPtr_(f.gradUPtr_), + gradHPtr_(f.gradHPtr_), gravity_(f.gravity_), virtualMass_(f.virtualMass_), Cvm_(f.Cvm_), pressureGradient_(f.pressureGradient_), - UName_(f.UName_) + paramagnetic_(f.paramagnetic_), + chi_(f.chi_), + UName_(f.UName_), + HName_(f.HName_) {} @@ -102,18 +117,42 @@ Foam::Switch Foam::particleForces::virtualMass() const } +Foam::scalar Foam::particleForces::Cvm() const +{ + return Cvm_; +} + + Foam::Switch Foam::particleForces::pressureGradient() const { return pressureGradient_; } +Foam::Switch Foam::particleForces::paramagnetic() const +{ + return paramagnetic_; +} + + +Foam::scalar Foam::particleForces::chi() const +{ + return chi_; +} + + const Foam::word& Foam::particleForces::UName() const { return UName_; } +const Foam::word& Foam::particleForces::HName() const +{ + return HName_; +} + + void Foam::particleForces::cacheFields(const bool store) { if (store && pressureGradient_) @@ -129,6 +168,20 @@ void Foam::particleForces::cacheFields(const bool store) gradUPtr_ = NULL; } } + + if (store && paramagnetic_) + { + const volVectorField& H = mesh_.lookupObject(HName_); + gradHPtr_ = fvc::grad(H).ptr(); + } + else + { + if (gradHPtr_) + { + delete gradHPtr_; + gradHPtr_ = NULL; + } + } } @@ -139,7 +192,8 @@ Foam::vector Foam::particleForces::calcCoupled const scalar rhoc, const scalar rho, const vector& Uc, - const vector& U + const vector& U, + const scalar d ) const { vector Ftot = vector::zero; @@ -172,7 +226,8 @@ Foam::vector Foam::particleForces::calcNonCoupled const scalar rhoc, const scalar rho, const vector& Uc, - const vector& U + const vector& U, + const scalar d ) const { vector Ftot = vector::zero; @@ -183,9 +238,34 @@ Foam::vector Foam::particleForces::calcNonCoupled Ftot += g_*(1.0 - rhoc/rho); } + // Magnetic field force + + if (paramagnetic_) + { + const volVectorField& H = mesh_.lookupObject(HName_); + + const volTensorField& gradH = *gradHPtr_; + + Ftot += + 3.0*constant::electromagnetic::mu0.value()/rho + *chi_/(chi_ + 3) + *(H[cellI] & gradH[cellI]); + + // force is: + + // 4.0 + // *constant::mathematical::pi + // *constant::electromagnetic::mu0.value() + // *pow3(d/2) + // *chi/(chi + 3) + // *(H[cellI] & gradH[cellI]); + + // which is divided by mass ((4/3)*pi*r^3*rho) to produce + // acceleration + } + return Ftot; } // ************************************************************************* // - diff --git a/src/lagrangian/intermediate/particleForces/particleForces.H b/src/lagrangian/intermediate/particleForces/particleForces.H index 87abf7a7d0..19c7b1b784 100644 --- a/src/lagrangian/intermediate/particleForces/particleForces.H +++ b/src/lagrangian/intermediate/particleForces/particleForces.H @@ -69,6 +69,9 @@ class particleForces //- Velocity gradient field const volTensorField* gradUPtr_; + //- Magnetic field strength gradient field + const volTensorField* gradHPtr_; + // Forces to include in particle motion evaluation @@ -84,12 +87,21 @@ class particleForces //- Pressure gradient Switch pressureGradient_; + //- Paramagnetic force + Switch paramagnetic_; + + //- Magnetic susceptibility of particle + scalar chi_; + // Additional info - //- Name of velucity field - default = "U" + //- Name of velocity field - default = "U" const word UName_; + //- Name of magnetic field strength field - default = "H" + const word HName_; + public: @@ -128,7 +140,7 @@ public: Switch virtualMass() const; //- Return virtual mass force coefficient - Switch Cvm() const; + scalar Cvm() const; //- Return pressure gradient force activate switch Switch pressureGradient() const; @@ -136,6 +148,15 @@ public: //- Return name of velocity field const word& UName() const; + //- Return paramagnetic force activate switch + Switch paramagnetic() const; + + //- Return magnetic susceptibility + scalar chi() const; + + //- Return name of velocity field + const word& HName() const; + // Evaluation @@ -150,7 +171,8 @@ public: const scalar rhoc, const scalar rho, const vector& Uc, - const vector& U + const vector& U, + const scalar d ) const; //- Calculate external forces applied to the particles @@ -161,7 +183,8 @@ public: const scalar rhoc, const scalar rho, const vector& Uc, - const vector& U + const vector& U, + const scalar d ) const; }; From 55cd7409d8d3565df68651546c3bae86ae49b7b5 Mon Sep 17 00:00:00 2001 From: graham Date: Wed, 14 Apr 2010 09:51:46 +0100 Subject: [PATCH 5/6] STYLE: particleForces. Rename variable chi -> magneticSusceptibility. --- .../intermediate/particleForces/particleForces.C | 14 +++++++------- .../intermediate/particleForces/particleForces.H | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lagrangian/intermediate/particleForces/particleForces.C b/src/lagrangian/intermediate/particleForces/particleForces.C index 938549a734..a9c11aa81f 100644 --- a/src/lagrangian/intermediate/particleForces/particleForces.C +++ b/src/lagrangian/intermediate/particleForces/particleForces.C @@ -49,7 +49,7 @@ Foam::particleForces::particleForces Cvm_(0.0), pressureGradient_(dict_.lookup("pressureGradient")), paramagnetic_(dict_.lookup("paramagnetic")), - chi_(0.0), + magneticSusceptibility_(0.0), UName_(dict_.lookupOrDefault("U", "U")), HName_(dict_.lookupOrDefault("H", "H")) { @@ -60,7 +60,7 @@ Foam::particleForces::particleForces if (paramagnetic_) { - dict_.lookup("chi") >> chi_; + dict_.lookup("magneticSusceptibility") >> magneticSusceptibility_; } } @@ -77,7 +77,7 @@ Foam::particleForces::particleForces(const particleForces& f) Cvm_(f.Cvm_), pressureGradient_(f.pressureGradient_), paramagnetic_(f.paramagnetic_), - chi_(f.chi_), + magneticSusceptibility_(f.magneticSusceptibility_), UName_(f.UName_), HName_(f.HName_) {} @@ -135,9 +135,9 @@ Foam::Switch Foam::particleForces::paramagnetic() const } -Foam::scalar Foam::particleForces::chi() const +Foam::scalar Foam::particleForces::magneticSusceptibility() const { - return chi_; + return magneticSusceptibility_; } @@ -248,7 +248,7 @@ Foam::vector Foam::particleForces::calcNonCoupled Ftot += 3.0*constant::electromagnetic::mu0.value()/rho - *chi_/(chi_ + 3) + *magneticSusceptibility_/(magneticSusceptibility_ + 3) *(H[cellI] & gradH[cellI]); // force is: @@ -257,7 +257,7 @@ Foam::vector Foam::particleForces::calcNonCoupled // *constant::mathematical::pi // *constant::electromagnetic::mu0.value() // *pow3(d/2) - // *chi/(chi + 3) + // *magneticSusceptibility/(magneticSusceptibility + 3) // *(H[cellI] & gradH[cellI]); // which is divided by mass ((4/3)*pi*r^3*rho) to produce diff --git a/src/lagrangian/intermediate/particleForces/particleForces.H b/src/lagrangian/intermediate/particleForces/particleForces.H index 19c7b1b784..d7e891ab65 100644 --- a/src/lagrangian/intermediate/particleForces/particleForces.H +++ b/src/lagrangian/intermediate/particleForces/particleForces.H @@ -91,7 +91,7 @@ class particleForces Switch paramagnetic_; //- Magnetic susceptibility of particle - scalar chi_; + scalar magneticSusceptibility_; // Additional info @@ -152,7 +152,7 @@ public: Switch paramagnetic() const; //- Return magnetic susceptibility - scalar chi() const; + scalar magneticSusceptibility() const; //- Return name of velocity field const word& HName() const; From c948fadb10bb06282d786f0528515056660d84cc Mon Sep 17 00:00:00 2001 From: graham Date: Wed, 14 Apr 2010 13:59:58 +0100 Subject: [PATCH 6/6] ENH: particleForces. Not caching gradH field, looking up HdotGradH field directly. Renaming Ftot to accelTot to remind that the functions return accelerations. --- .../particleForces/particleForces.C | 53 +++++++------------ .../particleForces/particleForces.H | 12 ++--- 2 files changed, 24 insertions(+), 41 deletions(-) diff --git a/src/lagrangian/intermediate/particleForces/particleForces.C b/src/lagrangian/intermediate/particleForces/particleForces.C index a9c11aa81f..7778736683 100644 --- a/src/lagrangian/intermediate/particleForces/particleForces.C +++ b/src/lagrangian/intermediate/particleForces/particleForces.C @@ -43,7 +43,6 @@ Foam::particleForces::particleForces dict_(dict.subDict("particleForces")), g_(g), gradUPtr_(NULL), - gradHPtr_(NULL), gravity_(dict_.lookup("gravity")), virtualMass_(dict_.lookup("virtualMass")), Cvm_(0.0), @@ -51,7 +50,7 @@ Foam::particleForces::particleForces paramagnetic_(dict_.lookup("paramagnetic")), magneticSusceptibility_(0.0), UName_(dict_.lookupOrDefault("U", "U")), - HName_(dict_.lookupOrDefault("H", "H")) + HdotGradHName_(dict_.lookupOrDefault("HdotGradH", "HdotGradH")) { if (virtualMass_) { @@ -71,7 +70,6 @@ Foam::particleForces::particleForces(const particleForces& f) dict_(f.dict_), g_(f.g_), gradUPtr_(f.gradUPtr_), - gradHPtr_(f.gradHPtr_), gravity_(f.gravity_), virtualMass_(f.virtualMass_), Cvm_(f.Cvm_), @@ -79,7 +77,7 @@ Foam::particleForces::particleForces(const particleForces& f) paramagnetic_(f.paramagnetic_), magneticSusceptibility_(f.magneticSusceptibility_), UName_(f.UName_), - HName_(f.HName_) + HdotGradHName_(f.HdotGradHName_) {} @@ -147,9 +145,9 @@ const Foam::word& Foam::particleForces::UName() const } -const Foam::word& Foam::particleForces::HName() const +const Foam::word& Foam::particleForces::HdotGradHName() const { - return HName_; + return HdotGradHName_; } @@ -168,20 +166,6 @@ void Foam::particleForces::cacheFields(const bool store) gradUPtr_ = NULL; } } - - if (store && paramagnetic_) - { - const volVectorField& H = mesh_.lookupObject(HName_); - gradHPtr_ = fvc::grad(H).ptr(); - } - else - { - if (gradHPtr_) - { - delete gradHPtr_; - gradHPtr_ = NULL; - } - } } @@ -196,7 +180,7 @@ Foam::vector Foam::particleForces::calcCoupled const scalar d ) const { - vector Ftot = vector::zero; + vector accelTot = vector::zero; // Virtual mass force if (virtualMass_) @@ -205,17 +189,17 @@ Foam::vector Foam::particleForces::calcCoupled ( "Foam::particleForces::calcCoupled(...) - virtual mass force" ); -// Ftot += Cvm_*rhoc/rho*d(Uc - U)/dt; +// accelTot += Cvm_*rhoc/rho*d(Uc - U)/dt; } // Pressure gradient force if (pressureGradient_) { const volTensorField& gradU = *gradUPtr_; - Ftot += rhoc/rho*(U & gradU[cellI]); + accelTot += rhoc/rho*(U & gradU[cellI]); } - return Ftot; + return accelTot; } @@ -230,26 +214,27 @@ Foam::vector Foam::particleForces::calcNonCoupled const scalar d ) const { - vector Ftot = vector::zero; + vector accelTot = vector::zero; // Gravity force if (gravity_) { - Ftot += g_*(1.0 - rhoc/rho); + accelTot += g_*(1.0 - rhoc/rho); } // Magnetic field force if (paramagnetic_) { - const volVectorField& H = mesh_.lookupObject(HName_); + const volVectorField& HdotGradH = mesh_.lookupObject + ( + HdotGradHName_ + ); - const volTensorField& gradH = *gradHPtr_; - - Ftot += + accelTot += 3.0*constant::electromagnetic::mu0.value()/rho *magneticSusceptibility_/(magneticSusceptibility_ + 3) - *(H[cellI] & gradH[cellI]); + *HdotGradH[cellI]; // force is: @@ -257,14 +242,14 @@ Foam::vector Foam::particleForces::calcNonCoupled // *constant::mathematical::pi // *constant::electromagnetic::mu0.value() // *pow3(d/2) - // *magneticSusceptibility/(magneticSusceptibility + 3) - // *(H[cellI] & gradH[cellI]); + // *magneticSusceptibility_/(magneticSusceptibility_ + 3) + // *HdotGradH[cellI]; // which is divided by mass ((4/3)*pi*r^3*rho) to produce // acceleration } - return Ftot; + return accelTot; } diff --git a/src/lagrangian/intermediate/particleForces/particleForces.H b/src/lagrangian/intermediate/particleForces/particleForces.H index d7e891ab65..cc47366533 100644 --- a/src/lagrangian/intermediate/particleForces/particleForces.H +++ b/src/lagrangian/intermediate/particleForces/particleForces.H @@ -69,9 +69,6 @@ class particleForces //- Velocity gradient field const volTensorField* gradUPtr_; - //- Magnetic field strength gradient field - const volTensorField* gradHPtr_; - // Forces to include in particle motion evaluation @@ -99,8 +96,9 @@ class particleForces //- Name of velocity field - default = "U" const word UName_; - //- Name of magnetic field strength field - default = "H" - const word HName_; + //- Name of paramagnetic field strength field - default = + // "HdotGradH" + const word HdotGradHName_; public: @@ -154,8 +152,8 @@ public: //- Return magnetic susceptibility scalar magneticSusceptibility() const; - //- Return name of velocity field - const word& HName() const; + //- Return name of paramagnetic field strength field + const word& HdotGradHName() const; // Evaluation