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
Snippets
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
Özgür Ozan Sen
ogs
Commits
0f848e95
Commit
0f848e95
authored
1 year ago
by
Dmitri Naumov
Committed by
Tom Fischer
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
[MGTL] Move static class methods into TU
parent
93625bc7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MeshGeoToolsLib/BoundaryElementsAlongPolyline.cpp
+80
-57
80 additions, 57 deletions
MeshGeoToolsLib/BoundaryElementsAlongPolyline.cpp
MeshGeoToolsLib/BoundaryElementsAlongPolyline.h
+0
-31
0 additions, 31 deletions
MeshGeoToolsLib/BoundaryElementsAlongPolyline.h
with
80 additions
and
88 deletions
MeshGeoToolsLib/BoundaryElementsAlongPolyline.cpp
+
80
−
57
View file @
0f848e95
...
...
@@ -21,6 +21,86 @@
#include
"MeshLib/MeshSearch/ElementSearch.h"
#include
"MeshLib/Node.h"
namespace
{
/**
* Check if a vector of node IDs includes all nodes of a given element
* \param vec_node_ids a vector of Node IDs
* \param edge Edge object whose node IDs are checked
* \param edge_node_distances a vector of distances of the edge nodes from the
* beginning of the given node ID vector
* \return true if all element nodes are included in the vector
*/
bool
includesAllEdgeNodeIDs
(
std
::
vector
<
std
::
size_t
>
const
&
vec_node_ids
,
MeshLib
::
Element
const
&
edge
,
std
::
vector
<
std
::
size_t
>&
edge_node_distances
)
{
unsigned
j
=
0
;
for
(;
j
<
edge
.
getNumberOfBaseNodes
();
j
++
)
{
auto
itr
=
std
::
find
(
vec_node_ids
.
begin
(),
vec_node_ids
.
end
(),
getNodeIndex
(
edge
,
j
));
if
(
itr
!=
vec_node_ids
.
end
())
{
edge_node_distances
.
push_back
(
std
::
distance
(
vec_node_ids
.
begin
(),
itr
));
}
else
{
break
;
}
}
return
j
==
edge
.
getNumberOfBaseNodes
();
}
/**
* Modify node ordering of an edge so that its first node is closer to the
* beginning of a polyline than others
* \param edge Element object
* \param ply Polyline object
* \param edge_node_distances_along_ply A vector of current edge node
* distances along poly
* \param node_ids_on_poly A vector of node IDs along the polyine
* \return A pointer to the new modified edge object. A pointer to the original
* edge is returned if the modification is unnecessary.
*/
MeshLib
::
Element
*
modifyEdgeNodeOrdering
(
const
MeshLib
::
Element
&
edge
,
const
GeoLib
::
Polyline
&
ply
,
const
std
::
vector
<
std
::
size_t
>&
edge_node_distances_along_ply
,
const
std
::
vector
<
std
::
size_t
>&
node_ids_on_poly
)
{
// The first node of the edge should be always closer to the beginning of
// the polyline than other nodes.
if
(
edge_node_distances_along_ply
.
front
()
>
edge_node_distances_along_ply
.
back
()
||
(
ply
.
isClosed
()
&&
edge_node_distances_along_ply
.
back
()
==
node_ids_on_poly
.
size
()
-
1
))
{
// Create a new element with reversed local node index
if
(
auto
const
*
e
=
dynamic_cast
<
MeshLib
::
Line
const
*>
(
&
edge
))
{
std
::
array
nodes
=
{
const_cast
<
MeshLib
::
Node
*>
(
e
->
getNode
(
1
)),
const_cast
<
MeshLib
::
Node
*>
(
e
->
getNode
(
0
))};
return
new
MeshLib
::
Line
(
nodes
);
}
else
if
(
auto
const
*
e
=
dynamic_cast
<
MeshLib
::
Line3
const
*>
(
&
edge
))
{
std
::
array
nodes
=
{
const_cast
<
MeshLib
::
Node
*>
(
e
->
getNode
(
1
)),
const_cast
<
MeshLib
::
Node
*>
(
e
->
getNode
(
0
)),
const_cast
<
MeshLib
::
Node
*>
(
e
->
getNode
(
2
))};
return
new
MeshLib
::
Line3
(
nodes
);
}
else
{
OGS_FATAL
(
"Not implemented for element type {:s}"
,
typeid
(
edge
).
name
());
}
}
// Return the original edge otherwise.
return
const_cast
<
MeshLib
::
Element
*>
(
&
edge
);
}
}
// namespace
namespace
MeshGeoToolsLib
{
BoundaryElementsAlongPolyline
::
BoundaryElementsAlongPolyline
(
...
...
@@ -101,61 +181,4 @@ BoundaryElementsAlongPolyline::~BoundaryElementsAlongPolyline()
}
}
bool
BoundaryElementsAlongPolyline
::
includesAllEdgeNodeIDs
(
const
std
::
vector
<
std
::
size_t
>&
vec_node_ids
,
const
MeshLib
::
Element
&
edge
,
std
::
vector
<
std
::
size_t
>&
edge_node_distances
)
{
unsigned
j
=
0
;
for
(;
j
<
edge
.
getNumberOfBaseNodes
();
j
++
)
{
auto
itr
=
std
::
find
(
vec_node_ids
.
begin
(),
vec_node_ids
.
end
(),
getNodeIndex
(
edge
,
j
));
if
(
itr
!=
vec_node_ids
.
end
())
{
edge_node_distances
.
push_back
(
std
::
distance
(
vec_node_ids
.
begin
(),
itr
));
}
else
{
break
;
}
}
return
(
j
==
edge
.
getNumberOfBaseNodes
());
}
MeshLib
::
Element
*
BoundaryElementsAlongPolyline
::
modifyEdgeNodeOrdering
(
const
MeshLib
::
Element
&
edge
,
const
GeoLib
::
Polyline
&
ply
,
const
std
::
vector
<
std
::
size_t
>&
edge_node_distances_along_ply
,
const
std
::
vector
<
std
::
size_t
>&
node_ids_on_poly
)
const
{
// The first node of the edge should be always closer to the beginning of
// the polyline than other nodes.
if
(
edge_node_distances_along_ply
.
front
()
>
edge_node_distances_along_ply
.
back
()
||
(
ply
.
isClosed
()
&&
edge_node_distances_along_ply
.
back
()
==
node_ids_on_poly
.
size
()
-
1
))
{
// Create a new element with reversed local node index
if
(
auto
const
*
e
=
dynamic_cast
<
MeshLib
::
Line
const
*>
(
&
edge
))
{
std
::
array
nodes
=
{
const_cast
<
MeshLib
::
Node
*>
(
e
->
getNode
(
1
)),
const_cast
<
MeshLib
::
Node
*>
(
e
->
getNode
(
0
))};
return
new
MeshLib
::
Line
(
nodes
);
}
else
if
(
auto
const
*
e
=
dynamic_cast
<
MeshLib
::
Line3
const
*>
(
&
edge
))
{
std
::
array
nodes
=
{
const_cast
<
MeshLib
::
Node
*>
(
e
->
getNode
(
1
)),
const_cast
<
MeshLib
::
Node
*>
(
e
->
getNode
(
0
)),
const_cast
<
MeshLib
::
Node
*>
(
e
->
getNode
(
2
))};
return
new
MeshLib
::
Line3
(
nodes
);
}
else
{
OGS_FATAL
(
"Not implemented for element type {:s}"
,
typeid
(
edge
).
name
());
}
}
// Return the original edge otherwise.
return
const_cast
<
MeshLib
::
Element
*>
(
&
edge
);
}
}
// end namespace MeshGeoToolsLib
This diff is collapsed.
Click to expand it.
MeshGeoToolsLib/BoundaryElementsAlongPolyline.h
+
0
−
31
View file @
0f848e95
...
...
@@ -67,37 +67,6 @@ public:
}
private
:
/**
* Check if a vector of node IDs includes all nodes of a given element
* @param vec_node_ids a vector of Node IDs
* @param edge Edge object whose node IDs are checked
* @param edge_node_distances a vector of distances of the edge nodes from
* the beginning of the given node ID vector
* @return true if all element nodes are included in the vector
*/
static
bool
includesAllEdgeNodeIDs
(
const
std
::
vector
<
std
::
size_t
>&
vec_node_ids
,
const
MeshLib
::
Element
&
edge
,
std
::
vector
<
std
::
size_t
>&
edge_node_distances
);
/**
* Modify node ordering of an edge so that its first node is closer to the
* beginning of a polyline than others
* @param edge Element object
* @param ply Polyline object
* @param edge_node_distances_along_ply A vector of current edge node
* distances along poly
* @param node_ids_on_poly A vector of node IDs along the
* polyine
* @return A pointer to the new modified edge object. A pointer to the
* original edge is returned if the modification is unnecessary.
*/
MeshLib
::
Element
*
modifyEdgeNodeOrdering
(
const
MeshLib
::
Element
&
edge
,
const
GeoLib
::
Polyline
&
ply
,
const
std
::
vector
<
std
::
size_t
>&
edge_node_distances_along_ply
,
const
std
::
vector
<
std
::
size_t
>&
node_ids_on_poly
)
const
;
MeshLib
::
Mesh
const
&
_mesh
;
GeoLib
::
Polyline
const
&
_ply
;
std
::
vector
<
MeshLib
::
Element
*>
_boundary_elements
;
...
...
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