Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
amdis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Show more breadcrumbs
iwr
amdis
Commits
8618030b
Commit
8618030b
authored
12 years ago
by
Praetorius, Simon
Browse files
Options
Downloads
Patches
Plain Diff
backgroundmesh and kdtree updated
parent
7e87c6ed
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
extensions/BackgroundMesh.cc
+2
-2
2 additions, 2 deletions
extensions/BackgroundMesh.cc
extensions/kdtree_nanoflann_mesh.h
+24
-20
24 additions, 20 deletions
extensions/kdtree_nanoflann_mesh.h
with
26 additions
and
22 deletions
extensions/BackgroundMesh.cc
+
2
−
2
View file @
8618030b
...
...
@@ -217,7 +217,7 @@ namespace experimental {
void
Box
::
init
()
{
int
maxNr
=
1
.0
;
int
maxNr
=
1
;
for
(
size_t
i
=
0
;
i
<
DOW
;
i
++
)
maxNr
*=
N
[
i
];
boxData
.
resize
(
maxNr
);
...
...
@@ -370,4 +370,4 @@ namespace experimental {
boxData
[
nr
].
push_back
(
data
);
}
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
extensions/kdtree_nanoflann_mesh.h
+
24
−
20
View file @
8618030b
...
...
@@ -36,6 +36,7 @@
#include
<iostream>
#include
"AMDiS.h"
#include
"ElementFunction.h"
using
namespace
nanoflann
;
using
namespace
AMDiS
;
...
...
@@ -66,10 +67,12 @@ typedef std::vector<DataType> VectorOfDataType;
typename
index_type
=
DegreeOfFreedom
>
struct
KDTreeMeshAdaptor
{
typedef
KDTreeMeshAdaptor
<
VectorOfPointsType_
,
typedef
KDTreeMeshAdaptor
<
VectorOfPointsType_
,
VectorOfDataType_
,
value_type
,
DIM
,
Distance
>
self_t
;
Distance
,
index_type
>
self_t
;
typedef
typename
Distance
::
template
traits
<
value_type
,
self_t
>
::
distance_t
metric_t
;
typedef
KDTreeSingleIndexAdaptor
<
metric_t
,
self_t
,
...
...
@@ -77,11 +80,12 @@ typedef std::vector<DataType> VectorOfDataType;
index_type
>
index_t
;
index_t
*
index
;
//! The kd-tree index for the user to call its methods as usual with any other FLANN index.
Mesh
*
mesh
;
/// Constructor: takes a const ref to the vector of vectors object with the data points
KDTree
VectorOfWorldVectors
Adaptor
(
const
int
dimensionality
,
Mesh
*
mesh_
,
const
int
leaf_max_size
=
10
)
KDTree
Mesh
Adaptor
(
const
int
dimensionality
,
Mesh
*
mesh_
,
const
int
leaf_max_size
=
10
)
:
mesh
(
mesh_
)
{
const
size_t
dims
=
Global
::
getGeo
(
WORLD
);
...
...
@@ -98,7 +102,7 @@ typedef std::vector<DataType> VectorOfDataType;
index
->
buildIndex
();
}
~
KDTree
VectorOfWorldVectors
Adaptor
()
{
~
KDTree
Mesh
Adaptor
()
{
delete
index
;
}
...
...
@@ -138,8 +142,8 @@ typedef std::vector<DataType> VectorOfDataType;
index
->
buildIndex
();
}
VectorOfPointsType_
&
m_points
;
VectorOfDataType_
&
m_data
;
VectorOfPointsType_
m_points
;
VectorOfDataType_
m_data
;
/** Query for the \a num_closest closest points to a given point (entered as query_point[0:dim-1]).
* Note that this is a short-cut method for index->findNeighbors().
...
...
@@ -169,7 +173,7 @@ typedef std::vector<DataType> VectorOfDataType;
// Must return the number of data points
inline
size_t
kdtree_get_point_count
()
const
{
return
m_points
.
getUsedS
ize
();
return
m_points
.
s
ize
();
}
// Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class:
...
...
@@ -249,24 +253,24 @@ typedef std::vector<DataType> VectorOfDataType;
};
// end of KDTreeMeshAdaptor
typedef
KDTreeMeshAdaptor
<
VectorOfPointsType
,
VectorOfDataType
,
double
>
KD_Tree
;
static
std
::
map
<
const
FiniteElemSpace
*
,
std
::
pair
<
int
,
KD_Tree
*>
>
kdtreeMap
;
typedef
KDTreeMeshAdaptor
<
VectorOfPointsType
,
VectorOfDataType
,
double
>
KD_Tree
_M
;
static
std
::
map
<
const
FiniteElemSpace
*
,
std
::
pair
<
int
,
KD_Tree
_M
*>
>
kdtreeMap
_M
;
inline
KD_Tree
*
provideKDTree
(
const
FiniteElemSpace
*
feSpace
)
inline
KD_Tree
_M
*
provideKDTree
(
const
FiniteElemSpace
*
feSpace
)
{
if
(
kdtreeMap
.
find
(
feSpace
)
!=
kdtreeMap
.
end
())
{
if
(
kdtreeMap
[
feSpace
].
first
!=
feSpace
->
getMesh
()
->
getChangeIndex
())
{
kdtreeMap
[
feSpace
].
second
->
reinit
();
kdtreeMap
[
feSpace
].
first
=
feSpace
->
getMesh
()
->
getChangeIndex
();
if
(
kdtreeMap
_M
.
find
(
feSpace
)
!=
kdtreeMap
_M
.
end
())
{
if
(
kdtreeMap
_M
[
feSpace
].
first
!=
feSpace
->
getMesh
()
->
getChangeIndex
())
{
kdtreeMap
_M
[
feSpace
].
second
->
reinit
();
kdtreeMap
_M
[
feSpace
].
first
=
feSpace
->
getMesh
()
->
getChangeIndex
();
}
}
else
{
KD_Tree
*
kdtree
=
new
KD_Tree
(
Global
::
getGeo
(
WORLD
),
feSpace
->
getMesh
());
kdtreeMap
[
feSpace
]
=
std
::
make_pair
(
feSpace
->
getMesh
()
->
getChangeIndex
(),
kdtree
);
KD_Tree
_M
*
kdtree
=
new
KD_Tree
_M
(
Global
::
getGeo
(
WORLD
),
feSpace
->
getMesh
());
kdtreeMap
_M
[
feSpace
]
=
std
::
make_pair
(
feSpace
->
getMesh
()
->
getChangeIndex
(),
kdtree
);
}
return
kdtreeMap
[
feSpace
].
second
;
return
kdtreeMap
_M
[
feSpace
].
second
;
}
}
// end namespace
}
// end namespace
experimental
#endif
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