function lambda = c0P2(h)
%% Mesh
[node,elem] = squarequadmesh([,,,],h);
elem = elem(:,[,,,]);
showmesh(node,elem);
findnode(node);
findquadelem(node,elem);
%% Construct Data Structure
[elem2dof,edge,inDof] = c0dofP2(elem);
elem2dof=double(elem2dof);
N = size(node,); NT = size(elem,);
Ndof = N+NT+size(edge,);
A=sparse(Ndof,Ndof);
B=sparse(Ndof,Ndof);
%% Assemble stiffness matrix
% Since Dphi_i*Dphi_j is quadratic,
% numerical quadrature rule is used here
option.quadorder = ; % default order
[pts,weight] = quadquadpts(option.quadorder);
pts=pts*-;
x=pts(:,);y=pts(:,);
h1=h/;h2=h1;
area=h2*h1;
%% Assemble Matrix
for i=:
for j=i:
DuDv=area*(Dxphi(x,y,h1,i).*Dxphi(x,y,h1,j)...
+Dyphi(x,y,h2,i).*Dyphi(x,y,h2,j))'*weight;
uv=area*(phi(x,y,i).*phi(x,y,j))'*weight;
if i==j
A = A + sparse(elem2dof(:,i),elem2dof(:,j),DuDv,Ndof,Ndof);
B = B + sparse(elem2dof(:,i),elem2dof(:,j),uv,Ndof,Ndof);
else
A = A + sparse([elem2dof(:,i);elem2dof(:,j)],...
[elem2dof(:,j);elem2dof(:,i)],DuDv,Ndof,Ndof);
B = B + sparse([elem2dof(:,i);elem2dof(:,j)],...
[elem2dof(:,j);elem2dof(:,i)],uv,Ndof,Ndof);
end
end
end
%% Solve Ax = lambda Bx, and its first solution is *pi^
lambda=eigs(A(inDof,inDof),B(inDof,inDof),,'sm');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% subfunction Dxphi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function s = Dxphi(xi,eta,L1,i) % gradient of basis phi for x
switch i
case
s = (eta.*(.*xi - ).*(eta - ))/(*L1);
case
s = (eta.*(.*xi + ).*(eta - ))/(*L1);
case
s = (eta.*(.*xi + ).*(eta + ))/(*L1);
case
s = (eta.*(.*xi - ).*(eta + ))/(*L1);
case
s = -(eta.*xi.*(eta - ))/L1;
case
s = -((eta.^ - ).*(*xi + ))/(*L1);
case
s = -(eta.*xi.*(eta + ))/L1;
case
s = -((eta.^ - ).*(.*xi - ))/(*L1);
case
s = (*xi.*(eta.^ - ))/L1;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% subfunction Dxphi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function s = Dyphi(xi,eta,L2,i) % gradient of basis phi for y
switch i
case
s = (xi.*(.*eta - ).*(xi - ))/(*L2);
case
s = (xi.*(.*eta - ).*(xi + ))/(*L2);
case
s = (xi.*(.*eta + ).*(xi + ))/(*L2);
case
s = (xi.*(.*eta + ).*(xi - ))/(*L2);
case
s = -((.*eta - ).*(xi.^ - ))/(*L2);
case
s = -(eta.*xi.*(xi + ))/L2;
case
s =-((*eta + ).*(xi.^ - ))/(*L2);
case
s = -(eta.*xi.*(xi - ))/L2;
case
s = (*eta.*(xi.^ - ))/L2;
end
end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% subfunction phi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function s = phi(xi,eta,i) % gradient of basis phi
switch i
case
s = (eta.*xi.*(eta - ).*(xi - ))/;
case
s = (eta.*xi.*(eta - ).*(xi + ))/;
case
s = (eta.*xi.*(eta + ).*(xi + ))/;
case
s = (eta.*xi.*(eta + ).*(xi - ))/;
case
s = -(eta.*(xi.^ - ).*(eta - ))/;
case
s = -(xi.*(eta.^ - ).*(xi + ))/;
case
s = -(eta.*(xi.^ - ).*(eta + ))/;
case
s = -(xi.*(eta.^ - ).*(xi - ))/;
case
s = (eta.^ - ).*(xi.^ - );
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end

lambda = c0P2(h)

 function [elem2dof,edge,inDof] = c0dofP2(elem)
