Size grids on connected volumes
Give two adjacent blocks different numbers of cells along their lengths and matching grids on their shared face. Set res(direction, patch) to the number of sample points. An axis with points has cells.
program sample_a_multipatch
use forcad, only: rk, nurbs_volume, nurbs_multipatch_volume
implicit none
type(nurbs_volume) :: left, right, member
type(nurbs_multipatch_volume) :: pair
integer :: a, b, i, counts(3,2)
call left%set_hexahedron(L=[2._rk,1._rk,1._rk], nc=[2,2,2])
right = left
call right%translate_Xc([2._rk,0._rk,0._rk])
call pair%add_patch(left, id=a)
call pair%add_patch(right, id=b)
call pair%connect(a, 'u_max', b, 'u_min', continuity=0)
if (.not. pair%is_valid()) error stop "Invalid interface"
counts(:,a) = [3,5,3]
counts(:,b) = [6,3,4]
call pair%create(res=counts, synchronize=.true.)
if (.not. pair%err%ok) error stop "Could not sample the assembly"
do i = 1, pair%get_npatch()
member = pair%get_patch(i)
print '(a,i0,a,3(1x,i0))', "Patch ", i, " samples:", member%get_ng()
end do
end program
| Member | Requested U × V × W | Result from get_ng() |
Hex cells |
|---|---|---|---|
| Left | 3 × 5 × 3 | 3 × 5 × 4 | 24 |
| Right | 6 × 3 × 4 | 6 × 5 × 4 | 60 |
The join is perpendicular to U. Synchronization takes the larger count in each corresponding face direction, so both sides have 5 × 4 face points while keeping their own U counts. The sampled points and cell indices belong to each member. A mesh consumer that needs shared node IDs must also merge matching interface nodes, as Studio’s conforming mesh generator does.
Use a target edge size
To size the same blocks in physical units, replace the call pair%create(...) line with:
call pair%create(target_size=0.5_rk, synchronize=.true.)
Each block now has 5 × 3 × 3 points, or 16 cells. For curved patches the estimate uses the lengths of the directional control polygons. Inspect the resulting grid when a specific physical edge length matters. Read the nodes and cells of a member.