Skip to content

Commit

Permalink
update solver docker and drawing pre model
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhanqun committed Feb 4, 2024
1 parent 812353c commit 9f4d19b
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 34 deletions.
2 changes: 1 addition & 1 deletion doc/source/getting-started/SERVER_SOLVER_README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Run an example on the client side
hostname = "localhost"
port = "5000"
dyna=solver.DynaSolver(hostname,port) # connect to the server
dyna=launch_dyna(ip = hostname,port = port) # connect to the server
dyna.push("./output/ball_plate.k") # push an input file
dyna.start_locally(input = "ball_plate.k",nproc=1)
Expand Down
2 changes: 1 addition & 1 deletion doc/source/getting-started/example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ you can get the Python file from ``examples/solver/ball_plate_solver.py``.
hostname = "localhost"
port = "5000"
dyna=solver.DynaSolver(hostname,port) # connect to the container
dyna=launch_dyna(ip = hostname,port = port) # connect to the container
dyna.push("./output/ball_plate.k") # push an input file
dyna.start(4) # start 4 ranks of mppdyna
dyna.run("i=ball_plate.k memory=10m ncycle=20000") # begin execution
Expand Down
2 changes: 1 addition & 1 deletion docker/pre/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Prerequisites
instructions from `this page <https://docs.docker.com/engine/install/>`_.

* Download the latest Linux release artifacts for the ``pre`` Docker container:
`linux-binaries.zip <https://github.com/ansys/pydyna/releases/download/v0.4.3/linux-binaries.zip>`_.
`linux-binaries.zip <https://github.com/ansys/pydyna/releases/download/v0.4.6/linux-binaries.zip>`_.

* Move this ZIP file to the ``docker/pre`` directory.

Expand Down
56 changes: 27 additions & 29 deletions docker/solver/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ LABEL "com.ansys.description"="Ansys MPPDYNA with gRPC server"

# install some missing stuff we want/need

RUN yum -y install openssh-clients openssh-server bind-utils sudo python3
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install grpcio
RUN python3 -m pip install grpcio-tools
RUN python3 -m pip install protobuf==4.21.0
RUN yum -y install openssh-clients openssh-server bind-utils sudo python3 unzip &>/dev/null && yum clean all

Check warning on line 16 in docker/solver/Dockerfile

View check run for this annotation

Wiz Inc. (572fc38784) / Wiz IaC Scanner

Yum install Without Version

Rule ID: 4f2689b2-3a22-4765-973f-c6eea7676cf2 Severity: Medium Resource: FROM={{centos:7}}.{{RUN yum -y install openssh-clients openssh-server bind-utils sudo python3 unzip &>/dev/null && yum clean all}} File Type: Dockerfile Expected: The package version should always be specified when using yum install Found: No version is specified in package 'sudo' Not specifying the package version can cause failures due to unanticipated changes in required packages

Check warning on line 16 in docker/solver/Dockerfile

View check run for this annotation

Wiz Inc. (572fc38784) / Wiz IaC Scanner

Yum install Without Version

Rule ID: 4f2689b2-3a22-4765-973f-c6eea7676cf2 Severity: Medium Resource: FROM={{centos:7}}.{{RUN yum -y install openssh-clients openssh-server bind-utils sudo python3 unzip &>/dev/null && yum clean all}} File Type: Dockerfile Expected: The package version should always be specified when using yum install Found: No version is specified in package 'unzip' Not specifying the package version can cause failures due to unanticipated changes in required packages

Check warning on line 16 in docker/solver/Dockerfile

View check run for this annotation

Wiz Inc. (572fc38784) / Wiz IaC Scanner

Yum install Without Version

Rule ID: 4f2689b2-3a22-4765-973f-c6eea7676cf2 Severity: Medium Resource: FROM={{centos:7}}.{{RUN yum -y install openssh-clients openssh-server bind-utils sudo python3 unzip &>/dev/null && yum clean all}} File Type: Dockerfile Expected: The package version should always be specified when using yum install Found: No version is specified in package 'bind-utils' Not specifying the package version can cause failures due to unanticipated changes in required packages

