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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "coupledFaPatch.H"
29 #include "transform.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(coupledFaPatch, 0);
36 }
37 
38 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
39 
41 (
42  const vector& Cf,
43  const vector& Cr,
44  const vector& nf,
45  const vector& nr
46 ) const
47 {
48  if (mag(nf & nr) < 1 - SMALL)
49  {
50  separation_.setSize(0);
51 
52  forwardT_ = tensorField(1, rotationTensor(-nr, nf));
53  reverseT_ = tensorField(1, rotationTensor(nf, -nr));
54  }
55  else
56  {
57  forwardT_.setSize(0);
58  reverseT_.setSize(0);
59 
60  vector separation = (nf & (Cr - Cf))*nf;
61 
62  if (mag(separation) > SMALL)
63  {
64  separation_ = vectorField(1, separation);
65  }
66  else
67  {
68  separation_.setSize(0);
69  }
70  }
71 }
72 
73 
75 (
76  const vectorField& Cf,
77  const vectorField& Cr,
78  const vectorField& nf,
79  const vectorField& nr
80 ) const
81 {
82  if (sum(mag(nf & nr)) < Cf.size() - SMALL)
83  {
84  separation_.setSize(0);
85 
86  forwardT_.setSize(size());
87  reverseT_.setSize(size());
88 
89  forAll(forwardT_, facei)
90  {
91  forwardT_[facei] = rotationTensor(-nr[facei], nf[facei]);
92  reverseT_[facei] = rotationTensor(nf[facei], -nr[facei]);
93  }
94 
95  if (sum(mag(forwardT_ - forwardT_[0])) < SMALL)
96  {
97  forwardT_.setSize(1);
98  reverseT_.setSize(1);
99  }
100  }
101  else
102  {
103  forwardT_.setSize(0);
104  reverseT_.setSize(0);
105 
106  separation_ = (nf&(Cr - Cf))*nf;
107 
108  if (sum(mag(separation_)) < SMALL)
109  {
110  separation_.setSize(0);
111  }
112  else if (sum(mag(separation_ - separation_[0])) < SMALL)
113  {
114  separation_.setSize(1);
115  }
116  }
117 }
118 
119 
120 // ************************************************************************* //
coupledFaPatch.H
Foam::tensorField
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
Definition: primitiveFieldsFwd.H:57
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
Foam::Field< vector >
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::coupledFaPatch::calcTransformTensors
void calcTransformTensors(const vector &Cf, const vector &Cr, const vector &nf, const vector &nr) const
Calculate the uniform transformation tensors.
Definition: coupledFaPatch.C:41
Foam::Vector< scalar >
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::sum
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:327
transform.H
3D tensor transformation operations.
Foam::rotationTensor
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from vector n1 to n2.
Definition: transform.H:51
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)