#!/usr/bin/perl
#
# create a datafile which can be plotted as a color map 
#    showing one solution to rectangular grid oscillations
#
# MWR 4/15/2019

$mypi = 3.14159;

$nx = 2;
$ny = 2;

$amp = 1.0;

$xmin = 0;
$xmax = 20;
$ymin = 0;
$ymax = 20;
$step = 0.2;

$lx = $xmax - $xmin;
$ly = $ymax - $ymin;

for ($x = $xmin; $x < $xmax; $x += $step) {

  for ($y = $ymin; $y < $ymax; $y += $step) {

    $xmid = $x + ($step/2.0);
    $ymid = $y + ($step/2.0);

    $val = $amp * sin(($nx*$mypi/$lx)*$xmid) * sin(($ny*$mypi/$ly)*$ymid);

    printf " %6.3f %6.3f %6.3f \n", $xmid, $ymid, $val;

  }

  printf "\n";

}


exit 0;
