Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
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
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
code
pugs
Commits
bfb44870
Commit
bfb44870
authored
7 years ago
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
added MeshData class (contains updated geometric info)
parent
bf87101c
No related branches found
No related tags found
2 merge requests
!2
Develop
,
!1
Develop
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
experimental/AcousticSolverWithMesh.hpp
+16
-32
16 additions, 32 deletions
experimental/AcousticSolverWithMesh.hpp
experimental/Mesh.hpp
+1
-1
1 addition, 1 deletion
experimental/Mesh.hpp
experimental/MeshData.hpp
+138
-0
138 additions, 0 deletions
experimental/MeshData.hpp
main.cpp
+7
-2
7 additions, 2 deletions
main.cpp
with
162 additions
and
35 deletions
experimental/AcousticSolverWithMesh.hpp
+
16
−
32
View file @
bfb44870
...
@@ -9,11 +9,14 @@
...
@@ -9,11 +9,14 @@
#include
<TinyVector.hpp>
#include
<TinyVector.hpp>
#include
<TinyMatrix.hpp>
#include
<TinyMatrix.hpp>
#include
<Mesh.hpp>
#include
<Mesh.hpp>
#include
<MeshData.hpp>
template
<
typename
MeshData
>
template
<
typename
MeshType
>
class
AcousticSolverWithMesh
class
AcousticSolverWithMesh
{
{
typedef
typename
MeshData
::
MeshType
MeshType
;
MeshData
&
m_mesh_data
;
const
MeshType
&
m_mesh
;
const
MeshType
&
m_mesh
;
const
typename
MeshType
::
Connectivity
&
m_connectivity
;
const
typename
MeshType
::
Connectivity
&
m_connectivity
;
...
@@ -225,11 +228,12 @@ private:
...
@@ -225,11 +228,12 @@ private:
public
:
public
:
AcousticSolverWithMesh
(
MeshType
&
mesh
)
AcousticSolverWithMesh
(
MeshData
&
mesh_data
)
:
m_mesh
(
mesh
),
:
m_mesh_data
(
mesh_data
),
m_mesh
(
mesh_data
.
mesh
()),
m_connectivity
(
m_mesh
.
connectivity
()),
m_connectivity
(
m_mesh
.
connectivity
()),
m_nj
(
mesh
.
numberOfCells
()),
m_nj
(
m_
mesh
.
numberOfCells
()),
m_nr
(
mesh
.
numberOfNodes
()),
m_nr
(
m_
mesh
.
numberOfNodes
()),
m_br
(
"br"
,
m_nr
),
m_br
(
"br"
,
m_nr
),
m_Ajr
(
"Ajr"
,
m_nj
,
m_connectivity
.
maxNbNodePerCell
()),
m_Ajr
(
"Ajr"
,
m_nj
,
m_connectivity
.
maxNbNodePerCell
()),
m_Ar
(
"Ar"
,
m_nr
),
m_Ar
(
"Ar"
,
m_nr
),
...
@@ -239,7 +243,6 @@ public:
...
@@ -239,7 +243,6 @@ public:
m_rhocj
(
"rho_c"
,
m_nj
),
m_rhocj
(
"rho_c"
,
m_nj
),
m_Vj_over_cj
(
"Vj_over_cj"
,
m_nj
)
m_Vj_over_cj
(
"Vj_over_cj"
,
m_nj
)
{
{
Kokkos
::
View
<
Rd
*>
xj
(
"xj"
,
m_nj
);
Kokkos
::
View
<
double
*>
rhoj
(
"rhoj"
,
m_nj
);
Kokkos
::
View
<
double
*>
rhoj
(
"rhoj"
,
m_nj
);
Kokkos
::
View
<
Rd
*>
uj
(
"uj"
,
m_nj
);
Kokkos
::
View
<
Rd
*>
uj
(
"uj"
,
m_nj
);
...
@@ -247,28 +250,17 @@ public:
...
@@ -247,28 +250,17 @@ public:
Kokkos
::
View
<
double
*>
Ej
(
"Ej"
,
m_nj
);
Kokkos
::
View
<
double
*>
Ej
(
"Ej"
,
m_nj
);
Kokkos
::
View
<
double
*>
ej
(
"ej"
,
m_nj
);
Kokkos
::
View
<
double
*>
ej
(
"ej"
,
m_nj
);
Kokkos
::
View
<
double
*>
pj
(
"pj"
,
m_nj
);
Kokkos
::
View
<
double
*>
pj
(
"pj"
,
m_nj
);
Kokkos
::
View
<
double
*>
Vj
(
"Vj"
,
m_nj
);
Kokkos
::
View
<
double
*>
gammaj
(
"gammaj"
,
m_nj
);
Kokkos
::
View
<
double
*>
gammaj
(
"gammaj"
,
m_nj
);
Kokkos
::
View
<
double
*>
cj
(
"cj"
,
m_nj
);
Kokkos
::
View
<
double
*>
cj
(
"cj"
,
m_nj
);
Kokkos
::
View
<
double
*>
mj
(
"mj"
,
m_nj
);
Kokkos
::
View
<
double
*>
mj
(
"mj"
,
m_nj
);
Kokkos
::
View
<
Rd
*>
xr
=
mesh
.
xr
();
Kokkos
::
View
<
Rd
*>
xr
=
m_mesh
.
xr
();
const
Kokkos
::
View
<
const
unsigned
int
**>&
cell_nodes
=
m_connectivity
.
cellNodes
();
Kokkos
::
parallel_for
(
m_nj
,
KOKKOS_LAMBDA
(
const
int
&
j
){
xj
[
j
]
=
0.5
*
(
xr
[
cell_nodes
(
j
,
0
)]
+
xr
[
cell_nodes
(
j
,
1
)]);
});
Kokkos
::
View
<
Rd
*
[
2
]
>
Cjr
(
"Cjr"
,
m_nj
);
const
Kokkos
::
View
<
const
Rd
*>
xj
=
m_mesh_data
.
xj
();
Kokkos
::
parallel_for
(
m_nj
,
KOKKOS_LAMBDA
(
const
int
&
j
)
{
const
Kokkos
::
View
<
const
double
*>
Vj
=
m_mesh_data
.
Vj
();
Cjr
(
j
,
0
)
=-
1
;
Cjr
(
j
,
1
)
=
1
;
});
Kokkos
::
parallel_for
(
m_nj
,
KOKKOS_LAMBDA
(
const
int
&
j
){
const
Kokkos
::
View
<
const
unsigned
int
**>&
cell_nodes
=
m_connectivity
.
cellNodes
();
Vj
[
j
]
=
(
xr
[
cell_nodes
(
j
,
1
)],
Cjr
(
j
,
1
))
const
Kokkos
::
View
<
const
Rd
**>
Cjr
=
m_mesh_data
.
Cjr
();
+
(
xr
[
cell_nodes
(
j
,
0
)],
Cjr
(
j
,
0
));
});
Kokkos
::
parallel_for
(
m_nj
,
KOKKOS_LAMBDA
(
const
int
&
j
){
Kokkos
::
parallel_for
(
m_nj
,
KOKKOS_LAMBDA
(
const
int
&
j
){
if
(
xj
[
j
][
0
]
<
0.5
)
{
if
(
xj
[
j
][
0
]
<
0.5
)
{
...
@@ -351,15 +343,7 @@ public:
...
@@ -351,15 +343,7 @@ public:
xr
[
r
]
+=
dt
*
ur
[
r
];
xr
[
r
]
+=
dt
*
ur
[
r
];
});
});
Kokkos
::
parallel_for
(
m_nj
,
KOKKOS_LAMBDA
(
const
int
&
j
){
m_mesh_data
.
updateAllData
();
xj
[
j
]
=
0.5
*
(
xr
[
j
]
+
xr
[
j
+
1
]);
});
Kokkos
::
parallel_for
(
m_nj
,
KOKKOS_LAMBDA
(
const
int
&
j
){
Vj
[
j
]
=
(
xr
[
cell_nodes
(
j
,
1
)],
Cjr
(
j
,
1
))
+
(
xr
[
cell_nodes
(
j
,
0
)],
Cjr
(
j
,
0
));
});
Kokkos
::
parallel_for
(
m_nj
,
KOKKOS_LAMBDA
(
const
int
&
j
){
Kokkos
::
parallel_for
(
m_nj
,
KOKKOS_LAMBDA
(
const
int
&
j
){
rhoj
[
j
]
=
mj
[
j
]
/
Vj
[
j
];
rhoj
[
j
]
=
mj
[
j
]
/
Vj
[
j
];
...
...
This diff is collapsed.
Click to expand it.
experimental/Mesh.hpp
+
1
−
1
View file @
bfb44870
...
@@ -39,7 +39,7 @@ public:
...
@@ -39,7 +39,7 @@ public:
}
}
#warning PASSER CES NOUVEAUX VECTEURS EN CONST
#warning PASSER CES NOUVEAUX VECTEURS EN CONST
Kokkos
::
View
<
Rd
*>
xr
()
Kokkos
::
View
<
Rd
*>
xr
()
const
{
{
return
m_xr
;
return
m_xr
;
}
}
...
...
This diff is collapsed.
Click to expand it.
experimental/MeshData.hpp
0 → 100644
+
138
−
0
View file @
bfb44870
#ifndef MESH_DATA_HPP
#define MESH_DATA_HPP
#include
<Kokkos_Core.hpp>
#include
<TinyVector.hpp>
template
<
typename
M
>
class
MeshData
{
public:
typedef
M
MeshType
;
typedef
TinyVector
<
dimension
>
Rd
;
typedef
double
R
;
static
constexpr
size_t
dimension
=
MeshType
::
dimension
;
static_assert
(
dimension
>
0
,
"dimension must be strictly positive"
);
static
constexpr
R
inv_dimension
=
1.
/
dimension
;
private:
const
MeshType
&
m_mesh
;
Kokkos
::
View
<
Rd
**>
m_Cjr
;
Kokkos
::
View
<
Rd
*>
m_xj
;
Kokkos
::
View
<
R
*>
m_Vj
;
template
<
size_t
Dim
>
KOKKOS_INLINE_FUNCTION
void
_updateCenter
();
template
<
>
KOKKOS_INLINE_FUNCTION
void
_updateCenter
<
1
>
()
{
const
Kokkos
::
View
<
const
Rd
*>
xr
=
m_mesh
.
xr
();
const
Kokkos
::
View
<
const
unsigned
int
**>&
cell_nodes
=
m_mesh
.
connectivity
().
cellNodes
();
Kokkos
::
parallel_for
(
m_mesh
.
numberOfCells
(),
KOKKOS_LAMBDA
(
const
int
&
j
){
m_xj
[
j
]
=
0.5
*
(
xr
[
cell_nodes
(
j
,
0
)]
+
xr
[
cell_nodes
(
j
,
1
)]);
});
}
template
<
size_t
Dim
>
KOKKOS_INLINE_FUNCTION
void
_updateVolume
()
{
const
Kokkos
::
View
<
const
unsigned
int
**>&
cell_nodes
=
m_mesh
.
connectivity
().
cellNodes
();
const
Kokkos
::
View
<
const
unsigned
short
*>
cell_nb_nodes
=
m_mesh
.
connectivity
().
cellNbNodes
();
const
Kokkos
::
View
<
const
Rd
*>
xr
=
m_mesh
.
xr
();
Kokkos
::
parallel_for
(
m_mesh
.
numberOfCells
(),
KOKKOS_LAMBDA
(
const
int
&
j
){
R
sum_cjr_xr
=
0
;
for
(
int
R
=
0
;
R
<
cell_nb_nodes
[
j
];
++
R
)
{
sum_cjr_xr
+=
(
xr
[
cell_nodes
(
j
,
R
)],
m_Cjr
(
j
,
R
));
}
m_Vj
[
j
]
=
inv_dimension
*
sum_cjr_xr
;
});
}
template
<
>
KOKKOS_INLINE_FUNCTION
void
_updateVolume
<
1
>
()
{
const
Kokkos
::
View
<
const
Rd
*>
xr
=
m_mesh
.
xr
();
const
Kokkos
::
View
<
const
unsigned
int
**>&
cell_nodes
=
m_mesh
.
connectivity
().
cellNodes
();
Kokkos
::
parallel_for
(
m_mesh
.
numberOfCells
(),
KOKKOS_LAMBDA
(
const
int
&
j
){
m_Vj
[
j
]
=
(
xr
[
cell_nodes
(
j
,
1
)],
m_Cjr
(
j
,
1
))
+
(
xr
[
cell_nodes
(
j
,
0
)],
m_Cjr
(
j
,
0
));
});
}
template
<
size_t
Dim
>
KOKKOS_INLINE_FUNCTION
void
_updateCjr
();
template
<
>
KOKKOS_INLINE_FUNCTION
void
_updateCjr
<
1
>
()
{}
public
:
const
MeshType
&
mesh
()
const
{
return
m_mesh
;
}
const
Kokkos
::
View
<
const
Rd
**>
Cjr
()
const
{
return
m_Cjr
;
}
const
Kokkos
::
View
<
const
Rd
*>
xj
()
const
{
return
m_xj
;
}
const
Kokkos
::
View
<
const
R
*>
Vj
()
const
{
return
m_Vj
;
}
void
updateAllData
()
{
this
->
_updateCenter
<
dimension
>
();
this
->
_updateVolume
<
dimension
>
();
this
->
_updateCjr
<
dimension
>
();
}
MeshData
(
const
MeshType
&
mesh
)
:
m_mesh
(
mesh
),
m_Cjr
(
"Cjr"
,
mesh
.
numberOfCells
(),
mesh
.
connectivity
().
maxNbNodePerCell
()),
m_xj
(
"xj"
,
mesh
.
numberOfCells
()),
m_Vj
(
"Vj"
,
mesh
.
numberOfCells
())
{
Kokkos
::
parallel_for
(
m_mesh
.
numberOfCells
(),
KOKKOS_LAMBDA
(
const
int
&
j
)
{
m_Cjr
(
j
,
0
)
=-
1
;
m_Cjr
(
j
,
1
)
=
1
;
});
this
->
updateAllData
();
}
~
MeshData
()
{
;
}
};
#endif // MESH_DATA_HPP
This diff is collapsed.
Click to expand it.
main.cpp
+
7
−
2
View file @
bfb44870
...
@@ -118,8 +118,13 @@ int main(int argc, char *argv[])
...
@@ -118,8 +118,13 @@ int main(int argc, char *argv[])
Kokkos
::
Timer
timer
;
Kokkos
::
Timer
timer
;
timer
.
reset
();
timer
.
reset
();
Connectivity1D
connectivity
(
number
);
Connectivity1D
connectivity
(
number
);
Mesh
<
Connectivity1D
>
mesh
(
connectivity
);
typedef
Mesh
<
Connectivity1D
>
MeshType
;
AcousticSolverWithMesh
<
Mesh
<
Connectivity1D
>>
acoustic_solver
(
mesh
);
typedef
MeshData
<
MeshType
>
MeshDataType
;
MeshType
mesh
(
connectivity
);
MeshDataType
mesh_data
(
mesh
);
AcousticSolverWithMesh
<
MeshDataType
>
acoustic_solver
(
mesh_data
);
method_cost_map
[
"AcousticSolverWithMesh"
]
=
timer
.
seconds
();
method_cost_map
[
"AcousticSolverWithMesh"
]
=
timer
.
seconds
();
}
}
...
...
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