Skip to content

Commit 8ae47c4

Browse files
committed
Adapting examples to dpf 9.0.
1 parent 9cf11db commit 8ae47c4

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

examples/00-mapdl-examples/basic_dpf_example.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,16 @@
6262
###############################################################################
6363
# If you are working with a remote server, you might need to upload the ``RST``
6464
# file before working with it.
65+
# Then you can create the :class:`DPF Model <ansys.dpf.core.model.Model>`.
6566

66-
server_file_path = dpf.upload_file_in_tmp_folder(rst_path)
67+
dpf.core.make_tmp_dir_server(dpf.SERVER)
6768

68-
###############################################################################
69-
# Then you can create the :class:`DPF Model <ansys.dpf.core.model.Model>`.
70-
#
69+
if dpf.SERVER.local_server:
70+
model = dpf.Model(rst_path)
71+
else:
72+
server_file_path = dpf.upload_file_in_tmp_folder(rst_path)
73+
model = dpf.Model(server_file_path)
7174

72-
model = dpf.Model(rst_path)
7375
print(model)
7476

7577
###############################################################################

examples/00-mapdl-examples/composite_dcb.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import tempfile
5050

5151
from ansys.dpf import core as dpf
52-
from ansys.dpf.core import Model
5352
import matplotlib.pyplot as plt
5453
import numpy as np
5554
import pyvista as pv
@@ -313,17 +312,13 @@
313312
temp_directory = tempfile.gettempdir()
314313
rst_path = mapdl.download_result(temp_directory)
315314

316-
try:
317-
# ONLY IF DPF SERVER DEPLOYED WITH gRPC COMMUNICATION
318-
# Upload file to DPF server
319-
server_file_path = dpf.upload_file_in_tmp_folder(rst_path)
320-
data_src = dpf.DataSources(server_file_path)
321-
except:
322-
# Using DPF locally
323-
data_src = dpf.DataSources(rst_path)
315+
dpf.core.make_tmp_dir_server(dpf.SERVER)
324316

325-
# Generate the DPF model
326-
model = Model(data_src)
317+
if dpf.SERVER.local_server:
318+
model = dpf.Model(rst_path)
319+
else:
320+
server_file_path = dpf.upload_file_in_tmp_folder(rst_path)
321+
model = dpf.Model(server_file_path)
327322

328323
# Get the mesh of the whole model
329324
meshed_region = model.metadata.meshed_region

0 commit comments

Comments
 (0)