cutFaceIso.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 DHI
9  Copyright (C) 2018-2019 Johan Roenby
10  Copyright (C) 2019-2020 DLR
11 -------------------------------------------------------------------------------
12 License
13  This file is part of OpenFOAM.
14 
15  OpenFOAM is free software: you can redistribute it and/or modify it
16  under the terms of the GNU General Public License as published by
17  the Free Software Foundation, either version 3 of the License, or
18  (at your option) any later version.
19 
20  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
21  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23  for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
27 
28 \*---------------------------------------------------------------------------*/
29 
30 #include "cutFaceIso.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
35 :
36  cutFace(mesh),
37  mesh_(mesh),
38  f_(f),
39  subFaceCentre_(Zero),
40  subFaceArea_(Zero),
41  subFacePoints_(10),
42  surfacePoints_(4),
43  pointStatus_(10),
44  weight_(10),
45  faceStatus_(-1)
46 {
47  clearStorage();
48 }
49 
50 
51 // * * * * * * * * * * * Public Member Functions * * * * * * * * * * * * * //
52 
54 (
55  const label faceI,
56  const scalar cutValue
57 )
58 {
59  clearStorage();
60  const face& f = mesh_.faces()[faceI];
61  label inLiquid = 0;
62  label firstFullySubmergedPoint = -1;
63 
64  // loop over face
65  forAll(f, i)
66  {
67  // pointStatus is f - cutValue
68  pointStatus_.append(f_[f[i]] - cutValue);
69  if (mag(pointStatus_[i]) < 10 * SMALL)
70  {
71  pointStatus_[i] = 0;
72  }
73  if (pointStatus_[i] > 10 * SMALL)
74  {
75  inLiquid++;
76  if (firstFullySubmergedPoint == -1)
77  {
78  firstFullySubmergedPoint = i;
79  }
80  }
81  }
82 
83  if (inLiquid == f.size()) // fluid face
84  {
85  faceStatus_ = -1;
86  subFaceCentre_ = mesh_.faceCentres()[faceI];
87  subFaceArea_ = mesh_.faceAreas()[faceI];
88  return faceStatus_;
89  }
90  else if (inLiquid == 0) // gas face
91  {
92  faceStatus_ = 1;
93  subFaceCentre_ = Zero;
94  subFaceArea_ = Zero;
95  return faceStatus_;
96  }
97 
99  (
100  faceI,
101  pointStatus_,
102  firstFullySubmergedPoint,
103  subFacePoints_,
104  surfacePoints_,
105  faceStatus_,
106  subFaceCentre_,
107  subFaceArea_
108  );
109 
110  return faceStatus_;
111 }
112 
113 
115 {
116  subFaceCentre_ = Zero;
117  subFaceArea_ = Zero;
118  subFacePoints_.clear();
119  surfacePoints_.clear();
120  pointStatus_.clear();
121  weight_.clear();
122  faceStatus_ = -1;
123 }
124 
125 
126 // ************************************************************************* //
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::cutFaceIso::clearStorage
void clearStorage()
Resets internal variables.
Definition: cutFaceIso.C:114
cutFaceIso.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::Field< scalar >
Foam::cutFaceIso::calcSubFace
label calcSubFace(const label faceI, const scalar cutValue)
Calculate cut points along edges of faceI.
Definition: cutFaceIso.C:54
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam::cutFace
Base class for cutting a face, faceI, of an fvMesh, mesh_, at its intersections.
Definition: cutFace.H:59
f
labelList f(nPoints)
Foam::cutFace::calcSubFace
void calcSubFace(const label faceI, const scalarList &pointStatus, label firstFullySubmergedPoint, DynamicList< point > &subFacePoints, DynamicList< point > &surfacePoints, label &faceStatus, vector &subFaceCentre, vector &subFaceArea)
Definition: cutFace.C:39
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::cutFaceIso::cutFaceIso
cutFaceIso(const fvMesh &mesh, scalarField &f)
Construct from fvMesh and a scalarField.
Definition: cutFaceIso.C:34
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72