v0.13.1
Loading...
Searching...
No Matches
BcManager.hpp
Go to the documentation of this file.
1/** \file BcManager.hpp
2 * \brief Manage boundary conditions set to the problem
3 * \ingroup bc_manager
4 *
5 */
6
7#ifndef __BCMANAGER_HPP__
8#define __BCMANAGER_HPP__
9
10#include "UnknownInterface.hpp"
11
12namespace MoFEM {
13
14template <CubitBC BC>
15struct BcMeshsetType {};
16template <CubitBC BC>
18
19/**
20 * \brief Simple interface for fast problem set-up
21 * \ingroup mofem_simple_interface
22 */
23struct BcManager : public UnknownInterface {
24
25 MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
26 UnknownInterface **iface) const;
27
28 BcManager(const MoFEM::Core &core);
29 virtual ~BcManager() = default;
30
31 /**
32 * @brief Data structure storing bc markers and atributes
33 *
34 */
35 struct BCs : boost::enable_shared_from_this<BCs> {
37 std::vector<double> bcAttributes;
38 std::vector<unsigned char> bcMarkers;
39
40 boost::shared_ptr<DisplacementCubitBcData> dispBcPtr;
41 boost::shared_ptr<TemperatureCubitBcData> tempBcPtr;
42 boost::shared_ptr<HeatFluxCubitBcData> heatFluxBcPtr;
43
44 /// \deprecated use getBcEntsPtr
45 DEPRECATED inline auto getBcEdgesPtr() {
46 return boost::shared_ptr<Range>(shared_from_this(), &bcEnts);
47 }
48
49 inline auto getBcEntsPtr() {
50 return boost::shared_ptr<Range>(shared_from_this(), &bcEnts);
51 }
52
53 inline auto getBcMarkersPtr() {
54 return boost::shared_ptr<std::vector<unsigned char>>(shared_from_this(),
55 &bcMarkers);
56 }
57 };
58
59 /**
60 * \brief get options
61 * @return error code
62 */
64
65 /**
66 * @brief Remove DOFs from problem
67 *
68 * @param problem_name
69 * @param block_name
70 * @param field_name
71 * @param lo lowest coefficient
72 * @param hi highest coefficient
73 * @param get_low_dim_ents get lower dimension entities
74 * @param block_name_field_prefix block name is expected to have prefix with
75 * field name
76 * @param is_distributed_mesh distributed mesh
77 * @return MoFEMErrorCode
78 */
79 MoFEMErrorCode removeBlockDOFsOnEntities(const std::string problem_name,
80 const std::string block_name,
81 const std::string field_name, int lo,
82 int hi, bool get_low_dim_ents = true,
83 bool is_distributed_mesh = true);
84
85 /**
86 * @brief Mark block DOFs
87 *
88 * @param problem_name
89 * @param block_name
90 * @param field_name
91 * @param lo lowest coefficient
92 * @param hi highest coefficient
93 * @param get_low_dim_ents get lower dimension entities
94 * field name
95 * @return MoFEMErrorCode
96 */
97 MoFEMErrorCode pushMarkDOFsOnEntities(const std::string problem_name,
98 const std::string block_name,
99 const std::string field_name, int lo,
100 int hi, bool get_low_dim_ents = true);
101
102 /**
103 * @brief Mark block DOFs
104 *
105 * @tparam BCSET
106 * @param problem_name
107 * @param field_name
108 * @param get_low_dim_ents
109 * @param is_distributed_mesh
110 * @param block_name_field_prefix
111 * @return MoFEMErrorCode
112 */
113 template <typename T>
114 MoFEMErrorCode removeBlockDOFsOnEntities(const std::string problem_name,
115 const std::string field_name,
116 bool get_low_dim_ents = true,
117 bool block_name_field_prefix = false,
118 bool is_distributed_mesh = true);
119
120 /**
121 * @brief Mark block DOFs
122 *
123 * @param problem_name
124 * @param field_name
125 * @param get_low_dim_ents get lower dimension entities
126 * @return MoFEMErrorCode
127 */
128 template <typename T>
129 MoFEMErrorCode pushMarkDOFsOnEntities(const std::string problem_name,
130 const std::string field_name,
131 bool get_low_dim_ents = true,
132 bool block_name_field_prefix = false);
133
134 /**
135 * @brief Get bc data and remove element
136 *
137 * @param block_name
138 * @return boost::shared_ptr<BCs>
139 */
140 boost::shared_ptr<BCs> popMarkDOFsOnEntities(const std::string block_name);
141
142 /** \todo Add markers for standard BCs from cubit on Nodests and Sidesets used
143 * bu cubit for displacements, forces, etc. Also add function to add blockset
144 * by id and type.
145 */
146
147 using BcMapByBlockName = std::map<string, boost::shared_ptr<BCs>>;
148
149 using BcMarkerPtr = boost::shared_ptr<std::vector<char unsigned>>;
150 /**
151 * @brief Get the bc structure object
152 *
153 * @param block_name
154 * @return auto
155 */
156 inline auto getBcStructure(const std::string bc_id) {
157 return bcMapByBlockName.at(bc_id);
158 }
159
160 /**
161 * @brief Get the bc map
162 *
163 * @return auto
164 */
166
167 /**
168 * @brief Get the Merged Boundary Marker object
169 *
170 * @param bc_regex_vec boundary name regex vector
171 * @return boundaryMarker
172 */
173 BcMarkerPtr getMergedBlocksMarker(std::vector<std::regex> bc_regex_vec);
174 /**
175 * @brief Get the Merged Boundary Marker object
176 *
177 * @param bc_names vector of boundary names
178 * @return boundaryMarker
179 */
180 inline auto getMergedBlocksMarker(std::vector<string> bc_names) {
181 std::vector<std::regex> reg_vec(bc_names.size());
182 for (int i = 0; i != bc_names.size(); ++i) {
183 auto full_name = std::string("(.*)_") + bc_names[i] + std::string("(.*)");
184 reg_vec[i] = std::regex(full_name);
185 }
186 return getMergedBlocksMarker(reg_vec);
187 }
188 /**
189 * @brief Get the Merged Blocks Marker object
190 *
191 * @param boundary_markers_ptr_vec vector of boundary markers to merge
192 * @return BcMarkerPtr
193 */
195 const std::vector<BcMarkerPtr> &boundary_markers_ptr_vec);
196 /**
197 * @brief check if given boundary condition name is in the map bc element
198 *
199 * @param bc element of the map
200 * @param reg bc regex
201 * @return auto
202 */
203 inline auto checkBlock(const std::pair<string, boost::shared_ptr<BCs>> &bc,
204 std::regex reg) {
205 return std::regex_match(bc.first, reg);
206 }
207 /**
208 * @brief check if given boundary condition name is in the map bc element
209 *
210 * @param bc element of the map
211 * @param name bc name
212 * @return auto
213 */
214 inline auto
215 checkBlock(const std::pair<std::string, boost::shared_ptr<BCs>> &bc,
216 std::string name) {
217 auto full_name = std::string("(.*)_") + name + std::string("(.*)");
218 return checkBlock(bc, std::regex(full_name));
219 }
220
221 /**
222 * @brief Get block IS
223 *
224 * @param block_prefix for hashmap
225 * @param block_name for hash map
226 * @param field_name for hash map and IS
227 * @param problem_name for IS
228 * @param lo
229 * @param hi
230 * @param is_expand is to extend
231 * @return SmartPetscObj<IS>
232 */
234 getBlockIS(const std::string block_prefix, const std::string block_name,
235 const std::string field_name, const std::string problem_name,
236 int lo, int hi, SmartPetscObj<IS> is_expand = SmartPetscObj<IS>());
237
238 /**
239 * @brief Get block IS
240 *
241 * @param problem_name
242 * @param block_name
243 * @param field_name
244 * @param lo
245 * @param hi
246 * @param is_expand is to extend
247 * @return SmartPetscObj<IS>
248 */
250 getBlockIS(const std::string problem_name, const std::string block_name,
251 const std::string field_name, int lo, int hi,
253
254 /**
255 * @brief Extract block name and block name form block id
256 *
257 * @param block_id
258 * @param prb_name
259 * @return std::pair<std::string, std::string>
260 */
261 static std::pair<std::string, std::string>
262 extractStringFromBlockId(const std::string block_id,
263 const std::string prb_name);
264
265private:
267
269};
270
271template <>
273BcManager::removeBlockDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
274 const std::string problem_name, const std::string field_name,
275 bool get_low_dim_ents, bool block_name_field_prefix,
276 bool is_distributed_mesh);
277
278template <>
280BcManager::removeBlockDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
281 const std::string problem_name, const std::string field_name,
282 bool get_low_dim_ents, bool block_name_field_prefix,
283 bool is_distributed_mesh);
284
285template <>
286MoFEMErrorCode BcManager::removeBlockDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
287 const std::string problem_name, const std::string field_name,
288 bool get_low_dim_ents, bool block_name_field_prefix,
289 bool is_distributed_mesh);
290
291template <>
293BcManager::removeBlockDOFsOnEntities<BcVectorMeshsetType<BLOCKSET>>(
294 const std::string problem_name, const std::string field_name,
295 bool get_low_dim_ents, bool block_name_field_prefix,
296 bool is_distributed_mesh);
297
298template <>
300BcManager::pushMarkDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
301 const std::string problem_name, const std::string field_name,
302 bool get_low_dim_ents, bool block_name_field_prefix);
303
304template <>
305MoFEMErrorCode BcManager::pushMarkDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
306 const std::string problem_name, const std::string field_name,
307 bool get_low_dim_ents, bool block_name_field_prefix);
308
309template <>
310MoFEMErrorCode BcManager::pushMarkDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
311 const std::string problem_name, const std::string field_name,
312 bool get_low_dim_ents, bool block_name_field_prefix);
313
314template <>
315MoFEMErrorCode BcManager::pushMarkDOFsOnEntities<BcVectorMeshsetType<BLOCKSET>>(
316 const std::string problem_name, const std::string field_name,
317 bool get_low_dim_ents, bool block_name_field_prefix);
318
319template <>
320MoFEMErrorCode BcManager::pushMarkDOFsOnEntities<DisplacementCubitBcData>(
321 const std::string problem_name, const std::string field_name,
322 bool get_low_dim_ents, bool block_name_field_prefix);
323
324template <>
326BcManager::removeBlockDOFsOnEntities<DisplacementCubitBcData>(
327 const std::string problem_name, const std::string field_name,
328 bool get_low_dim_ents, bool block_name_field_prefix,
329 bool is_distributed_mesh);
330
331template <>
332MoFEMErrorCode BcManager::pushMarkDOFsOnEntities<HeatFluxCubitBcData>(
333 const std::string problem_name, const std::string field_name,
334 bool get_low_dim_ents, bool block_name_field_prefix);
335
336template <>
337MoFEMErrorCode BcManager::removeBlockDOFsOnEntities<HeatFluxCubitBcData>(
338 const std::string problem_name, const std::string field_name,
339 bool get_low_dim_ents, bool block_name_field_prefix,
340 bool is_distributed_mesh);
341
342} // namespace MoFEM
343
344#endif //__BCMANAGER_HPP__
345
346/**
347 * \defgroup bc_manager Manages boundary conditions
348 * \brief Implementation manages boundary conditions
349 *
350 * \ingroup mofem
351 **/
MoFEM interface.
#define DEPRECATED
Definition: definitions.h:17
FTensor::Index< 'i', SPACE_DIM > i
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
constexpr auto field_name
Data structure storing bc markers and atributes.
Definition: BcManager.hpp:35
boost::shared_ptr< HeatFluxCubitBcData > heatFluxBcPtr
Definition: BcManager.hpp:42
boost::shared_ptr< DisplacementCubitBcData > dispBcPtr
Definition: BcManager.hpp:40
std::vector< unsigned char > bcMarkers
Definition: BcManager.hpp:38
std::vector< double > bcAttributes
Definition: BcManager.hpp:37
boost::shared_ptr< TemperatureCubitBcData > tempBcPtr
Definition: BcManager.hpp:41
DEPRECATED auto getBcEdgesPtr()
Definition: BcManager.hpp:45
Simple interface for fast problem set-up.
Definition: BcManager.hpp:23
auto checkBlock(const std::pair< string, boost::shared_ptr< BCs > > &bc, std::regex reg)
check if given boundary condition name is in the map bc element
Definition: BcManager.hpp:203
boost::shared_ptr< std::vector< char unsigned > > BcMarkerPtr
Definition: BcManager.hpp:149
MoFEMErrorCode removeBlockDOFsOnEntities(const std::string problem_name, const std::string field_name, bool get_low_dim_ents=true, bool block_name_field_prefix=false, bool is_distributed_mesh=true)
Mark block DOFs.
MoFEMErrorCode getOptions()
get options
Definition: BcManager.cpp:40
BcMarkerPtr getMergedBlocksMarker(std::vector< std::regex > bc_regex_vec)
Get the Merged Boundary Marker object.
Definition: BcManager.cpp:187
static std::pair< std::string, std::string > extractStringFromBlockId(const std::string block_id, const std::string prb_name)
Extract block name and block name form block id.
Definition: BcManager.cpp:901
auto getMergedBlocksMarker(std::vector< string > bc_names)
Get the Merged Boundary Marker object.
Definition: BcManager.hpp:180
MoFEM::Core & cOre
Definition: BcManager.hpp:266
BcMapByBlockName bcMapByBlockName
Definition: BcManager.hpp:268
SmartPetscObj< IS > getBlockIS(const std::string block_prefix, const std::string block_name, const std::string field_name, const std::string problem_name, int lo, int hi, SmartPetscObj< IS > is_expand=SmartPetscObj< IS >())
Get block IS.
Definition: BcManager.cpp:218
MoFEMErrorCode removeBlockDOFsOnEntities(const std::string problem_name, const std::string block_name, const std::string field_name, int lo, int hi, bool get_low_dim_ents=true, bool is_distributed_mesh=true)
Remove DOFs from problem.
Definition: BcManager.cpp:49
virtual ~BcManager()=default
std::map< string, boost::shared_ptr< BCs > > BcMapByBlockName
Definition: BcManager.hpp:147
MoFEMErrorCode pushMarkDOFsOnEntities(const std::string problem_name, const std::string field_name, bool get_low_dim_ents=true, bool block_name_field_prefix=false)
Mark block DOFs.
auto getBcStructure(const std::string bc_id)
Get the bc structure object.
Definition: BcManager.hpp:156
auto checkBlock(const std::pair< std::string, boost::shared_ptr< BCs > > &bc, std::string name)
check if given boundary condition name is in the map bc element
Definition: BcManager.hpp:215
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Definition: BcManager.cpp:9
BcMarkerPtr getMergedBlocksMarker(const std::vector< BcMarkerPtr > &boundary_markers_ptr_vec)
Get the Merged Blocks Marker object.
boost::shared_ptr< BCs > popMarkDOFsOnEntities(const std::string block_name)
Get bc data and remove element.
Definition: BcManager.cpp:176
MoFEMErrorCode pushMarkDOFsOnEntities(const std::string problem_name, const std::string block_name, const std::string field_name, int lo, int hi, bool get_low_dim_ents=true)
Mark block DOFs.
Definition: BcManager.cpp:87
BcMapByBlockName & getBcMapByBlockName()
Get the bc map.
Definition: BcManager.hpp:165
Core (interface) class.
Definition: Core.hpp:82
intrusive_ptr for managing petsc objects
base class for all interface classes