Skip to content

Commit bf45b10

Browse files
committed
fix(oscillator): expand oscillator type and output
Output now represents a real small-run configuration for the sensei oscillator mini-app.
1 parent de4b555 commit bf45b10

8 files changed

Lines changed: 254 additions & 14 deletions

File tree

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"bundle": "inline-source --compress false --root ./dist ./dist/index.html ./dist/Simput.html",
3131
"commit": "git cz",
3232
"semantic-release": "semantic-release",
33-
3433
"types": "npm run type:nwchem && npm run type:nwchem-neb && npm run type:openfoam-periodic && npm run type:openfoam-tutorials && npm run type:openfoam-windtunnel && npm run type:oscillator && npm run type:pyfr && npm run type:test && npm run type:vcard && npm run type:vera",
3534
"type:nwchem": "node ./src/cli/simput-cli.js -c ./types/nwchem/src -o ./static/types -t nwchem",
3635
"type:nwchem-neb": "node ./src/cli/simput-cli.js -c ./types/nwchem-neb/src -o ./static/types -t nwchem-neb",
@@ -42,7 +41,6 @@
4241
"type:test": "node ./src/cli/simput-cli.js -c ./types/test/src -o ./static/types -t test",
4342
"type:vcard": "node ./src/cli/simput-cli.js -c ./types/vcard/src -o ./static/types -t vcard",
4443
"type:vera": "node ./src/cli/simput-cli.js -c ./types/vera/src -o ./static/types -t vera",
45-
4644
"prepublishOnly": "npm run version && npm run bundle"
4745
},
4846
"author": "Kitware",

static/types/oscillator.js

