diff --git a/doc/source/getting-started/SERVER_PRE_README.rst b/doc/source/getting-started/SERVER_PRE_README.rst new file mode 100644 index 000000000..88c0b793a --- /dev/null +++ b/doc/source/getting-started/SERVER_PRE_README.rst @@ -0,0 +1,52 @@ +Start pydyna pre server locally +=============================== + +There are two ways to start the pydyna pre server + +1.Start server manually +----------------------- + +* Run this command in the current folder: + + .. code:: console + + python kwserver.py + +2.Start server automatically +---------------------------- + +Start server on Windows +~~~~~~~~~~~~~~~~~~~~~~~ + +#. Set environment variable: + + .. code:: bash + + Variable name: ANSYS_PYDYNA_PRE_SERVER_PATH + variable value: + + example of variable value: C:\pydyna\ansys-pydyna-pre-server + +Start server on Linux +~~~~~~~~~~~~~~~~~~~~~ + +#. Set environment variable: + + .. code:: bash + + ANSYS_PYDYNA_PRE_SERVER_PATH= + + example of variable value: /home/lstc/ansys-pydyna-pre-server + +Run an example on the client side +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + .. code:: bash + + hostname = "localhost" + if len(sys.argv) > 1: + hostname = sys.argv[1] + solution = DynaSolution(hostname) + ...... + +#. The function of DynaSolution() will start the pre server automatically. \ No newline at end of file diff --git a/doc/source/getting-started/SERVER_SOLVER_README.rst b/doc/source/getting-started/SERVER_SOLVER_README.rst new file mode 100644 index 000000000..23541cbdc --- /dev/null +++ b/doc/source/getting-started/SERVER_SOLVER_README.rst @@ -0,0 +1,80 @@ +Start pydyna solver server locally +================================== + +Prerequisites +------------- + +Start server on Windows +~~~~~~~~~~~~~~~~~~~~~~~ + +#. If you want to start the server on Windows,please ensure that you have installed the ANSYS locally. + +Start server on Linux(Centos7) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +#. If you want to start the server on Linux,please ensure that you have installed the openmpi package. + + .. code:: bash + + yum install openmpi3 openmpi3-dev + +#. set environment variable for openmpi + + .. code:: bash + + export LD_LIBRARY_PATH=/usr/lib64/openmpi3/lib:$LD_LIBRARY_PATH + export PATH=/usr/lib64/openmpi3/bin:$PATH + + +There are two ways to start the pydyna solver server +==================================================== + +1.Start server manually +----------------------- + +* Run this command in the current folder: + + .. code:: console + + python server.py + +2.Start server automatically +---------------------------- + +Start server on Windows +~~~~~~~~~~~~~~~~~~~~~~~ + +#. Set environment variable: + + .. code:: bash + + Variable name: ANSYS_PYDYNA_SOLVER_SERVER_PATH + variable value: + + example of variable value: C:\pydyna\ansys-pydyna-solver-server + +Start server on Linux(Centos7) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +#. Set environment variable: + + .. code:: bash + + ANSYS_PYDYNA_SOLVER_SERVER_PATH= + + example of variable value: /home/lstc/ansys-pydyna-solver-server + +Run an example on the client side +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + .. code:: bash + + import ansys.dyna.core.solver as solver + + hostname = "localhost" + port = "5000" + dyna=solver.DynaSolver(hostname,port) # connect to the server + dyna.push("./output/ball_plate.k") # push an input file + dyna.start_locally(input = "ball_plate.k",nproc=1) + +#. The function of solver.DynaSolver() will start the solver server automatically. \ No newline at end of file diff --git a/doc/source/getting-started/index.rst b/doc/source/getting-started/index.rst index dbaa2069c..98f9e43a8 100644 --- a/doc/source/getting-started/index.rst +++ b/doc/source/getting-started/index.rst @@ -80,15 +80,23 @@ with these commands: If you're on Windows with Python 3.8, unzip the wheelhouse archive to a ``wheelhouse`` directory and install PyDYNA using the preceding command. -Install the server ------------------- -Currently, PyDYNA server is only supported withing a Docker container. -Future releases support launching the servers directly on local machines as well. +Run PyDYNA Server locally +------------------------- +Launching the servers directly on local machines. + +.. include:: ./SERVER_PRE_README.rst + +.. include:: ./SERVER_SOLVER_README.rst + +Run PyDYNA Server in a Docker container +--------------------------------------- +PyDYNA server can be run in a Docker container. .. include:: ../../../docker/pre/README.rst .. include:: ../../../docker/solver/README.rst + .. LINKS .. _pydyna_pypi: https://pypi.org/projects/ansys-dyna-core/ .. _pydyna_repo: https://github.com/ansys/pydyna/ diff --git a/docker/solver/Dockerfile b/docker/solver/Dockerfile index 4bdfbb058..41f4228c3 100644 --- a/docker/solver/Dockerfile +++ b/docker/solver/Dockerfile @@ -24,7 +24,7 @@ ENV HOME /home/mpirun ENV LD_LIBRARY_PATH /ansys_inc/lib ENV LSTC_LICENSE network ENV LSTC_LICENSE_SERVER license -ENV SSHDIR ${HOME}/.ssh/ +ENV SSHDIR ${HOME}/.ssh RUN groupadd ${USER} @@ -66,10 +66,18 @@ CMD ["/usr/sbin/sshd", "-D"] ENV PATH /opt/openmpi/bin:${PATH} RUN echo "export PATH=/opt/openmpi/bin:\${PATH}" >> ${HOME}/.bashrc -ADD ssh/config ${SSHDIR}/config -ADD ssh/id_rsa ${SSHDIR}/id_rsa -ADD ssh/id_rsa.pub ${SSHDIR}/id_rsa.pub -ADD ssh/id_rsa.pub ${SSHDIR}/authorized_keys +#ADD ssh/config ${SSHDIR}/config +#ADD ssh/id_rsa ${SSHDIR}/id_rsa +#ADD ssh/id_rsa.pub ${SSHDIR}/id_rsa.pub +#ADD ssh/id_rsa.pub ${SSHDIR}/authorized_keys +#RUN ssh-keygen -A + + +RUN ssh-keygen -q -b 2048 -f ${SSHDIR}/id_rsa -N "" +RUN chmod 700 ${SSHDIR} && chmod -R 600 ${SSHDIR}/id_rsa +RUN echo "Host *" > ${SSHDIR}/config +RUN echo " StrictHostKeyChecking no" >> ${SSHDIR}/config +RUN cp ${SSHDIR}/id_rsa.pub ${SSHDIR}/authorized_keys RUN ssh-keygen -A RUN chmod -R 600 ${SSHDIR}* && \ @@ -79,11 +87,15 @@ RUN chown -R ${USER}:${USER} ${HOME} # Copy the openmpi libraries -RUN mkdir -p /opt -COPY mpi /opt/openmpi +RUN yum install -y unzip +COPY mppdyna_docker_centos7.zip . +RUN unzip -qu mppdyna_docker_centos7.zip && rm mppdyna_docker_centos7.zip +RUN mkdir -p /opt/openmpi +RUN cp -r mpi/* /opt/openmpi +RUN chmod -R 777 /opt/openmpi # The executable will go in /ansys_inc, and the # ifort runtime libraries in /ansys_inc/lib -COPY docker_dir /ansys_inc -RUN chmod 755 /ansys_inc/ \ No newline at end of file +RUN cp -rpu docker_dir/* /ansys_inc/ +RUN chmod -R 777 /ansys_inc/ diff --git a/docker/solver/README.rst b/docker/solver/README.rst index 165593308..94c018088 100644 --- a/docker/solver/README.rst +++ b/docker/solver/README.rst @@ -27,17 +27,14 @@ Prerequisites * Download the latest Linux release artifacts for the ``solver`` Docker container: `mppdyna_docker_centos7.zip `_. -* Move this ZIP file to the ``docker/solver`` directory and unzip it in the same directory. +* Move this ZIP file to the ``docker/solver`` directory. The files in this folder should look similar to this: .. code:: bash - >>> Dockerfile README.rst do_build docker-compose.yml docker_dir mpi mppdyna_docker_centos7.zip + >>> Dockerfile README.rst docker-compose.yml mppdyna_docker_centos7.zip -* Within docker_dir, there is a file called mppdyna. This file is the executable to run. It can be - any executable (SMP, MPP) or revision and branch. To run a given file, the name shall be changed to - mppdyna and copied inside docker_dir. Once all prerequisites are met, you can build the Docker image for the ``solver`` service. @@ -52,7 +49,7 @@ To build the Docker image for the ``solver`` service, perform these steps: .. code:: bash - ./do_build + docker build -t dyna_solver_v04 . #. Check that the image has been built successfully by running this command: @@ -70,15 +67,20 @@ To build the Docker image for the ``solver`` service, perform these steps: >>> ...... ...... ............ .............. ...... -Run the image as a container -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Start the container from a ``docker-compose.yml`` file +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Perform these steps to run the image for the ``solver`` service as a container: +Alternatively, you can start the container for the ``pre`` service from a +``docker-compose.yml`` file. + +#. Ensure that Docker Compose has been installed on your computer. If Docker Compose is not + installed, see `Overview of installing Docker Compose `_ + in the Docker documentation. #. In the ``docker-compose.yml`` file, replace ```` with the correct license server hosting the LS-DYNA license. -#. Run this Docker command: +#. In your terminal, go to the ``docker/solver`` directory and run this Docker command: .. code:: bash diff --git a/docker/solver/do_build b/docker/solver/do_build deleted file mode 100644 index adfa4078a..000000000 --- a/docker/solver/do_build +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# -# Do some basic ssh setup -# -rm -rf ssh -mkdir ssh -ssh-keygen -q -b 2048 -f ssh/id_rsa -N "" -echo "Host *" > ssh/config -echo " StrictHostKeyChecking no" >> ssh/config -# -chmod -R 755 * -# -# Build container -# -docker build -t dyna_solver_v04 . diff --git a/docker/solver/docker-compose.yml b/docker/solver/docker-compose.yml index 0eef2a2fa..6c651b7cd 100644 --- a/docker/solver/docker-compose.yml +++ b/docker/solver/docker-compose.yml @@ -1,7 +1,8 @@ version: "3.3" +name: "dyna" services: dyna: - image: dyna_solver_v04 + build: ./ networks: - dyna_internal volumes: @@ -14,7 +15,7 @@ services: mode: ingress user: mpirun environment: - - LSTC_LICENSE_SERVER= + - LSTC_LICENSE_SERVER=lvrpanda.ansys.com entrypoint: ["/ansys_inc/server.py","dyna"] networks: dyna_internal: \ No newline at end of file