Matlab data to .k file
古いコメントを表示
clear;
filename='plate.k';
global preprocessor_type passive0 passive1 curved_extrusion extrusion_type
preprocessor_type=1
fid = fopen(filename, 'rt');
load nodetable.mat
if(fid == -1) disp('Error: Model file does not exist.')
x=[]; error=1; eltsize=0;
return;
end % if file does not exist or is empty, exit
n=1;
%temp_nodetable=zeros(400000,4);
tline = fgetl(fid);
str1=['k'];
%filename = ['/input.k'];
%filename = ['k',num2str,'/input.k'];
fid = fopen(filename, 'rt');
tline = fgetl(fid);
% str1=['iter_',num2str(ITER)];mkdir(str1);
filename_out = ['k','/input.k'];
filename_in = ['k','/input.k'];
fid_in = fopen(filename_in, 'rt');
fid_out = fopen(filename_out, 'wt');
%tline = fgetl(fid_in);
while( feof(fid_in) == 0 && ( ~strcmp(tline,'*END') || ~strcmp(tline(1:4),'*END')))
findstring1='*NODE';
flag1 = strcmp(strtrim(tline),findstring1);
if flag1 > 0
fprintf(fid_out,[tline '\n']);
tline = fgetl(fid_in);
for j=1:(n-1);
fprintf(fid_out,'%8g%16g%16g%16g%8g%8g',nodetable(j,:));fprintf(fid_out,'\n');
end
while(~isempty(tline) && ~strcmp(tline(1),'*'))
tline = fgetl(fid_in);
end
else
fprintf(fid_out,[tline '\n']);tline = fgetl(fid_in);
end
end
fprintf(fid_out,'\n');
fclose('all');
cd ..
I have this code to insert my data in nodetable in a .k file format to read in LS-Dyna. Please let me know where i am going wrong. Thanks.
2 件のコメント
Walter Roberson
2012 年 4 月 24 日
What problem are you encountering? Is there an error message?
Sven
2012 年 7 月 9 日
"Please let me know where i am going wrong"
Yep, I think the problem you're having is that you're not describing the problem you're having.
Dyna decks are tricky to work with but here are a couple of suggestions:
- Test your deck-writer with a small file (~20 nodes)... I bet the 10 seconds saved by not having to scroll to the *NODE card each time you make a change will outweigh the 5 minutes it will take to make a test file.
- I see some of your previous questions about lining up coordinates over 16 characters. Remember that with dyna you can also just separate lists (node x,y,z, element node #s) with a comma (,). It doesn't look as pretty to read for a human, but it's easier to code and can even save file size if you're working with massive meshes.
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Software Development についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!