Contents     Functions         Previous Next     PDF Index

naswrite

Purpose

Formatted ASCII output to MSC/NASTRAN bulk data deck. This function is part of FEMLink.

Syntax

naswrite('FileName',node,elt,pl,il)
naswrite('FileName','command', ...)
naswrite('-newFileName','command', ...)
naswrite(fid,'command', ...)

Description

naswrite appends its output to the file FileName or creates it, if it does not exist. Use option -newFileName to force deletion of an existing file. You can also provide a handle fid to a file that you opened with fopen. fid=1 can be used to have a screen output.

EditBulk

Supports bulk file editing. Calls take the form
nas2up('EditBulk',InFile,edits,Outfile), where InFile and OutFile are file names and edits is a cell array with four columns giving command, BeginTag, EndTag, and data. Accepted commands are

Beforeinserts data before the BeginTag.
Insertinserts data after the EndTag.
Removeremoves a given card. Warning this does not yet handle multiple line cards.
Setused to set parameter and assign values. For example
 edits={'Set','PARAM','POST','-2'};
 rootname='my_job';
 f0={'OUTPUT4',sprintf('%s_mkekvr.op4',rootname),'NEW',40,'DELETE',
     'OUTPUT4',sprintf('%s_TR.op4',rootname),'NEW',41,'DELETE'};
 edits(end+1,1:4)={'set','ASSIGN','',f0}

When writing automated solutions, the edits should be stored in a stack entry info,EditBulk.

model

naswrite('FileName',model) the nominal call, it writes everything possible : nodes, elements, material properties, case information (boundary conditions, loads, etc.). For example naswrite(1,femesh('testquad4')).

The following information present in model stack is supported

The obsolete call naswrite('FileName',node,elt,pl,il) is still supported.

node,elt

You can also write nodes and elements using the low level calls but this will not allow fixes in material/element property numbers or writing of case information.

femesh('reset');
femesh('testquad4')
fid=1 % fid=fopen('FileName');
naswrite(fid,'node',FEnode)
naswrite(fid,'node',FEnode)
%fclose(fid)

Note that node(:,4) which is a group identifier in SDT, is written as the SEID in NASTRAN. This may cause problems when writing models from translated from other FEM codes. Just use model.Node(:,4)=0 in such cases.

dmig

