Skip to content

Commit 78ddc45

Browse files
committed
Merge remote-tracking branch 'origin/updatedocker'
2 parents 69af9b9 + 7cc97fa commit 78ddc45

File tree

12 files changed

+189
-92
lines changed

12 files changed

+189
-92
lines changed

README.rst

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ Start by cloning the repository
111111
.. code::
112112
113113
git clone https://github.com/pyansys/pyDyna
114-
115-
and copy the required files.
114+
cd pyDyna
115+
pip install -e .
116116
117117
Install in offline mode
118118
^^^^^^^^^^^^^^^^^^^^^^^
@@ -123,17 +123,17 @@ archive from the `Releases Page <https://github.com/pyansys/pydyna/releases>`_ f
123123
corresponding machine architecture.
124124

125125
Each wheelhouse archive contains all the Python wheels necessary to install PyDyna from scratch on Windows
126-
and Linux, from Python 3.6,3.8 and 3.9. You can install this on an isolated system with a fresh Python
126+
and Linux, from Python 3.7 to 3.10. You can install this on an isolated system with a fresh Python
127127
installation or on a virtual environment.
128128

129129
For example, on Linux with Python 3.8, unzip the wheelhouse archive and install it with:
130130

131131
.. code:: bash
132132
133-
unzip ansys-dyna-core-v0.3.dev0-wheelhouse-Linux-3.8.zip wheelhouse
133+
unzip ansys-dyna-core-v0.3.dev0-wheelhouse-Linux-3.8.zip -d wheelhouse
134134
pip install ansys-dyna-core -f wheelhouse --no-index --upgrade --ignore-installed
135135
136-
If you are on Windows with Python 3.9, unzip the corresponding wheelhouse to a wheelhouse directory
136+
If you are on Windows with Python 3.8, unzip the corresponding wheelhouse to a wheelhouse directory
137137
and install using the preceding command.
138138

139139
Consider installing using a `virtual environment <https://docs.python.org/3/library/venv.html>`_.
@@ -176,8 +176,8 @@ Here is a basic pre-processing example:
176176
icfd_solution = DynaSolution(hostname)
177177
# Import the initial mesh data(nodes and elements)
178178
fns = []
179-
path = examples.cylinder_flow + os.sep
180-
fns.append(path + "cylinder_flow.k")
179+
path = os.getcwd()+os.sep
180+
fns.append(path+"cylinder_flow.k")
181181
icfd_solution.open_files(fns)
182182
# Set total time of simulation
183183
icfd_solution.set_termination(termination_time=100)
@@ -224,7 +224,13 @@ Here is a basic pre-processing example:
224224
icfd.add(meshvol)
225225
226226
icfd_solution.create_database_binary(dt=1)
227-
icfd_solution.save_file()
227+
serverpath = icfd_solution.save_file()
228+
serveroutfile = '/'.join((serverpath,"cylinder_flow.k"))
229+
downloadpath = os.path.join(os.getcwd(), "output")
230+
if not os.path.exists(downloadpath):
231+
os.makedirs(downloadpath)
232+
downloadfile = os.path.join(downloadpath,"cylinder_flow.k")
233+
icfd_solution.download(serveroutfile,downloadfile)
228234
229235
For more examples, visit https://dyna.docs.pyansys.com/version/stable/examples/index.html
230236

File renamed without changes.

docker/README.rst renamed to docker/pre/README.rst

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Create your own pydyna-pre service docker container
44
The pydyna-pre service Docker containers can be easily built by following
55
these steps.
66

7-
Inside this folder, the instructions (i.e. ``Dockerfile.*`` files) for
7+
Inside this folder, the instructions (i.e. ``Dockerfile`` files) for
88
building the pydyna-pre service Docker containers are made available.
99

1010
* ``Dockerfile``: this file builds the Linux-based Docker image.
@@ -15,20 +15,29 @@ Prerequisites
1515
* Ensure that ``docker`` is installed in your machine.
1616
If you do not have ``docker`` available, please refer to the
1717
`official Docker site <https://www.docker.com>`_.
18+
Note that the container can also be started on Windows if the Docker Desktop has been installed.
19+
How to install the Docker Desktop: https://docs.docker.com/desktop/install/windows-install/
1820

19-
* Download the latest release artifacts for the Linux
20-
Docker container. You can do this as follows:
21+
* Download the latest release artifacts. You can do this as follows:
2122

2223
* Latest Linux artifacts: `linux-binaries.zip <https://github.com/ansys/pydyna/releases/download/v0.2.1/linux-binaries.zip>`_
2324

