我有兴趣使用这里讨论的开源代码。这里讨论了框架和一些关于如何运行代码的说明。为了能够使用该代码,应该首先安装PETSc。我已经这样做了,它似乎安装正确。当我试图按照论文(第2.2节(中给出的说明运行make topopt
时,问题就出现了。在GitHub上有一个makefile_ref
,根据论文中给出的指示,我进行了以下更改:PETSC_DIR=homemyusernamepetsc
和PETSC_ARCH=arch-linux-c-debug
。运行make -d topopt
后,我得到以下错误:
GNU Make 4.2.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Updating makefiles....
Considering target file 'GNUmakefile'.
File 'GNUmakefile' does not exist.
Looking for an implicit rule for 'GNUmakefile'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.o'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.c'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.cc'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.C'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.cpp'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.p'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.f'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.F'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.m'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.r'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.s'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.S'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.mod'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.sh'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile,v'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'RCS/GNUmakefile,v'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'RCS/GNUmakefile'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 's.GNUmakefile'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'SCCS/s.GNUmakefile'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.o'.
Looking for a rule with intermediate file 'GNUmakefile.o'.
Avoiding implicit rule recursion.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.c'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.cc'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.C'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.cpp'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.p'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.f'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.F'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.m'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.r'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.s'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.S'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.mod'.
Trying pattern rule with stem 'GNUmakefile.o'.
Trying implicit prerequisite 'GNUmakefile.o,v'.
Trying pattern rule with stem 'GNUmakefile.o'.
Trying implicit prerequisite 'RCS/GNUmakefile.o,v'.
Trying pattern rule with stem 'GNUmakefile.o'.
Trying implicit prerequisite 'RCS/GNUmakefile.o'.
Trying pattern rule with stem 'GNUmakefile.o'.
Trying implicit prerequisite 's.GNUmakefile.o'.
Trying pattern rule with stem 'GNUmakefile.o'.
Trying implicit prerequisite 'SCCS/s.GNUmakefile.o'.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.c'.
Looking for a rule with intermediate file 'GNUmakefile.c'.
Avoiding implicit rule recursion.
Avoiding implicit rule recursion.
Trying pattern rule with stem 'GNUmakefile'.
Trying implicit prerequisite 'GNUmakefile.y'.
Trying pattern rule with stem 'GNUmakefile'.
.
.
.
.
.
.
.
.
.
.
Looking for a rule with intermediate file 'topopt.mod'.
Avoiding implicit rule recursion.
Avoiding implicit rule recursion.
Trying pattern rule with stem 'topopt.mod'.
Trying implicit prerequisite 'topopt.mod,v'.
Trying pattern rule with stem 'topopt.mod'.
Trying implicit prerequisite 'RCS/topopt.mod,v'.
Trying pattern rule with stem 'topopt.mod'.
Trying implicit prerequisite 'RCS/topopt.mod'.
Trying pattern rule with stem 'topopt.mod'.
Trying implicit prerequisite 's.topopt.mod'.
Trying pattern rule with stem 'topopt.mod'.
Trying implicit prerequisite 'SCCS/s.topopt.mod'.
Trying pattern rule with stem 'topopt'.
Rejecting impossible implicit prerequisite 'topopt.c'.
Trying pattern rule with stem 'topopt'.
Rejecting impossible implicit prerequisite 'topopt.cc'.
Trying pattern rule with stem 'topopt'.
Rejecting impossible implicit prerequisite 'topopt.C'.
Trying pattern rule with stem 'topopt'.
Rejecting impossible implicit prerequisite 'topopt.cpp'.
Trying pattern rule with stem 'topopt'.
Rejecting impossible implicit prerequisite 'topopt.p'.
Trying pattern rule with stem 'topopt'.
Rejecting impossible implicit prerequisite 'topopt.f'.
Trying pattern rule with stem 'topopt'.
Rejecting impossible implicit prerequisite 'topopt.F'.
Trying pattern rule with stem 'topopt'.
Rejecting impossible implicit prerequisite 'topopt.m'.
Trying pattern rule with stem 'topopt'.
Rejecting impossible implicit prerequisite 'topopt.r'.
Trying pattern rule with stem 'topopt'.
Rejecting impossible implicit prerequisite 'topopt.s'.
Trying pattern rule with stem 'topopt'.
Rejecting impossible implicit prerequisite 'topopt.S'.
Trying pattern rule with stem 'topopt'.
Rejecting impossible implicit prerequisite 'topopt.mod'.
Trying pattern rule with stem 'topopt'.
Trying implicit prerequisite 'topopt.sh'.
Looking for a rule with intermediate file 'topopt.sh'.
Avoiding implicit rule recursion.
Trying pattern rule with stem 'topopt.sh'.
Trying implicit prerequisite 'topopt.sh,v'.
Trying pattern rule with stem 'topopt.sh'.
Trying implicit prerequisite 'RCS/topopt.sh,v'.
Trying pattern rule with stem 'topopt.sh'.
Trying implicit prerequisite 'RCS/topopt.sh'.
Trying pattern rule with stem 'topopt.sh'.
Trying implicit prerequisite 's.topopt.sh'.
Trying pattern rule with stem 'topopt.sh'.
Trying implicit prerequisite 'SCCS/s.topopt.sh'.
No implicit rule found for 'topopt'.
Finished prerequisites of target file 'topopt'.
Must remake target 'topopt'.
make: *** No rule to make target 'topopt'. Stop.
上面的代码只是整个消息的一小部分(起始部分和结束部分(。
我正在Ubuntu 20.04上工作。
提前谢谢。
存在一个
makefile_ref
,根据论文中给出的说明,我进行了以下更改[…]
如果没有指定要读取的makefile的显式选项,make
实用程序将通过几个备选名称查找输入文件。CCD_ 8不是其中之一。我把"_ref";文件名的一部分作为"的助记符;参考";,从这个角度来看,目的似乎是将makefile_ref
复制到makefile
(默认情况下make
查找的文件名之一(,并修改副本以适合您的环境。
答案:
事实证明,编译GitHub上给出的拓扑优化代码并没有那么复杂。在这里,我重申了GitHub上的说明,并提供了更多细节。
要使用PETSc运行拓扑优化开源代码,首先需要安装PETSc。您应该注意,要安装PETSc,您需要安装BLAS和LAPACK库,这非常简单,说明在PETSc中给出。现在系统上已经安装了PETSc,只需从GitHub克隆TopOpt_in_PETSc。
您会发现一个名为makefile_ref
的文件,将文件名更改为makefile
,然后打开它,在代码的前两行修改路径,类似于PETSC_DIR=/home/username/petsc
和PETSC_ARCH=arch-linux-c-debug
(在我的情况下,根据您的机器可能会有所不同(。前一个命令是指向本地计算机上安装PETSc的目录的路径,后一个是PETSc构建名称。
完成上述操作后,您可以运行make topopt
,它将为您构建一个名为topopt
的可执行文件。按照论文中给出的说明,您将能够运行拓扑优化模拟。
备注:上面给出的安装说明是在ubuntu 20.04 LTS上执行的,尽管PETSc也与Windows、iOS甚至Android兼容。另一方面,TopOpt_in_PETSc是在linux上开发和实现的,可能需要进一步操作才能安装在Windows上。