DMIG writing is supported through calls of the form naswrite(fid,'dmigwrite NAME',mat,mdof). For example

 naswrite(1,'dmigwrite KAAT',rand(3),[1:3]'+.01)

A nastran,dmig entry in model.Stack, where the data is a cell array where each row gives name, DOF and matrix, will also be written. You can then add these matrices to your model by adding cards of the form K2GG=KAAT to you NASTRAN case.

job

NASTRAN job handling on a remote server from the MATLAB command line is partially supported. You are expected to have ssh and scp installed on your computer. On windows, it is assumed that you have access to these commands using CYGWIN. You first need to define your preferences

 setpref('FEMLink','CopyFcn','scp');
 setpref('FEMLink','RunNastran','nastran');
 setpref('FEMLink','RemoteShell','ssh');
 setpref('FEMLink','RemoteDir','/tmp2/nastran');
 setpref('FEMLink','RemoteUserHost','user@myhost.com')
 setpref('FEMLink','DmapDir',fullfile(fileparts(which('nasread')),'dmap'))

You can define a job handler customized to your needs and still use the nas2up calls for portability by defining setpref('FEMLink','NASTRANJobHandler', 'FunctionName').

You can then run a job using nas2up('joball','BulkFileName.dat'). Additional arguments can be passed to the RunNastran command by simply adding them to the joball command. For example
nas2up('joball','BulkFileName.dat',struct('RunOptions','memory=1GB')).

It is possible provide specific options to your job handler by storing them as a info,NasJobOptentry in your model.Stack. nas2up('JobOptReset') resets the default. The calling format in various functions that use the job handling facility is then

 model=stack_set('info','NasJobOpt',nas2up('jobopt'));
 nas2up('joball','step12.dat',model);

RunOpt.RunOptions stores text options to be added to the nastran command. RunOpt.BackWd can be used to specify an additional relative directory for the JobCpFrom command. RunOpt.RemoteRelDir can be used to specify the associated input for the JobCpTo command.

nas2up('JobCpTo', 'LocalFileName', 'RemoteRelDir') puts (copies) files to the remote directory or to fullfile(RemoteDir,RemoteRelativeDir) if specified.

nas2up('JobCpFrom', 'RemoteFileName') fetches files. The full remote file name is given by fullfile(RemoteDir,RemoteFileName). Any relative directory is ignored for the local directory.

Here is a simple script that generates a model, runs NASTRAN and reads the result

wd=sdtdef('tempdir');

model=demosdt('demoubeam-2mat'); cf=feplot;
model=fe_case(model,'dofload','Input', ...
  struct('DOF',[349.01;360.01;241.01;365.03],'def',[1;-1;1;1],'ID',100));
model=nas2up('JobOpt',model);
model=stack_set(model,'info','Freq',[20:2:150]);

% write bulk but do not include eigenvalue options
naswrite(['-new' fullfile(wd,'ubeam.bdf')],stack_rm(model,'info','EigOpt'))

% generate a job by editing the reference mode.dat file
fname='ubeam.dat';
edits={'Set','PARAM','POST','-2';
 'replace','include ''model.bdf''','','include ''ubeam.bdf''';
 'replace','EIGRL','',nas2up('writecard',-1,[1 0 0 30],'ijji','EIGRL')};
nas2up('editbulk','mode.dat',edits,fullfile(wd,fname));
cd(wd);type(fname)
nas2up('joball',fname,model)
cg=feplot(4);mo1=nasread('ubeam.op2');

Wop4

Matrix writing to OUTPUT4 format. You provide a cell array with one matrix per row, names in first column and matrix in second column. The optional byte swapping argument can be used to write matrices for use on a computer with another binary format.

 kv=speye(20);
 ByteSwap=0;  % No Byte Swapping needed
 nas2up('wop4','File.op4',{'kv',kv},ByteSwap);

For ByteSwap you can also specify ieee-le for little endian (Intel PC) or ieee-be depending on the architecture NASTRAN will be running on. You can omit specifying ByteSwap at every run by setting

 setpref('FEMLink','OutputBinaryType','ieee-le')

WriteFreqLoad

edits=naswrite('Target.bdf','WriteFreqLoad',model) (or the equivalent nas2up call when the file is already open as show below) writes loads defined in model (and generated with Load=fe_load(model)) as a series of cards. FREQ1 for load frequencies, TABLED1 for the associated curve, RLOAD1 to define the loaded DOFs and DAREA for the spatial information about the load. The return edits argument is the entry that can be used to insert the associated subcase information in a nominal bulk.

The identifiers for the loads are supposed to be defined as Case.Stack{j1,end}.ID fields.

% Generate a model with sets of point loads
model=demosdt('Demo ubeam dofload noplot')
% Define the desired frequencies for output
model=stack_set(model,'info','Freq', ...
   struct('ID',101,'data',linspace(0,10,12)));
fid=1 % fid=fopen('FileName');
edits=nas2up('writefreqload',fid,model);
fprintf('%s\n',edits{end}{:}); % Main bulk to be modified with EditBulk
%fclose(fid)

Write[Curve,Set,SetC,Uset]

Write commands are used to WriteCurve lets you easily generate NASTRAN curve tables.

WriteSet lets you easily generate NASTRAN node and elements sets associated with node and element selection commands.

WriteSetC formats the sets for use in the case control section rather than the bulk.

WriteUset generates DOFs sets.

model=demosdt('demogartfe');
fid=1; % display on screen (otherwise use FOPEN to open file)
nas2up('WriteSet',fid,3000,model,'findnode x>.8');
selections={'zone_1','group 1';'zone_2','group 2:3'};
nas2up('WriteSet',fid,2000,model,selections);
st=nas2up('WriteSet',-1,2000,model,selections);

curves={'curve','Sine',fe_curve('testEval -id1 sin(t)',linspace(0,pi,10)) ; ...
        'curve','Exp.',fe_curve('testEval -id100 exp(-2*t)',linspace(0,1,30))};
nas2up('WriteCurve',fid,curves)
DOF=feutil('getdof',model);
nas2up('WriteUset U4',fid,DOF(1:20))

WritePLIL

The WritePLIL is used to resolve identifier issues in MatId and ProId (elements in SDT have both a MatId and an ProID while in NASTRAN they only have a ProId with the element property information pointing to material entries). While this command is typically used indirectly while writing a full model, you may want to access it directly. For example

 model=demosdt('demogartfe');
 nas2up('Writeplil',1,model);

See also

nasread, ufread, ufwrite


©1991-2017 by SDTools
Previous Up Next