svalinn / r2s-act

Rigorous 2 Step Activation Workflow
4 stars 7 forks source link

Sampling of hexahedra (especially in mixed hex/tet mesh) #46

Closed erelson closed 11 years ago

erelson commented 11 years ago

I have been taking the approach of supporting mixed tet/hex meshes (i.e. for #3). After not identifying any methods for sampling general hexahedra, I believe the best approach is therefore to assume any given hexahedron is a parallelepiped (and probably a right angle-only parallelepiped...).

Sampling a parallelepiped is a straightforward algorithm. For points a through h, with MOAB's vertice ordering:

        ! Get 3 edge vectors that begin at point 'a'
        v1 = rand() * (b - a)
        v2 = rand() * (e - a)
        v3 = rand() * (d - a)

        ! Sample random point within the voxel
        xxx = a(1) + v1(1) + v2(1) + v3(1)
        yyy = a(2) + v1(2) + v2(2) + v3(2)
        zzz = a(3) + v1(3) + v2(3) + v3(3)

Where a(1)=a_x, a(2)=a_y, etc.

erelson commented 11 years ago

This has been implemented. See sample_hexahedra() in mcnp_source/sample_moab.F90 for implemented code.

gonuke commented 11 years ago

This is a useful capability but probably not general enough for real hexahedron sampling. In general, for an unstructured mesh, I would assume the opposite - that a hexahedron is not a parallelepiped. The methods for sampling this would derive from finite element discretizations, but may not be well-developed in the literature.