291 std::cout <<
"Creating side set from free surface." << std::endl;
293 std::vector<std::pair<int, int>> freeSurfCellEdge;
294 std::vector<std::pair<int, int>> hexFreeSurfCellFace;
295 std::vector<std::pair<int, int>> wedgeFreeSurfCellFace;
296 std::vector<std::pair<int, int>> tetraFreeSurfCellFace;
297 std::vector<int> elementIds1, elementIds2, elementIds3, sideIds1, sideIds2,
299 std::vector<std::vector<int>> splitElemIds, splitSideIds;
302 std::map<int, int> v2e_hexFace_map = {{1, 4}, {2, 2}, {3, 1},
303 {4, 3}, {5, 5}, {6, 6}};
304 std::map<int, int> v2e_wedgeFace_map = {
305 {1, 4}, {2, 5}, {3, 1}, {4, 2}, {5, 3}};
306 std::map<int, int> v2e_tetraFace_map = {{1, 1}, {2, 2}, {3, 3}, {4, 4}};
309 vtkSmartPointer<vtkDataSet> ds = mb->
getDataSet();
311 std::cerr <<
"No dataset is associated to the meshbase." << std::endl;
314 bool tetWarning =
false;
316 int nCl = ds->GetNumberOfCells();
317 for (
int cell_i = 0; cell_i < nCl; cell_i++) {
318 vtkCell *vc = ds->GetCell(cell_i);
319 if (vc->GetCellDimension() == 2) {
321 int ne = vc->GetNumberOfEdges();
322 for (
int edge_i = 0; edge_i < ne; edge_i++) {
323 vtkCell *ve = vc->GetEdge(edge_i);
324 vtkIdList *pidl = ve->GetPointIds();
326 std::pair<int, int> adjPair;
330 ds->GetCellNeighbors(cell_i, pidl, cidl);
331 if (cidl->GetNumberOfIds() == 0) {
332 adjPair.first = cell_i;
333 adjPair.second = edge_i + 1;
334 freeSurfCellEdge.push_back(adjPair);
337 }
else if (vc->GetCellDimension() == 3) {
339 int nfc = vc->GetNumberOfFaces();
340 for (
int face_i = 0; face_i < nfc; face_i++) {
341 vtkCell *vf = vc->GetFace(face_i);
342 vtkIdList *facePoints = vf->GetPointIds();
344 std::pair<int, int> adjPair;
348 ds->GetCellNeighbors(cell_i, facePoints, cidl);
349 if (cidl->GetNumberOfIds() == 0) {
350 adjPair.first = cell_i;
351 adjPair.second = face_i + 1;
352 if (nfc == 6) hexFreeSurfCellFace.push_back(adjPair);
353 if (nfc == 5) wedgeFreeSurfCellFace.push_back(adjPair);
355 tetraFreeSurfCellFace.push_back(adjPair);
356 if (splitTopBotSS && tetWarning ==
false) {
358 <<
"Warning: Tetrahedral element found on free surface.\n" 359 <<
" Cannot split top and bottom into separate side " 361 <<
" Creating single side set." << std::endl;
362 splitTopBotSS =
false;
374 for (
int i = 0; i < hexFreeSurfCellFace.size(); i++) {
375 int exoId = v2e_elemID_map[hexFreeSurfCellFace[i].first];
376 int sId = v2e_hexFace_map[hexFreeSurfCellFace[i].second];
381 elementIds2.push_back(exoId);
382 sideIds2.push_back(sId);
383 }
else if (sId == 6) {
385 elementIds3.push_back(exoId);
386 sideIds3.push_back(sId);
388 elementIds1.push_back(exoId);
389 sideIds1.push_back(sId);
392 elementIds1.push_back(exoId);
393 sideIds1.push_back(sId);
397 for (
int i = 0; i < wedgeFreeSurfCellFace.size(); i++) {
398 int exoId = v2e_elemID_map[wedgeFreeSurfCellFace[i].first];
399 int sId = v2e_wedgeFace_map[wedgeFreeSurfCellFace[i].second];
404 elementIds2.push_back(exoId);
405 sideIds2.push_back(sId);
406 }
else if (sId == 5) {
408 elementIds3.push_back(exoId);
409 sideIds3.push_back(sId);
411 elementIds1.push_back(exoId);
412 sideIds1.push_back(sId);
415 elementIds1.push_back(exoId);
416 sideIds1.push_back(sId);
420 for (
int i = 0; i < tetraFreeSurfCellFace.size(); i++) {
421 int exoId = v2e_elemID_map[tetraFreeSurfCellFace[i].first];
422 int sId = v2e_tetraFace_map[tetraFreeSurfCellFace[i].second];
423 elementIds1.push_back(exoId);
424 sideIds1.push_back(sId);
430 for (
int i = 0; i < freeSurfCellEdge.size(); i++) {
432 int exoId = v2e_elemID_map[freeSurfCellEdge[i].first];
433 elementIds1.push_back(exoId);
434 sideIds1.push_back(freeSurfCellEdge[i].second);
439 splitElemIds = {elementIds1, elementIds2, elementIds3};
440 splitSideIds = {sideIds1, sideIds2, sideIds3};
442 splitElemIds = {elementIds1};
443 splitSideIds = {sideIds1};
446 for (
int i = 0; i < splitElemIds.size(); ++i) {
450 if (sideSetNames.size() == 1 && splitElemIds.size() == 1) {
451 ss.
name = sideSetNames[i];
453 if (sideSetNames.size() == 0) {
454 std::cout <<
"side set names size is zero" << std::endl;
455 ss.
name =
"side_set_000000" + std::to_string(i + 1);
457 if (sideSetNames.size() > 0 && sideSetNames.size() < 3 && splitTopBotSS) {
458 std::cerr <<
"Error: Expected 3 'Side Set Names', found " 459 << sideSetNames.size() << std::endl;
462 if (sideSetNames.size() == 3) {
463 ss.
name = sideSetNames[i];
468 ss.
nSde = (int)splitSideIds[i].size();
469 ss.
elmIds = splitElemIds[i];
470 ss.
sdeIds = splitSideIds[i];
int getDimension() const
Returns problem dimension.
std::vector< int > sdeIds
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
std::vector< int > elmIds
Stores side set information.
vtkSmartPointer< vtkDataSet > getDataSet() const
get this meshes' dataSet
void addSdeSet(const sdeSetType &ss)
Add side set to the database.