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-2024 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  return
40  (
41  lookupName.empty()
42  ? obr.getObjectPtr<polySurface>(this->name())
43  : obr.getObjectPtr<polySurface>(lookupName)
44  );
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  auto* surfptr = obr.getObjectPtr<polySurface>(lookupName);
60 
61  if (!surfptr)
62  {
63  surfptr = new polySurface(lookupName, obr);
64  regIOobject::store(surfptr);
65  }
66 
67  // Copy in geometry (removes existing fields if sizes have changed)
68  surfptr->copySurface(*this);
69 
70  return surfptr;
71 }
72 
73 
75 (
76  objectRegistry& obr,
77  word lookupName
78 ) const
79 {
80  return
81  (
82  lookupName.empty()
83  ? polySurface::Delete(this->name(), obr)
84  : polySurface::Delete(lookupName, obr)
85  );
86 }
87 
88 
89 // ************************************************************************* //
A surface mesh consisting of general polygon faces and capable of holding fields. ...
Definition: polySurface.H:62
static bool Delete(const word &surfName, const objectRegistry &)
Remove named surface from specified registry.
Definition: polySurface.C:170
bool store()
Register object with its registry and transfer ownership to the registry.
Definition: regIOobjectI.H:36
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.