totalEdge=sort([elem(:,[,]);elem(:,[,]);elem(:,[,]);elem(:,[,])],);
[edge, i2, j] = myunique(totalEdge);
N = max(elem(:));
NT = size(elem,);
NE = size(edge,);
elem2edge = reshape(j,NT,);
elem2dof = uint32([elem N+elem2edge (N+NE+:N+NE+NT)']);
i1(j(*NT:-:)) = *NT:-:;
i1 = i1';
bdEdgeIdx = (i1 == i2);
isBdDof = false(N+NE+NT,);
isBdDof(edge(bdEdgeIdx,:)) = true; % nodal
idx = find(bdEdgeIdx);
isBdDof(N+idx) = true;
inDof = find(~isBdDof);
end

[elem2dof,edge,inDof] = c0dofP2(elem)

http://files.cnblogs.com/files/wangshixi12/%E5%8F%8C%E4%BA%8C%E6%AC%A1Lagrange%E6%9C%89%E9%99%90%E5%85%83.rar

双二次Lagrange 有限元计算特征值程序(基于iFEM)的更多相关文章

  1. (原)使用mkl计算特征值和特征向量

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5585271.html 参考文档:mkl官方文档 lapack_int LAPACKE_sgeev(in ...

  2. 第十六届“二十一世纪的计算”学术研讨会 密西根州立大学教授Anil K. Jain主题演讲

    Biometrics---How Do I Know Who You Are? 密西根州立大学教授Anil K. Jain主题演讲" title="第十六届"二十一世纪的 ...

  3. 第十六届“二十一世纪的计算”学术研讨会 图灵奖获得者Butler W. Lampson主题演讲

    Personal Control of Digital Data 图灵奖获得者Butler W. Lampson主题演讲" title="第十六届"二十一世纪的计算&qu ...

  4. 三种计算c#程序运行时间的方法

    三种计算c#程序运行时间的方法 第一种: 利用 System.DateTime.Now // example1: System.DateTime.Now method DateTime dt1 = S ...

  5. 二 ASP.NET MVC 第一个程序 hello world

    二 ASP.NET MVC 第一个程序 hello world   https://blog.csdn.net/xmroom/article/details/51335917 我使用的Visual s ...

  6. Senparc.Weixin.MP SDK 微信公众平台开发教程(二十一):在小程序中使用 WebSocket (.NET Core)

    本文将介绍如何在 .NET Core 环境下,借助 SignalR 在小程序内使用 WebSocket.关于 WebSocket 和 SignalR 的基础理论知识不在这里展开,已经有足够的参考资料, ...

  7. 第十六届“二十一世纪的计算”学术研讨会 牛津大学肿瘤成像学教授Michael Brady主题演讲

    Computing and Healthcare 牛津大学肿瘤成像学教授Michael Brady主题演讲" title="第十六届"二十一世纪的计算"学术研讨 ...

  8. Spark练习之通过Spark Streaming实时计算wordcount程序

    Spark练习之通过Spark Streaming实时计算wordcount程序 Java版本 Scala版本 pom.xml Java版本 import org.apache.spark.Spark ...

  9. 微信小程序-基于canvas画画涂鸦

    代码地址如下:http://www.demodashi.com/demo/14461.html 一.前期准备工作 软件环境:微信开发者工具 官方下载地址:https://mp.weixin.qq.co ...

随机推荐

  1. Spring Integration

    @ContextConfiguration directs Spring's test runner to locate a configuration file with the same name ...

  2. JDBC 数据库连接池 小结

    原文:http://www.cnblogs.com/lihuiyy/archive/2012/02/14/2351768.html 当对数据库的访问不是很频繁时,可以在每次访问数据库时建立一个连接,用 ...

  3. CentOS下Apache开启Gzip网页压缩功能

    1.进入/etc/httpd/conf下打开httpd.conf文件 开启Gzip压缩功能,即去掉LoadModule deflate_module modules/mod_deflate.so这行前 ...

  4. log4cplus 在配置文件中设置文件路径,程序自动创建目录,且在日志文件前按日期创建相应的目录

    #include <string> #include <cstdio> #include <log4cplus/logger.h> #include <log ...

  5. SQLAlchemy query with OR/AND/like common filters

    http://www.leeladharan.com/sqlalchemy-query-with-or-and-like-common-filters Some of the most common ...

  6. Windows系统

    1. 更改XP登录界面 怎样启用XP的经典登录界面 第一步:用管理员账号登录系统. 第二步:运行gpedit.msc启动组策略编辑器,找到"计算机配置"--"管理模板&q ...

  7. (Array)169. Majority Element

    Given an array of size n, find the majority element. The majority element is the element that appear ...

  8. 安装centOS分区的图解记录

    要将linux的boot loader安装在MBR上,才能起到多重引导的作用.

  9. 【VB6】VB6实现拖拽

    首先,设置OLEDropMode OLEDropMode = 1 然后插入代码 Private Sub 控件名_OLEStartDrag(Data As DataObject, AllowedEffe ...

  10. Shogun网站上的关于主流机器学习工具包的比较

    Shogun网站上的关于主流机器学习工具包的比较: http://www.shogun-toolbox.org/page/features/   created last updated main l ...