Loading...
Searching...
No Matches
pointcloud.cpp
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#include "bitpit_common.hpp"
26
27#include "pointcloud.hpp"
28
29namespace bitpit {
30
40#if BITPIT_ENABLE_MPI==1
51PointCloud::PointCloud(MPI_Comm communicator)
52 : PointKernel(communicator, ADAPTION_MANUAL, PARTITIONING_DISABLED)
53#else
58 : PointKernel(ADAPTION_MANUAL)
59#endif
60{
61}
62
63#if BITPIT_ENABLE_MPI==1
75PointCloud::PointCloud(int dimension, MPI_Comm communicator)
76 : PointKernel(PatchManager::AUTOMATIC_ID, dimension, communicator, ADAPTION_MANUAL, PARTITIONING_DISABLED)
77#else
83PointCloud::PointCloud(int dimension)
84 : PointKernel(PatchManager::AUTOMATIC_ID, dimension, ADAPTION_MANUAL)
85#endif
86{
87}
88
89#if BITPIT_ENABLE_MPI==1
102PointCloud::PointCloud(int id, int dimension, MPI_Comm communicator)
103 : PointKernel(id, dimension, communicator, ADAPTION_MANUAL, PARTITIONING_DISABLED)
104#else
111PointCloud::PointCloud(int id, int dimension)
112 : PointKernel(id, dimension, ADAPTION_MANUAL)
113#endif
114{
115}
116
117#if BITPIT_ENABLE_MPI==1
128PointCloud::PointCloud(std::istream &stream, MPI_Comm communicator)
129 : PointKernel(communicator, ADAPTION_MANUAL, PARTITIONING_DISABLED)
130#else
136PointCloud::PointCloud(std::istream &stream)
137 : PointKernel(ADAPTION_MANUAL)
138#endif
139{
140 // Restore the patch
141 restore(stream);
142}
143
149std::unique_ptr<PatchKernel> PointCloud::clone() const
150{
151 return std::unique_ptr<PointCloud>(new PointCloud(*this));
152}
153
160{
161 const int DUMP_VERSION = 1;
162
163 return DUMP_VERSION;
164}
165
171void PointCloud::_dump(std::ostream &stream) const
172{
173#if BITPIT_ENABLE_MPI==1
174 // Dump works only for serial calculations
175 if (getProcessorCount() != 1) {
176 throw std::runtime_error ("Dump of lineunstructured is implemented only for serial calculations.");
177 }
178#endif
179
180 // Save the vertices
181 dumpVertices(stream);
182
183 // Save the cells
184 dumpCells(stream);
185
186 // Save the interfaces
187 dumpInterfaces(stream);
188}
189
195void PointCloud::_restore(std::istream &stream)
196{
197#if BITPIT_ENABLE_MPI==1
198 // Restore works only for serial calculations
199 if (getProcessorCount() != 1) {
200 throw std::runtime_error ("Restore of lineunstructured is implemented only for serial calculations.");
201 }
202#endif
203
204 // Restore the vertices
205 restoreVertices(stream);
206
207 // Restore the cells
208 restoreCells(stream);
209
210 // Restore the interfaces
211 restoreInterfaces(stream);
212}
213
227long PointCloud::locatePoint(const std::array<double, 3> &point) const
228{
229 BITPIT_UNUSED(point);
230
231 throw std::runtime_error ("The function 'locatePoint' is not implemented yet");
232
233 return false;
234}
235
236}
void dumpInterfaces(std::ostream &stream) const
void dumpVertices(std::ostream &stream) const
void dumpCells(std::ostream &stream) const
void restoreCells(std::istream &stream)
void restoreVertices(std::istream &stream)
void restore(std::istream &stream, bool reregister=false)
void restoreInterfaces(std::istream &stream)
The PatchManager oversee the handling of the patches.
The PointCloud class defines a point cloud.
void _restore(std::istream &stream) override
long locatePoint(const std::array< double, 3 > &point) const override
std::unique_ptr< PatchKernel > clone() const override
void _dump(std::ostream &stream) const override
PointCloud(MPI_Comm communicator)
int _getDumpVersion() const override
#define BITPIT_UNUSED(variable)
Definition compiler.hpp:63
--- layout: doxygen_footer ---