找回密码
 注册
Simdroid-非首页
查看: 1890|回复: 24

克服comsol内存不足问题(ZZ)

  [复制链接]
发表于 2008-1-23 08:33:26 | 显示全部楼层 |阅读模式 来自 上海
转自:http://www.altsoft.co.kr/gbd/bbs/board.php?bo_table=forum_alt_dataroom&wr_id=20&sfl=wr_subject%7C%7Cwr_content&stx=gra&sop=and   


About memory monitoring


Especially in 3D modelling, extensive memory usage urges some extra precautions. The "Out of Memory"-problem occurs whenever COMSOL Multiphysics tries to allocate an array which does not fit sequentially in memory. It is common that the amount of available memory seems large enough for the array - but there may exist no continuous block of that size, due to fragmentation. If you for example look in the task manager of Windows, this may have the effect that you can't see any high memory allocation, and get "out of memory" anyway. See more about operating systems below.
In Windows XP, you only have 2 GB of virtual address space available initially for a user process. This memory space is also sometimes fragmented by shared libraries. On Linux, UNIX, and Mac, you typically get between 3-4 GB of virtual address space available for your process. This address space is usually not fragmented. Windows XP Professional x64 edition does not suffer any notable problems from memory fragmentation since the available address space is extremely large. COMSOL Multiphysics supports the option in Windows XP professional and Windows 2003 Server to have 3 GB of virtual address space available user processes. This reduces the available address space for the operating system to 1 GB. To access it you must boot the system using an additional boot parameter. The following example shows how to enable application memory tuning by adding the /3GB parameter in the boot.ini file: [boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(2)\WINNT
[operating systems]
multi(0)disk(0)rdisk(0)partition(2)\WINNT="????" /3GB
The "????" above can be the name of your operating system for example "Microsoft Windows XP Professional". Please note that the file boot.ini is critical to booting your system. The "Memory Usage" column in the Windows task manager can also be misleading, because it only shows the currently swapped portion. A better indicator of total usage can be found like this (Win2000, WinNT, Win XP):
  • Press Ctrl-Alt-Del to bring up the Task Manager.
  • Go to the "processes" tab.
  • From the View menu, choose Select Columns.
  • Select the Virtual Memory Size check box.
  • Now find the comsol.exe process that corresponds to the COMSOL Multiphysics process in the process list and look in the "VM Size" column. This shows a better value for the actual memory used.

Building memory efficient models in COMSOL Multiphysics

General
It is a delicate task to give a general rule how much memory is needed for a specific problem. It depends on

  • Number of nodes in the geometry mesh (base mesh).
  • Type of shape function, (for example 2nd order Lagrange elements). The shape function type together with the geometry mesh determines the size of computational mesh (extended mesh).
  • Number of dependent and independent variables.
  • Sparsity of system matrices. This is in turn governed by the shape of the geometry and mesh. An extended ellipsoid gives sparser matrices than a sphere. Spheres and cubes are the toughest shapes with regards to memory demand. Further, the degree of coupling between different equations affect sparsity.
From the last item above we understand that the amount of memory required to solve a problem depends on the number of non-zero entries in the Jacobian matrix, not the number of degrees of freedom. For example, for a non-isothermal flow problem coupled to the conduction-convection equation and ideal gas law equation of state, all 5 dependent variables (u, v, w, p, T) appear in all 5 equations (in 3D). Hence the Jacobian matrix will be much fuller than a simple heat conduction problem. This is also the reason why solving a thermal radiation problems often uses up a lot of memory. The contribution to the Jacobian matrix from any surface elements creates a block in the matrix which is full. Read more about the definition of Degrees of Freedom (DOF) in COMSOL Multiphysics.

Selecting Proper Solver Type
The solvers in COMSOL Multiphysics always break down each problem into the solution of one or several linear systems of equations. Thus, in all the solvers the choice between direct and iterative solvers for linear systems affects the solution time and memory requirements. The direct solvers solve a linear system by Gaussian elimination. This stable and reliable process is well suited even for for ill-conditioned systems. These solvers require less tuning and are often faster than the iterative solvers in 1D and 2D, where they are the default setting. The elimination process sometimes requires large memory resources and long computing times, an effect particularly noticeable for 3D models. If you have a symmetric system, the first action should be to check the "Symmetric matrices" checkbox in the solver settings. (Note: Symmetric in this case does not mean a symmetric geometry. Rather, it refers to the Jacobian matrix being symmetric along the diagonal.) Then change the linear solver to "Direct (SPOOLES)" or "Direct Cholesky (TAUCS)". Only a simple class of problems like Poisson-type problems have symmetric matrices (see further COMSOL Multiphysics User's Guide, section Solving the Model). The default setting for 3D calls on iterative solvers. They generally use less memory than direct solvers and are often faster in 3D. For optimal performance, though, the iterative solvers need the careful selection of a preconditioner. Some examples of preconditioners are
  • Incomplete LU
  • Algebraic and Geometric Multigrid
  • SSOR Vector
  • et.c.
For large problems, it is imperative to choose a proconditioner that is suitable for the problem type at hand. Please refer to the COMSOL Multiphysics 3.2 User's guide, section The Linear System Solver for more information.

Efficient Geometry Modeling
In general, the first step is to try to reduce the model geometry as much as possible. Often you can find symmetry planes and therefore reduce the model to 1/2 or 1/4 or even 1/8 of the original size. The memory usage does not scale linearly, rather polynomially (A*n^k, k>1), where A is a constant, n the number of degrees of freedom, and k a real number describing the polynomial order. The value of k may vary depending on the geometry dimension (1D, 2D, or 3D) and solver settings, but is always greater than one. This means that you save more than half the memory if you find a symmetry plane and cut the geometry size by half.
  • Avoid small geometry objects where they are not needed (for curved segments, use one Bézier-curve instead many small line segments, for example)
  • Also, the quality of the mesh is important if an iterative solver is used. Convergence will be faster and more robust if the element quality is high. If an angle in a mesh element corner approaches 180 degrees, the quality will be too low. This is often the case for triangular or tetrahedron elements in thin layer regions. Quad and hexahedron elements can also have low quality in some cases. If you select Mesh/Statistics, you will see the Minimum element quality. It should not be lower that 0.01. The problem can be that the triangles get very thin when they approach the sharp corners of the geometry, leading to poor element quality there.

Hardware and software settings
Virtual Memory and Swap Space
Increasing the swap file size on the system is only interesting if you can live with the notable slowness in operation that occurs as soon as the hard disk swapping starts. In many cases, hard disk swapping is not an option.
Concerning virtual memory, a normal 32 bit processor (e.g., Windows platform) can potentially allocate allocate up to 4 GB of memory, but in most practical cases only 1.5 GB due to operating system footprint (see the first paragraph of this article). This is regardless of how high you set the swap space. Some operating systems require special settings to be able to use high amounts of memory. COMSOL Multiphysics comes in an optional 64-bit version. Using a 64-bit processor with a 64-bit operating system enables you to address substantially more RAM memory than 4 GB.

Software Settings
There are several ways of increasing the available memory for the solvers.

Reducing the Java heap size will make more memory available for the solvers. When running COMSOL Multiphysics, you can decrease the maximum Java heap size. On Windows, modify the file COMSOL32/bin/comsol.opts and on UNIX/Linux/Mac OSX, modify the file COMSOL32/bin/comsol. Decrease the value of parameter MAXHEAP=256m from 256MB to a lower value, say 128, by changing to MAXHEAP=128m. By default, you get more memory available in a COMSOL Multiphysics server. Connect to the COMSOL Multiphysics server from a COMSOL Multiphysics client. You can also modify the Java heap size on a COMSOL Multiphysics server: On Windows, modify the file COMSOL32/bin/comsol.opts and on UNIX/Linux/Mac OSX, modify the file COMSOL32/bin/comsol. Decrease the value of parameter MAXHEAPSERVER=128m from 128MB to a lower value, say 64, by changing to MAXHEAPSERVER=64m. A corollary of this is that many users report that they get more free memory by running a COMSOL Multiphysics server and a COMSOL Multiphysics client on the same machine.

If you run out of memory during postprocessing, you can increase the maximum Java heap size. On Windows, modify the file COMSOL32/bin/comsol.opts and on UNIX/Linux/Mac OSX, modify the file COMSOL32/bin/comsol. Increase the value of parameter MAXHEAP=256m from 256MB to a higher value, say 512, by changing to MAXHEAP=512m. To run a COMSOL Multiphysics server and a COMSOL Multiphysics client on different computers, you need a floating network license. All COMSOL Multiphysics licenses allow you to run a COMSOL Multiphysics server and a COMSOL Multiphysics client on the same computer. If you run out of memory when saving an mph-file from the COMSOL Multiphysics graphical user interface when you are running COMSOL Multiphysics with MATLAB you might have to increase the Java heap size within MATLAB. When you are running COMSOL Multiphysics with MATLAB the Java heap within MATLAB will function like the Java heap within the COMSOL Multiphysics server. To set the Java heap size in MATLAB, create a java.opts file with the contents -Xmx256m for example, to set the maximum Java heap to 256MB. Create java.opts either in the current directory or in the directory MATLAB/bin/ARCH, where MATLAB is the MATLAB installation directory, e. g., C:\MATLAB71, and ARCH is the architecture, win32, glnx86, hpux, sol2, or Mac OSX.

[ 本帖最后由 hadrons 于 2008-1-23 08:40 编辑 ]

评分

2

查看全部评分

 楼主| 发表于 2008-1-23 08:59:56 | 显示全部楼层 来自 上海
Simdroid开发平台
在不想改变模型的情况下:
1.增加内存,windows 32位系统使用/3GB开关,或换用64位的。
2.换求解器,如直接求解器换为迭代求解器。
3.修改comsol的堆为较小点的值,如256->128。
回复 不支持

使用道具 举报

发表于 2008-1-30 22:57:02 | 显示全部楼层 来自 吉林长春
谢谢,第3条还是挺好使的
回复 不支持

使用道具 举报

发表于 2008-2-20 20:02:50 | 显示全部楼层 来自 浙江杭州
3GZB开关是什么东西?
谢谢!
回复 不支持

使用道具 举报

发表于 2008-2-21 07:19:52 | 显示全部楼层 来自 美国
正碰到这个问题
回复 不支持

使用道具 举报

 楼主| 发表于 2008-3-3 09:34:28 | 显示全部楼层 来自 上海
windows 32位操作系统的内存寻址能力是4GB,4GB以上的内存使用不了。
默认情况下内核占用的内存是2GB,这样应用程序也就只能使用2GB。/3GB开关的功能是将内核所占用的内存压缩在1GB内,这样应用程序就可以使用3GB的空间了,比原来(2GB)多了1GB。

大体就是这样。
回复 不支持

使用道具 举报

发表于 2008-11-8 13:29:37 | 显示全部楼层 来自 北京海淀
请问怎么修改comsol的堆为较小点的值,如256->128?
回复 不支持

使用道具 举报

发表于 2008-11-8 16:18:06 | 显示全部楼层 来自 大连理工大学
还有用64位的计算吧。我的机器有4G,计算时用过11G的内存情况,没有任何问题
回复 不支持

使用道具 举报

发表于 2008-11-11 22:41:59 | 显示全部楼层 来自 德国
原帖由 decay 于 2008-11-8 13:29 发表
请问怎么修改comsol的堆为较小点的值,如256->128?


我把comsol guide里面的都贴出来吧

Optimizing Memory Use

The Java engine in the graphical user interface and in the COMSOL Multiphysics server component reserves a fixed amount of memory for its heap. You might have to increase or decrease the size of the Java heap depending on the situation.
For example, to make more memory available for the solvers, you might need to decrease the Java heap size in standalone COMSOL Multiphysics or the 32-bit COMSOL Multiphysics server. In addition, always try to select a solver that minimizes memory usage (see the section “Solving the Model” in the COMSOL Multiphysics User’s Guide).
For large models you might get problems during postprocessing or when loading or saving them. In those cases you must increase the size of the Java heap. This issue is particularly true when running the 64-bit COMSOL Multiphysics server from the COMSOL Multiphysics client.

Follow this procedure to modify the Java heap size for standalone COMSOL Multiphysics: On Windows modify the file COMSOL32/bin/comsol.opts, and on UNIX/Linux/Mac OS X modify the file COMSOL32/bin/comsol. Change the value of the parameter MAXHEAP=256m from 256 MB to, say 128, by changing it to MAXHEAP=128m.
You can also modify the Java heap size on a the 32-bit COMSOL Multiphysics server in this fashion: On Windows modify the file COMSOL32/bin/comsol.opts, and on UNIX/Linux/Mac OS X modify the file COMSOL32/bin/comsol. Change the value of the parameter MAXHEAPSERVER=256m from 256 MB to, say 128, by changing it to MAXHEAPSERVER=128m.

The COMSOL Multiphysics client uses the variable MAXHEAPCLIENT to determine the Java heap size. The default value is 512MB. The 64-bit COMSOL Multiphysics server uses MAXHEAPSERVER64, which is 1024 MB by default. The MAXHEAPCLIENT and MAXHEAPSERVER64 settings are tuned for running large models on 64-bit servers from a COMSOL Multiphysics client.
To run a COMSOL Multiphysics server and a COMSOL Multiphysics client on different computers you need a floating network license. All COMSOL Multiphysics licenses allow you to run a COMSOL Multiphysics server and a COMSOL Multiphysics client on the same computer.
70 | C H A P T E R 2 : R U N N ING COM S O L
If you run out of memory when saving an FL-file from the COMSOL Multiphysics user interface when running COMSOL Multiphysics with MATLAB, you might need to increase the Java heap size within MATLAB. When running COMSOL Multiphysics with MATLAB, the Java heap within MATLAB functions like the Java heap within the COMSOL Multiphysics server. To set the Java heap size in MATLAB to a maximum of, for example, 256 MB, create a java.opts file with the contents
-Xmx256m
COMSOL Multiphysics with MATLAB automatically creates a java.opts file with heap size settings (MAXHEAPSERVER or MAXHEAPSERVER64 value) in the current directory if the JAVAOPTS variable equals on in COMSOL32/bin/comsol (UNIX/Linux/Mac OS X) or COMSOL32/bin/comsol.opts (Windows). Set the JAVAOPTS to off if you do not want COMSOL Multiphysics to create a java.opts file.
If you create a java.opts file manually, create it either in the current directory or in the directory MATLAB/bin/ARCH, where MATLAB is the MATLAB installation directory (typically C:\MATLABR7), and ARCH is the architecture (win32, glnx86, hpux, sol2, or macosx).
STACK SIZE AND THE DIRECT CHOLESKY (TAUCS) SOLVER
To analyze large problems with the Direct Cholesky (TAUCS) solver you might need to increase the size of the Java stack. On Windows, modify the file COMSOL32/bin/comsol.opts, and on UNIX/Linux/Mac OS X, modify the file COMSOL32/bin/comsol. Change the parameter STACKSIZE=2m from 2 MB to a higher value, say 4 MB, by changing it to STACKSIZE=4m.

评分

1

查看全部评分

回复 不支持

使用道具 举报

发表于 2008-11-12 14:20:26 | 显示全部楼层 来自 清华大学
本帖最后由 TBE_Legend 于 2009-3-28 11:08 编辑

good,谢了,刚好需要。


转载一下,可以解决,我已经试过了
This problem has been reported by some users of COMSOL 3.4 with MATLAB 2007b on Windows. MATLAB 2007a and earlier versions are not affected by this problem.
The problem seems to be related to 32-bit MATLAB on a dual core (or more) Windows machines.
The solution is to change how MATLAB's Java Heap size is set. When COMSOL starts with MATLAB the maximum size of the Java heap is set to 256 MB. We need to disable this and use the default Java Heap size instead. The maximum size of the Java heap can be given by providing a line in a file java.opts in the directory where MATLAB is started.
The workaround is as follows:

Try to start COMSOL with MATLAB once. It will fail but a file java.opts will be written to the COMSOL  3.4 installation directory.
Open the java.opts file, remove the line -Xmx256m and save the file.
Open the file comsol.opts in the bin directory under your COMSOL installation and change the line
  JAVAOPTS=on
to
  JAVAOPTS=off
This will ensure that a new java.opts file is not written automatically every time you start COMSOL with MATLAB and your manually edited comsol.opts will always be used.
When you use "Connect to MATLAB" from the File menu in COMSOL Multiphysics it will look for a java.opts file in your home directory. This means that you should copy the edited java.opts file to the home directory as well. This will be something like
C:\Documents and Settings\<user name>
回复 不支持

使用道具 举报

发表于 2009-3-29 17:12:30 | 显示全部楼层 来自 安徽合肥
第三条确实有用
回复 不支持

使用道具 举报

发表于 2009-3-30 15:12:03 | 显示全部楼层 来自 北京
好贴啊! 11# 6314323
回复 不支持

使用道具 举报

发表于 2009-3-30 15:12:42 | 显示全部楼层 来自 北京
很好啊
回复 不支持

使用道具 举报

发表于 2009-3-31 10:49:03 | 显示全部楼层 来自 江苏南京
急急急!!
请问怎么修改comsol的堆为较小点的值,如256->128?
回复 不支持

使用道具 举报

发表于 2009-4-13 16:03:34 | 显示全部楼层 来自 浙江杭州
同问怎么修改堆??
回复 不支持

使用道具 举报

发表于 2009-4-14 09:23:35 | 显示全部楼层 来自 广东佛山
14# smilingfly

楼主写了的啊
On Windows, modify the file COMSOL32/bin/comsol.opts and on UNIX/Linux/Mac OSX, modify the file COMSOL32/bin/comsol. Decrease the value of parameter MAXHEAP=256m from 256MB to a lower value, say 128, by changing to MAXHEAP=128m
修改COMSOL32/bin/comsol.opts 里面的MAXHEAP的值
回复 不支持

使用道具 举报

发表于 2009-5-18 14:13:10 | 显示全部楼层 来自 陕西西安
还可应用外存
回复 不支持

使用道具 举报

发表于 2009-7-31 16:03:07 | 显示全部楼层 来自 意大利
太好了,总是碰到这样的问题!
回复 不支持

使用道具 举报

发表于 2009-8-14 16:47:38 | 显示全部楼层 来自 江苏南京
很好,很有用,谢谢分享!
回复 不支持

使用道具 举报

发表于 2011-11-22 20:17:21 | 显示全部楼层 来自 重庆沙坪坝区
有限资源条件下确实是比较有用!学习了!
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-4-27 16:49 , Processed in 0.051816 second(s), 14 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表