coupledFaPatch.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016-2017 Wikki Ltd
9  Copyright (C) 2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "coupledFaPatch.H"
30 #include "transform.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
37 }
38 
39 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
40 
42 (
43  const vector& Cf,
44  const vector& Cr,
45  const vector& nf,
46  const vector& nr
47 ) const
48 {
49  if (mag(nf & nr) < 1 - SMALL)
50  {
51  separation_.clear();
52  forwardT_.resize(1);
53  reverseT_.resize(1);
54 
55  forwardT_[0] = rotationTensor(-nr, nf);
56  reverseT_[0] = rotationTensor(nf, -nr);
57  }
58  else
59  {
60  forwardT_.clear();
61  reverseT_.clear();
62 
63  vector separation = (nf & (Cr - Cf))*nf;
64 
65  if (mag(separation) > SMALL)
66  {
67  separation_.resize(1);
68  separation_[0] = separation;
69  }
70  else
71  {
72  separation_.clear();
73  }
74  }
75 }
76 
77 
79 (
80  const vectorField& Cf,
81  const vectorField& Cr,
82  const vectorField& nf,
83  const vectorField& nr
84 ) const
85 {
86  if (sum(mag(nf & nr)) < Cf.size() - SMALL)
87  {
88  separation_.clear();
89 
90  forwardT_.resize_nocopy(size());
91  reverseT_.resize_nocopy(size());
92 
93  forAll(forwardT_, facei)
94  {
95  forwardT_[facei] = rotationTensor(-nr[facei], nf[facei]);
96  reverseT_[facei] = rotationTensor(nf[facei], -nr[facei]);
97  }
98 
99  if (sum(mag(forwardT_ - forwardT_[0])) < SMALL)
100  {
101  forwardT_.resize(1);
102  reverseT_.resize(1);
103  }
104  }
105  else
106  {
107  forwardT_.clear();
108  reverseT_.clear();
109 
110  separation_ = (nf&(Cr - Cf))*nf;
111 
112  if (sum(mag(separation_)) < SMALL)
113  {
114  separation_.clear();
115  }
116  else if (sum(mag(separation_ - separation_[0])) < SMALL)
117  {
118  separation_.resize(1);
119  }
120  }
121 }
122 
123 
124 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
125 
127 {
128  return (edgeCentres() - edgeFaceCentres());
129 }
130 
131 
132 // ************************************************************************* //
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:160
const vectorField & separation() const
Return the offset (distance) vector from one side of the couple.
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from vector n1 to n2.
Definition: transform.H:47
virtual tmp< vectorField > delta() const =0
Return delta (P to N) vectors across coupled patch.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
defineTypeName(manifoldCellsMeshObject)
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ const Field< vector > edgeCentres(faMeshTools::flattenEdgeField(aMesh.edgeCentres(), true))
void clear()
Clear the list, i.e. set size to zero.
Definition: ListI.H:137
3D tensor transformation operations.
Vector< scalar > vector
Definition: vector.H:57
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
coupledFaPatch is an abstract base class for patches that couple regions of the computational domain ...
Field< vector > vectorField
Specialisation of Field<T> for vector.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Namespace for OpenFOAM.
void calcTransformTensors(const vector &Cf, const vector &Cr, const vector &nf, const vector &nr) const
Calculate the uniform transformation tensors.