rafavzqz / geopdes

GeoPDEs: Isogeometric Analysis in Octave and Matlab, for research and teaching purposes.

Home Page:http://rafavzqz.github.io/geopdes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HB basis

liuyuanhao opened this issue · comments

Dear Rafa
Thank you for your previous help.
I would like to implement HB splines related computation.I have read the documents in the appendix and GeoPDEs code libraries this week.However,my code level is very limited.
I feel a little embrassed ... Would you please give me a example like how to
compute and plot the HB basis functions with the GeoPDEs source code?If the GeoPDEs source code has the above function,please tell me about that.(Sry,I can't understand this code very well...)
Would you give me some guidance,please?

Deeply grateful,
Jim

Dear Jim,
Hamid asked a similar question some time ago (issue #7). The easiest way to plot a basis function without writing new code, is to consider a solution vector with all the degrees of freedom set to zero, except one which is set to one. To plot all the basis functions, you can do something like this.

for ii = 1:hspace.ndof
u = zeros (hspace.ndof, 1); u(ii) = 1;
[eu,F] = sp_eval (u, hspace, geometry, npts);
surf (squeeze(F(1,:,:)), squeeze(F(2,:,:)), eu);
hold on
end

Best,
Rafa

Dear Rafa,
Thank you for your previous help.I'm sorry to disturb you again.
I have written an successful code with your help,as described below.

problem_data.geo_name = 'geo_square.txt';

method_data.degree = [2 2]; % Degree of the splines
method_data.regularity = [1 1]; % Regularity of the splines
method_data.nsub_coarse = [2 2]; % Number of subdivisions of the coarsest mesh
method_data.nsub_refine = [2 2]; % Number of subdivisions for each refinement step
method_data.nquad = [1 1]; % Points for the Gaussian quadrature rule
method_data.space_type = 'standard'; % 'simplified' (only children functions) or 'standard' (full basis)
method_data.truncated = 0; % 0: False, 1: True

adaptivity_data.flag = 'elements'; % Refine by marking the elements of the hierarchical mesh (you can also mark 'functions'

% Initialize HB-splines as B-splines of level 0
[hmsh, hspace] = adaptivity_initialize_laplace (problem_data, method_data);

% Then, refine by marking elements
% The elements in marked{level} should be included in hmsh.active{level}
marked{1} = [1 2 3];
[hmsh, hspace] = adaptivity_refine (hmsh, hspace, marked, adaptivity_data);
figure
hmsh_plot_cells (hmsh);

marked{1} = [];
marked{2} = [1 2 3 4 5 6 7 9 10 13];
[hmsh, hspace] = adaptivity_refine (hmsh, hspace, marked, adaptivity_data);
figure
hmsh_plot_cells (hmsh);

marked{1} = 4;
marked{2} = [8 14];
marked{3} = [1 2 3 9 10 17];
[hmsh, hspace] = adaptivity_refine (hmsh, hspace, marked, adaptivity_data);
figure
hmsh_plot_cells (hmsh);

figure
for ii = 1:hspace.ndof
u = zeros (hspace.ndof, 1); u(ii) = 1;
[eu,F] = sp_eval (u, hspace, test66Copy, 8);
surf(squeeze(F(1,:,:)), squeeze(F(2,:,:)), eu);
hold on
end

It's an example of creating HB (hierarchical b-splines) splines,but I have a slight problem.How to modify this code so that it can be used to create THB(Truncated Hierarchical B-splines) splines and draw its basis functions.
Would you give me some guidance,please?

Deeply grateful,
Jim

Dear Jim,
you only need to set
method_data.truncated = 1;
The rest of the code should remain the same.

Rafa