Skip to content

Commit

Permalink
Merge Pull Request #9508 from trilinos/Trilinos/master_merge_20210730…
Browse files Browse the repository at this point in the history
…_000542

Automatically Merged using Trilinos Master Merge AutoTester
PR Title: Trilinos Master Merge PR Generator: Auto PR created to promote from master_merge_20210730_000542 branch to master
PR Author: trilinos-autotester
  • Loading branch information
trilinos-autotester authored Aug 2, 2021
2 parents 5e14fa1 + 19be9ac commit a5b9f3d
Show file tree
Hide file tree
Showing 20 changed files with 703 additions and 258 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,10 @@ void CubeHexMeshFactory::completeMeshConstruction(STK_Interface & mesh,stk::Para
}

mesh.buildLocalElementIDs();
if(buildSubcells_) {
if(createEdgeBlocks_) {
mesh.buildLocalEdgeIDs();
}
if(createFaceBlocks_) {
mesh.buildLocalFaceIDs();
}

Expand All @@ -181,8 +183,10 @@ void CubeHexMeshFactory::completeMeshConstruction(STK_Interface & mesh,stk::Para
// now that edges are built, side and node sets can be added
addSideSets(mesh);
addNodeSets(mesh);
if(buildSubcells_) {
if(createEdgeBlocks_) {
addEdgeBlocks(mesh);
}
if(createFaceBlocks_) {
addFaceBlocks(mesh);
}

Expand Down Expand Up @@ -223,6 +227,25 @@ void CubeHexMeshFactory::setParameterList(const Teuchos::RCP<Teuchos::ParameterL

buildSubcells_ = paramList->get<bool>("Build Subcells");

createEdgeBlocks_ = paramList->get<bool>("Create Edge Blocks");
createFaceBlocks_ = paramList->get<bool>("Create Face Blocks");
if (not buildSubcells_ && createEdgeBlocks_) {
Teuchos::FancyOStream out(Teuchos::rcpFromRef(std::cout));
out.setOutputToRootOnly(0);
out.setShowProcRank(true);

out << "CubeHexMesh: NOT creating edge blocks because building sub cells disabled" << std::endl;
createEdgeBlocks_ = false;
}
if (not buildSubcells_ && createFaceBlocks_) {
Teuchos::FancyOStream out(Teuchos::rcpFromRef(std::cout));
out.setOutputToRootOnly(0);
out.setShowProcRank(true);

out << "CubeHexMesh: NOT creating face blocks because building sub cells disabled" << std::endl;
createFaceBlocks_ = false;
}

// read in periodic boundary conditions
parsePeriodicBCList(Teuchos::rcpFromRef(paramList->sublist("Periodic BCs")),periodicBCVec_);
}
Expand Down Expand Up @@ -260,6 +283,10 @@ Teuchos::RCP<const Teuchos::ParameterList> CubeHexMeshFactory::getValidParameter

defaultParams->set<bool>("Build Subcells",true);

// default to false for backward compatibility
defaultParams->set<bool>("Create Edge Blocks",false,"Create edge blocks in the mesh");
defaultParams->set<bool>("Create Face Blocks",false,"Create face blocks in the mesh");

Teuchos::ParameterList & bcs = defaultParams->sublist("Periodic BCs");
bcs.set<int>("Count",0); // no default periodic boundary conditions
}
Expand All @@ -282,9 +309,6 @@ void CubeHexMeshFactory::buildMetaData(stk::ParallelMachine /* parallelMach */,
const CellTopologyData * ctd = shards::getCellTopologyData<HexTopo>();
const CellTopologyData * side_ctd = shards::CellTopology(ctd).getBaseCellTopologyData(2,0);

const CellTopologyData * edge_ctd = shards::CellTopology(ctd).getBaseCellTopologyData(1,0);
const CellTopologyData * face_ctd = shards::CellTopology(ctd).getBaseCellTopologyData(2,0);

// build meta data
//mesh.setDimension(2);
for(int bx=0;bx<xBlocks_;bx++) {
Expand Down Expand Up @@ -329,8 +353,12 @@ void CubeHexMeshFactory::buildMetaData(stk::ParallelMachine /* parallelMach */,
// add nodesets
mesh.addNodeset("origin");

if(buildSubcells_) {
if(createEdgeBlocks_) {
const CellTopologyData * edge_ctd = shards::CellTopology(ctd).getBaseCellTopologyData(1,0);
mesh.addEdgeBlock(panzer_stk::STK_Interface::edgeBlockString, edge_ctd);
}
if(createFaceBlocks_) {
const CellTopologyData * face_ctd = shards::CellTopology(ctd).getBaseCellTopologyData(2,0);
mesh.addFaceBlock(panzer_stk::STK_Interface::faceBlockString, face_ctd);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ class CubeHexMeshFactory : public STK_MeshFactory {

bool buildInterfaceSidesets_;
bool buildSubcells_;
bool createEdgeBlocks_;
bool createFaceBlocks_;

mutable Teuchos::Tuple<std::size_t,3> procTuple_;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,25 @@ void CubeTetMeshFactory::completeMeshConstruction(STK_Interface & mesh,stk::Para
// finish up the edges and faces
mesh.buildSubcells();
mesh.buildLocalElementIDs();
mesh.buildLocalEdgeIDs();
mesh.buildLocalFaceIDs();
if(createEdgeBlocks_) {
mesh.buildLocalEdgeIDs();
}
if(createFaceBlocks_) {
mesh.buildLocalFaceIDs();
}

// now that edges are built, sidets can be added
addSideSets(mesh);
addNodeSets(mesh);
addEdgeBlocks(mesh);
addFaceBlocks(mesh);

mesh.beginModification();
if(createEdgeBlocks_) {
addEdgeBlocks(mesh);
}
if(createFaceBlocks_) {
addFaceBlocks(mesh);
}
mesh.endModification();

// calls Stk_MeshFactory::rebalance
this->rebalance(mesh);
Expand Down Expand Up @@ -196,6 +207,9 @@ void CubeTetMeshFactory::setParameterList(const Teuchos::RCP<Teuchos::ParameterL
nYElems_ = paramList->get<int>("Y Elements");
nZElems_ = paramList->get<int>("Z Elements");

createEdgeBlocks_ = paramList->get<bool>("Create Edge Blocks");
createFaceBlocks_ = paramList->get<bool>("Create Face Blocks");

// read in periodic boundary conditions
parsePeriodicBCList(Teuchos::rcpFromRef(paramList->sublist("Periodic BCs")),periodicBCVec_);
}
Expand Down Expand Up @@ -229,6 +243,10 @@ Teuchos::RCP<const Teuchos::ParameterList> CubeTetMeshFactory::getValidParameter
defaultParams->set<int>("Y Elements",5);
defaultParams->set<int>("Z Elements",5);

// default to false for backward compatibility
defaultParams->set<bool>("Create Edge Blocks",false,"Create edge blocks in the mesh");
defaultParams->set<bool>("Create Face Blocks",false,"Create face blocks in the mesh");

Teuchos::ParameterList & bcs = defaultParams->sublist("Periodic BCs");
bcs.set<int>("Count",0); // no default periodic boundary conditions
}
Expand All @@ -251,9 +269,6 @@ void CubeTetMeshFactory::buildMetaData(stk::ParallelMachine /* parallelMach */,
const CellTopologyData * ctd = shards::getCellTopologyData<TetTopo>();
const CellTopologyData * side_ctd = shards::CellTopology(ctd).getBaseCellTopologyData(2,0);

const CellTopologyData * edge_ctd = shards::CellTopology(ctd).getBaseCellTopologyData(1,0);
const CellTopologyData * face_ctd = shards::CellTopology(ctd).getBaseCellTopologyData(2,0);

// build meta data
//mesh.setDimension(2);
for(int bx=0;bx<xBlocks_;bx++) {
Expand All @@ -278,9 +293,15 @@ void CubeTetMeshFactory::buildMetaData(stk::ParallelMachine /* parallelMach */,
mesh.addSideset("back",side_ctd);

mesh.addNodeset("origin");

mesh.addEdgeBlock(panzer_stk::STK_Interface::edgeBlockString, edge_ctd);
mesh.addFaceBlock(panzer_stk::STK_Interface::faceBlockString, face_ctd);

if(createEdgeBlocks_) {
const CellTopologyData * edge_ctd = shards::CellTopology(ctd).getBaseCellTopologyData(1,0);
mesh.addEdgeBlock(panzer_stk::STK_Interface::edgeBlockString, edge_ctd);
}
if(createFaceBlocks_) {
const CellTopologyData * face_ctd = shards::CellTopology(ctd).getBaseCellTopologyData(2,0);
mesh.addFaceBlock(panzer_stk::STK_Interface::faceBlockString, face_ctd);
}
}

void CubeTetMeshFactory::buildElements(stk::ParallelMachine parallelMach,STK_Interface & mesh) const
Expand Down Expand Up @@ -603,40 +624,32 @@ void CubeTetMeshFactory::addNodeSets(STK_Interface & mesh) const
mesh.endModification();
}

// Pre-Condition: call beginModification() before entry
// Post-Condition: call endModification() after exit
void CubeTetMeshFactory::addEdgeBlocks(STK_Interface & mesh) const
{
mesh.beginModification();

stk::mesh::Part * edge_block = mesh.getEdgeBlock(panzer_stk::STK_Interface::edgeBlockString);

Teuchos::RCP<stk::mesh::BulkData> bulkData = mesh.getBulkData();
Teuchos::RCP<stk::mesh::MetaData> metaData = mesh.getMetaData();

std::vector<stk::mesh::Entity> edges;
bulkData->get_entities(mesh.getEdgeRank(),metaData->locally_owned_part(),edges);
for(auto edge : edges) {
mesh.addEntityToEdgeBlock(edge, edge_block);
}

mesh.endModification();
mesh.addEntitiesToEdgeBlock(edges, edge_block);
}

// Pre-Condition: call beginModification() before entry
// Post-Condition: call endModification() after exit
void CubeTetMeshFactory::addFaceBlocks(STK_Interface & mesh) const
{
mesh.beginModification();

stk::mesh::Part * face_block = mesh.getFaceBlock(panzer_stk::STK_Interface::faceBlockString);

Teuchos::RCP<stk::mesh::BulkData> bulkData = mesh.getBulkData();
Teuchos::RCP<stk::mesh::MetaData> metaData = mesh.getMetaData();

std::vector<stk::mesh::Entity> faces;
bulkData->get_entities(mesh.getFaceRank(),metaData->locally_owned_part(),faces);
for(auto face : faces) {
mesh.addEntityToFaceBlock(face, face_block);
}

mesh.endModification();
mesh.addEntitiesToFaceBlock(faces, face_block);
}

//! Convert processor rank to a tuple
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ class CubeTetMeshFactory : public STK_MeshFactory {
mutable unsigned int machRank_, machSize_;

mutable Teuchos::Tuple<std::size_t,3> procTuple_;

bool createEdgeBlocks_;
bool createFaceBlocks_;
};

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ void STK_ExodusReaderFactory::setParameterList(const Teuchos::RCP<Teuchos::Param
levelsOfRefinement_ = paramList->get<int>("Levels of Uniform Refinement");

createEdgeBlocks_ = paramList->get<bool>("Create Edge Blocks");

createFaceBlocks_ = paramList->get<bool>("Create Face Blocks");
}

Expand Down Expand Up @@ -401,10 +400,8 @@ Teuchos::RCP<const Teuchos::ParameterList> STK_ExodusReaderFactory::getValidPara

validParams->set("Rebalancing","default","The type of rebalancing to be performed on the mesh after creation (default, none)");

// default to false to prevent massive exodiff test failures
// default to false for backward compatibility
validParams->set("Create Edge Blocks",false,"Create or copy edge blocks in the mesh");

// default to false to prevent massive exodiff test failures
validParams->set("Create Face Blocks",false,"Create or copy face blocks in the mesh");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ void SquareQuadMeshFactory::completeMeshConstruction(STK_Interface & mesh,stk::P
mesh.buildSubcells();
#endif
mesh.buildLocalElementIDs();
if(createEdgeBlocks_) {
mesh.buildLocalEdgeIDs();
}

// now that edges are built, sidsets can be added
#ifndef ENABLE_UNIFORM
Expand All @@ -169,6 +172,10 @@ void SquareQuadMeshFactory::completeMeshConstruction(STK_Interface & mesh,stk::P
// add nodesets
addNodeSets(mesh);

if(createEdgeBlocks_) {
addEdgeBlocks(mesh);
}

// calls Stk_MeshFactory::rebalance
this->rebalance(mesh);
}
Expand Down Expand Up @@ -197,6 +204,8 @@ void SquareQuadMeshFactory::setParameterList(const Teuchos::RCP<Teuchos::Paramet

offsetGIDs_ = (paramList->get<std::string>("Offset mesh GIDs above 32-bit int limit") == "ON") ? true : false;

createEdgeBlocks_ = paramList->get<bool>("Create Edge Blocks");

// read in periodic boundary conditions
parsePeriodicBCList(Teuchos::rcpFromRef(paramList->sublist("Periodic BCs")),periodicBCVec_);
}
Expand Down Expand Up @@ -225,6 +234,9 @@ Teuchos::RCP<const Teuchos::ParameterList> SquareQuadMeshFactory::getValidParame
defaultParams->set<int>("X Elements",5);
defaultParams->set<int>("Y Elements",5);

// default to false for backward compatibility
defaultParams->set<bool>("Create Edge Blocks",false,"Create edge blocks in the mesh");

Teuchos::setStringToIntegralParameter<int>(
"Offset mesh GIDs above 32-bit int limit",
"OFF",
Expand Down Expand Up @@ -293,6 +305,11 @@ void SquareQuadMeshFactory::buildMetaData(stk::ParallelMachine /* parallelMach *
// add nodesets
mesh.addNodeset("lower_left");
mesh.addNodeset("origin");

if(createEdgeBlocks_) {
const CellTopologyData * edge_ctd = shards::CellTopology(ctd).getBaseCellTopologyData(1,0);
mesh.addEdgeBlock(panzer_stk::STK_Interface::edgeBlockString, edge_ctd);
}
}

void SquareQuadMeshFactory::buildElements(stk::ParallelMachine parallelMach,STK_Interface & mesh) const
Expand Down Expand Up @@ -559,6 +576,22 @@ void SquareQuadMeshFactory::addNodeSets(STK_Interface & mesh) const
mesh.endModification();
}

void SquareQuadMeshFactory::addEdgeBlocks(STK_Interface & mesh) const
{
mesh.beginModification();

stk::mesh::Part * edge_block = mesh.getEdgeBlock(panzer_stk::STK_Interface::edgeBlockString);

Teuchos::RCP<stk::mesh::BulkData> bulkData = mesh.getBulkData();
Teuchos::RCP<stk::mesh::MetaData> metaData = mesh.getMetaData();

std::vector<stk::mesh::Entity> edges;
bulkData->get_entities(mesh.getEdgeRank(),metaData->locally_owned_part(),edges);
mesh.addEntitiesToEdgeBlock(edges, edge_block);

mesh.endModification();
}

//! Convert processor rank to a tuple
Teuchos::Tuple<std::size_t,2> SquareQuadMeshFactory::procRankToProcTuple(std::size_t procRank) const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class SquareQuadMeshFactory : public STK_MeshFactory {

void addSideSets(STK_Interface & mesh) const;
void addNodeSets(STK_Interface & mesh) const;
void addEdgeBlocks(STK_Interface & mesh) const;

double x0_, y0_;
double xf_, yf_;
Expand All @@ -108,6 +109,8 @@ class SquareQuadMeshFactory : public STK_MeshFactory {
mutable unsigned int machRank_, machSize_;
mutable Teuchos::Tuple<std::size_t,2> procTuple_;

bool createEdgeBlocks_;

/// If true, offset mesh GIDs to exercise 32-bit limits.
bool offsetGIDs_;
mutable stk::mesh::EntityId offset_;
Expand Down
Loading

0 comments on commit a5b9f3d

Please sign in to comment.