v0.14.0
Loading...
Searching...
No Matches
MakeStructures.hpp
Go to the documentation of this file.
1/* This file is part of MoFEM.
2 * MoFEM is free software: you can redistribute it and/or modify it under
3 * the terms of the GNU Lesser General Public License as published by the
4 * Free Software Foundation, either version 3 of the License, or (at your
5 * option) any later version.
6 *
7 * MoFEM is distributed in the hope that it will be useful, but WITHOUT
8 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10 * License for more details.
11 *
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>. */
14
15#ifndef __MORTAR_CONTACT_STRUCTURES__
16#define __MORTAR_CONTACT_STRUCTURES__
17
19
20 static MoFEMErrorCode masterSlaveTrianglesCreation(MoFEM::Interface &m_field,
21 Range &range_surf_master,
22 Range &range_surf_slave,
23 int step = 1) {
26 if (it->getName().compare(0, 13, "MORTAR_MASTER") == 0) {
27 CHKERR m_field.get_moab().get_entities_by_type(it->meshset, MBTRI,
28 range_surf_master, true);
29 }
30 }
31
33 if (it->getName().compare(0, 12, "MORTAR_SLAVE") == 0) {
34 rval = m_field.get_moab().get_entities_by_type(it->meshset, MBTRI,
35 range_surf_slave, true);
36 CHKERRQ_MOAB(rval);
37 }
38 }
39
41 }
42
43 static MoFEMErrorCode findContactSurfacePairs(
44 MoFEM::Interface &m_field,
45 std::vector<std::pair<Range, Range>> &contact_surface_pairs) {
47
48 std::map<std::string, Range> slave_surface_map, master_surface_map;
49
50 auto fill_surface_map = [&](auto &surface_map, std::string surface_name) {
52
54 if (it->getName().compare(0, surface_name.size(), surface_name) == 0) {
55 Range tris;
56 CHKERR m_field.get_moab().get_entities_by_type(it->meshset, MBTRI,
57 tris, true);
58 std::string key = it->getName().substr(surface_name.size());
59 auto res =
60 surface_map.insert(std::pair<std::string, Range>(key, tris));
61 if (!res.second) {
62 SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
63 "Contact surface name %s used more than once",
64 it->getName().c_str());
65 }
66 }
67 }
68
70 };
71
72 CHKERR fill_surface_map(slave_surface_map, "MORTAR_SLAVE");
73 CHKERR fill_surface_map(master_surface_map, "MORTAR_MASTER");
74
75 for (const auto &[key, slave_range] : slave_surface_map) {
76 auto master_search = master_surface_map.find(key);
77 if (master_search != master_surface_map.end()) {
78 contact_surface_pairs.push_back(
79 std::pair<Range, Range>(slave_range, master_search->second));
80 master_surface_map.erase(master_search);
81 } else {
82 SETERRQ2(
83 PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
84 "Cannot find pairing contact surface MORTAR_MASTER%s for existing "
85 "surface MORTAR_SLAVE%s",
86 key.c_str(), key.c_str());
87 }
88 }
89
90 if (!master_surface_map.empty()) {
91 std::string key = master_surface_map.begin()->first;
92 SETERRQ2(
93 PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
94 "Cannot find pairing contact surface MORTAR_SLAVE%s for existing "
95 "surface MORTAR_MASTER%s",
96 key.c_str(), key.c_str());
97 }
98
100 }
101};
102#endif
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
@ BLOCKSET
Definition: definitions.h:148
#define CHKERRQ_MOAB(a)
check error code of MoAB function
Definition: definitions.h:454
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
#define _IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet having a particular BC meshset in a moFEM field.
virtual moab::Interface & get_moab()=0
Deprecated interface functions.
static MoFEMErrorCode findContactSurfacePairs(MoFEM::Interface &m_field, std::vector< std::pair< Range, Range > > &contact_surface_pairs)
static MoFEMErrorCode masterSlaveTrianglesCreation(MoFEM::Interface &m_field, Range &range_surf_master, Range &range_surf_slave, int step=1)