Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yuhao Liu
ogs
Commits
9f5153df
Commit
9f5153df
authored
9 years ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
[MeL] NodeSearcher split method.
parent
7ff2ab75
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MeshLib/MeshSearch/NodeSearch.cpp
+34
-30
34 additions, 30 deletions
MeshLib/MeshSearch/NodeSearch.cpp
MeshLib/MeshSearch/NodeSearch.h
+13
-1
13 additions, 1 deletion
MeshLib/MeshSearch/NodeSearch.h
with
47 additions
and
31 deletions
MeshLib/MeshSearch/NodeSearch.cpp
+
34
−
30
View file @
9f5153df
...
@@ -24,40 +24,44 @@ NodeSearch::NodeSearch(const MeshLib::Mesh &mesh)
...
@@ -24,40 +24,44 @@ NodeSearch::NodeSearch(const MeshLib::Mesh &mesh)
{
{
}
}
std
::
size_t
NodeSearch
::
searchByElementIDs
(
const
std
::
vector
<
std
::
size_t
>
&
elements
,
bool
only_match_all_connected_elements
)
std
::
vector
<
std
::
size_t
>
NodeSearch
::
searchByElementIDs
MatchAllConnectedElements
(
const
std
::
vector
<
std
::
size_t
>
&
elements
)
{
{
std
::
vector
<
std
::
size_t
>
connected_nodes
;
std
::
vector
<
std
::
size_t
>
connected_nodes
;
if
(
only_match_all_connected_elements
)
{
std
::
vector
<
std
::
size_t
>
node_marked_counts
(
_mesh
.
getNNodes
(),
0
);
//this approach is not optimum for memory size
std
::
vector
<
std
::
size_t
>
node_marked_counts
(
_mesh
.
getNNodes
(),
0
);
//this approach is not optimum for memory size
std
::
for_each
(
elements
.
begin
(),
elements
.
end
(),
std
::
for_each
(
elements
.
begin
(),
elements
.
end
(),
[
&
](
std
::
size_t
eid
)
[
&
](
std
::
size_t
eid
)
{
auto
*
e
=
_mesh
.
getElement
(
eid
);
for
(
unsigned
i
=
0
;
i
<
e
->
getNBaseNodes
();
i
++
)
{
node_marked_counts
[
e
->
getNodeIndex
(
i
)]
++
;
}
});
for
(
std
::
size_t
i
=
0
;
i
<
node_marked_counts
.
size
();
i
++
)
{
{
if
(
node_marked_counts
[
i
]
==
_mesh
.
getNode
(
i
)
->
getElements
().
size
())
auto
*
e
=
_mesh
.
getElement
(
eid
);
connected_nodes
.
push_back
(
i
);
for
(
unsigned
i
=
0
;
i
<
e
->
getNBaseNodes
();
i
++
)
{
}
node_marked_counts
[
e
->
getNodeIndex
(
i
)]
++
;
}
else
{
}
std
::
for_each
(
elements
.
begin
(),
elements
.
end
(),
});
[
&
](
std
::
size_t
eid
)
for
(
std
::
size_t
i
=
0
;
i
<
node_marked_counts
.
size
();
i
++
)
{
{
auto
*
e
=
_mesh
.
getElement
(
eid
);
if
(
node_marked_counts
[
i
]
==
_mesh
.
getNode
(
i
)
->
getElements
().
size
())
for
(
unsigned
i
=
0
;
i
<
e
->
getNBaseNodes
();
i
++
)
{
connected_nodes
.
push_back
(
i
);
connected_nodes
.
push_back
(
e
->
getNodeIndex
(
i
));
}
});
std
::
sort
(
connected_nodes
.
begin
(),
connected_nodes
.
end
());
auto
it
=
std
::
unique
(
connected_nodes
.
begin
(),
connected_nodes
.
end
());
connected_nodes
.
resize
(
std
::
distance
(
connected_nodes
.
begin
(),
it
));
}
}
this
->
updateUnion
(
connected_nodes
);
return
connected_nodes
;
return
connected_nodes
.
size
();
}
std
::
vector
<
std
::
size_t
>
NodeSearch
::
searchByElementIDsNotMatchAllConnectedElements
(
const
std
::
vector
<
std
::
size_t
>
&
elements
)
{
std
::
vector
<
std
::
size_t
>
connected_nodes
;
std
::
for_each
(
elements
.
begin
(),
elements
.
end
(),
[
&
](
std
::
size_t
eid
)
{
auto
*
e
=
_mesh
.
getElement
(
eid
);
for
(
unsigned
i
=
0
;
i
<
e
->
getNBaseNodes
();
i
++
)
{
connected_nodes
.
push_back
(
e
->
getNodeIndex
(
i
));
}
});
std
::
sort
(
connected_nodes
.
begin
(),
connected_nodes
.
end
());
auto
it
=
std
::
unique
(
connected_nodes
.
begin
(),
connected_nodes
.
end
());
connected_nodes
.
resize
(
std
::
distance
(
connected_nodes
.
begin
(),
it
));
return
connected_nodes
;
}
}
std
::
size_t
NodeSearch
::
searchUnused
()
std
::
size_t
NodeSearch
::
searchUnused
()
...
...
This diff is collapsed.
Click to expand it.
MeshLib/MeshSearch/NodeSearch.h
+
13
−
1
View file @
9f5153df
...
@@ -30,12 +30,24 @@ public:
...
@@ -30,12 +30,24 @@ public:
const
std
::
vector
<
std
::
size_t
>&
getSearchedNodeIDs
()
const
{
return
_marked_nodes
;
}
const
std
::
vector
<
std
::
size_t
>&
getSearchedNodeIDs
()
const
{
return
_marked_nodes
;
}
/// Marks all nodes connecting to any of the given elements
/// Marks all nodes connecting to any of the given elements
std
::
size_t
searchByElementIDs
(
const
std
::
vector
<
std
::
size_t
>
&
element_ids
,
bool
only_match_all_connected_elements
=
false
);
std
::
size_t
searchByElementIDs
(
const
std
::
vector
<
std
::
size_t
>
&
element_ids
,
bool
only_match_all_connected_elements
=
false
)
{
std
::
vector
<
std
::
size_t
>
connected_nodes
=
(
only_match_all_connected_elements
?
searchByElementIDsMatchAllConnectedElements
(
element_ids
)
:
searchByElementIDsNotMatchAllConnectedElements
(
element_ids
));
this
->
updateUnion
(
connected_nodes
);
return
connected_nodes
.
size
();
}
/// Marks all unused nodes
/// Marks all unused nodes
std
::
size_t
searchUnused
();
std
::
size_t
searchUnused
();
private
:
private
:
std
::
vector
<
std
::
size_t
>
searchByElementIDsMatchAllConnectedElements
(
const
std
::
vector
<
std
::
size_t
>
&
element_ids
);
std
::
vector
<
std
::
size_t
>
searchByElementIDsNotMatchAllConnectedElements
(
const
std
::
vector
<
std
::
size_t
>
&
element_ids
);
/// Updates the vector of marked items with values from vec.
/// Updates the vector of marked items with values from vec.
void
updateUnion
(
const
std
::
vector
<
std
::
size_t
>
&
vec
);
void
updateUnion
(
const
std
::
vector
<
std
::
size_t
>
&
vec
);
...
...
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