Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/src/meshes/face_interpolant.jl
2055 views
1
# By default, Julia/LLVM does not use fused multiply-add operations (FMAs).
2
# Since these FMAs can increase the performance of many numerical algorithms,
3
# we need to opt-in explicitly.
4
# See https://ranocha.de/blog/Optimizing_EC_Trixi for further details.
5
@muladd begin
6
#! format: noindent
7
8
# CurvedFace{RealT<:Real}
9
#
10
# Contains the data needed to represent a curved face with data points (x,y,z) as a Lagrange polynomial
11
# interpolant written in barycentric form at a given set of nodes.
12
struct CurvedFace{RealT <: Real}
13
nodes::Vector{RealT}
14
barycentric_weights::Vector{RealT}
15
coordinates::Array{RealT, 3} #[ndims, nnodes, nnodes]
16
end
17
18
# evaluate the Gamma face interpolant at a particular point s = (s_1, s_2) and return the (x,y,z) coordinate
19
function evaluate_at(s, boundary_face::CurvedFace)
20
@unpack nodes, barycentric_weights, coordinates = boundary_face
21
22
x_coordinate_at_s_on_boundary_face = lagrange_interpolation_2d(s, nodes,
23
view(coordinates, 1,
24
:, :),
25
barycentric_weights)
26
y_coordinate_at_s_on_boundary_face = lagrange_interpolation_2d(s, nodes,
27
view(coordinates, 2,
28
:, :),
29
barycentric_weights)
30
z_coordinate_at_s_on_boundary_face = lagrange_interpolation_2d(s, nodes,
31
view(coordinates, 3,
32
:, :),
33
barycentric_weights)
34
35
return x_coordinate_at_s_on_boundary_face,
36
y_coordinate_at_s_on_boundary_face,
37
z_coordinate_at_s_on_boundary_face
38
end
39
40
# Calculate a 2D Lagrange interpolating polynomial in barycentric 2 form
41
# of a function f(x,y) at a given coordinate (x,y) for a given node distribution.
42
function lagrange_interpolation_2d(x, nodes, function_values, barycentric_weights)
43
f_intermediate = zeros(eltype(function_values), length(nodes))
44
for j in eachindex(nodes)
45
f_intermediate[j] = lagrange_interpolation(x[2], nodes,
46
view(function_values, j, :),
47
barycentric_weights)
48
end
49
point_value = lagrange_interpolation(x[1], nodes, f_intermediate,
50
barycentric_weights)
51
52
return point_value
53
end
54
end # @muladd
55
56