Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Kirill Terekhov
INMOST
Commits
aa2a4e83
Commit
aa2a4e83
authored
Oct 24, 2016
by
chrmaier
Browse files
Merge remote-tracking branch 'origin/master'
# Conflicts: # Source/IO/mesh_xml_file.cpp
parents
e2844e42
9e7fbcc5
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
Examples/ADMFD/main.cpp
View file @
aa2a4e83
This diff is collapsed.
Click to expand it.
Examples/CMakeLists.txt
View file @
aa2a4e83
if
(
USE_MESH
)
#
add_subdirectory(DrawGrid)
add_subdirectory
(
DrawGrid
)
add_subdirectory
(
OldDrawGrid
)
add_subdirectory
(
GridGen
)
endif
(
USE_MESH
)
...
...
Examples/DrawGrid/CMakeLists.txt
View file @
aa2a4e83
...
...
@@ -8,6 +8,7 @@ find_package(GLUT)
if
(
OPENGL_FOUND
)
if
(
GLUT_FOUND
)
message
(
"linking DrawGrid with GLUT and OpenGL"
)
include_directories
(
${
OPENGL_INCLUDE_DIR
}
)
include_directories
(
${
GLUT_INCLUDE_DIR
}
)
add_executable
(
DrawGrid
${
SOURCE
}
)
...
...
@@ -20,9 +21,9 @@ if(OPENGL_FOUND)
endif
(
USE_MPI
)
install
(
TARGETS DrawGrid EXPORT inmost-targets RUNTIME DESTINATION bin
)
else
(
GLUT_FOUND
)
message
(
"GLUT not found"
)
message
(
"GLUT not found
, not building DrawGrid
"
)
endif
(
GLUT_FOUND
)
else
(
OPENGL_FOUND
)
message
(
"OpenGL not found"
)
message
(
"OpenGL not found
, not building DrawGrid
"
)
endif
(
OPENGL_FOUND
)
Examples/DrawGrid/main.cpp
View file @
aa2a4e83
...
...
@@ -3,7 +3,7 @@
//#define OCTREECUTCELL_DEBUG
#define DISCR_DEBUG
#include "
../../
inmost.h"
#include "inmost.h"
#include "my_glut.h"
#include <iostream>
#include <sstream>
...
...
@@ -20,7 +20,7 @@ double zoom = 1;
int
width
=
800
,
height
=
800
;
double
sleft
=
1e20
,
sright
=
-
1e20
,
sbottom
=
1e20
,
stop
=
-
1e20
,
sfar
=
-
1e20
,
snear
=
1e20
;
Tag
mat
,
colort
;
int
maxmat
=
-
1
,
maxcolor
=
0
;
std
::
map
<
GeometricData
,
ElementType
>
table
;
Mesh
::
GeomParam
table
;
double
reset_timer
=
Timer
();
double
shift
[
3
]
=
{
0
,
0
,
0
};
int
boundary
=
2
;
...
...
@@ -30,7 +30,7 @@ bool perspective = false;
int
text
=
4
;
int
display_orphans
=
1
;
int
badfaces
=
1
;
ElementSet
*
problem_set
,
*
orphan_edges
,
*
orphan_faces
;
ElementSet
problem_set
,
orphan_edges
,
orphan_faces
;
#if defined(DISCR_DEBUG)
...
...
@@ -44,7 +44,7 @@ static void tensor_prod3(Storage::real * K, Storage::real v[3], Storage::real ou
out
[
2
]
=
v
[
0
]
*
K
[
6
]
+
v
[
1
]
*
K
[
7
]
+
v
[
2
]
*
K
[
8
];
}
void
FindHarmonicPoint
(
Face
*
fKL
,
Cell
*
cK
,
Cell
*
cL
,
Tag
tensor
,
Storage
::
real
xK
[
3
],
Storage
::
real
xL
[
3
],
Storage
::
real
y
[
3
],
Storage
::
real
&
coef
)
void
FindHarmonicPoint
(
Face
&
fKL
,
Cell
&
cK
,
Cell
&
cL
,
Tag
tensor
,
Storage
::
real
xK
[
3
],
Storage
::
real
xL
[
3
],
Storage
::
real
y
[
3
],
Storage
::
real
&
coef
)
{
Storage
::
real
yK
[
3
],
yL
[
3
],
xKL
[
3
],
nKL
[
3
],
dK
,
dL
,
lK
,
lL
,
lKs
[
3
],
lLs
[
3
],
D
,
t
;
Storage
::
real
coefK
,
coefL
,
coefQ
,
coefDiv
;
...
...
@@ -81,7 +81,7 @@ void FindHarmonicPoint(Face * fKL, Cell * cK, Cell * cL, Tag tensor, Storage::re
}
void
FindBoundaryPoint
(
Face
*
fK
,
Cell
*
cK
,
Tag
tensor
,
Storage
::
real
xK
[
3
],
Storage
::
real
y
[
3
])
void
FindBoundaryPoint
(
Face
&
fK
,
Cell
&
cK
,
Tag
tensor
,
Storage
::
real
xK
[
3
],
Storage
::
real
y
[
3
])
{
Storage
::
real
nK
[
3
],
lKs
[
3
],
lK
,
xfK
[
3
],
t
;
Storage
::
real_array
KK
=
cK
->
RealArray
(
tensor
);
...
...
@@ -393,8 +393,8 @@ void keyboard(unsigned char key, int x, int y)
{
unsigned
visited
=
0
;
colort
=
mesh
->
CreateTag
(
"COLOR"
,
DATA_INTEGER
,
CELL
,
NONE
,
1
);
std
::
vector
<
Cell
*
>
queue
;
adjacent
<
Element
>
around
;
std
::
vector
<
Cell
>
queue
;
ElementArray
<
Element
>
around
;
queue
.
reserve
(
256
);
while
(
visited
!=
mesh
->
NumberOfCells
()
)
{
...
...
@@ -404,7 +404,7 @@ void keyboard(unsigned char key, int x, int y)
{
if
(
it
->
Integer
(
colort
)
==
0
)
{
queue
.
push_back
(
&*
it
);
queue
.
push_back
(
it
->
self
()
);
visited
++
;
queue
.
back
()
->
Integer
(
colort
)
=
maxcolor
;
break
;
...
...
@@ -415,7 +415,7 @@ void keyboard(unsigned char key, int x, int y)
around
=
queue
.
back
()
->
BridgeAdjacencies
(
FACE
,
CELL
);
queue
.
pop_back
();
for
(
adjacent
<
Element
>::
iterator
it
=
around
.
begin
();
it
!=
around
.
end
();
++
it
)
for
(
ElementArray
<
Element
>::
iterator
it
=
around
.
begin
();
it
!=
around
.
end
();
++
it
)
if
(
it
->
Integer
(
colort
)
==
0
)
{
queue
.
push_back
(
it
->
getAsCell
());
...
...
@@ -474,13 +474,13 @@ public:
face2gl
DrawFace
(
Element
*
f
,
int
mmat
,
double
campos
[
3
])
face2gl
DrawFace
(
Element
&
f
,
int
mmat
,
double
campos
[
3
])
{
double
cnt
[
3
];
face2gl
ret
;
f
->
Centroid
(
cnt
);
ret
.
set_center
(
cnt
,
campos
);
adjacent
<
Node
>
nodes
=
f
->
getNodes
();
ElementArray
<
Node
>
nodes
=
f
->
getNodes
();
if
(
f
->
nbAdjElements
(
CELL
)
==
0
)
ret
.
set_color
(
1
,
0
,
0
,
0.25
);
...
...
@@ -494,7 +494,7 @@ face2gl DrawFace(Element * f, int mmat, double campos[3])
ret
.
set_color
(
1
-
r
,
r
,
1
-
r
,
0.25
);
}
for
(
adjacent
<
Node
>::
iterator
kt
=
nodes
.
begin
();
kt
!=
nodes
.
end
();
kt
++
)
for
(
ElementArray
<
Node
>::
iterator
kt
=
nodes
.
begin
();
kt
!=
nodes
.
end
();
kt
++
)
ret
.
add_vert
(
&
(
kt
->
Coords
()[
0
]));
...
...
@@ -503,7 +503,7 @@ face2gl DrawFace(Element * f, int mmat, double campos[3])
//glLineWidth(2.0);
if
(
boundary
==
1
)
glColor3f
(
0
,
0
,
1
);
else
glColor3f
(
0
,
0
,
0
);
glBegin
(
GL_LINE_LOOP
);
for
(
adjacent
<
Node
>::
iterator
kt
=
nodes
.
begin
();
kt
!=
nodes
.
end
();
kt
++
)
for
(
ElementArray
<
Node
>::
iterator
kt
=
nodes
.
begin
();
kt
!=
nodes
.
end
();
kt
++
)
glVertex3dv
(
&
(
kt
->
Coords
()[
0
]));
glEnd
();
//glLineWidth(1.0);
...
...
@@ -596,7 +596,7 @@ void draw()
//glTranslated((l+r)*0.5,(b+t)*0.5,(near+far)*0.5);
int
pacef
=
std
::
max
(
1
,
mesh
->
Max
LocalID
FACE
()
/
10000
);
int
pacef
=
std
::
max
(
1
,
mesh
->
FaceLast
LocalID
()
/
10000
);
std
::
vector
<
face2gl
>
polygons
;
...
...
@@ -604,14 +604,11 @@ void draw()
if
(
badfaces
)
{
for
(
INMOST_DATA_INTEGER_TYPE
it
=
0
;
it
<
mesh
->
Max
LocalID
FACE
();
it
+=
(
interactive
?
pacef
:
1
))
for
(
INMOST_DATA_INTEGER_TYPE
it
=
0
;
it
<
mesh
->
FaceLast
LocalID
();
it
+=
(
interactive
?
pacef
:
1
))
if
(
mesh
->
isValidFace
(
it
)
)
{
Face
*
f
=
mesh
->
FaceByLocalID
(
it
);
if
(
f
!=
NULL
)
{
if
(
!
f
->
CheckNormalOrientation
()
)
polygons
.
push_back
(
DrawFace
(
f
,
1
,
campos
));
}
Face
f
=
mesh
->
FaceByLocalID
(
it
);
if
(
!
f
->
CheckNormalOrientation
()
)
polygons
.
push_back
(
DrawFace
(
f
,
1
,
campos
));
}
}
...
...
@@ -628,8 +625,8 @@ void draw()
{
Storage
::
real
cnt
[
3
];
it
->
Centroid
(
cnt
);
adjacent
<
Face
>
faces
=
it
->
getFaces
();
for
(
adjacent
<
Face
>::
iterator
jt
=
faces
.
begin
();
jt
!=
faces
.
end
();
++
jt
)
if
(
!
jt
->
Boundary
())
ElementArray
<
Face
>
faces
=
it
->
getFaces
();
for
(
ElementArray
<
Face
>::
iterator
jt
=
faces
.
begin
();
jt
!=
faces
.
end
();
++
jt
)
if
(
!
jt
->
Boundary
())
{
Storage
::
real_array
cc
=
jt
->
RealArray
(
avg_coord
);
glVertex3dv
(
cnt
);
...
...
@@ -664,8 +661,8 @@ void draw()
for
(
Mesh
::
iteratorFace
it
=
mesh
->
BeginFace
();
it
!=
mesh
->
EndFace
();
++
it
)
if
(
!
it
->
Boundary
()
)
{
Storage
::
real
nrm
[
3
],
scale
,
f1
[
3
],
f2
[
3
],
l
,
cnt
[
3
],
v
[
3
];
Cell
*
c1
=
it
->
BackCell
(),
*
c2
=
it
->
FrontCell
();
if
(
c1
!=
NULL
&&
c2
!=
NULL
)
Cell
c1
=
it
->
BackCell
(),
c2
=
it
->
FrontCell
();
if
(
c1
.
isValid
()
&&
c2
.
isValid
()
)
{
it
->
Centroid
(
cnt
);
it
->
OrientedUnitNormal
(
c1
,
nrm
);
...
...
@@ -735,19 +732,19 @@ void draw()
{
for
(
int
qq
=
0
;
qq
<
show_cells
.
size
();
qq
++
)
{
if
(
show_cells
[
qq
]
<
0
||
show_cells
[
qq
]
>=
mesh
->
Max
LocalID
CELL
()
)
continue
;
Element
*
it
=
mesh
->
ElementByLocalID
(
CELL
,
show_cells
[
qq
]);
if
(
it
!=
NULL
)
if
(
show_cells
[
qq
]
<
0
||
show_cells
[
qq
]
>=
mesh
->
CellLast
LocalID
()
)
continue
;
Element
it
=
mesh
->
ElementByLocalID
(
CELL
,
show_cells
[
qq
]);
if
(
it
.
isValid
()
)
{
Storage
::
integer_array
mats
;
adjacent
<
Edge
>
edges
=
it
->
getEdges
();
ElementArray
<
Edge
>
edges
=
it
->
getEdges
();
Storage
::
real
cnt
[
3
];
for
(
unsigned
k
=
0
;
k
<
edges
.
size
();
k
++
)
{
edges
[
k
].
Centroid
(
cnt
);
if
(
mats_tag
.
isValid
()
)
mats
=
edges
[
k
].
IntegerArray
(
mats_tag
);
adjacent
<
Node
>
nodes
=
edges
[
k
].
getNodes
();
ElementArray
<
Node
>
nodes
=
edges
[
k
].
getNodes
();
if
(
matfilter
==
0
||
(
mats_tag
.
isValid
()
&&
std
::
binary_search
(
mats
.
begin
(),
mats
.
end
(),
matfilter
-
1
))
)
...
...
@@ -787,7 +784,7 @@ void draw()
}
}
adjacent
<
Face
>
faces
=
it
->
getFaces
();
ElementArray
<
Face
>
faces
=
it
->
getFaces
();
for
(
unsigned
k
=
0
;
k
<
faces
.
size
();
k
++
)
{
...
...
@@ -843,22 +840,22 @@ void draw()
{
for
(
int
qq
=
0
;
qq
<
show_faces
.
size
();
qq
++
)
{
Element
*
it
=
NULL
;
if
(
show_faces
[
qq
]
<
0
||
show_faces
[
qq
]
>=
mesh
->
Max
LocalID
(
FACE
)
)
continue
;
Element
it
=
InvalidElement
()
;
if
(
show_faces
[
qq
]
<
0
||
show_faces
[
qq
]
>=
mesh
->
Last
LocalID
(
FACE
)
)
continue
;
it
=
mesh
->
ElementByLocalID
(
FACE
,
show_faces
[
qq
]);
if
(
it
!=
NULL
)
if
(
it
.
isValid
()
)
{
Storage
::
integer_array
mats
;
Storage
::
real
cnt
[
3
],
cntf
[
3
];
adjacent
<
Edge
>
edges
=
it
->
getEdges
();
ElementArray
<
Edge
>
edges
=
it
->
getEdges
();
it
->
Centroid
(
cntf
);
for
(
unsigned
k
=
0
;
k
<
edges
.
size
();
k
++
)
//if( edges[k].nbAdjElements(CELL) == 0 )
{
if
(
mats_tag
.
isValid
()
)
mats
=
edges
[
k
].
IntegerArray
(
mats_tag
);
adjacent
<
Node
>
nodes
=
edges
[
k
].
getNodes
();
ElementArray
<
Node
>
nodes
=
edges
[
k
].
getNodes
();
if
(
matfilter
==
0
||
(
mats_tag
.
isValid
()
&&
std
::
binary_search
(
mats
.
begin
(),
mats
.
end
(),
matfilter
-
1
))
)
{
...
...
@@ -914,9 +911,9 @@ void draw()
if
(
text
==
3
||
text
==
5
)
if
(
text
)
printtext
(
str
);
}
#if 0
adjacent
<Cell> cells = it->getCells();
ElementArray
<Cell> cells = it->getCells();
for(
adjacent
<Cell>::iterator jt = cells.begin(); jt != cells.end(); ++jt)
for(
ElementArray
<Cell>::iterator jt = cells.begin(); jt != cells.end(); ++jt)
{
glColor3f(0,0,0);
jt->Centroid(cnt);
...
...
@@ -948,7 +945,7 @@ void draw()
}
glEnd();
*/
for(
adjacent
<Cell>::iterator jt = cells.begin(); jt != cells.end(); ++jt)
for(
ElementArray
<Cell>::iterator jt = cells.begin(); jt != cells.end(); ++jt)
{
jt->Centroid(cnt);
...
...
@@ -958,9 +955,9 @@ void draw()
glVertex3dv(cnt);
glEnd();
adjacent
<Face> faces = jt->getFaces();
ElementArray
<Face> faces = jt->getFaces();
for(
adjacent
<Face>::iterator qt = faces.begin(); qt != faces.end(); ++qt)
for(
ElementArray
<Face>::iterator qt = faces.begin(); qt != faces.end(); ++qt)
{
qt->Centroid(cnt);
glColor3f(0,0,1);
...
...
@@ -1042,14 +1039,14 @@ void draw()
{
if
(
parentfilter
!=
-
1
&&
parent_tag
.
isValid
()
&&
it
->
Integer
(
parent_tag
)
!=
parentfilter
)
continue
;
Storage
::
integer_array
mats
;
adjacent
<
Edge
>
edges
=
it
->
getEdges
();
ElementArray
<
Edge
>
edges
=
it
->
getEdges
();
Storage
::
real
cnt
[
3
];
for
(
unsigned
k
=
0
;
k
<
edges
.
size
();
k
++
)
{
edges
[
k
].
Centroid
(
cnt
);
mats
=
edges
[
k
].
IntegerArray
(
mats_tag
);
adjacent
<
Node
>
nodes
=
edges
[
k
].
getNodes
();
ElementArray
<
Node
>
nodes
=
edges
[
k
].
getNodes
();
if
(
matfilter
==
0
||
std
::
binary_search
(
mats
.
begin
(),
mats
.
end
(),
matfilter
-
1
)
)
...
...
@@ -1086,7 +1083,7 @@ void draw()
}
}
adjacent
<
Face
>
faces
=
it
->
getFaces
();
ElementArray
<
Face
>
faces
=
it
->
getFaces
();
for
(
unsigned
k
=
0
;
k
<
faces
.
size
();
k
++
)
{
...
...
@@ -1145,7 +1142,7 @@ void draw()
//end = mesh->MaxLocalID(EDGE);
//for(Mesh::iteratorEdge it = mesh->BeginEdge(); it != mesh->EndEdge(); it++)
//for(int i = 0; i < end; i++)
if
(
orphan_edges
!=
NULL
)
for
(
ElementSet
::
iterator
iit
=
orphan_edges
->
b
egin
();
iit
!=
orphan_edges
->
e
nd
();
++
iit
)
if
(
orphan_edges
!=
NULL
)
for
(
ElementSet
::
iterator
iit
=
orphan_edges
.
B
egin
();
iit
!=
orphan_edges
.
E
nd
();
++
iit
)
{
Element
*
it
=
&*
iit
;
//mesh->ElementByLocalID(EDGE,i);
//if( it == NULL ) continue;
...
...
@@ -1154,7 +1151,7 @@ void draw()
Storage
::
integer_array
mats
=
it
->
IntegerArray
(
mats_tag
);
Storage
::
real
cnt
[
3
];
adjacent
<
Node
>
nodes
=
it
->
getNodes
();
ElementArray
<
Node
>
nodes
=
it
->
getNodes
();
if
(
matfilter
==
0
||
std
::
binary_search
(
mats
.
begin
(),
mats
.
end
(),
matfilter
-
1
)
)
{
...
...
@@ -1203,14 +1200,14 @@ void draw()
Storage
::
integer_array
mats
;
Storage
::
real
cnt
[
3
];
adjacent
<
Edge
>
edges
=
it
->
getEdges
();
ElementArray
<
Edge
>
edges
=
it
->
getEdges
();
for
(
unsigned
k
=
0
;
k
<
edges
.
size
();
k
++
)
//if( edges[k].nbAdjElements(CELL) == 0 )
{
mats
=
edges
[
k
].
IntegerArray
(
mats_tag
);
adjacent
<
Node
>
nodes
=
edges
[
k
].
getNodes
();
ElementArray
<
Node
>
nodes
=
edges
[
k
].
getNodes
();
if
(
matfilter
==
0
||
std
::
binary_search
(
mats
.
begin
(),
mats
.
end
(),
matfilter
-
1
)
)
{
...
...
@@ -1268,45 +1265,48 @@ void draw()
#endif
if
(
boundary
)
{
int
end
=
mesh
->
MaxLocalID
(
FACE
);
//for(Mesh::iteratorFace it = mesh->BeginFace(); it != mesh->EndFace(); it++)
if
(
colort
.
isValid
()
)
for
(
ElementType
etype
=
FACE
;
etype
<=
CELL
;
etype
=
NextElementType
(
etype
)
)
{
for
(
int
i
=
0
;
i
<
end
;
i
+=
interactive
?
pacef
:
1
)
int
end
=
mesh
->
LastLocalID
(
etype
);
//for(Mesh::iteratorFace it = mesh->BeginFace(); it != mesh->EndFace(); it++)
if
(
colort
.
isValid
()
)
{
Element
*
it
=
mesh
->
ElementByLocalID
(
FACE
,
i
);
if
(
it
==
NULL
)
continue
;
if
(
it
->
Boundary
()
)
for
(
int
i
=
0
;
i
<
end
;
i
+=
interactive
?
pacef
:
1
)
{
int
mmat
=
color
?
(
it
->
getAsFace
()
->
BackCell
()
==
NULL
?
0
:
it
->
getAsFace
()
->
BackCell
()
->
Integer
(
colort
))
:
(
it
->
getAsFace
()
->
BackCell
()
==
NULL
?
0
:
it
->
getAsFace
()
->
BackCell
()
->
Integer
(
mat
));
if
(
matfilter
==
0
||
matfilter
-
1
==
mmat
)
polygons
.
push_back
(
DrawFace
(
&*
it
,
mmat
,
campos
));
Element
it
=
mesh
->
ElementByLocalID
(
etype
,
i
);
if
(
!
it
.
isValid
()
)
continue
;
if
(
it
->
Boundary
()
)
{
int
mmat
=
color
?
(
!
it
->
getAsFace
()
->
BackCell
().
isValid
()
?
0
:
it
->
getAsFace
()
->
BackCell
()
->
Integer
(
colort
))
:
(
!
it
->
getAsFace
()
->
BackCell
().
isValid
()
?
0
:
it
->
getAsFace
()
->
BackCell
()
->
Integer
(
mat
));
if
(
matfilter
==
0
||
matfilter
-
1
==
mmat
)
polygons
.
push_back
(
DrawFace
(
it
->
self
(),
mmat
,
campos
));
}
}
}
}
else
{
for
(
int
i
=
0
;
i
<
end
;
i
+=
interactive
?
pacef
:
1
)
else
{
Element
*
it
=
mesh
->
ElementByLocalID
(
FACE
,
i
);
if
(
it
==
NULL
)
continue
;
if
(
it
->
Boundary
()
)
polygons
.
push_back
(
DrawFace
(
&*
it
,
0
,
campos
));
for
(
int
i
=
0
;
i
<
end
;
i
+=
interactive
?
pacef
:
1
)
{
Element
it
=
mesh
->
ElementByLocalID
(
etype
,
i
);
if
(
!
it
.
isValid
()
)
continue
;
if
(
it
->
Boundary
()
)
polygons
.
push_back
(
DrawFace
(
it
->
self
(),
0
,
campos
));
}
}
}
}
if
(
display_orphans
)
{
if
(
orphan_edges
!=
NULL
)
for
(
ElementSet
::
iterator
iit
=
orphan_edges
->
b
egin
();
iit
!=
orphan_edges
->
e
nd
();
++
iit
)
if
(
orphan_edges
.
isValid
()
)
for
(
ElementSet
::
iterator
iit
=
orphan_edges
.
B
egin
();
iit
!=
orphan_edges
.
E
nd
();
++
iit
)
{
Element
*
it
=
&*
iit
;
//mesh->ElementByLocalID(EDGE,i);
Element
it
=
iit
->
self
()
;
//mesh->ElementByLocalID(EDGE,i);
//if( it == NULL ) continue;
//if( it->nbAdjElements(CELL) == 0 )
{
Storage
::
real
cnt
[
3
];
adjacent
<
Node
>
nodes
=
it
->
getNodes
();
ElementArray
<
Node
>
nodes
=
it
->
getNodes
();
{
glBegin
(
GL_LINES
);
...
...
@@ -1317,18 +1317,18 @@ void draw()
}
}
}
if
(
orphan_faces
!=
NULL
)
for
(
ElementSet
::
iterator
iit
=
orphan_faces
->
b
egin
();
iit
!=
orphan_faces
->
e
nd
();
++
iit
)
if
(
orphan_faces
.
isValid
()
)
for
(
ElementSet
::
iterator
iit
=
orphan_faces
.
B
egin
();
iit
!=
orphan_faces
.
E
nd
();
++
iit
)
{
Element
*
it
=
&*
iit
;
Element
it
=
iit
->
self
()
;
{
Storage
::
integer_array
mats
;
Storage
::
real
cnt
[
3
];
adjacent
<
Edge
>
edges
=
it
->
getEdges
();
ElementArray
<
Edge
>
edges
=
it
->
getEdges
();
for
(
unsigned
k
=
0
;
k
<
edges
.
size
();
k
++
)
{
adjacent
<
Node
>
nodes
=
edges
[
k
].
getNodes
();
ElementArray
<
Node
>
nodes
=
edges
[
k
].
getNodes
();
{
glBegin
(
GL_LINES
);
glVertex3dv
(
&
nodes
[
0
].
Coords
()[
0
]);
...
...
@@ -1339,7 +1339,7 @@ void draw()
if
(
matfilter
==
0
||
std
::
binary_search
(
mats
.
begin
(),
mats
.
end
(),
matfilter
-
1
)
)
polygons
.
push_back
(
DrawFace
(
&*
it
,
0
,
campos
));
polygons
.
push_back
(
DrawFace
(
it
->
self
()
,
0
,
campos
));
}
}
}
...
...
@@ -1388,7 +1388,7 @@ void draw()
{
if( it->GetElementDimension() == 2 )
{
adjacent
<Node> nodes = it->getNodes();
ElementArray
<Node> nodes = it->getNodes();
if( it->GetGeometricType() == MultiPolygon )
{
glColor3f(1,0,0);
...
...
@@ -1400,14 +1400,14 @@ void draw()
}
else glColor3f(0,1,0);
glBegin(GL_POLYGON);
for(
adjacent
<Node>::iterator kt = nodes.begin(); kt != nodes.end(); kt++)
for(
ElementArray
<Node>::iterator kt = nodes.begin(); kt != nodes.end(); kt++)
glVertex3d(kt->Coords()[0]+dir[0]*scale,kt->Coords()[1]+dir[1]*scale,kt->Coords()[2]+dir[2]*scale);
glEnd();
}
adjacent
<Element> faces = it->getAdjElements(FACE);
for(
adjacent
<Element>::iterator f = faces.begin(); f != faces.end(); f++)// if( Geometry::Boundary(&*f) )
ElementArray
<Element> faces = it->getAdjElements(FACE);
for(
ElementArray
<Element>::iterator f = faces.begin(); f != faces.end(); f++)// if( Geometry::Boundary(&*f) )
{
adjacent
<Node> nodes = f->getNodes();
ElementArray
<Node> nodes = f->getNodes();
if( it->GetGeometricType() == MultiPolygon )
{
glColor3f(1,0,0);
...
...
@@ -1422,7 +1422,7 @@ void draw()
glBegin(GL_POLYGON);
else
glBegin(GL_LINES);
for(
adjacent
<Node>::iterator n = nodes.begin(); n != nodes.end(); n++)
for(
ElementArray
<Node>::iterator n = nodes.begin(); n != nodes.end(); n++)
glVertex3d(n->Coords()[0]+dir[0]*scale,n->Coords()[1]+dir[1]*scale,n->Coords()[2]+dir[2]*scale);
glEnd();
...
...
@@ -1430,8 +1430,8 @@ void draw()
glBegin(GL_LINES);
adjacent
<Cell> cells = f->getCells();
for(
adjacent
<Cell>::iterator c = cells.begin(); c != cells.end(); c++)
ElementArray
<Cell> cells = f->getCells();
for(
ElementArray
<Cell>::iterator c = cells.begin(); c != cells.end(); c++)
if( &*c != &*it )
{
Storage::real cc2[3];
...
...
@@ -1450,11 +1450,11 @@ void draw()
if( it->GetElementDimension() == 3 )
{
glBegin(GL_LINES);
adjacent
<Edge> edges = it->getEdges();
for(
adjacent
<Edge>::iterator e = edges.begin(); e != edges.end(); e++)
ElementArray
<Edge> edges = it->getEdges();
for(
ElementArray
<Edge>::iterator e = edges.begin(); e != edges.end(); e++)
{
adjacent
<Element> nodes = e->getAdjElements(NODE);
for(
adjacent
<Element>::iterator jt = nodes.begin(); jt != nodes.end(); jt++)
ElementArray
<Element> nodes = e->getAdjElements(NODE);
for(
ElementArray
<Element>::iterator jt = nodes.begin(); jt != nodes.end(); jt++)
{
Storage::real_array nc = jt->getAsNode()->Coords();
glVertex3d(nc[0]+dir[0]*scale,nc[1]+dir[1]*scale,nc[2]+dir[2]*scale);
...
...
@@ -1533,12 +1533,12 @@ void draw()
{
delete
CommonInput
;
CommonInput
=
NULL
;
Element
*
it
=
NULL
;
Element
it
=
InvalidElement
()
;
Storage
::
real
cnt
[
3
];
if
(
show_cell
!=
-
1
)
{
it
=
mesh
->
ElementByLocalID
(
CELL
,
show_cell
);
if
(
it
==
NULL
)
if
(
!
it
.
isValid
()
)
{
std
::
cout
<<
"cell "
<<
show_cell
<<
" not accepted "
<<
std
::
endl
;
show_cell
=
-
1
;
...
...
@@ -1553,7 +1553,7 @@ void draw()
if
(
show_face
!=
-
1
)
{
it
=
mesh
->
ElementByLocalID
(
FACE
,
show_face
);
if
(
it
==
NULL
)
if
(
!
it
.
isValid
()
)
{
std
::
cout
<<
"face "
<<
show_face
<<
" not accepted "
<<
std
::
endl
;
show_face
=
-
1
;
...
...
@@ -1565,7 +1565,7 @@ void draw()
show_face
=
-
1
;
}
}
if
(
it
!=
NULL
)
if
(
it
.
isValid
()
)
{
it
->
Centroid
(
cnt
);
shift
[
0
]
=
-
cnt
[
0
];
...
...
@@ -1716,8 +1716,8 @@ int main(int argc, char ** argv)
if
(
argc
<=
2
)
{
orphan_edges
=
mesh
->
CreateSet
(
)
;
orphan_faces
=
mesh
->
CreateSet
(
)
;
orphan_edges
=
mesh
->
CreateSet
(
"ORPHAN_EDGES"
).
first
;
orphan_faces
=
mesh
->
CreateSet
(
"ORPHAN_FACES"
).
first
;
}
for
(
ElementType
mask
=
FACE
;
mask
>=
NODE
;
mask
=
mask
>>
1
)
...
...
@@ -1727,9 +1727,9 @@ int main(int argc, char ** argv)
if
(
it
->
nbAdjElements
(
mask
<<
1
)
==
0
)
{
norphan
++
;
if
(
argc
>
2
)
delete
&*
it
;
else
if
(
mask
==
EDGE
)
orphan_edges
->
Insert
(
&*
it
);
else
if
(
mask
==
FACE
)
orphan_faces
->
Insert
(
&*
it
);
if
(
argc
>
2
)
it
->
Delete
()
;
else
if
(
mask
==
EDGE
)
orphan_edges
->
PutElement
(
it
->
self
()
);
else
if
(
mask
==
FACE
)
orphan_faces
->
PutElement
(
it
->
self
()
);
}
if
(
norphan
>
0
)
std
::
cout
<<
"orphan elements "
<<
ElementTypeName
(
mask
)
<<
" "
<<
norphan
<<
std
::
endl
;
}
...
...
@@ -1743,8 +1743,8 @@ int main(int argc, char ** argv)
if
(
!
it
->
CheckNormalOrientation
()
)
{
badorient
++
;
if
(
it
->
BackCell
()
!=
NULL
)
neighbours
[
it
->
BackCell
()
->
GetGeometricType
()]
++
;
if
(
it
->
FrontCell
()
!=
NULL
)
neighbours
[
it
->
FrontCell
()
->
GetGeometricType
()]
++
;
if
(
it
->
BackCell
()
.
isValid
()
)
neighbours
[
it
->
BackCell
()
->
GetGeometricType
()]
++
;
if
(
it
->
FrontCell
()
.
isValid
()
)
neighbours
[
it
->
FrontCell
()
->
GetGeometricType
()]
++
;
elemtypes
[
it
->
GetGeometricType
()]
++
;
}
...
...
@@ -1794,10 +1794,10 @@ int main(int argc, char ** argv)
if
(
mesh
->
HaveTag
(
"GMSH_TAGS"
)
)
{
Tag
t
=
mesh
->
GetTag
(
"GMSH_TAGS"
);
for
(
int
k
=
0
;
k
<
mesh
->
Max
LocalID
FACE
();
k
++
)
for
(
int
k
=
0
;
k
<
mesh
->
FaceLast
LocalID
();
k
++
)
if
(
mesh
->
isValidFace
(
k
)
)
{
Face
*
f
=
mesh
->
FaceByLocalID
(
k
);
if
(
f
!=
NULL
&&
f
->
HaveData
(
t
)
&&
!
f
->
Boundary
()
)
show_faces
.
push_back
(
k
);
Face
f
=
mesh
->
FaceByLocalID
(
k
);
if
(
f
->
HaveData
(
t
)
&&
!
f
->
Boundary
()
)
show_faces
.
push_back
(
k
);
}
}
...
...
Examples/GridGen/main.cpp
View file @
aa2a4e83
...
...
@@ -82,6 +82,50 @@ void CreateNWPrismElements(Mesh *m, ElementArray<Node> verts)
m
->
CreateCell
(
verts
,
sw_face_nodes
,
sw_num_nodes
,
5
);
// Create south-west prismatic cell
}
/* (4)*-------*(6)
/|\ /|
/ \ / |
/ | \ / |
(5)*-------*(7)|
| | | |
| | |
| | | |
|(0)*- -|- -*(2)
| / \ | /
| | /
|/ \|/
(1)*-------*(3) */
void
CreateNWTetElements
(
Mesh
*
m
,
ElementArray
<
Node
>
verts
)
{
// Define prism faces assuming verts are numerated in the way presented above
const
INMOST_DATA_INTEGER_TYPE
ne_face_nodes1
[
12
]
=
{
0
,
1
,
5
,
5
,
1
,
3
,
1
,
0
,
3
,
3
,
0
,
5
};
const
INMOST_DATA_INTEGER_TYPE
ne_num_nodes1
[
4
]
=
{
3
,
3
,
3
,
3
};
const
INMOST_DATA_INTEGER_TYPE
ne_face_nodes2
[
12
]
=
{
0
,
3
,
5
,
0
,
7
,
3
,
5