From 373481add9e304733a119ce9bb28e81f01e3436f Mon Sep 17 00:00:00 2001 From: Andrea Rovinelli Date: Tue, 1 Sep 2020 16:00:37 -0500 Subject: [PATCH 1/5] fix and closes #15793 --- .../BreakMeshByBlockGenerator.C | 3 +- .../gold/hanging_nodes_parallel_in.e | Bin 0 -> 7152 bytes .../hanging_nodes_parallel.i | 69 ++++++++++++++++++ .../break_mesh_by_block_generator/tests | 14 ++++ 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 test/tests/meshgenerators/break_mesh_by_block_generator/gold/hanging_nodes_parallel_in.e create mode 100644 test/tests/meshgenerators/break_mesh_by_block_generator/hanging_nodes_parallel.i diff --git a/framework/src/meshgenerators/BreakMeshByBlockGenerator.C b/framework/src/meshgenerators/BreakMeshByBlockGenerator.C index 1a01e5d9030a..a670fb30c4de 100644 --- a/framework/src/meshgenerators/BreakMeshByBlockGenerator.C +++ b/framework/src/meshgenerators/BreakMeshByBlockGenerator.C @@ -12,7 +12,7 @@ #include "libmesh/distributed_mesh.h" #include "libmesh/elem.h" - +#include "libmesh/partitioner.h" #include registerMooseObject("MooseApp", BreakMeshByBlockGenerator); @@ -163,6 +163,7 @@ BreakMeshByBlockGenerator::generate() } // end nodeptr check addInterfaceBoundary(*mesh); + Partitioner::set_node_processor_ids(*mesh); return dynamic_pointer_cast(mesh); } diff --git a/test/tests/meshgenerators/break_mesh_by_block_generator/gold/hanging_nodes_parallel_in.e b/test/tests/meshgenerators/break_mesh_by_block_generator/gold/hanging_nodes_parallel_in.e new file mode 100644 index 0000000000000000000000000000000000000000..125b2d84e34713401c9f3621b36c3c096fda33fb GIT binary patch literal 7152 zcmeI0%W_jk5QgOowj`UIF<@*6;tt^&FxL<)gCURr!QqwwL6$AqRz;Rn(jh=9OBPw? z0kWhjS>^#!{5Fy zc#>+i2+3l;l&N{uLTSby*rsd4=F7qgMMbR_^o=uTr15kQ_FkKc7?`#eXWqw zIu__xIUj`*Za(t;tkHY5^OLFMtD4gvU@r^#N1O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djRJMDMfgD2Dx`#6!fs)YzP(PUgYSMKyK24@tU>Kd_?0Lp8H)gvBftrqy~s1wMQ(81M%b=Wp!w0pSajLx-5BI zm=LZAt^R)I#9?0YLOj_6HAKy@_fY{KcLmmy6sW(H5Usa;(uM1tbsZI`?=j(;z<25X E-#c!yL;wH) literal 0 HcmV?d00001 diff --git a/test/tests/meshgenerators/break_mesh_by_block_generator/hanging_nodes_parallel.i b/test/tests/meshgenerators/break_mesh_by_block_generator/hanging_nodes_parallel.i new file mode 100644 index 000000000000..a5a37c82b742 --- /dev/null +++ b/test/tests/meshgenerators/break_mesh_by_block_generator/hanging_nodes_parallel.i @@ -0,0 +1,69 @@ +[GlobalParams] + displacements = "disp_x disp_y disp_z" +[] + +[Mesh] + [./msh] + type = GeneratedMeshGenerator + nx = 2 + ny = 3 + nz = 4 + xmin = -2.5 + xmax = 2.5 + ymin = -2 + ymax = 2 + zmin = -1.5 + zmax = 1.5 + dim = 3 + [../] + [./subdomain_1] + type = SubdomainBoundingBoxGenerator + input = msh + bottom_left = '-2.5 -2 -1' + top_right = '2.5 0 0.5' + block_id = 1 + [] + [./subdomain_2] + type = SubdomainBoundingBoxGenerator + input = subdomain_1 + bottom_left = '-2.5 0 -1' + top_right = '2.5 2 0.5' + block_id = 2 + [] + [./subdomain_3] + type = SubdomainBoundingBoxGenerator + input = subdomain_2 + bottom_left = '-2.5 -2 0.5' + top_right = '1.25 2 1.5' + block_id = 3 + [] + [./subdomain_4] + type = SubdomainBoundingBoxGenerator + input = subdomain_3 + bottom_left = '1.25 -2 0.5' + top_right = '5 2 1.5' + block_id = 4 + [] + [./subdomain_5] + type = SubdomainBoundingBoxGenerator + input = subdomain_4 + bottom_left = '-2.5 -2 -1.5' + top_right = '1.25 2 -1' + block_id = 3 + [] + [./subdomain_6] + type = SubdomainBoundingBoxGenerator + input = subdomain_5 + bottom_left = '1.25 -2 -1.5' + top_right = '2.5 2 -1' + block_id = 4 + [] + [./split] + type = BreakMeshByBlockGenerator + input = subdomain_6 + [] +[] + +[Outputs] + exodus = true +[] diff --git a/test/tests/meshgenerators/break_mesh_by_block_generator/tests b/test/tests/meshgenerators/break_mesh_by_block_generator/tests index 499ddfd85a3a..2e30bdd3e196 100644 --- a/test/tests/meshgenerators/break_mesh_by_block_generator/tests +++ b/test/tests/meshgenerators/break_mesh_by_block_generator/tests @@ -70,4 +70,18 @@ mesh_mode = 'REPLICATED' recover = false [../] + + [./hanging_nodes] + type = 'Exodiff' + input = 'hanging_nodes_parallel.i' + cli_args = '--mesh-only' + exodiff = 'hanging_nodes_parallel_in.e' + requirement = 'MOOSE shall be able to create separate blocks in a mesh in parallel' + design = 'meshgenerators/BreakMeshByBlockGenerator.md' + issues = '#15793' + mesh_mode = 'REPLICATED' + min_parallel = 4 + max_parallel = 5 + recover = false + [../] [] From 209c9c7c3dd49488ba9a3103112ba4479108dd9b Mon Sep 17 00:00:00 2001 From: Andrea Rovinelli Date: Wed, 2 Sep 2020 09:16:34 -0500 Subject: [PATCH 2/5] Fixed gold file --- .../gold/hanging_nodes_parallel_in.e | Bin 7152 -> 9112 bytes .../break_mesh_by_block_generator/tests | 1 + 2 files changed, 1 insertion(+) diff --git a/test/tests/meshgenerators/break_mesh_by_block_generator/gold/hanging_nodes_parallel_in.e b/test/tests/meshgenerators/break_mesh_by_block_generator/gold/hanging_nodes_parallel_in.e index 125b2d84e34713401c9f3621b36c3c096fda33fb..ce85056fdcaaf9a4d5199759d238598f78d80ac8 100644 GIT binary patch literal 9112 zcmdUz%X3u66~+e(nb8BV4FTB(G!g=gZSV`*_>pJ~;$dSPV*@6BWHgdS(wNcA)XWe+ zDvK=qCuEU7z*Wi83-8gwOE0p>pWswwk!2QHWa01E_kQH6#nlKLrIN1tZudRs>(i&t zIelmDJv(#$fkM)T)lCS)jaswP?RDzSrJz7oMAoP`YZ_k>wlB7Bb?AkmUVWve3AMIv z(iZs5>I!`3?`YmysVvl2P!9-0+&5bbwJwrE0Ywp6tx;n+aM}rCsZ2&7e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eb+^DbV?&%nDq)bn6*w0O9Ez1!;F z)lQZ@uk8QZqshG0!pyAKWXxB4<;r5iu~;!by{Lo5t=(wLb+(*Ezp(Sw>Fkud{Ws3K z{GB%XT&gB|AK|wWzYV#M#|3_$`TxsM%kKyKZDPME?6&}S@_vE4F85OIkOKnuIPPcM zySPvBf3**UtwKuJCTtgW2s?#c!fs)Yuvge8d?@S}xceOx4he^aBLcs{xHEDW?V-M7EruL$=&l zo-9Y?3mbTr4`g`c1syUxa)b_<{E{zp>?> zeW1ezURoG+GQ9IbT0n+(K|qI$EwzIVo3vncgA9-QL5B>FT0)16Ep>&CTIvycg_};c zGlve@&fY2~uT|S8tP!w*Hy}`t$nZ7^=#b$J3h0or9TL!C18Yc6*dBDc2WmMZ$AqktAF3U8I^>LS-06@fgcAZfY_L5m zOgb4`&OJJ0c;^Ik$k>hu=&*rzQJ8WvJiZC&km2!tK!=R&WdR*F@U9CvC&S}=fesno z4FMf8w&Mc2HlbbU5IO}r+g1~n>vbCI7c3v-V6#B%Eyl!^a~1x6TD=n^VsTnHBT&Qa zdxg*?bPI98YR_tJy>uIdjRJMDMfgD2Dx`#6!fs)YzP(PUgYSMKyK24@tU>Kd_?0Lp8H)gvBftrqy~s1wMQ(81M%b=Wp!w0pSajLx-5BI zm=LZAt^R)I#9?0YLOj_6HAKy@_fY{KcLmmy6sW(H5Usa;(uM1tbsZI`?=j(;z<25X E-#c!yL;wH) diff --git a/test/tests/meshgenerators/break_mesh_by_block_generator/tests b/test/tests/meshgenerators/break_mesh_by_block_generator/tests index 2e30bdd3e196..a6594187b9b3 100644 --- a/test/tests/meshgenerators/break_mesh_by_block_generator/tests +++ b/test/tests/meshgenerators/break_mesh_by_block_generator/tests @@ -83,5 +83,6 @@ min_parallel = 4 max_parallel = 5 recover = false + method = 'dbg' [../] [] From 24308d56cc72508d6366f2857ddee5b9fa68fa76 Mon Sep 17 00:00:00 2001 From: Andrea Rovinelli Date: Fri, 25 Sep 2020 18:46:08 -0500 Subject: [PATCH 3/5] added block restricted BMBB --- .../BreakMeshByBlockGenerator.h | 5 +++- .../BreakMeshByBlockGenerator.C | 27 +++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/framework/include/meshgenerators/BreakMeshByBlockGenerator.h b/framework/include/meshgenerators/BreakMeshByBlockGenerator.h index efd94084d1ee..53e44bdc77eb 100644 --- a/framework/include/meshgenerators/BreakMeshByBlockGenerator.h +++ b/framework/include/meshgenerators/BreakMeshByBlockGenerator.h @@ -10,6 +10,7 @@ #pragma once #include "BreakMeshByBlockGeneratorBase.h" +#include class BreakMeshByBlockGenerator; @@ -27,6 +28,9 @@ class BreakMeshByBlockGenerator : public BreakMeshByBlockGeneratorBase protected: std::unique_ptr & _input; + std::vector _block; + std::unordered_set _block_set; + const bool _block_restricted; private: /// generate the new boundary interface @@ -37,4 +41,3 @@ class BreakMeshByBlockGenerator : public BreakMeshByBlockGeneratorBase std::set>> _new_boundary_sides_map; }; - diff --git a/framework/src/meshgenerators/BreakMeshByBlockGenerator.C b/framework/src/meshgenerators/BreakMeshByBlockGenerator.C index a670fb30c4de..4b8aa3db83ea 100644 --- a/framework/src/meshgenerators/BreakMeshByBlockGenerator.C +++ b/framework/src/meshgenerators/BreakMeshByBlockGenerator.C @@ -28,11 +28,20 @@ BreakMeshByBlockGenerator::validParams() "attached. Naming convention for the new boundaries will be the old " "boundary name plus \"_to_\" plus the subdomain name. At the moment" "this only works on REPLICATED mesh"); + params.addParam>( + "block", + "The list of subdomain names where neml mehcanisc should be used, " + "default all blocks."); return params; } BreakMeshByBlockGenerator::BreakMeshByBlockGenerator(const InputParameters & parameters) - : BreakMeshByBlockGeneratorBase(parameters), _input(getMesh("input")) + : BreakMeshByBlockGeneratorBase(parameters), + _input(getMesh("input")), + _block(parameters.isParamSetByUser("block") ? getParam>("block") + : std::vector(0)), + _block_set(_block.begin(), _block.end()), + _block_restricted(parameters.isParamSetByUser("block")) { if (typeid(_input).name() == typeid(DistributedMesh).name()) mooseError("BreakMeshByBlockGenerator only works with ReplicatedMesh."); @@ -47,7 +56,15 @@ BreakMeshByBlockGenerator::generate() std::map> node_to_elem_map; for (const auto & elem : mesh->active_element_ptr_range()) for (unsigned int n = 0; n < elem->n_nodes(); n++) - node_to_elem_map[elem->node_id(n)].push_back(elem->id()); + { + if (!_block_restricted) + node_to_elem_map[elem->node_id(n)].push_back(elem->id()); + else + { + if (_block_set.find(elem->subdomain_id()) != _block_set.end()) + node_to_elem_map[elem->node_id(n)].push_back(elem->id()); + } + } for (auto node_it = node_to_elem_map.begin(); node_it != node_to_elem_map.end(); ++node_it) { @@ -61,7 +78,13 @@ BreakMeshByBlockGenerator::generate() for (auto elem_id = node_it->second.begin(); elem_id != node_it->second.end(); elem_id++) { const Elem * current_elem = mesh->elem_ptr(*elem_id); + // if (!_block_restricted) connected_blocks.insert(current_elem->subdomain_id()); + // else + // { + // if (_block_set.find(current_elem->subdomain_id()) != _block_set.end()) + // connected_blocks.insert(current_elem->subdomain_id()); + // } } unsigned int node_multiplicity = connected_blocks.size(); From 165dabe0c6c40dfa51e6e4704c52aa3f42d5d9d6 Mon Sep 17 00:00:00 2001 From: Andrea Rovinelli Date: Sat, 26 Sep 2020 18:28:39 -0500 Subject: [PATCH 4/5] this should work --- .../BreakMeshByBlockGenerator.h | 6 +- .../BreakMeshByBlockGeneratorBase.h | 9 +- .../BreakMeshByBlockGenerator.C | 127 ++++++++++++------ .../BreakMeshByBlockGeneratorBase.C | 8 +- 4 files changed, 97 insertions(+), 53 deletions(-) diff --git a/framework/include/meshgenerators/BreakMeshByBlockGenerator.h b/framework/include/meshgenerators/BreakMeshByBlockGenerator.h index 53e44bdc77eb..ccec219cd4b0 100644 --- a/framework/include/meshgenerators/BreakMeshByBlockGenerator.h +++ b/framework/include/meshgenerators/BreakMeshByBlockGenerator.h @@ -27,17 +27,19 @@ class BreakMeshByBlockGenerator : public BreakMeshByBlockGeneratorBase std::unique_ptr generate() override; protected: + int blockRestricteElementSubdomainID(const Elem * elem); + std::unique_ptr & _input; std::vector _block; std::unordered_set _block_set; const bool _block_restricted; + const bool _create_transition_boundary; private: /// generate the new boundary interface void addInterfaceBoundary(MeshBase & mesh); std::set> _neighboring_block_list; - std::map, - std::set>> + std::map, std::set>> _new_boundary_sides_map; }; diff --git a/framework/include/meshgenerators/BreakMeshByBlockGeneratorBase.h b/framework/include/meshgenerators/BreakMeshByBlockGeneratorBase.h index a6ad918a199a..79e86d5659ee 100644 --- a/framework/include/meshgenerators/BreakMeshByBlockGeneratorBase.h +++ b/framework/include/meshgenerators/BreakMeshByBlockGeneratorBase.h @@ -44,8 +44,8 @@ class BreakMeshByBlockGeneratorBase : public MeshGenerator /// given the primary and secondary blocks this method return the appropriate /// boundary id and name void findBoundaryNameAndInd(MeshBase & mesh, - const subdomain_id_type & /*primaryBlockID*/, - const subdomain_id_type & /*secondaryBlockID*/, + const int & /*primaryBlockID*/, + const int & /*secondaryBlockID*/, std::string & /*boundaryName*/, boundary_id_type & /*boundaryID*/, BoundaryInfo & /*boundary_info*/); @@ -58,11 +58,10 @@ class BreakMeshByBlockGeneratorBase : public MeshGenerator private: /// this method generate the boundary name by assembling subdomain names std::string generateBoundaryName(MeshBase & mesh, - const subdomain_id_type & /*primaryBlockID*/, - const subdomain_id_type & /*secondaryBlockID*/); + const int & /*primaryBlockID*/, + const int & /*secondaryBlockID*/); /// this method save the boundary name/id pair void mapBoundaryIdAndBoundaryName(boundary_id_type & /*boundaryID*/, const std::string & /*boundaryName*/); }; - diff --git a/framework/src/meshgenerators/BreakMeshByBlockGenerator.C b/framework/src/meshgenerators/BreakMeshByBlockGenerator.C index 4b8aa3db83ea..a9067a357602 100644 --- a/framework/src/meshgenerators/BreakMeshByBlockGenerator.C +++ b/framework/src/meshgenerators/BreakMeshByBlockGenerator.C @@ -32,6 +32,11 @@ BreakMeshByBlockGenerator::validParams() "block", "The list of subdomain names where neml mehcanisc should be used, " "default all blocks."); + params.addParam("create_transition_boundary", + true, + "If true (default) and block is not empty, a special boundary named " + "interface_transition is generate between listed blocks and other blocks. " + "The transition boundary will not be split if split_interface=true"); return params; } @@ -41,7 +46,8 @@ BreakMeshByBlockGenerator::BreakMeshByBlockGenerator(const InputParameters & par _block(parameters.isParamSetByUser("block") ? getParam>("block") : std::vector(0)), _block_set(_block.begin(), _block.end()), - _block_restricted(parameters.isParamSetByUser("block")) + _block_restricted(parameters.isParamSetByUser("block")), + _create_transition_boundary(getParam("create_transition_boundary")) { if (typeid(_input).name() == typeid(DistributedMesh).name()) mooseError("BreakMeshByBlockGenerator only works with ReplicatedMesh."); @@ -56,15 +62,7 @@ BreakMeshByBlockGenerator::generate() std::map> node_to_elem_map; for (const auto & elem : mesh->active_element_ptr_range()) for (unsigned int n = 0; n < elem->n_nodes(); n++) - { - if (!_block_restricted) - node_to_elem_map[elem->node_id(n)].push_back(elem->id()); - else - { - if (_block_set.find(elem->subdomain_id()) != _block_set.end()) - node_to_elem_map[elem->node_id(n)].push_back(elem->id()); - } - } + node_to_elem_map[elem->node_id(n)].push_back(elem->id()); for (auto node_it = node_to_elem_map.begin(); node_it != node_to_elem_map.end(); ++node_it) { @@ -74,17 +72,11 @@ BreakMeshByBlockGenerator::generate() if (current_node != nullptr) { // find node multiplicity - std::set connected_blocks; + std::set connected_blocks; for (auto elem_id = node_it->second.begin(); elem_id != node_it->second.end(); elem_id++) { const Elem * current_elem = mesh->elem_ptr(*elem_id); - // if (!_block_restricted) - connected_blocks.insert(current_elem->subdomain_id()); - // else - // { - // if (_block_set.find(current_elem->subdomain_id()) != _block_set.end()) - // connected_blocks.insert(current_elem->subdomain_id()); - // } + connected_blocks.insert(blockRestricteElementSubdomainID(current_elem)); } unsigned int node_multiplicity = connected_blocks.size(); @@ -97,8 +89,7 @@ BreakMeshByBlockGenerator::generate() // find reference_subdomain_id (e.g. the subdomain with lower id) auto subdomain_it = connected_blocks.begin(); - subdomain_id_type reference_subdomain_id = *subdomain_it; - + int reference_subdomain_id = *subdomain_it; // multiplicity counter to keep track of how many nodes we added unsigned int multiplicity_counter = node_multiplicity; for (auto elem_id : connected_elems) @@ -108,7 +99,7 @@ BreakMeshByBlockGenerator::generate() break; Elem * current_elem = mesh->elem_ptr(elem_id); - if (current_elem->subdomain_id() != reference_subdomain_id) + if (blockRestricteElementSubdomainID(current_elem) != reference_subdomain_id) { // assign the newly added node to current_elem Node * new_node = nullptr; @@ -122,8 +113,9 @@ BreakMeshByBlockGenerator::generate() // add new node new_node = Node::build(*current_node, mesh->n_nodes()).release(); - // We're duplicating nodes so that each subdomain elem has its own copy, so it seems - // natural to assign this new node the same proc id as corresponding subdomain elem + // We're duplicating nodes so that each subdomain elem has its own copy, so it + // seems natural to assign this new node the same proc id as corresponding + // subdomain elem new_node->processor_id() = current_elem->processor_id(); mesh->add_node(new_node); @@ -165,14 +157,22 @@ BreakMeshByBlockGenerator::generate() { Elem * current_elem = mesh->elem_ptr(elem_id); Elem * connected_elem = mesh->elem_ptr(connected_elem_id); + int curr_elem_subid = blockRestricteElementSubdomainID(current_elem); + int connected_elem_subid = blockRestricteElementSubdomainID(connected_elem); - if (current_elem != connected_elem && - current_elem->subdomain_id() < connected_elem->subdomain_id()) + if (current_elem != connected_elem && curr_elem_subid < connected_elem_subid) { if (current_elem->has_neighbor(connected_elem)) { - std::pair blocks_pair = - std::make_pair(current_elem->subdomain_id(), connected_elem->subdomain_id()); + + std::pair blocks_pair = + std::make_pair(curr_elem_subid, connected_elem_subid); + + // we want to create a special boundary for the transition, much easier to do it + // here than later + if (_block_restricted && _create_transition_boundary && + (curr_elem_subid == -1 || connected_elem_subid == -1)) + blocks_pair = std::make_pair(-1, -1); _new_boundary_sides_map[blocks_pair].insert(std::make_pair( current_elem->id(), current_elem->which_neighbor_am_i(connected_elem))); @@ -195,27 +195,70 @@ BreakMeshByBlockGenerator::addInterfaceBoundary(MeshBase & mesh) { BoundaryInfo & boundary_info = mesh.get_boundary_info(); - boundary_id_type boundaryID = findFreeBoundaryId(mesh); - std::string boundaryName = _interface_name; + boundary_id_type boundaryID; + boundary_id_type boundaryID_interface = findFreeBoundaryId(mesh); + std::string boundaryName; // loop over boundary sides for (auto & boundary_side_map : _new_boundary_sides_map) { - - // find the appropriate boundary name and id - // given primary and secondary block ID - if (_split_interface) - findBoundaryNameAndInd(mesh, - boundary_side_map.first.first, - boundary_side_map.first.second, - boundaryName, - boundaryID, - boundary_info); - else - boundary_info.sideset_name(boundaryID) = boundaryName; - + if (!_block_restricted || (_block_restricted && !_create_transition_boundary)) + { + // find the appropriate boundary name and id + // given primary and secondary block ID + if (_split_interface) + findBoundaryNameAndInd(mesh, + boundary_side_map.first.first, + boundary_side_map.first.second, + boundaryName, + boundaryID, + boundary_info); + else + { + boundaryName = _interface_name; + boundaryID = boundaryID_interface; + boundary_info.sideset_name(boundaryID_interface) = boundaryName; + } + } + else // block resticted with transition boundary + { + if (boundary_side_map.first.first == -1 || + boundary_side_map.first.second == -1) // we are creating the trnasition boundary + { + boundaryID = findFreeBoundaryId(mesh); + boundaryName = "interface_transition"; + boundary_info.sideset_name(boundaryID) = boundaryName; + boundaryID_interface = boundaryID + 1; + } + else + { + if (_split_interface) + findBoundaryNameAndInd(mesh, + boundary_side_map.first.first, + boundary_side_map.first.second, + boundaryName, + boundaryID, + boundary_info); + else + { + boundaryName = _interface_name; + boundaryID = boundaryID_interface; + boundary_info.sideset_name(boundaryID_interface) = boundaryName; + } + } + } // loop over all the side belonging to each pair and add it to the proper interface for (auto & element_side : boundary_side_map.second) boundary_info.add_side(element_side.first, element_side.second, boundaryID); } } + +int +BreakMeshByBlockGenerator::blockRestricteElementSubdomainID(const Elem * elem) +{ + int elem_subdomain_id = elem->subdomain_id(); + if (_block_restricted && (_block_set.find(elem_subdomain_id) == _block_set.end())) + elem_subdomain_id = -1; + + return elem_subdomain_id; +} diff --git a/framework/src/meshgenerators/BreakMeshByBlockGeneratorBase.C b/framework/src/meshgenerators/BreakMeshByBlockGeneratorBase.C index 94f10d1c0af7..7b57080a5fef 100644 --- a/framework/src/meshgenerators/BreakMeshByBlockGeneratorBase.C +++ b/framework/src/meshgenerators/BreakMeshByBlockGeneratorBase.C @@ -69,8 +69,8 @@ BreakMeshByBlockGeneratorBase::findFreeBoundaryId(MeshBase & mesh) std::string BreakMeshByBlockGeneratorBase::generateBoundaryName(MeshBase & mesh, - const subdomain_id_type & primaryBlockID, - const subdomain_id_type & secondaryBlockID) + const int & primaryBlockID, + const int & secondaryBlockID) { std::string primary_block_name = mesh.subdomain_name(primaryBlockID); std::string secondary_block_name = mesh.subdomain_name(secondaryBlockID); @@ -91,8 +91,8 @@ BreakMeshByBlockGeneratorBase::mapBoundaryIdAndBoundaryName(boundary_id_type & b void BreakMeshByBlockGeneratorBase::findBoundaryNameAndInd(MeshBase & mesh, - const subdomain_id_type & primaryBlockID, - const subdomain_id_type & secondaryBlockID, + const int & primaryBlockID, + const int & secondaryBlockID, std::string & boundaryName, boundary_id_type & boundaryID, BoundaryInfo & boundary_info) From d332a43c0d5cb7e67566567f1c68d81bc93fdfd2 Mon Sep 17 00:00:00 2001 From: Andrea Rovinelli Date: Sun, 27 Sep 2020 11:36:01 -0500 Subject: [PATCH 5/5] added test for block restricted mode --- .../BreakMeshByBlockGenerator.C | 2 +- .../break_mesh_block_restricted.i | 25 ++++++++++++++++++ .../gold/break_mesh_block_restricted_in.e | Bin 0 -> 30068 bytes .../break_mesh_by_block_generator/tests | 11 ++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 test/tests/meshgenerators/break_mesh_by_block_generator/break_mesh_block_restricted.i create mode 100644 test/tests/meshgenerators/break_mesh_by_block_generator/gold/break_mesh_block_restricted_in.e diff --git a/framework/src/meshgenerators/BreakMeshByBlockGenerator.C b/framework/src/meshgenerators/BreakMeshByBlockGenerator.C index a9067a357602..043b57faa7fe 100644 --- a/framework/src/meshgenerators/BreakMeshByBlockGenerator.C +++ b/framework/src/meshgenerators/BreakMeshByBlockGenerator.C @@ -223,7 +223,7 @@ BreakMeshByBlockGenerator::addInterfaceBoundary(MeshBase & mesh) else // block resticted with transition boundary { if (boundary_side_map.first.first == -1 || - boundary_side_map.first.second == -1) // we are creating the trnasition boundary + boundary_side_map.first.second == -1) // we are creating the transition boundary { boundaryID = findFreeBoundaryId(mesh); boundaryName = "interface_transition"; diff --git a/test/tests/meshgenerators/break_mesh_by_block_generator/break_mesh_block_restricted.i b/test/tests/meshgenerators/break_mesh_by_block_generator/break_mesh_block_restricted.i new file mode 100644 index 000000000000..5ed9a708827d --- /dev/null +++ b/test/tests/meshgenerators/break_mesh_by_block_generator/break_mesh_block_restricted.i @@ -0,0 +1,25 @@ +[Mesh] + [msh] + type = CartesianMeshGenerator + dim = 3 + dx = '0.25 0.25 0.25 0.25' + dy = '0.25 0.25 0.25 0.25' + dz = '0.25 0.25 0.25 0.25' + subdomain_id = '0 1 2 3 4 5 6 7 8 9 10 11 12 + 13 14 15 16 17 18 19 20 21 22 23 24 25 + 26 27 28 29 30 31 32 33 34 35 36 37 38 + 39 40 41 42 43 44 45 46 47 48 49 50 51 + 52 53 54 55 56 57 58 59 60 61 62 63' + [] + [split] + input = msh + type = BreakMeshByBlockGenerator + block = '16 17 18 19 20 21 22 23 24 25 + 26 27 28 29 30 31 32 34 35 36 37 38 + 39 40 41 42 43 44 45 46 47' + [] +[] + +[Outputs] + nemesis = true +[] diff --git a/test/tests/meshgenerators/break_mesh_by_block_generator/gold/break_mesh_block_restricted_in.e b/test/tests/meshgenerators/break_mesh_by_block_generator/gold/break_mesh_block_restricted_in.e new file mode 100644 index 0000000000000000000000000000000000000000..1c18c14db0a8ba758503cc6d0e2b880ebda8e4dd GIT binary patch literal 30068 zcmeI42YgjU+J_TrLRW$yHj3CNVhTl3f^-E02?7>ENNymKMsg9bV(&fnvg+E_w(7=S z7W?Yj<+JO?u4`AUYuV>N=T3Gw_Z%*qu}!d**%Te`e-=XYRcRPDYOz*CNe3 z+EH8p?aE`7g|+dTvda0!(3{r`)s>f3#&|ysT9sBUu2Bh@@v@2-4Pw=tBo5_0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4YY+!Xb0qIdI#tTouCVB02@MA$bxRr9eO}d*aXN~bN`?>WgplY$XT-n2T~4# z!H^B)kGX#`l#(3MJr;96g#0o0T=FSL0ePeQC+1$qc*=>e8|)5~f&A9}kMwCU9SVTl NHv8~w%6(zZzX5LWS@!?{ literal 0 HcmV?d00001 diff --git a/test/tests/meshgenerators/break_mesh_by_block_generator/tests b/test/tests/meshgenerators/break_mesh_by_block_generator/tests index a6594187b9b3..83897fee8bf3 100644 --- a/test/tests/meshgenerators/break_mesh_by_block_generator/tests +++ b/test/tests/meshgenerators/break_mesh_by_block_generator/tests @@ -85,4 +85,15 @@ recover = false method = 'dbg' [../] + + [./block_restricted] + type = 'Exodiff' + input = 'break_mesh_block_restricted.i' + cli_args = '--mesh-only' + exodiff = 'break_mesh_block_restricted_in.e' + requirement = 'The system shall be able to break teh mesh only for some blocks' + design = 'meshgenerators/BreakMeshByBlockGenerator.md' + issues = '#15793' + mesh_mode = 'REPLICATED' + [../] []