Path: blob/main/src/meshes/face_interpolant.jl
2055 views
# By default, Julia/LLVM does not use fused multiply-add operations (FMAs).1# Since these FMAs can increase the performance of many numerical algorithms,2# we need to opt-in explicitly.3# See https://ranocha.de/blog/Optimizing_EC_Trixi for further details.4@muladd begin5#! format: noindent67# CurvedFace{RealT<:Real}8#9# Contains the data needed to represent a curved face with data points (x,y,z) as a Lagrange polynomial10# interpolant written in barycentric form at a given set of nodes.11struct CurvedFace{RealT <: Real}12nodes::Vector{RealT}13barycentric_weights::Vector{RealT}14coordinates::Array{RealT, 3} #[ndims, nnodes, nnodes]15end1617# evaluate the Gamma face interpolant at a particular point s = (s_1, s_2) and return the (x,y,z) coordinate18function evaluate_at(s, boundary_face::CurvedFace)19@unpack nodes, barycentric_weights, coordinates = boundary_face2021x_coordinate_at_s_on_boundary_face = lagrange_interpolation_2d(s, nodes,22view(coordinates, 1,23:, :),24barycentric_weights)25y_coordinate_at_s_on_boundary_face = lagrange_interpolation_2d(s, nodes,26view(coordinates, 2,27:, :),28barycentric_weights)29z_coordinate_at_s_on_boundary_face = lagrange_interpolation_2d(s, nodes,30view(coordinates, 3,31:, :),32barycentric_weights)3334return x_coordinate_at_s_on_boundary_face,35y_coordinate_at_s_on_boundary_face,36z_coordinate_at_s_on_boundary_face37end3839# Calculate a 2D Lagrange interpolating polynomial in barycentric 2 form40# of a function f(x,y) at a given coordinate (x,y) for a given node distribution.41function lagrange_interpolation_2d(x, nodes, function_values, barycentric_weights)42f_intermediate = zeros(eltype(function_values), length(nodes))43for j in eachindex(nodes)44f_intermediate[j] = lagrange_interpolation(x[2], nodes,45view(function_values, j, :),46barycentric_weights)47end48point_value = lagrange_interpolation(x[1], nodes, f_intermediate,49barycentric_weights)5051return point_value52end53end # @muladd545556