45 #include <PanzerAdaptersSTK_config.hpp>
50 namespace panzer_stk {
66 PANZER_FUNC_TIME_MONITOR(
"panzer::CustomMeshFactory::buildMesh()");
72 mesh->initialize(parallelMach);
83 PANZER_FUNC_TIME_MONITOR(
"panzer::CustomMeshFactory::buildUncomittedMesh()");
87 machRank_ = stk::parallel_machine_rank(parallelMach);
88 machSize_ = stk::parallel_machine_size(parallelMach);
100 stk::ParallelMachine parallelMach)
const
102 PANZER_FUNC_TIME_MONITOR(
"panzer::CustomMeshFactory::completeMeshConstruction()");
165 if(defaultParams == Teuchos::null) {
168 defaultParams->
set<
int>(
"Dimension",3);
170 defaultParams->
set<
int>(
"NumBlocks",0);
172 defaultParams->
set<
int>(
"NumNodesPerProc",0);
173 defaultParams->
set<
int*>(
"Nodes",NULL);
175 defaultParams->
set<
double*>(
"Coords",NULL);
177 defaultParams->
set<
int>(
"NumElementsPerProc",0);
179 defaultParams->
set<
int*>(
"BlockIDs",NULL);
180 defaultParams->
set<
int*>(
"Element2Nodes",NULL);
182 defaultParams->
set<
int>(
"OffsetToGlobalElementIDs", 0);
184 defaultParams->
set<
double*>(
"ChargeDensity",NULL);
185 defaultParams->
set<
double*>(
"ElectricPotential",NULL);
188 bcs.
set<
int>(
"Count",0);
191 return defaultParams;
207 typedef shards::Hexahedron<8> HexTopo;
208 const CellTopologyData *ctd = shards::getCellTopologyData<HexTopo>();
209 const CellTopologyData *side_ctd = shards::CellTopology(ctd).getBaseCellTopologyData(2,0);
212 std::stringstream block_id;
213 block_id <<
"eblock-" << blk;
240 std::vector<double> coords(dim,0.0);
242 for (
int k=0;k<dim;++k)
248 std::vector<std::string> block_ids;
254 std::stringstream block_id;
261 std::vector<stk::mesh::EntityId> elt2nodes(8);
263 for (
int k=0;k<8;++k)
277 stk::mesh::BulkData& bulkData = *mesh.
getBulkData();
278 const stk::mesh::EntityRank sideRank = mesh.
getSideRank();
281 stk::mesh::Part *box[6];
289 stk::mesh::Part *wall = mesh.
getSideset(
"wall");
291 std::vector<stk::mesh::Entity> elements;
295 for (std::vector<stk::mesh::Entity>::const_iterator
296 itr=elements.begin();itr!=elements.end();++itr) {
297 stk::mesh::Entity element = (*itr);
298 const size_t numSides = bulkData.num_connectivity(element, sideRank);
299 stk::mesh::Entity
const* relations = bulkData.begin(element, sideRank);
302 for (std::size_t i=0;i<numSides;++i) {
303 stk::mesh::Entity side = relations[i];
304 const size_t numNeighbors = bulkData.num_elements(side);
305 stk::mesh::Entity
const* neighbors = bulkData.begin_elements(side);
307 if (numNeighbors == 1) {
311 else if (numNeighbors == 2) {
331 std::stringstream block_id;
332 block_id <<
"eblock-" << blk;
335 std::vector<stk::mesh::Entity> elements;
339 std::size_t n_elements = elements.size();
342 std::vector<std::size_t> local_ids;
343 for (std::vector<stk::mesh::Entity>::const_iterator
344 itr=elements.begin();itr!=elements.end();++itr)
348 std::vector<double> charge_density_by_local_ids, electric_potential_by_local_ids;
349 for (std::vector<stk::mesh::Entity>::const_iterator
350 itr=elements.begin();itr!=elements.end();++itr) {
352 for (
int k=0;k<8;++k) {
360 FieldContainer charge_density(n_elements, 8, &charge_density_by_local_ids[0]),
361 electric_potential(n_elements, 8, &electric_potential_by_local_ids[0]);
367 charge_density, 1.0);
372 electric_potential, 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.
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 count
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
void addEntityToSideset(stk::mesh::Entity entity, stk::mesh::Part *sideset)
void addSolutionField(const std::string &fieldName, const std::string &blockId)
void initializeWithDefaults()
CustomMeshFactory()
Constructor.
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)
static void parsePeriodicBCList(const Teuchos::RCP< Teuchos::ParameterList > &pl, std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > &periodicBC)