Skip to content

Commit 9a567b7

Browse files
committed
WIP: adding mesh config to frontend
1 parent 271660e commit 9a567b7

File tree

2 files changed

+53
-5
lines changed

2 files changed

+53
-5
lines changed

packages/algjulia-interop/src/decapodes-service/geometry.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ const domain_names = [:Plane, :Sphere]
55

66
""" Mapping from supported domains to meshes for the domain. """
77
const mesh_names = Dict(
8-
:Plane => [:Rectangle, :Periodic],
9-
:Sphere => [:Icosphere6, :Icosphere7, :Icosphere8, :UV],
10-
)
8+
:Plane => [:Rectangle, :Periodic],
9+
:Sphere => [:Icosphere, :UV])
10+
11+
""" Mapping between meshes and their configurable parameters """
12+
const mesh_config = Dict(:Plane => Dict(:Rectangle => (x=100, y=100)),
13+
:Sphere => Dict(:Icosphere => (dim=[6,7,8],)))
14+
1115

1216
""" Mapping from supported domains to initial/boundary conditions. """
1317
const initial_condition_names = Dict(
@@ -21,6 +25,7 @@ function supported_decapodes_geometries()
2125
Dict(
2226
:name => domain,
2327
:meshes => mesh_names[domain],
28+
:meshConfig => mesh_config[domain],
2429
:initialConditions => initial_condition_names[domain],
2530
)
2631
end

packages/frontend/src/stdlib/analyses/decapodes.tsx

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ export function Decapodes(props: DiagramAnalysisProps<DecapodesContent>) {
207207
return;
208208
}
209209
content.domain = domain;
210-
content.mesh = options()?.domains.get(domain)?.meshes[0] ?? null;
211-
content.initialConditions = {};
210+
content.mesh = options()?.domains?.get(domain)?.meshes[0] ?? null;
211+
console.log(domains);
212212
})
213213
}
214214
>
@@ -235,6 +235,45 @@ export function Decapodes(props: DiagramAnalysisProps<DecapodesContent>) {
235235
</>
236236
)}
237237
</Show>
238+
<Show when={props.content.domain && props.content.mesh}>
239+
{(() => {
240+
const mesh = props.content.mesh;
241+
const domain = props.content.domain;
242+
if (!mesh || !domain) return null;
243+
244+
const config = domains.get(domain);
245+
if (!config?.meshConfig) return null;
246+
247+
const meshConfigData = (config.meshConfig as any)[mesh!];
248+
if (!meshConfigData) return null;
249+
250+
const entries = Object.entries(meshConfigData);
251+
252+
return (
253+
<For each={entries}>
254+
{([key, value]) => (
255+
<>
256+
<Show when={Array.isArray(value)}>
257+
<select>
258+
<For each={value}>
259+
{(x) => <option value={x}>{x}</option>}
260+
</For>
261+
</select>
262+
</Show>
263+
<Show when={!Array.isArray(value)}>
264+
<input
265+
type="number"
266+
placeholder={key}
267+
value={value}
268+
onInput={(e) => console.log(value, e)}
269+
/>
270+
</Show>
271+
</>
272+
)}
273+
</For>
274+
);
275+
})()}
276+
</Show>
238277
</div>
239278
);
240279

@@ -301,6 +340,9 @@ type Domain = {
301340

302341
/** Initial/boundary conditions supported for the domain. */
303342
initialConditions: string[];
343+
344+
/** Dimension configuration */
345+
meshConfig: Map<string, Record<string, number | number[]>>;
304346
};
305347

306348
/** Data sent to the Julia kernel defining a simulation. */
@@ -371,6 +413,7 @@ const makeSimulationData = (
371413
return undefined;
372414
}
373415

416+
// console.log("CONFIG: ", content);
374417
const { domain, mesh, initialConditions, plotVariables, scalars, duration } = content;
375418
if (domain === null || mesh === null || !Object.values(plotVariables).some((x) => x)) {
376419
return undefined;

0 commit comments

Comments
 (0)