Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
5c33df5d
There was an error fetching the commit references. Please try again later.
Commit
5c33df5d
authored
7 years ago
by
Jakub Klinkovský
Browse files
Options
Downloads
Patches
Plain Diff
Refactoring MeshBuilder
parent
725a6d33
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/TNL/Meshes/MeshBuilder.h
+56
-67
56 additions, 67 deletions
src/TNL/Meshes/MeshBuilder.h
with
56 additions
and
67 deletions
src/TNL/Meshes/MeshBuilder.h
+
56
−
67
View file @
5c33df5d
...
...
@@ -16,6 +16,7 @@
#pragma once
#include
<TNL/Containers/Vector.h>
#include
<TNL/Meshes/MeshDetails/traits/MeshTraits.h>
namespace
TNL
{
...
...
@@ -24,50 +25,48 @@ namespace Meshes {
template
<
typename
Mesh
>
class
MeshBuilder
{
//static constexpr const char *CLASS_NAME = "MeshBuilder";
public:
typedef
Mesh
MeshType
;
typedef
typename
MeshType
::
MeshTraitsType
MeshTraitsType
;
typedef
typename
MeshTraitsType
::
GlobalIndexType
GlobalIndexType
;
typedef
typename
MeshTraitsType
::
LocalIndexType
LocalIndexType
;
typedef
typename
MeshTraitsType
::
PointType
PointType
;
typedef
typename
MeshTraitsType
::
CellTopology
CellTopology
;
typedef
typename
MeshTraitsType
::
CellSeedType
CellSeedType
;
public:
using
MeshType
=
Mesh
;
using
MeshTraitsType
=
typename
MeshType
::
MeshTraitsType
;
using
GlobalIndexType
=
typename
MeshTraitsType
::
GlobalIndexType
;
using
LocalIndexType
=
typename
MeshTraitsType
::
LocalIndexType
;
using
PointType
=
typename
MeshTraitsType
::
PointType
;
using
CellTopology
=
typename
MeshTraitsType
::
CellTopology
;
using
CellSeedType
=
typename
MeshTraitsType
::
CellSeedType
;
bool
setPointsCount
(
const
GlobalIndexType
&
points
)
{
TNL_ASSERT
(
0
<=
points
,
std
::
cerr
<<
"pointsCount = "
<<
points
)
;
this
->
points
.
setSize
(
points
)
;
this
->
pointsSet
.
setSize
(
points
)
;
if
(
!
this
->
points
.
setSize
(
points
)
||
!
this
->
points
Set
.
setSize
(
points
)
)
return
false
;
pointsSet
.
setValue
(
false
);
return
true
;
}
bool
setCellsCount
(
const
GlobalIndexType
&
cellsCount
)
{
TNL_ASSERT
(
0
<=
cellsCount
,
std
::
cerr
<<
"cellsCount = "
<<
cellsCount
);
this
->
cellSeeds
.
setSize
(
cellsCount
);
return
true
;
return
this
->
cellSeeds
.
setSize
(
cellsCount
);
}
GlobalIndexType
getPointsCount
()
const
{
return
this
->
points
.
getSize
();
}
GlobalIndexType
getCellsCount
()
const
{
return
this
->
cellSeeds
.
getSize
();
}
void
setPoint
(
GlobalIndexType
index
,
const
PointType
&
point
)
GlobalIndexType
getPointsCount
()
const
{
return
this
->
points
.
getSize
();
}
GlobalIndexType
getCellsCount
()
const
{
Assert
(
0
<=
index
&&
index
<
getPointsCount
(),
std
::
cerr
<<
"Index = "
<<
index
);
return
this
->
cellSeeds
.
getSize
();
}
void
setPoint
(
GlobalIndexType
index
,
const
PointType
&
point
)
{
this
->
points
[
index
]
=
point
;
this
->
pointsSet
[
index
]
=
true
;
}
CellSeedType
&
getCellSeed
(
GlobalIndexType
index
)
{
TNL_ASSERT
(
0
<=
index
&&
index
<
getCellsCount
(),
std
::
cerr
<<
"Index = "
<<
index
);
return
this
->
cellSeeds
[
index
];
}
...
...
@@ -80,56 +79,46 @@ class MeshBuilder
return
true
;
}
private
:
typedef
typename
MeshTraitsType
::
PointArrayType
PointArrayType
;
typedef
typename
MeshTraitsType
::
CellSeedArrayType
CellSeedArrayType
;
private
:
using
PointArrayType
=
typename
MeshTraitsType
::
PointArrayType
;
using
CellSeedArrayType
=
typename
MeshTraitsType
::
CellSeedArrayType
;
using
BoolVector
=
Containers
::
Vector
<
bool
,
Devices
::
Host
,
GlobalIndexType
>
;
bool
validate
()
const
{
if
(
!
allPointsSet
()
)
{
std
::
cerr
<<
"Mesh builder error: Not all points were set."
<<
std
::
endl
;
return
false
;
}
bool
validate
()
const
{
if
(
pointsSet
.
min
()
!=
true
)
{
std
::
cerr
<<
"Mesh builder error: Not all points were set."
<<
std
::
endl
;
return
false
;
}
std
::
unordered_set
<
GlobalIndexType
>
assignedPoints
;
for
(
GlobalIndexType
i
=
0
;
i
<
getCellsCount
();
i
++
)
{
a
uto
cornerIds
=
this
->
cellSeeds
[
i
].
getCornerIds
(
);
for
(
LocalIndexType
j
=
0
;
j
<
cornerIds
.
getSize
();
j
++
)
{
assignedPoints
.
insert
(
c
ornerIds
[
j
]
);
if
(
cornerIds
[
j
]
<
0
||
getPointsCount
()
<
=
cornerIds
[
j
]
)
{
std
::
cerr
<<
"Cell seed "
<<
i
<<
" is referencing unavailable point "
<
<
cornerIds
[
j
]
<<
std
::
endl
;
return
false
;
}
BoolVector
assignedPoints
;
if
(
!
assignedPoints
.
setLike
(
pointsSet
)
)
return
false
;
a
ssignedPoints
.
setValue
(
false
);
for
(
GlobalIndexType
i
=
0
;
i
<
getCellsCount
();
i
++
)
{
const
auto
cornerIds
=
this
->
cellSeeds
[
i
].
getC
ornerIds
(
);
for
(
LocalIndexType
j
=
0
;
j
<
cornerIds
.
getSize
();
j
++
)
{
assignedPoints
[
cornerIds
[
j
]
]
=
true
;
if
(
cornerIds
[
j
]
<
0
||
getPointsCount
()
<
=
cornerIds
[
j
]
)
{
std
::
cerr
<<
"Cell seed "
<<
i
<<
" is referencing unavailable point "
<<
cornerIds
[
j
]
<<
std
::
endl
;
return
false
;
}
}
if
(
(
GlobalIndexType
)
assignedPoints
.
size
()
!=
this
->
getPointsCount
()
)
{
std
::
cerr
<<
"Mesh builder error: Some points were not used for cells."
<<
std
::
endl
;
return
false
;
}
return
true
;
}
bool
allPointsSet
()
const
{
for
(
GlobalIndexType
i
=
0
;
i
<
this
->
points
.
getSize
();
i
++
)
if
(
!
this
->
pointsSet
[
i
]
)
return
false
;
return
true
;
if
(
assignedPoints
.
min
()
!=
true
)
{
std
::
cerr
<<
"Mesh builder error: Some points were not used for cells."
<<
std
::
endl
;
return
false
;
}
PointArrayType
points
;
CellSeedArrayType
cellSeeds
;
Containers
::
Array
<
bool
,
Devices
::
Host
,
GlobalIndexType
>
pointsSet
;
return
true
;
}
PointArrayType
points
;
CellSeedArrayType
cellSeeds
;
BoolVector
pointsSet
;
};
}
// namespace Meshes
}
// namespace TNL
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment