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