Flow123d  release_3.0.0-1106-ga3b2e4c
bc_mesh.cc
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file bc_mesh.cc
15  * @ingroup mesh
16  * @brief Mesh construction
17  */
18 
19 
20 
21 #include "mesh/bc_mesh.hh"
22 #include "mesh/long_idx.hh"
23 #include "mesh/accessors.hh"
24 #include "mesh/partitioning.hh"
25 #include "mesh/neighbours.h"
26 #include "mesh/range_wrapper.hh"
27 #include "la/distribution.hh"
28 
29 
30 
31 BCMesh::BCMesh(Mesh* parent_mesh)
32 : parent_mesh_(parent_mesh),
33  local_part_(nullptr)
34 {
35  this->init_element_vector(0);
36  this->init_node_vector(0);
37 }
38 
39 
41 {
42  if (local_part_!=nullptr) delete local_part_;
43 }
44 
45 
47 {
48  auto bgn_it = make_iter<ElementAccessor<3>>( ElementAccessor<3>(parent_mesh_, parent_mesh_->bulk_size_) );
49  auto end_it = make_iter<ElementAccessor<3>>( ElementAccessor<3>(parent_mesh_, parent_mesh_->element_vec_.size()) );
50  return Range<ElementAccessor<3>>(bgn_it, end_it);
51 }
52 
53 
54 unsigned int BCMesh::n_elements(bool boundary) const {
56 }
57 
58 
60  return parent_mesh_->get_part();
61 }
62 
64  if (local_part_ == nullptr) {
65  local_part_ = new LongIdx[this->n_elements()];
66  unsigned int bc_ele_idx;
67  for (auto ele : parent_mesh_->elements_range())
68  if (ele->boundary_idx_ != NULL)
69  for (unsigned int i=0; i<ele->n_sides(); ++i)
70  if ((int)ele->boundary_idx_[i] != -1) {
71  bc_ele_idx = parent_mesh_->boundary_[ ele->boundary_idx_[i] ].bc_ele_idx_;
72  local_part_[bc_ele_idx - parent_mesh_->bulk_size_] = parent_mesh_->get_local_part()[ele.idx()];
73  }
74  }
75  return local_part_;
76 }
77 
78 
79 bool BCMesh::check_compatible_mesh( Mesh & mesh, vector<LongIdx> & bulk_elements_id, vector<LongIdx> & boundary_elements_id ) {
80  return parent_mesh_->check_compatible_mesh(mesh, bulk_elements_id, boundary_elements_id);
81 }
82 
83 
84 unsigned int BCMesh::n_nodes() const {
85  return parent_mesh_->node_vec_.size();
86 }
87 
88 
90  return ElementAccessor<3>(parent_mesh_, idx+parent_mesh_->bulk_size_);
91 }
92 
93 
int LongIdx
Define type that represents indices of large arrays (elements, nodes, dofs etc.)
Definition: long_idx.hh:22
Class for the mesh partitioning. This should provide:
Definition: partitioning.hh:52
vector< Element > element_vec_
Definition: mesh.h:508
unsigned int size() const
Return size of map.
BCMesh(Mesh *parent_mesh)
Definition: bc_mesh.cc:31
void init_element_vector(unsigned int size)
Initialize element_vec_, set size and reset counters of boundary and bulk elements.
Definition: mesh.cc:1006
virtual const LongIdx * get_local_part()
Definition: mesh.cc:254
unsigned int n_elements(bool boundary=false) const
Returns count of boundary elements of parent mesh.
Definition: bc_mesh.cc:54
BidirectionalMap< int > element_ids_
Maps element ids to indexes into vector element_vec_.
Definition: mesh.h:520
Range< ElementAccessor< 3 > > elements_range() const override
Returns range of boundary elements of parent mesh.
Definition: bc_mesh.cc:46
ElementAccessor< 3 > element_accessor(unsigned int idx) const override
Overwrite Mesh::element_accessor()
Definition: bc_mesh.cc:89
Definition: mesh.h:76
unsigned int n_nodes() const override
Overwrite Mesh::n_nodes()
Definition: bc_mesh.cc:84
bool check_compatible_mesh(Mesh &mesh, vector< LongIdx > &bulk_elements_id, vector< LongIdx > &boundary_elements_id) override
Overwrite Mesh::check_compatible_mesh()
Definition: bc_mesh.cc:79
Partitioning * get_part() override
Overwrite Mesh::get_part()
Definition: bc_mesh.cc:59
vector< Boundary > boundary_
Definition: mesh.h:249
virtual Partitioning * get_part()
Definition: mesh.cc:250
virtual bool check_compatible_mesh(Mesh &mesh, vector< LongIdx > &bulk_elements_id, vector< LongIdx > &boundary_elements_id)
Definition: mesh.cc:779
Range helper class.
LongIdx * local_part_
Distribution of boundary elements to processors.
Definition: bc_mesh.hh:71
vector< Node > node_vec_
Definition: mesh.h:525
virtual Range< ElementAccessor< 3 > > elements_range() const
Returns range of bulk elements.
Definition: mesh.cc:1040
Support classes for parallel programing.
const LongIdx * get_local_part() override
Overwrite Mesh::get_local_part()
Definition: bc_mesh.cc:63
Mesh * parent_mesh_
Pointer to parent (bulk) mesh.
Definition: bc_mesh.hh:68
~BCMesh()
Destructor.
Definition: bc_mesh.cc:40
Implementation of range helper class.
unsigned int bulk_size_
Count of bulk elements.
Definition: mesh.h:514
void init_node_vector(unsigned int size)
Initialize node_vec_, set size.
Definition: mesh.cc:1017