reconstructionSchemes.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) 2019-2020 DLR
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 "reconstructionSchemes.H"
29 #include "cutCellPLIC.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(reconstructionSchemes, 0);
36  defineRunTimeSelectionTable(reconstructionSchemes, components);
37 }
38 
39 
40 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
41 
43 {
44  const Time& runTime = alpha1_.mesh().time();
45 
46  label& curTimeIndex = timeIndexAndIter_.first();
47  label& curIter = timeIndexAndIter_.second();
48 
49  // Reset timeIndex and curIter
50  if (curTimeIndex < runTime.timeIndex())
51  {
52  curTimeIndex = runTime.timeIndex();
53  curIter = 0;
54  return false;
55  }
56 
57  if (forceUpdate)
58  {
59  curIter = 0;
60  return false;
61  }
62 
63  // Always reconstruct when subcycling
64  if (runTime.subCycling() != 0)
65  {
66  return false;
67  }
68 
69  ++curIter;
70  if (curIter > 1)
71  {
72  return true;
73  }
74 
75  return false;
76 }
77 
78 
79 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
80 
82 (
83  const word& type,
85  const surfaceScalarField& phi,
86  const volVectorField& U,
87  const dictionary& dict
88 )
89 :
91  (
92  IOobject
93  (
94  "reconstructionScheme",
95  alpha1.time().constant(),
96  alpha1.db(),
97  IOobject::NO_READ,
98  IOobject::NO_WRITE
99  )
100  ),
101  reconstructionSchemesCoeffs_(dict),
102  alpha1_(alpha1),
103  phi_(phi),
104  U_(U),
105  normal_
106  (
107  IOobject
108  (
109  IOobject::groupName("interfaceNormal", alpha1.group()),
110  alpha1_.mesh().time().timeName(),
111  alpha1_.mesh(),
112  IOobject::NO_READ,
113  dict.getOrDefault("writeFields",false)
114  ? IOobject::AUTO_WRITE
115  : IOobject::NO_WRITE
116  ),
117  alpha1_.mesh(),
119  ),
120  centre_
121  (
122  IOobject
123  (
124  IOobject::groupName("interfaceCentre", alpha1.group()),
125  alpha1_.mesh().time().timeName(),
126  alpha1_.mesh(),
127  IOobject::NO_READ,
128  dict.getOrDefault("writeFields",false)
129  ? IOobject::AUTO_WRITE
130  : IOobject::NO_WRITE
131  ),
132  alpha1_.mesh(),
134  ),
135  interfaceCell_(alpha1_.mesh().nCells(), false),
136  interfaceLabels_(0.2*alpha1_.mesh().nCells()),
137  timeIndexAndIter_(0, 0)
138 {}
139 
140 
141 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
142 
144 {
145  reconstruct(false);
146  const fvMesh& mesh = centre_.mesh();
147 
148  cutCellPLIC cellCut(mesh);
149 
150  DynamicList<point> dynPts;
151  DynamicList<face> dynFaces(mesh.nCells()*0.1);
152  bitSet interfaceCellAddressing(mesh.nCells());
153 
154  forAll(interfaceCell_, celli)
155  {
156  if (interfaceCell_[celli])
157  {
158  if (mag(normal_[celli]) != 0)
159  {
160  interfaceCellAddressing.set(celli);
161  vector n = -normal_[celli]/mag(normal_[celli]);
162 
163  scalar cutVal = (centre_[celli] - mesh.C()[celli]) & n;
164  cellCut.calcSubCell(celli, cutVal, n);
165 
166  // cellCut.facePoints() are ordered and not connected
167  // to the other face
168  // append face with the starting label: dynPts.size()
169  dynFaces.append
170  (
171  face(identity(cellCut.facePoints().size(), dynPts.size()))
172  );
173  dynPts.append(cellCut.facePoints());
174  }
175  }
176  }
177 
178 
179  labelList meshCells(interfaceCellAddressing.sortedToc());
180 
181  // Transfer to mesh storage
182  pointField pts(std::move(dynPts));
183  faceList faces(std::move(dynFaces));
184 
185  return interface(std::move(pts), std::move(faces), std::move(meshCells));
186 }
187 
188 
189 // ************************************************************************* //
Foam::Pair::second
const T & second() const noexcept
Return second element, which is also the last element.
Definition: PairI.H:122
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::fvc::reconstruct
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> reconstruct(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcReconstruct.C:56
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::cutCellPLIC::calcSubCell
label calcSubCell(const label celli, const scalar cutValue, const vector &normal)
Sets internal values and returns face status.
Definition: cutCellPLIC.C:60
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::reconstructionSchemes::timeIndexAndIter_
Pair< label > timeIndexAndIter_
Store timeindex/iteration to avoid multiple reconstruction.
Definition: reconstructionSchemes.H:94
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:63
Foam::constant::atomic::group
constexpr const char *const group
Group name for atomic constants.
Definition: atomicConstants.H:52
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
reconstructionSchemes.H
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::DynamicList< point >
interface
interfaceProperties interface(alpha1, U, thermo->transportPropertiesDict())
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::cutCellPLIC
Class for cutting a cell, cellI, of an fvMesh, mesh_, at its intersection with an surface defined by ...
Definition: cutCellPLIC.H:71
Foam::reconstructionSchemes::reconstructionSchemes
reconstructionSchemes(const reconstructionSchemes &)=delete
No copy construct.
alpha1
const volScalarField & alpha1
Definition: setRegionFluidFields.H:8
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::primitiveMesh::nCells
label nCells() const noexcept
Number of mesh cells.
Definition: primitiveMeshI.H:96
Foam::dimArea
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:59
Foam::Field< vector >
Foam::DynamicList::append
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
Definition: DynamicListI.H:511
Foam::reconstructionSchemes::surface
interface surface()
Generated interface surface points/faces.
Definition: reconstructionSchemes.C:143
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::reconstructionSchemes::alpha1_
volScalarField & alpha1_
Reference to the VoF Field.
Definition: reconstructionSchemes.H:73
Foam::fvMesh::C
const volVectorField & C() const
Return cell centres as volVectorField.
Definition: fvMeshGeometry.C:341
timeName
word timeName
Definition: getTimeIndex.H:3
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::dimensioned< vector >
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::cutCellPLIC::facePoints
const DynamicList< point > & facePoints()
Returns the points of the cutting PLICface.
Definition: cutCellPLIC.C:175
U
U
Definition: pEqn.H:72
Foam::reconstructionSchemes::alreadyReconstructed
bool alreadyReconstructed(bool forceUpdate=true) const
Is the interface already up-to-date?
Definition: reconstructionSchemes.C:42
Foam::Vector< scalar >
Foam::List< label >
cutCellPLIC.H
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::identity
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
Definition: labelList.C:38
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
Foam::GeometricField< scalar, fvPatchField, volMesh >
constant
constant condensation/saturation model.
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::reconstructionSchemes::interface
Definition: reconstructionSchemes.H:113