Check warning on line 16 in docker/solver/Dockerfile

View check run for this annotation

Wiz Inc. (572fc38784) / Wiz IaC Scanner

Yum install Without Version

Rule ID: 4f2689b2-3a22-4765-973f-c6eea7676cf2 Severity: Medium Resource: FROM={{centos:7}}.{{RUN yum -y install openssh-clients openssh-server bind-utils sudo python3 unzip &>/dev/null && yum clean all}} File Type: Dockerfile Expected: The package version should always be specified when using yum install Found: No version is specified in package 'python3' Not specifying the package version can cause failures due to unanticipated changes in required packages

Check warning on line 16 in docker/solver/Dockerfile

View check run for this annotation

Wiz Inc. (572fc38784) / Wiz IaC Scanner

Yum install Without Version

Rule ID: 4f2689b2-3a22-4765-973f-c6eea7676cf2 Severity: Medium Resource: FROM={{centos:7}}.{{RUN yum -y install openssh-clients openssh-server bind-utils sudo python3 unzip &>/dev/null && yum clean all}} File Type: Dockerfile Expected: The package version should always be specified when using yum install Found: No version is specified in package 'openssh-clients' Not specifying the package version can cause failures due to unanticipated changes in required packages

Check warning on line 16 in docker/solver/Dockerfile

View check run for this annotation

Wiz Inc. (572fc38784) / Wiz IaC Scanner

Yum install Without Version

Rule ID: 4f2689b2-3a22-4765-973f-c6eea7676cf2 Severity: Medium Resource: FROM={{centos:7}}.{{RUN yum -y install openssh-clients openssh-server bind-utils sudo python3 unzip &>/dev/null && yum clean all}} File Type: Dockerfile Expected: The package version should always be specified when using yum install Found: No version is specified in package 'openssh-server' Not specifying the package version can cause failures due to unanticipated changes in required packages

Check notice on line 16 in docker/solver/Dockerfile

View check run for this annotation

Wiz Inc. (572fc38784) / Wiz IaC Scanner

Multiple RUN, ADD, COPY, Instructions Listed

Rule ID: 9ab4fc4b-f836-4e3b-b82d-6b16761c9f28 Severity: Low Resource: FROM={{centos:7}}.{{RUN yum -y install openssh-clients openssh-server bind-utils sudo python3 unzip &>/dev/null && yum clean all}} File Type: Dockerfile Expected: There isn´t any RUN instruction that could be grouped Found: There are RUN instructions that could be grouped Multiple commands (RUN, Copy, And) should be grouped in order to reduce the number of layers.
RUN python3 -m pip install --upgrade pip && \
python3 -m pip install grpcio && \
python3 -m pip install grpcio-tools && \
python3 -m pip install protobuf==4.21.0
#
ENV USER mpirun
ENV HOME /home/mpirun
Expand All @@ -27,16 +27,15 @@ ENV LSTC_LICENSE_SERVER license
ENV SSHDIR ${HOME}/.ssh


RUN groupadd ${USER}
RUN useradd -g ${USER} -d ${HOME} ${USER} && \
RUN groupadd ${USER} && useradd -g ${USER} -d ${HOME} ${USER} && \
echo "${USER} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
#
RUN mkdir -p /ansys_inc/lib
RUN mkdir -p /rundir
RUN mkdir /var/run/sshd
RUN mkdir -p ${SSHDIR}
RUN chown -R ${USER}:${USER} /rundir
RUN chmod -R 755 /rundir
RUN mkdir -p /ansys_inc/lib && \
mkdir -p /rundir && \
mkdir /var/run/sshd && \
mkdir -p ${SSHDIR} && \
chown -R ${USER}:${USER} /rundir && \
chmod -R 755 /rundir
WORKDIR /rundir

