Skip to content

Commit

Permalink
Added boundary normal.
Browse files Browse the repository at this point in the history
  • Loading branch information
skang67 committed Feb 14, 2025
1 parent 3039fc7 commit 438d3a8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
7 changes: 5 additions & 2 deletions Source/EB/ERF_EBAux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,11 @@ define( int const& a_idim,
aux_bcent(i,j,k,2) = ( lo_areaBoun * (lo_centBoun[2]-0.5) + hi_areaBoun * (hi_centBoun[2]+0.5) ) / aux_barea(i,j,k); // z (mapped)
}

// aux_bnorm(i,j,k)

RealVect eb_normal = ( lo_areaBoun * lo_normal + hi_areaBoun * hi_normal )/ aux_barea(i,j,k);

aux_bnorm(i,j,k,0) = eb_normal[0];
aux_bnorm(i,j,k,1) = eb_normal[1];
aux_bnorm(i,j,k,2) = eb_normal[2];

}

Expand Down
9 changes: 9 additions & 0 deletions Source/EB/ERF_EBCutCell.H
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@ class eb_cut_cell_ {
return cent;
}

[[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
amrex::RealVect normBoun () const noexcept {
amrex::RealVect normal{0.,0.,0.};
if (m_flag.isSingleValued()){
normal = m_eb_normal;
}
return normal;
}

void debug ( int const a_face = -1 );

private:
Expand Down
14 changes: 7 additions & 7 deletions Source/EB/ERF_EBPolygon.H
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,10 @@ class polygon_ {
return amrex::Math::abs(x0.dotProduct(m_zdir));
}

// Calculate the centroid of the polygon.
// Centroid of the polygon based on the sub-triangulation
[[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
amrex::RealVect get_centroid ( ) const noexcept {
amrex::RealVect cent(0.);
// Original version: only valid for a triangle
// for ( int i(0); i<m_vertices; ++i) {
// cent += m_vertex[i];
// }
// return cent / static_cast<amrex::Real>(m_vertices);

if (m_vertices==3) {
cent = (m_vertex[0] + m_vertex[1] + m_vertex[2]) / 3.0;
} else {
Expand All @@ -162,6 +156,12 @@ class polygon_ {
return cent;
}

// Unit normal vector
[[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
amrex::RealVect normal () const noexcept {
return m_zdir;
}

#ifndef AMREX_USE_GPU
void report ( int const a_id, amrex::RealVect a_v0 )
#else
Expand Down

0 comments on commit 438d3a8

Please sign in to comment.