diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointConstraint/pointConstraint.H b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointConstraint/pointConstraint.H index 5b48463befa18f99aecf5859a2e67b5e4c2ad47d..04de1932202e0d5ec1fb5edbf290e83845591efc 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointConstraint/pointConstraint.H +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointConstraint/pointConstraint.H @@ -83,6 +83,10 @@ public: //- Return the accumulated constraint transformation tensor inline tensor constraintTransformation() const; + + //- Return the accumulated unconstrained directions. Directions + // coded as first n rows of tensor. + inline void unconstrainedDirections(label& n, tensor& vecs) const; }; diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointConstraint/pointConstraintI.H b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointConstraint/pointConstraintI.H index 0915a301d4db98a8d20e3a9193c22482e7f2149c..82c1957c3b2ff8a69418d3136739e8c3f7e572dd 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointConstraint/pointConstraintI.H +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointConstraint/pointConstraintI.H @@ -136,6 +136,49 @@ Foam::tensor Foam::pointConstraint::constraintTransformation() const } +void Foam::pointConstraint::unconstrainedDirections(label& n, tensor& tt) +const +{ + n = 3-first(); + + FixedList<vector, 3> vecs; + + if (first() == 0) + { + vecs[0] = vector(1, 0, 0); + vecs[1] = vector(0, 1, 0); + vecs[2] = vector(0, 0, 1); + } + else if (first() == 1) + { + const vector& planeDir = second(); + + vecs[0] = vector(1, 0, 0) - planeDir.x()*planeDir; + + if (mag(vecs[0].x()) < 1e-3) + { + vecs[0] = vector(0, 1, 0) - planeDir.y()*planeDir; + } + + vecs[0] /= mag(vecs[0]); + vecs[1] = vecs[0] ^ planeDir; + vecs[1] /= mag(vecs[1]); + } + else if (first() == 2) + { + vecs[0] = second(); + } + + // Knock out remaining vectors + for (direction dir = n; dir < vecs.size(); dir++) + { + vecs[dir] = vector::zero; + } + + tt = tensor(vecs[0], vecs[1], vecs[2]); +} + + void Foam::combineConstraintsEqOp::operator() ( pointConstraint& x,