cutFacePLIC.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 "cutFacePLIC.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
35 :
36  cutFace(mesh),
37  mesh_(mesh),
38  subFaceCentre_(Zero),
39  subFaceArea_(Zero),
40  subFacePoints_(10),
41  surfacePoints_(4),
42  pointStatus_(10),
43  weight_(10),
44  faceStatus_(-1)
45 {
46  clearStorage();
47 }
48 
49 
50 // * * * * * * * * * * * Public Member Functions * * * * * * * * * * * * * //
51 
53 (
54  const label faceI,
55  const vector& normal,
56  const vector& base
57  )
58 {
59  clearStorage();
60 
61  const face& f = mesh_.faces()[faceI];
62  label inLiquid = 0;
63  label firstFullySubmergedPoint = -1;
64 
65  // loop face
66  forAll(f, i)
67  {
68  // pointStatus is the distance to the plane
69  scalar value = (mesh_.points()[f[i]] - base) & normal;
70  if (mag(value) < SMALL)
71  {
72  value = 0;
73  }
74 
75  pointStatus_.append(value);
76  if (pointStatus_[i] > 0)
77  {
78  inLiquid++;
79  if (firstFullySubmergedPoint == -1)
80  {
81  firstFullySubmergedPoint = i;
82  }
83  }
84  }
85 
86  if (inLiquid == f.size()) // fluid face
87  {
88  faceStatus_ = -1;
89  subFaceCentre_ = mesh_.faceCentres()[faceI];
90  subFaceArea_ = mesh_.faceAreas()[faceI];
91  return faceStatus_;
92  }
93  else if (inLiquid == 0) // gas face
94  {
95  faceStatus_ = 1;
96  subFaceCentre_ = Zero;
97  subFaceArea_ = Zero;
98  return faceStatus_;
99  }
100 
101 
103  (
104  faceI,
105  pointStatus_,
106  firstFullySubmergedPoint,
107  subFacePoints_,
108  surfacePoints_,
109  faceStatus_,
110  subFaceCentre_,
111  subFaceArea_
112  );
113 
114  return faceStatus_;
115 }
116 
117 
119 {
120  subFaceCentre_ = Zero;
121  subFaceArea_ = Zero;
122  subFacePoints_.clear();
123  surfacePoints_.clear();
124  pointStatus_.clear();
125  weight_.clear();
126  faceStatus_ = -1;
127 }
128 
129 
130 // ************************************************************************* //
Foam::cutFacePLIC::calcSubFace
label calcSubFace(const label faceI, const vector &normal, const vector &base)
Calculate cut points along edges of faceI.
Definition: cutFacePLIC.C:53
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::cutFacePLIC::cutFacePLIC
cutFacePLIC(const fvMesh &mesh)
Construct from fvMesh and a scalarField.
Definition: cutFacePLIC.C:34
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
cutFacePLIC.H
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
Foam::cutFacePLIC::clearStorage
void clearStorage()
Resets internal variables.
Definition: cutFacePLIC.C:118
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::Vector< scalar >
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72