flowgraph 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flowgraph/__init__.py +9 -0
- flowgraph/__main__.py +6 -0
- flowgraph/adapters/__init__.py +141 -0
- flowgraph/adapters/controls.py +96 -0
- flowgraph/adapters/cosapp.py +195 -0
- flowgraph/adapters/data_types.py +59 -0
- flowgraph/adapters/documentation.py +45 -0
- flowgraph/adapters/field_ops.py +121 -0
- flowgraph/adapters/file_conversion.py +393 -0
- flowgraph/adapters/files.py +191 -0
- flowgraph/adapters/filters.py +173 -0
- flowgraph/adapters/image_tools.py +394 -0
- flowgraph/adapters/mesh_creation_tools.py +431 -0
- flowgraph/adapters/mesh_generations.py +58 -0
- flowgraph/adapters/mesh_ops.py +362 -0
- flowgraph/adapters/paraview.py +39 -0
- flowgraph/adapters/plaid_bridge.py +205 -0
- flowgraph/adapters/readers.py +215 -0
- flowgraph/adapters/remote_files.py +118 -0
- flowgraph/adapters/simple_sources.py +199 -0
- flowgraph/adapters/sinks.py +80 -0
- flowgraph/adapters/user_code.py +196 -0
- flowgraph/adapters/workflow.py +176 -0
- flowgraph/adapters/workflow_interfaces.py +78 -0
- flowgraph/adapters/writers.py +159 -0
- flowgraph/application/__init__.py +1 -0
- flowgraph/application/node_registry.py +14 -0
- flowgraph/application/port_conversions.py +63 -0
- flowgraph/application/wasm_execution.py +132 -0
- flowgraph/application/workflow_cli.py +417 -0
- flowgraph/application/workflow_core.py +1193 -0
- flowgraph/application/workflow_history.py +93 -0
- flowgraph/application/workflow_io.py +393 -0
- flowgraph/application/workflow_layout.py +170 -0
- flowgraph/application/workflow_web_catalog.py +143 -0
- flowgraph/application/workflows.py +7 -0
- flowgraph/core_cli.py +81 -0
- flowgraph/domain/__init__.py +5 -0
- flowgraph/domain/mesh_document.py +91 -0
- flowgraph/examples/AllFilters.py +19 -0
- flowgraph/examples/convert_format.py +21 -0
- flowgraph/resources.py +29 -0
- flowgraph/testdata/AllFilters.json +390 -0
- flowgraph/testdata/FlowGraph.h5 +0 -0
- flowgraph/testdata/FlowGraph.stl +0 -0
- flowgraph/testdata/FlowGraph.xdmf +22 -0
- flowgraph/testdata/SimpleReadMesh.json +70 -0
- flowgraph/testdata/SpherePoints.csv +83 -0
- flowgraph/testdata/muscat-muscat-mesh-conversion.json +101 -0
- flowgraph/version.py +3 -0
- flowgraph-0.1.2.dist-info/METADATA +150 -0
- flowgraph-0.1.2.dist-info/RECORD +56 -0
- flowgraph-0.1.2.dist-info/WHEEL +5 -0
- flowgraph-0.1.2.dist-info/entry_points.txt +2 -0
- flowgraph-0.1.2.dist-info/licenses/LICENSE +29 -0
- flowgraph-0.1.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
"""Workflow nodes for Muscat mesh creation and conversion tools."""
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from math import pi
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from Muscat.MeshContainers import ElementsDescription as ED
|
|
8
|
+
from Muscat.MeshContainers.ElementsContainers import ElementsContainer
|
|
9
|
+
from Muscat.MeshTools.MeshCreationTools import (
|
|
10
|
+
Create0DElementContainerForEveryPoint,
|
|
11
|
+
CreateCube,
|
|
12
|
+
CreateDisk,
|
|
13
|
+
CreateMeshFromCellsDict,
|
|
14
|
+
CreateMeshOf,
|
|
15
|
+
CreateMeshOfTriangles,
|
|
16
|
+
CreateSquare,
|
|
17
|
+
CreateUniformMeshOfBars,
|
|
18
|
+
MeshToSimplex,
|
|
19
|
+
MirrorMesh,
|
|
20
|
+
QuadToLin,
|
|
21
|
+
SubDivideMesh,
|
|
22
|
+
ToQuadraticMesh,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
from flowgraph.application.workflow_core import (
|
|
26
|
+
DataType,
|
|
27
|
+
NodeDefinition,
|
|
28
|
+
ParameterDefinition,
|
|
29
|
+
ParameterOption,
|
|
30
|
+
PortDefinition,
|
|
31
|
+
PortDirection,
|
|
32
|
+
)
|
|
33
|
+
from flowgraph.domain.mesh_document import MeshDocument
|
|
34
|
+
|
|
35
|
+
from .data_types import ANY, INTEGER, MESH_DOCUMENT, VEC2DI, VEC3DI, ParameterKind
|
|
36
|
+
|
|
37
|
+
ELEMENTS_CONTAINER = DataType("elements-container", "Elements container", ElementsContainer)
|
|
38
|
+
|
|
39
|
+
_ELEMENT_OPTIONS = tuple(
|
|
40
|
+
ParameterOption(element.name, element.name)
|
|
41
|
+
for element in ED.ElementType
|
|
42
|
+
if element is not ED.ElementType.Element_NA
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _element_type(value: Any) -> ED.ElementType:
|
|
47
|
+
"""Convert a persisted element-type name or enum to a Muscat element type."""
|
|
48
|
+
if isinstance(value, ED.ElementType):
|
|
49
|
+
return value
|
|
50
|
+
if isinstance(value, str):
|
|
51
|
+
try:
|
|
52
|
+
return ED.ElementType[value]
|
|
53
|
+
except KeyError as error:
|
|
54
|
+
raise ValueError(f"Unknown Muscat element type: {value!r}") from error
|
|
55
|
+
raise TypeError("elemName must be a Muscat ElementType or its name")
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _mesh_result(mesh) -> Mapping[str, Any]:
|
|
59
|
+
"""Wrap a Muscat mesh in the canonical FlowGraph mesh document."""
|
|
60
|
+
return {"mesh": MeshDocument(mesh=mesh)}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _create_uniform_bars(
|
|
64
|
+
_inputs: Mapping[str, Any], parameters: Mapping[str, Any]
|
|
65
|
+
) -> Mapping[str, Any]:
|
|
66
|
+
return _mesh_result(
|
|
67
|
+
CreateUniformMeshOfBars(
|
|
68
|
+
parameters.get("startPoint", 0.0),
|
|
69
|
+
parameters.get("stopPoint", 1.0),
|
|
70
|
+
nbPoints=parameters.get("nbPoints", 50),
|
|
71
|
+
secondOrder=parameters.get("secondOrder", False),
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _create_triangles(
|
|
77
|
+
inputs: Mapping[str, Any], _parameters: Mapping[str, Any]
|
|
78
|
+
) -> Mapping[str, Any]:
|
|
79
|
+
return _mesh_result(CreateMeshOfTriangles(inputs["points"], inputs["triangles"]))
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _create_mesh(inputs: Mapping[str, Any], parameters: Mapping[str, Any]) -> Mapping[str, Any]:
|
|
83
|
+
return _mesh_result(
|
|
84
|
+
CreateMeshOf(
|
|
85
|
+
inputs["points"], inputs["connectivity"], _element_type(parameters["elemName"])
|
|
86
|
+
)
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def _create_square(_inputs: Mapping[str, Any], parameters: Mapping[str, Any]) -> Mapping[str, Any]:
|
|
91
|
+
return _mesh_result(
|
|
92
|
+
CreateSquare(
|
|
93
|
+
dimensions=parameters.get("dimensions", [2, 2]),
|
|
94
|
+
origin=parameters.get("origin", [-1.0, -1.0]),
|
|
95
|
+
spacing=parameters.get("spacing", [1.0, 1.0]),
|
|
96
|
+
ofTriangles=parameters.get("ofTriangles", False),
|
|
97
|
+
)
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def _create_disk(_inputs: Mapping[str, Any], parameters: Mapping[str, Any]) -> Mapping[str, Any]:
|
|
102
|
+
return _mesh_result(
|
|
103
|
+
CreateDisk(
|
|
104
|
+
nr=parameters.get("nr", 10),
|
|
105
|
+
nTheta=parameters.get("nTheta", 10),
|
|
106
|
+
r0=parameters.get("r0", 0.5),
|
|
107
|
+
r1=parameters.get("r1", 1.0),
|
|
108
|
+
theta0=parameters.get("theta0", 0.0),
|
|
109
|
+
theta1=parameters.get("theta1", pi / 2),
|
|
110
|
+
ofTriangles=parameters.get("ofTriangles", False),
|
|
111
|
+
)
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def _create_cube(_inputs: Mapping[str, Any], parameters: Mapping[str, Any]) -> Mapping[str, Any]:
|
|
116
|
+
return _mesh_result(
|
|
117
|
+
CreateCube(
|
|
118
|
+
dimensions=parameters.get("dimensions", [2, 2, 2]),
|
|
119
|
+
origin=parameters.get("origin", [-1.0, -1.0, -1.0]),
|
|
120
|
+
spacing=parameters.get("spacing", [1.0, 1.0, 1.0]),
|
|
121
|
+
ofTetras=parameters.get("ofTetras", False),
|
|
122
|
+
)
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _create_mesh_from_cells_dict(
|
|
127
|
+
inputs: Mapping[str, Any], parameters: Mapping[str, Any]
|
|
128
|
+
) -> Mapping[str, Any]:
|
|
129
|
+
return _mesh_result(
|
|
130
|
+
CreateMeshFromCellsDict(
|
|
131
|
+
inputs["points"],
|
|
132
|
+
inputs["cellsDict"],
|
|
133
|
+
pointFields=inputs["pointFields"],
|
|
134
|
+
cellFields=inputs["cellFields"],
|
|
135
|
+
cellFieldInDictOrder=parameters.get("cellFieldInDictOrder", True),
|
|
136
|
+
originalIds=inputs["originalIds"],
|
|
137
|
+
cellsOriginalIds=inputs["cellsOriginalIds"],
|
|
138
|
+
)
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _mesh_to_simplex(inputs: Mapping[str, Any], parameters: Mapping[str, Any]) -> Mapping[str, Any]:
|
|
143
|
+
return _mesh_result(
|
|
144
|
+
MeshToSimplex(inputs["mesh"].mesh, inPlace=parameters.get("inPlace", False))
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def _to_quadratic_mesh(
|
|
149
|
+
inputs: Mapping[str, Any], _parameters: Mapping[str, Any]
|
|
150
|
+
) -> Mapping[str, Any]:
|
|
151
|
+
return _mesh_result(ToQuadraticMesh(inputs["inputMesh"].mesh))
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def _quad_to_lin_creation(
|
|
155
|
+
inputs: Mapping[str, Any], parameters: Mapping[str, Any]
|
|
156
|
+
) -> Mapping[str, Any]:
|
|
157
|
+
return {
|
|
158
|
+
"outputMesh": MeshDocument(
|
|
159
|
+
mesh=QuadToLin(
|
|
160
|
+
inputs["inputMesh"].mesh,
|
|
161
|
+
divideQuadElements=parameters.get("divideQuadElements", True),
|
|
162
|
+
linearizedMiddlePoints=parameters.get("linearizedMiddlePoints", False),
|
|
163
|
+
)
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def _mirror_mesh(inputs: Mapping[str, Any], parameters: Mapping[str, Any]) -> Mapping[str, Any]:
|
|
169
|
+
return _mesh_result(
|
|
170
|
+
MirrorMesh(
|
|
171
|
+
inputs["inmesh"].mesh,
|
|
172
|
+
x=parameters.get("x"),
|
|
173
|
+
y=parameters.get("y"),
|
|
174
|
+
z=parameters.get("z"),
|
|
175
|
+
propagateToNodeFields=parameters.get("propagateToNodeFields", False),
|
|
176
|
+
)
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def _create_zero_d_elements(
|
|
181
|
+
inputs: Mapping[str, Any], _parameters: Mapping[str, Any]
|
|
182
|
+
) -> Mapping[str, Any]:
|
|
183
|
+
return {"elements": Create0DElementContainerForEveryPoint(inputs["mesh"].mesh)}
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def _subdivide_mesh(inputs: Mapping[str, Any], parameters: Mapping[str, Any]) -> Mapping[str, Any]:
|
|
187
|
+
return _mesh_result(SubDivideMesh(inputs["mesh"].mesh, level=parameters.get("level", 1)))
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def _mesh_output(name: str = "mesh") -> tuple[PortDefinition, ...]:
|
|
191
|
+
return (PortDefinition(name, PortDirection.OUTPUT, MESH_DOCUMENT, "Mesh"),)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def _mesh_input_output(input_name: str, output_name: str = "mesh") -> tuple[PortDefinition, ...]:
|
|
195
|
+
return (
|
|
196
|
+
PortDefinition(input_name, PortDirection.INPUT, MESH_DOCUMENT, "Input mesh"),
|
|
197
|
+
PortDefinition(output_name, PortDirection.OUTPUT, MESH_DOCUMENT, "Output mesh"),
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
CREATE_UNIFORM_MESH_OF_BARS_NODE = NodeDefinition(
|
|
202
|
+
id="create-uniform-mesh-of-bars",
|
|
203
|
+
icon="mdi-vector-line",
|
|
204
|
+
label="Create Uniform Mesh Of Bars",
|
|
205
|
+
description="Create a uniform Muscat mesh of bars.",
|
|
206
|
+
ports=_mesh_output(),
|
|
207
|
+
executor=_create_uniform_bars,
|
|
208
|
+
parameters=(
|
|
209
|
+
ParameterDefinition("startPoint", ParameterKind.VEC3D, "Start point", [0, 0, 0]),
|
|
210
|
+
ParameterDefinition("stopPoint", ParameterKind.VEC3D, "Stop point", [1, 0, 0]),
|
|
211
|
+
ParameterDefinition("nbPoints", INTEGER, "Number of points", 50),
|
|
212
|
+
ParameterDefinition(
|
|
213
|
+
"secondOrder", ParameterKind.BOOLEAN, "Second order", False, port=False
|
|
214
|
+
),
|
|
215
|
+
),
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
CREATE_MESH_OF_TRIANGLES_NODE = NodeDefinition(
|
|
219
|
+
id="create-mesh-of-triangles",
|
|
220
|
+
icon="mdi-triangle-outline",
|
|
221
|
+
label="Create Mesh Of Triangles",
|
|
222
|
+
description="Create a Muscat triangular mesh from points and connectivity.",
|
|
223
|
+
ports=(
|
|
224
|
+
PortDefinition("points", PortDirection.INPUT, ANY, "Points"),
|
|
225
|
+
PortDefinition("triangles", PortDirection.INPUT, ANY, "Triangles"),
|
|
226
|
+
*_mesh_output(),
|
|
227
|
+
),
|
|
228
|
+
executor=_create_triangles,
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
CREATE_MESH_OF_NODE = NodeDefinition(
|
|
232
|
+
id="create-mesh-of",
|
|
233
|
+
icon="mdi-shape-outline",
|
|
234
|
+
label="Create Mesh Of",
|
|
235
|
+
description="Create a homogeneous Muscat mesh from points and connectivity.",
|
|
236
|
+
ports=(
|
|
237
|
+
PortDefinition("points", PortDirection.INPUT, ANY, "Points"),
|
|
238
|
+
PortDefinition("connectivity", PortDirection.INPUT, ANY, "Connectivity"),
|
|
239
|
+
*_mesh_output(),
|
|
240
|
+
),
|
|
241
|
+
executor=_create_mesh,
|
|
242
|
+
parameters=(
|
|
243
|
+
ParameterDefinition(
|
|
244
|
+
"elemName",
|
|
245
|
+
ParameterKind.STR_SELECT,
|
|
246
|
+
"Element type",
|
|
247
|
+
"Triangle_3",
|
|
248
|
+
options=_ELEMENT_OPTIONS,
|
|
249
|
+
),
|
|
250
|
+
),
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
CREATE_SQUARE_NODE = NodeDefinition(
|
|
254
|
+
id="create-square",
|
|
255
|
+
icon="mdi-grid",
|
|
256
|
+
label="Create Square",
|
|
257
|
+
description="Create a structured Muscat square mesh.",
|
|
258
|
+
ports=_mesh_output(),
|
|
259
|
+
executor=_create_square,
|
|
260
|
+
parameters=(
|
|
261
|
+
ParameterDefinition("dimensions", VEC2DI, "Dimensions", [2, 2]),
|
|
262
|
+
ParameterDefinition("origin", ParameterKind.VEC2D, "Origin", [-1.0, -1.0]),
|
|
263
|
+
ParameterDefinition("spacing", ParameterKind.VEC2D, "Spacing", [1.0, 1.0]),
|
|
264
|
+
ParameterDefinition(
|
|
265
|
+
"ofTriangles", ParameterKind.BOOLEAN, "Use triangles", False, port=False
|
|
266
|
+
),
|
|
267
|
+
),
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
CREATE_DISK_NODE = NodeDefinition(
|
|
271
|
+
id="create-disk",
|
|
272
|
+
icon="mdi-circle-outline",
|
|
273
|
+
label="Create Disk",
|
|
274
|
+
description="Create a structured Muscat disk-sector mesh.",
|
|
275
|
+
ports=_mesh_output(),
|
|
276
|
+
executor=_create_disk,
|
|
277
|
+
parameters=(
|
|
278
|
+
ParameterDefinition("nr", INTEGER, "Radial points", 10),
|
|
279
|
+
ParameterDefinition("nTheta", INTEGER, "Angular points", 10),
|
|
280
|
+
ParameterDefinition("r0", ParameterKind.FLOAT, "Inner radius", 0.5),
|
|
281
|
+
ParameterDefinition("r1", ParameterKind.FLOAT, "Outer radius", 1.0),
|
|
282
|
+
ParameterDefinition("theta0", ParameterKind.FLOAT, "Start angle", 0.0),
|
|
283
|
+
ParameterDefinition("theta1", ParameterKind.FLOAT, "End angle", pi / 2),
|
|
284
|
+
ParameterDefinition(
|
|
285
|
+
"ofTriangles", ParameterKind.BOOLEAN, "Use triangles", False, port=False
|
|
286
|
+
),
|
|
287
|
+
),
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
CREATE_CUBE_NODE = NodeDefinition(
|
|
291
|
+
id="create-cube",
|
|
292
|
+
icon="mdi-cube-outline",
|
|
293
|
+
label="Create Cube",
|
|
294
|
+
description="Create a structured Muscat cube mesh.",
|
|
295
|
+
ports=_mesh_output(),
|
|
296
|
+
executor=_create_cube,
|
|
297
|
+
parameters=(
|
|
298
|
+
ParameterDefinition("dimensions", VEC3DI, "Dimensions", [2, 2, 2]),
|
|
299
|
+
ParameterDefinition("origin", ParameterKind.VEC3D, "Origin", [-1.0, -1.0, -1.0]),
|
|
300
|
+
ParameterDefinition("spacing", ParameterKind.VEC3D, "Spacing", [1.0, 1.0, 1.0]),
|
|
301
|
+
ParameterDefinition("ofTetras", ParameterKind.BOOLEAN, "Use tetrahedra", False, port=False),
|
|
302
|
+
),
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
CREATE_MESH_FROM_CELLS_DICT_NODE = NodeDefinition(
|
|
306
|
+
id="create-mesh-from-cells-dict",
|
|
307
|
+
icon="mdi-code-braces-box",
|
|
308
|
+
label="Create Mesh From Cells Dict",
|
|
309
|
+
description="Create a Muscat mesh from points and a dictionary of cells.",
|
|
310
|
+
ports=(
|
|
311
|
+
PortDefinition("points", PortDirection.INPUT, ANY, "Points"),
|
|
312
|
+
PortDefinition("cellsDict", PortDirection.INPUT, ANY, "Cells dictionary"),
|
|
313
|
+
PortDefinition("pointFields", PortDirection.INPUT, ANY, "Point fields"),
|
|
314
|
+
PortDefinition("cellFields", PortDirection.INPUT, ANY, "Cell fields"),
|
|
315
|
+
PortDefinition("originalIds", PortDirection.INPUT, ANY, "Original node IDs"),
|
|
316
|
+
PortDefinition("cellsOriginalIds", PortDirection.INPUT, ANY, "Original cell IDs"),
|
|
317
|
+
*_mesh_output(),
|
|
318
|
+
),
|
|
319
|
+
executor=_create_mesh_from_cells_dict,
|
|
320
|
+
parameters=(
|
|
321
|
+
ParameterDefinition(
|
|
322
|
+
"cellFieldInDictOrder",
|
|
323
|
+
ParameterKind.BOOLEAN,
|
|
324
|
+
"Fields in dictionary order",
|
|
325
|
+
True,
|
|
326
|
+
port=False,
|
|
327
|
+
),
|
|
328
|
+
),
|
|
329
|
+
)
|
|
330
|
+
|
|
331
|
+
MESH_TO_SIMPLEX_NODE = NodeDefinition(
|
|
332
|
+
id="mesh-to-simplex",
|
|
333
|
+
icon="mdi-vector-triangle",
|
|
334
|
+
label="Mesh To Simplex",
|
|
335
|
+
description="Convert a Muscat mesh to simplex elements.",
|
|
336
|
+
ports=_mesh_input_output("mesh"),
|
|
337
|
+
executor=_mesh_to_simplex,
|
|
338
|
+
)
|
|
339
|
+
|
|
340
|
+
TO_QUADRATIC_MESH_NODE = NodeDefinition(
|
|
341
|
+
id="to-quadratic-mesh",
|
|
342
|
+
icon="mdi-vector-square-plus",
|
|
343
|
+
label="To Quadratic Mesh",
|
|
344
|
+
description="Convert a linear Muscat mesh to quadratic elements.",
|
|
345
|
+
ports=_mesh_input_output("inputMesh", "outputMesh"),
|
|
346
|
+
executor=_to_quadratic_mesh,
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
QUAD_TO_LIN_CREATION_NODE = NodeDefinition(
|
|
350
|
+
id="quad-to-lin-creation",
|
|
351
|
+
icon="mdi-vector-square-remove",
|
|
352
|
+
label="To Linear Mesh",
|
|
353
|
+
description="Convert a quadratic Muscat mesh to linear elements.",
|
|
354
|
+
ports=_mesh_input_output("inputMesh", "outputMesh"),
|
|
355
|
+
executor=_quad_to_lin_creation,
|
|
356
|
+
parameters=(
|
|
357
|
+
ParameterDefinition(
|
|
358
|
+
"divideQuadElements",
|
|
359
|
+
ParameterKind.BOOLEAN,
|
|
360
|
+
"Divide quadratic elements",
|
|
361
|
+
True,
|
|
362
|
+
port=False,
|
|
363
|
+
),
|
|
364
|
+
ParameterDefinition(
|
|
365
|
+
"linearizedMiddlePoints",
|
|
366
|
+
ParameterKind.BOOLEAN,
|
|
367
|
+
"Linearize middle points",
|
|
368
|
+
False,
|
|
369
|
+
port=False,
|
|
370
|
+
),
|
|
371
|
+
),
|
|
372
|
+
)
|
|
373
|
+
|
|
374
|
+
MIRROR_MESH_NODE = NodeDefinition(
|
|
375
|
+
id="mirror-mesh",
|
|
376
|
+
icon="mdi-mirror-rectangle",
|
|
377
|
+
label="Mirror Mesh",
|
|
378
|
+
description="Create a mirrored copy of a Muscat mesh across selected planes.",
|
|
379
|
+
ports=_mesh_input_output("inmesh"),
|
|
380
|
+
executor=_mirror_mesh,
|
|
381
|
+
parameters=(
|
|
382
|
+
ParameterDefinition("x", ParameterKind.FLOAT, "YZ plane x", None),
|
|
383
|
+
ParameterDefinition("y", ParameterKind.FLOAT, "XZ plane y", None),
|
|
384
|
+
ParameterDefinition("z", ParameterKind.FLOAT, "XY plane z", None),
|
|
385
|
+
ParameterDefinition(
|
|
386
|
+
"propagateToNodeFields",
|
|
387
|
+
ParameterKind.BOOLEAN,
|
|
388
|
+
"Propagate node fields",
|
|
389
|
+
False,
|
|
390
|
+
port=False,
|
|
391
|
+
),
|
|
392
|
+
),
|
|
393
|
+
)
|
|
394
|
+
|
|
395
|
+
CREATE_0D_ELEMENTS_NODE = NodeDefinition(
|
|
396
|
+
id="create-0d-elements-for-every-point",
|
|
397
|
+
icon="mdi-vector-point",
|
|
398
|
+
label="Create 0D Elements For Every Point",
|
|
399
|
+
description="Create a Muscat point-element container for every mesh point.",
|
|
400
|
+
ports=(
|
|
401
|
+
PortDefinition("mesh", PortDirection.INPUT, MESH_DOCUMENT, "Mesh"),
|
|
402
|
+
PortDefinition("elements", PortDirection.OUTPUT, ELEMENTS_CONTAINER, "Elements"),
|
|
403
|
+
),
|
|
404
|
+
executor=_create_zero_d_elements,
|
|
405
|
+
)
|
|
406
|
+
|
|
407
|
+
SUBDIVIDE_MESH_NODE = NodeDefinition(
|
|
408
|
+
id="subdivide-mesh",
|
|
409
|
+
icon="mdi-vector-split",
|
|
410
|
+
label="Subdivide Mesh",
|
|
411
|
+
description="Subdivide a Muscat mesh one or more times.",
|
|
412
|
+
ports=_mesh_input_output("mesh"),
|
|
413
|
+
executor=_subdivide_mesh,
|
|
414
|
+
parameters=(ParameterDefinition("level", INTEGER, "Subdivision level", 1),),
|
|
415
|
+
)
|
|
416
|
+
|
|
417
|
+
AVAILABLE_NODES = (
|
|
418
|
+
CREATE_UNIFORM_MESH_OF_BARS_NODE,
|
|
419
|
+
CREATE_MESH_OF_TRIANGLES_NODE,
|
|
420
|
+
CREATE_MESH_OF_NODE,
|
|
421
|
+
CREATE_SQUARE_NODE,
|
|
422
|
+
CREATE_DISK_NODE,
|
|
423
|
+
CREATE_CUBE_NODE,
|
|
424
|
+
CREATE_MESH_FROM_CELLS_DICT_NODE,
|
|
425
|
+
MESH_TO_SIMPLEX_NODE,
|
|
426
|
+
TO_QUADRATIC_MESH_NODE,
|
|
427
|
+
QUAD_TO_LIN_CREATION_NODE,
|
|
428
|
+
MIRROR_MESH_NODE,
|
|
429
|
+
CREATE_0D_ELEMENTS_NODE,
|
|
430
|
+
SUBDIVIDE_MESH_NODE,
|
|
431
|
+
)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""Workflow nodes that read external data into FlowGraph domain objects."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from collections.abc import Mapping
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from Muscat.MeshContainers.Mesh import Mesh
|
|
8
|
+
|
|
9
|
+
from flowgraph.adapters.data_types import VEC3DSTR
|
|
10
|
+
from flowgraph.adapters.readers import MESH_DOCUMENT, TABLE_DOCUMENT
|
|
11
|
+
from flowgraph.application.workflow_core import (
|
|
12
|
+
NodeDefinition,
|
|
13
|
+
ParameterDefinition,
|
|
14
|
+
PortDefinition,
|
|
15
|
+
PortDirection,
|
|
16
|
+
)
|
|
17
|
+
from flowgraph.domain.mesh_document import MeshDocument
|
|
18
|
+
|
|
19
|
+
LOGGER = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def create_mesh_from_table(
|
|
23
|
+
inputs: Mapping[str, Any], parameters: Mapping[str, Any]
|
|
24
|
+
) -> Mapping[str, Any]:
|
|
25
|
+
import numpy as np
|
|
26
|
+
|
|
27
|
+
data_table = inputs["table"]
|
|
28
|
+
values = parameters["value"]
|
|
29
|
+
|
|
30
|
+
positions = np.vstack(tuple(data_table[x].flatten() for x in values)).T
|
|
31
|
+
|
|
32
|
+
mesh = Mesh()
|
|
33
|
+
mesh.SetNodes(positions, generateOriginalIDs=True)
|
|
34
|
+
mesh.nodeFields = {x: data_table[x] for x in values}
|
|
35
|
+
|
|
36
|
+
return {"mesh": MeshDocument(mesh=mesh)}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
CSV_TO_MESH = NodeDefinition(
|
|
40
|
+
id="csv-to-mesh",
|
|
41
|
+
icon="mdi-table-merge-cells",
|
|
42
|
+
label="Table to Mesh",
|
|
43
|
+
description="Create a mesh from a table.",
|
|
44
|
+
ports=(
|
|
45
|
+
PortDefinition("table", PortDirection.INPUT, TABLE_DOCUMENT, "Table"),
|
|
46
|
+
PortDefinition("mesh", PortDirection.OUTPUT, MESH_DOCUMENT, "Mesh"),
|
|
47
|
+
),
|
|
48
|
+
executor=create_mesh_from_table,
|
|
49
|
+
parameters=(
|
|
50
|
+
ParameterDefinition(
|
|
51
|
+
"value",
|
|
52
|
+
VEC3DSTR,
|
|
53
|
+
"Coordinates Names",
|
|
54
|
+
["x", "y", "z"],
|
|
55
|
+
port=True,
|
|
56
|
+
),
|
|
57
|
+
),
|
|
58
|
+
)
|