File Coverage

blib/lib/Sim/OPTS.pm
Criterion Covered Total %
statement 30 3529 0.8
branch 0 828 0.0
condition 0 165 0.0
subroutine 10 85 11.7
pod 0 75 0.0
total 40 4682 0.8


line stmt bran cond sub pod time code
1             package Sim::OPTS;
2             # Copyright (C) 2008-2014 by Gian Luca Brunetti and Politecnico di Milano.
3             # This is OPTS, a program for detailed metadesign managing parametric explorations through the ESP-r building performance simulation platform and performing optimization by block coordinate descent.
4             # This is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License
5             # as published by the Free Software Foundation, version 2.
6              
7 1     1   17565 use v5.14; # use v5.20;
  1         4  
  1         45  
8 1     1   5 use Exporter;
  1         1  
  1         47  
9 1     1   10 use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS );
  1         5  
  1         73  
10 1     1   1495 use Math::Trig;
  1         42124  
  1         208  
11 1     1   11 use List::Util qw[ min max reduce shuffle];
  1         2  
  1         106  
12 1     1   694 use List::MoreUtils;
  1         1174  
  1         85  
13              
14 1     1   743 use Data::Dumper;
  1         6787  
  1         106  
15             $Data::Dumper::Indent = 0;
16             $Data::Dumper::Useqq = 1;
17             $Data::Dumper::Terse = 1;
18              
19             #use feature qw(postderef);
20             # no warnings qw(experimental::postderef);
21 1     1   8 use feature 'say';
  1         2  
  1         97  
22 1     1   5 no strict;
  1         1  
  1         32  
23 1     1   4 no warnings;
  1         1  
  1         43717  
