粒子軌道セグメントと三角形要素の交差判定を提供する衝突検出モジュール。
線分のAABBと要素AABBの重なりを先に判定し、詳細交差計算を枝刈りする。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | p0(3) | |||
| real(kind=dp), | intent(in) | :: | p1(3) | |||
| real(kind=dp), | intent(in) | :: | bb_min(3) | |||
| real(kind=dp), | intent(in) | :: | bb_max(3) |
事前計算済みの線分AABBと要素AABBの重なりを判定する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | seg_min(3) | |||
| real(kind=dp), | intent(in) | :: | seg_max(3) | |||
| real(kind=dp), | intent(in) | :: | bb_min(3) | |||
| real(kind=dp), | intent(in) | :: | bb_max(3) |
座標をグリッドセル添字へ変換し、範囲外は端セルへ丸める。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_type), | intent(in) | :: | mesh | |||
| real(kind=dp), | intent(in) | :: | x | |||
| integer(kind=i32), | intent(in) | :: | axis |
3次元セル添字 (ix,iy,iz) をCSR一次元インデックスへ変換する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=i32), | intent(in) | :: | ix | |||
| integer(kind=i32), | intent(in) | :: | iy | |||
| integer(kind=i32), | intent(in) | :: | iz | |||
| integer(kind=i32), | intent(in) | :: | nx | |||
| integer(kind=i32), | intent(in) | :: | ny |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | p(3) | |||
| real(kind=dp), | intent(in) | :: | box_min(3) | |||
| real(kind=dp), | intent(in) | :: | box_max(3) | |||
| real(kind=dp), | intent(in) | :: | tol |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | p(3) | |||
| real(kind=dp), | intent(in) | :: | box_min(3) | |||
| real(kind=dp), | intent(in) | :: | box_max(3) | |||
| real(kind=dp), | intent(in) | :: | tol | |||
| integer(kind=i32), | intent(in) | :: | periodic_axes(2) | |||
| logical, | intent(in) | :: | require_half_open |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | bb_min(3) | |||
| real(kind=dp), | intent(in) | :: | bb_max(3) | |||
| real(kind=dp), | intent(in) | :: | box_min(3) | |||
| real(kind=dp), | intent(in) | :: | box_max(3) | |||
| real(kind=dp), | intent(in) | :: | tol |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | a(3) | |||
| real(kind=dp), | intent(in) | :: | b(3) |
候補 hit が現在の best より優先されるかを deterministic に判定する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | t | |||
| integer(kind=i32), | intent(in) | :: | elem_idx | |||
| integer(kind=i32), | intent(in) | :: | image_shift(2) | |||
| type(hit_info), | intent(in) | :: | best_hit |
線分 [p0,p1] に対して最初に衝突する三角形要素を探索し、命中情報を返す。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_type), | intent(in) | :: | mesh |
三角形要素とAABB情報を保持した衝突判定対象メッシュ。 |
||
| real(kind=dp), | intent(in) | :: | p0(3) | |||
| real(kind=dp), | intent(in) | :: | p1(3) | |||
| type(hit_info), | intent(out) | :: | hit |
最初に命中した要素インデックス・命中位置・線分パラメータを格納。 |
||
| type(sim_config), | intent(in), | optional | :: | sim | ||
| real(kind=dp), | intent(in), | optional | :: | box_min(3) | ||
| real(kind=dp), | intent(in), | optional | :: | box_max(3) | ||
| logical, | intent(in), | optional | :: | require_elem_inside |
通常メッシュに対する最初の命中要素探索を行う。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_type), | intent(in) | :: | mesh | |||
| real(kind=dp), | intent(in) | :: | p0(3) | |||
| real(kind=dp), | intent(in) | :: | p1(3) | |||
| type(hit_info), | intent(out) | :: | hit | |||
| real(kind=dp), | intent(in), | optional | :: | box_min(3) | ||
| real(kind=dp), | intent(in), | optional | :: | box_max(3) | ||
| logical, | intent(in), | optional | :: | require_elem_inside |
periodic2 用に image shift を列挙し、base collision の結果を統合する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_type), | intent(in) | :: | mesh | |||
| real(kind=dp), | intent(in) | :: | p0(3) | |||
| real(kind=dp), | intent(in) | :: | p1(3) | |||
| type(hit_info), | intent(out) | :: | hit | |||
| type(sim_config), | intent(in) | :: | sim | |||
| real(kind=dp), | intent(in), | optional | :: | box_min(3) | ||
| real(kind=dp), | intent(in), | optional | :: | box_max(3) | ||
| logical, | intent(in), | optional | :: | require_elem_inside |
旧実装と同じ線形探索で最初の命中要素を探索する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_type), | intent(in) | :: | mesh | |||
| real(kind=dp), | intent(in) | :: | p0(3) | |||
| real(kind=dp), | intent(in) | :: | p1(3) | |||
| real(kind=dp), | intent(in) | :: | seg_min(3) | |||
| real(kind=dp), | intent(in) | :: | seg_max(3) | |||
| type(hit_info), | intent(inout) | :: | hit | |||
| real(kind=dp), | intent(inout) | :: | best_t | |||
| logical, | intent(in) | :: | use_box_filter | |||
| real(kind=dp), | intent(in) | :: | box_min(3) | |||
| real(kind=dp), | intent(in) | :: | box_max(3) | |||
| real(kind=dp), | intent(in) | :: | box_tol | |||
| logical, | intent(in) | :: | require_elem_inside |
一様グリッド + 3D-DDA で候補セルのみ探索し、最初の命中要素を返す。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_type), | intent(in) | :: | mesh | |||
| real(kind=dp), | intent(in) | :: | p0(3) | |||
| real(kind=dp), | intent(in) | :: | p1(3) | |||
| real(kind=dp), | intent(in) | :: | d(3) | |||
| real(kind=dp), | intent(in) | :: | seg_min(3) | |||
| real(kind=dp), | intent(in) | :: | seg_max(3) | |||
| type(hit_info), | intent(inout) | :: | hit | |||
| real(kind=dp), | intent(inout) | :: | best_t | |||
| logical, | intent(in) | :: | use_box_filter | |||
| real(kind=dp), | intent(in) | :: | box_min(3) | |||
| real(kind=dp), | intent(in) | :: | box_max(3) | |||
| real(kind=dp), | intent(in) | :: | box_tol | |||
| logical, | intent(in) | :: | require_elem_inside |
線分 p(t)=p0+t*d (0<=t<=1) とAABBの交差区間 [t_entry,t_exit] を返す。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | p0(3) | |||
| real(kind=dp), | intent(in) | :: | d(3) | |||
| real(kind=dp), | intent(in) | :: | bb_min(3) | |||
| real(kind=dp), | intent(in) | :: | bb_max(3) | |||
| logical, | intent(out) | :: | ok | |||
| real(kind=dp), | intent(out) | :: | t_entry | |||
| real(kind=dp), | intent(out) | :: | t_exit |
Möller–Trumbore法で線分と三角形の交差有無・線分パラメータ t・交点座標を計算する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | p0(3) | |||
| real(kind=dp), | intent(in) | :: | p1(3) | |||
| real(kind=dp), | intent(in) | :: | v0(3) | |||
| real(kind=dp), | intent(in) | :: | v1(3) | |||
| real(kind=dp), | intent(in) | :: | v2(3) | |||
| logical, | intent(out) | :: | ok |
線分と三角形が交差した場合に |
||
| real(kind=dp), | intent(out) | :: | t |
交点の線分内パラメータ( |
||
| real(kind=dp), | intent(out) | :: | h(3) |
交点の線分内パラメータ( |
hit 構造体を未命中状態へ初期化する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(hit_info), | intent(out) | :: | hit |
box filter 関連の optional 引数を検証付きで展開する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in), | optional | :: | box_min(3) | ||
| real(kind=dp), | intent(in), | optional | :: | box_max(3) | ||
| logical, | intent(in), | optional | :: | require_elem_inside | ||
| logical, | intent(out) | :: | use_box_filter | |||
| real(kind=dp), | intent(out) | :: | box_min_local(3) | |||
| real(kind=dp), | intent(out) | :: | box_max_local(3) | |||
| real(kind=dp), | intent(out) | :: | box_tol | |||
| logical, | intent(out) | :: | require_inside_elem |
periodic2 collision で必要な 2 軸周期設定を解決する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(sim_config), | intent(in) | :: | sim | |||
| logical, | intent(out) | :: | use_periodic2 | |||
| integer(kind=i32), | intent(out) | :: | periodic_axes(2) | |||
| real(kind=dp), | intent(out) | :: | periodic_len(2) |
線分 AABB と canonical mesh AABB の重なりから必要な image shift 範囲を決める。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_type), | intent(in) | :: | mesh | |||
| real(kind=dp), | intent(in) | :: | p0(3) | |||
| real(kind=dp), | intent(in) | :: | p1(3) | |||
| integer(kind=i32), | intent(in) | :: | axis | |||
| real(kind=dp), | intent(in) | :: | period_len | |||
| integer(kind=i32), | intent(out) | :: | nmin | |||
| integer(kind=i32), | intent(out) | :: | nmax |
point を primary cell へ折り返す。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(inout) | :: | point(3) | |||
| real(kind=dp), | intent(in) | :: | box_min(3) | |||
| integer(kind=i32), | intent(in) | :: | periodic_axes(2) | |||
| real(kind=dp), | intent(in) | :: | periodic_len(2) |