Skip to content

Commit

Permalink
Merge pull request #69 from vincentcasseau/main
Browse files Browse the repository at this point in the history
Transform: subzone by faces for NGon v4 and BE/ME
  • Loading branch information
vincentcasseau authored Jun 27, 2024
2 parents fa902aa + 9e650d9 commit a48f09c
Show file tree
Hide file tree
Showing 5 changed files with 495 additions and 214 deletions.
4 changes: 4 additions & 0 deletions Cassiopee/KCore/KCore/Connect/connect.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ namespace K_CONNECT
/*----------------------------------*/
/* - Connectivite element basique - */
/*----------------------------------*/
/* Get all facets of a basic element*/
E_Int getEVFacets(std::vector<std::vector<E_Int> >& facets,
const char* eltType, E_Bool allow_degenerated=true);

/* Change a Elts-Vertex connectivity to a Vertex-Elts connectivity.
cVE doit deja etre alloue au nombre de noeuds. */
void connectEV2VE(K_FLD::FldArrayI& cEV,
Expand Down
93 changes: 93 additions & 0 deletions Cassiopee/KCore/KCore/Connect/getEVFacets.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
Copyright 2013-2024 Onera.
This file is part of Cassiopee.
Cassiopee is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Cassiopee is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Cassiopee. If not, see <http://www.gnu.org/licenses/>.
*/

#include "Connect/connect.h"
#include "String/kstring.h"
#include <vector>

//=============================================================================
/* Get all facets of a basic element
IN: eltType: Type of basic element
IN: allow_degenerated: whether to allow degenerated elements (in which case
the last vertex of a degenerated facet is a repetition
of the first)
OUT: facets: vertex indices for each of the facets - indexing starts at 1
Return: error index 0 (ok), 1 (error) */
//=============================================================================
E_Int K_CONNECT::getEVFacets(std::vector<std::vector<E_Int> >& facets,
const char* eltType, E_Bool allow_degenerated)
{
E_Int ierr = 0;
facets.clear();

if (K_STRING::cmp(eltType, "BAR") == 0)
{
facets.push_back({1}); facets.push_back({2});
}
else if (K_STRING::cmp(eltType, "TRI") == 0)
{
facets.push_back({1, 2}); facets.push_back({2, 3});
facets.push_back({3, 1});
}
else if (K_STRING::cmp(eltType, "QUAD") == 0)
{
facets.push_back({1, 2}); facets.push_back({2, 3});
facets.push_back({3, 4}); facets.push_back({4, 1});
}
else if (K_STRING::cmp(eltType, "TETRA") == 0)
{
facets.push_back({1, 3, 2}); facets.push_back({1, 2, 4});
facets.push_back({2, 3, 4}); facets.push_back({3, 1, 4});
}
else if (K_STRING::cmp(eltType, "PYRA") == 0)
{
facets.push_back({1, 4, 3, 2});
if (allow_degenerated)
{
facets.push_back({1, 2, 5, 1}); facets.push_back({2, 3, 5, 2});
facets.push_back({3, 4, 5, 3}); facets.push_back({4, 1, 5, 4});
}
else
{
facets.push_back({1, 2, 5}); facets.push_back({2, 3, 5});
facets.push_back({3, 4, 5}); facets.push_back({4, 1, 5});
}
}
else if (K_STRING::cmp(eltType, "PENTA") == 0)
{
facets.push_back({1, 2, 5, 4}); facets.push_back({2, 3, 6, 5});
facets.push_back({3, 1, 4, 6});
if (allow_degenerated)
{
facets.push_back({1, 3, 2, 1}); facets.push_back({4, 5, 6, 4});
}
else
{
facets.push_back({1, 3, 2}); facets.push_back({4, 5, 6});
}
}
else if (K_STRING::cmp(eltType, "HEXA") == 0)
{
facets.push_back({1, 4, 3, 2}); facets.push_back({1, 2, 6, 5});
facets.push_back({2, 3, 7, 6}); facets.push_back({3, 4, 8, 7});
facets.push_back({1, 5, 8, 4}); facets.push_back({5, 6, 7, 8});
}
else ierr = 1;
return ierr;
}
1 change: 1 addition & 0 deletions Cassiopee/KCore/srcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
'KCore/CompGeom/getAlphaAngleBetweenElts.cpp',
'KCore/CompGeom/convexity.cpp',
'KCore/CompGeom/getEdgeLength.cpp',
'KCore/Connect/getEVFacets.cpp',
'KCore/Connect/connectEV2VE.cpp',
'KCore/Connect/connectEV2VNbrs.cpp',
'KCore/Connect/connectEV2EENbrs.cpp',
Expand Down
6 changes: 3 additions & 3 deletions Cassiopee/Transform/Transform/PyTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,9 @@ def subzoneUnstruct__(t, indices, type):
nodes = Internal.getZones(tp)
for z in nodes:
dimz = Internal.getZoneDim(z)
fc = C.getFields(Internal.__GridCoordinates__, z)[0]
fa = C.getFields(Internal.__FlowSolutionNodes__, z)[0]
fb = C.getFields(Internal.__FlowSolutionCenters__, z)[0]
fc = C.getFields(Internal.__GridCoordinates__, z, api=1)[0]
fa = C.getFields(Internal.__FlowSolutionNodes__, z, api=1)[0]
fb = C.getFields(Internal.__FlowSolutionCenters__, z, api=1)[0]
if fa != []: fc = Converter.addVars([fc, fa])
if fb == []: # no flow sol at centers
nodes = Transform.subzone(fc, indices, type=type)
Expand Down
Loading

0 comments on commit a48f09c

Please sign in to comment.