24-
* Move these ``.zip`` files to the current location (i.e. ``<repository-root-folder>/docker``).
25+
* Move these ``.zip`` files to the current location (i.e. ``<repository-root-folder>/docker/pre``).
26+
27+
Starting the docker container
28+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29+
30+
There are two ways to start docker container.
31+
32+
1.bulid image and run container
33+
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2534

2635
Building the Docker images
27-
^^^^^^^^^^^^^^^^^^^^^^^^^^
36+
::::::::::::::::::::::::::
2837

2938
In order to build your images, follow the next instructions:
3039

31-
* Locate yourself at ``<repository-root-folder>/docker`` in your terminal.
40+
* Locate yourself at ``<repository-root-folder>/docker/pre`` in your terminal.
3241
* Run the following Docker command:
3342

3443
.. code:: bash
@@ -52,13 +61,13 @@ In order to build your images, follow the next instructions:
5261
>>> ...... ...... ............ .............. ......
5362
5463
Run the image as a container
55-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
64+
::::::::::::::::::::::::::::
5665

5766
* Run the following Docker command:
5867

5968
.. code:: bash
6069
61-
docker run -d -p 50051:50051 ghcr.io/ansys/ls-pre .
70+
docker run -d -p 50051:50051 ghcr.io/ansys/ls-pre
6271
6372
* Check that the image has been created successfully.
6473

@@ -67,4 +76,19 @@ Run the image as a container
6776
6877
6978
>>> CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
70-
>>> c77ffd67f9fa ghcr.io/ansys/ls-pre "python3 ./linux-bin…" 7 seconds ago Up 7 seconds 0.0.0.0:50051->50051/tcp, :::50051->50051/tcp hardcore_margulis
79+
>>> c77ffd67f9fa ghcr.io/ansys/ls-pre "python3 ./linux-bin…" 7 seconds ago Up 7 seconds 0.0.0.0:50051->50051/tcp, :::50051->50051/tcp hardcore_margulis
80+
81+
82+
2.Start the container from docker-compose.yml file
83+
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
84+
85+
Make sure the docker compose have been installed on your computer.
86+
For more information: https://docs.docker.com/compose/install/
87+
88+
* Locate yourself at ``<repository-root-folder>/docker/pre`` in your terminal.
89+
* Run the following Docker command:
90+
91+
.. code:: bash
92+
93+
docker compose up -d
94+

docker/pre/docker-compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: "3.8"
2+
services:
3+
dyna-pre:
4+
build: ./
5+
ports:
6+
- 50051:50051
File renamed without changes.

examples/Implicit/camry_rc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
ContactSurface,
2626
DOF,
2727
OffsetType,
28-
ImplicitAnalysis,
28+
AnalysisType
2929
)
3030
from ansys.dyna.core.pre.dynamaterial import (
3131
MatNull,
@@ -80,7 +80,7 @@
8080
###############################################################################
8181
# We can then use the implicit analysis methods in DynaMech class to define
8282
# the IMILICIT control cards.
83-
camry = DynaMech()
83+
camry = DynaMech(analysis=AnalysisType.EXPLICIT)
8484
camry_solution.add(camry)
8585

8686
###############################################################################

examples/Thermal/thermal_stress.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
ThermalAnalysisType,
1919
SolidPart,
2020
SolidFormulation,
21-
NodeSet
21+
NodeSet,
22+
AnalysisType
2223
)
2324
from ansys.dyna.core.pre.dynamaterial import MatElasticPlasticThermal
2425
from ansys.dyna.core.pre import examples
@@ -53,7 +54,7 @@
5354
###############################################################################
5455
# To invoke the transient thermal solver, the thermal analysis type in CONTROL_SOLUTION is
5556
# being set to 2 by ThermalAnalysisType.TRANSIENT.
56-
ts = DynaMech()
57+
ts = DynaMech(analysis=AnalysisType.EXPLICIT)
5758
solution.add(ts)
5859

5960
tanalysis = ThermalAnalysis()

src/ansys/dyna/core/pre/dynabase.py

Lines changed: 60 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ def __init__(self):
218218
self.constraints = Constraint()
219219
self.contacts = ContactGroup()
220220
self.entities = []
221+
self.have_accuracy = False
222+
self.have_energy = False
223+
self.have_hourglass = False
224+
self.have_bulk_viscosity = False
225+
self.have_control_shell = False
221226

