Treats each relation network as a conductance network (diameter^4 / length), solves nodal balance per connected component, so flow is conserved at every junction and wider pipes carry proportionally more flow. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
30 lines
869 B
C++
30 lines
869 B
C++
#pragma once
|
|
|
|
#include "Types.h"
|
|
|
|
#include <QHash>
|
|
|
|
namespace diag {
|
|
|
|
class NetworkModel;
|
|
|
|
struct FlowResult {
|
|
bool ok = false;
|
|
QString message;
|
|
QHash<QUuid, double> edgeFlow; // signed; positive flows from -> to
|
|
};
|
|
|
|
// Mock flow-distribution calculation. Treats each relation network as a
|
|
// resistor-style network: edge conductance derives from pipe diameter and
|
|
// length, node injections from "supply"/"demand" properties. Solves nodal
|
|
// balance (Kirchhoff) per connected component with dense Gaussian
|
|
// elimination, so flow is conserved at every junction.
|
|
class FlowSolver {
|
|
public:
|
|
static FlowResult solve(const NetworkModel& model, const QString& relationId);
|
|
// Writes flows into the model (setEdgeFlow); edges of other relations keep theirs.
|
|
static void apply(NetworkModel& model, const FlowResult& result);
|
|
};
|
|
|
|
} // namespace diag
|