文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > 高等教育 > 工学 > matlab有限元计算程序
侵权投诉

matlab有限元计算程序

简要介绍资料的主要内容,以获得更多的关注

function [T,fail,meth]=DefineBases(T,ntries)

% [T,fail]=DefineBases(T,ntries)
%
% This function implements a heuristic algorithm to
% define the list of bases for the triangles in
% the mesh T. If it is successful, it adds the
% field Bases to T; T.Bases(i) is the index of
% the base of triangle i in T.Edges.
%
% The input ntries determines how many times
% the heuristic algorithm is attempted; the default
% is ntries=4. (There is a random element to
% the algorithm, so it can be attempted repeatedly.
% The probability of success increases with ntries,
% but obviously so does the execution time.)
%
% The output flag fail is 0 if the algorithm succeeds
% (so that T.Bases is added to T) and nonzero if
% the algorithm fails (in which case T is unchanged).
%
% T.Bases is used by the newest node refinement algorithm.
% See LocalRefine1 for details.

% The following algorithm is based on a linear programming
% formulation of the problem. If the linear program
% has an integer-valued solution, then DefineBases succeeds.
% However, this is not guaranteed. The code tries four
% non-random cost functions and then ntries-4 random
% cost functions, if necessary.

if nargin<2
ntries=4;
end

Nt=size(T.Elements,1);
Ne=size(T.Edges,1);

% First, get the triangle-edge incidence matrix

A=TriEdgeIncidence(T);

% Define the right-hand side for the LP constraints:

b=ones(Nt,1);

% Get the lengths of the edges in T:

c=zeros(Ne,1);
for i=1:Ne
c(i,1)=norm(T.Nodes(T.Edges(i,1),:)-T.Nodes(T.Edges(i,2),:));
end

% Weight boundary edges by half:

i=find(T.EdgeEls(:,2)<=0);
c(i)=0.5*c(i);

% Define ntries different cost functions.
%
% 1: Maximize the total length of the chosen bases.
% 2: Maximize the number of bases chosen.
% 3: Minimize the total length of the chosen bases.
% 4: Minimize the number of bases chosen.
% 5,6,...,ntries: random

C=[c,ones(Ne,1),-c,-ones(Ne,1)];
for i=5:ntries
C=[C,rand(Ne,1)];
end

% Invoke the simplex method up to ntries times, looking
% for an integer-valued solution:

fail=1;
for i=1:ntries
x=rsimplex(C(:,i),A,b,zeros(Ne,1),ones(Ne,1));
if norm(x-round(x))<100*eps*norm(x)
fail=0;
meth=i;
break
end
end

if fail
meth=0;
return
else

% An integer-valued solution was found.
% x now indicates the edges chosen as bases. Loop through
% the triangles and record the base of each:

T.Bases=zeros(Nt,1);
for i=1:Nt
e=abs(T.Elements(i,:));
T.Bases(i)=e(find(x(e)==1));
end

end

return

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function A=TriEdgeIncidence(T)

% A=TriEdgeIncidence(T)
%
% This function computes the triangle-edge incidence
% matrix of the mesh T. The result is an Nt by Ne
% sparse 0-1 matrix.

Nt=size(T.Elements,1);
Ne=size(T.Edges,1);
A=sparse(Nt,Ne);

for i=1:Nt
A(i,abs(T.Elements(i,

第1页

你可能喜欢

热门文档

相关文档

  • MATLAB 有限元计算程序3

    MATLAB 有限元计算程序3_工学_高等教育_教育专区。有限元 matlab 程序设计function exam7_1 % 本程序为第七章的第一个算例,采用薄板矩形单元计算矩形板的弯曲 ...

  • matlab有限元计算程序6

    关键词:力学matlab有限元有限单元法实例 同系列文档 朝鲜历届领导人资料 朝鲜现状 为什么南北朝鲜会分裂 朝鲜的近代史 matlab有限元计算程序5...

  • matlab计算有限元程序 (2)

    matlab计算有限元程序 (4) 2页 免费 MATLAB 有限元计算程序3 6页 2财富值 matlab计算有限元程序 (3) 1页 免费 MATLAB 有限元计算程序1 4页 2财富值...

  • matlab有限元法计算分析程序编写

    matlab有限元法计算分析程序编写_机械/仪表_工程科技_专业资料。matlab应用有限元法计算分析程序编写 结构参数输入,包括 1)节点坐标值 2)单元类型以及连接信息 3)...

  • MATLAB 有限元计算程序4

    有限元 matlab 程序设计有限元 matlab 程序设计隐藏>> function exam8_1 % 本程序为第八章的第一个算例,采用平面梁单元计算两铰抛物线拱的自由振动特性 % ...

  • matlab有限元计算程序5

    MATLAB 有限元计算程序3 6页 2财富值搜你所想,读你所爱 拒绝盗版,营造绿色文库 如要投诉违规内容,请到百度文库投诉中心;如要提出功能问题或意见建议,请点击...

  • Matlab 有限元法计算分析程序编写

    Matlab 有限元法计算分析程序编写_交通运输_工程科技_专业资料。Matlab 有限元法计算分析程序编写有限元法计算分析程序编写 结构参数输入,包括 1)节点坐标值 2)...

  • 梁单元有限元计算程序(matlab)

    梁单元的有限元计算程序%此程序计算杆的总刚度矩阵及节点位移,分五步完成:输入各单元数据、计算单元刚度矩阵 %组集总...

  • Matlab与有限元程序设计

    Matlab与有限元程序设计_工学_高等教育_教育专区。Matlab与有限元程序设计...编制的 聚合 物 口 模挤 出计 算机模 有限元程序设计 的方 法在 开 始...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email