sampledSurfaceRegister.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-2022 OpenCFD 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 "sampledSurface.H"
29 #include "MeshedSurface.H"
30 
31 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 
34 (
35  const objectRegistry& obr,
36  word lookupName
37 ) const
38 {
39  if (lookupName.empty())
40  {
41  lookupName = this->name();
42  }
43 
44  return obr.getObjectPtr<polySurface>(lookupName);
45 }
46 
47 
49 (
50  objectRegistry& obr,
51  word lookupName
52 ) const
53 {
54  if (lookupName.empty())
55  {
56  lookupName = this->name();
57  }
58 
59  polySurface* surfptr = getRegistrySurface(obr, lookupName);
60 
61  if (!surfptr)
62  {
63  // Default construct and add to registry (owned by registry)
64  surfptr = new polySurface(lookupName, obr, true);
65  }
66 
67  surfptr->copySurface(*this); // Copy in geometry (removes old fields)
68 
69  return surfptr;
70 }
71 
72 
74 (
75  objectRegistry& obr,
76  word lookupName
77 ) const
78 {
79  polySurface* surfptr = getRegistrySurface(obr, lookupName);
80  return obr.checkOut(surfptr);
81 }
82 
83 
84 // ************************************************************************* //
A surface mesh consisting of general polygon faces and capable of holding fields. ...
Definition: polySurface.H:62
bool checkOut(regIOobject *io) const
Remove a regIOobject from registry and free memory if the object is ownedByRegistry. A nullptr is ignored.
const word & name() const noexcept
Name of surface.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
A class for handling words, derived from Foam::string.
Definition: word.H:63
Type * getObjectPtr(const word &name, const bool recursive=false) const
Return non-const pointer to the object of the given Type, using a const-cast to have it behave like a...
polySurface * getRegistrySurface(const objectRegistry &obr, word lookupName="") const
Get surface from registry if available.
bool removeRegistrySurface(objectRegistry &obr, word lookupName="") const
Remove surface from registry.
Registry of regIOobjects.
polySurface * storeRegistrySurface(objectRegistry &obr, word lookupName="") const
Copy surface into registry.