//
// TestVis5DCluster.java
//

/*
VisAD system for interactive analysis and visualization of numerical
data.  Copyright (C) 1996 - 2017 Bill Hibbard, Curtis Rueden, Tom
Rink, Dave Glowacki, Steve Emmerson, Tom Whittaker, Don Murray, and
Tommy Jasmin.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/

package visad.cluster;

import visad.*;
import visad.java3d.*;
import visad.java2d.*;
import visad.util.ContourWidget;
import visad.util.AnimationWidget;
import visad.data.vis5d.Vis5DForm;

import java.rmi.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.IOException;

/**
   TestVis5DCluster is the class for testing the visad.cluster package.

*/ public class TestVis5DCluster extends Object { public TestVis5DCluster() { } public static void main(String[] args) throws RemoteException, VisADException, IOException { int node_divide = 2; int number_of_nodes = node_divide * node_divide; RemoteNodeField[] node_v5ds = new RemoteNodeField[number_of_nodes]; if (args == null || args.length < 2) { System.out.println("usage: 'java visad.cluster.TestVis5DCluster " + "n file.v5d'"); System.out.println(" where n = 0 for client, 1 - " + number_of_nodes + " for nodes"); return; } int id = -1; try { id = Integer.parseInt(args[0]); } catch (NumberFormatException e) { System.out.println("usage: 'java visad.cluster.TestVis5DCluster " + "n file.v5d'"); System.out.println(" where n = 0 for client, 1 - " + number_of_nodes + " for nodes"); return; } if (id < 0 || id > number_of_nodes) { System.out.println("usage: 'java visad.cluster.TestVis5DCluster " + "n file.v5d'"); System.out.println(" where n = 0 for client, 1 - " + number_of_nodes + " for nodes"); return; } boolean client = (id == 0); Vis5DForm v5d_form = new Vis5DForm(); FieldImpl v5d = (FieldImpl) v5d_form.open(args[1]); if (v5d == null) { System.out.println("cannot open " + args[1]); return; } FunctionType v5d_type = (FunctionType) v5d.getType(); Set time_set = v5d.getDomainSet(); int time_length = time_set.getLength(); MathType v5d_range_type = v5d_type.getRange(); DataImpl v5d_range0 = (DataImpl) v5d.getSample(0); FunctionType grid_type = null; FunctionType grid_type2 = null; FlatField grid0 = null; if (v5d_range_type instanceof FunctionType) { grid_type = (FunctionType) v5d_range_type; grid_type2 = null; grid0 = (FlatField) v5d_range0; } else { grid_type = (FunctionType) ((TupleType) v5d_range_type).getComponent(0); grid_type2 = (FunctionType) ((TupleType) v5d_range_type).getComponent(1); grid0 = (FlatField) ((Tuple) v5d_range0).getComponent(0); } Gridded3DSet domain_set = (Gridded3DSet) grid0.getDomainSet(); Gridded3DSet ps = makePS(domain_set, node_divide); if (!client) { System.out.println("v5d_type = " + v5d_type); RealTupleType domain_type = grid_type.getDomain(); RealTupleType time_tuple = v5d_type.getDomain(); RealType time = (RealType) time_tuple.getComponent(0); RealType x = (RealType) domain_type.getComponent(0); RealType y = (RealType) domain_type.getComponent(1); RealType z = (RealType) domain_type.getComponent(2); RealType val = (RealType) grid_type.getRange(); RealType val2 = (grid_type2 == null) ? null : (RealType) grid_type2.getRange(); float[][] samples = domain_set.getSamples(false); int x_len = domain_set.getLength(0); int y_len = domain_set.getLength(1); int z_len = domain_set.getLength(2); int len = domain_set.getLength(); Gridded3DSet[] subsets = new Gridded3DSet[number_of_nodes]; int k = id - 1; int ik = k % node_divide; int ig = ik * x_len / node_divide; int igp = (ik + 1) * x_len / node_divide; if (ik == (node_divide - 1)) igp = x_len; int jk = k / node_divide; int jg = jk * y_len / node_divide; int jgp = (jk + 1) * y_len / node_divide; if (jk == (node_divide - 1)) jgp = y_len; int sub_x_len = igp - ig; int sub_y_len = jgp - jg; int sub_len = sub_x_len * sub_y_len * z_len; // System.out.println("sub_len = " + sub_len + " out of len = " + len); float[][] sub_samples = new float[3][sub_len]; for (int i=0; i

Ads help maintain this website.