Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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// ************************************************************************* //
Registry of regIOobjects.
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...
A surface mesh consisting of general polygon faces and capable of holding fields.
Definition polySurface.H:67
void copySurface(const pointField &points, const faceList &faces, bool unused=false)
Update with new contents. Removes existing fields if sizes have changed.
static bool Delete(const word &surfName, const objectRegistry &)
Remove named surface from specified registry.
bool store()
Register object with its registry and transfer ownership to the registry.
polySurface * getRegistrySurface(const objectRegistry &obr, word lookupName="") const
Get surface from registry if available.
polySurface * storeRegistrySurface(objectRegistry &obr, word lookupName="") const
Copy surface into registry.
bool removeRegistrySurface(objectRegistry &obr, word lookupName="") const
Remove surface from registry.
A class for handling words, derived from Foam::string.
Definition word.H:66
auto & name