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
Dmitri Naumov
ogs
Commits
bb776a27
Commit
bb776a27
authored
12 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
some optimizations for speed up the computations
parent
36a63523
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
MeshLib/Mesh2MeshPropertyInterpolation.cpp
+38
-13
38 additions, 13 deletions
MeshLib/Mesh2MeshPropertyInterpolation.cpp
with
38 additions
and
13 deletions
MeshLib/Mesh2MeshPropertyInterpolation.cpp
+
38
−
13
View file @
bb776a27
...
...
@@ -16,6 +16,7 @@
// BaseLib
#include
"logog/include/logog.hpp"
#include
"StringTools.h"
// GeoLib
#include
"AABB.h"
...
...
@@ -79,18 +80,9 @@ void Mesh2MeshPropertyInterpolation::interpolatePropertiesForMesh(Mesh *dest_mes
// compute axis aligned bounding box around the current element
const
GeoLib
::
AABB
<
MeshLib
::
Node
>
elem_aabb
(
dest_elements
[
k
]
->
getNodes
(),
dest_elements
[
k
]
->
getNodes
()
+
dest_elements
[
k
]
->
getNNodes
());
// compute parameters for requesting "interesting" nodes from the grid
double
center
[
3
]
=
{(
elem_aabb
.
getMaxPoint
()[
0
]
+
elem_aabb
.
getMinPoint
()[
0
])
/
2
,
(
elem_aabb
.
getMaxPoint
()[
1
]
+
elem_aabb
.
getMinPoint
()[
1
])
/
2
,
(
elem_aabb
.
getMaxPoint
()[
2
]
+
elem_aabb
.
getMinPoint
()[
2
])
/
2
};
double
half_len
(
std
::
max
(
elem_aabb
.
getMaxPoint
()[
0
]
-
elem_aabb
.
getMinPoint
()[
0
],
elem_aabb
.
getMaxPoint
()[
1
]
-
elem_aabb
.
getMinPoint
()[
1
]));
half_len
=
std
::
max
(
half_len
,
elem_aabb
.
getMaxPoint
()[
2
]
-
elem_aabb
.
getMinPoint
()[
2
]);
half_len
/=
2
;
// request "interesting" nodes from grid
std
::
vector
<
std
::
vector
<
MeshLib
::
Node
*>
const
*>
nodes
;
src_grid
.
getVecsOfGridCellsIntersectingCub
e
(
center
,
half_len
,
nodes
);
src_grid
.
get
Pnt
VecsOfGridCellsIntersectingCub
oid
(
elem_aabb
.
getMinPoint
(),
elem_aabb
.
getMaxPoint
()
,
nodes
);
size_t
cnt
(
0
);
dest_properties
[
k
]
=
0.0
;
...
...
@@ -100,15 +92,48 @@ void Mesh2MeshPropertyInterpolation::interpolatePropertiesForMesh(Mesh *dest_mes
const
size_t
n_nodes_in_vec
(
i_th_vec
->
size
());
for
(
size_t
j
(
0
);
j
<
n_nodes_in_vec
;
j
++
)
{
MeshLib
::
Node
const
*
const
j_th_node
((
*
i_th_vec
)[
j
]);
if
(
dynamic_cast
<
MeshLib
::
Face
*>
(
dest_elements
[
k
])
->
isPntInside
(
*
dynamic_cast
<
GeoLib
::
Point
const
*>
(
j_th_node
)))
{
dest_properties
[
k
]
+=
interpolated_src_node_properties
[(
*
i_th_vec
)[
j
]
->
getID
()];
cnt
++
;
if
(
elem_aabb
.
containsPoint
(
*
j_th_node
))
{
if
(
dynamic_cast
<
MeshLib
::
Face
*>
(
dest_elements
[
k
])
->
isPntInside
(
*
dynamic_cast
<
GeoLib
::
Point
const
*>
(
j_th_node
),
30
))
{
dest_properties
[
k
]
+=
interpolated_src_node_properties
[(
*
i_th_vec
)[
j
]
->
getID
()];
cnt
++
;
}
}
}
}
dest_properties
[
k
]
/=
cnt
;
dest_elements
[
k
]
->
setValue
(
k
);
if
(
cnt
==
0
)
{
std
::
string
base_name
(
"DebugData/Element-"
);
base_name
+=
BaseLib
::
number2str
(
k
);
std
::
string
aabb_fname
(
base_name
+
"-aabb.gli"
);
std
::
ofstream
out_aabb
(
aabb_fname
.
c_str
());
out_aabb
<<
"#POINTS"
<<
std
::
endl
;
out_aabb
<<
"0 "
<<
elem_aabb
.
getMinPoint
()
<<
std
::
endl
;
out_aabb
<<
"1 "
<<
elem_aabb
.
getMaxPoint
()
<<
std
::
endl
;
out_aabb
<<
"#STOP"
<<
std
::
endl
;
out_aabb
.
close
();
std
::
string
source_fname
(
base_name
+
"-SourceNodes.gli"
);
std
::
ofstream
out_src
(
source_fname
.
c_str
());
out_src
<<
"#POINTS"
<<
std
::
endl
;
size_t
nodes_cnt
(
0
);
for
(
size_t
i
(
0
);
i
<
nodes
.
size
();
++
i
)
{
std
::
vector
<
MeshLib
::
Node
*>
const
*
i_th_vec
(
nodes
[
i
]);
const
size_t
n_nodes_in_vec
(
i_th_vec
->
size
());
for
(
size_t
j
(
0
);
j
<
n_nodes_in_vec
;
j
++
)
{
MeshLib
::
Node
const
*
const
j_th_node
((
*
i_th_vec
)[
j
]);
out_src
<<
nodes_cnt
<<
" "
<<
*
(
dynamic_cast
<
GeoLib
::
Point
const
*>
(
j_th_node
))
<<
std
::
endl
;
nodes_cnt
++
;
}
}
out_src
<<
"#STOP"
<<
std
::
endl
;
out_src
.
close
();
std
::
cerr
<<
"no source nodes in dest element "
<<
k
<<
std
::
endl
;
}
}
}
...
...
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