仕組み
A textbook figure of a 2D potential flow. A source of strength Q pushes fluid outward at Q / 2πr and an equal sink pulls it in; the velocity anywhere is the vector sum. The plate (x from −8 to 8 m, y from −4 to 4 m) shows the direction of flow as a grid of small arrows and as streamlines traced from the source. At the probe the source's and the sink's contributions are drawn tip to tail with their sum in ink, and the row under the plate reads the speed, its direction and both contributions. Drag the source, the sink or the probe; a press on the empty plate moves the probe there. Inside half a metre of a source or a sink the speed is capped, a finite core.
向いている場面
- Teach potential flow and superposition: let learners see that the velocity at a point is the source's outward push plus the sink's inward pull.
- Show how the streamlines change as the source and the sink move closer, until the pattern approaches a doublet.
向かない場面
- For measured flow data or viscous flow, use a real flow visualisation: this figure is an ideal, inviscid model.
使い方
import React, { useState } from 'react'
import { SourceSinkSampler } from './SourceSinkSampler.jsx'
export function FlowLesson() {
const [points, setPoints] = useState({
source: { x: -4, y: -1 },
sink: { x: 4, y: 1 },
probe: { x: 0, y: 2 },
})
return (
<SourceSinkSampler
value={points}
onChange={(next, { speed }) => setPoints(next)}
strength={20}
labels={{ title: 'A source and a sink' }}
/>
)
}プロパティ
| プロパティ | 型 | 既定値 | 説明 |
|---|---|---|---|
value | { source, sink, probe } | — | 位置を外部から指定します。それぞれ { x, y }(メートル)、x は −8〜8、y は −4〜4(0.1 刻みに丸めます)。 |
defaultValue | { source, sink, probe } | { source: { x: -4, y: -1 }, sink: { x: 4, y: 1 }, probe: { x: 0, y: 2 } } | 内部状態での初期位置です。どちらの使い方でもリセットはここに戻ります。 |
onChange | (points, reading) => void | — | 新しい位置と、測定点での { object('source'、'sink'、'probe'、リセット時は null)、reason('drag'、'press'、'tap'、'key'、'cancel'、'reset')、velocity、speed、angle(度、流れがなければ null)、source、sink }(m/s)を受け取ります。 |
strength | number | 20 | わき出しと吸い込みの強さ Q(m²/s)です。すべての速さが比例して変わります。 |
labels | object | — | 組み込みの文言を置き換えます:title、caption('{q}' は強さ)、source、sink、probe、velocity、readout('{point}')、direction('{angle}')、undefinedDirection、fromSource、fromSink、pointText('{name}'、'{point}')、movable、plate、speedUnit、strengthUnit、reset。 |
locale | string | 'en' | 小数の表示に使う言語タグです。 |
className | string | — | カードに追加するクラス名です。幅の指定などに使います(既定は 30rem、コンテナより広くなりません)。 |
アクセシビリティ
- The source, the sink and the probe are each one tab stop, a button with the role description 'movable point' and a name that reads its position. Arrow keys move the focused point by 0.5 m, with Shift by 2 m, clamped to the plate.
- The readout is a polite live region: it reads the position of the probe, the speed, its direction and the two contributions. Reset is a button, marked unavailable while nothing has changed.
- Dragging uses pointer capture. A handle sets touch-action: none, so the page does not scroll while a point is dragged; on the empty plate a tap places the probe and a swipe still scrolls the page. A cancelled gesture puts the point back where it started.
- Colour is not the only key: the source and the sink carry + and − signs, the legend names every colour, and the readout names each contribution.
モーション
After a key press, a tap or Reset, the moved point glides for --ds-duration-fast while the field, streamlines and probe arrows redraw at once; while a point is dragged it follows the pointer directly. With reduced motion every change lands at once.
プロジェクトに追加
Pro メンバーはプロンプトをコピーし、コーディングエージェントが無料コンポーネントと同じ手順でソースを導入します。
SourceSinkSampler.jsxsource-sink-sampler.csstokens.cssREADME.md
2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。







