Source code for buffalo_panel.views.internal.line_source_2d

"""
Diagnostic views for a line source element.

This module contains the diagnostic views for one panel of various line source
element types.
"""

from dataclasses import dataclass, field

import numpy as np

from buffalo_panel.basis.descriptors import LINE_CONSTANT, LINE_POINT
from buffalo_panel.families.dof_maps import PerElementDofMap
from buffalo_panel.families.element_family import ElementFamily
from buffalo_panel.geometry.line2d import (
    LinePanelGeometry2D,
    PointElementLineGeometry2D,
)
from buffalo_panel.geometry.supports import LINE_2D
from buffalo_panel.kernels.internal.line_source_constant_2d import (
    LineSourceConstant2D,
)
from buffalo_panel.kernels.internal.line_source_point_2d import (
    LineSourcePoint2D,
)
from buffalo_panel.singularities.descriptors import SOURCE
from buffalo_panel.views.internal.line_family_2d import LineFamily2DView


def make_diagnostic_line_source_point_family() -> ElementFamily:
    """Create diagnostic point source family for one panel."""
    return ElementFamily(
        name="diagnostic_point_source_panel",
        support=LINE_2D,
        singularity=SOURCE,
        basis=LINE_POINT,
        n_elements=1,
        panel_indices=np.array([0], dtype=np.int32),
        dof_map=PerElementDofMap(
            global_indices=np.array([0], dtype=np.int32),
        ),
    )


[docs] @dataclass(frozen=True, slots=True) class LineSourcePoint2DView(LineFamily2DView[PointElementLineGeometry2D]): """ Field view for one point source line panel. The view evaluates the velocity, potential, and stream-function contribution from one geometry panel whose source coefficient is concentrated at the panel point. """ kernel: LineSourcePoint2D = field( default_factory=LineSourcePoint2D, repr=False, compare=False, init=False, ) """Kernel used to evaluate unit point source influence values.""" family: ElementFamily = field( default_factory=make_diagnostic_line_source_point_family, repr=False, compare=False, init=False, ) """Element family defining panel ownership and local coefficient layout."""
def make_diagnostic_line_source_constant_family() -> ElementFamily: """Create diagnostic constant strength line source family.""" return ElementFamily( name="diagnostic_source_panel", support=LINE_2D, singularity=SOURCE, basis=LINE_CONSTANT, n_elements=1, panel_indices=np.array([0], dtype=np.int32), dof_map=PerElementDofMap( global_indices=np.array([0], dtype=np.int32), ), )
[docs] @dataclass(frozen=True, slots=True) class LineSourceConstant2DView(LineFamily2DView[LinePanelGeometry2D]): """ Field view for one constant-strength source line panel. The view evaluates the velocity, potential, and stream-function contribution from one geometry panel with one source strength. It is intended for diagnostics, visualization, and kernel-level demonstrations rather than solver assembly. """ kernel: LineSourceConstant2D = field( default_factory=LineSourceConstant2D, repr=False, compare=False, init=False, ) """Kernel used to evaluate unit constant-source influence values.""" family: ElementFamily = field( default_factory=make_diagnostic_line_source_constant_family, repr=False, compare=False, init=False, ) """Element family defining panel ownership and local coefficient layout."""