Loading...
Searching...
No Matches
pod_common.hpp
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * bitpit is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23\*---------------------------------------------------------------------------*/
24
25#ifndef __BITPIT_POD_COMMON_HPP__
26#define __BITPIT_POD_COMMON_HPP__
27
28#include "bitpit_containers.hpp"
29#include "bitpit_patchkernel.hpp"
30
31namespace bitpit {
32
37namespace pod {
46{
47 std::string directory;
48 std::string name;
53 SnapshotFile(const std::string &_directory = std::string(), const std::string &_name = std::string())
54 : directory(_directory), name(_name)
55 {
56 }
57
58};
59
66{
67 std::shared_ptr<VolumeKernel> meshStorage;
69 std::unique_ptr<PiercedStorage<bool>> mask;
70 std::unique_ptr<pod::ScalarStorage> scalar;
71 std::unique_ptr<pod::VectorStorage> vector;
77 : mesh(nullptr)
78 {
79 }
80
92
96 PODField(PODField && field) = default;
97
107 PODField(int nsf, int nvf, VolumeKernel *lmesh = nullptr, const PiercedKernel<long> *lkernel = nullptr)
108 {
109 mesh = lmesh;
110 mask = std::unique_ptr<PiercedStorage<bool>>(new PiercedStorage<bool>(1, lkernel));
111 scalar = std::unique_ptr<pod::ScalarStorage>(new pod::ScalarStorage(nsf, lkernel));
112 vector = std::unique_ptr<pod::VectorStorage>(new pod::VectorStorage(nvf, lkernel));
113 }
114
123 {
124 this->swap(other);
125
126 return *this;
127 }
128
137 {
138 std::swap(meshStorage, other.meshStorage);
139 std::swap(mesh, other.mesh);
140 std::swap(mask, other.mask);
141 std::swap(scalar, other.scalar);
142 std::swap(vector, other.vector);
143 }
144
151 {
152 mask->unsetKernel();
153 mask->setStaticKernel(lkernel);
154 scalar->unsetKernel();
155 scalar->setStaticKernel(lkernel);
156 vector->unsetKernel();
157 vector->setStaticKernel(lkernel);
158 }
159
166 {
167 mask->setDynamicKernel(lkernel, PiercedSyncMaster::SyncMode::SYNC_MODE_JOURNALED);
168 scalar->setDynamicKernel(lkernel, PiercedSyncMaster::SyncMode::SYNC_MODE_JOURNALED);
169 vector->setDynamicKernel(lkernel, PiercedSyncMaster::SyncMode::SYNC_MODE_JOURNALED);
170 }
171
178 {
179 meshStorage.reset();
180 mesh = lmesh;
181 }
182
188 void setMesh(const std::shared_ptr<VolumeKernel> &lmesh)
189 {
191 mesh = meshStorage.get();
192 }
193
198 void clear()
199 {
200 meshStorage.reset();
201
202 mesh = nullptr;
203 mask.reset();
204 scalar.reset();
205 vector.reset();
206 }
207
208};
209
216{
217 std::unique_ptr<pod::ScalarStorage> scalar;
218 std::unique_ptr<pod::VectorStorage> vector;
224 {
225 scalar = nullptr;
226 vector = nullptr;
227 }
228
236 PODMode(int nsf, int nvf, const PiercedKernel<long>* lkernel = nullptr)
237 {
238 scalar = std::unique_ptr<pod::ScalarStorage>(new pod::ScalarStorage(nsf, lkernel));
239 vector = std::unique_ptr<pod::VectorStorage>(new pod::VectorStorage(nvf, lkernel));
240 }
241
245 void clear()
246 {
247 scalar.reset();
248 vector.reset();
249 }
250
251};
252
253}
254
255}
256
257#endif
virtual void reset()
Metafunction for generating a pierced kernel.
Metafunction for generating a pierced storage.
The VolumeKernel class provides an interface for defining volume patches.
PiercedStorage< std::array< double, 3 > > VectorStorage
PiercedStorage< double > ScalarStorage
The PODfield structure is used to store the fields inside POD classes.
void setStaticKernel(const PiercedKernel< long > *lkernel)
std::unique_ptr< pod::ScalarStorage > scalar
PODField & operator=(PODField other)
PODField(int nsf, int nvf, VolumeKernel *lmesh=nullptr, const PiercedKernel< long > *lkernel=nullptr)
std::unique_ptr< PiercedStorage< bool > > mask
void swap(PODField &other)
std::unique_ptr< pod::VectorStorage > vector
void setMesh(const std::shared_ptr< VolumeKernel > &lmesh)
void setMesh(VolumeKernel *lmesh)
PODField(PODField &&field)=default
VolumeKernel * mesh
PODField(const PODField &field)
void setDynamicKernel(PiercedKernel< long > *lkernel)
std::shared_ptr< VolumeKernel > meshStorage
The PODMode structure is used to store the modes inside pod classes.
std::unique_ptr< pod::VectorStorage > vector
PODMode(int nsf, int nvf, const PiercedKernel< long > *lkernel=nullptr)
std::unique_ptr< pod::ScalarStorage > scalar
The SnapFile structure is used to store the file names inside POD classes.
SnapshotFile(const std::string &_directory=std::string(), const std::string &_name=std::string())
--- layout: doxygen_footer ---