Flow123d  JS_before_hm-1879-g0c4ed93bc
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() 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<EquivalentMeshMap> 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 
90 }
91 
92 
BCMesh::elements_range
Range< ElementAccessor< 3 > > elements_range() const override
Returns range of boundary elements of parent mesh.
Definition: bc_mesh.cc:45
Mesh::BCMesh
friend class BCMesh
Definition: mesh.h:636
Mesh::nodes_
Armor::Array< double > nodes_
Definition: mesh.h:615
BCMesh::get_local_part
const LongIdx * get_local_part() override
Overwrite Mesh::get_local_part()
Definition: bc_mesh.cc:62
Mesh::init_element_vector
void init_element_vector(unsigned int size)
Initialize element_vec_, set size and reset counters of boundary and bulk elements.
Definition: mesh.cc:1099
neighbours.h
Mesh::elements_range
virtual Range< ElementAccessor< 3 > > elements_range() const
Returns range of bulk elements.
Definition: mesh.cc:1130
Mesh::check_compatible_mesh
virtual std::shared_ptr< EquivalentMeshMap > check_compatible_mesh(Mesh &input_mesh)
Definition: mesh.cc:870
distribution.hh
Support classes for parallel programing.
bc_mesh.hh
Mesh::element_vec_
vector< Element > element_vec_
Definition: mesh.h:598
ElementAccessor< 3 >
Partitioning
Class for the mesh partitioning. This should provide:
Definition: partitioning.hh:52
index_types.hh
BCMesh::parent_mesh_
Mesh * parent_mesh_
Pointer to parent (bulk) mesh.
Definition: bc_mesh.hh:68
BCMesh::local_part_
LongIdx * local_part_
Distribution of boundary elements to processors.
Definition: bc_mesh.hh:71
Mesh::get_local_part
virtual const LongIdx * get_local_part()
Definition: mesh.cc:278
accessors.hh
BCMesh::~BCMesh
~BCMesh()
Destructor.
Definition: bc_mesh.cc:39
BCMesh::n_nodes
unsigned int n_nodes() const override
Overwrite Mesh::n_nodes()
Definition: bc_mesh.cc:83
Armor::Array::size
unsigned int size() const
Definition: armor.hh:728
BCMesh::element_accessor
ElementAccessor< 3 > element_accessor(unsigned int idx) const override
Overwrite Mesh::element_accessor()
Definition: bc_mesh.cc:88
partitioning.hh
LongIdx
int LongIdx
Define type that represents indices of large arrays (elements, nodes, dofs etc.)
Definition: index_types.hh:24
Mesh
Definition: mesh.h:98
Range
Range helper class.
Definition: range_wrapper.hh:65
Mesh::init_node_vector
void init_node_vector(unsigned int size)
Initialize node_vec_, set size.
Definition: mesh.cc:1113
BCMesh::get_part
Partitioning * get_part() override
Overwrite Mesh::get_part()
Definition: bc_mesh.cc:58
BCMesh::check_compatible_mesh
std::shared_ptr< EquivalentMeshMap > check_compatible_mesh(Mesh &input_mesh) override
Overwrite Mesh::check_compatible_mesh()
Definition: bc_mesh.cc:78
Mesh::bulk_size_
unsigned int bulk_size_
Count of bulk elements.
Definition: mesh.h:604
Mesh::boundary_
vector< BoundaryData > boundary_
Definition: mesh.h:301
Mesh::get_part
virtual Partitioning * get_part()
Definition: mesh.cc:274
BCMesh::n_elements
unsigned int n_elements() const override
Returns count of boundary elements of parent mesh.
Definition: bc_mesh.cc:53
range_wrapper.hh
Implementation of range helper class.