task8
This commit is contained in:
parent
3763c53dab
commit
3882aee07a
71 changed files with 160045 additions and 0 deletions
35
ex3/seq/generate_mesh/save_mesh2_mini.m
Normal file
35
ex3/seq/generate_mesh/save_mesh2_mini.m
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
function save_mesh2_mini( xc, ia, e, basename)
|
||||
% Save the 3D triangular mesh in the minimal way (only coordinates and vertex connectivity)
|
||||
% in binary file.
|
||||
% The indexing in the connectivity is changed to C-style (starts with 0)
|
||||
%
|
||||
% coordinates xc: [2][nnode]
|
||||
% connectivity ia: [4][nelem] with t(4,:) are the subdomain numbers
|
||||
% edges e: [7][nedges] boundary edges
|
||||
% e([1,2],:) - start/end vertex of edge
|
||||
% e([3,4],:) - start/end values
|
||||
% e(5,:) - segment number
|
||||
% e([6,7],:) - left/right subdomain
|
||||
% basename: file name without extension
|
||||
% data from
|
||||
% output from <https://de.mathworks.com/help/pde/ug/initmesh.html initmesh>
|
||||
%
|
||||
fname = [basename, '.bin'];
|
||||
offset = 1; % index difference from C to Matlab
|
||||
|
||||
nnode = size(xc,2);
|
||||
ndim = size(xc,1);
|
||||
nelem = size(ia,2);
|
||||
nvert_e = 3;
|
||||
|
||||
fileID = fopen(fname,'w');
|
||||
fwrite(fileID, nnode, 'int'); % number of nodes
|
||||
fwrite(fileID, ndim, 'int'); % space dimension
|
||||
fwrite(fileID, nelem, 'int'); % number of elements
|
||||
fwrite(fileID, nvert_e, 'int'); % number of vertices per element
|
||||
|
||||
fwrite(fileID, xc(:), 'double'); % coordinates
|
||||
tmp=ia(1:3,:)-offset;
|
||||
fwrite(fileID, tmp(:), 'double'); % connectivity
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue