43 #include "PanzerAdaptersSTK_config.hpp"
48 #include "Teuchos_StandardParameterEntryValidators.hpp"
49 #include <stk_mesh/base/FieldBase.hpp>
50 #include <stk_mesh/base/DumpMeshInfo.hpp>
55 namespace panzer_stk {
58 stk::ParallelMachine mpi_comm,
59 const bool print_debug)
60 : createEdgeBlocks_(false),
61 print_debug_(print_debug)
63 panzer_stk::STK_ExodusReaderFactory factory;
65 pl->
set(
"File Name",quadMeshFileName);
66 factory.setParameterList(pl);
79 const bool print_debug)
80 : quadMesh_(quadMesh),
81 createEdgeBlocks_(false),
82 print_debug_(print_debug)
96 PANZER_FUNC_TIME_MONITOR(
"panzer::QuadraticToLinearMeshFactory::buildMesh()");
109 mesh->initialize(parallelMach);
119 bool errFlag =
false;
121 std::vector<std::string> eblock_names;
129 "ERROR :: Input topology " << inputTopo->getName() <<
" currently unsupported by QuadraticToLinearMeshFactory!");
133 for (
auto & eblock : eblock_names) {
135 if (*cellTopo != *inputTopo) errFlag =
true;
139 "ERROR :: The mesh has different topologies on different blocks!");
151 PANZER_FUNC_TIME_MONITOR(
"panzer::QuadraticToLinearMeshFactory::buildUncomittedMesh()");
155 machRank_ = stk::parallel_machine_rank(parallelMach);
156 machSize_ = stk::parallel_machine_size(parallelMach);
169 PANZER_FUNC_TIME_MONITOR(
"panzer::QuadraticToLinearMeshFactory::completeMeshConstruction()");
178 #ifndef ENABLE_UNIFORM
187 #ifndef ENABLE_UNIFORM
227 if(defaultParams == Teuchos::null) {
230 defaultParams->
set<std::string>(
"Offset mesh GIDs above 32-bit int limit",
"OFF",
231 "If 64-bit GIDs are supported, the mesh element and node global indices will start at a value greater than 32-bit limit.",
235 defaultParams->
set<
bool>(
"Create Edge Blocks",
false,
"Create edge blocks in the mesh");
238 bcs.
set<
int>(
"Count",0);
241 return defaultParams;
247 std::cout <<
"\n\n**** DEBUG: begin printing source quad mesh exodus file metadata ****\n";
249 std::cout <<
"\n\n**** DEBUG: end printing source quad mesh exodus file metadata ****\n";
255 const CellTopologyData * side_ctd = shards::CellTopology(ctd).getBaseCellTopologyData(
nDim_-1,0);
258 std::vector<std::string> element_block_names;
261 for (
const auto& n : element_block_names)
267 std::vector<std::string> sideset_names;
269 for (
const auto& n : sideset_names)
275 std::vector<std::string> nodeset_names;
277 for (
const auto& n : nodeset_names)
282 const CellTopologyData * edge_ctd = shards::CellTopology(ctd).getBaseCellTopologyData(1,0);
283 std::vector<std::string> element_block_names;
285 for (
const auto& block_name : element_block_names)
292 for (
const auto& f : fields) {
294 std::cout <<
"Field=" << f->name() <<
", rank=" << f->entity_rank() << std::endl;
298 if (f->name() !=
"coordinates") {
299 for (
const auto& n : element_block_names)
308 for (
const auto& f : fields) {
310 std::cout <<
"Add Cell Field=" << f->name() <<
", rank=" << f->entity_rank() << std::endl;
312 for (
const auto& n : element_block_names)
324 std::cout <<
"\n\n**** DEBUG: begin printing source linear mesh exodus file metadata ****\n";
325 stk::mesh::impl::dump_all_meta_info(*(mesh.
getMetaData()), std::cout);
326 std::cout <<
"\n\n**** DEBUG: end printing source linear mesh exodus file metadata ****\n";
338 std::vector<std::string> block_names;
340 for (
const auto& block_name : block_names) {
343 std::vector<stk::mesh::Entity> elements;
347 std::cout <<
"*************************************************" << std::endl;
348 std::cout <<
"block_name=" << block_name <<
", num_my_elements=" << elements.size() << std::endl;
349 std::cout <<
"*************************************************" << std::endl;
352 for (
const auto& element : elements) {
358 <<
", block=" << block_name
359 <<
", element entity_id=" << element
360 <<
", gid=" << element_gid << std::endl;
364 std::vector<stk::mesh::EntityId> nodes(
nNodes_);
365 for (
size_t i=0; i <
nNodes_; ++i) {
375 std::vector<double> coords_vec(
nDim_);
376 for (
size_t j=0; j <
nDim_; ++j) coords_vec[j] = node_coords[j];
377 mesh.
addNode(node_gid,coords_vec);
382 <<
", node_gid=" << node_gid <<
", ("
383 << coords_vec[0] <<
"," << coords_vec[1] <<
")\n";
386 <<
", node_gid=" << node_gid <<
", ("
387 << coords_vec[0] <<
"," << coords_vec[1] <<
"," << coords_vec[2] <<
")\n";
394 auto element_block_part = mesh.
getMetaData()->get_part(block_name);
395 mesh.
addElement(element_descriptor,element_block_part);
406 std::vector<std::string> sideset_names;
408 for (
const auto& sideset_name : sideset_names) {
410 stk::mesh::Part* sideset_part = mesh.
getSideset(sideset_name);
412 std::vector<stk::mesh::Entity> q_sides;
416 for (
const auto q_ent : q_sides) {
442 stk::mesh::Selector owned_block = metaData->locally_owned_part();
444 std::vector<stk::mesh::Entity> edges;
445 bulkData->get_entities(mesh.
getEdgeRank(), owned_block, edges);
457 for (
const auto&
field : fields) {
460 std::cout <<
"Adding field values for \"" << *
field <<
"\" to the linear mesh!\n";
462 auto field_name = field->name();
466 if (field->type_is<
double>() &&
467 field_name !=
"coordinates" &&
468 field_name !=
"PROC_ID" &&
469 field_name !=
"LOAD_BAL") {
472 std::vector<std::string> block_names;
474 for (
const auto& block : block_names) {
476 auto* lin_field = lin_mesh.
getCellField(field_name,block);
486 std::vector<stk::mesh::Entity> lin_elements;
488 std::vector<stk::mesh::Entity> q_elements;
492 for (
size_t i=0; i < lin_elements.size(); ++i) {
498 double*
const lin_val =
static_cast<double*
>(stk::mesh::field_data(*lin_field,lin_elements[i]));
499 const double*
const q_val =
static_cast<double*
>(stk::mesh::field_data(*q_field,q_elements[i]));
503 std::cout <<
"field=" << field_name <<
", block=" << block
504 <<
", 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_
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
#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.
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.