222227
def get_stub():
223228
"""Get the stub of this DynaBase object."""
@@ -280,16 +285,19 @@ def set_accuracy(
280285
bool
281286
"True" when successful, "False" when failed
282287
"""
283-
ret = self.stub.CreateControlAccuracy(
284-
ControlAccuracyRequest(
285-
osu=objective_stress_updates.value,
286-
inn=invariant_node_number.value,
287-
pidosu=partsetid_for_objective_stress_updates,
288-
iacc=implicit_accuracy_flag.value,
289-
exacc=explicit_accuracy_flag.value,
288+
ret = True
289+
if not self.have_accuracy:
290+
ret = self.stub.CreateControlAccuracy(
291+
ControlAccuracyRequest(
292+
osu=objective_stress_updates.value,
293+
inn=invariant_node_number.value,
294+
pidosu=partsetid_for_objective_stress_updates,
295+
iacc=implicit_accuracy_flag.value,
296+
exacc=explicit_accuracy_flag.value,
297+
)
290298
)
291-
)
292-
logging.info("Control Accuracy Created...")
299+
self.have_accuracy = True
300+
logging.info("Control Accuracy Created...")
293301
return ret
294302

295303
def set_energy(
@@ -324,16 +332,19 @@ def set_energy(
324332
bool
325333
"True" when successful, "False" when failed
326334
"""
327-
ret = self.stub.CreateControlEnergy(
328-
ControlEnergyRequest(
329-
hgen=hourglass_energy.value,
330-
rwen=rigidwall_energy.value,
331-
slnten=sliding_interface_energy.value,
332-
rylen=rayleigh_energy.value,
333-
irgen=initial_reference_geometry_energy.value,
335+
ret = True
336+
if not self.have_energy:
337+
ret = self.stub.CreateControlEnergy(
338+
ControlEnergyRequest(
339+
hgen=hourglass_energy.value,
340+
rwen=rigidwall_energy.value,
341+
slnten=sliding_interface_energy.value,
342+
rylen=rayleigh_energy.value,
343+
irgen=initial_reference_geometry_energy.value,
344+
)
334345
)
335-
)
336-
logging.info("Control Energy Created...")
346+
self.have_energy = True
347+
logging.info("Control Energy Created...")
337348
return ret
338349

339350
def set_output(
@@ -385,8 +396,11 @@ def set_hourglass(self, controltype=HourglassControl.STANDARD_VISCOSITY_FORM, co
385396
bool
386397
"True" when successful, "False" when failed
387398
"""
388-
ret = self.stub.CreateControlHourgalss(ControlHourglassRequest(ihq=controltype.value, qh=coefficient))
389-
logging.info("Control Hourglass Created...")
399+
ret = True
400+
if not self.have_hourglass:
401+
ret = self.stub.CreateControlHourgalss(ControlHourglassRequest(ihq=controltype.value, qh=coefficient))
402+
self.have_hourglass = True
403+
logging.info("Control Hourglass Created...")
390404
return ret
391405

392406
def set_bulk_viscosity(
@@ -411,14 +425,17 @@ def set_bulk_viscosity(
411425
bool
412426
"True" when successful, "False" when failed
413427
"""
414-
ret = self.stub.CreateControlBulkViscosity(
415-
ControlBulkViscosityRequest(
416-
q1=quadratic_viscosity_coeff,
417-
q2=linear_viscosity_coeff,
418-
type=bulk_viscosity_type.value,
428+
ret = True
429+
if not self.have_bulk_viscosity:
430+
ret = self.stub.CreateControlBulkViscosity(
431+
ControlBulkViscosityRequest(
432+
q1=quadratic_viscosity_coeff,
433+
q2=linear_viscosity_coeff,
434+
type=bulk_viscosity_type.value,
435+
)
419436
)
420-
)
421-
logging.info("Control Bulk Viscosity Created...")
437+
self.have_bulk_viscosity = True
438+
logging.info("Control Bulk Viscosity Created...")
422439
return ret
423440

424441
def set_init_temperature(self, temp=0):
@@ -482,20 +499,23 @@ def create_control_shell(
482499
bool
483500
"True" when successful, "False" when failed
484501
"""
485-
ret = self.stub.CreateControlShell(
486-
ControlShellRequest(
487-
wrpang=wrpang,
488-
esort=esort,
489-
irnxx=irnxx,
490-
istupd=istupd,
491-
theory=theory,
492-
bwc=bwc,
493-
miter=miter,
494-
proj=proj,
495-
irquad=irquad,
502+
ret = True
503+
if not self.have_control_shell:
504+
ret = self.stub.CreateControlShell(
505+
ControlShellRequest(
506+
wrpang=wrpang,
507+
esort=esort,
508+
irnxx=irnxx,
509+
istupd=istupd,
510+
theory=theory,
511+
bwc=bwc,
512+
miter=miter,
513+
proj=proj,
514+
irquad=irquad,
515+
)
496516
)
497-
)
498-
logging.info("Control Shell Created...")
517+
self.have_control_shell = True
518+
logging.info("Control Shell Created...")
499519
return ret
500520

501521
def create_control_solid(

0 commit comments

Comments
 (0)