Flow123d  JS_before_hm-984-g3a19f2f
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 #include "system/index_types.hh"
21 #include "mesh/bc_mesh.hh"
22 #include "mesh/accessors.hh"
23 #include "mesh/partitioning.hh"
24 #include "mesh/neighbours.h"
25 #include "mesh/range_wrapper.hh"
26 #include "la/distribution.hh"
27 
28 
29 
30 BCMesh::BCMesh(Mesh* parent_mesh)
31 : parent_mesh_(parent_mesh),
32  local_part_(nullptr)
33 {
34  this->init_element_vector(0);
35  this->init_node_vector(0);
36 }
37 
38 
40 {
41  if (local_part_!=nullptr) delete local_part_;
42 }
43 
44 
46 {
47  auto bgn_it = make_iter<ElementAccessor<3>>( ElementAccessor<3>(parent_mesh_, parent_mesh_->bulk_size_) );
48  auto end_it = make_iter<ElementAccessor<3>>( ElementAccessor<3>(parent_mesh_, parent_mesh_->element_vec_.size()) );
49  return Range<ElementAccessor<3>>(bgn_it, end_it);
50 }
51 
52 
53 unsigned int BCMesh::n_elements(FMT_UNUSED bool boundary) const {
55 }
56 
57 
59  return parent_mesh_->get_part();
60 }
61 
63  if (local_part_ == nullptr) {
64  local_part_ = new LongIdx[this->n_elements()];
65  unsigned int bc_ele_idx;
66  for (auto ele : parent_mesh_->elements_range())
67  if (ele->boundary_idx_ != NULL)
68  for (unsigned int i=0; i<ele->n_sides(); ++i)
69  if ((int)ele->boundary_idx_[i] != -1) {
70  bc_ele_idx = parent_mesh_->boundary_[ ele->boundary_idx_[i] ].bc_ele_idx_;
71  local_part_[bc_ele_idx - parent_mesh_->bulk_size_] = parent_mesh_->get_local_part()[ele.idx()];
72  }
73  }
74  return local_part_;
75 }
76 
77 
78 std::shared_ptr<std::vector<LongIdx>> BCMesh::check_compatible_mesh( Mesh & input_mesh) {
79  return parent_mesh_->check_compatible_mesh(input_mesh);
80 }
81 
82 
83 unsigned int BCMesh::n_nodes() const {
84  return parent_mesh_->nodes_.size();
85 }
86 
87 
89  return ElementAccessor<3>(parent_mesh_, idx+parent_mesh_->bulk_size_);
90 }
91 
92 
Class for the mesh partitioning. This should provide:
Definition: partitioning.hh:52
vector< Element > element_vec_
Definition: mesh.h:517
unsigned int size() const
Definition: armor.hh:718
unsigned int size() const
Return size of map.
BCMesh(Mesh *parent_mesh)
Definition: bc_mesh.cc:30
void init_element_vector(unsigned int size)
Initialize element_vec_, set size and reset counters of boundary and bulk elements.
Definition: mesh.cc:1127
virtual const LongIdx * get_local_part()
Definition: mesh.cc:270
BidirectionalMap< int > element_ids_
Maps element ids to indexes into vector element_vec_.
Definition: mesh.h:529
Range< ElementAccessor< 3 > > elements_range() const override
Returns range of boundary elements of parent mesh.
Definition: bc_mesh.cc:45
virtual std::shared_ptr< std::vector< LongIdx > > check_compatible_mesh(Mesh &input_mesh)
Definition: mesh.cc:892
ElementAccessor< 3 > element_accessor(unsigned int idx) const override
Overwrite Mesh::element_accessor()
Definition: bc_mesh.cc:88
Definition: mesh.h:78
unsigned int n_nodes() const override
Overwrite Mesh::n_nodes()
Definition: bc_mesh.cc:83
vector< BoundaryData > boundary_
Definition: mesh.h:246
Boundary boundary(uint edge_idx) const
Definition: mesh.cc:260
Partitioning * get_part() override
Overwrite Mesh::get_part()
Definition: bc_mesh.cc:58
virtual Partitioning * get_part()
Definition: mesh.cc:266
Armor::Array< double > nodes_
Definition: mesh.h:534
#define FMT_UNUSED
Definition: posix.h:75
Range helper class.
std::shared_ptr< std::vector< LongIdx > > check_compatible_mesh(Mesh &input_mesh) override
Overwrite Mesh::check_compatible_mesh()
Definition: bc_mesh.cc:78
LongIdx * local_part_
Distribution of boundary elements to processors.
Definition: bc_mesh.hh:71
virtual Range< ElementAccessor< 3 > > elements_range() const
Returns range of bulk elements.
Definition: mesh.cc:1153
Support classes for parallel programing.
int LongIdx
Define type that represents indices of large arrays (elements, nodes, dofs etc.)
Definition: index_types.hh:24
const LongIdx * get_local_part() override
Overwrite Mesh::get_local_part()
Definition: bc_mesh.cc:62
Mesh * parent_mesh_
Pointer to parent (bulk) mesh.
Definition: bc_mesh.hh:68
~BCMesh()
Destructor.
Definition: bc_mesh.cc:39
Implementation of range helper class.
unsigned int bulk_size_
Count of bulk elements.
Definition: mesh.h:523
unsigned int n_elements(bool boundary=false) const override
Returns count of boundary elements of parent mesh.
Definition: bc_mesh.cc:53
void init_node_vector(unsigned int size)
Initialize node_vec_, set size.
Definition: mesh.cc:1139