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 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 "fvMesh.H"
30 #include "MeshedSurface.H"
31 
32 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
33 
35 (
36  const objectRegistry& obr,
37  word lookupName
38 ) const
39 {
40  if (lookupName.empty())
41  {
42  lookupName = this->name();
43  }
44 
45  return obr.getObjectPtr<polySurface>(lookupName);
46 }
47 
48 
50 (
51  objectRegistry& obr,
52  word lookupName
53 ) const
54 {
55  if (lookupName.empty())
56  {
57  lookupName = this->name();
58  }
59 
60  polySurface* surfptr = getRegistrySurface(obr, lookupName);
61 
62  if (!surfptr)
63  {
64  // Construct null and add to registry (owned by registry)
65  surfptr = new polySurface(lookupName, obr, true);
66  }
67 
68  surfptr->copySurface(*this); // Copy in geometry (removes old fields)
69 
70  return surfptr;
71 }
72 
73 
75 (
76  objectRegistry& obr,
77  word lookupName
78 ) const
79 {
80  polySurface* surfptr = getRegistrySurface(obr, lookupName);
81  return obr.checkOut(surfptr);
82 }
83 
84 
86 {
87  if (lookupName.empty())
88  {
89  lookupName = this->name();
90  }
91 
92  return mesh().getObjectPtr<surfMesh>(lookupName);
93 }
94 
95 
97 {
98  if (lookupName.empty())
99  {
100  lookupName = this->name();
101  }
102 
103  surfMesh* surfptr = getSurfMesh();
104 
105  if (!surfptr)
106  {
107  // Construct null and add owned by registry
108  surfptr = new surfMesh(lookupName, mesh());
109 
110  surfptr->store(); // Add to registry - owned by registry
111  }
112 
113  surfptr->copySurface(*this); // Copy in geometry (removes old fields)
114 
115  return surfptr;
116 }
117 
118 
120 {
121  surfMesh* surfptr = getSurfMesh(lookupName);
122  return mesh().checkOut(surfptr);
123 }
124 
125 
126 // ************************************************************************* //
Foam::sampledSurface::getRegistrySurface
polySurface * getRegistrySurface(const objectRegistry &obr, word lookupName="") const
Get surface from registry if available.
Definition: sampledSurfaceRegister.C:35
Foam::objectRegistry::getObjectPtr
Type * getObjectPtr(const word &name, const bool recursive=false) const
Definition: objectRegistryTemplates.C:423
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::sampledSurface::removeRegistrySurface
bool removeRegistrySurface(objectRegistry &obr, word lookupName="") const
Remove surface from registry.
Definition: sampledSurfaceRegister.C:75
Foam::surfMesh
A surface mesh consisting of general polygon faces that has IO capabilities and a registry for storin...
Definition: surfMesh.H:63
Foam::regIOobject::store
bool store()
Definition: regIOobjectI.H:37
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::polySurface
A surface mesh consisting of general polygon faces and capable of holding fields.
Definition: polySurface.H:67
Foam::polySurface::copySurface
void copySurface(const pointField &points, const faceList &faces, bool unused=false)
Update with new contents.
Definition: polySurface.C:280
sampledSurface.H
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::sampledSurface::name
const word & name() const noexcept
Name of surface.
Definition: sampledSurface.H:322
fvMesh.H
Foam::sampledSurface::storeRegistrySurface
polySurface * storeRegistrySurface(objectRegistry &obr, word lookupName="") const
Copy surface into registry.
Definition: sampledSurfaceRegister.C:50
Foam::sampledSurface::removeSurfMesh
bool removeSurfMesh(word lookupName="") const
Remove surface from registry.
Definition: sampledSurfaceRegister.C:119
Foam::sampledSurface::mesh
const polyMesh & mesh() const noexcept
Access to the underlying mesh.
Definition: sampledSurface.H:316
Foam::sampledSurface::getSurfMesh
surfMesh * getSurfMesh(word lookupName="") const
Get surface from registry if available.
Definition: sampledSurfaceRegister.C:85
Foam::objectRegistry::checkOut
bool checkOut(regIOobject *io) const
Definition: objectRegistry.C:254
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::surfMesh::copySurface
void copySurface(const pointField &points, const faceList &faces, bool validate=false)
Update with new contents.
Definition: surfMesh.C:298
MeshedSurface.H
Foam::sampledSurface::storeSurfMesh
surfMesh * storeSurfMesh(word lookupName="") const
Copy surface into registry.
Definition: sampledSurfaceRegister.C:96