Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VirtualFluids
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
iRMB
VirtualFluids
Commits
ae4ab5c2
Commit
ae4ab5c2
authored
2 years ago
by
Anna Wellmann
Browse files
Options
Downloads
Patches
Plain Diff
Fix bug and add some tests in NeighborDebugWriter
parent
dbfe4d72
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!182
Fix bug and add some tests in NeighborDebugWriter
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/gpu/VirtualFluids_GPU/Output/NeighborDebugWriter.hpp
+12
-10
12 additions, 10 deletions
src/gpu/VirtualFluids_GPU/Output/NeighborDebugWriter.hpp
src/gpu/VirtualFluids_GPU/Output/NeighborDebugWriterTest.cpp
+89
-0
89 additions, 0 deletions
src/gpu/VirtualFluids_GPU/Output/NeighborDebugWriterTest.cpp
with
101 additions
and
10 deletions
src/gpu/VirtualFluids_GPU/Output/NeighborDebugWriter.hpp
+
12
−
10
View file @
ae4ab5c2
...
...
@@ -5,25 +5,27 @@
#include
"Logger.h"
#include
"Parameter/Parameter.h"
#include
"basics/utilities/UbSystem.h"
#include
"grid/NodeValues.h"
#include
"
gpu/GridGenerator/
grid/NodeValues.h"
#include
"lbm/constants/D3Q27.h"
#include
<basics/writer/WbWriterVtkXmlBinary.h>
#include
"Utilities/FindNeighbors.h"
#include
"VirtualFluids_GPU/Communication/Communicator.h"
#include
"Core/StringUtilities/StringUtil.h"
#include
"Utilities/FindNeighbors.h"
#include
"gpu/VirtualFluids_GPU/Communication/Communicator.h"
namespace
NeighborDebugWriter
{
inline
void
writeNeighborLinkLines
(
Parameter
*
para
,
const
int
level
,
const
unsigned
long
long
numberOfNodes
,
const
int
direction
,
const
std
::
string
&
name
)
inline
void
writeNeighborLinkLines
(
Parameter
*
para
,
int
level
,
int
direction
,
const
std
::
string
&
name
,
WbWriter
*
writer
)
{
VF_LOG_INFO
(
"Write node links in direction {}."
,
direction
);
std
::
vector
<
UbTupleFloat3
>
nodes
(
numberOfNodes
*
2
);
std
::
vector
<
UbTupleInt2
>
cells
(
numberOfNodes
);
std
::
vector
<
UbTupleFloat3
>
nodes
;
nodes
.
reserve
(
para
->
getParH
(
level
)
->
numberOfNodes
);
std
::
vector
<
UbTupleInt2
>
cells
;
cells
.
reserve
(
para
->
getParH
(
level
)
->
numberOfNodes
/
2
);
for
(
size_t
position
=
0
;
position
<
numberOfNodes
;
position
++
)
{
for
(
size_t
position
=
0
;
position
<
para
->
getParH
(
level
)
->
numberOfNodes
;
position
++
)
{
if
(
para
->
getParH
(
level
)
->
typeOfGridNode
[
position
]
!=
GEO_FLUID
)
continue
;
...
...
@@ -42,7 +44,7 @@ inline void writeNeighborLinkLines(Parameter *para, const int level, const unsig
cells
.
emplace_back
((
int
)
nodes
.
size
()
-
2
,
(
int
)
nodes
.
size
()
-
1
);
}
WbW
riter
VtkXmlBinary
::
getInstance
()
->
writeLines
(
name
,
nodes
,
cells
);
w
riter
->
writeLines
(
name
,
nodes
,
cells
);
}
inline
void
writeNeighborLinkLinesDebug
(
Parameter
*
para
)
...
...
@@ -51,7 +53,7 @@ inline void writeNeighborLinkLinesDebug(Parameter *para)
for
(
size_t
direction
=
vf
::
lbm
::
dir
::
STARTDIR
;
direction
<=
vf
::
lbm
::
dir
::
ENDDIR
;
direction
++
)
{
const
std
::
string
fileName
=
para
->
getFName
()
+
"_"
+
StringUtil
::
toString
<
int
>
(
level
)
+
"_Link_"
+
std
::
to_string
(
direction
)
+
"_Debug.vtk"
;
writeNeighborLinkLines
(
para
,
level
,
para
->
getParH
(
level
)
->
numberOfNodes
,
(
int
)
direction
,
fileName
);
writeNeighborLinkLines
(
para
,
level
,
(
int
)
direction
,
fileName
,
WbWriterVtkXmlBinary
::
getInstance
()
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/gpu/VirtualFluids_GPU/Output/NeighborDebugWriterTest.cpp
0 → 100644
+
89
−
0
View file @
ae4ab5c2
#include
"NeighborDebugWriter.hpp"
#include
"LBM/LB.h"
#include
"PreCollisionInteractor/PreCollisionInteractor.h"
#include
"UbTuple.h"
#include
"gpu/VirtualFluids_GPU/Utilities/testUtilitiesGPU.h"
#include
"lbm/constants/D3Q27.h"
#include
<gmock/gmock.h>
#include
<gtest/gtest.h>
#include
<iostream>
#include
<iterator>
#include
<memory>
#include
<vector>
class
WbWriterSpy
:
public
WbWriter
{
public:
std
::
string
writeLines
(
const
std
::
string
&
/*filename*/
,
std
::
vector
<
UbTupleFloat3
>
&
nodes
,
std
::
vector
<
UbTupleInt2
>
&
lines
)
override
{
this
->
nodes
=
nodes
;
this
->
lines
=
lines
;
return
""
;
}
std
::
vector
<
UbTupleFloat3
>
nodes
;
std
::
vector
<
UbTupleInt2
>
lines
;
std
::
string
getFileExtension
()
override
{
return
""
;
}
};
class
NeighborDebugWriterTest
:
public
testing
::
Test
{
protected:
void
SetUp
()
override
{
typeOfGridNode
=
std
::
vector
<
uint
>
(
numberOfNodes
,
GEO_FLUID
);
neighbors
=
std
::
vector
<
uint
>
(
numberOfNodes
,
2
);
coordinates
=
std
::
vector
<
real
>
(
numberOfNodes
,
1.0
);
coordinates
[
2
]
=
3.0
;
para
=
testingVF
::
createParameterForLevel
(
0
);
para
->
getParH
(
level
)
->
numberOfNodes
=
numberOfNodes
;
para
->
getParH
(
level
)
->
coordinateX
=
coordinates
.
data
();
para
->
getParH
(
level
)
->
coordinateY
=
coordinates
.
data
();
para
->
getParH
(
level
)
->
coordinateZ
=
coordinates
.
data
();
para
->
getParH
(
level
)
->
neighborX
=
neighbors
.
data
();
para
->
getParH
(
level
)
->
typeOfGridNode
=
typeOfGridNode
.
data
();
}
const
int
level
=
0
;
const
unsigned
long
long
numberOfNodes
=
3
;
const
uint
direction
=
vf
::
lbm
::
dir
::
DIR_P00
;
// x
std
::
shared_ptr
<
Parameter
>
para
;
WbWriterSpy
writerSpy
;
std
::
vector
<
uint
>
typeOfGridNode
;
std
::
vector
<
uint
>
neighbors
;
std
::
vector
<
real
>
coordinates
;
};
TEST_F
(
NeighborDebugWriterTest
,
writeNeighborLinkLinesOnlyFLuidNodes
)
{
UbTupleFloat3
oneCoord
(
1.0
,
1.0
,
1.0
);
UbTupleFloat3
threeCoord
(
3.0
,
3.0
,
3.0
);
std
::
vector
<
UbTupleFloat3
>
expectedNodes
=
{
oneCoord
,
threeCoord
,
oneCoord
,
threeCoord
,
threeCoord
,
threeCoord
};
std
::
vector
<
UbTupleInt2
>
expectedLines
=
{
UbTupleInt2
(
0
,
1
),
UbTupleInt2
(
2
,
3
),
UbTupleInt2
(
4
,
5
)
};
NeighborDebugWriter
::
writeNeighborLinkLines
(
para
.
get
(),
level
,
direction
,
"name"
,
&
writerSpy
);
EXPECT_THAT
(
writerSpy
.
nodes
.
size
(),
testing
::
Eq
(
numberOfNodes
*
2
));
EXPECT_THAT
(
writerSpy
.
lines
.
size
(),
testing
::
Eq
(
numberOfNodes
));
EXPECT_THAT
(
writerSpy
.
nodes
,
testing
::
Eq
(
expectedNodes
));
EXPECT_THAT
(
writerSpy
.
lines
,
testing
::
Eq
(
expectedLines
));
}
TEST_F
(
NeighborDebugWriterTest
,
writeNeighborLinkLinesOneSolidNode
)
{
typeOfGridNode
[
2
]
=
GEO_SOLID
;
UbTupleFloat3
oneCoord
(
1.0
,
1.0
,
1.0
);
UbTupleFloat3
threeCoord
(
3.0
,
3.0
,
3.0
);
std
::
vector
<
UbTupleFloat3
>
expectedNodes
=
{
oneCoord
,
threeCoord
,
oneCoord
,
threeCoord
};
std
::
vector
<
UbTupleInt2
>
expectedLines
=
{
UbTupleInt2
(
0
,
1
),
UbTupleInt2
(
2
,
3
)};
NeighborDebugWriter
::
writeNeighborLinkLines
(
para
.
get
(),
level
,
direction
,
"name"
,
&
writerSpy
);
EXPECT_THAT
(
writerSpy
.
nodes
.
size
(),
testing
::
Eq
((
numberOfNodes
-
1
)
*
2
));
EXPECT_THAT
(
writerSpy
.
lines
.
size
(),
testing
::
Eq
(
numberOfNodes
-
1
));
EXPECT_THAT
(
writerSpy
.
nodes
,
testing
::
Eq
(
expectedNodes
));
EXPECT_THAT
(
writerSpy
.
lines
,
testing
::
Eq
(
expectedLines
));
}
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