11 #include "PanzerAdaptersSTK_config.hpp"
16 #include "Teuchos_StandardParameterEntryValidators.hpp"
17 #include <stk_mesh/base/FieldBase.hpp>
18 #include <stk_mesh/base/DumpMeshInfo.hpp>
23 namespace panzer_stk {
26 stk::ParallelMachine mpi_comm,
27 const bool print_debug)
28 : createEdgeBlocks_(false),
29 print_debug_(print_debug)
31 panzer_stk::STK_ExodusReaderFactory factory;
33 pl->
set(
"File Name",quadMeshFileName);
34 factory.setParameterList(pl);
47 const bool print_debug)
48 : quadMesh_(quadMesh),
49 createEdgeBlocks_(false),
50 print_debug_(print_debug)
64 PANZER_FUNC_TIME_MONITOR(
"panzer::QuadraticToLinearMeshFactory::buildMesh()");
77 mesh->initialize(parallelMach);
89 std::vector<std::string> eblock_names;
97 "ERROR :: Input topology " << inputTopo->getName() <<
" currently unsupported by QuadraticToLinearMeshFactory!");
101 for (
auto & eblock : eblock_names) {
103 if (*cellTopo != *inputTopo) errFlag =
true;
107 "ERROR :: The mesh has different topologies on different blocks!");
119 PANZER_FUNC_TIME_MONITOR(
"panzer::QuadraticToLinearMeshFactory::buildUncomittedMesh()");
123 machRank_ = stk::parallel_machine_rank(parallelMach);
124 machSize_ = stk::parallel_machine_size(parallelMach);
137 PANZER_FUNC_TIME_MONITOR(
"panzer::QuadraticToLinearMeshFactory::completeMeshConstruction()");
146 #ifndef ENABLE_UNIFORM
155 #ifndef ENABLE_UNIFORM
195 if(defaultParams == Teuchos::null) {
198 defaultParams->
set<std::string>(
"Offset mesh GIDs above 32-bit int limit",
"OFF",
199 "If 64-bit GIDs are supported, the mesh element and node global indices will start at a value greater than 32-bit limit.",
203 defaultParams->
set<
bool>(
"Create Edge Blocks",
false,
"Create edge blocks in the mesh");
206 bcs.
set<
int>(
"Count",0);
209 return defaultParams;
215 std::cout <<
"\n\n**** DEBUG: begin printing source quad mesh exodus file metadata ****\n";
217 std::cout <<
"\n\n**** DEBUG: end printing source quad mesh exodus file metadata ****\n";
223 const CellTopologyData * side_ctd = shards::CellTopology(ctd).getBaseCellTopologyData(
nDim_-1,0);
226 std::vector<std::string> element_block_names;
229 for (
const auto& n : element_block_names)
235 std::vector<std::string> sideset_names;
237 for (
const auto& n : sideset_names)
243 std::vector<std::string> nodeset_names;
245 for (
const auto& n : nodeset_names)
250 const CellTopologyData * edge_ctd = shards::CellTopology(ctd).getBaseCellTopologyData(1,0);
251 std::vector<std::string> element_block_names2;
253 for (
const auto& block_name : element_block_names2)
260 for (
const auto& f : fields) {
262 std::cout <<
"Field=" << f->name() <<
", rank=" << f->entity_rank() << std::endl;
266 if (f->name() !=
"coordinates") {
267 for (
const auto& n : element_block_names)
276 for (
const auto& f : fields) {
278 std::cout <<
"Add Cell Field=" << f->name() <<
", rank=" << f->entity_rank() << std::endl;
280 for (
const auto& n : element_block_names)
292 std::cout <<
"\n\n**** DEBUG: begin printing source linear mesh exodus file metadata ****\n";
293 stk::mesh::impl::dump_all_meta_info(*(mesh.
getMetaData()), std::cout);
294 std::cout <<
"\n\n**** DEBUG: end printing source linear mesh exodus file metadata ****\n";
306 std::vector<std::string> block_names;
308 for (
const auto& block_name : block_names) {
311 std::vector<stk::mesh::Entity> elements;
315 std::cout <<
"*************************************************" << std::endl;
316 std::cout <<
"block_name=" << block_name <<
", num_my_elements=" << elements.size() << std::endl;
317 std::cout <<
"*************************************************" << std::endl;
320 for (
const auto& element : elements) {
326 <<
", block=" << block_name
327 <<
", element entity_id=" << element
328 <<
", gid=" << element_gid << std::endl;
332 std::vector<stk::mesh::EntityId> nodes(
nNodes_);
333 for (
size_t i=0; i <
nNodes_; ++i) {
343 std::vector<double> coords_vec(
nDim_);
344 for (
size_t j=0; j <
nDim_; ++j) coords_vec[j] = node_coords[j];
345 mesh.
addNode(node_gid,coords_vec);
350 <<
", node_gid=" << node_gid <<
", ("
351 << coords_vec[0] <<
"," << coords_vec[1] <<
")\n";
354 <<
", node_gid=" << node_gid <<
", ("
355 << coords_vec[0] <<
"," << coords_vec[1] <<
"," << coords_vec[2] <<
")\n";
362 auto element_block_part = mesh.
getMetaData()->get_part(block_name);
363 mesh.
addElement(element_descriptor,element_block_part);
374 std::vector<std::string> sideset_names;
376 for (
const auto& sideset_name : sideset_names) {
378 stk::mesh::Part* sideset_part = mesh.
getSideset(sideset_name);
380 std::vector<stk::mesh::Entity> q_sides;
384 for (
const auto q_ent : q_sides) {
410 stk::mesh::Selector owned_block = metaData->locally_owned_part();
412 std::vector<stk::mesh::Entity> edges;
413 bulkData->get_entities(mesh.
getEdgeRank(), owned_block, edges);
425 for (
const auto&
field : fields) {
428 std::cout <<
"Adding field values for \"" << *
field <<
"\" to the linear mesh!\n";
430 auto field_name = field->name();
434 if (field->type_is<
double>() &&
435 field_name !=
"coordinates" &&
436 field_name !=
"PROC_ID" &&
437 field_name !=
"LOAD_BAL") {
440 std::vector<std::string> block_names;
442 for (
const auto& block : block_names) {
444 auto* lin_field = lin_mesh.
getCellField(field_name,block);
454 std::vector<stk::mesh::Entity> lin_elements;
456 std::vector<stk::mesh::Entity> q_elements;
460 for (
size_t i=0; i < lin_elements.size(); ++i) {
466 double*
const lin_val =
static_cast<double*
>(stk::mesh::field_data(*lin_field,lin_elements[i]));
467 const double*
const q_val =
static_cast<double*
>(stk::mesh::field_data(*q_field,q_elements[i]));
471 std::cout <<
"field=" << field_name <<
", block=" << block
472 <<
", lin_e(" << lin_mesh.
getBulkData()->identifier(lin_elements[i]) <<
") = " << *lin_val
QuadraticToLinearMeshFactory(const std::string &quadMeshFileName, stk::ParallelMachine mpi_comm=MPI_COMM_WORLD, const bool print_debug=false)
Teuchos::RCP< ElementDescriptor > buildElementDescriptor(stk::mesh::EntityId elmtId, std::vector< stk::mesh::EntityId > &nodes)
void getSidesetNames(std::vector< std::string > &name) const
void addNodeset(const std::string &name)
const CellTopologyData * outputTopoData_
static void parsePeriodicBCList(const Teuchos::RCP< Teuchos::ParameterList > &pl, std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > &periodicBC, bool &useBBoxSearch)
unsigned int nNodes_
Dimension of the mesh.
std::map< const std::string, const CellTopologyData * > outputTopoMap_
void getElementBlockNames(std::vector< std::string > &names) const
T & get(const std::string &name, T def_value)
void buildElements(stk::ParallelMachine parallelMach, STK_Interface &mesh) const
Teuchos::RCP< panzer_stk::STK_Interface > quadMesh_
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void addEntityToSideset(stk::mesh::Entity entity, stk::mesh::Part *sideset)
void addSolutionField(const std::string &fieldName, const std::string &blockId)
std::string edgeBlockName_
unsigned int nDim_
Output mesh topology data.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Teuchos::RCP< STK_Interface > buildMesh(stk::ParallelMachine parallelMach) const
Build the mesh object.
void addEdgeBlock(const std::string &elemBlockName, const std::string &edgeBlockName, const stk::topology &topology)
const double * getNodeCoordinates(stk::mesh::EntityId nodeId) const
stk::mesh::Part * getSideset(const std::string &name) const
void getMySides(const std::string &sideName, std::vector< stk::mesh::Entity > &sides) const
PHX::MDField< ScalarT, panzer::Cell, panzer::IP > result
A field that will be used to build up the result of the integral we're performing.
void addElement(const Teuchos::RCP< ElementDescriptor > &ed, stk::mesh::Part *block)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Derived from ParameterListAcceptor.
stk::mesh::EntityRank getSideRank() const
void initialize(stk::ParallelMachine parallelMach, bool setupIO=true, const bool buildRefinementSupport=false)
Teuchos::RCP< stk::mesh::BulkData > getBulkData() const
void addNodeSets(STK_Interface &mesh) const
void setMyParamList(const RCP< ParameterList > ¶mList)
void validateParametersAndSetDefaults(ParameterList const &validParamList, int const depth=1000)
static const std::string edgeBlockString
void buildMetaData(stk::ParallelMachine parallelMach, STK_Interface &mesh) const
void addSideSets(STK_Interface &mesh) const
void addNode(stk::mesh::EntityId gid, const std::vector< double > &coord)
void addEntitiesToEdgeBlock(std::vector< stk::mesh::Entity > entities, stk::mesh::Part *edgeblock)
void buildSubcells()
force the mesh to build subcells: edges and faces
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > ¶mList)
Derived from ParameterListAcceptor.
Teuchos::RCP< stk::mesh::MetaData > getMetaData() const
bool isInitialized() const
Has initialize been called on this mesh object?
stk::mesh::Entity findConnectivityById(stk::mesh::Entity src, stk::mesh::EntityRank tgt_rank, unsigned rel_id) const
void addSideset(const std::string &name, const CellTopologyData *ctData)
stk::mesh::Part * getEdgeBlock(const std::string &name) const
get the block part
PHX::MDField< ScalarT, panzer::Cell, panzer::BASIS > field
A field to which we'll contribute, or in which we'll store, the result of computing this integral...
std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > periodicBCVec_
stk::mesh::EntityRank getEdgeRank() const
virtual void completeMeshConstruction(STK_Interface &mesh, stk::ParallelMachine parallelMach) const
void buildLocalElementIDs()
void addEdgeBlocks(STK_Interface &mesh) const
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
void getMyElements(std::vector< stk::mesh::Entity > &elements) const
#define TEUCHOS_ASSERT(assertion_test)
void copyCellFieldData(STK_Interface &mesh) const
stk::mesh::EntityRank getNodeRank() const
unsigned int machRank_
Second order mesh.
void addCellField(const std::string &fieldName, const std::string &blockId)
stk::mesh::EntityRank getElementRank() const
virtual Teuchos::RCP< STK_Interface > buildUncommitedMesh(stk::ParallelMachine parallelMach) const
void addElementBlock(const std::string &name, const CellTopologyData *ctData)
stk::mesh::Field< double > * getCellField(const std::string &fieldName, const std::string &blockId) const
void getNodesetNames(std::vector< std::string > &name) const
Teuchos::RCP< const shards::CellTopology > getCellTopology(const std::string &eBlock) const
std::vector< shards::CellTopology > supportedInputTopos_
Nodes in one element of the linear basis.