Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
amdis-core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
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
amdis
amdis-core
Commits
6f44dd6d
Commit
6f44dd6d
authored
5 years ago
by
Praetorius, Simon
Browse files
Options
Downloads
Patches
Plain Diff
add nodeIndexCount and test of nodeIndex range
parent
d2dcaa71
No related branches found
No related tags found
1 merge request
!102
Add range over node indices
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/amdis/functions/NodeIndices.hpp
+27
-4
27 additions, 4 deletions
src/amdis/functions/NodeIndices.hpp
test/CMakeLists.txt
+3
-0
3 additions, 0 deletions
test/CMakeLists.txt
test/NodeIndicesTest.cpp
+73
-0
73 additions, 0 deletions
test/NodeIndicesTest.cpp
with
103 additions
and
4 deletions
src/amdis/functions/NodeIndices.hpp
+
27
−
4
View file @
6f44dd6d
#pragma once
#include
<dune/common/rangeutilities.hh>
#include
<dune/functions/functionspacebases/concepts.hh>
#include
<amdis/typetree/MultiIndex.hpp>
#include
<amdis/utility/MappedRangeView.hpp>
namespace
AMDiS
{
/// Returns a range over
the
DOF indices on a node, given by the localView
/// Returns a range over
(flat)
DOF indices on a node, given by the localView
template
<
class
LocalView
,
class
Node
>
auto
nodeIndices
(
LocalView
const
&
localView
,
Node
const
&
node
)
{
return
mappedRangeView
(
Dune
::
range
(
node
.
size
()),
[
&
](
std
::
size_t
j
)
{
using
namespace
Dune
::
Functions
;
static_assert
(
Dune
::
models
<
Concept
::
LocalView
<
typename
LocalView
::
GlobalBasis
>
,
LocalView
>
(),
""
);
static_assert
(
Dune
::
models
<
Concept
::
BasisTree
<
typename
LocalView
::
GridView
>
,
Node
>
(),
""
);
return
mappedRangeView
(
Dune
::
range
(
node
.
size
()),
[
&
](
std
::
size_t
j
)
->
std
::
size_t
{
return
flatMultiIndex
(
localView
.
index
(
node
.
localIndex
(
j
)));
});
}
/// Returns a range over
the
DOF indices on the basis tree, given by the localView
/// Returns a range over
(flat)
DOF indices on the basis tree, given by the localView
template
<
class
LocalView
>
auto
nodeIndices
(
LocalView
const
&
localView
)
{
return
mappedRangeView
(
Dune
::
range
(
localView
.
size
()),
[
&
](
std
::
size_t
i
)
{
using
namespace
Dune
::
Functions
;
static_assert
(
Dune
::
models
<
Concept
::
LocalView
<
typename
LocalView
::
GlobalBasis
>
,
LocalView
>
(),
""
);
return
mappedRangeView
(
Dune
::
range
(
localView
.
size
()),
[
&
](
std
::
size_t
i
)
->
std
::
size_t
{
return
flatMultiIndex
(
localView
.
index
(
i
));
});
}
/// Returns the number of DOF indices on a node, given by the localView
template
<
class
LocalView
,
class
Node
>
std
::
size_t
nodeIndexCount
(
LocalView
const
&
/*localView*/
,
Node
const
&
node
)
{
return
node
.
size
();
}
/// Returns the number of DOF indices on the basis tree, given by the localView
template
<
class
LocalView
>
std
::
size_t
nodeIndexCount
(
LocalView
const
&
localView
)
{
return
localView
.
size
();
}
}
// end namespace AMDiS
This diff is collapsed.
Click to expand it.
test/CMakeLists.txt
+
3
−
0
View file @
6f44dd6d
...
...
@@ -84,6 +84,9 @@ dune_add_test(SOURCES MultiTypeVectorTest.cpp
dune_add_test
(
SOURCES MultiTypeMatrixTest.cpp
LINK_LIBRARIES amdis
)
dune_add_test
(
SOURCES NodeIndicesTest.cpp
LINK_LIBRARIES amdis
)
dune_add_test
(
SOURCES OperationsTest.cpp
LINK_LIBRARIES amdis
)
...
...
This diff is collapsed.
Click to expand it.
test/NodeIndicesTest.cpp
0 → 100644
+
73
−
0
View file @
6f44dd6d
#include
<dune/grid/yaspgrid.hh>
#include
<dune/functions/functionspacebases/compositebasis.hh>
#include
<dune/functions/functionspacebases/powerbasis.hh>
#include
<dune/functions/functionspacebases/lagrangebasis.hh>
#include
<amdis/functions/NodeIndices.hpp>
#include
"Tests.hpp"
int
main
()
{
using
namespace
AMDiS
;
using
namespace
Dune
::
Functions
::
BasisFactory
;
// create grid
Dune
::
YaspGrid
<
2
>
grid
({
1.0
,
1.0
},
{
1
,
1
});
auto
gridView
=
grid
.
leafGridView
();
// create basis
auto
taylorHoodBasis
=
makeBasis
(
gridView
,
composite
(
power
<
2
>
(
lagrange
<
2
>
(),
flatInterleaved
()),
lagrange
<
1
>
(),
flatLexicographic
()
));
auto
localView
=
taylorHoodBasis
.
localView
();
for
(
auto
const
&
e
:
elements
(
gridView
))
{
localView
.
bind
(
e
);
std
::
size_t
numDofs
=
2
*
(
3
*
3
)
+
(
2
*
2
);
std
::
size_t
numNodeIndices
=
nodeIndexCount
(
localView
);
AMDIS_TEST_EQ
(
numNodeIndices
,
numDofs
);
std
::
size_t
num
=
0
;
for
(
std
::
size_t
dof
:
nodeIndices
(
localView
))
{
DUNE_UNUSED_PARAMETER
(
dof
);
num
++
;
}
AMDIS_TEST_EQ
(
num
,
numDofs
);
auto
node
=
localView
.
tree
();
numNodeIndices
=
nodeIndexCount
(
localView
,
node
);
AMDIS_TEST_EQ
(
numNodeIndices
,
numDofs
);
// count the number of velocity dofs
std
::
size_t
numVelDofs
=
2
*
(
3
*
3
);
auto
v_node
=
Dune
::
TypeTree
::
child
(
node
,
Dune
::
Indices
::
_0
);
std
::
size_t
numVelNodeIndices
=
nodeIndexCount
(
localView
,
v_node
);
AMDIS_TEST_EQ
(
numVelNodeIndices
,
numVelDofs
);
num
=
0
;
for
(
std
::
size_t
dof
:
nodeIndices
(
localView
,
v_node
))
{
DUNE_UNUSED_PARAMETER
(
dof
);
num
++
;
}
AMDIS_TEST_EQ
(
num
,
numVelDofs
);
// count the number of pressure dofs
std
::
size_t
numPDofs
=
2
*
2
;
auto
p_node
=
Dune
::
TypeTree
::
child
(
node
,
Dune
::
Indices
::
_1
);
std
::
size_t
numPNodeIndices
=
nodeIndexCount
(
localView
,
p_node
);
AMDIS_TEST_EQ
(
numPNodeIndices
,
numPDofs
);
num
=
0
;
for
(
std
::
size_t
dof
:
nodeIndices
(
localView
,
p_node
))
{
DUNE_UNUSED_PARAMETER
(
dof
);
num
++
;
}
AMDIS_TEST_EQ
(
num
,
numPDofs
);
}
return
report_errors
();
}
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