Datasets:
Update README.md
Browse files
README.md
CHANGED
|
@@ -2362,32 +2362,43 @@ Mesh objects included in samples follow the [CGNS](https://cgns.github.io/) stan
|
|
| 2362 |
|
| 2363 |
Example of commands:
|
| 2364 |
```python
|
| 2365 |
-
import pickle
|
| 2366 |
from datasets import load_dataset
|
| 2367 |
from plaid.containers.sample import Sample
|
|
|
|
| 2368 |
|
| 2369 |
# Load the dataset
|
| 2370 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2371 |
|
| 2372 |
-
#
|
| 2373 |
-
|
| 2374 |
-
|
| 2375 |
-
|
| 2376 |
-
|
| 2377 |
-
print("type(plaid_sample) =", type(plaid_sample))
|
| 2378 |
|
| 2379 |
-
|
|
|
|
| 2380 |
|
| 2381 |
-
#
|
| 2382 |
-
|
| 2383 |
-
field =
|
| 2384 |
-
print("field_names[0] =", field_names[0])
|
| 2385 |
|
| 2386 |
-
|
| 2387 |
|
| 2388 |
# Get the mesh and convert it to Muscat
|
| 2389 |
from Muscat.Bridges import CGNSBridge
|
| 2390 |
-
CGNS_tree =
|
| 2391 |
mesh = CGNSBridge.CGNSToMesh(CGNS_tree)
|
| 2392 |
print(mesh)
|
| 2393 |
```
|
|
|
|
| 2362 |
|
| 2363 |
Example of commands:
|
| 2364 |
```python
|
|
|
|
| 2365 |
from datasets import load_dataset
|
| 2366 |
from plaid.containers.sample import Sample
|
| 2367 |
+
import pickle
|
| 2368 |
|
| 2369 |
# Load the dataset
|
| 2370 |
+
hf_dataset = load_dataset("PLAID-datasets/2D_Multiscale_Hyperelasticity", split="all_samples")
|
| 2371 |
+
|
| 2372 |
+
# Get split ids
|
| 2373 |
+
ids_train = hf_dataset.description["split"]['DOE_train']
|
| 2374 |
+
ids_test = hf_dataset.description["split"]['DOE_test']
|
| 2375 |
+
|
| 2376 |
+
# Get inputs/outputs names
|
| 2377 |
+
in_scalars_names = hf_dataset.description["in_scalars_names"]
|
| 2378 |
+
out_fields_names = hf_dataset.description["out_fields_names"]
|
| 2379 |
+
|
| 2380 |
+
# Get samples
|
| 2381 |
+
sample = Sample.model_validate(pickle.loads(hf_dataset[ids_train[0]]["sample"]))
|
| 2382 |
+
sample_2 = Sample.model_validate(pickle.loads(hf_dataset[ids_test[0]]["sample"]))
|
| 2383 |
|
| 2384 |
+
# Examples data retrievals
|
| 2385 |
+
# inputs
|
| 2386 |
+
nodes = sample.get_nodes()
|
| 2387 |
+
elements = sample.get_elements()
|
| 2388 |
+
nodal_tags = sample.get_nodal_tags()
|
|
|
|
| 2389 |
|
| 2390 |
+
for sn in ['C11', 'C12', 'C22']:
|
| 2391 |
+
scalar = sample.get_scalar(sn)
|
| 2392 |
|
| 2393 |
+
# outputs
|
| 2394 |
+
for fn in ['u1', 'u2', 'P11', 'P12', 'P22', 'P21', 'psi']:
|
| 2395 |
+
field = sample.get_field(fn)
|
|
|
|
| 2396 |
|
| 2397 |
+
effective_energy = sample.get_scalar("effective_energy")
|
| 2398 |
|
| 2399 |
# Get the mesh and convert it to Muscat
|
| 2400 |
from Muscat.Bridges import CGNSBridge
|
| 2401 |
+
CGNS_tree = sample.get_mesh()
|
| 2402 |
mesh = CGNSBridge.CGNSToMesh(CGNS_tree)
|
| 2403 |
print(mesh)
|
| 2404 |
```
|