Skip to content

Commit

Permalink
Add tensor fields for 2D, 3D
Browse files Browse the repository at this point in the history
  • Loading branch information
luraess committed Feb 11, 2024
1 parent bc5a8e2 commit 67cfdbd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Fields/Fields.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fields

export AbstractField, Field, VectorField
export AbstractField, Field, VectorField, TensorField
export ConstantField, ZeroField, OneField, ValueField
export FunctionField
export location, halo, interior, set!
Expand Down
16 changes: 16 additions & 0 deletions src/Fields/field.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,19 @@ function VectorField(backend::Backend, grid::StructuredGrid{N}, args...; kwargs.
end
return NamedTuple{names}(values)
end

# tensor fields
TensorField(backend::Backend, grid::StructuredGrid{2}, args...; kwargs...) = (
xx = Field(backend, grid, Center(), args...; kwargs...),
yy = Field(backend, grid, Center(), args...; kwargs...),
xy = Field(backend, grid, Vertex(), args...; kwargs...)
)

TensorField(backend::Backend, grid::StructuredGrid{3}, args...; kwargs...) = (
xx = Field(backend, grid, Center(), args...; kwargs...),
yy = Field(backend, grid, Center(), args...; kwargs...),
zz = Field(backend, grid, Center(), args...; kwargs...),
xy = Field(backend, grid, (Vertex(), Vertex(), Center()), args...; kwargs...),
xz = Field(backend, grid, (Vertex(), Center(), Vertex()), args...; kwargs...),
yz = Field(backend, grid, (Center(), Vertex(), Vertex()), args...; kwargs...)
)

0 comments on commit 67cfdbd

Please sign in to comment.