example_nurbs_volume Program

Uses

  • program~~example_nurbs_volume~~UsesGraph program~example_nurbs_volume example_nurbs_volume module~forcad forcad program~example_nurbs_volume->module~forcad module~forcad_nurbs_curve forcad_nurbs_curve module~forcad->module~forcad_nurbs_curve module~forcad_nurbs_surface forcad_nurbs_surface module~forcad->module~forcad_nurbs_surface module~forcad_nurbs_volume forcad_nurbs_volume module~forcad->module~forcad_nurbs_volume module~forcad_utils forcad_utils module~forcad->module~forcad_utils module~forcad_nurbs_curve->module~forcad_utils module~forcad_nurbs_surface->module~forcad_utils module~forcad_nurbs_volume->module~forcad_utils stdlib_quadrature stdlib_quadrature module~forcad_utils->stdlib_quadrature

This program demonstrates the usage of a NURBS volume object to create, and finalize a NURBS volume. It sets up control points and weights, generates the volume, and exports the control points and the volume to VTK files at various stages.

Define control points for the NURBS volume

Define weights for the control points

Set control points and weights for the NURBS volume object

Deallocate local arrays

Export initial control points to a VTK file

Generate the NURBS volume with a resolution of 15X15X15

Export the generated volume to a VTK file

Show the control geometry and geometry using PyVista

Finalize the NURBS volume object


Calls

program~~example_nurbs_volume~~CallsGraph program~example_nurbs_volume example_nurbs_volume none~set nurbs_volume%set program~example_nurbs_volume->none~set proc~create nurbs_volume%create program~example_nurbs_volume->proc~create proc~export_xc nurbs_volume%export_Xc program~example_nurbs_volume->proc~export_xc proc~export_xg nurbs_volume%export_Xg program~example_nurbs_volume->proc~export_xg proc~finalize nurbs_volume%finalize program~example_nurbs_volume->proc~finalize proc~generate_xc generate_Xc program~example_nurbs_volume->proc~generate_xc proc~show nurbs_volume%show program~example_nurbs_volume->proc~show proc~set1 nurbs_volume%set1 none~set->proc~set1 proc~set2 nurbs_volume%set2 none~set->proc~set2 proc~set3 nurbs_volume%set3 none~set->proc~set3 proc~set4 nurbs_volume%set4 none~set->proc~set4 interface~compute_xg compute_Xg proc~create->interface~compute_xg interface~ndgrid ndgrid proc~create->interface~ndgrid proc~is_rational nurbs_volume%is_rational proc~create->proc~is_rational proc~cmp_elem_xc_vis nurbs_volume%cmp_elem_Xc_vis proc~export_xc->proc~cmp_elem_xc_vis proc~cmp_elem_xg_vis nurbs_volume%cmp_elem_Xg_vis proc~export_xg->proc~cmp_elem_xg_vis proc~ndgrid2 ndgrid2 interface~ndgrid->proc~ndgrid2 proc~ndgrid3 ndgrid3 interface~ndgrid->proc~ndgrid3 interface~elemconn_c0 elemConn_C0 proc~cmp_elem_xc_vis->interface~elemconn_c0 proc~cmp_elem_xg_vis->interface~elemconn_c0 proc~cmp_degree nurbs_volume%cmp_degree proc~set1->proc~cmp_degree proc~cmp_nc nurbs_volume%cmp_nc proc~set1->proc~cmp_nc proc~set2->proc~cmp_nc proc~compute_knot_vector compute_knot_vector proc~set2->proc~compute_knot_vector proc~set3->proc~cmp_degree proc~cmp_elemconn_c0_l cmp_elemConn_C0_L interface~elemconn_c0->proc~cmp_elemconn_c0_l proc~cmp_elemconn_c0_s cmp_elemConn_C0_S interface~elemconn_c0->proc~cmp_elemconn_c0_s proc~cmp_elemconn_c0_v cmp_elemConn_C0_V interface~elemconn_c0->proc~cmp_elemconn_c0_v proc~get_multiplicity nurbs_volume%get_multiplicity proc~cmp_degree->proc~get_multiplicity interface~compute_multiplicity compute_multiplicity proc~cmp_nc->interface~compute_multiplicity proc~repelem repelem proc~compute_knot_vector->proc~repelem proc~compute_multiplicity1 compute_multiplicity1 interface~compute_multiplicity->proc~compute_multiplicity1 proc~compute_multiplicity2 compute_multiplicity2 interface~compute_multiplicity->proc~compute_multiplicity2 proc~get_multiplicity->interface~compute_multiplicity

Variables

Type Attributes Name Initial
real(kind=rk), allocatable :: Wc(:)

Arrays for control points and weights

real(kind=rk), allocatable :: Xc(:,:)

Arrays for control points and weights

type(nurbs_volume) :: nurbs

Declare a NURBS volume object


Functions

function generate_Xc(L) result(control_points)

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: L

Return Value real(kind=rk), allocatable, (:,:)


Source Code

program example_nurbs_volume

    use forcad, only: rk, nurbs_volume

    implicit none
    type(nurbs_volume) :: nurbs              !! Declare a NURBS volume object
    real(rk), allocatable :: Xc(:,:), Wc(:)  !! Arrays for control points and weights

    !-----------------------------------------------------------------------------
    ! Setting up the NURBS volume
    !-----------------------------------------------------------------------------

    !> Define control points for the NURBS volume
    Xc = generate_Xc(1.0_rk)

    !> Define weights for the control points
    allocate(Wc(size(Xc, 1)), source=1.0_rk)

    !> Set control points and weights for the NURBS volume object
    call nurbs%set([2,2,2], Xc, Wc)

    !> Deallocate local arrays
    deallocate(Xc, Wc)

    !> Export initial control points to a VTK file
    call nurbs%export_Xc('vtk/demo_volume_Xc.vtk')

    !-----------------------------------------------------------------------------
    ! Creating the NURBS volume
    !-----------------------------------------------------------------------------

    !> Generate the NURBS volume with a resolution of 15X15X15
    call nurbs%create(15, 15, 15)

    !> Export the generated volume to a VTK file
    call nurbs%export_Xg('vtk/demo_volume_Xg.vtk')

    !-----------------------------------------------------------------------------
    ! Visualization using PyVista
    ! Note: PyVista is required for visualization. Install it using `pip install pyvista`
    !-----------------------------------------------------------------------------

    !> Show the control geometry and geometry using PyVista
    call nurbs%show('vtk/demo_volume_Xc.vtk','vtk/demo_volume_Xg.vtk')

    !-----------------------------------------------------------------------------
    ! Finalizing
    !-----------------------------------------------------------------------------

    !> Finalize the NURBS volume object
    call nurbs%finalize()

contains

    !-----------------------------------------------------------------------------
    function generate_Xc(L) result(control_points)
        implicit none
        real(rk), intent(in) :: L
        real(rk), allocatable :: control_points(:,:)
        real(rk) :: L2
        L2 = L / 2.0_rk
        allocate(control_points(8, 3))
        control_points(1,:) = [ L2, -L2,  L2]
        control_points(2,:) = [ L2, -L2, -L2]
        control_points(3,:) = [-L2, -L2,  L2]
        control_points(4,:) = [-L2, -L2, -L2]
        control_points(5,:) = [ L2,  L2,  L2]
        control_points(6,:) = [ L2,  L2, -L2]
        control_points(7,:) = [-L2,  L2,  L2]
        control_points(8,:) = [-L2,  L2, -L2]
    end function
    !-----------------------------------------------------------------------------

end program example_nurbs_volume