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 #include "demandDrivenData.H"
32 
33 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
34 
36 (
37  const objectRegistry& obr,
38  word lookupName
39 ) const
40 {
41  if (lookupName.empty())
42  {
43  lookupName = this->name();
44  }
45 
46  return obr.getObjectPtr<polySurface>(lookupName);
47 }
48 
49 
51 (
52  objectRegistry& obr,
53  word lookupName
54 ) const
55 {
56  if (lookupName.empty())
57  {
58  lookupName = this->name();
59  }
60 
61  polySurface* surfptr = getRegistrySurface(obr, lookupName);
62 
63  if (!surfptr)
64  {
65  // Construct null and add to registry (owned by registry)
66  surfptr = new polySurface(lookupName, obr, true);
67  }
68 
69  surfptr->copySurface(*this); // Copy in geometry (removes old fields)
70 
71  return surfptr;
72 }
73 
74 
76 (
77  objectRegistry& obr,
78  word lookupName
79 ) const
80 {
81  polySurface* surfptr = getRegistrySurface(obr, lookupName);
82  return obr.checkOut(surfptr);
83 }
84 
85 
87 {
88  if (lookupName.empty())
89  {
90  lookupName = this->name();
91  }
92 
93  return mesh().getObjectPtr<surfMesh>(lookupName);
94 }
95 
96 
98 {
99  if (lookupName.empty())
100  {
101  lookupName = this->name();
102  }
103 
104  surfMesh* surfptr = getSurfMesh();
105 
106  if (!surfptr)
107  {
108  // Construct null and add owned by registry
109  surfptr = new surfMesh(lookupName, mesh());
110 
111  surfptr->store(); // Add to registry - owned by registry
112  }
113 
114  surfptr->copySurface(*this); // Copy in geometry (removes old fields)
115 
116  return surfptr;
117 }
118 
119 
121 {
122  surfMesh* surfptr = getSurfMesh(lookupName);
123  return mesh().checkOut(surfptr);
124 }
125 
126 
127 // ************************************************************************* //
Foam::sampledSurface::getRegistrySurface
polySurface * getRegistrySurface(const objectRegistry &obr, word lookupName="") const
Get surface from registry if available.
Definition: sampledSurfaceRegister.C:36
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:62
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::sampledSurface::removeRegistrySurface
bool removeRegistrySurface(objectRegistry &obr, word lookupName="") const
Remove surface from registry.
Definition: sampledSurfaceRegister.C:76
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
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
sampledSurface.H
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
fvMesh.H
Foam::sampledSurface::storeRegistrySurface
polySurface * storeRegistrySurface(objectRegistry &obr, word lookupName="") const
Copy surface into registry.
Definition: sampledSurfaceRegister.C:51
Foam::sampledSurface::removeSurfMesh
bool removeSurfMesh(word lookupName="") const
Remove surface from registry.
Definition: sampledSurfaceRegister.C:120
Foam::sampledSurface::name
const word & name() const
Name of surface.
Definition: sampledSurface.H:321
Foam::sampledSurface::getSurfMesh
surfMesh * getSurfMesh(word lookupName="") const
Get surface from registry if available.
Definition: sampledSurfaceRegister.C:86
Foam::objectRegistry::checkOut
bool checkOut(regIOobject *io) const
Definition: objectRegistry.C:271
Foam::sampledSurface::mesh
const polyMesh & mesh() const
Access to the underlying mesh.
Definition: sampledSurface.H:315
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:97