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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Merge requests
!47
Feature/mass center
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
Feature/mass center
feature/mass-center
into
develop
Overview
0
Commits
2
Pipelines
0
Changes
1
Merged
Feature/mass center
Stéphane Del Pino
requested to merge
feature/mass-center
into
develop
Aug 4, 2020
Overview
0
Commits
2
Pipelines
0
Changes
1
0
0
Merge request reports
Viewing commit
8285983f
Prev
Next
Show latest version
1 file
+
48
−
3
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
8285983f
Add centroid calculation in 3d
· 8285983f
Stéphane Del Pino
authored
Aug 4, 2020
src/mesh/MeshData.hpp
+
48
−
3
View file @ 8285983f
Edit in single-file editor
Open in Web IDE
Show full file
@@ -155,7 +155,7 @@ class MeshData : public IMeshData
PUGS_INLINE
void
_computeCellCentroid
()
{
// Computes vertices isobarycenter
{
const
CellValue
<
const
Rd
>
cell_iso_barycenter
=
this
->
cellIsoBarycenter
();
if
constexpr
(
Dimension
==
1
)
{
m_cell_centroid
=
cell_iso_barycenter
;
@@ -190,8 +190,53 @@ class MeshData : public IMeshData
});
m_cell_centroid
=
cell_centroid
;
}
else
{
std
::
cout
<<
rang
::
fgB
::
yellow
<<
"Centroids are not computed correctly in 3d"
<<
rang
::
style
::
reset
<<
'\n'
;
m_cell_centroid
=
cell_iso_barycenter
;
const
auto
&
face_center
=
this
->
xl
();
const
CellValue
<
const
double
>
Vj
=
this
->
Vj
();
const
NodeValue
<
const
Rd
>&
xr
=
m_mesh
.
xr
();
const
auto
&
cell_to_face_matrix
=
m_mesh
.
connectivity
().
cellToFaceMatrix
();
const
auto
&
face_to_node_matrix
=
m_mesh
.
connectivity
().
faceToNodeMatrix
();
const
auto
&
cell_face_is_reversed
=
m_mesh
.
connectivity
().
cellFaceIsReversed
();
CellValue
<
Rd
>
cell_centroid
{
m_mesh
.
connectivity
()};
parallel_for
(
m_mesh
.
numberOfCells
(),
PUGS_LAMBDA
(
CellId
j
)
{
const
Rd
xj
=
m_cell_iso_barycenter
[
j
];
const
auto
&
cell_faces
=
cell_to_face_matrix
[
j
];
Rd
sum
=
zero
;
for
(
size_t
i_face
=
0
;
i_face
<
cell_faces
.
size
();
++
i_face
)
{
const
FaceId
face_id
=
cell_faces
[
i_face
];
const
Rd
xl
=
face_center
[
face_id
];
const
Rd
xjxl
=
xl
-
xj
;
const
auto
&
face_nodes
=
face_to_node_matrix
[
face_id
];
const
Rd
xl_plus_xj
=
xl
+
xj
;
double
sign
=
(
cell_face_is_reversed
(
j
,
i_face
))
?
-
1
:
1
;
for
(
size_t
i_face_node
=
0
;
i_face_node
<
face_nodes
.
size
();
++
i_face_node
)
{
const
Rd
&
xr0
=
xr
[
face_nodes
[
i_face_node
]];
const
Rd
&
xr1
=
xr
[
face_nodes
[(
i_face_node
+
1
)
%
face_nodes
.
size
()]];
const
Rd
xjxr0
=
xr0
-
xj
;
const
Rd
xjxr1
=
xr1
-
xj
;
const
double
Vjlr
=
(
crossProduct
(
xjxr0
,
xjxr1
),
xjxl
);
sum
+=
(
sign
*
Vjlr
)
*
(
xl_plus_xj
+
xr0
+
xr1
);
}
}
sum
*=
1
/
(
24
*
Vj
[
j
]);
cell_centroid
[
j
]
=
sum
;
});
m_cell_centroid
=
cell_centroid
;
}
}
}
Loading