24              
25             @ISA = qw(Exporter); # our @adamkISA = qw(Exporter);
26              
27             %EXPORT_TAGS = ( DEFAULT => [qw( &opts &prepare )]); # our %EXPORT_TAGS = ( 'all' => [ qw( ) ] );
28             @EXPORT_OK = qw(); # our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
29             @EXPORT = qw( opts prepare ); # our @EXPORT = qw( );
30             $VERSION = '0.36.16.10'; # our $VERSION = '';
31             $ABSTRACT = 'Sim::OPTS it a tool for detailed metadesign. It manages parametric explorations through the ESP-r building performance simulation platform and performs optimization by block coordinate descent.';
32              
33             #################################################################################
34             #################################################################################
35             # BEGINNING OF OPTS
36            
37             sub opts
38             {
39 0     0 0   my ( $filenew, $winnerline, $loserline, $configfile, $morphfile, $simlistfile, $sortmerged, @totvarnumbers, @uplift, @downlift, $fileuplift, $filedownlift, @varnumbers, @newvarnumbers, @newblockelts, $countvar, @seedfiles );
40             sub start
41             {
42             ###########################################
43 0     0 0   print "THIS IS OPTS.
44             Copyright by Gian Luca Brunetti and Politecnico di Milano, 2008-14.
45             DAStU Department, Polytechnic of Milan
46              
47             -------------------
48              
49             To use OPTS, an OPTS configuration file and a target ESP-r model should have been prepared.
50             Please insert the name of a configuration file (Unix path):\n";
51             ###########################################
52 0           $configfile = ;
53 0           chomp $configfile;
54 0 0         if (-e $configfile ) { ; }
55 0           else { &start; }
56             }
57 0           &start;
58              
59             # eval `cat $configfile`; # The file where the program data are
60 0           require $configfile; # The file where the program data are ZZZ# PROBLEM HERE, MISSING
61 0 0         if (-e $casegroupfile) { require $casegroupfile; }
  0            
62              
63             # use Sim::OPTS::morph; # use Sim::OPTS::sim; # HERE THE FUNCTIONS "sim" and "retrieve" are. # use Sim::OPTS::report; # use Sim::OPTS::format;
64              
65             ###########################################################################################
66             # BEGINNING OF THE OPTS PROGRAM.
67              
68 0           print "OPTS - IS - RUNNING.
69             -------------------\n";
70 0 0         if ($outfile) { open( OUTFILE, ">$outfile" ) or die "Can't open $outfile: $!"; }
  0 0          
71 0 0         if ($toshell) { open( TOSHELL, ">$toshell" ) or die "Can't open $toshell: $!"; }
  0 0          
72 0 0         unless (-e "$mypath/models") { `mkdir $mypath/models`; }
  0            
73 0 0         unless (-e "$mypath/models") { print TOSHELL "mkdir $mypath/models\n\n"; }
  0            
74            
75 0 0         if (-e "./SIM/OPTS/prepare.pm")
76             {
77 0           eval `cat ./SIM/OPTS/prepare.pm`;
78             }
79              
80             #################################################################################
81             #################################################################################
82             sub exec
83             {
84 0     0 0   my $swap = shift;
85 0           my @varnumbers = @$swap;
86 0           my $countblock = shift;
87 0           my $countcase = shift;
88 0           my $swap = shift;
89 0           my @newvarnumbers = @$swap;
90 0           my $swap = shift;
91 0           my @uplift = @$swap;
92 0           my $swap = shift;
93 0           my @downlift = @$swap;
94 0           my $swap = shift;
95 0           my @blocks = @$swap;
96 0           my $swap = shift;
97 0           my @blockelts = @$swap;
98 0           my $swap = shift;
99 0           my @newblockelts = @$swap;
100 0           my $swap = shift;
101 0           my @overlap = @$swap;
102            
103 0           $morphfile = "$mypath/$file-morphfile-$countcase-$countblock";
104 0           $simlistfile = "$mypath/$file-simlist-$countcase-$countblock";
105            
106 0 0         open (MORPHFILE, ">$morphfile") or die;
107            
108 0           @totvarnumbers = (@totvarnumbers, @varnumbers);
109 0           @totvarnumbers = uniq(@totvarnumbers);
110 0           @totvarnumbers = sort(@totvarnumbers);
111              
112             sub morph
113             {
114 0     0 0   my $to = shift;
115 0           my $mypath = shift;
116 0           my $file = shift;
117 0           my $filenew = shift;
118 0           my $swap = shift;
119 0           my @dowhat = @$swap;
120 0           my $swap = shift;
121 0           my @simdata = @$swap;
122 0           my $simnetwork = shift;
123 0           my $swap = shift;
124 0           my @simtitles = @$swap;
125 0           my $preventsim = shift;
126 0           my $exeonfiles = shift;
127 0           my $fileconfig = shift;
128 0           my $swap = shift;
129 0           my @themereports = @$swap;
130 0           my $swap = shift;
131 0           my @reporttitles = @$swap;
132 0           my $swap = shift;
133 0           my @retrievedata = @$swap;
134 0           my $swap = shift;
135 0           my @varnumbers = @$swap;
136 0           my $countblock = shift;
137 0           my $countcase = shift;
138            
139 0           say OUTFILE "\nHERE 2 ";
140 0           $countvar = 0;
141 0           foreach $varnumber (@varnumbers)
142             {
143 0           my @casemorphed;
144 0           say OUTFILE "\nHERE 3 ";
145            
146 0 0         if ( $countvar == $#varnumbers )
147             {
148 0           $$general_variables[0] = "n";
149             } # THIS TELLS THAT IF THE SEARCH IS ENDING (LAST SUBSEARCH CYCLE) GENERATION OF CASES HAS TO BE TURNED OFF
150            
151 0           $stepsvar = ${ "stepsvar" . "$varnumber" };
  0            
152 0           @applytype = @{ "applytype" . "$varnumber" };
  0            
153 0           @generic_change = @{ "generic_change" . "$varnumber" };
  0            
154 0           $rotate = ${ "rotate" . "$varnumber" };
  0            
155 0           $rotatez = ${ "rotatez" . "$varnumber" };
  0            
156 0           $general_variables = ${ "general_variables" . "$varnumber" };
  0            
157 0           $translate = ${ "translate" . "$varnumber" };
  0            
158 0           $translate_surface_simple = ${ "translate_surface_simple" . "$varnumber" };
  0            
159 0           $translate_surface = ${ "translate_surface" . "$varnumber" };
  0            
160 0           $keep_obstructions = ${ "keep_obstructions" . "$varnumber" };
  0            
161 0           $shift_vertexes = ${ "shift_vertexes" . "$varnumber" };
  0            
162 0           $construction_reassignment = ${ "construction_reassignment" . "$varnumber" };
  0            
163 0           $thickness_change = ${ "thickness_change" . "$varnumber" };
  0            
164 0           $recalculateish = ${ "recalculateish" . "$varnumber" };
  0            
165 0           @recalculatenet = @{ "recalculatenet" . "$varnumber" };
  0            
166 0           $obs_modify = ${ "obs_modify" . "$varnumber" };
  0            
167 0           $netcomponentchange = ${ "netcomponentchang" . "$varnumber" };
  0            
168 0           $changecontrol = ${ "changecontrol" . "$varnumber" };
  0            
169 0           @apply_constraints = @{ "apply_constraints" . "$varnumber" }; # NOW SUPERSEDED BY @constrain_geometry
  0            
170 0           $rotate_surface = ${ "rotate_surface" . "$varnumber" };
  0            
171 0           @reshape_windows = @{ "reshape_windows" . "$varnumber" };
  0            
172 0           @apply_netconstraints = @{ "apply_netconstraints" . "$varnumber" };
  0            
173 0           @apply_windowconstraints = @{ "apply_windowconstraints" . "$varnumber" };
  0            
174 0           @translate_vertexes = @{ "translate_vertexes" . "$varnumber" };
  0            
175 0           $warp = ${ "warp" . "$varnumber" };
  0            
176 0           @daylightcalc = @{ "daylightcalc" . "$varnumber" };
  0            
177 0           @change_config = @{ "change_config" . "$varnumber" };
  0            
178 0           @constrain_geometry = @{ "constrain_geometry" . "$varnumber" };
  0            
179 0           @vary_controls = @{ "vary_controls" . "$varnumber" };
  0            
180 0           @constrain_controls = @{ "constrain_controls" . "$varnumber" };
  0            
181 0           @constrain_geometry = @{ "constrain_geometry" . "$varnumber" };
  0            
182 0           @constrain_obstructions = @{ "constrain_obstructions" . "$varnumber" };
  0            
183 0           @get_obstructions = @{ "get_obstructions" . "$varnumber" };
  0            
184 0           @pin_obstructions = @{ "pin_obstructions" . "$varnumber" };
  0            
185 0           $checkfile = ${ "checkfile" . "$varnumber" };
  0            
186 0           @vary_net = @{ "vary_net" . "$varnumber" };
  0            
187 0           @constrain_net = @{ "constrain_net" . "$varnumber" };
  0            
188 0           @propagate_constraints = @{ "propagate_constraints" . "$varnumber" };
  0            
189 0           @change_climate = @{ "change_climate" . "$varnumber" };
  0            
190 0           $skip = ${ "skip" . "$varnumber" };
  0            
191 0           $constrain = ${ "constrain" . "$varnumber" };
  0            
192 0           my @cases_to_sim;
193             my @files_to_convert;
194 0           my (@v, @obs, @node, @component, @loopcontrol, @flowcontrol); # THINGS GLOBAL AS REGARDS COUNTER ZONE CYCLES
195 0           my (@myv, @myobs, @mynode, @mycomponent, @myloopcontrol, @myflowcontrol); # THINGS LOCAL AS REGARDS COUNTER ZONE CYCLES
196 0           my (@tempv, @tempobs, @tempnode, @tempcomponent, @temploopcontrol, @tempflowcontrol); # THINGS LOCAL AS REGARDS COUNTER ZONE CYCLES
197 0           my (@dov, @doobs, @donode, @docomponent, @doloopcontrol, @doflowcontrol); # THINGS LOCAL AS REGARDS COUNTER ZONE CYCLES
198            
199 0           my $generate = $$general_variables[0];
200 0           my $sequencer = $$general_variables[1];
201 0           my $dffile = "df-$file.txt";
202 0 0         if ( eval $skip) { $skipask = "yes"; }
  0            
203            
204 0 0 0       if ( ( $countvar == 0 ) and ( $countblock == 1 ) and ( $countcase == 0 ) )
      0        
205             {
206 0 0         if ($exeonfiles eq "y") { `cp -r $mypath/$file $filenew`; }
  0            
207 0           print TOSHELL "cp -r $mypath/$file $filenew\n\n";
208             }
209              
210 0           @cases_to_sim = grep -d, <$mypath/models/$file*_>;
211              
212 0           foreach $case_to_sim (@cases_to_sim)
213             {
214 0           say OUTFILE "\nHERE 4 ";
215            
216 0           $counterstep = 1;
217            
218 0           while ( $counterstep <= $stepsvar )
219             {
220 0           my $from = "$case_to_sim";
221 0           my $almost_to = $from;
222 0           $almost_to =~ s/$varnumber-\d+/$varnumber-$counterstep/ ;
223            
224 0 0 0       if ( ( $generate eq "n" )
    0 0        
    0 0        
    0 0        
    0 0        
      0        
225             and ( ( $sequencer eq "y" ) or ( $sequencer eq "last" ) ) )
226             {
227 0 0         if ( $almost_to =~ m/§$/ ) { $to = "$almost_to" ; }
  0            
228             else
229             {
230             #$to = "$case_to_sim$varnumber-$counterstep§";
231 0           $to = "$almost_to" . "§";
232             }
233             }
234             elsif ( ( $generate eq "y" ) and ( $sequencer eq "n" ) )
235             {
236 0 0         if ( $almost_to =~ m/_$/ ) { $to = "$almost_to" ; }
  0            
237             else
238             {
239             #$to = "$case_to_sim$varnumber-$counterstep" . "_";
240 0           $to = "$almost_to" . "_";
241             #if ( $counterstep == $stepsvar )
242             #{
243             # if ($exeonfiles eq "y") { print `chmod -R 777 $from\n`; }
244             # print TOSHELL "chmod -R 777 $from\n\n";
245             #}
246             }
247             }
248             elsif ( ( $generate eq "y" ) and ( $sequencer eq "y" ) )
249             {
250             #$to = "$case_to_sim$varnumber-$counterstep" . "£";
251 0           $to = "$almost_to" . "£";
252             }
253             elsif ( ( $generate eq "y" ) and ( $sequencer eq "last" ) )
254             {
255 0 0         if ( $almost_to =~ m/£$/ ) { $to = "$almost_to" ; }
  0            
256             else
257             {
258             #$to = "$case_to_sim$varnumber-$counterstep" . "£";
259 0           $to = "$almost_to" . "£";
260             #if ( $counterstep == $stepsvar )
261             #{
262             # if ($exeonfiles eq "y") { print `chmod -R 777 $from\n`; }
263             # print TOSHELL "chmod -R 777 $from\n\n";
264             #}
265             }
266             }
267             elsif ( ( $generate eq "n" ) and ( $sequencer eq "n" ) )
268             {
269 0           $almost_to =~ s/[_|£]$// ;
270             #$to = "$case_to_sim$varnumber-$counterstep";
271 0           $to = "$almost_to";
272             }
273            
274 0 0 0       if ( ($countvar == $#varnumbers) and ( ($skip ne "") and ($skipask ne "yes") ) )
      0        
275             {
276 0           $to =~ s/_$//;
277 0           print MORPHFILE "$to\n";
278             }
279            
280             # say OUTFILE "\nHERE AFTER ";
281            
282             { # BLOCK
283 0 0 0       if ( ( $generate eq "y" )
  0   0        
      0        
      0        
      0        
284             and ( $counterstep == $stepsvar )
285             and ( ( $sequencer eq "n" ) or ( $sequencer eq "last" ) )
286             and ( ($skip ne "") and ($skipask ne "yes") )
287             )
288             {
289 0 0         unless (-e $to)
290             {
291 0 0         if ($exeonfiles eq "y") { `cp -R $from $to\n`; }
  0            
292 0           print TOSHELL "cp -R $from $to\n\n";
293             #if ($exeonfiles eq "y") { print `chmod -R 777 $to\n`; }
294             #print TOSHELL "chmod -R 777 $to\n\n";
295             }
296             }
297             else
298             {
299 0 0         unless (-e $to)
300             {
301            
302 0 0         if ($exeonfiles eq "y") { `cp -R $from $to\n`; }
  0            
303 0           print TOSHELL "cp -R $from $to\n\n";
304             #if ($exeonfiles eq "y") { print `chmod -R 777 $to\n`; }
305             #print TOSHELL "chmod -R 777 $to\n\n";
306             }
307             }
308             }
309            
310 0           push(@morphed, $to);
311            
312 0           $counterzone = 0;
313            
314 0           foreach my $zone (@applytype)
315             {
316 0           my $modification_type = $applytype[$counterzone][0];
317 0 0 0       if ( ( $applytype[$counterzone][1] ne $applytype[$counterzone][2] )
318             and ( $modification_type ne "changeconfig" ) )
319             {
320 0 0         if ($exeonfiles eq "y")
321             {
322 0           `cp -f $to/zones/$applytype[$counterzone][1] $to/zones/$applytype[$counterzone][2]\n`;
323             }
324 0           print TOSHELL
325             "cp -f $to/zones/$applytype[$counterzone][1] $to/zones/$applytype[$counterzone][2]\n\n";
326 0 0         if ($exeonfiles eq "y")
327             {
328 0           `cp -f $to/cfg/$applytype[$counterzone][1] $to/cfg/$applytype[$counterzone][2]\n`;
329             } # ORDINARILY, YOU MAY REMOVE THIS PART
330 0           print TOSHELL
331             "cp -f $to/cfg/$applytype[$counterzone][1] $to/cfg/$applytype[$counterzone][2]\n\n";
332             # ORDINARILY, YOU MAY REMOVE THIS PART
333             }
334 0 0 0       if (
335             (
336             $applytype[$counterzone][1] ne $applytype[$counterzone][2]
337             )
338             and ( $modification_type eq "changeconfig" )
339             )
340             {
341 0 0         if ($exeonfiles eq "y")
342             {
343 0           `cp -f $to/cfg/$applytype[$counterzone][1] $to/cfg/$applytype[$counterzone][2]\n`;
344             }
345 0           print TOSHELL
346             "cp -f $to/cfg/$applytype[$counterzone][1] $to/cfg/$applytype[$counterzone][2]\n\n";
347             # ORDINARILY, REMOVE THIS LINE
348             }
349 0           print CASELIST "$to\n";
350            
351            
352             #########################################################################################
353             #########################################################################################
354             #########################################################################################
355              
356             # HERE FOLLOWS THE CONTENT OF THE FILE "morph.pm", which has been merged here
357             # TO AVOID COMPLICATIONS WITH THE PERL MODULE INSTALLATION.
358              
359             ##############################################################################
360             sub translate
361             {
362 0     0 0   my $to = shift;
363 0           my $fileconfig = shift;
364 0           my $stepsvar = shift;
365 0           my $counterzone = shift;
366 0           my $counterstep = shift;
367 0           my $exeonfiles = shift;
368 0           my $swap = shift;
369 0           my @applytype = @$swap;
370 0           my $zone_letter = $applytype[$counterzone][3];
371 0           my $translate = shift;
372              
373 0 0         if ( $stepsvar > 1 )
374             {
375 0           my $yes_or_no_translation = "$$translate[$counterzone][0]";
376 0           my $yes_or_no_translate_obstructions = "$$translate[$counterzone][1]";
377 0           my $yes_or_no_update_radiation = $$translate[$counterzone][3];
378 0           my $configfile = $$translate[$counterzone][4];
379 0 0         if ( $yes_or_no_update_radiation eq "y" )
    0          
380             {
381 0           $yes_or_no_update_radiation = "a";
382             } elsif ( $yes_or_no_update_radiation eq "n" )
383             {
384 0           $yes_or_no_update_radiation = "c";
385             }
386 0 0         if ( $yes_or_no_translation eq "y" )
387             {
388 0           my @coordinates_for_movement = @{ $$translate[$counterzone][2] };
  0            
389 0           my $x_end = $coordinates_for_movement[0];
390 0           my $y_end = $coordinates_for_movement[1];
391 0           my $z_end = $coordinates_for_movement[2];
392 0           my $x_swingtranslate = ( 2 * $x_end );
393 0           my $y_swingtranslate = ( 2 * $y_end );
394 0           my $z_swingtranslate = ( 2 * $z_end );
395 0           my $x_pace = ( $x_swingtranslate / ( $stepsvar - 1 ) );
396 0           my $x_movement = (- ( $x_end - ( $x_pace * ( $counterstep - 1 ) ) ));
397 0           my $y_pace = ( $y_swingtranslate / ( $stepsvar - 1 ) );
398 0           my $y_movement = (- ( $y_end - ( $y_pace * ( $counterstep - 1 ) ) ));
399 0           my $z_pace = ( $z_swingtranslate / ( $stepsvar - 1 ) );
400 0           my $z_movement = (- ( $z_end - ( $z_pace * ( $counterstep - 1 ) ) ));
401              
402 0           my $printthis =
403             "prj -file $to/cfg/$fileconfig -mode script<
404              
405             m
406             c
407             a
408             $zone_letter
409             i
410             e
411             $x_movement $y_movement $z_movement
412             y
413             $yes_or_no_translate_obstructions
414             -
415             y
416             c
417             -
418             -
419             -
420             -
421             -
422             -
423             -
424             -
425             -
426             YYY
427             ";
428              
429 0 0         if ($exeonfiles eq "y")
430             {
431 0           print `$printthis`;
432             }
433 0           print TOSHELL $printthis;
434             }
435             }
436             } # end sub translate
437              
438              
439 0           my $countercycles_transl_surfs = 0;
440             #############################################################################
441              
442              
443             #############################################################################
444             sub translate_surfaces_simple # THIS IS VERSION 1, THE OLD ONE. DISMISSED? IN DOUBT, DO NOT USE IT.
445             {
446 0     0 0   my $to = shift;
447 0           my $fileconfig = shift;
448 0           my $stepsvar = shift;
449 0           my $counterzone = shift;
450 0           my $counterstep = shift;
451 0           my $exeonfiles = shift;
452 0           my $swap = shift;
453 0           my @applytype = @$swap;
454 0           my $zone_letter = $applytype[$counterzone][3];
455 0           my $translate_surface_simple = shift;
456              
457              
458 0           my $yes_or_no_transl_surfs =
459             $$translate_surface_simple[$counterzone][0];
460 0           my @surfs_to_transl =
461 0           @{ $translate_surface_simple->[$counterzone][1] };
462 0           my @ends_movs =
463 0           @{ $translate_surface_simple->[$counterzone][2]
464             }; # end points of the movements.
465 0           my $yes_or_no_update_radiation =
466             $$translate_surface_simple[$counterzone][3];
467 0           my $firstedge_constrainedarea = $$translate_surface_simple[$counterzone][4][0];
468 0           my $secondedge_constrainedarea = $$translate_surface_simple[$counterzone][4][1];
469 0           my $constrainedarea = ($firstedge_constrainedarea * $secondedge_constrainedarea);
470 0           my @swings_surfs = map { $_ * 2 } @ends_movs;
  0            
471 0           my @surfs_to_transl_constrainedarea =
472 0           @{ $translate_surface_simple->[$counterzone][5] };
473 0           my $countersurface = 0;
474 0           my $end_mov;
475             my $mov_surf;
476 0           my $pace;
477 0           my $movement;
478 0           my $surface_letter_constrainedarea;
479 0           my $movement_constrainedarea;
480              
481 0 0         if ( $yes_or_no_transl_surfs eq "y" )
482             {
483 0           foreach my $surface_letter (@surfs_to_transl)
484             {
485 0 0         if ( $stepsvar > 1 )
486             {
487 0           $end_mov = $ends_movs[$countersurface];
488 0           $swing_surf = $end_mov * 2;
489 0           $pace = ( $swing_surf / ( $stepsvar - 1 ) );
490 0           $movement =
491             ( - ( ($end_mov) -
492             ( $pace * ( $counterstep - 1 ) ) ) );
493 0           $surface_letter_constrainedarea = $surfs_to_transl_constrainedarea[$countersurface];
494 0           $movement_constrainedarea =
495             ( ( ( $constrainedarea / ( $firstedge_constrainedarea + ( 2 * $movement ) ) ) - $secondedge_constrainedarea) /2);
496              
497 0           my $printthis =
498             "prj -file $to/cfg/$fileconfig -mode script<
499              
500             m
501             c
502             a
503             $zone_letter
504             e
505             >
506             $surface_letter
507             a
508             $movement
509             y
510             -
511             -
512             y
513             c
514             -
515             -
516             -
517             -
518             -
519             -
520             -
521             -
522             YYY\n\n";
523 0 0         if ($exeonfiles eq "y")
524             {
525 0           print `$printthis`;
526             }
527 0           print TOSHELL $printthis;
528              
529 0           my $printthis =
530             "prj -file $to/cfg/$fileconfig -mode script<
531              
532             m
533             c
534             a
535             $zone_letter
536             e
537             >
538             $surface_letter_constrainedarea
539             a
540             $movement_constrainedarea
541             y
542             -
543             -
544             y
545             c
546             -
547             -
548             -
549             -
550             -
551             -
552             -
553             -
554             -
555             YYY
556             ";
557 0 0         if ($exeonfiles eq "y")
558             {
559 0           print `$printthis`;
560             }
561 0           print TOSHELL $printthis;
562              
563 0           $countersurface++;
564 0           $countercycles_transl_surfs++;
565             }
566             }
567             }
568             } # end sub translate_surfaces_simple
569             ######################################################################
570              
571              
572             ######################################################################
573             sub translate_surfaces
574             {
575 0     0 0   my $to = shift;
576 0           my $fileconfig = shift;
577 0           my $stepsvar = shift;
578 0           my $counterzone = shift;
579 0           my $counterstep = shift;
580 0           my $exeonfiles = shift;
581 0           my $swap = shift;
582 0           my @applytype = @$swap;
583 0           my $zone_letter = $applytype[$counterzone][3];
584 0           my $translate_surface = shift;
585              
586 0           my $yes_or_no_transl_surfs = $$translate_surface[$counterzone][0];
587 0           my $transform_type = $$translate_surface[$counterzone][1];
588 0           my @surfs_to_transl = @{ $translate_surface->[$counterzone][2] };
  0            
589 0           my @ends_movs = @{ $translate_surface->[$counterzone][3] }; # end points of the movements.
  0            
590 0           my $yes_or_no_update_radiation = $$translate_surface[$counterzone][4];
591 0           my @transform_coordinates = @{ $translate_surface->[$counterzone][5] };
  0            
592 0           my $countersurface = 0;
593 0           my $end_mov;
594             my $mov_surf;
595 0           my $pace;
596 0           my $movement;
597 0           my $surface_letter_constrainedarea;
598 0           my $movement_constrainedarea;
599              
600 0 0         if ( $yes_or_no_transl_surfs eq "y" )
601             {
602 0           foreach my $surface_letter (@surfs_to_transl)
603             {
604 0 0         if ( $stepsvar > 1 )
605             {
606 0 0         if ($transform_type eq "a")
    0          
607             {
608 0           $end_mov = $ends_movs[$countersurface];
609 0           $swing_surf = $end_mov * 2;
610 0           $pace = ( $swing_surf / ( $stepsvar - 1 ) );
611 0           $movement = ( - ( ($end_mov) -( $pace * ( $counterstep - 1 ) ) ) );
612            
613 0           my $printthis =
614             "prj -file $to/cfg/$fileconfig -mode script<
615              
616             m
617             c
618             a
619             $zone_letter
620             e
621             >
622             $surface_letter
623             $transform_type
624             $movement
625             y
626             -
627             -
628             y
629             c
630             -
631             -
632             -
633             -
634             -
635             -
636             -
637             -
638             YYY
639             ";
640              
641 0 0         if ($exeonfiles eq "y") {
642 0           print `$printthis`;
643             }
644 0           print TOSHELL $printthis;
645              
646 0           $countersurface++;
647 0           $countercycles_transl_surfs++;
648             }
649             elsif ($transform_type eq "b")
650             {
651 0           my @coordinates_for_movement =
652 0           @{ $transform_coordinates[$countersurface] };
653 0           my $x_end = $coordinates_for_movement[0];
654 0           my $y_end = $coordinates_for_movement[1];
655 0           my $z_end = $coordinates_for_movement[2];
656 0           my $x_swingtranslate = ( 2 * $x_end );
657 0           my $y_swingtranslate = ( 2 * $y_end );
658 0           my $z_swingtranslate = ( 2 * $z_end );
659 0           my $x_pace = ( $x_swingtranslate / ( $stepsvar - 1 ) );
660 0           my $x_movement = (- ( $x_end - ( $x_pace * ( $counterstep - 1 ) ) ));
661 0           my $y_pace = ( $y_swingtranslate / ( $stepsvar - 1 ) );
662 0           my $y_movement = (- ( $y_end - ( $y_pace * ( $counterstep - 1 ) ) ));
663 0           my $z_pace = ( $z_swingtranslate / ( $stepsvar - 1 ) );
664 0           my $z_movement = (- ( $z_end - ( $z_pace * ( $counterstep - 1 ) ) ));
665              
666 0           my $printthis =
667             "prj -file $to/cfg/$fileconfig -mode script<
668              
669             m
670             c
671             a
672             $zone_letter
673             e
674             >
675             $surface_letter
676             $transform_type
677             $x_movement $y_movement $z_movement
678             y
679             -
680             -
681             y
682             c
683             -
684             -
685             -
686             -
687             -
688             -
689             -
690             -
691             YYY
692             ";
693              
694 0 0         if ($exeonfiles eq "y")
695             {
696 0           print `$printthis`;
697             }
698              
699 0           print TOSHELL $printthis;
700              
701 0           $countersurface++;
702 0           $countercycles_transl_surfs++;
703             }
704             }
705             }
706             }
707             } # END SUB translate_surfaces
708             ##############################################################################
709              
710              
711             ##############################################################################
712             sub rotate_surface
713             {
714 0     0 0   my $to = shift;
715 0           my $fileconfig = shift;
716 0           my $stepsvar = shift;
717 0           my $counterzone = shift;
718 0           my $counterstep = shift;
719 0           my $exeonfiles = shift;
720 0           my $swap = shift;
721 0           my @applytype = @$swap;
722 0           my $zone_letter = $applytype[$counterzone][3];
723 0           my $rotate_surface = shift;
724              
725 0           my $yes_or_no_rotate_surfs = $$rotate_surface[$counterzone][0];
726 0           my @surfs_to_rotate = @{ $rotate_surface->[$counterzone][1] };
  0            
727 0           my @vertexes_numbers = @{ $rotate_surface->[$counterzone][2] };
  0            
728 0           my @swingrotations = @{ $rotate_surface->[$counterzone][3] };
  0            
729 0           my @yes_or_no_apply_to_others = @{ $rotate_surface->[$counterzone][4] };
  0            
730 0           my $configfile = $$rotate_surface[$counterzone][5];
731              
732 0 0         if ( $yes_or_no_rotate_surfs eq "y" )
733             {
734 0           my $counterrotate = 0;
735 0           foreach my $surface_letter (@surfs_to_rotate)
736             {
737 0           $swingrotate = $swingrotations[$counterrotate];
738 0           $pacerotate = ( $swingrotate / ( $stepsvar - 1 ) );
739 0           $rotation_degrees =
740             ( ( $swingrotate / 2 ) - ( $pacerotate * ( $counterstep - 1 ) )) ;
741 0           $vertex_number = $vertexes_numbers[$counterrotate];
742 0           $yes_or_no_apply = $yes_or_no_apply_to_others[$counterrotate];
743 0 0 0       if ( ( $swingrotate != 0 ) and ( $stepsvar > 1 ) and ( $yes_or_no_rotate_surfs eq "y" ) )
      0        
744             {
745 0           my $printthis =
746             "prj -file $to/cfg/$fileconfig -mode script<
747              
748             m
749             c
750             a
751             $zone_letter
752             e
753             >
754             $surface_letter
755             c
756             $vertex_number
757             $rotation_degrees
758             $yes_or_no_apply
759             -
760             -
761             y
762             c
763             -
764             -
765             -
766             -
767             -
768             -
769             -
770             -
771             YYY
772             ";
773 0 0         if ($exeonfiles eq "y")
774             {
775 0           print `$printthis`;
776             }
777              
778 0           print TOSHELL $printthis;
779             }
780 0           $counterrotate++;
781             }
782             }
783             } # END SUB rotate_surface
784             ##############################################################################
785              
786              
787              
788             ##############################################################################
789             sub translate_vertexes #STILL UNFINISHED, NOT WORKING. PROBABLY ALMOST FINISHED. The reference to @base_coordinates is not working.
790             {
791 0     0 0   my $to = shift;
792 0           my $fileconfig = shift;
793 0           my $stepsvar = shift;
794 0           my $counterzone = shift;
795 0           my $counterstep = shift;
796 0           my $exeonfiles = shift;
797 0           my $swap = shift;
798 0           my @applytype = @$swap;
799 0           my $zone_letter = $applytype[$counterzone][3];
800 0           my $swap2 = shift;
801 0           my @translate_vertexes = @$swap2;
802              
803              
804              
805              
806              
807 0           my @v;
808 0           my @verts_to_transl = @{ $translate_vertexes[$counterzone][0] };
  0            
809 0           my @transform_coordinates = @{ $translate_vertexes[$counterzone][1] };
  0            
810 0           my @sourcefiles = @{ $translate_vertexes[$counterzone][2] };
  0            
811 0           my @targetfiles = @{ $translate_vertexes[$counterzone][3] };
  0            
812 0           my @configfiles = @{ $translate_vertexes[$counterzone][4] };
  0            
813 0           my @longmenus = @{ $translate_vertexes[$counterzone][5] };
  0            
814 0           $counteroperations = 0;
815 0           foreach my $sourcefile ( @sourcefiles)
816             {
817 0           my $targetfile = $targetfiles[ $counteroperations ];
818 0           my $configfile = $configfiles[ $counteroperations ];
819 0           my $longmenu = $longmenus[ $counteroperations ];
820 0           my $sourceaddress = "$mypath/$file$sourcefile";
821 0           my $targetaddress = "$mypath/$file$targetfile";
822 0           my $configaddress = "$to/opts/$configfile";
823 0           checkfile($sourceaddress, $targetaddress);
824              
825 0 0         open( SOURCEFILE, $sourceaddress ) or die "Can't open $sourcefile 2: $!\n";
826 0           my @lines = ;
827 0           close SOURCEFILE;
828            
829 0           my $counterlines = 0;
830 0           my $countervert = 0;
831              
832 0           my @vertex_letters;
833 0 0         if ($longmenu eq "y")
834             {
835 0           @vertex_letters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
836             "n", "o", "p", "0\nb\nq", "0\nb\nr", "0\nb\ns", "0\nb\nt", "0\nb\nu", "0\nb\nv",
837             "0\nb\nw", "0\nb\nx", "0\nb\ny", "0\nb\nz", "0\nb\na", "0\nb\nb","0\nb\nc","0\nb\nd",
838             "0\nb\ne","0\nb\n0\nb\nf","0\nb\n0\nb\ng","0\nb\n0\nb\nh","0\nb\n0\nb\ni",
839             "0\nb\n0\nb\nj","0\nb\n0\nb\nk","0\nb\n0\nb\nl","0\nb\n0\nb\nm","0\nb\n0\nb\nn",
840             "0\nb\n0\nb\no","0\nb\n0\nb\np","0\nb\n0\nb\nq","0\nb\n0\nb\nr","0\nb\n0\nb\ns",
841             "0\nb\n0\nb\nt");
842             }
843             else
844             {
845 0           @vertex_letters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
846             "n", "o", "p", "0\nq", "0\nr", "0\ns", "0\nt", "0\nu", "0\nv", "0\nw", "0\nx",
847             "0\ny", "0\nz", "0\na", "0\nb","0\n0\nc","0\n0\nd","0\n0\ne","0\n0\nf","0\n0\ng",
848             "0\n0\nh","0\n0\ni","0\n0\nj","0\n0\nk","0\n0\nl","0\n0\nm","0\n0\nn","0\n0\no",
849             "0\n0\np","0\n0\nq","0\n0\nr","0\n0\ns","0\n0\nt");
850             }
851              
852 0           foreach my $line (@lines)
853             {
854 0           $line =~ s/^\s+//;
855 0           my @rowelements = split(/\s+|,/, $line);
856 0 0         if ($rowelements[0] eq "*vertex" )
857             {
858 0 0         if ($countervert == 0)
859             {
860 0           push (@v, [ "vertexes of $sourceaddress" ]);
861 0           push (@v, [ $rowelements[1], $rowelements[2], $rowelements[3] ], $vertexletters[$countervert] );
862             }
863              
864 0 0         if ($countervert > 0)
865             {
866 0           push (@v, [ $rowelements[1], $rowelements[2], $rowelements[3], $vertexletters[$countervert] ] );
867             }
868 0           $countervert++;
869             }
870 0           $counterlines++;
871             }
872              
873 0 0         if (-e $configaddress)
874             {
875 0           eval `cat $configaddress`; # HERE AN EXTERNAL FILE FOR PROPAGATION OF CONSTRAINTS
876             # IS EVALUATED, AND HERE BELOW CONSTRAINTS ARE PROPAGATED.
877              
878 0           my $countervertex = 0;
879            
880 0           foreach my $vertex_letter (@vertex_letters)
881             {
882 0 0         if ($countervertex > 0)
883             {
884 0 0         if ($vertex_letter eq $v[$countervertex][3])
885             {
886 0           my @base_coordinates = @{ $transform_coordinates[$countervertex] };
  0            
887 0           my $x_end = $base_coordinates[0];
888 0           my $y_end = $base_coordinates[1];
889 0           my $z_end = $base_coordinates[2];
890 0           my $x_swingtranslate = ( 2 * $x_end );
891 0           my $y_swingtranslate = ( 2 * $y_end );
892 0           my $z_swingtranslate = ( 2 * $z_end );
893 0           my $x_pace = ( $x_swingtranslate / ( $stepsvar - 1 ) );
894 0           my $x_movement = (- ( $x_end - ( $x_pace * ( $counterstep - 1 ) ) ));
895 0           my $y_pace = ( $y_swingtranslate / ( $stepsvar - 1 ) );
896 0           my $y_movement = (- ( $y_end - ( $y_pace * ( $counterstep - 1 ) ) ));
897 0           my $z_pace = ( $z_swingtranslate / ( $stepsvar - 1 ) );
898 0           my $z_movement = (- ( $z_end - ( $z_pace * ( $counterstep - 1 ) ) ));
899 0           my $printthis =
900             "prj -file $to/cfg/$fileconfig -mode script<
901              
902             m
903             c
904             a
905             $zone_letter
906             d
907             $vertex_letter
908             $x_movement $y_movement $z_movement
909             -
910             y
911             -
912             y
913             c
914             -
915             -
916             -
917             -
918             -
919             -
920             -
921             -
922             -
923             YYY
924             ";
925 0 0         if ($exeonfiles eq "y")
926             {
927 0           print `$printthis`;
928             }
929              
930 0           print TOSHELL $printthis;
931             }
932             }
933 0           $countervertex++;
934             }
935             }
936 0           $counteroperations++;
937             }
938             } # END SUB translate_vertexes
939              
940              
941             ##############################################################################
942             sub shift_vertexes
943             {
944 0     0 0   my $to = shift;
945 0           my $fileconfig = shift;
946 0           my $stepsvar = shift;
947 0           my $counterzone = shift;
948 0           my $counterstep = shift;
949 0           my $exeonfiles = shift;
950 0           my $swap = shift;
951 0           my @applytype = @$swap;
952 0           my $zone_letter = $applytype[$counterzone][3];
953 0           my $shift_vertexes = shift;
954              
955              
956 0           my $pace;
957             my $movement;
958 0           my $yes_or_no_shift_vertexes = $$shift_vertexes[$counterzone][0];
959 0           my $movementtype = $$shift_vertexes[$counterzone][1];
960 0           my @pairs_of_vertexes = @{ $$shift_vertexes[$counterzone][2] };
  0            
961 0           my @shift_swings = @{ $$shift_vertexes[$counterzone][3] };
  0            
962 0           my $yes_or_no_radiation_update = $$shift_vertexes[$counterzone][4];
963 0           my $configfile = $$shift_vertexes[$counterzone][5];
964              
965 0 0         if ( $stepsvar > 1 )
966             {
967 0 0         if ( $yes_or_no_shift_vertexes eq "y" )
968             {
969              
970 0           my $counterthis = 0;
971 0 0         if ($movementtype eq "j")
    0          
972             {
973 0           foreach my $shift_swing (@shift_swings)
974             {
975 0           $pace = ( $shift_swing / ( $stepsvar - 1 ) );
976 0           $movement_or_vertex =
977             ( ( ($shift_swing) / 2 ) - ( $pace * ( $counterstep - 1 ) ) );
978 0           $vertex1 = $pairs_of_vertexes[ 0 + ( 2 * $counterthis ) ];
979 0           $vertex2 = $pairs_of_vertexes[ 1 + ( 2 * $counterthis ) ];
980            
981 0           my $printthis =
982             "prj -file $to/cfg/$fileconfig -mode script<
983              
984             m
985             c
986             a
987             $zone_letter
988             d
989             ^
990             $movementtype
991             $vertex1
992             $vertex2
993             -
994             $movement_or_vertex
995             y
996             -
997             y
998             -
999             y
1000             -
1001             -
1002             -
1003             -
1004             -
1005             -
1006             -
1007             -
1008             YYY
1009             ";
1010 0 0         if ($exeonfiles eq "y")
1011             {
1012 0           print `$printthis`;
1013             }
1014 0           print TOSHELL $printthis;
1015              
1016 0           $counterthis++;
1017             }
1018             }
1019             elsif ($movementtype eq "h")
1020             {
1021 0           foreach my $shift_swing (@shift_swings)
1022             {
1023 0           my $printthis =
1024             "prj -file $to/cfg/$fileconfig -mode script<
1025              
1026             m
1027             c
1028             a
1029             $zone_letter
1030             d
1031             ^
1032             $movementtype
1033             $vertex1
1034             $vertex2
1035             -
1036             $movement_or_vertex
1037             -
1038             y
1039             n
1040             n
1041             n
1042             -
1043             y
1044             -
1045             y
1046             -
1047             -
1048             -
1049             -
1050             -
1051             -
1052             -
1053             -
1054             YYY
1055             ";
1056 0 0         if ($exeonfiles eq "y")
1057             {
1058 0           print `$printthis`;
1059             }
1060 0           print TOSHELL $printthis;
1061             }
1062             }
1063             }
1064             }
1065             } # END SUB shift_vertexes
1066              
1067              
1068             sub rotate # generic zone rotation
1069             {
1070 0     0 0   my $to = shift;
1071 0           my $fileconfig = shift;
1072 0           my $stepsvar = shift;
1073 0           my $counterzone = shift;
1074 0           my $counterstep = shift;
1075 0           my $exeonfiles = shift;
1076 0           my $swap = shift;
1077 0           my @applytype = @$swap;
1078 0           my $zone_letter = $applytype[$counterzone][3];
1079 0           my $rotate = shift;
1080              
1081              
1082 0           my $rotation_degrees;
1083 0           my $yes_or_no_rotation = "$$rotate[$counterzone][0]";
1084 0           my $yes_or_no_rotate_obstructions =
1085             "$$rotate[$counterzone][1]";
1086 0           my $swingrotate = $$rotate[$counterzone][2];
1087 0           my $yes_or_no_update_radiation =
1088             $$rotate[$counterzone][3];
1089 0           my $base_vertex = $$rotate[$counterzone][4];
1090 0           my $configfile = $$rotate[$counterzone][5];
1091 0           my $pacerotate;
1092 0           my $counter_rotate = 0;
1093 0 0 0       if ( ( $swingrotate != 0 )
      0        
1094             and ( $stepsvar > 1 )
1095             and ( $yes_or_no_rotation eq "y" ) )
1096             {
1097 0           $pacerotate = ( $swingrotate / ( $stepsvar - 1 ) );
1098 0           $rotation_degrees =
1099             ( ( $swingrotate / 2 ) -
1100             ( $pacerotate * ( $counterstep - 1 ) ) );
1101              
1102 0           my $printthis =
1103             "prj -file $to/cfg/$fileconfig -mode script<
1104              
1105              
1106             m
1107             c
1108             a
1109             $zone_letter
1110             i
1111             b
1112             $rotation_degrees
1113             $base_vertex
1114             -
1115             $yes_or_no_rotate_obstructions
1116             -
1117             y
1118             c
1119             -
1120             y
1121             -
1122             -
1123             -
1124             -
1125             -
1126             -
1127             -
1128             -
1129             YYY
1130             ";
1131 0 0         if ($exeonfiles eq "y")
1132             {
1133 0           print `$printthis`;
1134             }
1135 0           print TOSHELL $printthis;
1136             }
1137             } # END SUB rotate
1138             ##############################################################################
1139              
1140              
1141             ##############################################################################
1142             sub rotatez # PUT THE ROTATION POINT AT POINT 0, 0, 0. I HAVE NOT YET MADE THE FUNCTION GENERIC ENOUGH.
1143             {
1144 0     0 0   my $to = shift;
1145 0           my $fileconfig = shift;
1146 0           my $stepsvar = shift;
1147 0           my $counterzone = shift;
1148 0           my $counterstep = shift;
1149 0           my $exeonfiles = shift;
1150 0           my $swap = shift;
1151 0           my @applytype = @$swap;
1152 0           my $zone_letter = $applytype[$counterzone][3];
1153 0           my $rotatez = shift;
1154              
1155              
1156 0           my $yes_or_no_rotation = "$$rotatez[0]";
1157 0           my @centerpoints = @{$$rotatez[1]};
  0            
1158 0           my $centerpointsx = $centerpoints[0];
1159 0           my $centerpointsy = $centerpoints[1];
1160 0           my $centerpointsz = $centerpoints[2];
1161 0           my $plane_of_rotation = "$$rotatez[2]";
1162 0           my $infile = "$to/zones/$applytype[$counterzone][2]";
1163 0           my $infile2 = "$to/cfg/$applytype[$counterzone][2]";
1164 0           my $outfile = "erase";
1165 0           my $outfile2 = "$to/zones/$applytype[$counterzone][2]eraseobtained";
1166 0 0         open(INFILE, "$infile") or die "Can't open infile $infile: $!\n";
1167 0 0         open(OUTFILE2, ">>$outfile2") or die "Can't open outfile2 $outfile2: $!\n";
1168 0           my @lines = ;
1169 0           close(INFILE);
1170 0           my $counterline = 0;
1171 0           my $countercases=0;
1172 0           my @vertexes;
1173 0           my $swingrotate = $$rotatez[3];
1174 0           my $alreadyrotation = $$rotatez[4];
1175 0           my $rotatexy = $$rotatez[5];
1176 0           my $swingrotatexy = $$rotatez[6];
1177 0           my $pacerotate;
1178 0           my $counter_rotate = 0;
1179 0           my $linenew;
1180             my $linenew2;
1181 0           my @rowprovv;
1182 0           my @rowprovv2;
1183 0           my @row;
1184 0           my @row2;
1185 0 0 0       if ( $stepsvar > 1 and ( $yes_or_no_rotation eq "y" ) )
1186             {
1187 0           foreach $line (@lines)
1188             {#
1189             {
1190 0           $linenew = $line;
  0            
1191 0           $linenew =~ s/\:\s/\:/g ;
1192 0           @rowprovv = split(/\s+/, $linenew);
1193 0           $rowprovv[0] =~ s/\:\,/\:/g ;
1194 0           @row = split(/\,/, $rowprovv[0]);
1195 0 0         if ($row[0] eq "*vertex")
1196 0           { push (@vertexes, [$row[1], $row[2], $row[3]] ) }
1197             }
1198 0           $counterline = $counterline +1;
1199             }
1200              
1201 0           foreach $vertex (@vertexes)
1202             {
1203 0           print OUTFILE "vanilla ${$vertex}[0], ${$vertex}[1], ${$vertex}[2]\n";
  0            
  0            
  0            
1204             }
1205 0           foreach $vertex (@vertexes)
1206             {
1207 0           ${$vertex}[0] = (${$vertex}[0] - $centerpointsx);
  0            
  0            
1208 0           ${$vertex}[0] = sprintf("%.5f", ${$vertex}[0]);
  0            
  0            
1209 0           ${$vertex}[1] = (${$vertex}[1] - $centerpointsy);
  0            
  0            
1210 0           ${$vertex}[1] = sprintf("%.5f", ${$vertex}[1]);
  0            
  0            
1211 0           ${$vertex}[2] = (${$vertex}[2] - $centerpointsz);
  0            
  0            
1212 0           ${$vertex}[2] = sprintf("%.5f", ${$vertex}[2]);
  0            
  0            
1213 0           print OUTFILE "aftersum ${$vertex}[0], ${$vertex}[1], ${$vertex}[2]\n";
  0            
  0            
  0            
1214             }
1215              
1216 0           my $anglealready = deg2rad(-$alreadyrotation);
1217 0           foreach $vertex (@vertexes)
1218             {
1219 0           my $x_new = cos($anglealready)*${$vertex}[0] - sin($anglealready)*${$vertex}[1];
  0            
  0            
1220 0           my $y_new = sin($anglealready)*${$vertex}[0] + cos($anglealready)*${$vertex}[1];
  0            
  0            
1221 0           ${$vertex}[0] = $x_new; ${$vertex}[0] = sprintf("%.5f", ${$vertex}[0]);
  0            
  0            
  0            
  0            
1222 0           ${$vertex}[1] = $y_new; ${$vertex}[1] = sprintf("%.5f", ${$vertex}[1]);
  0            
  0            
  0            
  0            
1223 0           print OUTFILE "afterfirstrotation ${$vertex}[0], ${$vertex}[1], ${$vertex}[2]\n";
  0            
  0            
  0            
1224             }
1225              
1226 0           $pacerotate = ( $swingrotate / ( $stepsvar - 1) );
1227 0           $rotation_degrees = - ( ($swingrotate / 2) - ($pacerotate * ($counterstep -1) ) );
1228 0           my $angle = deg2rad($rotation_degrees);
1229 0           foreach $vertex (@vertexes)
1230             {
1231 0           my $y_new = cos($angle)*${$vertex}[1] - sin($angle)*${$vertex}[2];
  0            
  0            
1232 0           my $z_new = sin($angle)*${$vertex}[1] + cos($angle)*${$vertex}[2];
  0            
  0            
1233 0           ${$vertex}[1] = $y_new; ${$vertex}[1] = sprintf("%.5f", ${$vertex}[1]);
  0            
  0            
  0            
  0            
1234 0           ${$vertex}[2] = $z_new; ${$vertex}[2] = sprintf("%.5f", ${$vertex}[2]);
  0            
  0            
  0            
  0            
1235 0           ${$vertex}[0] = sprintf("%.5f", ${$vertex}[0]);
  0            
  0            
1236 0           print OUTFILE "aftersincos ${$vertex}[0], ${$vertex}[1], ${$vertex}[2]\n";
  0            
  0            
  0            
1237             }
1238              
1239 0           my $angleback = deg2rad($alreadyrotation);
1240 0           foreach $vertex (@vertexes)
1241             {
1242 0           my $x_new = cos($angleback)*${$vertex}[0] - sin($angleback)*${$vertex}[1];
  0            
  0            
1243 0           my $y_new = sin($angleback)*${$vertex}[0] + cos($angleback)*${$vertex}[1];
  0            
  0            
1244 0           ${$vertex}[0] = $x_new; ${$vertex}[0] = sprintf("%.5f", ${$vertex}[0]);
  0            
  0            
  0            
  0            
1245 0           ${$vertex}[1] = $y_new; ${$vertex}[1] = sprintf("%.5f", ${$vertex}[1]);
  0            
  0            
  0            
  0            
1246 0           print OUTFILE "afterrotationback ${$vertex}[0], ${$vertex}[1], ${$vertex}[2]\n";ctl type
  0            
  0            
  0            
  0            
1247             }
1248              
1249 0           foreach $vertex (@vertexes)
1250             {
1251 0           ${$vertex}[0] = ${$vertex}[0] + $centerpointsx; ${$vertex}[0] = sprintf("%.5f", ${$vertex}[0]);
  0            
  0            
  0            
  0            
  0            
1252 0           ${$vertex}[1] = ${$vertex}[1] + $centerpointsy; ${$vertex}[1] = sprintf("%.5f", ${$vertex}[1]);
  0            
  0            
  0            
  0            
  0            
1253 0           ${$vertex}[2] = ${$vertex}[2] + $centerpointsz; ${$vertex}[2] = sprintf("%.5f", ${$vertex}[2]);
  0            
  0            
  0            
  0            
  0            
1254 0           print OUTFILE "after final substraction ${$vertex}[0], ${$vertex}[1], ${$vertex}[2]\n";
  0            
  0            
  0            
1255             }
1256              
1257 0           my $counterwrite = -1;
1258 0           my $counterwriteand1;
1259 0           foreach $line (@lines)
1260             {#
1261              
1262 0           $linenew2 = $line;
1263 0           $linenew2 =~ s/\:\s/\:/g ;
1264 0           my @rowprovv2 = split(/\s+/, $linenew2);
1265 0           $rowprovv2[0] =~ s/\:\,/\:/g ;
1266 0           @row2 = split(/\,/, $rowprovv2[0]);
1267 0           $counterwriteright = ($counterwrite - 5);
1268 0           $counterwriteand1 = ($counterwrite + 1);
1269 0 0         if ($row2[0] eq "*vertex")
1270             {
1271 0 0         if ( $counterwrite == - 1) { $counterwrite = 0 }
  0            
1272 0           print OUTFILE2
1273 0           "*vertex"."\,"."${$vertexes[$counterwrite]}[0]"."\,"."${$vertexes[$counterwrite]}[1]"."\,"."${$vertexes[$counterwrite]}[2]"." # "."$counterwriteand1\n";
  0            
  0            
1274             }
1275             else
1276             {
1277 0           print OUTFILE2 "$line";
1278             }
1279 0 0         if ( $counterwrite > ( - 1 ) ) { $counterwrite++; }
  0            
1280             }
1281              
1282 0           close(OUTFILE);
1283 0 0         if ($exeonfiles eq "y") { print `chmod 777 $infile`; }
  0            
1284 0           print TOSHELL "chmod -R 777 $infile\n";
1285 0 0         if ($exeonfiles eq "y") { print `chmod 777 $infile2`; }
  0            
1286 0           print TOSHELL "chmod -R 777 $infile2\n";
1287 0 0         if ($exeonfiles eq "y") { print `rm $infile`; }
  0            
1288 0           print TOSHELL "rm $infile\n";
1289 0 0         if ($exeonfiles eq "y") { print `chmod 777 $outfile2`; }
  0            
1290 0           print TOSHELL "chmod 777 $outfile2\n";
1291 0 0         if ($exeonfiles eq "y") { print `cp $outfile2 $infile`; }
  0            
1292 0           print TOSHELL "cp $outfile2 $infile\n";
1293 0 0         if ($exeonfiles eq "y") { print `cp $outfile2 $infile2`; }
  0            
1294 0           print TOSHELL "cp $outfile2 $infile2\n";
1295             }
1296             } # END SUB rotatez
1297             ##############################################################################
1298              
1299              
1300             ##############################################################################
1301             sub make_generic_change # WITH THIS FUNCTION YOU TARGET PORTIONS OF A FILE AND YOU CHANGE THEM.
1302             {
1303 0     0 0   my $to = shift;
1304 0           my $fileconfig = shift;
1305 0           my $stepsvar = shift;
1306 0           my $counterzone = shift;
1307 0           my $counterstep = shift;
1308 0           my $exeonfiles = shift;
1309 0           my $swap = shift;
1310 0           my @applytype = @$swap;
1311 0           my $zone_letter = $applytype[$counterzone][3];
1312 0           my $swap2 = shift;
1313 0           my @generic_change = @$swap2;
1314              
1315              
1316 0           my $infile = "$to/zones/$applytype[$counterzone][2]";
1317 0           my $outfile = "$to/zones/$applytype[$counterzone][2]provv";
1318 0 0         open( INFILE, "$infile" ) or die "Can't open $infile 2: $!\n";
1319 0 0         open( OUTFILE, ">$outfile" ) or die "Can't open $outfile: $!\n";
1320 0           my @lines = ;
1321 0           close(INFILE);
1322 0           my $counterline = 0;
1323 0           my $countercases = 0;
1324              
1325 0           foreach $line (@lines)
1326             { #
1327 0           $linetochange = ( $generic_change[$counterzone][$countercases][1] );
1328 0 0         if ( $counterline == ( $linetochange - 1 ) )
1329             { #
1330 0           $linetochange = ( $generic_change[$counterzone][$counter_conditions][$countercases][1] );
1331 0           $cases = $#{ generic_change->[$counterzone][$counter_conditions] };
  0            
1332 0           $swing1 = $generic_change[$counterzone][$countercases][2][2];
1333 0           $swing2 = $generic_change[$counterzone][$countercases][3][2];
1334 0           $swing3 = $generic_change[$counterzone][$countercases][4][2];
1335 0 0 0       if ( ( $stepsvar > 1 )
    0 0        
    0          
1336             and ( $tiepacestofirst eq "n" ) )
1337             {
1338 0           $pace1 = ( $swing1 / ( $stepsvar - 1 ) );
1339 0           $pace2 = ( $swing2 / ( $stepsvar - 1 ) );
1340 0           $pace3 = ( $swing3 / ( $stepsvar - 1 ) );
1341             } elsif ( ( $stepsvar > 1 )
1342             and ( $tiepacestofirst eq "y" ) )
1343             {
1344 0           $pace1 = ( $swing1 / ( $stepsvar - 1 ) );
1345 0           $pace2 = ( $swing2 / ( $stepsvar - 1 ) );
1346 0           $pace3 = ( $swing3 / ( $stepsvar - 1 ) );
1347             } elsif ( $stepsvar == 1 )
1348             {
1349 0           $pace1 = 0;
1350 0           $pace2 = 0;
1351 0           $pace3 = 0;
1352             }
1353 0           $digits1 = $generic_change[$counterzone][$countercases][2][3];
1354 0           $digits2 = $generic_change[$counterzone][$countercases][3][3];
1355 0           $digits3 = $generic_change[$counterzone][$countercases][4][3];
1356 0           $begin_read_column1 = $generic_change[$counterzone][$countercases][2][0] - 1;
1357 0           $begin_read_column2 = $generic_change[$counterzone][$countercases][3][0] - 1;
1358 0           $begin_read_column3 = $generic_change[$counterzone][$countercases][4][0] - 1;
1359 0           $length_read_string1 = $generic_change[$counterzone][$countercases][2][1] + 1;
1360 0           $length_read_string2 = $generic_change[$counterzone][$countercases][3][1] + 1;
1361 0           $length_read_string3 = $generic_change[$counterzone][$countercases][4][1] + 1;
1362             ########## COMPLETE HERE ->
1363 0           $numbertype = "f"; #floating
1364 0           $to_substitute1 =
1365             substr( $line, $begin_read_column1, $length_read_string1 );
1366 0           $substitute_provv1 = ( $to_substitute1 - ( $swing1 / 2 ) + ( $pace1 * $counterstep ) );
1367 0           $substitute1 = sprintf( "%.$digits1$numbertype", $substitute_provv1 );
1368 0           $to_substitute2 = substr( $line, $begin_read_column2, $length_read_string2 );
1369 0           $substitute_provv2 = ( $to_substitute2 - ( $swing2 / 2 ) + ( $pace2 * $counterstep ) );
1370 0           $substitute2 = sprintf( "%.$digits2$numbertype", $substitute_provv2 );
1371 0           $to_substitute3 = substr( $line, $begin_read_column3, $length_read_string3 );
1372 0           $substitute_provv3 = ( $to_substitute3 - ( $swing3 / 2 ) + ( $pace3 * $counterstep ) );
1373 0           $substitute3 = sprintf( "%.$digits3$numbertype", $substitute_provv3 );
1374              
1375 0 0         if ( $substitute1 >= 0 )
1376             {
1377 0           $begin_write_column1 = $generic_change[$counterzone][$countercases][2][0];
1378 0           $length_write_string1 = $generic_change[$counterzone][$countercases][2][1];
1379             } else
1380             {
1381 0           $begin_write_column1 = $generic_change[$counterzone][$countercases][2][0] - 1;
1382 0           $length_write_string1 = $generic_change[$counterzone][$countercases][2][1] + 1;
1383             }
1384 0 0         if ( $substitute2 >= 0 )
1385             {
1386 0           $begin_write_column2 = $generic_change[$counterzone][$countercases][3][0];
1387 0           $length_write_string2 = $generic_change[$counterzone][$countercases][3][1];
1388             } else
1389             {
1390 0           $begin_write_column2 =$generic_change[$counterzone][$countercases][3][0] - 1;
1391 0           $length_write_string2 = $generic_change[$counterzone][$countercases][3][1] + 1;
1392             }
1393 0 0         if ( $substitute3 >= 0 )
1394             {
1395 0           $begin_write_column3 = $generic_change[$counterzone][$countercases][4][0];
1396 0           $length_write_string3 = $generic_change[$counterzone][$countercases][4][1];
1397             } else
1398             {
1399 0           $begin_write_column3 = $generic_change[$counterzone][$countercases][4][0] - 1;
1400 0           $length_write_string3 = $generic_change[$counterzone][$countercases][4][1] + 1;
1401             }
1402 0           substr( $line, $begin_write_column1, $length_write_string1, $substitute1 );
1403 0           substr( $line, $begin_write_column2, $length_write_string2, $substitute2 );
1404 0           substr( $line, $begin_write_column3, $length_write_string3, $substitute3 );
1405 0           print OUTFILE "$line";
1406 0           $countercases = $countercases + 1;
1407             } else
1408             {
1409 0           print OUTFILE "$line";
1410             }
1411 0           $counterline = $counterline + 1;
1412             }
1413 0           close(OUTFILE);
1414 0 0         if ($exeonfiles eq "y") { print `chmod -R 755 $infile`; }
  0            
1415 0           print TOSHELL "chmod -R 755 $infile\n";
1416 0 0         if ($exeonfiles eq "y") { print `chmod -R 755 $outfile`; }
  0            
1417 0           print TOSHELL
1418             "chmod -R 755 $outfile\n";
1419 0 0         if ($exeonfiles eq "y") { print `cp -f $outfile $infile`; }
  0            
1420 0           print TOSHELL
1421             "cp -f $outfile $infile\n";
1422             } # END SUB generic_change
1423             ##############################################################################
1424              
1425              
1426             ##############################################################################
1427             sub reassign_construction
1428             {
1429 0     0 0   my $to = shift;
1430 0           my $fileconfig = shift;
1431 0           my $stepsvar = shift;
1432 0           my $counterzone = shift;
1433 0           my $counterstep = shift;
1434 0           my $exeonfiles = shift;
1435 0           my $swap = shift;
1436 0           my @applytype = @$swap;
1437 0           my $zone_letter = $applytype[$counterzone][3];
1438 0           my $construction_reassignment = shift;
1439              
1440              
1441 0           my $yes_or_no_reassign_construction = $$construction_reassignment[$counterzone][0];
1442 0 0         if ( $yes_or_no_reassign_construction eq "y" )
1443             {
1444 0           my @surfaces_to_reassign =
1445 0           @{ $construction_reassignment->[$counterzone][1]
1446             };
1447 0           my @constructions_to_choose =
1448 0           @{ $construction_reassignment->[$counterzone][2] };
1449 0           my $configfile = $$construction_reassignment[$counterzone][3];
1450 0           my $surface_letter;
1451 0           my $counter = 0;
1452 0           my @reassign_constructions;
1453              
1454 0           foreach $surface_to_reassign (@surfaces_to_reassign)
1455             {
1456 0           $construction_to_choose = $constructions_to_choose[$counter][$counterstep];
1457            
1458 0           my $printthis =
1459             "prj -file $to/cfg/$fileconfig -mode script<
1460              
1461             m
1462             c
1463             a
1464             $zone_letter
1465             f
1466             $surface_to_reassign
1467             e
1468             n
1469             y
1470             $construction_to_choose
1471             -
1472             -
1473             -
1474             -
1475             y
1476             y
1477             -
1478             -
1479             -
1480             -
1481             -
1482             -
1483             -
1484             -
1485             YYY
1486             ";
1487 0 0         if ($exeonfiles eq "y")
1488             {
1489 0           print `$printthis`;
1490             }
1491              
1492 0           print TOSHELL $printthis;
1493 0           $counter++;
1494             }
1495             }
1496             } # END SUB reassign_construction
1497             ##############################################################################
1498              
1499              
1500             ##############################################################################
1501             sub change_thickness
1502             {
1503 0     0 0   my $to = shift;
1504 0           my $fileconfig = shift;
1505 0           my $stepsvar = shift;
1506 0           my $counterzone = shift;
1507 0           my $counterstep = shift;
1508 0           my $exeonfiles = shift;
1509 0           my $swap = shift;
1510 0           my @applytype = @$swap;
1511 0           my $zone_letter = $applytype[$counterzone][3];
1512 0           my $thickness_change = shift;
1513              
1514              
1515 0           my $yes_or_no_change_thickness = $$thickness_change[$counterzone][0];
1516 0           my @entries_to_change = @{ $$thickness_change[$counterzone][1] };
  0            
1517 0           my @groups_of_strata_to_change = @{ $$thickness_change[$counterzone][2] };
  0            
1518 0           my @groups_of_couples_of_min_max_values = @{ $$thickness_change[$counterzone][3] };
  0            
1519 0           my $configfile = $$thickness_change[$counterzone][4];
1520 0           my $thiscounter = 0;
1521 0           my $entry_to_change;
1522             my $counterstrata;
1523 0           my @strata_to_change;
1524 0           my $stratum_to_change;
1525 0           my @min_max_values;
1526 0           my $min;
1527 0           my $max;
1528 0           my $change_stratum;
1529 0           my @change_strata;
1530 0           my $enter_change_entry;
1531 0           my @change_entries;
1532 0           my $swing;
1533 0           my $pace;
1534 0           my $thickness;
1535 0           my @change_entries_with_thicknesses;
1536              
1537 0 0         if ( $stepsvar > 1 )
1538             {
1539 0           foreach $entry_to_change (@entries_to_change)
1540             {
1541 0           @strata_to_change =
1542 0           @{ $groups_of_strata_to_change[$thiscounter]
1543             };
1544 0           $counterstrata = 0;
1545 0           foreach $stratum_to_change (@strata_to_change)
1546             {
1547 0           @min_max_values =
1548 0           @{ $groups_of_couples_of_min_max_values[$thiscounter][$counterstrata] };
1549 0           $min = $min_max_values[0];
1550 0           $max = $min_max_values[1];
1551 0           $swing = $max - $min;
1552 0           $pace = ( $swing / ( $stepsvar - 1 ) );
1553 0           $thickness = $min + ( $pace * ( $counterstep - 1 ) );
1554              
1555 0           my $printthis =
1556             "prj -file $to/cfg/$fileconfig -mode script<
1557             b
1558             e
1559             a
1560             $entry_to_change
1561             $stratum_to_change
1562             n
1563             $thickness
1564             -
1565             -
1566             y
1567             y
1568             -
1569             y
1570             y
1571             -
1572             -
1573             -
1574             -
1575             -
1576             YYY
1577             ";
1578 0 0         if ($exeonfiles eq "y")
1579             {
1580 0           print `$printthis`;
1581             }
1582 0           print TOSHELL $printthis;
1583 0           $counterstrata++;
1584             }
1585 0           $thiscounter++;
1586             }
1587 0           $" = " ";
1588 0 0         if ($exeonfiles eq "y") { print `$enter_esp$go_to_construction_database@change_entries_with_thicknesses$exit_construction_database_and_esp`; }
  0            
1589 0           print TOSHELL "$enter_esp$go_to_construction_database@change_entries_with_thicknesses$exit_construction_database_and_esp\n";
1590             }
1591             } # END sub change_thickness
1592             ##############################################################################
1593              
1594              
1595             ##############################################################################
1596             sub obs_modify
1597             {
1598 0 0   0 0   if ( $stepsvar > 1 )
1599             {
1600 0           my $to = shift;
1601 0           my $fileconfig = shift;
1602 0           my $stepsvar = shift;
1603 0           my $counterzone = shift;
1604 0           my $counterstep = shift;
1605 0           my $exeonfiles = shift;
1606 0           my $swap = shift;
1607 0           my @applytype = @$swap;
1608 0           my $zone_letter = $applytype[$counterzone][3];
1609 0           my $obs_modify = shift;
1610              
1611              
1612 0           my @obs_letters = @{ $$obs_modify[$counterzone][0] };
  0            
1613 0           my $modification_type = $$obs_modify[$counterzone][1];
1614 0           my @values = @{ $$obs_modify[$counterzone][2] };
  0            
1615 0           my @base = @{ $$obs_modify[$counterzone][3] };
  0            
1616 0           my $configfile = $$obs_modify[$counterzone][4];
1617 0           my $xz_resolution = $$obs_modify[$counterzone][5];
1618 0           my $countobs = 0;
1619 0           my $x_end;
1620             my $y_end;
1621 0           my $z_end;
1622 0           my $x_base;
1623 0           my $y_base;
1624 0           my $z_base;
1625 0           my $end_value;
1626 0           my $base_value;
1627 0           my $x_swingtranslate;
1628 0           my $y_swingtranslate;
1629 0           my $z_swingtranslate;
1630 0           my $x_pace;
1631 0           my $x_value;
1632 0           my $y_pace;
1633 0           my $y_value;
1634 0           my $z_pace;
1635 0           my $z_value;
1636 0 0 0       if ( ($modification_type eq "a") or ($modification_type eq "b"))
1637             {
1638 0           $x_end = $values[0];
1639 0           $y_end = $values[1];
1640 0           $z_end = $values[2];
1641 0           $x_base = $base[0];
1642 0           $y_base = $base[1];
1643 0           $z_base = $base[2];
1644 0           $x_swingtranslate = ( 2 * $x_end );
1645 0           $y_swingtranslate = ( 2 * $y_end );
1646 0           $z_swingtranslate = ( 2 * $z_end );
1647 0           $x_pace = ( $x_swingtranslate / ( $stepsvar - 1 ) );
1648 0           $x_value = ($x_base + ( $x_end - ( $x_pace * ( $counterstep - 1 ) ) ));
1649 0           $y_pace = ( $y_swingtranslate / ( $stepsvar - 1 ) );
1650 0           $y_value = ($y_base + ( $y_end - ( $y_pace * ( $counterstep - 1 ) ) ));
1651 0           $z_pace = ( $z_swingtranslate / ( $stepsvar - 1 ) );
1652 0           $z_value = ($z_base + ( $z_end - ( $z_pace * ( $counterstep - 1 ) ) ));
1653              
1654 0           my $printthis =
1655             "prj -file $to/cfg/$fileconfig -mode script<
1656              
1657             m
1658             c
1659             a
1660             $zone_letter
1661             h
1662             a
1663             $obs_letter
1664             $modification_type
1665             a
1666             $x_value $y_value $z_value
1667             -
1668             -
1669             c
1670             -
1671             c
1672             -
1673             -
1674             -
1675             -
1676             -
1677             -
1678             -
1679             -
1680             YYY
1681             ";
1682 0           foreach my $obs_letter (@obs_letters)
1683             {
1684 0 0         if ($exeonfiles eq "y")
1685             {
1686 0           print `$printthis`;
1687             }
1688 0           print TOSHELL $printthis;
1689 0           $countobs++;
1690             }
1691             }
1692              
1693 0 0 0       if ( ($modification_type eq "c") or ($modification_type eq "d"))
1694             {
1695 0           $x_end = $values[0];
1696 0           $x_base = $base[0];
1697 0           $x_swingtranslate = ( 2 * $x_end );
1698 0           $x_pace = ( $x_swingtranslate / ( $stepsvar - 1 ) );
1699 0           $x_value = ($x_base + ( $x_end - ( $x_pace * ( $counterstep - 1 ) ) ));
1700              
1701 0           foreach my $obs_letter (@obs_letters)
1702             {
1703 0           my $printthis =
1704             "prj -file $to/cfg/$fileconfig -mode script<
1705              
1706             m
1707             c
1708             a
1709             $zone_letter
1710             h
1711             a
1712             $obs_letter
1713             $modification_type
1714             $x_value
1715             -
1716             -
1717             c
1718             -
1719             c
1720             -
1721             -
1722             -
1723             -
1724             -
1725             -
1726             -
1727             -
1728             YYY
1729             ";
1730 0 0         if ($exeonfiles eq "y")
1731             {
1732 0           print `$printthis`;
1733             }
1734 0           print TOSHELL $printthis;
1735 0           $countobs++;
1736             }
1737             }
1738              
1739 0 0         if ($modification_type eq "g")
1740             {
1741 0           foreach my $obs_letter (@obs_letters)
1742             {
1743 0           my $count = 0;
1744 0           foreach my $x_value (@values)
1745             {
1746 0 0         if ($count < $stepsvar)
1747             {
1748 0           my $printthis =
1749             "prj -file $to/cfg/$fileconfig -mode script<
1750              
1751             m
1752             c
1753             a
1754             $zone_letter
1755             h
1756             a
1757             $obs_letter
1758             $modification_type
1759             $x_value
1760             -
1761             -
1762             -
1763             -
1764             -
1765             -
1766             -
1767             -
1768             -
1769             -
1770             -
1771             -
1772             -
1773             -
1774             YYY
1775             ";
1776 0 0         if ($exeonfiles eq "y")
1777             {
1778 0           print `$printthis`;
1779             }
1780 0           print TOSHELL $printthis;
1781 0           $countobs++;
1782 0           $count++;
1783             }
1784             }
1785             }
1786             }
1787              
1788 0 0         if ($modification_type eq "h")
1789             {
1790 0           $x_end = $values[0];
1791 0           $x_base = $base[0];
1792 0           $x_swingtranslate = ( $x_base - $x_end );
1793 0           $x_pace = ( $x_swingtranslate / ( $stepsvar - 1 ) );
1794 0           $x_value = ($x_base - ( $x_pace * ( $counterstep - 1 ) ));
1795              
1796 0           foreach my $obs_letter (@obs_letters)
1797             {
1798 0           my $printthis =
1799             "prj -file $to/cfg/$fileconfig -mode script<
1800              
1801             m
1802             c
1803             a
1804             $zone_letter
1805             h
1806             a
1807             $obs_letter
1808             $modification_type
1809             $x_value
1810             -
1811             -
1812             -
1813             -
1814             -
1815             -
1816             -
1817             -
1818             -
1819             -
1820             -
1821             -
1822             -
1823             -
1824             YYY
1825             ";
1826 0 0         if ($exeonfiles eq "y")
1827             {
1828 0           print `$printthis`;
1829             }
1830 0           print TOSHELL $printthis;
1831 0           $countobs++;
1832             }
1833             }
1834              
1835 0 0         if ($modification_type eq "t")
1836             {
1837 0           my $modification_type = "~";
1838 0           my $what_todo = $base[0];
1839 0           $x_end = $values[0];
1840 0           $y_end = $values[1];
1841 0           $z_end = $values[2];
1842 0           $x_swingtranslate = ( 2 * $x_end );
1843 0           $y_swingtranslate = ( 2 * $y_end );
1844 0           $z_swingtranslate = ( 2 * $z_end );
1845 0           $x_pace = ( $x_swingtranslate / ( $stepsvar - 1 ) );
1846 0           $x_value = ( $x_end - ( $x_pace * ( $counterstep - 1 ) ) );
1847 0           $y_pace = ( $y_swingtranslate / ( $stepsvar - 1 ) );
1848 0           $y_value = ( $y_end - ( $y_pace * ( $counterstep - 1 ) ) );
1849 0           $z_pace = ( $z_swingtranslate / ( $stepsvar - 1 ) );
1850 0           $z_value = ( $z_end - ( $z_pace * ( $counterstep - 1 ) ) );
1851              
1852 0           foreach my $obs_letter (@obs_letters)
1853             {
1854 0           my $printthis =
1855             "prj -file $to/cfg/$fileconfig -mode script<
1856              
1857             m
1858             c
1859             a
1860             $zone_letter
1861             h
1862             a
1863             $modification_type
1864             $what_todo
1865             $obs_letter
1866             -
1867             $x_value $y_value $z_value
1868             -
1869             c
1870             -
1871             c
1872             -
1873             -
1874             -
1875             -
1876             -
1877             -
1878             -
1879             -
1880             YYY
1881             ";
1882 0 0         if ($exeonfiles eq "y")
1883             {
1884 0           print `$printthis`;
1885             }
1886 0           print TOSHELL $printthis;
1887 0           $countobs++;
1888             }
1889             }
1890              
1891             #NOW THE XZ GRID RESOLUTION WILL BE PUT TO THE SPECIFIED VALUE
1892 0           my $printthis = #THIS IS WHAT HAPPEN INSIDE SUB KEEP_SOME_OBSTRUCTIONS
1893             "prj -file $to/cfg/$fileconfig -mode script<
1894              
1895              
1896             m
1897             c
1898             a
1899             $zone_letter
1900             h
1901             a
1902             a
1903             $xz_resolution
1904             -
1905             c
1906             -
1907             c
1908             -
1909             -
1910             -
1911             -
1912             -
1913             -
1914             -
1915             YYY
1916             ";
1917 0 0         if ($exeonfiles eq "y")
1918             {
1919 0           print `$printthis`;
1920             }
1921 0           print TOSHELL $printthis;
1922             }
1923             } # END SUB obs_modify. FIX THE INDENTATION.
1924             ##############################################################################
1925              
1926              
1927             ##############################################################################
1928             sub bring_obstructions_back # TO BE REWRITTEN BETTER
1929             {
1930 0     0 0   my $to = shift;
1931 0           my $fileconfig = shift;
1932 0           my $stepsvar = shift;
1933 0           my $counterzone = shift;
1934 0           my $counterstep = shift;
1935 0           my $exeonfiles = shift;
1936 0           my $swap = shift;
1937 0           my @applytype = @$swap;
1938 0           my $zone_letter = $applytype[$counterzone][3];
1939 0           my $keep_obstructions = shift;
1940              
1941              
1942 0           my $yes_or_no_keep_some_obstructions = $$keep_obstructions[$counterzone][0];
1943 0           my $yes_or_no_update_radiation_provv = $$keep_obstructions[$counterzone][2];
1944 0           my $yes_or_no_update_radiation;
1945 0           my $configfile = $$keep_obstructions[$counterzone][3];
1946 0           my $xz_resolution = $$keep_obstructions[$counterzone][4];
1947 0 0         if ( $yes_or_no_update_radiation_provv eq "y" )
1948             {
1949 0           $yes_or_no_update_radiation = "a";
1950             } else
1951             {
1952 0           $yes_or_no_update_radiation = "c";
1953             }
1954 0 0         if ( $yes_or_no_keep_some_obstructions eq "y" )
1955             {
1956 0           my @group_of_obstructions_to_keep = @{ $$keep_obstructions[$counterzone][1] };
  0            
1957 0           my $keep_obs_counter = 0;
1958 0           my @obstruction_to_keep;
1959 0           foreach (@group_of_obstructions_to_keep)
1960             {
1961 0           @obstruction_to_keep =
1962 0           @{ $group_of_obstructions_to_keep[$keep_obs_counter] };
1963 0           my $obstruction_letter =
1964             "$obstruction_to_keep[0]";
1965 0           my $rotation_z = "$obstruction_to_keep[1]";
1966 0           my $rotation_y = "$obstruction_to_keep[2]"; # NOT YET IMPLEMENTED
1967 0           my $x_origin = "$obstruction_to_keep[3]";
1968 0           my $y_origin = "$obstruction_to_keep[4]";
1969 0           my $z_origin = "$obstruction_to_keep[5]";
1970             # $rotation_degrees used here is absolute, not local.
1971             # This is dangerous and it has to change.
1972              
1973 0           my $printthis =
1974             "prj -file $to/cfg/$fileconfig -mode script<
1975              
1976              
1977             m
1978             c
1979             a
1980             $zone_letter
1981             h
1982             a
1983             $obstruction_letter
1984             a
1985             a
1986             $x_origin $y_origin $z_origin
1987             c
1988             $rotation_z
1989             -
1990             -
1991             c
1992             -
1993             c
1994             -
1995             -
1996             -
1997             -
1998             -
1999             -
2000             -
2001             YYY
2002             ";
2003 0 0         if ($exeonfiles eq "y")
2004             {
2005 0           print `$printthis`;
2006             }
2007 0           print TOSHELL $printthis;
2008 0           $keep_obs_counter++;
2009             }
2010              
2011             # NOW THE XZ GRID RESOLUTION WILL BE PUT TO THE SPECIFIED VALUE
2012 0           my $printthis =
2013             "
2014             ";
2015 0 0         if ($exeonfiles eq "y")
2016             {
2017 0           print `$printthis`;
2018             }
2019 0           print TOSHELL $printthis;
2020             }
2021             } # END SUB bring_obstructions_back
2022             ##################################################################
2023              
2024              
2025             ##################################################################
2026             sub recalculateish
2027             {
2028 0     0 0   my $to = shift;
2029 0           my $fileconfig = shift;
2030 0           my $stepsvar = shift;
2031 0           my $counterzone = shift;
2032 0           my $counterstep = shift;
2033 0           my $exeonfiles = shift;
2034 0           my $swap = shift;
2035 0           my @applytype = @$swap;
2036              
2037              
2038 0           my $zone_letter = $applytype[$counterzone][3];
2039              
2040 0           my $printthis =
2041             "
2042             ";
2043 0 0         if ($exeonfiles eq "y")
2044             {
2045 0           print `$printthis`;
2046             }
2047              
2048 0           print TOSHELL $printthis;
2049             } #END SUB RECALCULATEISH
2050             ##############################################################################
2051              
2052              
2053              
2054             ##############################################################################
2055             sub daylightcalc # IT WORKS ONLY IF THE RAD DIRECTORY IS EMPTY
2056             {
2057 0     0 0   my $to = shift;
2058 0           my $fileconfig = shift;
2059 0           my $stepsvar = shift;
2060 0           my $counterzone = shift;
2061 0           my $counterstep = shift;
2062 0           my $exeonfiles = shift;
2063 0           my $swap = shift;
2064 0           my @applytype = @$swap;
2065 0           my $zone_letter = $applytype[$counterzone][3];
2066 0           my $filedf = shift;
2067 0           my $swap = shift;
2068 0           my @daylightcalc = @$swap;
2069              
2070              
2071 0           my $yes_or_no_daylightcalc = $daylightcalc[0];
2072 0           my $zone = $daylightcalc[1];
2073 0           my $surface = $daylightcalc[2];
2074 0           my $where = $daylightcalc[3];
2075 0           my $edge = $daylightcalc[4];
2076 0           my $distance = $daylightcalc[5];
2077 0           my $density = $daylightcalc[6];
2078 0           my $accuracy = $daylightcalc[7];
2079 0           my $filedf = $daylightcalc[8];
2080 0           my $pathdf = "$to/rad/$filedf";
2081              
2082 0           my $printthis =
2083             "
2084             cd $to/cfg/
2085             e2r -file $to/cfg/$fileconfig -mode script<
2086              
2087             a
2088              
2089             a
2090             d
2091             $zone
2092             -
2093             $surface
2094             $distance
2095             $where
2096             $edge
2097             -
2098             $density
2099             y
2100             $accuracy
2101             a
2102             -
2103             -
2104             -
2105             -
2106             -
2107             YYY
2108             \n\n
2109             cd $mypath
2110             ";
2111 0 0         if ($exeonfiles eq "y")
2112             {
2113 0           print `$printthis`;
2114             }
2115              
2116 0           print TOSHELL $printthis;
2117              
2118 0 0         open( RADFILE, $pathdf) or die "Can't open $pathdf: $!\n";
2119 0           my @linesrad = ;
2120 0           close RADFILE;
2121 0           my @dfs;
2122             my $dfaverage;
2123 0           my $sum = 0;
2124 0           foreach my $linerad (@linesrad)
2125             {
2126 0           $linerad =~ s/^\s+//;
2127 0           my @rowelements = split(/\s+|,/, $linerad);
2128 0           push (@dfs, $rowelements[-1]);
2129             }
2130 0           foreach my $df (@dfs)
2131             {
2132 0           $sum = ($sum + $df);
2133             }
2134 0           $dfaverage = ( $sum / scalar(@dfs) );
2135              
2136 0 0         open( DFFILE, ">>$dffile" ) or die "Can't open $dffile: $!";
2137 0           print DFFILE "$dfaverage\n";
2138 0           close DFFILE;
2139              
2140             } # END SUB dayligjtcalc
2141             ##############################################################################
2142              
2143              
2144             ##############################################################################
2145             sub daylightcalc_other # NOT USED. THE DIFFERENCE WITH THE ABOVE IS THAT IS WORKS IF THE RAD DIRECTORY IS NOT EMPTY.
2146             {
2147 0     0 0   my $to = shift;
2148 0           my $fileconfig = shift;
2149 0           my $stepsvar = shift;
2150 0           my $counterzone = shift;
2151 0           my $counterstep = shift;
2152 0           my $exeonfiles = shift;
2153 0           my $swap = shift;
2154 0           my @applytype = @$swap;
2155 0           my $zone_letter = $applytype[$counterzone][3];
2156 0           my $filedf = shift;
2157 0           my $swap = shift;
2158 0           my @daylightcalc = @$swap;
2159              
2160              
2161 0           my $yes_or_no_daylightcalc = $daylightcalc[0];
2162 0           my $zone = $daylightcalc[1];
2163 0           my $surface = $daylightcalc[2];
2164 0           my $where = $daylightcalc[3];
2165 0           my $edge = $daylightcalc[4];
2166 0           my $distance = $daylightcalc[5];
2167 0           my $density = $daylightcalc[6];
2168 0           my $accuracy = $daylightcalc[7];
2169 0           my $filedf = $daylightcalc[8];
2170 0           my $pathdf = "$to/rad/$filedf";
2171            
2172 0           my $printthis =
2173             "
2174             cd $to/cfg/
2175             e2r -file $to/cfg/$fileconfig -mode script<
2176             a
2177              
2178             d
2179              
2180             g
2181             -
2182             e
2183             d
2184              
2185              
2186              
2187             y
2188             -
2189             g
2190             y
2191             $zone
2192             -
2193             $surface
2194             $distance
2195             $where
2196             $edge
2197             -
2198             $density
2199              
2200             i
2201             $accuracy
2202             y
2203             a
2204             a
2205             -
2206             -
2207             YYY
2208             \n\n
2209             cd $mypath
2210             ";
2211 0 0         if ($exeonfiles eq "y")
2212             {
2213 0           print `$printthis`;
2214             }
2215              
2216 0           print TOSHELL $printthis;
2217              
2218 0 0         open( RADFILE, $pathdf) or die "Can't open $pathdf: $!\n";
2219 0           my @linesrad = ;
2220 0           close RADFILE;
2221 0           my @dfs;
2222             my $dfaverage;
2223 0           my $sum = 0;
2224 0           foreach my $linerad (@linesrad)
2225             {
2226 0           $linerad =~ s/^\s+//;
2227 0           my @rowelements = split(/\s+|,/, $linerad);
2228 0           push (@dfs, $rowelements[-1]);
2229             }
2230 0           foreach my $df (@dfs)
2231             {
2232 0           $sum = ($sum + $df);
2233             }
2234 0           $dfaverage = ( $sum / scalar(@dfs) );
2235              
2236 0 0         open( DFFILE, ">>$dffile" ) or die "Can't open $dffile: $!";
2237 0           print DFFILE "$dfaverage\n";
2238 0           close DFFILE;
2239              
2240             } # END SUB daylightcalc
2241             ##############################################################################
2242              
2243              
2244             sub change_config
2245             {
2246 0     0 0   my $to = shift;
2247 0           my $fileconfig = shift;
2248 0           my $stepsvar = shift;
2249 0           my $counterzone = shift;
2250 0           my $counterstep = shift;
2251 0           my $exeonfiles = shift;
2252 0           my $swap = shift;
2253 0           my @applytype = @$swap;
2254 0           my $zone_letter = $applytype[$counterzone][3];
2255 0           my $swap2 = shift;
2256 0           my @change_config = @$swap2;
2257              
2258              
2259 0           my @change_conf = @{$change_config[$countezone]};
  0            
2260 0           my @original_configfiles = @{$change_conf[0]};
  0            
2261 0           my @new_configfiles = @{$change_conf[1]};
  0            
2262 0           my $counterconfig = 0;
2263 0           my $original_configfile = $original_configfiles[$counterstep-1];
2264 0           my $new_configfile = $new_configfiles[$counterstep-1];
2265 0 0         if ( $new_configfile ne $original_configfile )
2266             {
2267 0 0         if ($exeonfiles eq "y") { `cp -f $to/$new_configfile $to/$original_configfile\n`; }
  0            
2268 0           print TOSHELL "cp -f $to/$new_configfile $to/$original_configfile\n";
2269             }
2270 0           $counterconfig++;
2271             } # END SUB copy_config
2272              
2273              
2274             sub checkfile # THIS FUNCTION DOES WHAT IS DONE BY THE PREVIOUS ONE, BUT BETTER.
2275             {
2276             # THIS CHECKS IF A SOURCE FILE MUST BE SUBSTITUTED BY ANOTHER ONE BEFORE THE TRANSFORMATIONS BEGIN.
2277             # IT HAS TO BE CALLED WITH: checkfile($sourceaddress, $targetaddress);
2278 0     0 0   my $sourceaddress = shift;
2279 0           my $targetaddress = shift;
2280              
2281              
2282 0 0 0       unless ( ($sourceaddress eq "" ) or ( $targetaddress eq "" ))
2283             {
2284 0           print OUTFILE "TARGETFILE IN FUNCTION: $targetaddress\n";
2285 0 0         if ( $sourceaddress ne $targetaddress )
2286             {
2287 0 0         if ($exeonfiles eq "y")
2288             {
2289 0           print
2290             `cp -f $sourceaddress $targetaddress\n`;
2291             }
2292 0           print TOSHELL
2293             "cp -f $sourceaddress $targetaddress\n\n";
2294             }
2295             }
2296             } # END SUB checkfile
2297              
2298              
2299             sub change_climate ### THIS SIMPLE SCRIPT HAS TO BE DEBUGGED. WHY DOES IT BLOCK ITSELF IF PRINTED TO THE SHELL?
2300             { # THIS FUNCTION CHANGES THE CLIMATE FILES.
2301 0     0 0   my $to = shift;
2302 0           my $fileconfig = shift;
2303 0           my $stepsvar = shift;
2304 0           my $counterzone = shift;
2305 0           my $counterstep = shift;
2306 0           my $exeonfiles = shift;
2307 0           my $swap = shift;
2308 0           my @applytype = @$swap;
2309 0           my $zone_letter = $applytype[$counterzone][3];
2310 0           my $swap = shift;
2311 0           my @change_climate = @$swap;
2312              
2313              
2314 0           my @climates = @{$change_climate[$counterzone]};
  0            
2315 0           my $climate = $climates[$counterstep-1];
2316              
2317 0           my $printthis =
2318             "prj -file $to/cfg/$fileconfig -mode script<
2319              
2320             b
2321             a
2322             b
2323             $climate
2324             a
2325             -
2326             -
2327             y
2328             n
2329             -
2330             -
2331             ZZZ
2332             \n
2333             ";
2334 0 0         if ($exeonfiles eq "y")
2335             {
2336 0           print `$printthis`;
2337             }
2338 0           print TOSHELL $printthis;
2339             }
2340              
2341              
2342             ##############################################################################
2343             # THIS FUNCTION HAS BEEN OUTDATED BY THOSE FOR CONSTRAINING THE NETS, BELOW
2344             sub recalculatenet
2345             {
2346 0     0 0   my $to = shift;
2347 0           my $fileconfig = shift;
2348 0           my $stepsvar = shift;
2349 0           my $counterzone = shift;
2350 0           my $counterstep = shift;
2351 0           my $exeonfiles = shift;
2352 0           my $swap = shift;
2353 0           my @applytype = @$swap;
2354 0           my $zone_letter = $applytype[$counterzone][3];
2355 0           my $swap2 = shift;
2356 0           my @recalculatenet = @$swap2;
2357              
2358              
2359 0           my $filenet = $recalculatenet[1];
2360 0           my $infilenet = "$mypath/$file/nets/$filenet";
2361 0           my @nodezone_data = @{$recalculatenet[2]};
  0            
2362 0           my @nodesdata = @{$recalculatenet[3]};
  0            
2363 0           my $geosourcefile = $recalculatenet[4];
2364 0           my $configfile = $recalculatenet[5];
2365 0           my $y_or_n_reassign_cp = $recalculatenet[6];
2366 0           my $y_or_n_detect_obs = $recalculatenet[7];
2367 0           my @crackwidths = @{$recalculatenet[9]};
  0            
2368              
2369 0           my @obstaclesdata;
2370 0           my $counterlines = 0;
2371 0           my $counternode = 0;
2372 0           my @differences;
2373             my @ratios;
2374 0           my $sourceaddress = "$to$geosourcefile";
2375 0           my $configaddress = "$to/opts/$configfile";
2376 0 0         open( SOURCEFILE, $sourceaddress ) or die "Can't open $geosourcefile 2: $!\n";
2377 0           my @linesgeo = ;
2378 0           close SOURCEFILE;
2379 0           my $countervert = 0;
2380 0           my $counterobs = 0;
2381 0           my $zone;
2382             my @rowelements;
2383 0           my $line;
2384 0           my @node;
2385 0           my @component;
2386 0           my @v;
2387 0           my @obs;
2388 0           my @obspoints;
2389 0           my @obstructionpoint;
2390 0           my $xlenght;
2391 0           my $ylenght;
2392 0           my $truedistance;
2393 0           my $heightdifference;
2394              
2395 0           foreach my $line (@linesgeo)
2396             {
2397 0           $line =~ s/^\s+//;
2398              
2399 0           my @rowelements = split(/\s+|,/, $line);
2400 0 0         if ($rowelements[0] eq "*vertex" )
    0          
2401             {
2402 0 0         if ($countervert == 0)
2403             {
2404 0           push (@v, [ "vertexes of $sourceaddress" ]);
2405 0           push (@v, [ $rowelements[1], $rowelements[2], $rowelements[3] ] );
2406             }
2407              
2408 0 0         if ($countervert > 0)
2409             {
2410 0           push (@v, [ $rowelements[1], $rowelements[2], $rowelements[3] ] );
2411             }
2412 0           $countervert++;
2413             }
2414             elsif ($rowelements[0] eq "*obs" )
2415             {
2416 0           push (@obs, [ $rowelements[1], $rowelements[2], $rowelements[3], $rowelements[4],
2417             $rowelements[5], $rowelements[6], $rowelements[7], $rowelements[8], $rowelements[9], $rowelements[10] ] );
2418 0           $counterobs++;
2419             }
2420 0           $counterlines++;
2421             }
2422              
2423 0 0         if ( $y_or_n_detect_obs eq "y") ### THIS HAS YET TO BE DONE AND WORK.
2424 0           {
2425 0           foreach my $ob (@obs)
2426             {
2427 0           push (@obspoints , [ $$ob[0], $$ob[1],$$ob[5] ] );
2428 0           push (@obspoints , [ ($$ob[0] + ( $$ob[3] / 2) ), ( $$ob[1] + ( $$ob[4] / 2 ) ) , $$ob[5] ] );
2429 0           push (@obspoints , [ ($$ob[0] + $$ob[3]), ( $$ob[1] + $$ob[4] ) , $$ob[5] ] );
2430             }
2431             }
2432              
2433 0           else {@obspoints = @{$recalculatenet[8]};}
2434 0           my @winpoints;
2435             my @windowpoints;
2436 0           my @windimsfront;
2437 0           my @windimseast;
2438 0           my @windimsback;
2439 0           my @windimswest;
2440 0           my $jointfront,
2441             my $jointeast;
2442 0           my $jointback;
2443 0           my $jointwest;
2444 0           my @windsims;
2445 0           my @windareas;
2446 0           my @jointlenghts;
2447 0           my $windimxfront;
2448 0           my $windimyfront;
2449 0           my $windimxback;
2450 0           my $windimyback;
2451 0           my $windimxeast;
2452 0           my $windimyeast;
2453 0           my $windimxwest;
2454 0           my $windimywest;
2455              
2456 0 0         if (-e $constrain) { eval "$constrain"; } # HERE THE INSTRUCTION WRITTEN IN THE OPTS CONFIGURATION FILE CAN BE SPEFICIED
  0            
2457             # FOR PROPAGATION OF CONSTRAINTS
2458              
2459 0 0         if ($y_or_n_reassign_cp == "y")
2460             {
2461 0           eval `cat $configaddress`; # HERE AN EXTERNAL FILE FOR PROPAGATION OF CONSTRAINTS
2462             # IS EVALUATED, AND HERE BELOW CONSTRAINTS ARE PROPAGATED.
2463             }
2464              
2465              
2466              
2467 0 0         open( INFILENET, $infilenet ) or die "Can't open $infilenet 2: $!\n";
2468 0           my @linesnet = ;
2469 0           close INFILENET;
2470              
2471 0           my @letters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
2472             "t", "u", "v", "w", "x", "y", "z");
2473 0           my $counternode = 0;
2474 0           my $interfaceletter;
2475             my $calcpressurecoefficient;
2476 0           my $nodetype;
2477 0           my $nodeletter;
2478 0           my $mode;
2479 0           my $counterlines = 0;
2480 0           my $counteropening = 0;
2481 0           my $countercrack = 0;
2482 0           my $counterthing = 0;
2483 0           my $counterjoint = 0;
2484 0           foreach my $line (@linesnet)
2485             {
2486 0           $line =~ s/^\s+//;
2487 0           @rowelements = split(/\s+/, $line);
2488              
2489 0 0         if ($rowelements[0] eq "Node") { $mode = "nodemode"; }
  0            
2490 0 0         if ($rowelements[0] eq "Component") { $mode = "componentmode"; }
  0            
2491 0 0 0       if ( ( $mode eq "nodemode" ) and ($counterlines > 1) and ($counterlines < (2 + scalar(@nodesdata) ) ) )
      0        
2492             {
2493 0           $counternode = ($counterlines - 2);
2494 0           $zone = $nodesdata[$counternode][0];
2495 0           $interfaceletter = $nodesdata[$counternode][1];
2496 0           $calcpressurecoefficient = $nodesdata[$counternode][2];
2497 0           $nodetype = $rowelements[2];
2498 0           $nodeletter = $letters[$counternode];
2499              
2500 0 0         if ( $nodetype eq "0")
    0          
2501             {
2502 0           my $printthis =
2503             "prj -file $to/cfg/$fileconfig -mode script<
2504              
2505              
2506             m
2507             e
2508             c
2509              
2510             n
2511             c
2512             $nodeletter
2513              
2514             a
2515             a
2516             y
2517             $zone
2518              
2519              
2520             a
2521              
2522             -
2523             -
2524             y
2525              
2526             y
2527             -
2528             -
2529             -
2530             -
2531             -
2532             -
2533             -
2534             -
2535             YYY
2536             ";
2537 0 0         if ($exeonfiles eq "y")
2538             {
2539 0           print `$printthis`;
2540             }
2541              
2542 0           print TOSHELL $printthis;
2543 0           $counternode++;
2544             }
2545             elsif ( $nodetype eq "3")
2546             {
2547 0 0         if ($y_or_n_reassign_cp == "y")
2548             {
2549 0           my $printthis =
2550             "prj -file $to/cfg/$fileconfig -mode script<
2551              
2552              
2553             m
2554             e
2555             c
2556              
2557             n
2558             c
2559             $nodeletter
2560              
2561             a
2562             e
2563             $zone
2564             $interfaceletter
2565             $calcpressurecoefficient
2566             y
2567              
2568              
2569             -
2570             -
2571             y
2572              
2573             y
2574             -
2575             -
2576             -
2577             -
2578             -
2579             -
2580             -
2581             -
2582             YYY
2583             ";
2584 0 0         if ($exeonfiles eq "y")
2585             {
2586 0           print `printthis`;
2587             }
2588              
2589 0           print TOSHELL $printthis;
2590 0           $counternode++;
2591             }
2592             }
2593             }
2594              
2595 0           my @node_letters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p",
2596             "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
2597 0 0 0       if ( ($mode eq "componentmode") and ( $line =~ "opening"))
    0 0        
2598             {
2599 0           my $printthis =
2600             "prj -file $to/cfg/$fileconfig -mode script<
2601              
2602              
2603             m
2604             e
2605             c
2606              
2607             n
2608             d
2609             $node_letters[$counterthing]
2610              
2611             k
2612             -
2613             $windareas[$counteropening]
2614             -
2615             -
2616             y
2617              
2618             y
2619             -
2620             -
2621             -
2622             -
2623             -
2624             -
2625             -
2626             YYY
2627             ";
2628 0 0         if ($exeonfiles eq "y")
2629             {
2630 0           print `$printthis`;
2631             }
2632              
2633 0           print TOSHELL $printthis;
2634              
2635 0           $counteropening++;
2636 0           $counterthing++;
2637             }
2638             elsif ( ($mode eq "componentmode") and ( $line =~ "crack "))
2639             {
2640 0           MY $printthis =
2641             "prj -file $to/cfg/$fileconfig -mode script<
2642              
2643              
2644             m
2645             e
2646             c
2647              
2648             n
2649             d
2650             $node_letters[$counterthing]
2651              
2652             l
2653             -
2654             $crackwidths[$counterjoint] $jointlenghts[$counterjoint]
2655             -
2656             -
2657             y
2658              
2659             y
2660             -
2661             -
2662             -
2663             -
2664             -
2665             -
2666             -
2667             YYY
2668             ";
2669 0 0         if ($exeonfiles eq "y")
2670             {
2671 0           print `$printthis`;
2672             }
2673              
2674 0           print TOSHELL $printthis;
2675              
2676 0           $countercrack++;
2677 0           $counterthing++;
2678 0           $counterjoint++;
2679             }
2680 0           $counterlines++;
2681             }
2682             } # END SUB recalculatenet
2683             ##############################################################################
2684              
2685              
2686             ##############################################################################
2687             sub apply_constraints
2688             {
2689 0     0 0   my $to = shift;
2690 0           my $fileconfig = shift;
2691 0           my $stepsvar = shift;
2692 0           my $counterzone = shift;
2693 0           my $counterstep = shift;
2694 0           my $exeonfiles = shift;
2695 0           my $swap = shift;
2696 0           my @applytype = @$swap;
2697 0           my $zone_letter = $applytype[$counterzone][3];
2698 0           my $swap2 = shift;
2699 0           my @apply_constraints = @$swap2;
2700              
2701              
2702 0           my $value_reshape;
2703             my $ybasewall;
2704 0           my $ybasewindow;
2705 0           my @v;
2706              
2707 0           foreach my $group_operations ( @apply_constraints )
2708             {
2709 0           my @group = @{$group_operations};
  0            
2710 0           my $yes_or_no_apply_constraints = $group[0];
2711              
2712 0           my @sourcefiles = @{$group[1]};
  0            
2713 0           my @targetfiles = @{$group[2]};
  0            
2714 0           my @configfiles = @{$group[3]};
  0            
2715 0           my @basevalues = @{$group[4]};
  0            
2716 0           my @swingvalues = @{$group[5]};
  0            
2717 0           my @work_values = @{$group[6]};
  0            
2718 0           my $longmenu = $group[7];
2719 0           my $basevalue;
2720             my $targetfile;
2721 0           my $configfile;
2722 0           my $swingvalue;
2723 0           my $sourceaddress;
2724 0           my $targetaddress;
2725 0           my $configaddress;
2726 0           my $countoperations = 0;
2727              
2728 0           foreach $sourcefile ( @sourcefiles )
2729             {
2730 0           $basevalue = $basevalues[$countoperations];
2731 0           $sourcefile = $sourcefiles[$countoperations];
2732 0           $targetfile = $targetfiles[$countoperations];
2733 0           $configfile = $configfiles[$countoperations];
2734 0           $swingvalue = $swingvalues[$countoperations];
2735 0           $sourceaddress = "$to$sourcefile";
2736 0           $targetaddress = "$to$targetfile";
2737 0           $configaddress = "$to/opts/$configfile";
2738 0           $longmenu = $longmenus[$countoperations];
2739 0           checkfile($sourceaddress, $targetaddress);
2740              
2741 0 0         open( SOURCEFILE, $sourceaddress ) or die "Can't open $sourcefile 2: $!\n";
2742 0           my @lines = ;
2743 0           close SOURCEFILE;
2744 0           my $counterlines = 0;
2745 0           my $countervert = 0;
2746 0           foreach my $line (@lines)
2747             {
2748 0           $line =~ s/^\s+//;
2749 0           my @rowelements = split(/\s+|,/, $line);
2750 0 0         if ($rowelements[0] eq "*vertex" )
2751             {
2752 0 0         if ($countervert == 0)
2753             {
2754 0           push (@v, [ "vertexes of $sourceaddress" ]);
2755 0           push (@v, [ $rowelements[1], $rowelements[2], $rowelements[3] ] );
2756             }
2757              
2758 0 0         if ($countervert > 0)
2759             {
2760 0           push (@v, [ $rowelements[1], $rowelements[2], $rowelements[3] ] );
2761             }
2762 0           $countervert++;
2763             }
2764 0           $counterlines++;
2765             }
2766              
2767 0           my @vertexletters;
2768 0 0         if ($longmenu eq "y")
2769             {
2770 0           @vertexletters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
2771             "o", "p", "0\nb\nq", "0\nb\nr", "0\nb\ns", "0\nb\nt", "0\nb\nu", "0\nb\nv", "0\nb\nw",
2772             "0\nb\nx", "0\nb\ny", "0\nb\nz", "0\nb\na", "0\nb\nb","0\nb\nc","0\nb\nd","0\nb\ne",
2773             "0\nb\n0\nb\nf","0\nb\n0\nb\ng","0\nb\n0\nb\nh","0\nb\n0\nb\ni","0\nb\n0\nb\nj",
2774             "0\nb\n0\nb\nk","0\nb\n0\nb\nl","0\nb\n0\nb\nm","0\nb\n0\nb\nn","0\nb\n0\nb\no",
2775             "0\nb\n0\nb\np","0\nb\n0\nb\nq","0\nb\n0\nb\nr","0\nb\n0\nb\ns","0\nb\n0\nb\nt");
2776             }
2777             else
2778             {
2779 0           @vertexletters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
2780             "n", "o", "p", "0\nq", "0\nr", "0\ns", "0\nt", "0\nu", "0\nv", "0\nw", "0\nx",
2781             "0\ny", "0\nz", "0\na", "0\nb","0\n0\nc","0\n0\nd","0\n0\ne","0\n0\nf","0\n0\ng",
2782             "0\n0\nh","0\n0\ni","0\n0\nj","0\n0\nk","0\n0\nl","0\n0\nm","0\n0\nn","0\n0\no",
2783             "0\n0\np","0\n0\nq","0\n0\nr","0\n0\ns","0\n0\nt");
2784             }
2785              
2786 0 0         if (-e $constrain) { eval "$constrain"; } # HERE THE INSTRUCTION WRITTEN IN THE OPTS CONFIGURATION FILE CAN BE SPEFICIED
  0            
2787             # FOR PROPAGATION OF CONSTRAINTS
2788              
2789 0 0         if (-e $configaddress)
2790             {
2791 0           eval `cat $configaddress`; # HERE AN EXTERNAL FILE FOR PROPAGATION OF CONSTRAINTS
2792             # IS EVALUATED, AND HERE BELOW CONSTRAINTS ARE PROPAGATED.
2793              
2794 0 0         if (-e $constrain) { eval "$constrain"; } # HERE THE INSTRUCTION WRITTEN IN THE OPTS CONFIGURATION FILE CAN BE SPEFICIED
  0            
2795             # FOR PROPAGATION OF CONSTRAINTS
2796              
2797              
2798 0           my $countervertex = 0;
2799 0           foreach (@v)
2800             {
2801 0 0         if ($countervertex > 0)
2802             {
2803 0           my $vertexletter = $vertexletters[$countervertex-1];
2804 0 0         if ($vertexletter ~~ @work_values)
2805             {
2806 0           my $printthis =
2807             "prj -file $to/cfg/$fileconfig -mode script<
2808              
2809             m
2810             c
2811             a
2812             $zone_letter
2813             d
2814             $vertexletter
2815             $v[$countervertex][0] $v[$countervertex][1] $v[$countervertex][2]
2816             -
2817             y
2818             -
2819             y
2820             c
2821             -
2822             -
2823             -
2824             -
2825             -
2826             -
2827             -
2828             -
2829             -
2830             YYY
2831             ";
2832 0 0         if ($exeonfiles eq "y")
2833             {
2834 0           print `$printthis`;
2835             }
2836              
2837 0           print TOSHELL $printthis;
2838             }
2839             }
2840 0           $countervertex++;
2841             }
2842             }
2843 0           $countoperations++;
2844             }
2845             }
2846             } # END SUB apply_constraints
2847             ##############################################################################
2848              
2849              
2850             ##############################################################################
2851             sub reshape_windows # IT APPLIES CONSTRAINTS
2852             {
2853 0     0 0   my $to = shift;
2854 0           my $fileconfig = shift;
2855 0           my $stepsvar = shift;
2856 0           my $counterzone = shift;
2857 0           my $counterstep = shift;
2858 0           my $exeonfiles = shift;
2859 0           my $swap = shift;
2860 0           my @applytype = @$swap;
2861 0           my $zone_letter = $applytype[$counterzone][3];
2862 0           my $swap2 = shift;
2863 0           my @reshape_windows = @$swap2;
2864              
2865              
2866 0           my @work_letters ;
2867             my @v;
2868              
2869 0           foreach my $group_operations ( @{$reshape_windows[$counterzone]} )
  0            
2870             {
2871 0           my @group = @{$group_operations};
  0            
2872 0           my @sourcefiles = @{$group[0]};
  0            
2873 0           my @targetfiles = @{$group[1]};
  0            
2874 0           my @configfiles = @{$group[2]};
  0            
2875 0           my @basevalues = @{$group[3]};
  0            
2876 0           my @swingvalues = @{$group[4]};
  0            
2877 0           my @work_letters = @{$group[5]};
  0            
2878 0           my @longmenus = @{$group[6]};
  0            
2879              
2880 0           my $countoperations = 0;
2881 0           foreach $sourcefile ( @sourcefiles )
2882             {
2883 0           my $basevalue = $basevalues[$countoperations];
2884 0           my $sourcefile = $sourcefiles[$countoperations];
2885 0           my $targetfile = $targetfiles[$countoperations];
2886 0           my $configfile = $configfiles[$countoperations];
2887 0           my $swingvalue = $swingvalues[$countoperations];
2888 0           my $longmenu = $longmenus[$countoperations];
2889 0           my $sourceaddress = "$to$sourcefile";
2890 0           my $targetaddress = "$to$targetfile";
2891 0           my $configaddress = "$to/opts/$configfile";
2892 0           my $totalswing = ( 2 * $swingvalue );
2893 0           my $pace = ( $totalswing / ( $stepsvar - 1 ) );
2894 0           checkfile($sourceaddress, $targetaddress);
2895            
2896 0 0         open( SOURCEFILE, $sourceaddress ) or die "Can't open $sourcefile 2: $!\n";
2897 0           my @lines = ;
2898 0           close SOURCEFILE;
2899              
2900 0           my $counterlines = 0;
2901 0           my $countervert = 0;
2902 0           foreach my $line (@lines)
2903             {
2904 0           $line =~ s/^\s+//;
2905              
2906 0           my @rowelements = split(/\s+|,/, $line);
2907 0 0         if ($rowelements[0] eq "*vertex" )
2908             {
2909 0 0         if ($countervert == 0)
2910             {
2911 0           push (@v, [ "vertexes of $sourceaddress", [], [] ]);
2912 0           push (@v, [ $rowelements[1], $rowelements[2], $rowelements[3] ] );
2913             }
2914              
2915 0 0         if ($countervert > 0)
2916             {
2917 0           push (@v, [ $rowelements[1], $rowelements[2], $rowelements[3] ] );
2918             }
2919              
2920 0           $countervert++;
2921             }
2922 0           $counterlines++;
2923             }
2924              
2925 0           my @vertexletters;
2926 0 0         if ($longmenu eq "y")
2927             {
2928 0           @vertexletters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
2929             "n", "o", "p", "0\nb\nq", "0\nb\nr", "0\nb\ns", "0\nb\nt", "0\nb\nu", "0\nb\nv",
2930             "0\nb\nw", "0\nb\nx", "0\nb\ny", "0\nb\nz", "0\nb\na", "0\nb\nb","0\nb\nc","0\nb\nd",
2931             "0\nb\ne","0\nb\n0\nb\nf","0\nb\n0\nb\ng","0\nb\n0\nb\nh","0\nb\n0\nb\ni",
2932             "0\nb\n0\nb\nj","0\nb\n0\nb\nk","0\nb\n0\nb\nl","0\nb\n0\nb\nm","0\nb\n0\nb\nn",
2933             "0\nb\n0\nb\no","0\nb\n0\nb\np","0\nb\n0\nb\nq","0\nb\n0\nb\nr","0\nb\n0\nb\ns",
2934             "0\nb\n0\nb\nt");
2935             }
2936             else
2937             {
2938 0           @vertexletters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
2939             "n", "o", "p", "0\nq", "0\nr", "0\ns", "0\nt", "0\nu", "0\nv", "0\nw", "0\nx",
2940             "0\ny", "0\nz", "0\na", "0\nb","0\n0\nc","0\n0\nd","0\n0\ne","0\n0\nf","0\n0\ng",
2941             "0\n0\nh","0\n0\ni","0\n0\nj","0\n0\nk","0\n0\nl","0\n0\nm","0\n0\nn","0\n0\no",
2942             "0\n0\np","0\n0\nq","0\n0\nr","0\n0\ns","0\n0\nt");
2943             }
2944              
2945 0           $value_reshape_window = ( ( $basevalue - $swingvalue) + ( $pace * ( $counterstep - 1 )) );
2946              
2947 0 0         if (-e $configaddress)
2948             {
2949              
2950 0           eval `cat $configaddress`; # HERE AN EXTERNAL FILE FOR PROPAGATION OF CONSTRAINTS
2951             # IS EVALUATED, AND HERE BELOW CONSTRAINTS ARE PROPAGATED.
2952              
2953 0 0         if (-e $constrain) { eval "$constrain"; } # HERE THE INSTRUCTION WRITTEN IN THE OPTS CONFIGURATION FILE CAN BE SPEFICIED
  0            
2954             # FOR PROPAGATION OF CONSTRAINTS
2955              
2956 0           my $countervertex = 0;
2957              
2958 0           foreach (@v)
2959             {
2960 0 0         if ($countervertex > 0)
2961             {
2962 0           my $vertexletter = $vertexletters[$countervertex];
2963 0 0         if ($vertexletter ~~ @work_letters)
2964             {
2965 0           my $printthis =
2966             "prj -file $to/cfg/$fileconfig -mode script<
2967              
2968             m
2969             c
2970             a
2971             $zone_letter
2972             d
2973             $vertexletter
2974             $v[$countervertex+1][0] $v[$countervertex+1][1] $v[$countervertex+1][2]
2975             -
2976             y
2977             -
2978             y
2979             c
2980             -
2981             -
2982             -
2983             -
2984             -
2985             -
2986             -
2987             -
2988             -
2989             YYY
2990             ";
2991 0 0         if ($exeonfiles eq "y")
2992             {
2993 0           print `$printthis`;
2994             }
2995              
2996 0           print TOSHELL $printthis;
2997             }
2998             }
2999 0           $countervertex++;
3000             }
3001             }
3002 0           $countoperations++;
3003             }
3004              
3005             }
3006             } # END SUB reshape_windows
3007             ##############################################################################
3008              
3009              
3010             sub warp #
3011             {
3012 0     0 0   my $to = shift;
3013 0           my $fileconfig = shift;
3014 0           my $stepsvar = shift;
3015 0           my $counterzone = shift;
3016 0           my $counterstep = shift;
3017 0           my $exeonfiles = shift;
3018 0           my $swap = shift;
3019 0           my @applytype = @$swap;
3020 0           my $zone_letter = $applytype[$counterzone][3];
3021 0           my $warp = shift;
3022              
3023              
3024 0           my $yes_or_no_warp = $$warp[$counterzone][0];
3025 0           my @surfs_to_warp = @{ $warp->[$counterzone][1] };
  0            
3026 0           my @vertexes_numbers = @{ $warp->[$counterzone][2] };
  0            
3027 0           my @swingrotations = @{ $warp->[$counterzone][3] };
  0            
3028 0           my @yes_or_no_apply_to_others = @{ $warp->[$counterzone][4] };
  0            
3029 0           my $configfilename = $$warp[$counterzone][5];
3030 0           my $configfile = $to."/opts/".$configfilename;
3031 0           my @pairs_of_vertexes = @{ $warp->[$counterzone][6] }; # @pairs_of_vertexes defining axes
  0            
3032 0           my @windows_to_reallign = @{ $warp->[$counterzone][7] };
  0            
3033 0           my $sourcefilename = $$warp[$counterzone][8];
3034 0           my $sourcefile = $to.$sourcefilename;
3035 0           my $longmenu = $$warp[$counterzone][9];
3036 0 0         if ( $yes_or_no_warp eq "y" )
3037             {
3038 0           my $counterrotate = 0;
3039 0           foreach my $surface_letter (@surfs_to_warp)
3040             {
3041 0           $swingrotate = $swingrotations[$counterrotate];
3042 0           $pacerotate = ( $swingrotate / ( $stepsvar - 1 ) );
3043 0           $rotation_degrees = ( ( $swingrotate / 2 ) - ( $pacerotate * ( $counterstep - 1 ) )) ;
3044 0           $vertex_number = $vertexes_numbers[$counterrotate];
3045 0           $yes_or_no_apply = $yes_or_no_apply_to_others[$counterrotate];
3046 0 0 0       if ( ( $swingrotate != 0 ) and ( $stepsvar > 1 ) and ( $yes_or_no_warp eq "y" ) )
      0        
3047             {
3048 0           my $printthis =
3049             "prj -file $to/cfg/$fileconfig -mode script<
3050              
3051             m
3052             c
3053             a
3054             $zone_letter
3055             e
3056             >
3057             $surface_letter
3058             c
3059             $vertex_number
3060             $rotation_degrees
3061             $yes_or_no_apply
3062             -
3063             -
3064             y
3065             c
3066             -
3067             -
3068             -
3069             -
3070             -
3071             -
3072             -
3073             -
3074             YYY
3075             ";
3076 0 0         if ($exeonfiles eq "y")
3077             {
3078 0           print `$printthis`;
3079             }
3080 0           print TOSHELL $printthis;
3081             }
3082 0           $counterrotate++;
3083             }
3084              
3085             # THIS SECTION READS THE CONFIG FILE FOR DIMENSIONS
3086 0 0         open( SOURCEFILE, $sourcefile ) or die "Can't open $sourcefile: $!\n";
3087 0           my @lines = ;
3088 0           close SOURCEFILE;
3089 0           my $counterlines = 0;
3090 0           my $countervert = 0;
3091 0           foreach my $line (@lines)
3092             {
3093 0           $line =~ s/^\s+//;
3094            
3095 0           my @rowelements = split(/\s+|,/, $line);
3096 0 0         if ($rowelements[0] eq "*vertex" )
3097             {
3098 0 0         if ($countervert == 0)
3099             {
3100 0           push (@v, [ "vertexes of $sourceaddress" ]);
3101 0           push (@v, [ $rowelements[1], $rowelements[2], $rowelements[3] ] );
3102             }
3103              
3104 0 0         if ($countervert > 0)
3105             {
3106 0           push (@v, [ $rowelements[1], $rowelements[2], $rowelements[3] ] );
3107             }
3108 0           $countervert++;
3109             }
3110 0           $counterlines++;
3111             }
3112              
3113              
3114 0           my @vertexletters;
3115 0 0         if ($longmenu eq "y")
3116             {
3117 0           @vertexletters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
3118             "o", "p", "0\nb\nq", "0\nb\nr", "0\nb\ns", "0\nb\nt", "0\nb\nu", "0\nb\nv", "0\nb\nw",
3119             "0\nb\nx", "0\nb\ny", "0\nb\nz", "0\nb\na", "0\nb\nb","0\nb\nc","0\nb\nd","0\nb\ne",
3120             "0\nb\n0\nb\nf","0\nb\n0\nb\ng","0\nb\n0\nb\nh","0\nb\n0\nb\ni","0\nb\n0\nb\nj",
3121             "0\nb\n0\nb\nk","0\nb\n0\nb\nl","0\nb\n0\nb\nm","0\nb\n0\nb\nn","0\nb\n0\nb\no",
3122             "0\nb\n0\nb\np","0\nb\n0\nb\nq","0\nb\n0\nb\nr","0\nb\n0\nb\ns","0\nb\n0\nb\nt");
3123             }
3124             else
3125             {
3126 0           @vertexletters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
3127             "o", "p", "0\nq", "0\nr", "0\ns", "0\nt", "0\nu", "0\nv", "0\nw", "0\nx", "0\ny",
3128             "0\nz", "0\na", "0\nb","0\n0\nc","0\n0\nd","0\n0\ne","0\n0\nf","0\n0\ng","0\n0\nh",
3129             "0\n0\ni","0\n0\nj","0\n0\nk","0\n0\nl","0\n0\nm","0\n0\nn","0\n0\no","0\n0\np",
3130             "0\n0\nq","0\n0\nr","0\n0\ns","0\n0\nt");
3131             }
3132              
3133              
3134 0 0         if (-e $configfile)
3135             {
3136 0           eval `cat $configfile`; # HERE AN EXTERNAL FILE FOR PROPAGATION OF CONSTRAINTS IS EVALUATED
3137             # AND PROPAGATED.
3138              
3139 0 0         if (-e $constrain) { eval "$constrain"; } # HERE THE INSTRUCTION WRITTEN IN THE OPTS CONFIGURATION FILE CAN BE SPEFICIED
  0            
3140             # FOR PROPAGATION OF CONSTRAINTS
3141              
3142             }
3143             # THIS SECTION SHIFTS THE VERTEX TO LET THE BASE SURFACE AREA UNCHANGED AFTER THE WARPING.
3144              
3145 0           my $counterthis = 0;
3146 0           $number_of_moves = ( (scalar(@pairs_of_vertexes)) /2 ) ;
3147 0           foreach my $pair_of_vertexes (@pairs_of_vertexes)
3148             {
3149 0 0         if ($counterthis < $number_of_moves)
3150             {
3151 0           $vertex1 = $pairs_of_vertexes[ 0 + ( 2 * $counterthis ) ];
3152 0           $vertex2 = $pairs_of_vertexes[ 1 + ( 2 * $counterthis ) ];
3153              
3154 0           my $printthis =
3155             "prj -file $to/cfg/$fileconfig -mode script<
3156              
3157             m
3158             c
3159             a
3160             $zone_letter
3161             d
3162             ^
3163             j
3164             $vertex1
3165             $vertex2
3166             -
3167             $addedlength
3168             y
3169             -
3170             y
3171             -
3172             y
3173             -
3174             -
3175             -
3176             -
3177             -
3178             -
3179             -
3180             -
3181             YYY
3182             ";
3183 0 0         if ($exeonfiles eq "y")
3184             {
3185 0           print `$printthis`;
3186             }
3187 0           print TOSHELL $printthis;
3188             }
3189 0           $counterthis++;
3190             }
3191             }
3192             } # END SUB warp
3193             ##############################################################################
3194              
3195              
3196             ##############################################################################
3197             ##############################################################################
3198             # BEGINNING OF SECTION DEDICATED TO FUNCTIONS FOR CONSTRAINING GEOMETRY
3199              
3200             sub constrain_geometry # IT APPLIES CONSTRAINTS TO ZONE GEOMETRY
3201             {
3202             # IT CONSTRAIN GEOMETRY FILES. IT HAS TO BE CALLED FROM THE MAIN FILE WITH:
3203             # constrain_geometry($to, $fileconfig, $stepsvar, $counterzone, $counterstep, $exeonfiles, \@applytype, \@constrain_geometry);
3204             # constrain_geometry($to, $fileconfig, $stepsvar, $counterzone,
3205             # $counterstep, $exeonfiles, \@applytype, \@constrain_geometry, $to_do);
3206 0     0 0   my $to = shift;
3207 0           my $fileconfig = shift;
3208 0           my $stepsvar = shift;
3209 0           my $counterzone = shift;
3210 0           my $counterstep = shift;
3211 0           my $exeonfiles = shift;
3212 0           my $swap = shift;
3213 0           my @applytype = @$swap;
3214 0           my $zone_letter = $applytype[$counterzone][3];
3215 0           my $swap = shift;
3216 0           my @constrain_geometry = @$swap;
3217 0           my $to_do = shift;
3218              
3219              
3220             # print OUTFILE "YOUCALLED!\n\n";
3221             # print OUTFILE "HERE: \@constrain_geometry:" . Dumper(@constrain_geometry) . "\n\n";
3222 0 0         if ($longmenu eq "y")
3223             {
3224 0           @vertexletters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
3225             "o", "p", "0\nb\nq", "0\nb\nr", "0\nb\ns", "0\nb\nt", "0\nb\nu", "0\nb\nv", "0\nb\nw",
3226             "0\nb\nx", "0\nb\ny", "0\nb\nz", "0\nb\na", "0\nb\nb","0\nb\nc","0\nb\nd","0\nb\ne",
3227             "0\nb\n0\nb\nf","0\nb\n0\nb\ng","0\nb\n0\nb\nh","0\nb\n0\nb\ni","0\nb\n0\nb\nj",
3228             "0\nb\n0\nb\nk","0\nb\n0\nb\nl","0\nb\n0\nb\nm","0\nb\n0\nb\nn","0\nb\n0\nb\no",
3229             "0\nb\n0\nb\np","0\nb\n0\nb\nq","0\nb\n0\nb\nr","0\nb\n0\nb\ns","0\nb\n0\nb\nt");
3230             }
3231             else
3232             {
3233 0           @vertexletters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
3234             "n", "o", "p", "0\nq", "0\nr", "0\ns", "0\nt", "0\nu", "0\nv", "0\nw", "0\nx",
3235             "0\ny", "0\nz", "0\na", "0\nb","0\n0\nc","0\n0\nd","0\n0\ne","0\n0\nf","0\n0\ng",
3236             "0\n0\nh","0\n0\ni","0\n0\nj","0\n0\nk","0\n0\nl","0\n0\nm","0\n0\nn","0\n0\no",
3237             "0\n0\np","0\n0\nq","0\n0\nr","0\n0\ns","0\n0\nt");
3238             }
3239              
3240 0           foreach my $elm (@constrain_geometry)
3241             {
3242 0           my @group = @{$elm};
  0            
3243             # print OUTFILE "INSIDE: \@constrain_geometry:" . Dumper(@constrain_geometry) . "\n\n";
3244             # print OUTFILE "INSIDE: \@group:" . Dumper(@group) . "\n\n";
3245 0           my $zone_letter = $group[1];
3246 0           my $sourcefile = $group[2];
3247 0           my $targetfile = $group[3];
3248 0           my $configfile = $group[4];
3249 0           my $sourceaddress = "$to$sourcefile";
3250 0           my $targetaddress = "$to$targetfile";
3251 0           my @work_letters = @{$group[5]};
  0            
3252 0           my $longmenus = $group[6];
3253              
3254             # print OUTFILE "VARIABLES: \$to:$to, \$fileconfig:$fileconfig, \$stepsvar:$stepsvar, \$counterzone:$counterzone, \$counterstep:$counterstep, \$exeonfiles:$exeonfiles,
3255             # \$zone_letter:$zone_letter, \$sourceaddress:$sourceaddress, \$targetaddress:$targetaddress, \$longmenus:$longmenus, \@work_letters, " . Dumper(@work_letters) . "\n\n";
3256              
3257 0 0         unless ($to_do eq "justwrite")
3258             {
3259 0           checkfile($sourceaddress, $targetaddress);
3260 0           read_geometry($to, $sourcefile, $targetfile, $configfile, \@work_letters, $longmenus);
3261 0           read_geo_constraints($to, $fileconfig, $stepsvar, $counterzone, $counterstep, $configaddress, \@v, \@tempv);
3262             }
3263              
3264 0 0         unless ($to_do eq "justread")
3265             {
3266 0           apply_geo_constraints(\@dov, \@vertexletters, \@work_letters, $exeonfiles, $zone_letter, $toshell, $outfile, $configfile, \@tempv);
3267             }
3268             # print OUTFILE "\@v: " . Dumper(@v) . "\n\n";
3269             }
3270             } # END SUB constrain_geometry
3271              
3272              
3273             sub read_geometry
3274             {
3275             # THIS READS GEOMETRY FILES. # IT HAS TO BE CALLED WITH:
3276             # read_geometry($to, $sourcefile, $targetfile, $configfiles, \@work_letters, $longmenus);
3277 0     0 0   my $to = shift;
3278 0           my $sourcefile = shift;
3279 0           my $targetfile = shift;
3280 0           my $configfile = shift;
3281 0           my $swap = shift;
3282 0           my @work_letters = @$swap;
3283 0           my $longmenus = shift;
3284 0           my $sourceaddress = "$to$sourcefile";
3285 0           my $targetaddress = "$to$targetfile";
3286 0           my $configaddress = "$to$configfile";
3287            
3288 0 0         open( SOURCEFILE, $sourceaddress ) or die "Can't open $sourcefile 2: $!\n";
3289 0           my @lines = ;
3290 0           close SOURCEFILE;
3291              
3292 0           my $counterlines = 0;
3293 0           my $countervert = 0;
3294 0           foreach my $line (@lines)
3295             {
3296 0           $line =~ s/^\s+//;
3297              
3298 0           my @rowelements = split(/\s+|,/, $line);
3299 0 0         if ($rowelements[0] eq "*vertex" )
3300             {
3301 0           push (@v, [ $rowelements[1], $rowelements[2], $rowelements[3] ] );
3302 0           $countervert++;
3303             }
3304 0           $counterlines++;
3305             }
3306 0           @dov = @v;
3307             } # END SUB read_geometry
3308              
3309              
3310             sub read_geo_constraints
3311             {
3312             # THIS FILE IS FOR OPTS TO READ GEOMETRY USER-IMPOSED CONSTRAINTS.
3313             # IT IS CALLED WITH: read_geo_constraints($configaddress);
3314             # THIS MAKES AVAILABLE THE VERTEXES IN THE GEOMETRY FILES TO THE USER FOR MANIPULATION, IN THE FOLLOWING FORM:
3315             # $v[$counterzone][$number][$x], $v[$counterzone][$number][$y], $v[$counterzone][$number][$z]. EXAMPLE: $v[0][4][$x] = 1.
3316             # OR: @v[0][4][$x] = @v[0][4][$y]. OR EVEN: @v[1][4][$x] = @v[0][3][$z].
3317             # The $counterzone that is actuated is always the last, the one which is active.
3318             # It would have therefore no sense writing $v[0][4][$x] = $v[1][2][$y].
3319             # Differentent $counterzones can be referred to the same zone. Different $counterzones just number mutations in series.
3320             # ALSO, IT MAKES AVAILABLE TO THE USER INFORMATIONS ABOUT THE MORPHING STEP OF THE MODELS
3321             # AND THE STEPS THE MODEL HAVE TO FOLLOW.
3322             # THIS ALLOWS TO IMPOSE EQUALITY CONSTRAINTS TO THESE VARIABLES,
3323             # WHICH COULD ALSO BE COMBINED WITH THE FOLLOWING ONES:
3324             # $stepsvar, WHICH TELLS THE PROGRAM HOW MANY ITERATION STEPS IT HAS TO DO IN THE CURRENT MORPHING PHASE.
3325             # $counterzone, WHICH TELLS THE PROGRAM WHAT OPERATION IS BEING EXECUTED IN THE CHAIN OF OPERATIONS
3326             # THAT MAY BE EXECUTES AT EACH MORPHING PHASE. EACH $counterzone WILL CONTAIN ONE OR MORE ITERATION STEPS.
3327             # TYPICALLY, IT WILL BE USED FOR A ZONE, BUT NOTHING PREVENTS THAT SEVERAL OF THEM CHAINED ONE AFTER
3328             # THE OTHER ARE APPLIED TO THE SAME ZONE.
3329             # $counterstep, WHICH TELLS THE PROGRAM WHAT THE CURRENT ITERATION STEP IS.
3330 0     0 0   my $to = shift;
3331 0           my $fileconfig = shift;
3332 0           my $stepsvar = shift;
3333 0           my $counterzone = shift;
3334 0           my $counterstep = shift;
3335 0           my $configaddress = shift;
3336 0           my $swap = shift;
3337 0           my @myv = @$swap;
3338 0           @tempv = @myv;
3339              
3340 0           my $x = 0;
3341 0           my $y = 1;
3342 0           my $z = 2;
3343 0           unshift (@myv, [ "vertexes of $sourceaddress. \$counterzone: $counterzone ", [], [] ]);
3344              
3345 0 0         if (-e $configaddress)
3346             {
3347 0           push (@v, [@myv]); #
3348 0           eval `cat $configaddress`; # HERE AN EXTERNAL FILE FOR PROPAGATION OF CONSTRAINTS IS EVALUATED.
3349              
3350 0 0         if (-e $constrain) { eval "$constrain"; } # HERE THE INSTRUCTION WRITTEN IN THE OPTS CONFIGURATION FILE CAN BE SPEFICIED
  0            
3351             # FOR PROPAGATION OF CONSTRAINTS
3352              
3353 0           @dov = @{$v[$#v]}; #
  0            
3354 0           shift (@dov); #
3355             }
3356             } # END SUB read_geo_constraints
3357              
3358              
3359             sub apply_geo_constraints
3360             {
3361             # IT APPLY USER-IMPOSED CONSTRAINTS TO A GEOMETRY FILES VIA SHELL
3362             # IT HAS TO BE CALLED WITH:
3363             # apply_geo_constraints(\@v, \@vertexletters, \@work_letters, \$exeonfiles, \$zone_letter);
3364 0     0 0   my $swap = shift;
3365 0           my @v = @$swap;
3366 0           my $swap = shift;
3367 0           my @vertexletters = @$swap;
3368              
3369 0           my $swap = shift;
3370 0           my @work_letters = @$swap;
3371              
3372 0           my $exeonfiles = shift;
3373 0           my $zone_letter = shift;
3374 0           my $toshell = shift;
3375 0           my $outfile = shift;
3376 0           my $configfile = shift;
3377 0           my $swap = shift;
3378 0           my @tempv = @$swap;
3379              
3380              
3381 0           my $countervertex = 0;
3382              
3383 0           foreach my $v (@v)
3384             {
3385 0           my $vertexletter = $vertexletters[$countervertex];
3386 0 0 0       if
      0        
3387             (
3388             (
3389 0           (@work_letters eq "") or ($vertexletter ~~ @work_letters)
3390             )
3391             and
3392             (
3393 0           not ( @{$v[$countervertex]} ~~ @{$tempv[$countervertex]} )
3394             )
3395             )
3396             {
3397 0           my $printthis =
3398             "prj -file $to/cfg/$fileconfig -mode script<
3399              
3400             m
3401             c
3402             a
3403             $zone_letter
3404             d
3405             $vertexletter
3406             $v[$countervertex+1][0] $v[$countervertex+1][1] $v[$countervertex+1][2]
3407             -
3408             y
3409             -
3410             y
3411             c
3412             -
3413             -
3414             -
3415             -
3416             -
3417             -
3418             -
3419             -
3420             -
3421             YYY
3422             ";
3423 0 0         if ($exeonfiles eq "y")
3424             {
3425 0           print `$printthis`;
3426             }
3427              
3428 0           print TOSHELL $printthis;
3429             }
3430 0           $countervertex++;
3431             }
3432              
3433             } # END SUB apply_geo_constraints
3434              
3435             # END OF SECTION DEDICATED TO FUNCTIONS FOR CONSTRAINING GEOMETRY
3436             ##############################################################################
3437             ##############################################################################
3438              
3439              
3440              
3441             ##############################################################################
3442             ##############################################################################
3443             # BEGINNING OF SECTION DEDICATED TO FUNCTIONS FOR CONSTRAINING CONTROLS
3444              
3445             sub vary_controls
3446             { # IT IS CALLED FROM THE MAIN FILE
3447 0     0 0   my $to = shift;
3448 0           my $fileconfig = shift;
3449 0           my $stepsvar = shift;
3450 0           my $counterzone = shift;
3451 0           my $counterstep = shift;
3452 0           my $exeonfiles = shift;
3453 0           my $swap = shift;
3454 0           my @applytype = @$swap;
3455 0           my $zone_letter = $applytype[$counterzone][3];
3456 0           my $swap = shift;
3457 0           my @vary_controls = @$swap;
3458              
3459              
3460 0           my $semaphore_zone;
3461             my $semaphore_dataloop;
3462 0           my $semaphore_massflow;
3463 0           my $counter_controlmass = -1;
3464 0           my $semaphore_setpoint;
3465 0           my $counterline = 0;
3466 0           my $doline;
3467 0           my @letters = ("e", "f", "g", "h", "i", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "z"); # CHECK IF THE LAST LETTERS ARE CORRECT, ZZZ
3468 0           my @period_letters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "l", "m", "n", "o", "p", "q", "r", "s"); # CHECK IF THE LAST LETTERS ARE CORRECT, ZZZ
3469 0           my $loop_hour = 2; # NOTE: THE FOLLOWING VARIABLE NAMES ARE SHADOWED IN THE FOREACH LOOP BELOW,
3470             # BUT ARE THE ONES USED IN THE OPTS CONSTRAINTS FILES.
3471 0           my $max_heating_power = 3;
3472 0           my $min_heating_power = 4;
3473 0           my $max_cooling_power = 5,
3474             my $min_cooling_power = 6;
3475 0           my $heating_setpoint = 7;
3476 0           my $cooling_setpoint = 8;
3477 0           my $flow_hour = 2;
3478 0           my $flow_setpoint = 3;
3479 0           my $flow_onoff = 4;
3480 0           my $flow_fraction = 5;
3481 0           my $loop_letter;
3482             my $loopcontrol_letter;
3483              
3484 0           my @group = @{$vary_controls[$counterzone]};
  0            
3485 0           my $sourcefile = $group[0];
3486 0           my $targetfile = $group[1];
3487 0           my $configfile = $group[2];
3488 0           my @buildbulk = @{$group[3]};
  0            
3489 0           my @flowbulk = @{$group[4]};
  0            
3490 0           my $countbuild = 0;
3491 0           my $countflow = 0;
3492              
3493 0           my $countcontrol = 0;
3494 0           my $sourceaddress = "$to$sourcefile";
3495 0           my $targetaddress = "$to$targetfile";
3496 0           my $configaddress = "$to$configfile";
3497              
3498             #@loopcontrol; # DON'T PUT "my" HERE.
3499             #@flowcontrol; # DON'T PUT "my" HERE.
3500             #@new_loopcontrols; # DON'T PUT "my" HERE.
3501             #@new_flowcontrols; # DON'T PUT "my" HERE.
3502 0           my @groupzone_letters;
3503             my @zone_period_letters;
3504 0           my @flow_letters;
3505 0           my @fileloopbulk;
3506 0           my @fileflowbulk;
3507              
3508 0           checkfile($sourceaddress, $targetaddress);
3509              
3510 0 0         if ($counterstep == 1)
3511             {
3512 0           read_controls($sourceaddress, $targetaddress, \@letters, \@period_letters);
3513             }
3514              
3515              
3516 0           calc_newctl($to, $fileconfig, $stepsvar, $counterzone, $counterstep, \@buildbulk,
3517             \@flowbulk, \@loopcontrol, \@flowcontrol);
3518              
3519              
3520              
3521             sub calc_newctl
3522             { # TO BE CALLED WITH: calc_newcontrols($to, $fileconfig, $stepsvar, $counterzone, $counterstep, \@buildbulk, \@flowbulk, \@loopcontrol, \@flowcontrol);
3523             # THIS COMPUTES CHANGES TO BE MADE TO CONTROLS BEFORE PROPAGATION OF CONSTRAINTS
3524 0     0 0   my $to = shift;
3525 0           my $fileconfig = shift;
3526 0           my $stepsvar = shift;
3527 0           my $counterzone = shift;
3528 0           my $counterstep = shift;
3529 0           my $swap = shift;
3530 0           my @buildbulk = @$swap;
3531 0           my $swap = shift;
3532 0           my @flowbulk = @$swap;
3533 0           my $swap = shift;
3534 0           my @loopcontrol = @$swap;
3535 0           my $swap = shift;
3536 0           my @flowcontrol = @$swap;
3537              
3538 0           my @new_loop_hours;
3539             my @new_max_heating_powers;
3540 0           my @new_min_heating_powers;
3541 0           my @new_max_cooling_powers;
3542 0           my @new_min_cooling_powers;
3543 0           my @new_heating_setpoints;
3544 0           my @new_cooling_setpoints;
3545 0           my @new_flow_hours;
3546 0           my @new_flow_setpoints;
3547 0           my @new_flow_onoffs;
3548 0           my @new_flow_fractions;
3549              
3550             # HERE THE MODIFICATIONS TO BE EXECUTED ON EACH PARAMETERS ARE CALCULATED.
3551 0 0         if ($stepsvar == 0) {$stepsvar = 1;}
  0            
3552 0 0         if ($stepsvar > 1)
3553             {
3554 0           foreach $each_buildbulk (@buildbulk)
3555             {
3556 0           my @askloop = @{$each_buildbulk};
  0            
3557 0           my $new_loop_letter = $askloop[0];
3558 0           my $new_loopcontrol_letter = $askloop[1];
3559 0           my $swing_loop_hour = $askloop[2];
3560 0           my $swing_max_heating_power = $askloop[3];
3561 0           my $swing_min_heating_power = $askloop[4];
3562 0           my $swing_max_cooling_power = $askloop[5];
3563 0           my $swing_min_cooling_power = $askloop[6];
3564 0           my $swing_heating_setpoint = $askloop[7];
3565 0           my $swing_cooling_setpoint = $askloop[8];
3566              
3567 0           my $countloop = 0; #IT IS FOR THE FOLLOWING FOREACH. LEAVE IT ATTACHED TO IT.
3568 0           foreach $each_loop (@loopcontrol) # THIS DISTRIBUTES THIS NESTED DATA STRUCTURES IN A FLAT MODE TO PAIR THE INPUT FILE, USER DEFINED ONE.
3569             {
3570 0           my $countcontrol = 0;
3571 0           @thisloop = @{$each_loop};
  0            
3572             # my $letterfile = $letters[$countloop];
3573 0           foreach $lp (@thisloop)
3574             {
3575 0           my @control = @{$lp};
  0            
3576             # my $letterfilecontrol = $period_letters[$countcontrol];
3577 0           $loop_letter = $loopcontrol[$countloop][$countcontrol][0];
3578 0           $loopcontrol_letter = $loopcontrol[$countloop][$countcontrol][1];
3579 0 0 0       if ( ( $new_loop_letter eq $loop_letter ) and ($new_loopcontrol_letter eq $loopcontrol_letter ) )
3580             {
3581             # print OUTFILE "YES!: \n\n\n";
3582 0           $loop_hour__ = $loopcontrol[$countloop][$countcontrol][$loop_hour];
3583 0           $max_heating_power__ = $loopcontrol[$countloop][$countcontrol][$max_heating_power];
3584 0           $min_heating_power__ = $loopcontrol[$countloop][$countcontrol][$min_heating_power];
3585 0           $max_cooling_power__ = $loopcontrol[$countloop][$countcontrol][$max_cooling_power];
3586 0           $min_cooling_power__ = $loopcontrol[$countloop][$countcontrol][$min_cooling_power];
3587 0           $heating_setpoint__ = $loopcontrol[$countloop][$countcontrol][$heating_setpoint];
3588 0           $cooling_setpoint__ = $loopcontrol[$countloop][$countcontrol][$cooling_setpoint];
3589             }
3590 0           $countcontrol++;
3591             }
3592 0           $countloop++;
3593             }
3594              
3595 0           my $pace_loop_hour = ( $swing_loop_hour / ($stepsvar - 1) );
3596 0           my $floorvalue_loop_hour = ($loop_hour__ - ($swing_loop_hour / 2) );
3597 0           my $new_loop_hour = $floorvalue_loop_hour + ($counterstep * $pace_loop_hour);
3598              
3599 0           my $pace_max_heating_power = ( $swing_max_heating_power / ($stepsvar - 1) );
3600 0           my $floorvalue_max_heating_power = ($max_heating_power__ - ($swing_max_heating_power / 2) );
3601 0           my $new_max_heating_power = $floorvalue_max_heating_power + ($counterstep * $pace_max_heating_power);
3602              
3603 0           my $pace_min_heating_power = ( $swing_min_heating_power / ($stepsvar - 1) );
3604 0           my $floorvalue_min_heating_power = ($min_heating_power__ - ($swing_min_heating_power / 2) );
3605 0           my $new_min_heating_power = $floorvalue_min_heating_power + ($counterstep * $pace_min_heating_power);
3606              
3607 0           my $pace_max_cooling_power = ( $swing_max_cooling_power / ($stepsvar - 1) );
3608 0           my $floorvalue_max_cooling_power = ($max_cooling_power__ - ($swing_max_cooling_power / 2) );
3609 0           my $new_max_cooling_power = $floorvalue_max_cooling_power + ($counterstep * $pace_max_cooling_power);
3610              
3611 0           my $pace_min_cooling_power = ( $swing_min_cooling_power / ($stepsvar - 1) );
3612 0           my $floorvalue_min_cooling_power = ($min_cooling_power__ - ($swing_min_cooling_power / 2) );
3613 0           my $new_min_cooling_power = $floorvalue_min_cooling_power + ($counterstep * $pace_min_cooling_power);
3614              
3615 0           my $pace_heating_setpoint = ( $swing_heating_setpoint / ($stepsvar - 1) );
3616 0           my $floorvalue_heating_setpoint = ($heating_setpoint__ - ($swing_heating_setpoint / 2) );
3617 0           my $new_heating_setpoint = $floorvalue_heating_setpoint + ($counterstep * $pace_heating_setpoint);
3618              
3619 0           my $pace_cooling_setpoint = ( $swing_cooling_setpoint / ($stepsvar - 1) );
3620 0           my $floorvalue_cooling_setpoint = ($cooling_setpoint__ - ($swing_cooling_setpoint / 2) );
3621 0           my $new_cooling_setpoint = $floorvalue_cooling_setpoint + ($counterstep * $pace_cooling_setpoint);
3622              
3623 0           $new_loop_hour = sprintf("%.2f", $new_loop_hour);
3624 0           $new_max_heating_power = sprintf("%.2f", $new_max_heating_power);
3625 0           $new_min_heating_power = sprintf("%.2f", $new_min_heating_power);
3626 0           $new_max_cooling_power = sprintf("%.2f", $new_max_cooling_power);
3627 0           $new_min_cooling_power = sprintf("%.2f", $new_min_cooling_power);
3628 0           $new_heating_setpoint = sprintf("%.2f", $new_heating_setpoint);
3629 0           $new_cooling_setpoint = sprintf("%.2f", $new_cooling_setpoint);
3630              
3631 0           push(@new_loopcontrols,
3632             [ $new_loop_letter, $new_loopcontrol_letter, $new_loop_hour,
3633             $new_max_heating_power, $new_min_heating_power, $new_max_cooling_power,
3634             $new_min_cooling_power, $new_heating_setpoint, $new_cooling_setpoint ] );
3635             }
3636              
3637 0           my $countflow = 0;
3638              
3639 0           foreach my $elm (@flowbulk)
3640             {
3641 0           my @askflow = @{$elm};
  0            
3642 0           my $new_flow_letter = $askflow[0];
3643 0           my $new_flowcontrol_letter = $askflow[1];
3644 0           my $swing_flow_hour = $askflow[2];
3645 0           my $swing_flow_setpoint = $askflow[3];
3646 0           my $swing_flow_onoff = $askflow[4];
3647 0 0         if ( $swing_flow_onoff eq "ON") { $swing_flow_onoff = 1; }
  0 0          
3648 0           elsif ( $swing_flow_onoff eq "OFF") { $swing_flow_onoff = -1; }
3649 0           my $swing_flow_fraction = $askflow[5];
3650              
3651 0           my $countflow = 0; # IT IS FOR THE FOLLOWING FOREACH. LEAVE IT ATTACHED TO IT.
3652 0           foreach $each_flow (@flowcontrol) # THIS DISTRIBUTES THOSE NESTED DATA STRUCTURES IN A FLAT MODE TO PAIR THE INPUT FILE, USER DEFINED ONE.
3653             {
3654 0           my $countcontrol = 0;
3655 0           @thisflow = @{$each_flow};
  0            
3656             # my $letterfile = $letters[$countflow];
3657 0           foreach $elm (@thisflow)
3658             {
3659 0           my @control = @{$elm};
  0            
3660             # my $letterfilecontrol = $period_letters[$countcontrol];
3661 0           $flow_letter = $flowcontrol[$countflow][$countcontrol][0];
3662 0           $flowcontrol_letter = $flowcontrol[$countflow][$countcontrol][1];
3663 0 0 0       if ( ( $new_flow_letter eq $flow_letter ) and ($new_flowcontrol_letter eq $flowcontrol_letter ) )
3664             {
3665 0           $flow_hour__ = $flowcontrol[$countflow][$countcontrol][$flow_hour];
3666 0           $flow_setpoint__ = $flowcontrol[$countflow][$countcontrol][$flow_setpoint];
3667 0           $flow_onoff__ = $flowcontrol[$countflow][$countcontrol][$flow_onoff];
3668 0 0         if ( $flow_onoff__ eq "ON") { $flow_onoff__ = 1; }
  0 0          
3669 0           elsif ( $flow_onoff__ eq "OFF") { $flow_onoff__ = -1; }
3670 0           $flow_fraction__ = $flowcontrol[$countflow][$countcontrol][$flow_fraction];
3671             }
3672 0           $countcontrol++;
3673             }
3674 0           $countflow++;
3675             }
3676            
3677 0           my $pace_flow_hour = ( $swing_flow_hour / ($stepsvar - 1) );
3678 0           my $floorvalue_flow_hour = ($flow_hour__ - ($swing_flow_hour / 2) );
3679 0           my $new_flow_hour = $floorvalue_flow_hour + ($counterstep * $pace_flow_hour);
3680              
3681 0           my $pace_flow_setpoint = ( $swing_flow_setpoint / ($stepsvar - 1) );
3682 0           my $floorvalue_flow_setpoint = ($flow_setpoint__ - ($swing_flow_setpoint / 2) );
3683 0           my $new_flow_setpoint = $floorvalue_flow_setpoint + ($counterstep * $pace_flow_setpoint);
3684              
3685 0           my $pace_flow_onoff = ( $swing_flow_onoff / ($stepsvar - 1) );
3686 0           my $floorvalue_flow_onoff = ($flow_onoff__ - ($swing_flow_onoff / 2) );
3687 0           my $new_flow_onoff = $floorvalue_flow_onoff + ($counterstep * $pace_flow_onoff);
3688              
3689 0           my $pace_flow_fraction = ( $swing_flow_fraction / ($stepsvar - 1) );
3690 0           my $floorvalue_flow_fraction = ($flow_fraction__ - ($swing_flow_fraction / 2) );
3691 0           my $new_flow_fraction = $floorvalue_flow_fraction + ($counterstep * $pace_flow_fraction);
3692              
3693 0           $new_flow_hour = sprintf("%.2f", $new_flow_hour);
3694 0           $new_flow_setpoint = sprintf("%.2f", $new_flow_setpoint);
3695 0           $new_flow_onoff = sprintf("%.2f", $new_flow_onoff);
3696 0           $new_flow_fraction = sprintf("%.2f", $new_flow_fraction);
3697              
3698 0           push(@new_flowcontrols,
3699             [ $new_flow_letter, $new_flowcontrol_letter, $new_flow_hour, $new_flow_setpoint, $new_flow_onoff, $new_flow_fraction ] );
3700             }
3701             # HERE THE MODIFICATIONS TO BE EXECUTED ON EACH PARAMETERS ARE APPLIED TO THE MODELS THROUGH ESP-r.
3702             # FIRST, HERE THEY ARE APPLIED TO THE ZONE CONTROLS, THEN TO THE FLOW CONTROLS
3703             }
3704             } # END SUB calc_newcontrols
3705              
3706 0           print OUTFILE "\@new_loopcontrols: " . Dumper(@new_loopcontrols) . "\n\n";
3707              
3708 0           apply_loopcontrol_changes($exeonfiles, \@new_loopcontrols);
3709 0           apply_flowcontrol_changes($exeonfiles, \@new_flowcontrols);
3710              
3711             } # END SUB vary_controls.
3712              
3713              
3714             sub constrain_controls
3715             { # IT READS CONTROL USER-IMPOSED CONSTRAINTS
3716 0     0 0   my $to = shift;
3717 0           my $fileconfig = shift;
3718 0           my $stepsvar = shift;
3719 0           my $counterzone = shift;
3720 0           my $counterstep = shift;
3721 0           my $exeonfiles = shift;
3722 0           my $swap = shift;
3723 0           my @applytype = @$swap;
3724 0           my $zone_letter = $applytype[$counterzone][3];
3725 0           my $swap = shift;
3726 0           my @constrain_controls = @$swap;
3727 0           my $to_do = shift;
3728              
3729              
3730 0           my $elm = $constrain_controls[$counterzone];
3731 0           my @group = @{$elm};
  0            
3732 0           my $sourcefile = $group[2];
3733 0           my $targetfile = $group[3];
3734 0           my $configfile = $group[4];
3735 0           my $sourceaddress = "$to$sourcefile";
3736 0           my $targetaddress = "$to$targetfile";
3737 0           my $configaddress = "$to$configfile";
3738             #@loopcontrol; @flowcontrol; @new_loopcontrols; @new_flowcontrols; # DON'T PUT "my" HERE. THEY ARE GLOBAL!!!
3739 0           my $semaphore_zone;
3740             my $semaphore_dataloop;
3741 0           my $semaphore_massflow;
3742 0           my $counter_controlmass = -1;
3743 0           my $semaphore_setpoint;
3744 0           my $counterline = 0;
3745 0           my $doline;
3746 0           my @letters = ("e", "f", "g", "h", "i", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "z"); # CHECK IF THE LAST LETTERS ARE CORRECT, ZZZ
3747 0           my @period_letters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "l", "m", "n", "o", "p", "q", "r", "s"); # CHECK IF THE LAST LETTERS ARE CORRECT, ZZZ
3748 0           my $loop_hour = 2; # NOTE: THE FOLLOWING VARIABLE NAMES ARE SHADOWED IN THE FOREACH LOOP BELOW,
3749             # BUT ARE THE ONES USED IN THE OPTS CONSTRAINTS FILES.
3750 0           my $max_heating_power = 3;
3751 0           my $min_heating_power = 4;
3752 0           my $max_cooling_power = 5,
3753             my $min_cooling_power = 6;
3754 0           my $heating_setpoint = 7;
3755 0           my $cooling_setpoint = 8;
3756 0           my $flow_hour = 2;
3757 0           my $flow_setpoint = 3;
3758 0           my $flow_onoff = 4;
3759 0           my $flow_fraction = 5;
3760 0           my $loop_letter;
3761             my $loopcontrol_letter;
3762 0           my $countbuild = 0;
3763 0           my $countflow = 0;
3764 0           my $countcontrol = 0;
3765              
3766 0           my @groupzone_letters;
3767             my @zone_period_letters;
3768 0           my @flow_letters;
3769 0           my @fileloopbulk;
3770 0           my @fileflowbulk;
3771              
3772 0 0         unless ($to_do eq "justwrite")
3773             {
3774 0 0         if ($counterstep == 1)
3775             {
3776 0           print OUTFILE "THIS\n";
3777 0           checkfile($sourceaddress, $targetaddress);
3778 0           read_controls($sourceaddress, $targetaddress, \@letters, \@period_letters);
3779 0           read_control_constraints($to, $fileconfig, $stepsvar,
3780             $counterzone, $counterstep, $configaddress, \@loopcontrol, \@flowcontrol, \@temploopcontrol, \@tempflowcontrol);
3781             }
3782             }
3783              
3784 0 0         unless ($to_do eq "justread")
3785             {
3786 0           print OUTFILE "THAT\n";
3787 0           apply_loopcontrol_changes($exeonfiles, \@new_loopcontrol, \@temploopcontrol);
3788 0           apply_flowcontrol_changes($exeonfiles, \@new_flowcontrol, \@tempflowcontrol);
3789             }
3790              
3791             } # END SUB constrain_controls.
3792              
3793              
3794             sub read_controls
3795             { # TO BE CALLED WITH: read_controls($sourceaddress, $targetaddress, \@letters, \@period_letters);
3796             # THIS MAKES THE CONTROL CONFIGURATION FILE BE READ AND THE NEEDED VALUES ACQUIRED.
3797             # NOTICE THAT CURRENTLY ONLY THE "basic control law" IS SUPPORTED.
3798              
3799 0     0 0   my $sourceaddress = shift;
3800 0           my $targetaddress = shift;
3801             # checkfile($sourceaddress, $targetaddress); # THIS HAS TO BE _FIXED!_
3802 0           my $swap = shift;
3803 0           my @letters = @$swap;
3804 0           my $swap = shift;
3805 0           my @period_letters = @$swap;
3806              
3807              
3808 0 0         open( SOURCEFILE, $sourceaddress ) or die "Can't open $sourceaddress: $!\n";
3809 0           my @lines = ;
3810 0           close SOURCEFILE;
3811 0           my $counterlines = 0;
3812 0           my $countloop = -1;
3813 0           my $countloopcontrol;
3814 0           my $countflow = -1;
3815 0           my $countflowcontrol = -1;
3816 0           my $semaphore_building;
3817             my $semaphore_loop;
3818 0           my $loop_hour;
3819 0           my $semaphore_loopcontrol;
3820 0           my $semaphore_massflow;
3821 0           my $flow_hour;
3822 0           my $semaphore_flow;
3823 0           my $semaphore_flowcontrol;
3824 0           my $loop_letter;
3825 0           my $loopcontrol_letter;
3826 0           my $flow_letter;
3827 0           my $flowcontrol_letter;
3828              
3829 0           foreach my $line (@lines)
3830             {
3831 0 0         if ( $line =~ /Control function/ )
3832             {
3833 0           $semaphore_loop = "yes";
3834 0           $countloopcontrol = -1;
3835 0           $countloop++;
3836 0           $loop_letter = $letters[$countloop];
3837             }
3838 0 0         if ( ($line =~ /ctl type, law/ ) )
3839             {
3840 0           $countloopcontrol++;
3841 0           my @row = split(/\s+/, $line);
3842 0           $loop_hour = $row[3];
3843 0           $semaphore_loopcontrol = "yes";
3844 0           $loopcontrol_letter = $period_letters[$countloopcontrol];
3845             }
3846              
3847 0 0 0       if ( ($semaphore_loop eq "yes") and ($semaphore_loopcontrol eq "yes") and ($line =~ /No. of data items/ ) )
      0        
3848             {
3849 0           $doline = $counterlines + 1;
3850             }
3851              
3852 0 0 0       if ( ($semaphore_loop eq "yes" ) and ($semaphore_loopcontrol eq "yes") and ($counterlines == $doline) )
      0        
3853             {
3854 0           my @row = split(/\s+/, $line);
3855 0           my $max_heating_power = $row[1];
3856 0           my $min_heating_power = $row[2];
3857 0           my $max_cooling_power = $row[3];
3858 0           my $min_cooling_power = $row[4];
3859 0           my $heating_setpoint = $row[5];
3860 0           my $cooling_setpoint = $row[6];
3861              
3862 0           push(@{$loopcontrol[$countloop][$countloopcontrol]},
  0            
3863             $loop_letter, $loopcontrol_letter, $loop_hour,
3864             $max_heating_power, $min_heating_power, $max_cooling_power,
3865             $min_cooling_power, $heating_setpoint, $cooling_setpoint );
3866              
3867 0           $semaphore_loopcontrol = "no";
3868 0           $doline = "";
3869             }
3870              
3871 0 0         if ($line =~ /Control mass/ )
3872             {
3873 0           $semaphore_flow = "yes";
3874 0           $countflowcontrol = -1;
3875 0           $countflow++;
3876 0           $flow_letter = $letters[$countflow];
3877             }
3878 0 0         if ( ($line =~ /ctl type \(/ ) )
3879             {
3880 0           $countflowcontrol++;
3881 0           my @row = split(/\s+/, $line);
3882 0           $flow_hour = $row[3];
3883 0           $semaphore_flowcontrol = "yes";
3884 0           $flowcontrol_letter = $period_letters[$countflowcontrol];
3885             }
3886              
3887 0 0 0       if ( ($semaphore_flow eq "yes") and ($semaphore_flowcontrol eq "yes") and ($line =~ /No. of data items/ ) )
      0        
3888             {
3889 0           $doline = $counterlines + 1;
3890             }
3891              
3892 0 0 0       if ( ($semaphore_flow eq "yes" ) and ($semaphore_flowcontrol eq "yes") and ($counterlines == $doline) )
      0        
3893             {
3894 0           my @row = split(/\s+/, $line);
3895 0           my $flow_setpoint = $row[1];
3896 0           my $flow_onoff = $row[2];
3897 0           my $flow_fraction = $row[3];
3898 0           push(@{$flowcontrol[$countflow][$countflowcontrol]},
  0            
3899             $flow_letter, $flowcontrol_letter, $flow_hour, $flow_setpoint, $flow_onoff, $flow_fraction);
3900 0           $semaphore_flowcontrol = "no";
3901 0           $doline = "";
3902             }
3903 0           $counterlines++;
3904             }
3905             } # END SUB read_controls.
3906              
3907              
3908             sub read_control_constraints
3909             {
3910             # #!/usr/bin/perl
3911             # THIS FILE CAN CONTAIN USER-IMPOSED CONSTRAINTS FOR CONTROLS TO BE READ BY OPTS.
3912             # THE FOLLOWING VALUES CAN BE ADDRESSED IN THE OPTS CONSTRAINTS CONFIGURATION FILE,
3913             # SET BY THE PRESENT FUNCTION:
3914             # 1) $loopcontrol[$counterzone][$countloop][$countloopcontrol][$loop_hour]
3915             # Where $countloop and $countloopcontrol has to be set to a specified number in the OPTS file for constraints.
3916             # 2) $loopcontrol[$counterzone][$countloop][$countloopcontrol][$max_heating_power] # Same as above.
3917             # 3) $loopcontrol[$counterzone][$countloop][$countloopcontrol][$min_heating_power] # Same as above.
3918             # 4) $loopcontrol[$counterzone][$countloop][$countloopcontrol][$max_cooling_power] # Same as above.
3919             # 5) $loopcontrol[$counterzone][$countloop][$countloopcontrol][$min_cooling_power] # Same as above.
3920             # 6) $loopcontrol[$counterzone][$countloop][$countloopcontrol][heating_setpoint] # Same as above.
3921             # 7) $loopcontrol[$counterzone][$countloop][$countloopcontrol][cooling_setpoint] # Same as above.
3922             # 8) $flowcontrol[$counterzone][$countflow][$countflowcontrol][$flow_hour]
3923             # Where $countflow and $countflowcontrol has to be set to a specified number in the OPTS file for constraints.
3924             # 9) $flowcontrol[$counterzone][$countflow][$countflowcontrol][$flow_setpoint] # Same as above.
3925             # 10) $flowcontrol[$counterzone][$countflow][$countflowcontrol][$flow_onoff] # Same as above.
3926             # 11) $flowcontrol[$counterzone][$countflow][$countflowcontrol][$flow_fraction] # Same as above.
3927             # EXAMPLE : $flowcontrol[0][1][2][$flow_fraction] = 0.7
3928             # OTHER EXAMPLE: $flowcontrol[2][1][2][$flow_fraction] = $flowcontrol[0][2][1][$flow_fraction]
3929             # The $counterzone that is actuated is always the last, the one which is active.
3930             # It would have therefore no sense writing $flowcontrol[1][1][2][$flow_fraction] = $flowcontrol[3][2][1][$flow_fraction].
3931             # Differentent $counterzones can be referred to the same zone. Different $counterzones just number mutations in series.
3932             # ALSO, THIS MAKES AVAILABLE TO THE USER INFORMATIONS ABOUT THE MORPHING STEP OF THE MODELS
3933             # AND THE STEPS THE MODEL HAS TO FOLLOW.
3934             # THIS ALLOWS TO IMPOSE EQUALITY CONSTRAINTS TO THESE VARIABLES,
3935             # WHICH COULD ALSO BE COMBINED WITH THE FOLLOWING ONES:
3936             # $stepsvar, WHICH TELLS THE PROGRAM HOW MANY ITERATION STEPS IT HAS TO DO IN THE CURRENT MORPHING PHASE.
3937             # $counterzone, WHICH TELLS THE PROGRAM WHAT OPERATION IS BEING EXECUTED IN THE CHAIN OF OPERATIONS
3938             # THAT MAY BE EXECUTES AT EACH MORPHING PHASE. EACH $counterzone WILL CONTAIN ONE OR MORE ITERATION STEPS.
3939             # TYPICALLY, IT WILL BE USED FOR A ZONE, BUT NOTHING PREVENTS THAT SEVERAL OF THEM CHAINED ONE AFTER
3940             # THE OTHER ARE APPLIED TO THE SAME ZONE.
3941             # $counterstep, WHICH TELLS THE PROGRAM WHAT THE CURRENT ITERATION STEP IS.
3942 0     0 0   my $to = shift;
3943 0           my $fileconfig = shift;
3944 0           my $stepsvar = shift;
3945 0           my $counterzone = shift;
3946 0           my $counterstep = shift;
3947 0           my $configaddress = shift;
3948 0           my $swap = shift;
3949 0           @loopcontrol = @$swap;
3950 0           my $swap = shift;
3951 0           @flowcontrol = @$swap;
3952 0           my $swap = shift;
3953 0           @temploopcontrol = @$swap;
3954 0           my $swap = shift;
3955 0           @tempflowcontrol = @$swap;
3956              
3957 0 0         if (-e $configaddress) # TEST THIS, DDD
3958             { # THIS APPLIES CONSTRAINST, THE FLATTEN THE HIERARCHICAL STRUCTURE OF THE RESULTS,
3959             # TO BE PREPARED THEN FOR BEING APPLIED TO CHANGE PROCEDURES. IT HAS TO BE TESTED.
3960 0           push (@loopcontrol, [@myloopcontrol]); #
3961 0           push (@flowcontrol, [@myflowcontrol]); #
3962              
3963 0           eval `cat $configaddress`; # HERE AN EXTERNAL FILE FOR PROPAGATION OF CONSTRAINTS
3964             # IS EVALUATED, AND HERE BELOW CONSTRAINTS ARE PROPAGATED.
3965              
3966 0 0         if (-e $constrain) { eval "$constrain"; } # HERE THE INSTRUCTION WRITTEN IN THE OPTS CONFIGURATION FILE CAN BE SPEFICIED
  0            
3967             # FOR PROPAGATION OF CONSTRAINTS
3968              
3969 0           @doloopcontrol = @{$loopcontrol[$#loopcontrol]}; #
  0            
3970 0           @doflowcontrol = @{$flowcontrol[$#flowcontrol]}; #
  0            
3971              
3972 0           shift (@doloopcontrol);
3973 0           shift (@doflowcontrol);
3974              
3975             sub flatten_loopcontrol_constraints
3976             {
3977 0     0 0   my @looptemp = @doloopcontrol;
3978 0           @new_loopcontrol = "";
3979 0           foreach my $elm (@looptemp)
3980             {
3981 0           my @loop = @{$elm};
  0            
3982 0           foreach my $elm (@loop)
3983             {
3984 0           my @loop = @{$elm};
  0            
3985 0           push (@new_loopcontrol, [@loop]);
3986             }
3987             }
3988             }
3989 0           flatten_loopcontrol_constraints;
3990              
3991             sub flatten_flowcontrol_constraints
3992             {
3993 0     0 0   my @flowtemp = @doflowcontrol;
3994 0           @new_flowcontrol = "";
3995 0           foreach my $elm (@flowtemp)
3996             {
3997 0           my @flow = @{$elm};
  0            
3998 0           foreach my $elm (@flow)
3999             {
4000 0           my @loop = @{$elm};
  0            
4001 0           push (@new_flowcontrol, [@flow]);
4002             }
4003             }
4004             }
4005 0           flatten_flowcontrol_constraints;
4006              
4007 0           shift @new_loopcontrol;
4008 0           shift @new_flowcontrol;
4009             }
4010             } # END SUB read_control_constraints
4011              
4012              
4013             sub apply_loopcontrol_changes
4014             { # TO BE CALLED WITH: apply_loopcontrol_changes($exeonfiles, \@new_loopcontrol);
4015             # THIS APPLIES CHANGES TO LOOPS IN CONTROLS (ZONES)
4016 0     0 0   my $exeonfiles = shift;
4017 0           my $swap = shift;
4018 0           my @new_loop_ctls = @$swap;
4019 0           my $swap = shift;
4020 0           my @temploopcontrol = @$swap;
4021 0           my $counterloop = 0;
4022              
4023 0           foreach my $elm (@new_loop_ctls)
4024             {
4025 0           my @loop = @{$elm};
  0            
4026 0           $new_loop_letter = $loop[0];
4027 0           $new_loopcontrol_letter = $loop[1];
4028 0           $new_loop_hour = $loop[2];
4029 0           $new_max_heating_power = $loop[3];
4030 0           $new_min_heating_power = $loop[4];
4031 0           $new_max_cooling_power = $loop[5];
4032 0           $new_min_cooling_power = $loop[6];
4033 0           $new_heating_setpoint = $loop[7];
4034 0           $new_cooling_setpoint = $loop[8];
4035 0 0         unless ( @{$new_loop_ctls[$counterloop]} ~~ @{$temploopcontrol[$counterloop]} )
  0            
  0            
4036             {
4037 0           my $printthis =
4038             "prj -file $to/cfg/$fileconfig -mode script<
4039              
4040             m
4041             j
4042              
4043             $new_loop_letter
4044             c
4045             $new_loopcontrol_letter
4046             1
4047             $new_loop_hour
4048             b
4049             $new_max_heating_power
4050             c
4051             $new_min_heating_power
4052             d
4053             $new_max_cooling_power
4054             e
4055             $new_min_cooling_power
4056             f
4057             $new_heating_setpoint
4058             g
4059             $new_cooling_setpoint
4060             -
4061             y
4062             -
4063             -
4064             -
4065             n
4066             d
4067              
4068             -
4069             y
4070             y
4071             -
4072             -
4073             YYY
4074             ";
4075 0 0         if ($exeonfiles eq "y")
4076             {
4077 0           print `$printthis`;
4078             }
4079 0           print TOSHELL $printthis;
4080             }
4081 0           $counterloop++;
4082             }
4083             } # END SUB apply_loopcontrol_changes();
4084              
4085              
4086              
4087              
4088             sub apply_flowcontrol_changes
4089             { # THIS HAS TO BE CALLED WITH: apply_flowcontrol_changes($exeonfiles, \@new_flowcontrols);
4090             # # THIS APPLIES CHANGES TO NETS IN CONTROLS
4091 0     0 0   my $exeonfiles = shift;
4092 0           my $swap = shift;
4093 0           my @new_flowcontrols = @$swap;
4094 0           my $swap = shift;
4095 0           my @tempflowcontrol = @$swap;
4096 0           my $counterflow = 0;
4097              
4098 0           foreach my $elm (@new_flowcontrols)
4099             {
4100 0           my @flow = @{$elm};
  0            
4101 0           $flow_letter = $flow[0];
4102 0           $flowcontrol_letter = $flow[1];
4103 0           $new_flow_hour = $flow[2];
4104 0           $new_flow_setpoint = $flow[3];
4105 0           $new_flow_onoff = $flow[4];
4106 0           $new_flow_fraction = $flow[5];
4107 0 0         unless ( @{$new_flowcontrols[$counterflow]} ~~ @{$tempflowcontrol[$counterflow]} )
  0            
  0            
4108             {
4109 0           my $printthis =
4110             "prj -file $to/cfg/$fileconfig -mode script<
4111              
4112             m
4113             l
4114              
4115             $flow_letter
4116             c
4117             $flowcontrol_letter
4118             a
4119             $new_flow_hour
4120             $new_flow_setpoint $new_flow_onoff $new_flow_fraction
4121             -
4122             -
4123             -
4124             y
4125             y
4126             -
4127             -
4128             YYY
4129             ";
4130 0 0         if ($exeonfiles eq "y") # if ($exeonfiles eq "y")
4131             {
4132 0           print `$printthis`;
4133             }
4134              
4135 0           print TOSHELL $printthis;
4136             }
4137 0           $counterflow++;
4138             }
4139             } # END SUB apply_flowcontrol_changes;
4140              
4141             # END OF SECTION DEDICATED TO FUNCTIONS FOR CONSTRAINING CONTROLS
4142             ##############################################################################
4143             ##############################################################################
4144              
4145              
4146              
4147              
4148              
4149             ##############################################################################
4150             ##############################################################################
4151             # BEGINNING OF SECTION DEDICATED TO FUNCTIONS FOR CONSTRAINING OBSTRUCTIONS
4152              
4153             sub constrain_obstructions # IT APPLIES CONSTRAINTS TO OBSTRUCTIONS
4154             {
4155             # THIS CONSTRAINS OBSTRUCTION FILES. IT HAS TO BE CALLED FROM THE MAIN FILE WITH:
4156             # constrain_obstruction($to, $fileconfig, $stepsvar, $counterzone, $counterstep, $exeonfiles, \@applytype, \@constrain_obstructions);
4157 0     0 0   my $to = shift;
4158 0           my $fileconfig = shift;
4159 0           my $stepsvar = shift;
4160 0           my $counterzone = shift;
4161 0           my $counterstep = shift;
4162 0           my $exeonfiles = shift;
4163 0           my $swap = shift;
4164 0           my @applytype = @$swap;
4165 0           my $zone_letter = $applytype[$counterzone][3];
4166 0           my $swap2 = shift;
4167 0           my @constrain_obstructions = @$swap2;
4168 0           my $to_do = shift;
4169              
4170              
4171 0           my @work_letters;
4172             #@obs; # GLOBAL!
4173              
4174 0           foreach my $elm (@constrain_obstructions)
4175             {
4176 0           my @group = @{$elm};
  0            
4177 0           my $zone_letter = $group[1];
4178 0           my $sourcefile = $group[2];
4179 0           my $targetfile = $group[3];
4180 0           my $configfile = $group[4];
4181 0           my $sourceaddress = "$to$sourcefile";
4182 0           my $targetaddress = "$to$targetfile";
4183 0           my $configaddress = "$to$configfile";
4184 0           my @work_letters = @{$group[5]};
  0            
4185 0           my $actonmaterials = $group[6];
4186              
4187 0 0         unless ($to_do eq "justwrite")
4188             {
4189 0           checkfile($sourceaddress, $targetaddress);
4190 0           read_obstructions($to, $sourceaddress, $targetaddress, $configaddress, \@work_letters, $actonmaterials, $exeonfiles);
4191 0           read_obs_constraints($to, $fileconfig, $stepsvar, $counterzone, $counterstep, $configaddress, $actonmaterials, $exeonfiles, \@tempobs); # IT WORKS ON THE VARIABLE @obs, WHICH IS GLOBAL.
4192             }
4193              
4194 0 0         unless ($to_do eq "justread")
4195             {
4196 0           apply_obs_constraints(\@doobs, \@obs_letters, \@work_letters, $exeonfiles, $zone_letter, $actonmaterials, $exeonfiles, \@tempobs);
4197             }
4198             }
4199             } # END SUB constrain_obstructions
4200              
4201              
4202             sub read_obstructions
4203             {
4204             # THIS READS GEOMETRY FILES. # IT HAS TO BE CALLED WITH:
4205             # read_geometry($to, $sourcefile, $targetfile, $configfiles, \@work_letters, $longmenus);
4206 0     0 0   my $to = shift;
4207 0           my $sourceaddress = shift;
4208 0           my $targetaddress = shift;
4209 0           my $configaddress = shift;
4210 0           my $swap = shift;
4211 0           @work_letters = @$swap;
4212 0           my $actonmaterials = shift;
4213 0           my $exeonfiles = shift;
4214              
4215            
4216 0 0         open( SOURCEFILE, $sourceaddress) or die "Can't open $sourceaddress: $!\n";
4217 0           my @lines = ;
4218 0           close SOURCEFILE;
4219              
4220 0           my $counter = 0;
4221 0           foreach my $line (@lines)
4222             {
4223             #$line =~ s/^\s+//;
4224 0 0         if ( $line =~ m/\*obs/ )
4225             {
4226 0 0         unless ( $line =~ m/\*obs =/ )
4227             {
4228 0           $counter++;
4229             }
4230             }
4231             }
4232              
4233 0 0         if ( $counter > 21 )
4234             {
4235 0           @obs_letters = ("e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
4236             "o", "0\nb\nf", "0\nb\ng", "0\nb\nh", "0\nb\ni", "0\nb\nj", "0\nb\nk", "0\nb\nm",
4237             "0\nb\nn", "0\nb\no", "0\nb\n0\nb\nf","0\nb\n0\nb\ng",
4238             "0\nb\n0\nb\nh","0\nb\n0\nb\ni","0\nb\n0\nb\nj","0\nb\n0\nb\nk","0\nb\n0\nb\nl",
4239             "0\nb\n0\nb\nm","0\nb\n0\nb\nn","0\nb\n0\nb\no","0\nb\n0\nb\n0\nb\nf",
4240             "0\nb\n0\nb\n0\nb\ng","0\nb\n0\nb\n0\nb\nh","0\nb\n0\nb\n0\nb\ni","0\nb\n0\nb\n0\nb\nj",
4241             "0\nb\n0\nb\n0\nb\nk","0\nb\n0\nb\n0\nb\nl","0\nb\n0\nb\n0\nb\nm","0\nb\n0\nb\n0\nb\nn",
4242             "0\nb\n0\nb\n0\nb\no");
4243             }
4244             else
4245             {
4246 0           @obs_letters = ("e", "f", "g", "h", "i", "j", "k", "l", "m",
4247             "n", "o", "0\nf", "0\ng", "0\nh", "0\ni", "0\nj", "0\nk", "0\nl",
4248             "0\nm", "0\nn", "0\no");
4249             }
4250              
4251 0           my $counter = 0;
4252 0           foreach my $line (@lines)
4253             {
4254 0 0         if ( $line =~ m/\*obs/ )
4255             {
4256 0 0         unless ( $line =~ m/\*obs =/ )
4257             {
4258             #$line =~ s/^\s+//;
4259 0           my @rowelements = split(/,/, $line);
4260 0           push (@obs, [ $rowelements[1], $rowelements[2], $rowelements[3],
4261             $rowelements[4], $rowelements[5], $rowelements[6],
4262             $rowelements[7], $rowelements[8], $rowelements[9],
4263             $rowelements[10], $rowelements[11], $rowelements[12], $obs_letters[$counter] ] );
4264 0           $counter++;
4265             }
4266             }
4267             }
4268             } # END SUB read_obstructions
4269              
4270              
4271             sub read_obs_constraints
4272             {
4273             # THE VARIABLE @obs REGARDS OBSTRUCTION USER-IMPOSED CONSTRAINTS
4274             # THIS CONSTRAINT CONFIGURATION FILE MAKES AVAILABLE TO THE USER THE FOLLOWING VARIABLES:
4275             # $obs[$counterzone][$obs_number][$x], $obs[$counterzone][$obs_number][$y], $obs[$counterzone][$obs_number][$y]
4276             # $obs[$counterzone][$obs_number][$width], $obs[$counterzone][$obs_number][$depth], $obs[$counterzone][$obs_number][$height]
4277             # $obs[$counterzone][$obs_number][$z_rotation], $obs[$counterzone][$obs_number][$y_rotation],
4278             # $obs[$counterzone][$obs_number][$tilt], $obs[$counterzone][$obs_number][$opacity], $obs[$counterzone][$obs_number][$material],
4279             # EXAMPLE: $obs[0][2][$x] = 2. THIS MEANS: AT COUNTERZONE 0, COORDINATE x OF OBSTRUCTION HAS TO BE SET TO 2.
4280             # OTHER EXAMPLE: $obs[0][2][$x] = $obs[2][2][$y].
4281             # The $counterzone that is actuated is always the last, the one which is active.
4282             # There would be therefore no sense in writing $obs[0][4][$x] = $obs[1][2][$y].
4283             # Differentent $counterzones can be referred to the same zone. Different $counterzones just number mutations in series.
4284             # NOTE THAT THE MATERIAL TO BE SPECIFIED IS A MATERIAL LETTER, BETWEEN QUOTES. EXAMPLE: $obs[1][$material] = "a".
4285             # $tilt IS PRESENTLY UNUSED.
4286             # ALSO, THIS MAKES AVAILABLE TO THE USER INFORMATIONS ABOUT THE MORPHING STEP OF THE MODELS
4287             # AND THE STEPS THE MODEL HAVE TO FOLLOW.
4288             # THIS ALLOWS TO IMPOSE EQUALITY CONSTRAINTS TO THESE VARIABLES,
4289             # WHICH COULD ALSO BE COMBINED WITH THE FOLLOWING ONES:
4290             # $stepsvar, WHICH TELLS THE PROGRAM HOW MANY ITERATION STEPS IT HAS TO DO IN THE CURRENT MORPHING PHASE.
4291             # $counterzone, WHICH TELLS THE PROGRAM WHAT OPERATION IS BEING EXECUTED IN THE CHAIN OF OPERATIONS
4292             # THAT MAY BE EXECUTES AT EACH MORPHING PHASE. EACH $counterzone WILL CONTAIN ONE OR MORE ITERATION STEPS.
4293             # TYPICALLY, IT WILL BE USED FOR A ZONE, BUT NOTHING PREVENTS THAT SEVERAL OF THEM CHAINED ONE AFTER
4294             # THE OTHER ARE APPLIED TO THE SAME ZONE.
4295             # $counterstep, WHICH TELLS THE PROGRAM WHAT THE CURRENT ITERATION STEP IS.
4296 0     0 0   my $to = shift;
4297 0           my $fileconfig = shift;
4298 0           my $stepsvar = shift;
4299 0           my $counterzone = shift;
4300 0           my $counterstep = shift;
4301 0           my $configaddress = shift;
4302 0           my $actonmaterials = shift;
4303 0           my $exeonfiles = shift;
4304 0           my $swap = shift;
4305 0           @tempobs = @$swap;
4306              
4307 0           my $obs_letter = 13;
4308 0           my $x = 1;
4309 0           my $y = 2;
4310 0           my $z = 3;
4311 0           my $width = 4;
4312 0           my $depth = 5;
4313 0           my $height = 6;
4314 0           my $z_rotation = 7;
4315 0           my $y_rotation = 8;
4316 0           my $tilt = 9; # UNUSED
4317 0           my $opacity = 10;
4318 0           my $name = 11; # NOT TO BE CHANGED
4319 0           my $material = 12;
4320 0 0         if (-e $configaddress)
4321             {
4322 0           unshift (@obs, []);
4323 0           push (@obs, [@myobs]); #
4324 0           eval `cat $configaddress`; # HERE AN EXTERNAL FILE FOR PROPAGATION OF CONSTRAINTS IS EVALUATED.
4325              
4326 0 0         if (-e $constrain) { eval "$constrain"; } # HERE THE INSTRUCTION WRITTEN IN THE OPTS CONFIGURATION FILE CAN BE SPEFICIED
  0            
4327             # FOR PROPAGATION OF CONSTRAINTS
4328              
4329 0           @doobs = @{$obs[$#obs]}; #
  0            
4330 0           shift @doobs;
4331             }
4332             } # END SUB read_geo_constraints
4333              
4334              
4335             sub apply_obs_constraints
4336             {
4337             # IT APPLY USER-IMPOSED CONSTRAINTS TO A GEOMETRY FILES VIA SHELL
4338             # IT HAS TO BE CALLED WITH:
4339             # apply_geo_constraints(\@obs, \@obsletters, \@work_letters, \$exeonfiles, \$zone_letter, $actonmaterials);
4340 0     0 0   my $swap = shift;
4341 0           my @obs = @$swap;
4342 0           my $swap = shift;
4343 0           my @obs_letters = @$swap;
4344 0           my $swap = shift;
4345 0           my @work_letters = @$swap;
4346 0           my $exeonfiles = shift;
4347 0           my $zone_letter = shift;
4348             #print OUTFILE "ZONE LETTER: $zone_letter\n\n";
4349 0           my $actonmaterials = shift;
4350 0           my $exeonfiles = shift;
4351 0           my $swap = shift;
4352 0           my @tempobs = @$swap;
4353              
4354              
4355 0           my $counterobs = 0;
4356 0           print OUTFILE "OBS_LETTERS IN APPLY" . Dumper(@obs_letters) . "\n\n";
4357 0           foreach my $ob (@obs)
4358             {
4359 0           my $obs_letter = $obs_letters[$counterobs];
4360 0 0 0       if ( ( @work_letters eq "") or ($obs_letter ~~ @work_letters))
4361             {
4362 0           my @obstr = @{$ob};
  0            
4363 0           my $x = $obstr[0];
4364 0           my $y = $obstr[1];
4365 0           my $z = $obstr[2];
4366 0           my $width = $obs[3];
4367 0           my $depth = $obs[4];
4368 0           my $height = $obs[5];
4369 0           my $z_rotation = $obs[6];
4370 0           my $y_rotation = $obs[7];
4371 0           my $tilt = $obs[8];
4372 0           my $opacity = $obs[9];
4373 0           my $name = $obs[10];
4374 0           my $material = $obs[11];
4375 0 0         unless
4376             (
4377 0           ( @{$obs[$counterobs]} ~~ @{$tempobs[$counterobs]} )
  0            
4378             )
4379             {
4380 0           my $printthis =
4381             "prj -file $to/cfg/$fileconfig -mode script<
4382              
4383             m
4384             c
4385             a
4386             $zone_letter
4387             h
4388             a
4389             $obs_letter
4390             a
4391             a
4392             $x $y $z
4393             b
4394             $width $depth $height
4395             c
4396             $z_rotation
4397             d
4398             $y_rotation
4399             e # HERE THE DATUM IS STILL UNUSED. WHEN IT WILL, A LINE MUST BE ADDED WITH THE VARIABLE $tilt.
4400             h
4401             $opacity
4402             -
4403             -
4404             c
4405             -
4406             c
4407             -
4408             -
4409             -
4410             -
4411             YYY
4412             ";
4413 0 0         if ($exeonfiles eq "y")
4414             {
4415 0           print `$printthis`;
4416             }
4417              
4418 0           print TOSHELL $printthis;
4419             }
4420              
4421 0           my $obs_letter = $obs_letters[$counterobs];
4422 0 0         if ($obs_letter ~~ @work_letters)
4423             {
4424 0 0         if ($actonmaterials eq "y")
4425             {
4426 0           my $printthis =
4427             "prj -file $to/cfg/$fileconfig -mode script<
4428              
4429             m
4430             c
4431             a
4432             $zone_letter
4433             h
4434             a
4435             $obs_letter
4436             g
4437             $material
4438             -
4439             -
4440             -
4441             c
4442             -
4443             c
4444             -
4445             -
4446             -
4447             -
4448             YYY
4449             ";
4450 0 0         if ($exeonfiles eq "y")
4451             {
4452 0           print `$printthis`;
4453             }
4454              
4455 0           print TOSHELL $printthis;
4456             }
4457             }
4458             }
4459 0           $counterobs++;
4460             }
4461             } # END SUB apply_obs_constraints
4462              
4463              
4464             ############################################################## BEGINNING OF GROUP GET AND PIN OBSTRUCTIONS
4465             sub get_obstructions # IT APPLIES CONSTRAINTS TO ZONE GEOMETRY. TO DO. STILL UNUSED.
4466             # THE SAME FUNCTIONALITIES CAN BE OBTAINED, WITH MORE WORK, BY SPECIFYING APPROPRIATE SETTINGS IN THE OPTS CONFIG FILE.
4467             {
4468             # THIS CONSTRAINS OBSTRUCTION FILES. IT HAS TO BE CALLED FROM THE MAIN FILE WITH:
4469             # constrain_obstruction($to, $fileconfig, $stepsvar, $counterzone, $counterstep, $exeonfiles, \@applytype, \@constrain_obstructions);
4470 0     0 0   my $to = shift;
4471 0           my $fileconfig = shift;
4472 0           my $stepsvar = shift;
4473 0           my $counterzone = shift;
4474 0           my $counterstep = shift;
4475 0           my $exeonfiles = shift;
4476 0           my $swap = shift;
4477 0           my @applytype = @$swap;
4478 0           my $zone_letter = $applytype[$counterzone][3];
4479 0           my $swap2 = shift;
4480 0           my @get_obstructions = @$swap2;
4481              
4482              
4483 0           my @work_letters ;
4484             @obs; # GLOBAL!
4485 0           foreach my $elm (@constrain_obstructions)
4486             {
4487 0           my @group = @{$elm};
  0            
4488 0           my $zone_letter = $group[1];
4489 0           my $sourcefile = $group[2];
4490 0           my $targetfile = $group[3];
4491 0           my $sourceaddress = "$to$sourcefile";
4492 0           my $targetaddress = "$to$targetfile";
4493 0           my $temp = $group[4];
4494 0           my @work_letters = @{$group[5]};
  0            
4495 0           my @obs_letters;
4496 0           checkfile($sourceaddress, $targetaddress);
4497 0           read_obstructions($to, $sourceaddress, $targetaddress, $configaddress, \@work_letters);
4498 0           write_temporary(\@obs, \@obs_letters, \@work_letters, $exeonfiles, $zone_letter, $temp);
4499             }
4500             } # END SUB constrain_obstructions
4501              
4502              
4503             sub write_temporary
4504             {
4505             # IT APPLY USER-IMPOSED CONSTRAINTS TO A GEOMETRY FILES VIA SHELL. TO DO. STILL UNUSED. ZZZ
4506             # IT HAS TO BE CALLED WITH:
4507             # apply_geo_constraints(\obs, \@obsletters, \@work_letters, \$exeonfiles, \$zone_letter, $actonmaterials);
4508 0     0 0   my $swap = shift;
4509 0           my @obs = @$swap;
4510 0           my $swap = shift;
4511 0           my @obs_letters = @$swap;
4512 0           my $swap = shift;
4513 0           my @work_letters = @$swap;
4514 0           my $exeonfiles = shift;
4515 0           my $zone_letter = shift;
4516 0           my $temp = shift;
4517 0           my $toshell = shift;
4518 0           my $outfile = shift;
4519 0           my $configfile = shift;
4520              
4521              
4522              
4523              
4524 0 0         open( SOURCEFILE, ">$temp" ) or die "Can't open $temp: $!\n";
4525 0           my $counterobs = 0;
4526              
4527 0           foreach my $ob (@obs)
4528             {
4529 0           my $obs_letter = $obs_letters[$counterobs];
4530 0 0         if ($obs_letter ~~ @work_letters)
4531             {
4532 0           my @obs = @{$ob};
  0            
4533 0           print SOURCEFILE . "*obs $obs[1] $obs[2] $obs[3] $obs[4] $obs[5] $obs[6] $obs[7] $obs[8] $obs[10] $obs[11] $obs[12] $obs_letter\n";
4534             }
4535 0           $counterobs++;
4536 0           close SOURCEFILE;
4537             }
4538             } # END SUB write_temporary
4539              
4540              
4541             sub pin_obstructions # TO DO. ZZZ
4542             {
4543             # THIS CONSTRAINS OBSTRUCTION FILES. TO DO. STILL UNUSED. ZZZ
4544             # IT HAS TO BE CALLED FROM THE MAIN FILE WITH:
4545             # constrain_obstruction($to, $fileconfig, $stepsvar, $counterzone, $counterstep, $exeonfiles, \@applytype, \@pin_obstructions);
4546 0     0 0   my $to = shift;
4547 0           my $fileconfig = shift;
4548 0           my $stepsvar = shift;
4549 0           my $counterzone = shift;
4550 0           my $counterstep = shift;
4551 0           my $exeonfiles = shift;
4552 0           my $swap = shift;
4553 0           my @applytype = @$swap;
4554 0           my $zone_letter = $applytype[$counterzone][3];
4555 0           my $swap = shift;
4556 0           my @pin_obstructions = @$swap;
4557              
4558              
4559 0           my @work_letters ;
4560             my @obs;
4561 0           my @newobs;
4562 0           foreach my $elm (@pin_obstructions)
4563             {
4564 0           my @group = @{$elm};
  0            
4565 0           my $zone_letter = $group[1];
4566 0           my $sourcefile = $group[2];
4567 0           my $targetfile = $group[3];
4568 0           my $sourceaddress = "$to$sourcefile";
4569 0           my $targetaddress = "$to$targetfile";
4570 0           my $temp = $group[4];
4571 0           my @obs_letters;
4572 0           checkfile($sourceaddress, $targetaddress);
4573              
4574 0 0         open( SOURCEFILE, $temp ) or die "Can't open $temp: $!\n";
4575 0           my @rows = < SOURCEFILE >;
4576 0           foreach my $line (@rows)
4577             {
4578 0           my @elts = split(/\s+|,/, $line);
4579 0           push (@newobs, [ $elts[1], $elts[2], $elts[3], $elts[4], $elts[5], $elts[6], $elts[7], $elts[8], $elts[9], $elts[10], $elts[11], $elts[12], $elts[13] ] );
4580             }
4581 0           apply_pin_obstructions($to, $fileconfig,$stepsvar, $counterzone, $counterstep, $exeonfiles, \@newobs );
4582             }
4583             } # END SUB pin_obstructions
4584              
4585              
4586             sub apply_pin_obstructions # TO DO. STILL UNUSED. ZZZ
4587             {
4588             # IT APPLY USER-IMPOSED CONSTRAINTS TO A GEOMETRY FILES VIA SHELL
4589             # IT HAS TO BE CALLED WITH:
4590             # apply_pin_obstructions( $to, $fileconfig,$stepsvar, $counterzone, $counterstep, $exeonfiles, \@obs );
4591 0     0 0   my $to = shift;
4592 0           my $fileconfig = shift;
4593 0           my $stepsvar = shift;
4594 0           my $counterzone = shift;
4595 0           my $counterstep = shift;
4596 0           my $exeonfiles = shift;
4597 0           my $swap = shift;
4598 0           my @obs = @$swap;
4599              
4600              
4601 0           my $counterobs = 0;
4602 0           foreach my $ob (@obs)
4603             {
4604 0           my @obs = @{$ob};
  0            
4605 0           my $x = $obs[1];
4606 0           my $y = $obs[2];
4607 0           my $z = $obs[3];
4608 0           my $width = $obs[4];
4609 0           my $depth = $obs[5];
4610 0           my $height = $obs[6];
4611 0           my $z_rotation = $obs[7];
4612 0           my $y_rotation = $obs[8];
4613 0           my $tilt = $obs[9];
4614 0           my $opacity = $obs[10];
4615 0           my $name = $obs[11];
4616 0           my $material = $obs[12];
4617 0           my $obs_letter = $obs[13];
4618              
4619 0           my $printthis =
4620             "prj -file $to/cfg/$fileconfig -mode script<
4621              
4622             m
4623             c
4624             a
4625             $zone_letter
4626             h
4627             a
4628             $obs_letter
4629             a
4630             a
4631             $x $y $z
4632             b
4633             $width $depth $height
4634             c
4635             $z_rotation
4636             d
4637             $y_rotation
4638             e # HERE THE DATUM IS STILL UNUSED. WHEN IT WILL, A LINE MUST BE ADDED WITH THE VARIABLE $tilt.
4639             h
4640             $opacity
4641             -
4642             -
4643             c
4644             -
4645             c
4646             -
4647             -
4648             -
4649             -
4650             YYY
4651             ";
4652 0 0         if ($exeonfiles eq "y")
4653             {
4654 0           print `$printthis`;
4655             }
4656              
4657 0           print TOSHELL $printthis;
4658             }
4659 0           $countervertex++;
4660             } # END SUB apply_pin_obstructions
4661             ############################################################## END OF GROUP GET AND PIN OBSTRUCTIONS
4662              
4663              
4664             ##############################################################################
4665             ##############################################################################
4666             # END OF SECTION DEDICATED TO FUNCTIONS FOR CONSTRAINING OBSTRUCTIONS
4667              
4668              
4669              
4670             ##############################################################################
4671             ##############################################################################
4672             # BEGINNING OF SECTION DEDICATED TO FUNCTIONS FOR CONSTRAINING THE MASS-FLOW NETWORKS
4673              
4674             sub vary_net
4675             { # IT IS CALLED FROM THE MAIN FILE
4676 0     0 0   my $to = shift;
4677 0           my $fileconfig = shift;
4678 0           my $stepsvar = shift;
4679 0           my $counterzone = shift;
4680 0           my $counterstep = shift;
4681 0           my $exeonfiles = shift;
4682 0           my $swap = shift;
4683 0           my @applytype = @$swap;
4684 0           my $zone_letter = $applytype[$counterzone][3];
4685 0           my $swap = shift;
4686 0           my @vary_net = @$swap;
4687              
4688 0           my $activezone = $applytype[$counterzone][3];
4689 0           my ($semaphore_node, $semaphore_component, $node_letter);
4690 0           my $counter_component = -1;
4691 0           my $counterline = 0;
4692 0           my @node_letters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "l", "m", "n", "o", "p", "q", "r", "s"); # CHECK IF THE LAST LETTERS ARE CORRECT, ZZZ
4693 0           my @component_letters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "l", "m", "n", "o", "p", "q", "r", "s"); # CHECK IF THE LAST LETTERS ARE CORRECT, ZZZ
4694             # NOTE: THE FOLLOWING VARIABLE NAMES ARE SHADOWED IN THE FOREACH LOOP BELOW,
4695             # BUT ARE THE ONES USED IN THE OPTS CONSTRAINTS FILES.
4696              
4697 0           my @group = @{$vary_net[$counterzone]};
  0            
4698 0           my $sourcefile = $group[0];
4699 0           my $targetfile = $group[1];
4700 0           my $configfile = $group[2];
4701 0           my @nodebulk = @{$group[3]};
  0            
4702 0           my @componentbulk = @{$group[4]};
  0            
4703 0           my $countnode = 0;
4704 0           my $countcomponent = 0;
4705              
4706 0           my $sourceaddress = "$to$sourcefile";
4707 0           my $targetaddress = "$to$targetfile";
4708 0           my $configaddress = "$to$configfile";
4709              
4710             #@node; @component; # PLURAL. DON'T PUT "my" HERE!
4711             #@new_nodes; @new_components; # DON'T PUT "my" HERE.
4712              
4713 0           my @flow_letters;
4714              
4715 0           checkfile($sourceaddress, $targetaddress);
4716              
4717 0 0         if ($counterstep == 1)
4718             {
4719 0           read_net($sourceaddress, $targetaddress, \@node_letters, \@component_letters);
4720             }
4721              
4722             sub calc_newnet
4723             { # TO BE CALLED WITH: calc_newnet($to, $fileconfig, $stepsvar, $counterzone, $counterstep, \@nodebulk, \@componentbulk, \@node_, \@component);
4724             # THIS COMPUTES CHANGES TO BE MADE TO CONTROLS BEFORE PROPAGATION OF CONSTRAINTS
4725 0     0 0   my $to = shift;
4726 0           my $fileconfig = shift;
4727 0           my $stepsvar = shift;
4728 0           my $counterzone = shift;
4729 0           my $counterstep = shift;
4730 0           my $swap = shift;
4731 0           my @nodebulk = @$swap;
4732 0           my $swap = shift;
4733 0           my @componentbulk = @$swap;
4734 0           my $swap = shift;
4735 0           my @node = @$swap; # PLURAL
4736 0           my $swap = shift;
4737 0           my @component = @$swap; # PLURAL
4738 0           my $toshell = shift;
4739 0           my $outfile = shift;
4740 0           my $configfile = shift;
4741              
4742 0           my @new_volumes_or_surfaces;
4743             my @node_heights_or_cps;
4744 0           my @new_azimuths;
4745 0           my @boundary_heights;
4746              
4747             # HERE THE MODIFICATIONS TO BE EXECUTED ON EACH PARAMETERS ARE CALCULATED.
4748 0 0         if ($stepsvar == 0) {$stepsvar = 1;}
  0            
4749 0 0         if ($stepsvar > 1)
4750             {
4751 0           foreach $each_nodebulk (@nodebulk)
4752             {
4753 0           my @asknode = @{$each_nodebulk};
  0            
4754 0           my $new_node_letter = $asknode[0];
4755 0           my $new_fluid = $asknode[1];
4756 0           my $new_type = $asknode[2];
4757 0           my $new_zone = $activezone;
4758 0           my $swing_height = $asknode[3];
4759 0           my $swing_data_2 = $asknode[4];
4760 0           my $new_surface = $asknode[5];
4761 0           my @askcp = @{$asknode[6]};
  0            
4762 0           my ($height__, $data_2__, $data_1__, $new_cp);
4763 0           my $countnode = 0; #IT IS FOR THE FOLLOWING FOREACH. LEAVE IT ATTACHED TO IT.
4764 0           foreach $each_node (@node)
4765             {
4766 0           @node_ = @{$each_node};
  0            
4767 0           my $node_letter = $node_[0];
4768 0 0         if ( $new_node_letter eq $node_letter )
4769             {
4770 0           $height__ = $node_[3];
4771 0           $data_2__ = $node_[4];
4772 0           $data_1__ = $node_[5];
4773 0           $new_cp = $askcp[$counterstep-1];
4774             }
4775 0           $countnode++;
4776             }
4777 0           my $height = ( $swing_height / ($stepsvar - 1) );
4778 0           my $floorvalue_height = ($height__ - ($swing_height / 2) );
4779 0           my $new_height = $floorvalue_height + ($counterstep * $pace_height);
4780 0           $new_height = sprintf("%.3f", $height);
4781 0 0         if ($swing_height == 0) { $new_height = ""; }
  0            
4782              
4783 0           my $pace_data_2 = ( $swing_data_2 / ($stepsvar - 1) );
4784 0           my $floorvalue_data_2 = ($data_2__ - ($swing_data_2 / 2) );
4785 0           my $new_data_2 = $floorvalue_data_2 + ($counterstep * $pace_data_2);
4786 0           $new_data_2 = sprintf("%.3f", $new_data_2);
4787 0 0         if ($swing_data_2 == 0) { $new_data_2 = ""; }
  0            
4788              
4789 0           my $pace_data_1 = ( $swing_data_1 / ($stepsvar - 1) ); # UNUSED
4790 0           my $floorvalue_data_1 = ($data_1__ - ($swing_data_1 / 2) );
4791 0           my $new_data_1 = $floorvalue_data_1 + ($counterstep * $pace_data_1);
4792 0           $new_data_1 = sprintf("%.3f", $new_data_1);
4793 0 0         if ($swing_data_1 == 0) { $new_data_1 = ""; }
  0            
4794              
4795 0           push(@new_nodes,
4796             [ $new_node_letter, $new_fluid, $new_type, $new_zone, $new_height, $new_data_2, $new_surface, $new_cp ] );
4797             }
4798              
4799 0           foreach $each_componentbulk (@componentbulk)
4800             {
4801 0           my @askcomponent = @{$each_componentbulk};
  0            
4802 0           my $new_component_letter = $askcomponent[0];
4803              
4804 0           my $new_type = $askcomponent[1];
4805 0           my $swing_data_1 = $askcomponent[2];
4806 0           my $swing_data_2 = $askcomponent[3];
4807 0           my $swing_data_3 = $askcomponent[4];
4808 0           my $swing_data_4 = $askcomponent[5];
4809 0           my $component_letter;
4810 0           my $countcomponent = 0; #IT IS FOR THE FOLLOWING FOREACH.
4811 0           my ($new_type, $data_1__, $data_2__, $data_3__, $data_4__ );
4812 0           foreach $each_component (@component) # PLURAL
4813             {
4814 0           @component_ = @{$each_component};
  0            
4815 0           $component_letter = $component_letters[$countcomponent];
4816 0 0         if ( $new_component_letter eq $component_letter )
4817             {
4818 0           $new_component_letter = $component_[0];
4819 0           $new_fluid = $component_[1];
4820 0           $new_type = $component_[2];
4821 0           $data_1__ = $component_[3];
4822 0           $data_2__ = $component_[4];
4823 0           $data_3__ = $component_[5];
4824 0           $data_4__ = $component_[6];
4825             }
4826 0           $countcomponent++;
4827             }
4828              
4829 0           my $pace_data_1 = ( $swing_data_1 / ($stepsvar - 1) );
4830 0           my $floorvalue_data_1 = ($data_1__ - ($swing_data_1 / 2) );
4831 0           my $new_data_1 = $floorvalue_data_1 + ($counterstep * $pace_data_1);
4832 0 0         if ($swing_data_1 == 0) { $new_data_1 = ""; }
  0            
4833              
4834 0           my $pace_data_2 = ( $swing_data_2 / ($stepsvar - 1) );
4835 0           my $floorvalue_data_2 = ($data_2__ - ($swing_data_2 / 2) );
4836 0           my $new_data_2 = $floorvalue_data_2 + ($counterstep * $pace_data_2);
4837 0 0         if ($swing_data_2 == 0) { $new_data_2 = ""; }
  0            
4838              
4839 0           my $pace_data_3 = ( $swing_data_3 / ($stepsvar - 1) );
4840 0           my $floorvalue_data_3 = ($data_3__ - ($swing_data_3 / 2) );
4841 0           my $new_data_3 = $floorvalue_data_3 + ($counterstep * $pace_data_3 );
4842 0 0         if ($swing_data_3 == 0) { $new_data_3 = ""; }
  0            
4843              
4844 0           my $pace_data_4 = ( $swing_data_4 / ($stepsvar - 1) );
4845 0           my $floorvalue_data_4 = ($data_4__ - ($swing_data_4 / 2) );
4846 0           my $new_data_4 = $floorvalue_data_4 + ($counterstep * $pace_data_4 );
4847 0 0         if ($swing_data_4 == 0) { $new_data_4 = ""; }
  0            
4848              
4849 0           $new_data_1 = sprintf("%.3f", $new_data_1);
4850 0           $new_data_2 = sprintf("%.3f", $new_data_2);
4851 0           $new_data_3 = sprintf("%.3f", $new_data_3);
4852 0           $new_data_4 = sprintf("%.3f", $new_data_4);
4853 0           $new_data_4 = sprintf("%.3f", $new_data_4);
4854              
4855 0           push(@new_components, [ $new_component_letter, $new_fluid, $new_type, $new_data_1, $new_data_2, $new_data_3, $new_data_4 ] );
4856             }
4857             }
4858             } # END SUB calc_newnet
4859              
4860 0           calc_newnet($to, $fileconfig, $stepsvar, $counterzone, $counterstep, \@nodebulk, \@componentbulk, \@node, \@component); # PLURAL
4861              
4862 0           apply_node_changes($exeonfiles, \@new_nodes);
4863 0           apply_component_changes($exeonfiles, \@new_components);
4864              
4865             } # END SUB vary_net.
4866              
4867              
4868             sub read_net
4869             {
4870 0     0 0   my $sourceaddress = shift;
4871 0           my $targetaddress = shift;
4872             # checkfile($sourceaddress, $targetaddress); # THIS HAS TO BE _FIXED!_
4873 0           my $swap = shift;
4874 0           my @node_letters = @$swap;
4875 0           my $swap = shift;
4876 0           my @component_letters = @$swap;
4877              
4878 0 0         open( SOURCEFILE, $sourceaddress ) or die "Can't open $sourcefile : $!\n";
4879 0           my @lines = ;
4880 0           close SOURCEFILE;
4881 0           my $counterlines = 0;
4882 0           my $countnode = -1;
4883 0           my $countcomponent = -1;
4884 0           my $countcomp = 0;
4885 0           my $semaphore_node = "no";
4886 0           my $semaphore_component = "no";
4887 0           my $semaphore_connection = "no";
4888 0           my ($component_letter, $type, $data_1, $data_2, $data_3, $data_4);
4889 0           foreach my $line (@lines)
4890             {
4891 0 0         if ( $line =~ m/Fld. Type/ )
4892             {
4893 0           $semaphore_node = "yes";
4894             }
4895 0 0         if ( $semaphore_node eq "yes" )
4896             {
4897 0           $countnode++;
4898             }
4899 0 0         if ( $line =~ m/Type C\+ L\+/ )
4900             {
4901 0           $semaphore_component = "yes";
4902 0           $semaphore_node = "no";
4903             }
4904              
4905              
4906              
4907 0 0 0       if ( ($semaphore_node eq "yes") and ( $semaphore_component eq "no" ) and ( $countnode >= 0))
      0        
4908             {
4909 0           $line =~ s/^\s+//;
4910 0           my @row = split(/\s+/, $line);
4911 0           my $node_letter = $node_letters[$countnode];
4912 0           my $fluid = $row[1];
4913 0           my $type = $row[2];
4914 0           my $height = $row[3];
4915 0           my $data_2 = $row[6]; # volume or azimuth
4916 0           my $data_1 = $row[5]; #surface
4917 0           push(@node, [ $node_letter, $fluid, $type, $height, $data_2, $data_1 ] ); # PLURAL
4918             }
4919              
4920 0 0         if ( $semaphore_component eq "yes" )
4921             {
4922 0           $countcomponent++;
4923             }
4924              
4925 0 0         if ( $line =~ m/\+Node/ )
4926             {
4927 0           $semaphore_connection = "yes";
4928 0           $semaphore_component = "no";
4929 0           $semaphore_node = "no";
4930             }
4931              
4932 0 0 0       if ( ($semaphore_component eq "yes") and ( $semaphore_connection eq "no" ) and ( $countcomponent > 0))
      0        
4933             {
4934 0           $line =~ s/^\s+//;
4935 0           my @row = split(/\s+/, $line);
4936 0 0         if ($countcomponent % 2 == 1) # $number is odd
4937             {
4938 0           $component_letter = $component_letters[$countcomp];
4939 0           $fluid = $row[0];
4940 0           $type = $row[1];
4941 0 0         if ($type eq "110") { $type = "k";}
  0            
4942 0 0         if ($type eq "120") { $type = "l";}
  0            
4943 0 0         if ($type eq "130") { $type = "m";}
  0            
4944 0           $countcomp++;
4945             }
4946             else # $number is even
4947             {
4948 0           $data_1 = $row[1];
4949 0           $data_2 = $row[2];
4950 0           $data_3 = $row[3];
4951 0           $data_4 = $row[4];
4952 0           push( @component, [ $component_letter, $fluid, $type, $data_1, $data_2, $data_3, $data_4 ] ); # PLURAL
4953             }
4954              
4955             }
4956              
4957 0           $counterlines++;
4958             }
4959             } # END SUB read_controls.
4960              
4961              
4962             sub apply_node_changes
4963             { # TO BE CALLED WITH: apply_node_changes($exeonfiles, \@new_nodes);
4964             # THIS APPLIES CHANGES TO NODES IN NETS
4965 0     0 0   my $exeonfiles = shift;
4966 0           my $swap = shift;
4967 0           my @new_nodes = @$swap;
4968 0           my $swap = shift;
4969 0           my @tempnodes = @$swap;
4970              
4971              
4972 0           my $counternode = 0;
4973 0           foreach my $elm (@new_nodes)
4974             {
4975 0           my @node_ = @{$elm};
  0            
4976 0           my $new_node_letter = $node_[0];
4977 0           my $new_fluid = $node_[1];
4978 0           my $new_type = $node_[2];
4979 0           my $new_zone = $node_[3];
4980 0           my $new_height = $node_[4];
4981 0           my $new_data_2 = $node_[5];
4982 0           my $new_surface = $node_[6];
4983 0           my $new_cp = $node_[7];
4984              
4985 0 0         unless ( @{$new_nodes[$counternode]} ~~ @{$tempnodes[$counternode]} )
  0            
  0            
4986             {
4987 0 0         if ($new_type eq "a" ) # IF NODES ARE INTERNAL
4988             {
4989 0           my $printthis =
4990             "prj -file $to/cfg/$fileconfig -mode script<
4991              
4992             m
4993             e
4994             c
4995              
4996             n
4997             c
4998             $new_node_letter
4999              
5000             $new_fluid
5001             $new_type
5002             y
5003             $new_zone
5004             $new_data_2
5005             $new_height
5006             a
5007              
5008             -
5009             -
5010             y
5011              
5012             y
5013             -
5014             -
5015             YYY
5016             ";
5017 0 0         if ($exeonfiles eq "y")
5018             {
5019 0           print `$printthis`;
5020             }
5021 0           print TOSHELL $printthis;
5022             }
5023              
5024 0 0         if ($new_type eq "e" ) # IF NODES ARE BOUNDARY ONES, WIND-INDUCED
5025             {
5026 0           my $printthis =
5027             "prj -file $to/cfg/$fileconfig -mode script<
5028              
5029             m
5030             e
5031             c
5032              
5033             n
5034             c
5035             $new_node_letter
5036              
5037             $new_fluid
5038             $new_type
5039             $new_zone
5040             $new_surface
5041             $new_cp
5042             y
5043             $new_data_2
5044             $new_height
5045             -
5046             -
5047             y
5048              
5049             y
5050             -
5051             -
5052             YYY
5053             ";
5054 0 0         if ($exeonfiles eq "y")
5055             {
5056 0           print `$printthis`;
5057             }
5058 0           print TOSHELL $printthis;
5059             }
5060             }
5061 0           $counternode++;
5062             }
5063             } # END SUB apply_node_changes;
5064              
5065              
5066              
5067             sub apply_component_changes
5068             { # TO BE CALLED WITH: apply_component_changes($exeonfiles, \@new_components);
5069             # THIS APPLIES CHANGES TO COMPONENTS IN NETS
5070 0     0 0   my $exeonfiles = shift;
5071 0           my $swap = shift;
5072 0           my @new_components = @$swap; # [ $new_component_letter, $new_type, $new_data_1, $new_data_2, $new_data_3, $new_data_4 ]
5073 0           my $swap = shift;
5074 0           my @tempcomponents = @$swap;
5075              
5076 0           my $countercomponent = 0;
5077 0           foreach my $elm (@new_components)
5078             {
5079 0           my @component_ = @{$elm};
  0            
5080 0           my $new_component_letter = $component_[0];
5081 0           my $new_fluid = $component_[1];
5082 0           my $new_type = $component_[2];
5083 0           my $new_data_1 = $component_[3];
5084 0           my $new_data_2 = $component_[4];
5085 0           my $new_data_3 = $component_[5];
5086 0           my $new_data_4 = $component_[6];
5087              
5088 0 0         unless
5089 0           ( @{$new_components[$countercomponents]} ~~ @{$tempcomponents[$countercomponents]} )
  0            
5090             {
5091 0 0         if ($new_type eq "k" ) # IF THE COMPONENT IS A GENERIC OPENING
5092             {
5093 0           my $printthis =
5094             "prj -file $to/cfg/$fileconfig -mode script<
5095              
5096             m
5097             e
5098             c
5099              
5100             n
5101             d
5102             $new_component_letter
5103             $new_fluid
5104             $new_type
5105             -
5106             $new_data_1
5107             -
5108             -
5109             y
5110              
5111             y
5112             -
5113             -
5114             YYY
5115             ";
5116 0 0         if ($exeonfiles eq "y")
5117             {
5118 0           print `$printthis`;
5119             }
5120 0           print TOSHELL $printthis;
5121             }
5122              
5123 0 0         if ($new_type eq "l" ) # IF THE COMPONENT IS A CRACK
5124             {
5125 0           my $printthis =
5126             "prj -file $to/cfg/$fileconfig -mode script<
5127              
5128             m
5129             e
5130             c
5131              
5132             n
5133             d
5134             $new_component_letter
5135             $new_fluid
5136             $new_type
5137             -
5138             $new_data_1 $new_data_2
5139             -
5140             -
5141             y
5142              
5143             y
5144             -
5145             -
5146             YYY
5147             ";
5148 0 0         if ($exeonfiles eq "y")
5149             {
5150 0           print `$printthis`;
5151             }
5152 0           print TOSHELL $printthis;
5153             }
5154              
5155 0 0         if ($new_type eq "m" ) # IF THE COMPONENT IS A DOOR
5156             {
5157 0           my $printthis =
5158             "prj -file $to/cfg/$fileconfig -mode script<
5159              
5160             m
5161             e
5162             c
5163              
5164             n
5165             d
5166             $new_component_letter
5167             $new_fluid
5168             $new_type
5169             -
5170             $new_data_1 $new_data_2 $new_data_3 $new_data_4
5171             -
5172             -
5173             y
5174              
5175             y
5176             -
5177             -
5178             YYY
5179             ";
5180 0 0         if ($exeonfiles eq "y")
5181             {
5182 0           print `$printthis`;
5183             }
5184 0           print TOSHELL $printthis;
5185             }
5186             }
5187 0           $countercomponent++;
5188             }
5189             } # END SUB apply_component_changes;
5190              
5191              
5192             sub constrain_net
5193             { # IT ALLOWS TO MANIPULATE USER-IMPOSED CONSTRAINTS REGARDING NETS
5194 0     0 0   my $to = shift;
5195 0           my $fileconfig = shift;
5196 0           my $stepsvar = shift;
5197 0           my $counterzone = shift;
5198 0           my $counterstep = shift;
5199 0           my $exeonfiles = shift;
5200 0           my $swap = shift;
5201 0           my @applytype = @$swap;
5202 0           my $zone_letter = $applytype[$counterzone][3];
5203 0           my $swap = shift;
5204 0           my @constrain_net = @$swap;
5205 0           my $to_do = shift;
5206              
5207              
5208 0           my $elm = $constrain_net[$counterzone];
5209 0           my @group = @{$elm};
  0            
5210 0           my $sourcefile = $group[2];
5211 0           my $targetfile = $group[3];
5212 0           my $configfile = $group[4];
5213 0           my $sourceaddress = "$to$sourcefile";
5214 0           my $targetaddress = "$to$targetfile";
5215 0           my $configaddress = "$to$configfile";
5216              
5217 0           my $node = 0;
5218 0           my $fluid = 1;
5219 0           my $type = 2;
5220 0           my $height = 3;
5221 0           my $volume = 4;
5222 0           my $volume = 4;
5223 0           my $azimuth = 4;
5224 0           my $component = 0;
5225 0           my $area = 3;
5226 0           my $width = 4;
5227 0           my $length = 5;
5228 0           my $door_width = 4;
5229 0           my $door_height = 5;
5230 0           my $door_nodeheight = 6;
5231 0           my $door_discharge = 7;
5232              
5233 0           my $activezone = $applytype[$counterzone][3];
5234 0           my ($semaphore_node, $semaphore_component, $node_letter);
5235 0           my $counter_component = -1;
5236 0           my $counterline = 0;
5237 0           my @node_letters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "l", "m", "n", "o", "p", "q", "r", "s"); # CHECK IF THE LAST LETTERS ARE CORRECT, ZZZ
5238 0           my @component_letters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "l", "m", "n", "o", "p", "q", "r", "s"); # CHECK IF THE LAST LETTERS ARE CORRECT, ZZZ
5239 0           my $countnode = 0;
5240 0           my $countcomponent = 0;
5241              
5242             #@node; @component; # PLURAL! DON'T PUT "MY" HERE. GLOBAL.
5243             #@new_nodes; @new_components; # DON'T PUT "my" HERE. THEY ARE GLOBAL!!!
5244              
5245 0 0         unless ($to_do eq "justwrite")
5246             {
5247 0           checkfile($sourceaddress, $targetaddress);
5248 0 0         if ($counterstep == 1)
5249             {
5250 0           read_net($sourceaddress, $targetaddress, \@node_letters, \@component_letters);
5251 0           read_net_constraints
5252             ($to, $fileconfig, $stepsvar, $counterzone, $counterstep, $configaddress, \@node, \@component, \@tempnode, \@tempcomponent); # PLURAL
5253             }
5254             }
5255              
5256 0 0         unless ($to_do eq "justread")
5257             {
5258 0           apply_node_changes($exeonfiles, \@donode, \@tempnode); #PLURAL
5259 0           apply_component_changes($exeonfiles, \@docomponent, \@tempcomponent);
5260             }
5261             } # END SUB constrain_net.
5262              
5263             sub read_net_constraints
5264             {
5265 0     0 0   my $to = shift;
5266 0           my $fileconfig = shift;
5267 0           my $stepsvar = shift;
5268 0           my $counterzone = shift;
5269 0           my $counterstep = shift;
5270 0           my $configaddress = shift;
5271 0           my $swap = shift;
5272 0           @node = @$swap; # PLURAL
5273 0           my $swap = shift;
5274 0           @component = @$swap;
5275 0           my $swap = shift;
5276 0           @tempnode = @$swap;
5277 0           my $swap = shift;
5278 0           @tempcomponent = @$swap;
5279              
5280              
5281 0           unshift (@node, []); # PLURAL
5282 0           unshift (@component, []);
5283 0 0         if (-e $configaddress) # TEST THIS
5284             { # THIS APPLIES CONSTRAINST, THE FLATTEN THE HIERARCHICAL STRUCTURE OF THE RESULTS,
5285             # TO BE PREPARED THEN FOR BEING APPLIED TO CHANGE PROCEDURES. IT IS TO BE TESTED.
5286              
5287 0           push (@node, [@mynode]); #
5288 0           push (@component, [@mycomponent]); #
5289              
5290 0           eval `cat $configaddress`; # HERE AN EXTERNAL FILE FOR PROPAGATION OF CONSTRAINTS
5291             # IS EVALUATED, AND HERE BELOW CONSTRAINTS ARE PROPAGATED.
5292             # THIS FILE CAN CONTAIN USER-IMPOSED CONSTRAINTS FOR MASS-FLOW NETWORKS TO BE READ BY OPTS.
5293             # IT MAKES AVAILABLE VARIABLES REGARDING THE SETTING OF NODES IN A NETWORK.
5294             # CURRENTLY: INTERNAL UNKNOWN AIR NODES AND BOUNDARY WIND-CONCERNED NODES.
5295             # IT MAKES AVAILABLE VARIABLES REGARDING COMPONENTS
5296             # CURRENTLY: WINDOWS, CRACKS, DOORS.
5297             # ALSO, THIS MAKES AVAILABLE TO THE USER INFORMATIONS ABOUT THE MORPHING STEP OF THE MODELS.
5298             # SPECIFICALLY, THE FOLLOWING VARIABLES WHICH REGARD BOTH INTERNAL AND BOUNDARY NODES.
5299             # NOTE THAT "node_number" IS THE NUMBER OF THE NODE IN THE ".afn" ESP-r FILE.
5300             # $node[$counterzone][node_number][$node]. # EXAMPLE: $node[0][3][$node]. THIS IS THE LETTER OF THE THIRD NODE,
5301             # AT THE FIRST CONTERZONE (NUMBERING STARTS FROM 0)
5302             # $node[$counterzone][node_number][$type]
5303             # $node[$counterzone][node_number][$height]. # EXAMPLE: $node[0][3][$node]. THIS IS THE HEIGHT OF THE 3RD NODE AT THE FIRST COUNTERZONE
5304             # THEN IT MAKES AVAILABLE THE FOLLOWING VARIABLES REGARDING NODES:
5305             # $node[$counterzone][node_number][$volume] # REGARDING INTERNAL NODES
5306             # $node[$counterzone][node_number][$azimut] # REGARDING BOUNDARY NODES
5307             # THEN IT MAKE AVAILABLE THE FOLLOWING VARIABLES REGARDING COMPONENTS:
5308             # $node[$counterzone][node_number][$area] # REGARDING SIMPLE OPENINGS
5309             # $node[$counterzone][node_number][$width] # REGARDING CRACKS
5310             # $node[$counterzone][node_number][$length] # REGARDING CRACKS
5311             # $node[$counterzone][node_number][$door_width] # REGARDING DOORS
5312             # $node[$counterzone][node_number][$door_height] # REGARDING DOORS
5313             # $node[$counterzone][node_number][$door_nodeheight] # REGARDING DOORS
5314             # $node[$counterzone][node_number][$door_discharge] # REGARDING DOORS (DISCHARGE FACTOR)
5315             # ALSO, THIS MAKES AVAILABLE TO THE USER INFORMATIONS ABOUT THE MORPHING STEP OF THE MODELS
5316             # AND THE STEPS THE MODEL HAVE TO FOLLOW.
5317             # THIS ALLOWS TO IMPOSE EQUALITY CONSTRAINTS TO THESE VARIABLES,
5318             # WHICH COULD ALSO BE COMBINED WITH THE FOLLOWING ONES:
5319             # $stepsvar, WHICH TELLS THE PROGRAM HOW MANY ITERATION STEPS IT HAS TO DO IN THE CURRENT MORPHING PHASE.
5320             # $counterzone, WHICH TELLS THE PROGRAM WHAT OPERATION IS BEING EXECUTED IN THE CHAIN OF OPERATIONS
5321             # THAT MAY BE EXECUTES AT EACH MORPHING PHASE. EACH $counterzone WILL CONTAIN ONE OR MORE ITERATION STEPS.
5322             # TYPICALLY, IT WILL BE USED FOR A ZONE, BUT NOTHING PREVENTS THAT SEVERAL OF THEM CHAINED ONE AFTER
5323             # THE OTHER ARE APPLIED TO THE SAME ZONE.
5324             # $counterstep, WHICH TELLS THE PROGRAM WHAT THE CURRENT ITERATION STEP IS.
5325             # The $counterzone that is actuated is always the last, the one which is active.
5326             # It would have therefore no sense writing $node[0][3][$node] = $node[1][3][$node].
5327             # Differentent $counterzones can be referred to the same zone. Different $counterzones just number mutations in series.
5328              
5329 0 0         if (-e $constrain) { eval "$constrain"; } # HERE THE INSTRUCTION WRITTEN IN THE OPTS CONFIGURATION FILE CAN BE SPEFICIED
  0            
5330             # FOR PROPAGATION OF CONSTRAINTS
5331              
5332 0           @donode = @{$node[$#node]}; #
  0            
5333 0           @docomponent = @{$component[$#component]}; #
  0            
5334              
5335 0           shift (@donode);
5336 0           shift (@docomponent);
5337             }
5338             } # END SUB read_net_constraints
5339              
5340             ##############################################################################
5341             ##############################################################################
5342             # END OF SECTION DEDICATED TO FUNCTIONS FOR CONSTRAINING MASS-FLOW NETWORKS
5343              
5344              
5345              
5346             ##############################################################################
5347             ##############################################################################
5348             # BEGINNING OF SECTION DEDICATED TO GENERIC FUNCTIONS FOR PROPAGATING CONSTRAINTS
5349              
5350             sub propagate_constraints
5351             {
5352             # THIS FUNCTION ALLOWS TO MANIPULATE COMPOUND USER-IMPOSED CONSTRAINTS.
5353             # IT COMPOUNDS ALL FOUR PRINCIPAL PROPAGATION TYPES. THAT MEANS THAT ONE COULD DO
5354             # ANY TYPE OF THE AVAILABLE PROPAGATIONS JUST USING THIS FUNCTION.
5355             # IT MAKES AVAILABLE TO THE USER THE FOLLOWING VARIABLES FOR MANIPULATION.
5356              
5357             # REGARDING GEOMETRY:
5358             # $v[$counterzone][$number][$x], $v[$counterzone][$number][$y], $v[$counterzone][$number][$z]. EXAMPLE: $v[0][4][$x] = 1.
5359             # OR: @v[0][4][$x] = @v[0][4][$y]. OR EVEN: @v[1][4][$x] = @v[0][3][$z].
5360              
5361             # REGARDING OBSTRUCTIONS:
5362             # $obs[$counterzone][$obs_number][$x], $obs[$counterzone][$obs_number][$y], $obs[$counterzone][$obs_number][$y]
5363             # $obs[$counterzone][$obs_number][$width], $obs[$counterzone][$obs_number][$depth], $obs[$counterzone][$obs_number][$height]
5364             # $obs[$counterzone][$obs_number][$z_rotation], $obs[$counterzone][$obs_number][$y_rotation],
5365             # $obs[$counterzone][$obs_number][$tilt], $obs[$counterzone][$obs_number][$opacity], $obs[$counterzone][$obs_number][$material],
5366             # EXAMPLE: $obs[0][2][$x] = 2. THIS MEANS: AT COUNTERZONE 0, COORDINATE x OF OBSTRUCTION HAS TO BE SET TO 2.
5367             # OTHER EXAMPLE: $obs[0][2][$x] = $obs[2][2][$y].
5368             # NOTE THAT THE MATERIAL TO BE SPECIFIED IS A MATERIAL LETTER, BETWEEN QUOTES! EXAMPLE: $obs[1][$material] = "a".
5369             # $tilt IS PRESENTLY UNUSED.
5370              
5371             # REGARDING MASS-FLOW NETWORKS:
5372             # @node and @component.
5373             # CURRENTLY: INTERNAL UNKNOWN AIR NODES AND BOUNDARY WIND-CONCERNED NODES.
5374             # IT MAKES AVAILABLE VARIABLES REGARDING COMPONENTS
5375             # CURRENTLY: WINDOWS, CRACKS, DOORS.
5376             # ALSO, THIS MAKES AVAILABLE TO THE USER INFORMATIONS ABOUT THE MORPHING STEP OF THE MODELS.
5377             # SPECIFICALLY, THE FOLLOWING VARIABLES WHICH REGARD BOTH INTERNAL AND BOUNDARY NODES.
5378             # NOTE THAT "node_number" IS THE NUMBER OF THE NODE IN THE ".afn" ESP-r FILE.
5379             # 1) $loopcontrol[$counterzone][$countloop][$countloopcontrol][$loop_hour]
5380             # Where $countloop and $countloopcontrol has to be set to a specified number in the OPTS file for constraints.
5381             # 2) $loopcontrol[$counterzone][$countloop][$countloopcontrol][$max_heating_power] # Same as above.
5382             # 3) $loopcontrol[$counterzone][$countloop][$countloopcontrol][$min_heating_power] # Same as above.
5383             # 4) $loopcontrol[$counterzone][$countloop][$countloopcontrol][$max_cooling_power] # Same as above.
5384             # 5) $loopcontrol[$counterzone][$countloop][$countloopcontrol][$min_cooling_power] # Same as above.
5385             # 6) $loopcontrol[$counterzone][$countloop][$countloopcontrol][heating_setpoint] # Same as above.
5386             # 7) $loopcontrol[$counterzone][$countloop][$countloopcontrol][cooling_setpoint] # Same as above.
5387             # 8) $flowcontrol[$counterzone][$countflow][$countflowcontrol][$flow_hour]
5388             # Where $countflow and $countflowcontrol has to be set to a specified number in the OPTS file for constraints.
5389             # 9) $flowcontrol[$counterzone][$countflow][$countflowcontrol][$flow_setpoint] # Same as above.
5390             # 10) $flowcontrol[$counterzone][$countflow][$countflowcontrol][$flow_onoff] # Same as above.
5391             # 11) $flowcontrol[$counterzone][$countflow][$countflowcontrol][$flow_fraction] # Same as above.
5392             # EXAMPLE : $flowcontrol[0][1][2][$flow_fraction] = 0.7
5393             # OTHER EXAMPLE: $flowcontrol[2][1][2][$flow_fraction] = $flowcontrol[0][2][1][$flow_fraction]
5394              
5395             # REGARDING CONTROLS:
5396             # IT MAKES AVAILABLE VARIABLES REGARDING COMPONENTS
5397             # CURRENTLY: WINDOWS, CRACKS, DOORS.
5398             # ALSO, THIS MAKES AVAILABLE TO THE USER INFORMATIONS ABOUT THE MORPHING STEP OF THE MODELS.
5399             # SPECIFICALLY, THE FOLLOWING VARIABLES WHICH REGARD BOTH INTERNAL AND BOUNDARY NODES.
5400             # NOTE THAT "node_number" IS THE NUMBER OF THE NODE IN THE ".afn" ESP-r FILE.
5401             # $node[$counterzone][node_number][$node]. # EXAMPLE: $node[0][3][$node]. THIS IS THE LETTER OF THE THIRD NODE,
5402             # AT THE FIRST CONTERZONE (NUMBERING STARTS FROM 0)
5403             # $node[$counterzone][node_number][$type]
5404             # $node[$counterzone][node_number][$height]. # EXAMPLE: $node[0][3][$node]. THIS IS THE HEIGHT OF THE 3RD NODE AT THE FIRST COUNTERZONE
5405             # THEN IT MAKES AVAILABLE THE FOLLOWING VARIABLES REGARDING NODES:
5406             # $node[$counterzone][node_number][$volume] # REGARDING INTERNAL NODES
5407             # $node[$counterzone][node_number][$azimut] # REGARDING BOUNDARY NODES
5408             # THEN IT MAKE AVAILABLE THE FOLLOWING VARIABLES REGARDING COMPONENTS:
5409             # $node[$counterzone][node_number][$area] # REGARDING SIMPLE OPENINGS
5410             # $node[$counterzone][node_number][$width] # REGARDING CRACKS
5411             # $node[$counterzone][node_number][$length] # REGARDING CRACKS
5412             # $node[$counterzone][node_number][$door_width] # REGARDING DOORS
5413             # $node[$counterzone][node_number][$door_height] # REGARDING DOORS
5414             # $node[$counterzone][node_number][$door_nodeheight] # REGARDING DOORS
5415             # $node[$counterzone][node_number][$door_discharge] # REGARDING DOORS (DISCHARGE FACTOR)
5416              
5417             # ALSO, THIS KIND OF FILE MAKES INFORMATION AVAILABLE ABOUT
5418             # THE MORPHING STEP OF THE MODELS AND THE STEPS THE MODEL HAVE TO FOLLOW.
5419             # THIS ALLOWS TO IMPOSE EQUALITY CONSTRAINTS TO THESE VARIABLES,
5420             # WHICH COULD ALSO BE COMBINED WITH THE FOLLOWING ONES:
5421             # $stepsvar, WHICH TELLS THE PROGRAM HOW MANY ITERATION STEPS IT HAS TO DO IN THE CURRENT MORPHING PHASE.
5422             # $counterzone, WHICH TELLS THE PROGRAM WHAT OPERATION IS BEING EXECUTED IN THE CHAIN OF OPERATIONS
5423             # THAT MAY BE EXECUTES AT EACH MORPHING PHASE. EACH $counterzone WILL CONTAIN ONE OR MORE ITERATION STEPS.
5424             # TYPICALLY, IT WILL BE USED FOR A ZONE, BUT NOTHING PREVENTS THAT SEVERAL OF THEM CHAINED ONE AFTER
5425             # THE OTHER ARE APPLIED TO THE SAME ZONE.
5426             # $counterstep, WHICH TELLS THE PROGRAM WHAT THE CURRENT ITERATION STEP IS.
5427              
5428             # The $counterzone that is actuated is always the last, the one which is active.
5429             # It would have therefore no sense writing for example @v[0][4][$x] = @v[1][2][$y], because $counterzone 0 is before than $counterzone 1.
5430             # Also, it would not have sense setting $counterzone 1 if the current $counterzone is already 2.
5431             # Differentent $counterzones can be referred to the same zone. Different $counterzones just number mutations in series.
5432              
5433 0     0 0   my $to = shift;
5434 0           my $fileconfig = shift;
5435 0           my $stepsvar = shift;
5436 0           my $counterzone = shift;
5437 0           my $counterstep = shift;
5438 0           my $exeonfiles = shift;
5439 0           my $swap = shift;
5440 0           my ($justread, $justwrite);
5441 0           my @applytype = @$swap;
5442 0           my $zone_letter = $applytype[$counterzone][3];
5443 0           my $swap = shift;
5444 0           my @propagate_constraints = @$swap;
5445              
5446              
5447 0           my $zone = $applytype[$counterzone][3];
5448 0           my $counter = 0;
5449 0           my @group = @{$propagate_constraints[$counterzone]};
  0            
5450 0           foreach my $elm (@group)
5451             {
5452 0 0         if ($counter > 0)
5453             {
5454 0           my @items = @{$elm};
  0            
5455 0           my $what_to_do = $items[0];
5456 0           my $sourcefile = $items[1];
5457 0           my $targetfile = $items[2];
5458 0           my $configfile = $items[3];
5459 0 0         if ($what_to_do eq "read_geo")
5460             {
5461 0           $to_do = "justread";
5462 0           my @vertex_letters = @{$items[4]};
  0            
5463 0           my $long_menus = $items[5];
5464 0           my @constrain_geometry = ( [ "", $zone, $sourcefile, $targetfile, $configfile , \@vertex_letters, $long_menus ] );
5465 0           constrain_geometry($to, $fileconfig, $stepsvar, $counterzone,
5466             $counterstep, $exeonfiles, \@applytype, \@constrain_geometry, $to_do);
5467              
5468             }
5469 0 0         if ($what_to_do eq "read_obs")
5470             {
5471 0           $to_do = "justread";
5472 0           my @obs_letters = @{$items[4]};
  0            
5473 0           my $act_on_materials = $items[5];
5474 0           my @constrain_obstructions = ( [ "", $applytype[$counterzone][3], $sourcefile, $targetfile, $configfile , \@obs_letters, $act_on_materials ] );
5475 0           constrain_obstructions($to, $fileconfig, $stepsvar, $counterzone,
5476             $counterstep, $exeonfiles, \@applytype, \@constrain_obstructions, $to_do);
5477             }
5478 0 0         if ($what_to_do eq "read_ctl")
5479             {
5480 0           $to_do = "justread";
5481 0           my @constrain_controls = ( [ "", $zone, $sourcefile, $targetfile, $configfile ] );
5482 0           constrain_controls($to, $fileconfig, $stepsvar, $counterzone,
5483             $counterstep, $exeonfiles, \@applytype, \@constrain_controls, $to_do);
5484             }
5485 0 0         if ($what_to_do eq "read_net")
5486             {
5487 0           $to_do = "justread";
5488 0           my @surfaces = @{$items[4]};
  0            
5489 0           my @cps = @{$items[5]};
  0            
5490 0           my @constrain_net = ( [ "", $zone, $sourcefile, $targetfile, $configfile , \@surfaces, \@cps ] );
5491 0           constrain_net($to, $fileconfig, $stepsvar, $counterzone,
5492             $counterstep, $exeonfiles, \@applytype, \@constrain_net, $to_do);
5493             }
5494              
5495 0 0         if ($what_to_do eq "write_geo")
5496             {
5497 0           $to_do = "justwrite";
5498 0           my @vertex_letters = @{$items[4]};
  0            
5499 0           my $long_menus = $items[5];
5500 0           my @constrain_geometry = ( [ "", $zone, $sourcefile, $targetfile, $configfile , \@vertex_letters, $long_menus ] );
5501 0           constrain_geometry($to, $fileconfig, $stepsvar, $counterzone,
5502             $counterstep, $exeonfiles, \@applytype, \@constrain_geometry, $to_do);
5503             }
5504 0 0         if ($what_to_do eq "write_obs")
5505             {
5506 0           $to_do = "justwrite";
5507 0           my @obs_letters = @{$items[4]};
  0            
5508 0           my $act_on_materials = $items[5];
5509 0           my @constrain_obstructions = ( [ "", $zone, $sourcefile, $targetfile, $configfile , \@obs_letters, $act_on_materials] );
5510 0           constrain_obstructions($to, $fileconfig, $stepsvar, $counterzone,
5511             $counterstep, $exeonfiles, \@applytype, \@constrain_obstructions, $to_do);
5512             }
5513 0 0         if ($what_to_do eq "write_ctl")
5514             {
5515 0           $to_do = "justwrite";
5516 0           my @constrain_controls = ( [ "", $zone, $sourcefile, $targetfile, $configfile ] );
5517 0           constrain_controls($to, $fileconfig, $stepsvar, $counterzone,
5518             $counterstep, $exeonfiles, \@applytype, \@constrain_controls, $to_do);
5519             }
5520 0 0         if ($what_to_do eq "write_net")
5521             {
5522 0           $to_do = "justwrite";
5523 0           my @surfaces = @{$items[4]};
  0            
5524 0           my @cps = @{$items[5]};
  0            
5525 0           my @constrain_net = ( [ "", $zone, $sourcefile, $targetfile, $configfile , \@surfaces, \@cps ] );
5526 0           constrain_net($to, $fileconfig, $stepsvar, $counterzone,
5527             $counterstep, $exeonfiles, \@applytype, \@constrain_net, $to_do);
5528             }
5529             }
5530 0           $counter++;
5531             }
5532             }
5533              
5534             ##############################################################################
5535             ##############################################################################
5536             # END OF SECTION DEDICATED TO GENERIC FUNCTIONS FOR PROPAGATING CONSTRAINTS
5537              
5538              
5539              
5540             # END OF THE CONTENT OF THE "opts_morph.pl" FILE.
5541             #########################################################################################
5542             #########################################################################################
5543             #########################################################################################
5544            
5545 0           my $yes_or_no_rotate_obstructions = "$$rotate[$counterzone][1]" ;
5546             # WHY $BRING_CONSTRUCTION_BACK DOES NOT WORK IF THESE TWO VARIABLES ARE PRIVATE?
5547 0           my $yes_or_no_keep_some_obstructions = "$$keep_obstructions[$counterzone][0]";
5548 0           print `cd $to`;
5549 0           print TOSHELL "cd $to\n\n";
5550              
5551 0           my $countercycles_transl_surfs = 0;
5552            
5553 0           eval `cat /home/luca/Sim-OPTS/stuff1.pl`; # ZZZZ HERE stuff1.pl
5554 0 0         if ( $stepsvar > 1)
5555             {
5556             sub dothings
5557             { # THIS CONTAINS FUNCTIONS THAT APPLY CONSTRAINTS AND UPDATE CALCULATIONS.
5558             #if ( $get_obstructions[$counterzone][0] eq "y" )
5559             #{
5560             # get_obstructions # THIS IS TO MEMORIZE OBSTRUCTIONS.
5561             # # THEY WILL BE SAVED IN A TEMPORARY FILE.
5562             # ($to, $fileconfig, $stepsvar, $counterzone,
5563             # $counterstep, $exeonfiles, \@applytype, \@get_obstructions);
5564             #}
5565 0 0   0 0   if ($propagate_constraints[$counterzone][0] eq "y")
5566             {
5567 0           &propagate_constraints
5568             ($to, $fileconfig, $stepsvar, $counterzone,
5569             $counterstep, $exeonfiles, \@applytype, \@propagate_constraints);
5570             }
5571 0 0         if ($apply_constraints[$counterzone][0] eq "y")
5572             {
5573 0           &apply_constraints
5574             ($to, $fileconfig, $stepsvar, $counterzone,
5575             $counterstep, $exeonfiles, \@applytype, \@constrain_geometry);
5576             }
5577 0 0         if ($constrain_geometry[$counterzone][0] eq "y")
5578             {
5579 0           &constrain_geometry
5580             ($to, $fileconfig, $stepsvar, $counterzone,
5581             $counterstep, $exeonfiles, \@applytype, \@constrain_geometry);
5582             }
5583 0 0         if ($constrain_controls[$counterzone][0] eq "y")
5584             {
5585 0           &constrain_controls
5586             ($to, $fileconfig, $stepsvar, $counterzone,
5587             $counterstep, $exeonfiles, \@applytype, \@constrain_controls);
5588             }
5589 0 0         if ($$keep_obstructions[$counterzone][0] eq "y") # TO BE SUPERSEDED BY get_obstructions AND pin_obstructions
5590             {
5591 0           &bring_obstructions_back($to, $fileconfig, $stepsvar, $counterzone,
5592             $counterstep, $exeonfiles, \@applytype, $keep_obstructions);
5593             }
5594 0 0         if ($constrain_net[$counterzone][0] eq "y")
5595             {
5596 0           &constrain_net($to, $fileconfig, $stepsvar, $counterzone,
5597             $counterstep, $exeonfiles, \@applytype, \@constrain_net, $to_do);
5598             }
5599 0 0         if ($recalculatenet[0] eq "y")
5600             {
5601 0           &recalculatenet
5602             ($to, $fileconfig, $stepsvar, $counterzone,
5603             $counterstep, $exeonfiles, \@applytype, \@recalculatenet);
5604             }
5605 0 0         if ($constrain_obstructions[$counterzone][0] eq "y")
5606             {
5607 0           &constrain_obstructions
5608             ($to, $fileconfig, $stepsvar, $counterzone,
5609             $counterstep, $exeonfiles, \@applytype, \@constrain_obstructions, $to_do);
5610             }
5611             #if ( $pin_obstructions[$counterzone][0] eq "y" )
5612             #{
5613             # pin_obstructions ($to, $fileconfig, $stepsvar, $counterzone,
5614             # $counterstep, $exeonfiles, \@applytype, $zone_letter, \@pin_obstructions);
5615             #}
5616 0 0         if ($recalculateish eq "y")
5617             {
5618 0           &recalculateish
5619             ($to, $fileconfig, $stepsvar, $counterzone,
5620             $counterstep, $exeonfiles, \@applytype, \@recalculateish);
5621             }
5622 0 0         if ($daylightcalc[0] eq "y")
5623             {
5624 0           &daylightcalc
5625             ($to, $fileconfig, $stepsvar, $counterzone,
5626             $counterstep, $exeonfiles, \@applytype, $filedf, \@daylightcalc);
5627             }
5628             } # END SUB DOTHINGS
5629            
5630 0 0         if ( $modification_type eq "generic_change" )#
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
5631             {
5632 0           &make_generic_change
5633             ($to, $fileconfig, $stepsvar, $counterzone, $counterstep, $exeonfiles,
5634             \@applytype, $generic_change);
5635 0           &dothings;
5636             } #
5637             elsif ( $modification_type eq "surface_translation_simple" )
5638             {
5639 0           &translate_surfaces_simple
5640             ($to, $fileconfig, $stepsvar, $counterzone, $counterstep,
5641             $exeonfiles, \@applytype, $translate_surface_simple);
5642 0           &dothings;
5643             }
5644             elsif ( $modification_type eq "surface_translation" )
5645             {
5646 0           &translate_surfaces
5647             ($to, $fileconfig, $stepsvar, $counterzone, $counterstep,
5648             $exeonfiles, \@applytype, $translate_surface);
5649 0           &dothings;
5650             }
5651             elsif ( $modification_type eq "surface_rotation" ) #
5652             {
5653 0           &rotate_surface
5654             ($to, $fileconfig, $stepsvar, $counterzone, $counterstep,
5655             $exeonfiles, \@applytype, $rotate_surface);
5656 0           &dothings;
5657             }
5658             elsif ( $modification_type eq "vertexes_shift" )
5659             {
5660 0           &shift_vertexes
5661             ($to, $fileconfig, $stepsvar, $counterzone, $counterstep,
5662             $exeonfiles, \@applytype, $shift_vertexes);
5663 0           &dothings;
5664             }
5665             elsif ( $modification_type eq "vertex_translation" )
5666             {
5667 0           &translate_vertexes
5668             ($to, $fileconfig, $stepsvar, $counterzone, $counterstep,
5669             $exeonfiles, \@applytype, \@translate_vertexes);
5670 0           &dothings;
5671             }
5672             elsif ( $modification_type eq "construction_reassignment" )
5673             {
5674 0           &reassign_construction
5675             ($to, $fileconfig, $stepsvar, $counterzone, $counterstep,
5676             $exeonfiles, \@applytype, $construction_reassignment);
5677 0           &dothings;
5678             }
5679             elsif ( $modification_type eq "rotation" )
5680             {
5681 0           &rotate
5682             ($to, $fileconfig, $stepsvar, $counterzone, $counterstep,
5683             $exeonfiles, \@applytype, $rotate);
5684 0           &dothings;
5685             }
5686             elsif ( $modification_type eq "translation" )
5687             {
5688 0           &translate
5689             ($to, $fileconfig, $stepsvar, $counterzone, $counterstep,
5690             $exeonfiles, \@applytype, $translate, $toshell, $outfile, $configfile);
5691 0           &dothings;
5692             }
5693             elsif ( $modification_type eq "thickness_change" )
5694             {
5695 0           &change_thickness
5696             ($to, $fileconfig, $stepsvar, $counterzone, $counterstep,
5697             $exeonfiles, \@applytype, $thickness_change);
5698 0           &dothings;
5699             }
5700             elsif ( $modification_type eq "rotationz" )
5701             {
5702 0           &rotatez
5703             ($to, $fileconfig, $stepsvar, $counterzone, $counterstep,
5704             $exeonfiles, \@applytype, $rotatez);
5705 0           &dothings;
5706             }
5707             elsif ( $modification_type eq "change_config" )
5708             {
5709 0           &change_config
5710             ($to, $fileconfig, $stepsvar, $counterzone, $counterstep,
5711             $exeonfiles, \@applytype, \@change_config);
5712 0           &dothings;
5713             }
5714             elsif ( $modification_type eq "window_reshapement" )
5715             {
5716 0           &reshape_windows
5717             ($to, $fileconfig, $stepsvar, $counterzone, $counterstep,
5718             $exeonfiles, \@applytype, \@reshape_windows);
5719 0           &dothings;
5720             }
5721             elsif ( $modification_type eq "obs_modification" ) # REWRITE FOR NEW GEO FILE?
5722             {
5723 0           &obs_modify
5724             ($to, $fileconfig, $stepsvar, $counterzone, $counterstep,
5725             $exeonfiles, \@applytype, $obs_modify);
5726 0           &dothings;
5727             }
5728             elsif ( $modification_type eq "warping" )
5729             {
5730 0           &warp
5731             ($to, $fileconfig, $stepsvar, $counterzone, $counterstep,
5732             $exeonfiles, \@applytype, $warp);
5733 0           &dothings;
5734             }
5735             elsif ( $modification_type eq "vary_controls" )
5736             {
5737 0           &vary_controls
5738             ($to, $fileconfig, $stepsvar, $counterzone, $counterstep,
5739             $exeonfiles, \@applytype, \@vary_controls);
5740 0           &dothings;
5741             }
5742             elsif ( $modification_type eq "vary_net" )
5743             {
5744 0           &vary_net
5745             ($to, $fileconfig, $stepsvar, $counterzone, $counterstep,
5746             $exeonfiles, \@applytype, \@vary_net);
5747 0           &dothings;
5748             }
5749             elsif ( $modification_type eq "change_climate" )
5750             {
5751 0           &change_climate
5752             ($to, $fileconfig, $stepsvar, $counterzone, $counterstep,
5753             $exeonfiles, \@applytype, \@change_climate);
5754 0           &dothings;
5755             }
5756             elsif ( $modification_type eq "constrain_controls" )
5757             {
5758 0           &dothings;
5759             }
5760             #elsif ( $modification_type eq "get_obstructions" )
5761             #{
5762             # dothings;
5763             #}
5764             #elsif ( $modification_type eq "pin_obstructions" )
5765             #{
5766             # dothings;
5767             #}
5768             elsif ( $modification_type eq "constrain_geometry" )
5769             {
5770 0           &dothings;
5771             }
5772             elsif ( $modification_type eq "apply_constraints" )
5773             {
5774 0           &dothings;
5775             }
5776             elsif ( $modification_type eq "constrain_net" )
5777             {
5778 0           &dothings;
5779             }
5780             elsif ( $modification_type eq "propagate_net" )
5781             {
5782 0           &dothings;
5783             }
5784             elsif ( $modification_type eq "recalculatenet" )
5785             {
5786 0           &dothings;
5787             }
5788             elsif ( $modification_type eq "constrain_obstructions" )
5789             {
5790 0           &dothings;
5791             }
5792             elsif ( $modification_type eq "propagate_constraints" )
5793             {
5794 0           &dothings;
5795             }
5796             }
5797 0           $counterzone++;
5798 0           print `cd $mypath`;
5799 0           print TOSHELL "cd $mypath\n\n";
5800             }
5801 0           $counterstep++ ;
5802             }
5803             }
5804 0 0         if ($countvar == $#varnumbers)
5805             {
5806 0           my @files_to_erase = grep -d, <$mypath/models/$file*_>;
5807 0           foreach my $file (@files_to_erase)
5808             {
5809 0 0         if ($exeonfiles = "y") { print `rm -R $file`; }
  0            
5810 0           print TOSHELL "rm -R $file";
5811             }
5812             }
5813 0           $countvar++;
5814             }
5815 0           close MORPHFILE;
5816              
5817 0           close CASELIST;
5818             } # END SUB morph
5819             ##############################################################################
5820             ##############################################################################
5821             ##############################################################################
5822              
5823             # BEGINNING OF SUB SIM
5824             ##############################################################################
5825             ##############################################################################
5826             ##############################################################################
5827              
5828             # HERE FOLLOWES THE CONTENT OF THE "sim.pm" FILE, WHICH HAS BEEN MERGED HERE
5829             # TO AVOID COMPLICATIONS WITH THE PERL MODULE INSTALLATION.
5830              
5831             # HERE FOLLOWS THE "sim" FUNCTION, CALLED FROM THE MAIN PROGRAM FILE.
5832             # IT ALSO RETRIEVES RESULTS. THE TWO OPERATIONS ARE CONTROLLED SEPARATELY
5833             # FROM THE OPTS CONFIGURATION FILE.
5834              
5835             #____________________________________________________________________________
5836             # Activate or deactivate the following function calls depending from your needs
5837             sub sim # This function launch the simulations in ESP-r
5838             {
5839 0     0 0   my $to = shift;
5840 0           my $mypath = shift;
5841 0           my $file = shift;
5842 0           my $filenew = shift;
5843 0           my $swap = shift;
5844 0           my @dowhat = @$swap;
5845 0           my $swap = shift;
5846 0           my @simdata = @$swap;
5847 0           my $simnetwork = shift;
5848 0           my $swap = shift;
5849 0           my @simtitles = @$swap;
5850 0           my $preventsim = shift;
5851 0           my $exeonfiles = shift;
5852 0           my $fileconfig = shift;
5853 0           my $swap = shift;
5854 0           my @themereports = @$swap;
5855 0           my $swap = shift;
5856 0           my @reporttitles = @$swap;
5857 0           my $swap = shift;
5858 0           my @retrievedata = @$swap;
5859              
5860 0           my $countersimmax = ( ( $#simdata + 1 ) / 4 );
5861 0 0         open(MORPHFILE, $morphfile) or die "Can't open $morphfile $!";
5862             #@dirs_to_simulate = grep -d, <$mypath/$filenew*>;
5863 0           @dirs_to_simulate = ;
5864 0           close MORPHFILE;
5865 0           print OUTFILE "\$morphfile: $morphfile. \@dirs_to_simulate: " . Dumper(@dirs_to_simulate) . "\n";
5866 0           my @ress;
5867             my @flfs;
5868              
5869 0 0         open (SIMLIST, ">$simlistfile") or die;
5870              
5871 0           my $countdir = 0;
5872 0           foreach my $dir_to_simulate (@dirs_to_simulate)
5873             {
5874 0           chomp($dir_to_simulate);
5875 0           my $countersim = 0;
5876 0           foreach my $date_to_sim (@simtitles)
5877             {
5878 0           my $simdataref = $simdata[$countersim];
5879 0           my @simdata = @{$simdataref};
  0            
5880            
5881 0 0         unless ( $preventsim eq "y")
5882             {
5883 0           my $resfile = "$dir_to_simulate-$date_to_sim.res";
5884 0           my $flfile = "$dir_to_simulate-$date_to_sim.fl";
5885 0           push (@ress, $resfile);
5886 0           push (@flfs, $flfile);
5887            
5888 0 0         unless (-e $resfile )
5889             {
5890 0 0         if ( $simnetwork eq "n" )
5891             {
5892 0           my $printthis =
5893             "bps -file $dir_to_simulate/cfg/$fileconfig -mode script<
5894              
5895             c
5896             $resfile
5897             $simdata[0 + (4*$countersim)]
5898             $simdata[1 + (4*$countersim)]
5899             $simdata[2 + (4*$countersim)]
5900             $simdata[3 + (4*$countersim)]
5901             s
5902             $simnetwork
5903             Results for $dir_to_simulate-$date_to_sim
5904             y
5905             y
5906             -
5907             -
5908             -
5909             -
5910             -
5911             -
5912             -
5913             XXX
5914             ";
5915 0 0         if ($exeonfiles eq "y")
5916             {
5917 0           print `$printthis`;
5918             }
5919 0           print TOSHELL $printthis;
5920 0           print SIMLIST "$resfile\n";
5921             }
5922            
5923 0 0         if ( $simnetwork eq "y" )
5924             {
5925 0           my $printthis =
5926             "bps -file $dir_to_simulate/cfg/$fileconfig -mode script<
5927              
5928             c
5929             $resfile
5930             $flfile
5931             $simdata[0 + (4*$countersim)]
5932             $simdata[1 + (4*$countersim)]
5933             $simdata[2 + (4*$countersim)]
5934             $simdata[3 + (4*$countersim)]
5935             s
5936             $simnetwork
5937             Results for $dir_to_simulate-$dates_to_sim
5938             y
5939             y
5940             -
5941             -
5942             -
5943             -
5944             -
5945             -
5946             -
5947             XXX
5948             ";
5949 0 0         if ($exeonfiles eq "y")
5950             {
5951 0           print `$printthis`;
5952             }
5953 0           print TOSHELL $printthis;
5954 0           print SIMLIST "$resfile\n";
5955 0           print OUTFILE "TWO, $resfile\n";
5956             }
5957             }
5958             }
5959 0           $countersim++;
5960             }
5961 0           $countdir++;
5962             }
5963              
5964 0           close SIMLIST;
5965             } # END SUB sim;
5966              
5967             # END OF THE CONTENT OF THE "opts_sim.pl" FILE.
5968             ##############################################################################
5969             ##############################################################################
5970             ##############################################################################
5971              
5972              
5973              
5974             # BEGINNING OF SUB RETRIEVE
5975             ##############################################################################
5976             ##############################################################################
5977             ##############################################################################
5978             sub retrieve
5979             {
5980 0     0 0   my $to = shift;
5981 0           my $mypath = shift;
5982 0           my $file = shift;
5983 0           my $filenew = shift;
5984 0           my $swap = shift;
5985 0           my @dowhat = @$swap;
5986 0           my $swap = shift;
5987 0           my @simdata = @$swap;
5988 0           my $simnetwork = shift;
5989 0           my $swap = shift;
5990 0           my @simtitles = @$swap;
5991 0           my $preventsim = shift;
5992 0           my $exeonfiles = shift;
5993 0           my $fileconfig = shift;
5994 0           my $swap = shift;
5995 0           my @themereports = @$swap;
5996 0           my $swap = shift;
5997 0           my @reporttitles = @$swap;
5998 0           my $swap = shift;
5999 0           my @retrievedata = @$swap;
6000              
6001 0 0         unless (-e "$mypath/results")
6002             {
6003 0           print `mkdir $mypath/results`;
6004 0           print TOSHELL "mkdir $mypath/results\n\n";
6005             }
6006              
6007             sub retrieve_temperatures_results
6008             {
6009 0     0 0   my $result = shift;
6010 0           my $resfile = shift;
6011 0           my $swap = shift;
6012 0           my @retrievedatatemps = @$swap;
6013 0           my $reporttitle = shift;
6014 0           my $stripcheck = shift;
6015 0           my $theme = shift;
6016             #my $existingfile = "$resfile-$theme.grt";
6017             #if (-e $existingfile) { print `chmod 777 $existingfile\n`;}
6018             #print TOSHELL "chmod 777 $existingfile\n";
6019             #if (-e $existingfile) { print `rm $existingfile\n` ;}
6020             #print TOSHELL "rm $existingfile\n";
6021             #if ($exeonfiles eq "y") { print `rm -f $existingfile*par\n`; }
6022             #print TOSHELL "rm -f $existingfile*par\n";
6023              
6024 0 0         unless (-e "$result-$reporttitle-$theme.grt-")
6025             {
6026 0           my $printthis =
6027             "res -file $resfile -mode script<
6028              
6029             3
6030             $retrievedatatemps[0]
6031             $retrievedatatemps[1]
6032             $retrievedatatemps[2]
6033             c
6034             g
6035             a
6036             a
6037             b
6038             a
6039             b
6040             e
6041             b
6042             f
6043             >
6044             a
6045             $result-$reporttitle-$theme.grt
6046             Simulation results $result-$reporttitle-$theme
6047             !
6048             -
6049             -
6050             -
6051             -
6052             -
6053             -
6054             -
6055             -
6056             YYY
6057             ";
6058 0 0         if ($exeonfiles eq "y")
6059             {
6060 0           print `$printthis`;
6061             }
6062 0           print TOSHELL $printthis;
6063             #if (-e $existingfile) { print `rm -f $existingfile*par`;}
6064             #print TOSHELL "rm -f $existingfile*par\n";
6065             }
6066             }
6067              
6068             sub retrieve_comfort_results
6069             {
6070 0     0 0   my $result = shift;
6071 0           my $resfile = shift;
6072 0           my $swap = shift;
6073 0           my @retrievedatacomf = @$swap;
6074 0           my $reporttitle = shift;
6075 0           my $stripcheck = shift;
6076 0           my $theme = shift;
6077             #my $existingfile = "$resfile-$theme.grt";
6078             #if (-e $existingfile) { print `chmod 777 $existingfile\n`;}
6079             #print TOSHELL "chmod 777 $existingfile\n";
6080             #if (-e $existingfile) { print `rm $existingfile\n` ;}
6081             #print TOSHELL "rm $existingfile\n";
6082             #if ($exeonfiles eq "y") { print `rm -f $existingfile*par\n`;}
6083             #print TOSHELL "rm -f $existingfile*par\n";
6084              
6085 0 0         unless (-e "$result-$reporttitle-$theme.grt-")
6086             {
6087 0           my $printthis =
6088             "res -file $resfile -mode script<
6089              
6090             3
6091             $retrievedatacomf[0]
6092             $retrievedatacomf[1]
6093             $retrievedatacomf[2]
6094             c
6095             g
6096             c
6097             a
6098              
6099             b
6100              
6101              
6102             a
6103             >
6104             a
6105             $result-$reporttitle-$theme.grt
6106             Simulation results $result-$reporttitle-$theme
6107             !
6108             -
6109             -
6110             -
6111             -
6112             -
6113             -
6114             -
6115             -
6116             ZZZ
6117             ";
6118 0 0         if ($exeonfiles eq "y")
6119             {
6120 0           print `$printthis`;
6121             }
6122 0           print TOSHELL $printthis;
6123             #if (-e $existingfile) { `rm -f $existingfile*par\n`;}
6124             #print TOSHELL "rm -f $existingfile*par\n";
6125             }
6126             }
6127              
6128             sub retrieve_loads_results
6129             {
6130 0     0 0   my $result = shift;
6131 0           my $resfile = shift;
6132 0           my $swap = shift;
6133 0           my @retrievedataloads = @$swap;
6134 0           my $reporttitle = shift;
6135 0           my $stripcheck = shift;
6136 0           my $theme = shift;
6137             #my $existingfile = "$resfile-$theme.grt";
6138             #if (-e $existingfile) { `chmod 777 $existingfile\n`;}
6139             #print TOSHELL "chmod 777 $existingfile\n";
6140             #if (-e $existingfile) { `rm $existingfile\n` ;}
6141             #print TOSHELL "rm $existingfile\n";
6142              
6143 0 0         unless (-e "$result-$reporttitle-$theme.grt-")
6144             {
6145 0           my $printthis =
6146             "res -file $resfile -mode script<
6147              
6148             3
6149             $retrievedataloads[0]
6150             $retrievedataloads[1]
6151             $retrievedataloads[2]
6152             d
6153             >
6154             a
6155             $result-$reporttitle-$theme.grt
6156             Simulation results $result-$reporttitle-$theme
6157             l
6158             a
6159              
6160             -
6161             -
6162             -
6163             -
6164             -
6165             -
6166             -
6167             TTT
6168             ";
6169 0 0         if ($exeonfiles eq "y")
6170             {
6171 0           print `$printthis`;
6172             }
6173 0           print TOSHELL $printthis;
6174              
6175 0           print RETRIEVELIST "$result-$reporttitle-$theme.grt ";
6176 0 0         if ($stripcheck)
6177             {
6178 0 0         open (CHECKDATUM, "$result-$reporttitle-$theme.grt") or die;
6179 0 0         open (STRIPPED, ">$result-$reporttitle-$theme.grt-") or die;
6180 0           my @lines = ;
6181 0           foreach my $line (@lines)
6182             {
6183 0           $line =~ s/^\s+//;
6184 0           @lineelms = split(/\s+|,/, $line);
6185 0 0         if ($lineelms[0] eq $stripcheck)
6186             {
6187 0           print STRIPPED "$line";
6188             }
6189             }
6190 0           close STRIPPED;
6191 0           close CHECKDATUM;
6192             }
6193             }
6194             }
6195              
6196             sub retrieve_temps_stats
6197             {
6198 0     0 0   my $result = shift;
6199 0           my $resfile = shift;
6200 0           my $swap = shift;
6201 0           my @retrievedatatempsstats = @$swap;
6202 0           my $reporttitle = shift;
6203 0           my $stripcheck = shift;
6204 0           my $theme = shift;
6205             #my $existingfile = "$resfile-$theme.grt";
6206             #if (-e $existingfile) { `chmod 777 $existingfile\n`; }
6207             #print TOSHELL "chmod 777 $existingfile\n";
6208             #if (-e $existingfile) { `rm $existingfile\n` ;}
6209             #print TOSHELL "rm $existingfile\n";
6210             #if (-e $existingfile) { `rm -f $existingfile*par\n`;}
6211             #print TOSHELL "rm -f $existingfile*par\n";
6212              
6213 0 0         unless (-e "$result-$reporttitle-$theme.grt-")
6214             {
6215 0           my $printthis =
6216             "res -file $resfile -mode script<
6217              
6218             3
6219             $retrievedatatempsstats[0]
6220             $retrievedatatempsstats[1]
6221             $retrievedatatempsstats[2]
6222             d
6223             >
6224             a
6225             $result-$reporttitle-$theme.grt
6226             Simulation results $result-$reporttitle-$theme.grt
6227             m
6228             -
6229             -
6230             -
6231             -
6232             -
6233             TTT
6234             ";
6235              
6236 0 0         if ($exeonfiles eq "y")
6237             {
6238 0           print `$printthis`;
6239 0           print OUTFILE "CALLED RETRIEVE TEMPS STATS\n";
6240 0           print OUTFILE "\$resfile: $resfile, \$retrievedataloads[0]: $retrievedataloads[0], \$retrievedataloads[1]: $retrievedataloads[1], \$retrievedataloads[2]:$retrievedataloads[2]\n";
6241 0           print OUTFILE "\$reporttitle: $reporttitle, \$theme: $theme\n";
6242 0           print OUTFILE "\$resfile-\$reporttitle-\$theme: $resfile-$reporttitle-$theme";
6243             }
6244 0           print TOSHELL $printthis;
6245              
6246             #if ($exeonfiles eq "y") { print `rm -f $existingfile*par\n`;}
6247             #print TOSHELL "rm -f $existingfile*par\n";
6248 0           print RETRIEVELIST "$resfile-$reporttitle-$theme.grt ";
6249 0 0         if ($stripcheck)
6250             {
6251 0 0         open (CHECKDATUM, "$result-$reporttitle-$theme.grt") or die;
6252 0 0         open (STRIPPED, ">$result-$reporttitle-$theme.grt-") or die;
6253 0           my @lines = ;
6254 0           foreach my $line (@lines)
6255             {
6256 0           $line =~ s/^\s+//;
6257 0           @lineelms = split(/\s+|,/, $line);
6258 0 0         if ($lineelms[0] eq $stripcheck)
6259             {
6260 0           print STRIPPED "$line";
6261             }
6262             }
6263 0           close STRIPPED;
6264 0           close CHECKDATUM;
6265             }
6266             }
6267             }
6268              
6269 0 0         open (OPENSIMS, "$simlistfile") or die;
6270 0           my @sims = ;
6271             # print OUTFILE "SIMS: " . Dumper(@sims) . "\n";
6272 0           close OPENSIMS;
6273            
6274 0           my $countertheme = 0;
6275 0           foreach my $themereportref (@themereports)
6276             {
6277             # print OUTFILE "SIMS: \n";
6278 0           my @themereports = @{$themereportref};
  0            
6279 0           my $reporttitlesref = $reporttitles[$countertheme];
6280 0           my @reporttitles = @{$reporttitlesref};
  0            
6281 0           my $retrievedatarefsdeep = $retrievedata[$countertheme];
6282 0           my @retrievedatarefs = @{$retrievedatarefsdeep};
  0            
6283 0           my $stripcheckref = $stripchecks[$countertheme];
6284 0           my @stripckecks = @{$stripcheckref};
  0            
6285            
6286 0           my $countreport = 0;
6287 0           foreach my $reporttitle (@reporttitles)
6288             {
6289             # print OUTFILE "SIMS: \n";
6290 0           my $theme = $themereports[$countreport];
6291 0           my $retrieveref = $retrievedatarefs[$countreport];
6292 0           my $stripcheck = $stripckecks[$countreport];
6293 0           my @retrievedata = @{$retrieveref};
  0            
6294 0           my $countersim = 0;
6295 0           foreach my $sim (@sims)
6296             {
6297 0           chomp($sim);
6298 0           my $targetprov = $sim;
6299 0           $targetprov =~ s/$mypath\/models\///;
6300 0           my $result = "$mypath" . "/results/$targetprov";
6301              
6302 0 0         if ( $theme eq "temps" ) { &retrieve_temperatures_results($result, $sim, \@retrievedata, $reporttitle, $stripcheck, $theme); }
  0            
6303 0 0         if ( $theme eq "comfort" ) { &retrieve_comfort_results($result, $sim, \@retrievedata, $reporttitle, $stripcheck, $theme); }
  0            
6304 0 0         if ( $theme eq "loads" ) { &retrieve_loads_results($result, $sim, \@retrievedata, $reporttitle, $stripcheck, $theme); }
  0            
6305 0 0         if ( $theme eq "tempsstats" ) { &retrieve_temps_stats($result, $sim, \@retrievedata, $reporttitle, $stripcheck, $theme); }
  0            
6306 0           print OUTFILE "\$sim: $sim, \$result: $result, \@retrievedata: @retrievedata, \$reporttitle: $reporttitle, \$stripcheck: $stripcheck, \$theme: $theme\n";
6307 0           $countersim++;
6308             }
6309 0           $countreport++;
6310             }
6311 0           $countertheme++;
6312             }
6313 0           print `rm -f ./results/*.grt`;
6314 0           print TOSHELL "rm -f ./results/*.grt\n";
6315 0           print `rm -f ./results/*.par`;
6316 0           print TOSHELL "rm -f ./results/*.par\n";
6317             } # END SUB RETRIEVE
6318            
6319             ##############################################################################
6320             ##############################################################################
6321             ##############################################################################
6322             # END SUB RETRIEVE
6323              
6324 0     0 0   sub report { ; } # NO MORE USED # This function retrieved the results of interest from the text file created by the "retrieve" function
6325              
6326             # BEGINNING OF SUB MERGE_REPORTS
6327             ##############################################################################
6328             ##############################################################################
6329             ##############################################################################
6330             sub merge_reports # Self-explaining
6331             {
6332 0     0 0   my $to = shift;
6333 0           my $mypath = shift;
6334 0           my $file = shift;
6335 0           my $filenew = shift;
6336 0           my $swap = shift;
6337 0           my @dowhat = @$swap;
6338 0           my $swap = shift;
6339 0           my @simdata = @$swap;
6340 0           my $simnetwork = shift;
6341 0           my $swap = shift;
6342 0           my @simtitles = @$swap;
6343 0           my $preventsim = shift;
6344 0           my $exeonfiles = shift;
6345 0           my $fileconfig = shift;
6346 0           my $swap = shift;
6347 0           my @themereports = @$swap;
6348 0           my $swap = shift;
6349 0           my @reporttitles = @$swap;
6350 0           my $swap = shift;
6351 0           my @retrievedata = @$swap;
6352 0           my $toshell = shift;
6353 0           my $outfile = shift;
6354 0           my $configfile = shift;
6355 0           my $swap = shift;
6356 0           my @rankdata = @$swap;
6357 0           my $swap = shift;
6358 0           my @rankcolumn = @$swap;
6359 0           my $swap = shift;
6360 0           my @reporttempsdata = @$swap;
6361 0           my $swap = shift;
6362 0           my @reportcomfortdata = @$swap;
6363 0           my $swap = shift;
6364 0           my @reportradiationenteringdata = @$swap;
6365 0           my $stripcheck = shift;
6366 0           my @columns_to_report = @{ $reporttempsdata[1] };
  0            
6367 0           my $number_of_columns_to_report = scalar(@columns_to_report);
6368 0           my $counterlines;
6369 0           my $number_of_dates_to_merge = scalar(@simtitles);
6370 0           my @dates = @simtitles;
6371 0           my $mergefile = "$mypath/$file-merge-$countcase-$countblock";
6372              
6373             sub merge
6374             {
6375 0 0   0 0   open (MERGEFILE, ">$mergefile") or die;
6376 0 0         open (FILECASELIST, "$simlistfile") or die;
6377 0           my @lines = ;
6378 0           close FILECASELIST;
6379 0           my $counterline = 1;
6380 0           foreach my $line (@lines)
6381             {
6382 0           chomp($line);
6383 0           my $morphcase = "$line";
6384 0           my $reportcase = $morphcase;
6385 0           $reportcase =~ s/\/models/\/results/;
6386 0           print MERGEFILE "CASE$counterline ";
6387 0           my $counterouter = 0;
6388 0           foreach my $themeref (@themereports)
6389             {
6390 0           my $counterinner = 0;
6391 0           my @themes = @{$themeref};
  0            
6392 0           foreach my $theme (@themes)
6393             {
6394 0           my $simtitle = $simtitles[$counterouter];
6395 0           my $reporttitle = $reporttitles[$counterouter][$counterinner];
6396             #print OUTFILE "FILE: $file, SIMTITLE: $simtitle, REPORTTITLE!: $reporttitle, THEME: $theme\n";
6397 0           my $case = "$reportcase-$reporttitle-$theme.grt-";
6398             #print OUTFILE "\$case $case\n";
6399             #if (-e $case) { print OUTFILE "IT EXISTS!\n"; }
6400             #print OUTFILE "$case\n";
6401 0 0         open(OPENTEMP, $case) or die;
6402 0           my @linez = ;
6403 0           close OPENTEMP;
6404 0           chomp($linez[0]);
6405 0           print MERGEFILE "$case $linez[0] ";
6406 0           $counterinner++;
6407             }
6408 0           $counterouter++;
6409             }
6410 0           print MERGEFILE "\n";
6411 0           $counterline++;
6412             }
6413 0           close MERGEFILE;
6414             }
6415 0           &merge();
6416              
6417 0           my $cleanfile = "$mergefile-clean";
6418 0           my $selectmerged = "$cleanfile-select";
6419             sub cleanselect
6420             { # CLEANS THE MERGED FILE AND SELECTS SOME COLUMNS AND COPIES THEM IN ANOTHER FILE
6421 0 0   0 0   open ( MERGEFILE, $mergefile) or die;
6422 0           my @lines = ;
6423 0           close MERGEFILE;
6424 0 0         open ( CLEANMERGED, ">$cleanfile") or die;
6425 0           foreach my $line (@lines)
6426             {
6427 0           $line =~ s/\n/°/g;
6428 0           $line =~ s/\s+/,/g;
6429 0           $line =~ s/°/\n/g;
6430 0           print CLEANMERGED "$line";
6431             }
6432 0           close CLEANMERGED;
6433             # END. CLEANS THE MERGED FILE
6434            
6435             #SELECTS SOME COLUMNS AND COPIES THEM IN ANOTHER FILE
6436 0 0         open (CLEANMERGED, $cleanfile) or die;
6437 0           my @lines = ;
6438 0           close CLEANMERGED;
6439 0 0         open (SELECTMERGED, ">$selectmerged") or die;
6440            
6441            
6442 0           foreach my $line (@lines)
6443             {
6444 0           my @elts = split(/\s+|,/, $line);
6445 0           my $counterouter = 0;
6446 0           foreach my $elmref (@keepcolumns)
6447             {
6448 0           my @cols = @{$elmref};
  0            
6449 0           my $counterinner = 0;
6450 0           foreach my $elm (@cols)
6451             {
6452 0           print SELECTMERGED "$elts[$elm]";
6453 0 0 0       if ( ( $counterouter < $#keepcolumns ) or ( $counterinner < $#cols) )
6454 0           {
6455 0           print SELECTMERGED ",";
6456             }
6457             else {print SELECTMERGED "\n";}
6458 0           $counterinner++;
6459             }
6460 0           $counterouter++;
6461             }
6462             }
6463 0           close SELECTMERGED;
6464             } # END. CLEANS THE MERGED FILE AND SELECTS SOME COLUMNS AND COPIES THEM IN ANOTHER FILE
6465 0           &cleanselect();
6466            
6467 0           my $weight = "$selectmerged-weight"; # THIS WILL HOST PARTIALLY SCALED VALUES, MADE POSITIVE AND WITH A CELING OF 1
6468             sub weight
6469             {
6470 0 0   0 0   open (SELECTMERGED, $selectmerged) or die;
6471 0           my @lines = ;
6472 0           close SELECTMERGED;
6473             # print OUTFILE "FIRST LINE: $lines[0]\n";
6474 0           my $counterline = 0;
6475 0 0         open (WEIGHT, ">$weight") or die;
6476            
6477 0           my @containerone;
6478 0           foreach my $line (@lines)
6479             {
6480 0           $line =~ s/^[\n]//;
6481             #print OUTFILE "I SPLIT\n";
6482 0           my @elts = split(/\s+|,/, $line);
6483 0           my $countcol = 0;
6484 0           my $countel = 0;
6485 0           foreach my $elt (@elts)
6486             {
6487             #print OUTFILE "I CHECK\n";
6488 0 0         if ( odd($countel) )
6489             {
6490             # print OUTFILE "I PUSH\n";
6491 0           push ( @{$containerone[$countcol]}, $elt);
  0            
6492             #print OUTFILE "ELT: $elt\n";
6493 0           $countcol++;
6494             }
6495 0           $countel++;
6496             }
6497             }
6498             #print OUTFILE "CONTAINERONE " . Dumper(@containerone) . "\n";
6499            
6500 0           my @containertwo;
6501             my @containerthree;
6502 0           $countcolm = 0;
6503 0           my @optimals;
6504 0           foreach my $colref (@containerone)
6505             {
6506 0           my @column = @{$colref}; # DEREFERENCE
  0            
6507            
6508 0 0         if ( $weights[$countcolm] < 0 ) # TURNS EVERYTHING POSITIVE
6509             {
6510 0           foreach $el (@column)
6511             {
6512 0           $el = ($el * -1);
6513             }
6514             }
6515            
6516 0 0         if ( max(@column) != 0) # FILLS THE UNTRACTABLE VALUES
6517             {
6518 0           push (@maxes, max(@column));
6519             }
6520             else
6521             {
6522 0           push (@maxes, "NOTHING1");
6523             }
6524            
6525             #print OUTFILE "MAXES: " . Dumper(@maxes) . "\n";
6526             #print OUTFILE "DUMPCOLUMN: " . Dumper(@column) . "\n";
6527            
6528 0           foreach my $el (@column)
6529             {
6530 0           my $eltrans;
6531 0 0         if ( $maxes[$countcolm] != 0 )
6532             {
6533             #print OUTFILE "\$weights[\$countcolm]: $weights[$countcolm]\n";
6534 0           $eltrans = ( $el / $maxes[$countcolm] ) ;
6535             }
6536             else
6537             {
6538 0           $eltrans = "NOTHING2" ;
6539             }
6540 0           push ( @{$containertwo[$countcolm]}, $eltrans) ;
  0            
6541             #print OUTFILE "ELTRANS: $eltrans\n";
6542             }
6543 0           $countcolm++;
6544             }
6545             #print OUTFILE "CONTAINERTWO " . Dumper(@containertwo) . "\n";
6546            
6547 0           my $countline = 0;
6548 0           foreach my $line (@lines)
6549             {
6550 0           $line =~ s/^[\n]//;
6551 0           my @elts = split(/\s+|,/, $line);
6552 0           my $countcolm = 0;
6553 0           foreach $eltref (@containertwo)
6554             {
6555 0           my @col = @{$eltref};
  0            
6556 0           my $max = max(@col);
6557             #print OUTFILE "MAX: $max\n";
6558 0           my $min = min(@col);
6559             #print OUTFILE "MIN: $min\n";
6560 0           my $floordistance = ($max - $min);
6561 0           my $range = ( $min / $max);
6562 0           my $el = $col[$countline];
6563 0           my $rescaledel;
6564 0 0         if ( $floordistance != 0 )
6565             {
6566 0           $rescaledel = ( ( $el - $min ) / $floordistance ) ;
6567             }
6568             else
6569             {
6570 0           $rescaledel = 1;
6571             }
6572 0 0         if ( $weightsaim[$countcolm] < 0)
6573             {
6574 0           $rescaledel = ( 1 - $rescaledel);
6575             }
6576 0           push (@elts, $rescaledel);
6577 0           $countcolm++;
6578             }
6579            
6580 0           $countline++;
6581            
6582 0           my $counter = 0;
6583 0           foreach my $el (@elts)
6584             {
6585 0           print WEIGHT "$el";
6586 0 0         if ($counter < $#elts)
6587             {
6588 0           print WEIGHT ",";
6589             }
6590             else
6591             {
6592 0           print WEIGHT "\n";
6593             }
6594 0           $containerthree[$counterline][$counter] = $el;
6595 0           $counter++;
6596             }
6597 0           $counterline++;
6598             }
6599 0           close WEIGHT;
6600             #print OUTFILE "CONTAINERTHREE: " . Dumper(@containerthree) . "\n";
6601             }
6602 0           &weight(); #
6603            
6604 0           my $weighttwo = "$selectmerged-weighttwo"; # THIS WILL HOST PARTIALLY SCALED VALUES, MADE POSITIVE AND WITH A CELING OF 1
6605             sub weighttwo
6606             {
6607 0 0   0 0   open (WEIGHT, $weight) or die;
6608 0           my @lines = ;
6609 0           close WEIGHT;
6610 0 0         open (WEIGHTTWO, ">$weighttwo") or die;
6611 0           my $counterline;
6612 0           foreach my $line (@lines)
6613             {
6614 0           $line =~ s/^[\n]//;
6615 0           my @elts = split(/\s+|,/, $line);
6616 0           my $counterelt = 0;
6617 0           my $counterin = 0;
6618 0           my $sum = 0;
6619 0           my $avg;
6620 0           my $numberels = scalar(@keepcolumns);
6621 0           foreach my $elt (@elts)
6622             {
6623 0           my $newelt;
6624 0 0         if ($counterelt > ( $#elts - $numberels ))
6625             {
6626             #print OUTFILE "ELT: $elt\n";
6627 0           $newelt = ( $elt * abs($weights[$counterin]) );
6628             # print OUTFILE "ABS" . abs($weights[$counterin]) . "\n";
6629             # print OUTFILE "NEWELT: $newelt\n";
6630 0           $sum = ( $sum + $newelt ) ;
6631             # print OUTFILE "SUM: $sum\n";
6632 0           $counterin++;
6633             }
6634 0           $counterelt++;
6635             }
6636 0           $avg = ($sum / scalar(@keepcolumns) );
6637 0           push ( @elts, $avg);
6638            
6639 0           my $counter = 0;
6640 0           foreach my $elt (@elts)
6641             {
6642 0           print WEIGHTTWO "$elt";
6643 0 0         if ($counter < $#elts)
6644             {
6645 0           print WEIGHTTWO ",";
6646             }
6647             else
6648             {
6649 0           print WEIGHTTWO "\n";
6650             }
6651 0           $counter++;
6652             }
6653 0           $counterline++
6654             }
6655             }
6656 0           &weighttwo();
6657              
6658 0           $sortmerged = "$mergefile-sortmerged";
6659             sub sortmerged
6660             {
6661 0 0   0 0   open (WEIGHTTWO, $weighttwo) or die;
6662 0 0         open (SORTMERGED, ">$sortmerged") or die;
6663 0           my @lines = ;
6664 0           close WEIGHTTWO;
6665 0           my $line = $lines[0];
6666 0           $line =~ s/^[\n]//;
6667 0           my @eltstemp = split(/\s+|,/, $line);
6668 0           my $numberelts = scalar(@eltstemp);
6669 0 0         if ($numberelts > 0) { print SORTMERGED `sort -n -k$numberelts,$numberelts -t , $weighttwo`; }
  0            
6670             # print SORTMERGED `sort -n -k$numberelts -n $weighttwo`;
6671 0           close SORTMERGED;
6672             }
6673 0           &sortmerged();
6674             } # END SUB merge_reports
6675              
6676             #################################################################
6677             #################################################################
6678             #################################################################
6679             # END OF SUB MERGE_REPORTS
6680            
6681 0 0         if (-e "./SIM/OPTS/convertandfilter.pl")
6682             {
6683 0           eval `cat ./SIM/OPTS/convertandfilter.pl`;
6684             }
6685              
6686 0 0         if (-e "./SIM/OPTS/maketable.pl")
6687             {
6688 0           eval `cat ./SIM/OPTS/maketable.pl`;
6689             }
6690            
6691             # END OF THE CONTENT OF THE "opts_format.pl" FILE.
6692             ##############################################################################
6693             ##############################################################################
6694             ##############################################################################
6695            
6696            
6697             # BEGINNING OF SUB TAKEOPTIMA
6698             #################################################################
6699             #################################################################
6700             #################################################################
6701             sub takeoptima
6702             {
6703 0     0 0   $fileuplift = "$file-uplift-$countcase-$countblock";
6704 0 0         open(UPLIFT, ">$fileuplift") or die;
6705 0           my $to = shift;
6706 0           my $mypath = shift;
6707 0           my $file = shift;
6708 0           my $filenew = shift;
6709 0           my $sortmerged = shift;
6710 0           my (@winnerarray_tested, @winnerarray_nontested, @winnerarray, @nontested, @provcontainer);
6711 0           @uplift = ();
6712 0           @downlift = ();
6713            
6714 0 0         open (SORTMERGED, $sortmerged) or die;
6715 0           say OUTFILE "\$sortmerged: $sortmerged";
6716 0           my @lines = ;
6717 0           close SORTMERGED;
6718            
6719 0           my $winnerentry = $lines[0];
6720 0           chomp $winnerentry;
6721 0           say OUTFILE "\$winnerentry: $winnerentry";
6722 0           my @winnerelts = split(/\s+|,/, $winnerentry);
6723 0           my $winnerline = $winnerelts[0];
6724            
6725 0           say OUTFILE "YESHERE TAKEOPTIMA 1 ";
6726            
6727 0           foreach my $var (@totvarnumbers)
6728             {
6729 0 0         if ( $winnerline =~ /($var-\d+)/ )
6730             {
6731 0           my $fragment = $1;
6732 0           say OUTFILE "\$fragment: $fragment";
6733 0           push (@winnerarray_tested, $fragment);
6734             }
6735             }
6736            
6737 0           foreach my $elt (@varn)
6738             {
6739 0 0         unless ( $elt ~~ @totvarnumbers)
6740             {
6741 0           push (@nontested, $elt);
6742             }
6743             }
6744 0           @nontested = uniq(@nontested);
6745 0           @nontested = sort(@nontested);
6746            
6747 0           foreach my $el ( @nontested )
6748             {
6749 0           my $item = "$el-" . "$midvalues[$el]";
6750 0           push(@winnerarray_nontested, $item);
6751             }
6752 0           @winnerarray = (@winnerarray_tested, @winnerarray_nontested);
6753 0           @winnerarray = uniq(@winnerarray);
6754 0           @winnerarray = sort(@winnerarray);
6755            
6756 0           $winnermodel = "$filenew"; #BEGINNING
6757 0           $count = 0;
6758 0           foreach $elt (@winnerarray)
6759             {
6760 0 0         unless ($count == $#winnerarray)
6761             {
6762 0           $winnermodel = "$winnermodel" . "$elt" . "_";
6763             }
6764             else
6765             {
6766 0           $winnermodel = "$winnermodel" . "$elt";
6767             }
6768 0           $count++;
6769             }
6770            
6771 0 0 0       unless ( ($countvar == $#varnumbers) and ($countblock == $#blocks) )
6772             {
6773 0 0         if (@overlap)
6774             {
6775 0           my @nonoverlap;
6776 0           foreach my $elm (@varn)
6777             {
6778 0 0         unless ( $elm ~~ @overlap)
6779             {
6780 0           push ( @nonoverlap, $elm);
6781             }
6782             }
6783            
6784 0           my @present;
6785 0           foreach my $elt (@nonoverlap)
6786             {
6787 0 0         if ( $winnermodel =~ /($elt-\d+)/ )
6788             {
6789 0           push(@present, $1);
6790             }
6791             }
6792            
6793 0           my @extraneous;
6794 0           foreach my $el (@nonoverlap)
6795             {
6796 0           my $stepsvarthat = ${ "stepsvar" . "$el" };
  0            
6797 0           my $step = 1;
6798 0           while ( $step <= $stepsvarthat )
6799             {
6800 0           my $item = "$el" . "-" . "$step";
6801 0 0         unless ( $item ~~ @present )
6802             {
6803 0           push(@extraneous, $item);
6804             }
6805 0           $step++;
6806             }
6807             }
6808            
6809 0 0         open(MORPHFILE, "$morphfile") or die;
6810 0           my @models = ;
6811 0           close MORPHFILE;
6812            
6813 0           foreach my $model (@models)
6814             {
6815 0           chomp($model);
6816 0           my $counter = 0;
6817 0           foreach my $elt (@extraneous)
6818             {
6819 0 0         if( $model =~ /$elt/ )
6820             {
6821 0           $counter++;
6822             }
6823             }
6824 0 0         if ($counter == 0)
6825             {
6826 0           push(@seedfiles, $model);
6827             }
6828             }
6829             }
6830             else
6831             {
6832 0           push(@seedfiles, $winnermodel);
6833             }
6834             }
6835            
6836 0           @seedfiles = uniq(@seedfiles);
6837 0           @seedfiles = sort(@seedfiles);
6838 0           foreach my $seed (@seedfiles)
6839             {
6840 0           my $touchfile = $seed;
6841 0           $touchfile =~ s/_+$//;
6842 0           $touchfile = "$touchfile" . "_";
6843 0           push(@uplift, $touchfile);
6844 0 0         unless (-e "$touchfile")
6845             {
6846 0 0         if ( $exeonfiles eq "y" ) { print `cp -r $seed $touchfile` ; }
  0            
6847 0           print TOSHELL "cp -r $seed $touchfile\n\n";
6848             #if ( $exeonfiles eq "y" ) { print `mv -f $seed $touchfile` ; }
6849             #print TOSHELL "mv -f $seed $touchfile\n\n";
6850             }
6851             else
6852             {
6853             #if ( $exeonfiles eq "y" ) { print `rm -R $seed` ; }
6854             #print TOSHELL "rm -R $seed\n\n";
6855             }
6856             }
6857            
6858 0           foreach my $elt ( @uplift )
6859             {
6860 0           print UPLIFT "$elt\n";
6861             }
6862 0           close UPLIFT;
6863             }
6864              
6865             ###################################################################
6866             #################################################################
6867             #################################################################
6868             # END OF SUB TAKEOPTIMA
6869            
6870              
6871 0     0 0   sub rank_reports { ; } # ERASED
6872              
6873 0 0         if ( $dowhat[0] eq "y" )
6874             {
6875 0           { &morph( $to, $mypath, $file, $filenew, \@dowhat, \@simdata, $simnetwork,
  0            
6876             \@simtitles, $preventsim, $exeonfiles, $fileconfig,
6877             \@themereports, \@reporttitles, \@retrievedata, \@varnumbers, $countblock, $countcase); }
6878             }
6879              
6880 0 0         if ( $dowhat[1] eq "y" )
6881             {
6882 0           &sim( $to, $mypath, $file, $filenew, \@dowhat, \@simdata, $simnetwork,
6883             \@simtitles, $preventsim, $exeonfiles, $fileconfig,
6884             \@themereports, \@reporttitles, \@retrievedata);
6885             }
6886            
6887 0 0         if ( $dowhat[2] eq "y" )
6888             {
6889 0           &retrieve( $to, $mypath, $file, $filenew, \@dowhat, \@simdata, $simnetwork,
6890             \@simtitles, $preventsim, $exeonfiles, $fileconfig,
6891             \@themereports, \@reporttitles, \@retrievedata );
6892             }
6893            
6894 0 0         if ( $dowhat[4] eq "y" )
6895             {
6896 0           &report( $to, $mypath, $file, $filenew, \@dowhat, \@simdata, $simnetwork,
6897             \@simtitles, $preventsim, $exeonfiles, $fileconfig, \@themereports, \@reporttitles, \@retrievedata,
6898             \@rankdata, \@rankcolumn, \@reporttempsdata,
6899             \@reportcomfortdata, \@reportradiationenteringdata, $stripcheck ); }
6900              
6901 0 0         if ( $dowhat[5] eq "y" )
6902 0           { &merge_reports( $to, $mypath, $file, $filenew, \@dowhat, \@simdata, $simnetwork,
6903             \@simtitles, $preventsim, $exeonfiles, $fileconfig, \@themereports, \@reporttitles, \@retrievedata,
6904             \@rankdata, \@rankcolumn, \@reporttempsdata,
6905             \@reportcomfortdata, \@reportradiationenteringdata, $stripcheck );
6906             }
6907              
6908 0 0         if ( $dowhat[6] eq "y" )
6909             {
6910 0           &convert_report( \@varthemes_variations, \@varthemes_steps, $to, $mypath, $file, $filenew, \@dowhat, \@simdata, $simnetwork,
6911             \@simtitles, $preventsim, $exeonfiles, $fileconfig, \@themereports, \@reporttitles, \@retrievedata,
6912             \@rankdata, \@rankcolumn, \@reporttempsdata,
6913             \@reportcomfortdata, \@reportradiationenteringdata, $stripcheck ); # NAMES VARIABLES IN REPORTS
6914             }
6915 0 0         if ( $dowhat[10] eq "y" )
6916             {
6917 0           &takeoptima( $to, $mypath, $file, $filenew, $sortmerged); # CHECK THE WINNING CASE AND USES IT FOR BLOCK SEARCH IF POSSIBLE
6918             }
6919 0 0         if ( $dowhat[7] eq "y" )
6920             {
6921 0           &filter_reports( $to, $mypath, $file, $filenew, \@dowhat, \@simdata, $simnetwork,
6922             \@simtitles, $preventsim, $exeonfiles, $fileconfig, \@themereports, \@reporttitles, \@retrievedata,
6923             \@rankdata, \@rankcolumn, \@reporttempsdata, \@reportcomfortdata,
6924             \@reportradiationenteringdata, $stripcheck ); # FILTERS ALREADY CONVERTED REPORTS
6925             }
6926 0 0         if ( $dowhat[8] eq "y" )
6927             {
6928 0           &convert_filtered_reports( $to, $mypath, $file, $filenew, \@dowhat, \@simdata, $simnetwork,
6929             \@simtitles, $preventsim, $exeonfiles, $fileconfig, \@themereports, \@reporttitles, \@retrievedata,
6930             \@rankdata, \@rankcolumn, \@reporttempsdata, \@reportcomfortdata,
6931             \@reportradiationenteringdata, $stripcheck ); # CONVERTS ALREADY FILTERED REPORTS
6932             }
6933 0 0         if ( $dowhat[9] eq "y" )
6934             {
6935 0           &maketable( $to, $mypath, $file, $filenew, \@dowhat, \@simdata, $simnetwork,
6936             \@simtitles, $preventsim, $exeonfiles, $fileconfig, \@themereports, \@reporttitles, \@retrievedata,
6937             \@rankdata, \@rankcolumn, \@reporttempsdata,
6938             \@reportcomfortdata, \@reportradiationenteringdata, $stripcheck ); # CONVERTS TO TABLE ALREADY FILTERED REPORTS
6939             }
6940             } # END SUB exec
6941             ###########################################################################################
6942             ###########################################################################################
6943             ###########################################################################################
6944              
6945             ###########################################################################################
6946             ###########################################################################################
6947             # BELOW IS THE PART OF THE PROGRAM THAT LAUNCHES OPTS.
6948            
6949            
6950             # HERE IS A SPACE FOR GENERAL FUNCTIONS USED BY THE PROGRAM
6951             ###########################################################
6952             ###########################################################
6953             sub odd
6954             {
6955 0     0 0   my $number = shift;
6956 0           return !even ($number);
6957             }
6958              
6959             sub even
6960             {
6961 0     0 0   my $number = abs shift;
6962 0 0         return 1 if $number == 0;
6963 0           return odd ($number - 1);
6964             }
6965             ###########################################################
6966             ###########################################################
6967             # END OF THE SPACE FOR GENERAL FUNCTIONS
6968            
6969              
6970            
6971             ##########################################################################################
6972             ##########################################################################################
6973             # BEGINNING OF THE INSTRUCTIONS THAT LAUNCH OPTS AT EACH SUBSPACE SEARCH CYCLE.
6974            
6975 0 0 0       if ( ( (-e $casefile) and (-e $chancefile) ) or ( (-e $caseseed) and (-e $chanceseed) ) )
      0        
      0        
6976             {
6977 0           eval "$casefile"; # THIS BRINGS @casedata AND MAYBE @casegroup (OR PRODUCES IT).
6978 0           eval "$chancefile"; # THIS BRINGS @chanceseries.
6979 0           my @cancelineelms;
6980 0           my $countcase = 0;
6981 0 0         if ( $generatechance eq "n" )
    0          
6982             {
6983 0           foreach my $case (@casegroup) # in $casefile there may be a @casegroup. If not, it is fabricated from @casedescription and @chancefile
6984             {
6985 0           my @blocks = @{$case};
  0            
6986 0           my $countblock = 1;
6987 0           my (@varnumbers, @newvarnumbers, @chance, @newchance);
6988 0           foreach my $blockref (@blocks)
6989             {
6990 0           my @overlap;
6991 0           @varnumbers = @{$varn[$countcase][$countblock-1]};
  0            
6992 0           push (@chancelineelms, @varnumbers, @varnumbers, @varnumbers); # THIS SHOULD BE USEFUL SOONER OR LATER
6993 0           my $number_of_variables = scalar(@varnumbers);
6994 0           my @blockelts = @{$blockref};
  0            
6995 0           $blockelts[0] = ( $blockelts[0] + $number_of_variables );
6996 0           my @newblockelts = @{$blocks[$countblock]};
  0            
6997 0           $newblockelts[0] = ( $newblockelts[0] + $number_of_variables );
6998              
6999             sub def_filenew
7000             {
7001 0     0 0   $filenew = "$mypath/models/$file" . "_";
7002 0           my $counterfn = 0;
7003 0           foreach my $el (@varn)
7004             {
7005 0           $filenew = "$filenew" . "$varn[$counterfn]" . "-" . "$midvalues[$countblock]" . "_" ;
7006 0           $counterfn++;
7007             }
7008             }
7009 0 0         if ($countblock == 1)
7010             {
7011 0           &def_filenew;
7012 0           @uplift = ($filenew);
7013 0           @downlift = ($filenew);
7014             }
7015            
7016 0           foreach my $el (@varnumbers)
7017             {
7018 0           foreach my $elt (@newvarnumbers)
7019             {
7020 0 0         if ( $el eq $elt)
7021             {
7022 0           push (@overlap, $el);
7023             }
7024             }
7025             }
7026 0           @overlap = sort(@overlap);
7027 0           &exec(\@varnumbers, $countblock, $countcase, \@newvarnumbers, \@uplift, \@downlift, \@blocks, \@blockelts, \@newblockelts, \@overlap);
7028 0           $countblock++;
7029             }
7030             }
7031              
7032 0           $countcase++;
7033             }
7034             elsif ( $generatechance eq "y" )
7035             {
7036             ; # TO DO. ANCHOR1
7037             }
7038             else
7039             {
7040 0           die;
7041             }
7042             }
7043             else
7044             {
7045 0           die; # &exec;
7046             #print OUTFILE "I CALL EXEC AND \@VARNUMBERS IS: " . Dumper(@varnumbers) . "\n";
7047             }
7048              
7049             # END OF THE INSTRUCTIONS LAUNCHING OPTS.
7050             ##########################################################################################
7051             ##########################################################################################
7052              
7053 0           close(OUTFILE);
7054 0           close(TOSHELL);
7055 0           exit;
7056              
7057             } # END OF SUB OPTS
7058             #############################################################################
7059             #############################################################################
7060             #############################################################################
7061              
7062             1;
7063             __END__