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
Commits
824035fe
Commit
824035fe
authored
Jun 2, 2020
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add edge list of ridges and associated references in 3D
parent
bf59a630
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!37
Feature/language
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mesh/CartesianMeshBuilder.cpp
+183
-127
183 additions, 127 deletions
src/mesh/CartesianMeshBuilder.cpp
src/mesh/CartesianMeshBuilder.hpp
+3
-0
3 additions, 0 deletions
src/mesh/CartesianMeshBuilder.hpp
with
186 additions
and
127 deletions
src/mesh/CartesianMeshBuilder.cpp
+
183
−
127
View file @
824035fe
...
...
@@ -128,6 +128,116 @@ CartesianMeshBuilder::_buildBoundaryNodeList(const TinyVector<3, uint64_t>& cell
}
}
template
<
size_t
Dimension
>
void
CartesianMeshBuilder
::
_buildBoundaryEdgeList
(
const
TinyVector
<
Dimension
,
uint64_t
>&
,
ConnectivityDescriptor
&
)
{
static_assert
(
Dimension
==
3
,
"unexpected dimension"
);
}
template
<
>
void
CartesianMeshBuilder
::
_buildBoundaryEdgeList
(
const
TinyVector
<
3
,
uint64_t
>&
cell_size
,
ConnectivityDescriptor
&
descriptor
)
{
using
Edge
=
ConnectivityFace
<
2
>
;
const
auto
&
node_number_vector
=
descriptor
.
node_number_vector
;
const
std
::
unordered_map
<
Edge
,
EdgeId
,
typename
Edge
::
Hash
>
edge_to_id_map
=
[
&
]
{
std
::
unordered_map
<
Edge
,
EdgeId
,
typename
Edge
::
Hash
>
edge_to_id_map
;
for
(
EdgeId
l
=
0
;
l
<
descriptor
.
edge_to_node_vector
.
size
();
++
l
)
{
const
auto
&
node_vector
=
descriptor
.
edge_to_node_vector
[
l
];
edge_to_id_map
[
Edge
(
node_vector
,
node_number_vector
)]
=
l
;
}
return
edge_to_id_map
;
}();
std
::
unordered_map
<
int
,
EdgeId
>
edge_number_id_map
=
[
&
]
{
std
::
unordered_map
<
int
,
EdgeId
>
edge_number_id_map
;
for
(
size_t
l
=
0
;
l
<
descriptor
.
edge_number_vector
.
size
();
++
l
)
{
edge_number_id_map
[
descriptor
.
edge_number_vector
[
l
]]
=
l
;
}
Assert
(
edge_number_id_map
.
size
()
==
descriptor
.
edge_number_vector
.
size
());
return
edge_number_id_map
;
}();
const
TinyVector
<
3
,
uint64_t
>
node_size
{
cell_size
[
0
]
+
1
,
cell_size
[
1
]
+
1
,
cell_size
[
2
]
+
1
};
const
auto
node_number
=
[
&
](
const
TinyVector
<
3
,
uint64_t
>&
node_logic_id
)
{
return
(
node_logic_id
[
0
]
*
node_size
[
1
]
+
node_logic_id
[
1
])
*
node_size
[
2
]
+
node_logic_id
[
2
];
};
{
// Ridge edges in direction of Z axis
const
auto
add_ref_item_list_along_z
=
[
&
](
const
size_t
i
,
const
size_t
j
,
const
unsigned
ref_id
,
const
std
::
string
&
ref_name
)
{
Array
<
EdgeId
>
boundary_edges
(
cell_size
[
2
]);
size_t
l
=
0
;
for
(
size_t
k
=
0
;
k
<
cell_size
[
2
];
++
k
)
{
const
uint32_t
node_0_id
=
node_number
(
TinyVector
<
3
,
uint64_t
>
{
i
,
j
,
k
});
const
uint32_t
node_1_id
=
node_number
(
TinyVector
<
3
,
uint64_t
>
{
i
,
j
,
k
+
1
});
auto
i_edge
=
edge_to_id_map
.
find
(
Edge
{{
node_0_id
,
node_1_id
},
descriptor
.
node_number_vector
});
Assert
(
i_edge
!=
edge_to_id_map
.
end
());
boundary_edges
[
l
++
]
=
i_edge
->
second
;
}
Assert
(
l
==
cell_size
[
2
]);
descriptor
.
addRefItemList
(
RefEdgeList
{
RefId
{
ref_id
,
ref_name
},
boundary_edges
});
};
add_ref_item_list_along_z
(
0
,
0
,
20
,
"XMINYMIN"
);
add_ref_item_list_along_z
(
0
,
cell_size
[
1
],
21
,
"XMINYMAX"
);
add_ref_item_list_along_z
(
cell_size
[
0
],
cell_size
[
1
],
22
,
"XMAXYMAX"
);
add_ref_item_list_along_z
(
cell_size
[
0
],
0
,
23
,
"XMAXYMIN"
);
}
{
// Ridge edges in direction of Y axis
const
auto
add_ref_item_list_along_y
=
[
&
](
const
size_t
i
,
const
size_t
k
,
const
unsigned
ref_id
,
const
std
::
string
&
ref_name
)
{
Array
<
EdgeId
>
boundary_edges
(
cell_size
[
1
]);
size_t
l
=
0
;
for
(
size_t
j
=
0
;
j
<
cell_size
[
1
];
++
j
)
{
const
uint32_t
node_0_id
=
node_number
(
TinyVector
<
3
,
uint64_t
>
{
i
,
j
,
k
});
const
uint32_t
node_1_id
=
node_number
(
TinyVector
<
3
,
uint64_t
>
{
i
,
j
+
1
,
k
});
auto
i_edge
=
edge_to_id_map
.
find
(
Edge
{{
node_0_id
,
node_1_id
},
descriptor
.
node_number_vector
});
Assert
(
i_edge
!=
edge_to_id_map
.
end
());
boundary_edges
[
l
++
]
=
i_edge
->
second
;
}
Assert
(
l
==
cell_size
[
1
]);
descriptor
.
addRefItemList
(
RefEdgeList
{
RefId
{
ref_id
,
ref_name
},
boundary_edges
});
};
add_ref_item_list_along_y
(
0
,
0
,
24
,
"XMINZMIN"
);
add_ref_item_list_along_y
(
0
,
cell_size
[
2
],
25
,
"XMINZMAX"
);
add_ref_item_list_along_y
(
cell_size
[
0
],
cell_size
[
2
],
26
,
"XMAXZMAX"
);
add_ref_item_list_along_y
(
cell_size
[
0
],
0
,
27
,
"XMAXZMIN"
);
}
{
// Ridge edges in direction of X axis
const
auto
add_ref_item_list_along_x
=
[
&
](
const
size_t
j
,
const
size_t
k
,
const
unsigned
ref_id
,
const
std
::
string
&
ref_name
)
{
Array
<
EdgeId
>
boundary_edges
(
cell_size
[
0
]);
size_t
l
=
0
;
for
(
size_t
i
=
0
;
i
<
cell_size
[
0
];
++
i
)
{
const
uint32_t
node_0_id
=
node_number
(
TinyVector
<
3
,
uint64_t
>
{
i
,
j
,
k
});
const
uint32_t
node_1_id
=
node_number
(
TinyVector
<
3
,
uint64_t
>
{
i
+
1
,
j
,
k
});
auto
i_edge
=
edge_to_id_map
.
find
(
Edge
{{
node_0_id
,
node_1_id
},
descriptor
.
node_number_vector
});
Assert
(
i_edge
!=
edge_to_id_map
.
end
());
boundary_edges
[
l
++
]
=
i_edge
->
second
;
}
Assert
(
l
==
cell_size
[
0
]);
descriptor
.
addRefItemList
(
RefEdgeList
{
RefId
{
ref_id
,
ref_name
},
boundary_edges
});
};
add_ref_item_list_along_x
(
0
,
0
,
28
,
"YMINZMIN"
);
add_ref_item_list_along_x
(
0
,
cell_size
[
2
],
29
,
"YMINZMAX"
);
add_ref_item_list_along_x
(
cell_size
[
1
],
cell_size
[
2
],
30
,
"YMAXZMAX"
);
add_ref_item_list_along_x
(
cell_size
[
1
],
0
,
31
,
"YMAXZMIN"
);
}
}
template
<
size_t
Dimension
>
void
CartesianMeshBuilder
::
_buildBoundaryFaceList
(
const
TinyVector
<
Dimension
,
uint64_t
>&
,
ConnectivityDescriptor
&
)
...
...
@@ -231,8 +341,8 @@ CartesianMeshBuilder::_buildBoundaryFaceList(const TinyVector<3, uint64_t>& cell
return
(
node_logic_id
[
0
]
*
node_size
[
1
]
+
node_logic_id
[
1
])
*
node_size
[
2
]
+
node_logic_id
[
2
];
};
{
//
xmin
const
size_t
i
=
0
;
{
//
faces orthogonal to X
const
auto
add_ref_item_list_for_x
=
[
&
](
const
size_t
i
,
const
unsigned
ref_id
,
const
std
::
string
&
ref_name
)
{
Array
<
FaceId
>
boundary_faces
(
cell_size
[
1
]
*
cell_size
[
2
]);
size_t
l
=
0
;
for
(
size_t
j
=
0
;
j
<
cell_size
[
1
];
++
j
)
{
...
...
@@ -250,33 +360,15 @@ CartesianMeshBuilder::_buildBoundaryFaceList(const TinyVector<3, uint64_t>& cell
}
}
Assert
(
l
==
cell_size
[
1
]
*
cell_size
[
2
]);
descriptor
.
addRefItemList
(
RefFaceList
{
RefId
{
0
,
"XMIN"
},
boundary_faces
});
}
{
// xmax
const
size_t
i
=
cell_size
[
0
]
-
1
;
Array
<
FaceId
>
boundary_faces
(
cell_size
[
1
]
*
cell_size
[
2
]);
size_t
l
=
0
;
for
(
size_t
j
=
0
;
j
<
cell_size
[
1
];
++
j
)
{
for
(
size_t
k
=
0
;
k
<
cell_size
[
2
];
++
k
)
{
const
uint32_t
node_0_id
=
node_number
(
TinyVector
<
3
,
uint64_t
>
{
i
+
1
,
j
,
k
});
const
uint32_t
node_1_id
=
node_number
(
TinyVector
<
3
,
uint64_t
>
{
i
+
1
,
j
+
1
,
k
});
const
uint32_t
node_2_id
=
node_number
(
TinyVector
<
3
,
uint64_t
>
{
i
+
1
,
j
+
1
,
k
+
1
});
const
uint32_t
node_3_id
=
node_number
(
TinyVector
<
3
,
uint64_t
>
{
i
+
1
,
j
,
k
+
1
});
auto
i_face
=
face_to_id_map
.
find
(
Face
{{
node_0_id
,
node_1_id
,
node_2_id
,
node_3_id
},
descriptor
.
node_number_vector
});
Assert
(
i_face
!=
face_to_id_map
.
end
());
descriptor
.
addRefItemList
(
RefFaceList
{
RefId
{
ref_id
,
ref_name
},
boundary_faces
});
};
boundary_faces
[
l
++
]
=
i_face
->
second
;
}
}
Assert
(
l
==
cell_size
[
1
]
*
cell_size
[
2
]);
descriptor
.
addRefItemList
(
RefFaceList
{
RefId
{
1
,
"XMAX"
},
boundary_faces
});
add_ref_item_list_for_x
(
0
,
0
,
"XMIN"
);
add_ref_item_list_for_x
(
cell_size
[
0
],
1
,
"XMAX"
);
}
{
//
ymin
const
size_t
j
=
0
;
{
//
faces orthogonal to Y
const
auto
add_ref_item_list_for_y
=
[
&
](
const
size_t
j
,
const
unsigned
ref_id
,
const
std
::
string
&
ref_name
)
{
Array
<
FaceId
>
boundary_faces
(
cell_size
[
0
]
*
cell_size
[
2
]);
size_t
l
=
0
;
for
(
size_t
i
=
0
;
i
<
cell_size
[
0
];
++
i
)
{
...
...
@@ -294,34 +386,15 @@ CartesianMeshBuilder::_buildBoundaryFaceList(const TinyVector<3, uint64_t>& cell
}
}
Assert
(
l
==
cell_size
[
0
]
*
cell_size
[
2
]);
descriptor
.
addRefItemList
(
RefFaceList
{
RefId
{
2
,
"YMIN"
},
boundary_faces
});
}
{
// ymax
const
size_t
j
=
cell_size
[
1
]
-
1
;
Array
<
FaceId
>
boundary_faces
(
cell_size
[
0
]
*
cell_size
[
2
]);
size_t
l
=
0
;
for
(
size_t
i
=
0
;
i
<
cell_size
[
0
];
++
i
)
{
for
(
size_t
k
=
0
;
k
<
cell_size
[
2
];
++
k
)
{
const
uint32_t
node_0_id
=
node_number
(
TinyVector
<
3
,
uint64_t
>
{
i
,
j
+
1
,
k
});
const
uint32_t
node_1_id
=
node_number
(
TinyVector
<
3
,
uint64_t
>
{
i
+
1
,
j
+
1
,
k
});
const
uint32_t
node_2_id
=
node_number
(
TinyVector
<
3
,
uint64_t
>
{
i
+
1
,
j
+
1
,
k
+
1
});
const
uint32_t
node_3_id
=
node_number
(
TinyVector
<
3
,
uint64_t
>
{
i
,
j
+
1
,
k
+
1
});
auto
i_face
=
face_to_id_map
.
find
(
Face
{{
node_0_id
,
node_1_id
,
node_2_id
,
node_3_id
},
descriptor
.
node_number_vector
});
Assert
(
i_face
!=
face_to_id_map
.
end
());
descriptor
.
addRefItemList
(
RefFaceList
{
RefId
{
ref_id
,
ref_name
},
boundary_faces
});
};
boundary_faces
[
l
++
]
=
i_face
->
second
;
}
}
Assert
(
l
==
cell_size
[
0
]
*
cell_size
[
2
]);
descriptor
.
addRefItemList
(
RefFaceList
{
RefId
{
3
,
"YMAX"
},
boundary_faces
});
add_ref_item_list_for_y
(
0
,
2
,
"YMIN"
);
add_ref_item_list_for_y
(
cell_size
[
1
],
3
,
"YMAX"
);
}
{
//
zmin
const
size_t
k
=
0
;
{
//
faces orthogonal to Z
const
auto
add_ref_item_list_for_z
=
[
&
](
const
size_t
k
,
const
unsigned
ref_id
,
const
std
::
string
&
ref_name
)
{
Array
<
FaceId
>
boundary_faces
(
cell_size
[
0
]
*
cell_size
[
1
]);
size_t
l
=
0
;
for
(
size_t
i
=
0
;
i
<
cell_size
[
0
];
++
i
)
{
...
...
@@ -339,29 +412,11 @@ CartesianMeshBuilder::_buildBoundaryFaceList(const TinyVector<3, uint64_t>& cell
}
}
Assert
(
l
==
cell_size
[
0
]
*
cell_size
[
1
]);
descriptor
.
addRefItemList
(
RefFaceList
{
RefId
{
4
,
"ZMIN"
},
boundary_faces
});
}
{
// zmax
const
size_t
k
=
cell_size
[
2
]
-
1
;
Array
<
FaceId
>
boundary_faces
(
cell_size
[
0
]
*
cell_size
[
1
]);
size_t
l
=
0
;
for
(
size_t
i
=
0
;
i
<
cell_size
[
0
];
++
i
)
{
for
(
size_t
j
=
0
;
j
<
cell_size
[
1
];
++
j
)
{
const
uint32_t
node_0_id
=
node_number
(
TinyVector
<
3
,
uint64_t
>
{
i
,
j
,
k
+
1
});
const
uint32_t
node_1_id
=
node_number
(
TinyVector
<
3
,
uint64_t
>
{
i
+
1
,
j
,
k
+
1
});
const
uint32_t
node_2_id
=
node_number
(
TinyVector
<
3
,
uint64_t
>
{
i
+
1
,
j
+
1
,
k
+
1
});
const
uint32_t
node_3_id
=
node_number
(
TinyVector
<
3
,
uint64_t
>
{
i
,
j
+
1
,
k
+
1
});
auto
i_face
=
face_to_id_map
.
find
(
Face
{{
node_0_id
,
node_1_id
,
node_2_id
,
node_3_id
},
descriptor
.
node_number_vector
});
Assert
(
i_face
!=
face_to_id_map
.
end
());
descriptor
.
addRefItemList
(
RefFaceList
{
RefId
{
ref_id
,
ref_name
},
boundary_faces
});
};
boundary_faces
[
l
++
]
=
i_face
->
second
;
}
}
Assert
(
l
==
cell_size
[
0
]
*
cell_size
[
1
]);
descriptor
.
addRefItemList
(
RefFaceList
{
RefId
{
5
,
"ZMAX"
},
boundary_faces
});
add_ref_item_list_for_z
(
0
,
4
,
"ZMIN"
);
add_ref_item_list_for_z
(
cell_size
[
2
],
5
,
"ZMAX"
);
}
}
...
...
@@ -593,6 +648,7 @@ CartesianMeshBuilder::_buildCartesianMesh(const TinyVector<3>& a,
MeshBuilderBase
::
_computeFaceEdgeAndEdgeNodeAndCellEdgeConnectivities
<
Dimension
>
(
descriptor
);
this
->
_buildBoundaryNodeList
(
cell_size
,
descriptor
);
this
->
_buildBoundaryEdgeList
(
cell_size
,
descriptor
);
this
->
_buildBoundaryFaceList
(
cell_size
,
descriptor
);
descriptor
.
cell_owner_vector
.
resize
(
number_of_cells
);
...
...
This diff is collapsed.
Click to expand it.
src/mesh/CartesianMeshBuilder.hpp
+
3
−
0
View file @
824035fe
...
...
@@ -13,6 +13,9 @@ class CartesianMeshBuilder : public MeshBuilderBase
template
<
size_t
Dimension
>
void
_buildBoundaryNodeList
(
const
TinyVector
<
Dimension
,
uint64_t
>&
cell_size
,
ConnectivityDescriptor
&
descriptor
);
template
<
size_t
Dimension
>
void
_buildBoundaryEdgeList
(
const
TinyVector
<
Dimension
,
uint64_t
>&
cell_size
,
ConnectivityDescriptor
&
descriptor
);
template
<
size_t
Dimension
>
void
_buildBoundaryFaceList
(
const
TinyVector
<
Dimension
,
uint64_t
>&
cell_size
,
ConnectivityDescriptor
&
descriptor
);
...
...
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