13 #include <PanzerAdaptersSTK_config.hpp>
18 namespace panzer_stk {
34 PANZER_FUNC_TIME_MONITOR(
"panzer::CustomMeshFactory::buildMesh()");
40 mesh->initialize(parallelMach);
51 PANZER_FUNC_TIME_MONITOR(
"panzer::CustomMeshFactory::buildUncomittedMesh()");
55 machRank_ = stk::parallel_machine_rank(parallelMach);
56 machSize_ = stk::parallel_machine_size(parallelMach);
69 stk::ParallelMachine parallelMach)
const
71 PANZER_FUNC_TIME_MONITOR(
"panzer::CustomMeshFactory::completeMeshConstruction()");
134 if(defaultParams == Teuchos::null) {
137 defaultParams->
set<
int>(
"Dimension",3);
139 defaultParams->
set<
int>(
"NumBlocks",0);
141 defaultParams->
set<
int>(
"NumNodesPerProc",0);
142 defaultParams->
set<
int*>(
"Nodes",NULL);
144 defaultParams->
set<
double*>(
"Coords",NULL);
146 defaultParams->
set<
int>(
"NumElementsPerProc",0);
148 defaultParams->
set<
int*>(
"BlockIDs",NULL);
149 defaultParams->
set<
int*>(
"Element2Nodes",NULL);
151 defaultParams->
set<
int>(
"OffsetToGlobalElementIDs", 0);
153 defaultParams->
set<
double*>(
"ChargeDensity",NULL);
154 defaultParams->
set<
double*>(
"ElectricPotential",NULL);
157 bcs.
set<
int>(
"Count",0);
160 return defaultParams;
176 typedef shards::Hexahedron<8> HexTopo;
177 const CellTopologyData *ctd = shards::getCellTopologyData<HexTopo>();
178 const CellTopologyData *side_ctd = shards::CellTopology(ctd).getBaseCellTopologyData(2,0);
181 std::stringstream block_id;
182 block_id <<
"eblock-" << blk;
209 std::vector<double> coords(dim,0.0);
211 for (
int k=0;k<dim;++k)
217 std::vector<std::string> block_ids;
223 std::stringstream block_id;
230 std::vector<stk::mesh::EntityId> elt2nodes(8);
232 for (
int k=0;k<8;++k)
246 stk::mesh::BulkData& bulkData = *mesh.
getBulkData();
247 const stk::mesh::EntityRank sideRank = mesh.
getSideRank();
250 stk::mesh::Part *box[6];
258 stk::mesh::Part *wall = mesh.
getSideset(
"wall");
260 std::vector<stk::mesh::Entity> elements;
264 for (std::vector<stk::mesh::Entity>::const_iterator
265 itr=elements.begin();itr!=elements.end();++itr) {
266 stk::mesh::Entity element = (*itr);
267 const size_t numSides = bulkData.num_connectivity(element, sideRank);
268 stk::mesh::Entity
const* relations = bulkData.begin(element, sideRank);
271 for (std::size_t i=0;i<numSides;++i) {
272 stk::mesh::Entity side = relations[i];
273 const size_t numNeighbors = bulkData.num_elements(side);
274 stk::mesh::Entity
const* neighbors = bulkData.begin_elements(side);
276 if (numNeighbors == 1) {
280 else if (numNeighbors == 2) {
298 constexpr std::size_t dim_1 = 8;
302 std::stringstream block_id;
303 block_id <<
"eblock-" << blk;
306 std::vector<stk::mesh::Entity> elements;
310 const auto n_elements = elements.size();
313 std::vector<std::size_t> local_ids;
318 for (
const auto& elem : elements){
322 for (std::size_t k=0;k<dim_1;++k) {
323 const auto loc = q*dim_1 + k;
333 charge_density_by_local_ids, 1.0);
338 electric_potential_by_local_ids, 1.0);
unsigned entityOwnerRank(stk::mesh::Entity entity) const
void setSolutionFieldData(const std::string &fieldName, const std::string &blockId, const std::vector< std::size_t > &localElementIds, const ArrayT &solutionValues, double scaleValue=1.0)
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > ¶mList)
From ParameterListAcceptor.
static void parsePeriodicBCList(const Teuchos::RCP< Teuchos::ParameterList > &pl, std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > &periodicBC, bool &useBBoxSearch)
void getElementBlockNames(std::vector< std::string > &names) const
T & get(const std::string &name, T def_value)
stk::mesh::Part * getElementBlockPart(const std::string &name) const
get the block part
void addEntityToSideset(stk::mesh::Entity entity, stk::mesh::Part *sideset)
void addSolutionField(const std::string &fieldName, const std::string &blockId)
void initializeWithDefaults()
CustomMeshFactory()
Constructor.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
stk::mesh::Part * getSideset(const std::string &name) const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
From ParameterListAcceptor.
Teuchos::RCP< STK_Interface > buildMesh(stk::ParallelMachine parallelMach) const
Build the mesh object.
std::size_t elementLocalId(stk::mesh::Entity elmt) const
void addSideSets(STK_Interface &mesh) const
unsigned getDimension() const
get the dimension
void addElement(const Teuchos::RCP< ElementDescriptor > &ed, stk::mesh::Part *block)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
stk::mesh::EntityRank getSideRank() const
void initialize(stk::ParallelMachine parallelMach, bool setupIO=true, const bool buildRefinementSupport=false)
virtual void completeMeshConstruction(STK_Interface &mesh, stk::ParallelMachine parallelMach) const
Teuchos::RCP< stk::mesh::BulkData > getBulkData() const
virtual ~CustomMeshFactory()
Destructor.
stk::mesh::EntityId elementGlobalId(std::size_t lid) const
void setMyParamList(const RCP< ParameterList > ¶mList)
void validateParametersAndSetDefaults(ParameterList const &validParamList, int const depth=1000)
double * ElectricPotential_
std::string containingBlockId(stk::mesh::Entity elmt) const
void addNode(stk::mesh::EntityId gid, const std::vector< double > &coord)
void buildSubcells()
force the mesh to build subcells: edges and faces
bool isInitialized() const
Has initialize been called on this mesh object?
void fillSolutionFieldData(STK_Interface &mesh) const
void buildElements(STK_Interface &mesh) const
int OffsetToGlobalElementIDs_
void addSideset(const std::string &name, const CellTopologyData *ctData)
std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > periodicBCVec_
void buildLocalElementIDs()
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
void getMyElements(std::vector< stk::mesh::Entity > &elements) const
virtual Teuchos::RCP< STK_Interface > buildUncommitedMesh(stk::ParallelMachine parallelMach) const
void buildMetaData(STK_Interface &mesh) const
void addElementBlock(const std::string &name, const CellTopologyData *ctData)