Lines changed: 30 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<sensei>
2+
{{#each histogram}}
3+
<analysis type="histogram" mesh="{{mesh}}" array="{{array}}" association="{{association}}"
4+
bins="{{bins}}" enabled="1" />
5+
{{/each}}
6+
7+
{{#each autocorrelation}}
8+
<analysis type="autocorrelation" mesh="{{mesh}}" array="data" association="cell"
9+
window="{{window}}" k-max="{{kmax}}" enabled="1" />
10+
{{/each}}
11+
12+
</sensei>

types/oscillator/src/convert.js

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
const outputTemplate = require('./output.hbs');
1+
const outputTemplate = require('./oscillator_list.hbs');
2+
const configTemplate = require('./analysis_config.hbs');
3+
const runTemplate = require('./run_script.hbs');
24

35
/*
46
# type center r omega0 zeta
@@ -52,7 +54,57 @@ module.exports = function convert(dataModel) {
5254
}
5355

5456
// Use dummy line writer
55-
results['sample.osc'] = outputTemplate({ lines });
57+
results['oscillator_list.osc'] = outputTemplate({ lines });
58+
59+
// analyses, have sub-object matching type, with the attributes.
60+
const histogram = [];
61+
const autocorrelation = [];
62+
dataModel.data.analyses.forEach((attributes) => {
63+
const analysis = {};
64+
const type = attributes.analysis.type.value[0];
65+
Object.keys(attributes[type]).forEach((fieldName) => {
66+
const value = attributes[type][fieldName].value;
67+
if (value.length === 1) {
68+
analysis[fieldName] = value[0];
69+
} else {
70+
analysis[fieldName] = value;
71+
}
72+
});
73+
console.log(analysis);
74+
if (type === 'histogram') {
75+
// fill in associated fields.
76+
if (analysis.mesh === 'particles') {
77+
analysis.array = "velocityMagnitude";
78+
analysis.association="point";
79+
} else {
80+
analysis.array = "data";
81+
analysis.association="cell";
82+
}
83+
histogram.push(analysis);
84+
} else if (type === 'autocorrelation') {
85+
autocorrelation.push(analysis);
86+
}
87+
});
88+
89+
// analysis xml
90+
results['analysis_config.xml'] = configTemplate({ histogram, autocorrelation });
91+
92+
93+
const runParams = {};
94+
if (dataModel.data.run) {
95+
const params = dataModel.data.run[0].runParams;
96+
Object.keys(params).forEach((fieldName) => {
97+
const value = params[fieldName].value;
98+
if (value.length === 1) {
99+
runParams[fieldName] = value[0];
100+
} else {
101+
runParams[fieldName] = value;
102+
}
103+
});
104+
}
105+
106+
// analysis xml
107+
results['run.sh'] = runTemplate(runParams);
56108

57109
return { results, model: dataModel };
58110
};

types/oscillator/src/lang/en/label.json

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"views": {
3-
"oscillators": "Oscillator list"
3+
"oscillators": "Oscillators",
4+
"analyses": "Analyses",
5+
"run": "Execution Script"
46
},
57
"attributes": {
68
"oscillator": {
@@ -12,6 +14,36 @@
1214
"omega": "Omega 0",
1315
"zeta": "Zeta"
1416
}
17+
},
18+
"analysis": {
19+
"title": "Analysis",
20+
"parameters": {
21+
"type": "Type"
22+
}
23+
},
24+
"histogram": {
25+
"title": "Histogram",
26+
"parameters": {
27+
"mesh": "Mesh data",
28+
"bins": "Bins"
29+
}
30+
},
31+
"autocorrelation": {
32+
"title": "Autocorrelation",
33+
"parameters": {
34+
"mesh": "Mesh data",
35+
"window": "Window",
36+
"kmax": "K-max"
37+
}
38+
},
39+
"runParams": {
40+
"title": "Execution parameters",
41+
"parameters": {
42+
"nodes": "Nodes",
43+
"gridsize": "Grid size",
44+
"dt": "Time step",
45+
"endT": "Duration"
46+
}
1547
}
1648
}
1749
}

types/oscillator/src/model.js

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
order: ['oscillators'],
2+
order: ['oscillators', 'analyses', 'run'],
33
views: {
44
oscillators: {
55
size: -1,
@@ -11,6 +11,19 @@ module.exports = {
1111
},
1212
],
1313
},
14+
analyses: {
15+
size: -1,
16+
attributes: ['analysis'],
17+
hooks: [
18+
{
19+
type: 'copyParameterToViewName',
20+
attribute: 'analysis.name',
21+
},
22+
],
23+
},
24+
run: {
25+
attributes: ['runParams'],
26+
},
1427
},
1528
definitions: {
1629
oscillator: {
@@ -59,5 +72,105 @@ module.exports = {
5972
},
6073
],
6174
},
75+
analysis: {
76+
parameters: [
77+
{
78+
id: 'name',
79+
label: 'Name',
80+
type: 'string',
81+
size: 1,
82+
},
83+
{
84+
id: 'type',
85+
type: 'enum',
86+
size: 1,
87+
default: 'histogram',
88+
domain: {
89+
Histogram: 'histogram',
90+
Autocorrelation: 'autocorrelation',
91+
},
92+
},
93+
["histogram", "autocorrelation"],
94+
],
95+
children: {
96+
histogram: "analysis.type[0] === 'histogram'",
97+
autocorrelation: "analysis.type[0] === 'autocorrelation'",
98+
},
99+
},
100+
histogram: {
101+
parameters: [
102+
{
103+
id: 'mesh',
104+
type: 'enum',
105+
size: 1,
106+
default: 'mesh',
107+
domain: {
108+
Mesh: 'mesh',
109+
'Unstructured mesh': 'ucdmesh',
110+
'Particle velocity magnitude': 'particles',
111+
},
112+
},
113+
{
114+
id: 'bins',
115+
type: 'int',
116+
size: 1,
117+
default: [10],
118+
},
119+
],
120+
},
121+
autocorrelation: {
122+
parameters: [
123+
{
124+
id: 'mesh',
125+
type: 'enum',
126+
size: 1,
127+
default: 'mesh',
128+
domain: {
129+
// currently only works on one type.
130+
Mesh: 'mesh',
131+
},
132+
},
133+
{
134+
id: 'window',
135+
type: 'double',
136+
size: 1,
137+
default: [10],
138+
},
139+
{
140+
id: 'kmax',
141+
type: 'double',
142+
size: 1,
143+
default: [3],
144+
},
145+
],
146+
},
147+
runParams: {
148+
parameters: [
149+
{
150+
id: 'nodes',
151+
type: 'int',
152+
size: 1,
153+
default: [1],
154+
},
155+
{
156+
id: 'gridsize',
157+
type: 'int',
158+
size: 1,
159+
default: [64],
160+
},
161+
{
162+
id: 'dt',
163+
type: 'double',
164+
size: 1,
165+
default: [0.5],
166+
},
167+
{
168+
id: 'endT',
169+
type: 'double',
170+
size: 1,
171+
default: [10],
172+
},
173+
],
174+
},
62175
},
63176
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash -l
2+
3+
numranks={{nodes}}
4+
dt={{dt}}
5+
endt={{endT}}
6+
grid={{gridsize}}x{{gridsize}}x{{gridsize}}
7+
osc=oscillator_list.osc
8+
xml=analysis_config.xml
9+
exe=oscillator
10+
11+
mpirun -n $numranks $exe -s $grid --dt $dt --t-end $endt --shortlog -f $xml $osc

0 commit comments

Comments
 (0)