I have a set of runs that needs to be solved. Is there a way I can define
a list of runs to start one after another in the solver mode. For example,
run #1 start in parallel mode, runs until max number of iteration is
reached or residuals are reached, stop solver, start run #2 and repeat
until all runs on the list are completed.
This can easily be done using Perl scripts. An example which modifies a flow rate and uses results from previous runs as a restart for subsequent runs is shown below. It runs in local parallel and is based on a definition file named static.def. To run the script, bring up the CFX-5 command line from the CFX-5 launcher (Tools/Command Line) and type: perl doRuns_2.pl where doRuns_2.pl is the name given to the Perl file created for this particular script. # # Simple script to do a series of runs with varying inlet velocities. # This is a smarter version that allows the user to specify an initial # conditions file, #set up a hash for the name, speed and initial file for each run %run1= (NAME => "static", SPEED => "2 [m/s]", INIT => ""); %run2= (NAME => "static", SPEED => "3 [m/s]", INIT => "static_001.res"); %run3= (NAME => "static", SPEED => "4 [m/s]", INIT => "static_002.res"); # Create a list of references to the runs @runList = (%run1, %run2, %run3); # do some error checking in the run list to make sure all necessary data is # defined before we start anything. $errors = 0; foreach $run (@runList) { if (!defined($run->{NAME})) { print "Found run without a name.n"; $errors = 1; } if (!defined($run->{SPEED})) { print "No speed found for " . $run->{NAME} . ".n"; $errors = 1; } if (!defined($run->{INIT})) { print "No initial file found for " . $run->{NAME} . ".n"; $errors = 1; } } if ($errors) { die "Errors found in run definitions. Aborting.n"; } #loop over the list foreach $run (@runList) { $name = $run->{NAME}; $speed = $run->{SPEED}; $initFile = $run->{INIT}; # make sure the initial file exists and is readable if (! -r $initFile) { print "Warning: Initial conditions file $initFile not found for run $name.n"; print " Proceeding with default initial conditionsn"; $initCmd = ""; } else { $initCmd = "-ini $initFile"; } #Open the solver to accept some CCL from STDIN open(SOLVER,"|cfx5solve -def static.def -name $name $initCmd -par-local -part 2 -ccl -"); # send off the CCL to modify the BC print SOLVER "FLOW:n"; print SOLVER " DOMAIN : fluidn"; print SOLVER " BOUNDARY : inlet1n"; print SOLVER " BOUNDARY CONDITIONS:n"; print SOLVER " MASS AND MOMENTUM:n"; print SOLVER " Normal Speed = $speedn"; print SOLVER " ENDn"; print SOLVER " ENDn"; print SOLVER " ENDn"; print SOLVER " ENDn"; print SOLVER "ENDn"; close(SOLVER); # start the run } # end of loop |
||
|