# set up the runtime environment variables for
Expand Down Expand Up @@ -73,29 +72,28 @@ RUN echo "export PATH=/opt/openmpi/bin:\${PATH}" >> ${HOME}/.bashrc
#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 ssh-keygen -q -b 2048 -f ${SSHDIR}/id_rsa -N "" && \
chmod 700 ${SSHDIR} && chmod -R 600 ${SSHDIR}/id_rsa && \
echo "Host *" > ${SSHDIR}/config && \
echo " StrictHostKeyChecking no" >> ${SSHDIR}/config && \
cp ${SSHDIR}/id_rsa.pub ${SSHDIR}/authorized_keys && \
ssh-keygen -A

RUN chmod -R 600 ${SSHDIR}* && \
chown -R ${USER}:${USER} ${SSHDIR}

RUN chown -R ${USER}:${USER} ${HOME}
chown -R ${USER}:${USER} ${SSHDIR} && \
chown -R ${USER}:${USER} ${HOME}

# Copy the openmpi libraries

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
RUN unzip -qu mppdyna_docker_centos7.zip && \
rm mppdyna_docker_centos7.zip && \
mkdir -p /opt/openmpi && \
cp -r mpi/* /opt/openmpi && \
chmod -R 777 /opt/openmpi && \

# The executable will go in /ansys_inc, and the
# ifort runtime libraries in /ansys_inc/lib

RUN cp -rpu docker_dir/* /ansys_inc/
RUN chmod -R 777 /ansys_inc/
cp -rpu docker_dir/* /ansys_inc/ && \
chmod -R 777 /ansys_inc/
2 changes: 1 addition & 1 deletion docker/solver/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Prerequisites
instructions from `this page <https://docs.docker.com/engine/install/>`_.

* Download the latest Linux release artifacts for the ``solver`` Docker container:
`mppdyna_docker_centos7.zip <https://github.com/ansys/pydyna/releases/download/v0.4.3/mppdyna_docker_centos7.zip>`_.
`mppdyna_docker_centos7.zip <https://github.com/ansys/pydyna/releases/download/v0.4.6/mppdyna_docker_centos7.zip>`_.

* Move this ZIP file to the ``docker/solver`` directory.

Expand Down
12 changes: 11 additions & 1 deletion src/ansys/dyna/core/pre/graphics/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __call__(self, *args, **kwargs): # pragma: no cover
closest_disp_mesh = None
closest_dist = np.finfo(0.0).max
for disp_mesh in disp_mesh_list:
if disp_mesh.poly_data is None or disp_mesh._type == DisplayMeshType.BEAM:
if disp_mesh.poly_data is None:
continue
point, ix = disp_mesh.poly_data.ray_trace(start, end, first_point=True)
if ix.size != 0:
Expand Down Expand Up @@ -786,6 +786,16 @@ def add_to_plotter(self, plotter: Plotter):
self._poly_data, show_edges=True, scalars="colors", rgb=True, pickable=True
)
elif self._type is DisplayMeshType.BEAM:
surf = pv.PolyData(self._vertices, lines=self._facet_list)
fcolor = np.array(self.get_face_color())
colors = np.tile(fcolor, (surf.n_faces, 1))
surf["colors"] = colors
surf.disp_mesh = self
self._poly_data = surf
self._actor = plotter.add_mesh(
self._poly_data, show_edges=True, scalars="colors", rgb=True, pickable=True
)
return
lines = []
for line in self._facet_list:
coord = self._vertices[line[1]]
Expand Down
1 change: 1 addition & 0 deletions src/ansys/dyna/core/solver/dynasolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ def run(self, args):
request.b = bytes(args, "utf-8")
response = self.stub.send_request(request)
self._check_return(response)
self.tail(which=1, how=0)
return

def setlc(self, lc, value):
Expand Down

0 comments on commit 9f4d19b

Please sign in to comment.