/usr/include/dolfin/mesh/Mesh.h is in libdolfin1.0-dev 1.0.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 | // Copyright (C) 2006-2011 Anders Logg
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
//
// Modified by Johan Hoffman 2007
// Modified by Magnus Vikstrøm 2007
// Modified by Garth N. Wells 2007-2011
// Modified by Niclas Jansson 2008
// Modified by Kristoffer Selim 2008
// Modified by Andre Massing 2009-2010
//
// First added: 2006-05-08
// Last changed: 2011-11-11
#ifndef __MESH_H
#define __MESH_H
#include <string>
#include <utility>
#include <boost/scoped_ptr.hpp>
#include <dolfin/common/types.h>
#include <dolfin/common/Variable.h>
#include <dolfin/common/Hierarchical.h>
#include <dolfin/intersection/IntersectionOperator.h>
#include <dolfin/log/log.h>
#include "MeshData.h"
#include "MeshGeometry.h"
#include "MeshConnectivity.h"
#include "MeshTopology.h"
#include "MeshDomains.h"
namespace dolfin
{
class CellType;
class BoundaryMesh;
class Function;
class LocalMeshData;
class MeshEntity;
template <typename T> class MeshFunction;
class ParallelData;
class SubDomain;
/// A _Mesh_ consists of a set of connected and numbered mesh entities.
///
/// Both the representation and the interface are
/// dimension-independent, but a concrete interface is also provided
/// for standard named mesh entities:
///
/// .. tabularcolumns:: |c|c|c|
///
/// +--------+-----------+-------------+
/// | Entity | Dimension | Codimension |
/// +========+===========+=============+
/// | Vertex | 0 | |
/// +--------+-----------+-------------+
/// | Edge | 1 | |
/// +--------+-----------+-------------+
/// | Face | 2 | |
/// +--------+-----------+-------------+
/// | Facet | | 1 |
/// +--------+-----------+-------------+
/// | Cell | | 0 |
/// +--------+-----------+-------------+
///
/// When working with mesh iterators, all entities and connectivity
/// are precomputed automatically the first time an iterator is
/// created over any given topological dimension or connectivity.
///
/// Note that for efficiency, only entities of dimension zero
/// (vertices) and entities of the maximal dimension (cells) exist
/// when creating a _Mesh_. Other entities must be explicitly created
/// by calling init(). For example, all edges in a mesh may be
/// created by a call to mesh.init(1). Similarly, connectivities
/// such as all edges connected to a given vertex must also be
/// explicitly created (in this case by a call to mesh.init(0, 1)).
class Mesh : public Variable, public Hierarchical<Mesh>
{
public:
/// Create empty mesh
Mesh();
/// Copy constructor.
///
/// *Arguments*
/// mesh (_Mesh_)
/// Object to be copied.
Mesh(const Mesh& mesh);
/// Create mesh from data file.
///
/// *Arguments*
/// filename (std::string)
/// Name of file to load.
explicit Mesh(std::string filename);
/// Create a distributed mesh from local (per process) data.
///
/// *Arguments*
/// local_mesh_data (LocalMeshData)
/// Data from which to build the mesh.
explicit Mesh(LocalMeshData& local_mesh_data);
/// Destructor.
~Mesh();
/// Assignment operator
///
/// *Arguments*
/// mesh (_Mesh_)
/// Another _Mesh_ object.
const Mesh& operator=(const Mesh& mesh);
/// Get number of vertices in mesh.
///
/// *Returns*
/// uint
/// Number of vertices.
///
/// *Example*
/// .. note::
///
/// No example code available for this function.
uint num_vertices() const { return _topology.size(0); }
/// Get number of edges in mesh.
///
/// *Returns*
/// uint
/// Number of edges.
///
/// *Example*
/// .. note::
///
/// No example code available for this function.
uint num_edges() const { return _topology.size(1); }
/// Get number of faces in mesh.
///
/// *Returns*
/// uint
/// Number of faces.
///
/// *Example*
/// .. note::
///
/// No example code available for this function.
uint num_faces() const { return _topology.size(2); }
/// Get number of facets in mesh.
///
/// *Returns*
/// uint
/// Number of facets.
///
/// *Example*
/// .. note::
///
/// No example code available for this function.
uint num_facets() const { return _topology.size(_topology.dim() - 1); }
/// Get number of cells in mesh.
///
/// *Returns*
/// uint
/// Number of cells.
///
/// *Example*
/// .. note::
///
/// No example code available for this function.
uint num_cells() const { return _topology.size(_topology.dim()); }
/// Get number of entities of given topological dimension.
///
/// *Arguments*
/// d (uint)
/// Topological dimension.
///
/// *Returns*
/// uint
/// Number of entities of topological dimension d.
///
/// *Example*
/// .. note::
///
/// No example code available for this function.
uint num_entities(uint d) const { return _topology.size(d); }
/// Get vertex coordinates.
///
/// *Returns*
/// double*
/// Coordinates of all vertices.
///
/// *Example*
/// .. note::
///
/// No example code available for this function.
double* coordinates() { return _geometry.x(); }
/// Return coordinates of all vertices (const version).
const double* coordinates() const { return _geometry.x(); }
/// Get cell connectivity.
///
/// *Returns*
/// uint*
/// Connectivity for all cells.
///
/// *Example*
/// .. note::
///
/// No example code available for this function.
const uint* cells() const { return _topology(_topology.dim(), 0)(); }
/// Get number of entities of given topological dimension.
///
/// *Arguments*
/// dim (uint)
/// Topological dimension.
///
/// *Returns*
/// uint
/// Number of entities of topological dimension d.
///
/// *Example*
/// .. note::
///
/// No example code available for this function.
uint size(uint dim) const { return _topology.size(dim); }
/// Get mesh topology.
///
/// *Returns*
/// _MeshTopology_
/// The topology object associated with the mesh.
MeshTopology& topology() { return _topology; }
/// Get mesh topology (const version).
const MeshTopology& topology() const { return _topology; }
/// Get mesh geometry.
///
/// *Returns*
/// _MeshGeometry_
/// The geometry object associated with the mesh.
MeshGeometry& geometry() { return _geometry; }
/// Get mesh geometry (const version).
const MeshGeometry& geometry() const { return _geometry; }
/// Get mesh (sub)domains.
///
/// *Returns*
/// _MeshDomains_
/// The (sub)domains associated with the mesh.
MeshDomains& domains() { return _domains; }
/// Get mesh (sub)domains.
const MeshDomains& domains() const { return _domains; }
/// Get intersection operator.
///
/// *Returns*
/// _IntersectionOperator_
/// The intersection operator object associated with the mesh.
IntersectionOperator& intersection_operator();
/// Return intersection operator (const version);
const IntersectionOperator& intersection_operator() const;
/// Get mesh data.
///
/// *Returns*
/// _MeshData_
/// The mesh data object associated with the mesh.
MeshData& data();
/// Get mesh data (const version).
const MeshData& data() const;
/// Get parallel mesh data.
///
/// *Returns*
/// _ParallelData_
/// The parallel data object associated with the mesh.
ParallelData& parallel_data();
/// Get parallel mesh data (const version).
const ParallelData& parallel_data() const;
/// Get mesh cell type.
///
/// *Returns*
/// _CellType_
/// The cell type object associated with the mesh.
CellType& type() { dolfin_assert(_cell_type); return *_cell_type; }
/// Get mesh cell type (const version).
const CellType& type() const { dolfin_assert(_cell_type); return *_cell_type; }
/// Compute entities of given topological dimension.
///
/// *Arguments*
/// dim (uint)
/// Topological dimension.
///
/// *Returns*
/// uint
/// Number of created entities.
uint init(uint dim) const;
/// Compute connectivity between given pair of dimensions.
///
/// *Arguments*
/// d0 (uint)
/// Topological dimension.
///
/// d1 (uint)
/// Topological dimension.
void init(uint d0, uint d1) const;
/// Compute all entities and connectivity.
void init() const;
/// Clear all mesh data.
void clear();
/// Clean out all auxiliary topology data. This clears all
/// topological data, except the connectivity between cells and
/// vertices.
void clean();
/// Order all mesh entities.
///
/// .. seealso::
///
/// UFC documentation (put link here!)
void order();
/// Renumber mesh entities by coloring. This function is currently
/// restricted to renumbering by cell coloring. The cells
/// (cell-vertex connectivity) and the coordinates of the mesh are
/// renumbered to improve the locality within each color. It is
/// assumed that the mesh has already been colored and that only
/// cell-vertex connectivity exists as part of the mesh.
Mesh renumber_by_color() const;
/// Check if mesh is ordered according to the UFC numbering convention.
///
/// *Returns*
/// bool
/// The return values is true iff the mesh is ordered.
bool ordered() const;
/// Move coordinates of mesh according to new boundary coordinates.
///
/// *Arguments*
/// boundary (_BoundaryMesh_)
/// A mesh containing just the boundary cells.
void move(BoundaryMesh& boundary);
/// Move coordinates of mesh according to adjacent mesh with common global
/// vertices.
///
/// *Arguments*
/// mesh (_Mesh_)
/// A _Mesh_ object.
void move(Mesh& mesh);
/// Move coordinates of mesh according to displacement function.
///
/// *Arguments*
/// displacement (_Function_)
/// A _Function_ object.
void move(const Function& displacement);
/// Smooth internal vertices of mesh by local averaging.
///
/// *Arguments*
/// num_iterations (uint)
/// Number of iterations to perform smoothing,
/// default value is 1.
void smooth(uint num_iterations=1);
/// Smooth boundary vertices of mesh by local averaging.
///
/// *Arguments*
/// num_iterations (uint)
/// Number of iterations to perform smoothing,
/// default value is 1.
///
/// harmonic_smoothing (bool)
/// Flag to turn on harmonics smoothing, default
/// value is true.
void smooth_boundary(uint num_iterations=1, bool harmonic_smoothing=true);
/// Snap boundary vertices of mesh to match given sub domain.
///
/// *Arguments*
/// sub_domain (_SubDomain_)
/// A _SubDomain_ object.
///
/// harmonic_smoothing (bool)
/// Flag to turn on harmonics smoothing, default
/// value is true.
void snap_boundary(const SubDomain& sub_domain, bool harmonic_smoothing=true);
/// Color the cells of the mesh such that no two neighboring cells
/// share the same color. A colored mesh keeps a
/// CellFunction<unsigned int> named "cell colors" as mesh data which
/// holds the colors of the mesh.
///
/// *Arguments*
/// coloring_type (std::string)
/// Coloring type, specifying what relation makes two
/// cells neighbors, can be one of "vertex", "edge" or
/// "facet".
///
/// *Returns*
/// MeshFunction<unsigned int>
/// The colors as a mesh function over the cells of the mesh.
const MeshFunction<unsigned int>& color(std::string coloring_type) const;
/// Color the cells of the mesh such that no two neighboring cells
/// share the same color. A colored mesh keeps a
/// CellFunction<unsigned int> named "cell colors" as mesh data which
/// holds the colors of the mesh.
///
/// *Arguments*
/// coloring_type (std::vector<unsigned int>)
/// Coloring type given as list of topological dimensions,
/// specifying what relation makes two mesh entinties neighbors.
///
/// *Returns*
/// MeshFunction<unsigned int>
/// The colors as a mesh function over entities of the mesh.
const MeshFunction<unsigned int>& color(std::vector<unsigned int> coloring_type) const;
/// Compute all cells which are intersected by the given point.
///
/// *Arguments*
/// point (_Point_)
/// A _Point_ object.
///
/// cells (std::set<uint>)
/// A set of indices of all intersected cells.
void intersected_cells(const Point& point,
std::set<uint>& cells) const;
/// Compute all cells which are intersected by any of a vector of points.
///
/// *Arguments*
/// points (std::vector<_Point_>)
/// A vector of _Point_ objects.
///
/// cells (std::set<uint>)
/// A set of indices of all intersected cells.
void intersected_cells(const std::vector<Point>& points,
std::set<uint>& cells) const;
/// Compute all cells which are intersected by the given entity.
///
/// *Arguments*
/// entity (_MeshEntity_)
/// A _MeshEntity_ object.
///
/// cells (std::vector<uint>)
/// A vector of indices of all intersected cells.
void intersected_cells(const MeshEntity& entity,
std::vector<uint>& cells) const;
/// Compute all cells which are intersected by any of a vector of entities.
///
/// *Arguments*
/// entities (std::vector<_MeshEntity_>)
/// A vector of _MeshEntity_ objects.
///
/// cells (std::set<uint>)
/// A vector of indices of all intersected cells.
void intersected_cells(const std::vector<MeshEntity>& entities,
std::set<uint>& cells) const;
/// Compute all cells which are intersected by the given mesh.
///
/// *Arguments*
/// mesh (_Mesh_)
/// A _Mesh_ object.
///
/// cells (std::set<uint>)
/// A set of indices of all intersected cells.
void intersected_cells(const Mesh& mesh,
std::set<uint>& cells) const;
/// Find the cell (if any) containing the given point. If the point
/// is contained in several cells, the first cell is returned.
///
/// *Arguments*
/// point (_Point_)
/// A _Point_ object.
///
/// *Returns*
/// int
/// The index of the cell containing the point. If no cell
/// is found, the return value is -1.
int intersected_cell(const Point& point) const;
/// Find the point in the mesh closest to the given point.
///
/// *Arguments*
/// point (_Point_)
/// A _Point_ object.
///
/// *Returns*
/// _Point_
/// The closest point.
Point closest_point(const Point& point) const;
/// Find the cell in the mesh closest to the given point.
///
/// *Arguments*
/// point (_Point_)
/// A _Point_ object.
///
/// *Returns*
/// uint
/// The index of the closest cell.
///
/// *Example*
/// .. code-block:: c++
///
/// UnitSquare mesh(1, 1);
/// Point point(0.0, 2.0);
/// info("%d", mesh.closest_cell(point));
///
/// output::
///
/// 1
dolfin::uint closest_cell(const Point& point) const;
/// Find the point and corresponding cell closest to the given point.
///
/// *Arguments*
/// point (_Point_)
/// A _Point_ object.
///
/// *Returns*
/// std::pair<_Point_, uint>
/// A pair consisting of the closest point and corresponding cell index.
std::pair<Point, dolfin::uint> closest_point_and_cell(const Point& point) const;
/// Computes the distance between a given point and the mesh
///
/// *Arguments*
/// point (_Point_)
/// A _Point_ object.
///
/// *Returns*
/// double
/// The distance to the mesh.
double distance(const Point& point) const;
/// Compute minimum cell diameter.
///
/// *Returns*
/// double
/// The minimum cell diameter, the diameter is computed as
/// two times the circumradius
/// (http://mathworld.wolfram.com).
///
/// *Example*
/// .. note::
///
/// No example code available for this function.
double hmin() const;
/// Compute maximum cell diameter.
///
/// *Returns*
/// double
/// The maximum cell diameter, the diameter is computed as
/// two times the circumradius
/// (http://mathworld.wolfram.com).
///
/// *Example*
/// .. note::
///
/// No example code available for this function.
double hmax() const;
/// Informal string representation.
///
/// *Arguments*
/// verbose (bool)
/// Flag to turn on additional output.
///
/// *Returns*
/// std::string
/// An informal representation of the mesh.
///
/// *Example*
/// .. note::
///
/// No example code available for this function.
std::string str(bool verbose) const;
private:
// Friends
friend class MeshEditor;
friend class TopologyComputation;
friend class MeshOrdering;
friend class BinaryFile;
// Mesh topology
MeshTopology _topology;
// Mesh geometry
MeshGeometry _geometry;
// Mesh domains
MeshDomains _domains;
// Auxiliary mesh data
MeshData _data;
// Auxiliary parallel mesh data
boost::scoped_ptr<ParallelData> _parallel_data;
// Cell type
CellType* _cell_type;
// Intersection detector
IntersectionOperator _intersection_operator;
// True if mesh has been ordered
mutable bool _ordered;
};
}
#endif
|