From 9f5d57f8ab0d8d15edcac597d6f1b2613c820c37 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Fri, 24 Aug 2018 08:28:56 -0400 Subject: [PATCH] Remove the posthocinterpolation example as it didn't showcase vtkm --- examples/CMakeLists.txt | 5 +- examples/posthocinterpolation/CMakeLists.txt | 32 -- .../posthocinterpolation.cxx | 309 ------------------ examples/posthocinterpolation/runScript.sh | 23 -- 4 files changed, 2 insertions(+), 367 deletions(-) delete mode 100644 examples/posthocinterpolation/CMakeLists.txt delete mode 100644 examples/posthocinterpolation/posthocinterpolation.cxx delete mode 100755 examples/posthocinterpolation/runScript.sh diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 009dae29d..6300309d0 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -32,14 +32,13 @@ add_subdirectory(game_of_life) add_subdirectory(hello_world) add_subdirectory(histogram) add_subdirectory(isosurface) +add_subdirectory(lagrangian) add_subdirectory(multi_backend) add_subdirectory(oscillator) add_subdirectory(particle_advection) -add_subdirectory(temporal_advection) add_subdirectory(redistribute_points) add_subdirectory(rendering) add_subdirectory(streamline) +add_subdirectory(temporal_advection) add_subdirectory(tetrahedra) add_subdirectory(unified_memory) -add_subdirectory(lagrangian) -add_subdirectory(posthocinterpolation) diff --git a/examples/posthocinterpolation/CMakeLists.txt b/examples/posthocinterpolation/CMakeLists.txt deleted file mode 100644 index bdfe3570c..000000000 --- a/examples/posthocinterpolation/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -##============================================================================= -## -## Copyright (c) Kitware, Inc. -## All rights reserved. -## See LICENSE.txt for details. -## -## This software is distributed WITHOUT ANY WARRANTY; without even -## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -## PURPOSE. See the above copyright notice for more information. -## -## Copyright 2015 National Technology & Engineering Solutions of Sandia, LLC (NTESS). -## Copyright 2015 UT-Battelle, LLC. -## Copyright 2015 Los Alamos National Security. -## -## Under the terms of Contract DE-NA0003525 with NTESS, -## the U.S. Government retains certain rights in this software. -## Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National -## Laboratory (LANL), the U.S. Government retains certain rights in -## this software. -## -##============================================================================= - -find_package(VTK REQUIRED) -include(${VTK_USE_FILE}) - -#Find the VTK-m package -find_package(VTKm REQUIRED QUIET) - -add_executable(PostHocInterpolation posthocinterpolation.cxx) -target_compile_definitions(PostHocInterpolation PRIVATE "VTKM_DEVICE_ADAPTER=VTKM_DEVICE_ADAPTER_SERIAL") -target_link_libraries(PostHocInterpolation vtkm_cont) -target_link_libraries(PostHocInterpolation ${VTK_LIBRARIES}) diff --git a/examples/posthocinterpolation/posthocinterpolation.cxx b/examples/posthocinterpolation/posthocinterpolation.cxx deleted file mode 100644 index 749e2560a..000000000 --- a/examples/posthocinterpolation/posthocinterpolation.cxx +++ /dev/null @@ -1,309 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -// -// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS). -// Copyright 2014 UT-Battelle, LLC. -// Copyright 2014 Los Alamos National Security. -// -// Under the terms of Contract DE-NA0003525 with NTESS, -// the U.S. Government retains certain rights in this software. -// -// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National -// Laboratory (LANL), the U.S. Government retains certain rights in -// this software. -//============================================================================ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - - -using namespace std; - -vtkSmartPointer generateRandomSeeds(float xmin, - float xmax, - float ymin, - float ymax, - float zmin, - float zmax, - int num_seeds, - string out_path) -{ - vtkSmartPointer seed_points = vtkSmartPointer::New(); - float x, y, z; - - srand(1); - // srand(time(NULL)); - - int xdiff = (int)(xmax - xmin) * 100000; - int ydiff = (int)(ymax - ymin) * 100000; - int zdiff = (int)(zmax - zmin) * 100000; - - for (int i = 0; i < num_seeds; i++) - { - if (xdiff != 0) - x = (float)((rand() % (xdiff)) / 100000.0) + xmin; - else - x = 0.0; - if (ydiff != 0) - y = (float)((rand() % (ydiff)) / 100000.0) + ymin; - else - y = 0.0; - if (zdiff != 0) - z = (float)((rand() % (zdiff)) / 100000.0) + zmin; - else - z = 0.0; - seed_points->InsertNextPoint(x, y, z); - - stringstream file; - file << out_path << "/particle" << (i + 1) << ".lines"; - ofstream ofs; - ofs.open(file.str().c_str(), ofstream::out); - ofs << x << "," << y << "," << z << "\n"; - ofs.close(); - } - - vtkSmartPointer particleMesh = vtkSmartPointer::New(); - particleMesh->SetPoints(seed_points); - return particleMesh; -} - -vtkSmartPointer readSeedInputFile(string in_path, string out_path) -{ - vtkSmartPointer seed_points = vtkSmartPointer::New(); - float x, y, z, t0, tn; - ifstream seed_stream(in_path); - int i = 0; - while (seed_stream >> x) - { - seed_stream >> y; - seed_stream >> z; - seed_stream >> t0; - seed_stream >> tn; - - seed_points->InsertNextPoint(x, y, z); - - stringstream file; - file << out_path << "/particle" << (i + 1) << ".lines"; - ofstream ofs; - ofs.open(file.str().c_str(), ofstream::out); - ofs << x << "," << y << "," << z << "\n"; - ofs.close(); - cout << "Read point : " << x << " " << y << " " << z << endl; - - stringstream filetxt; - filetxt << out_path << "/particle" << (i + 1) << ".txt"; - ofstream ofstxt; - ofstxt.open(filetxt.str().c_str(), ofstream::out); - ofstxt << x << " " << y << " " << z << " " - << "0" - << "\n"; - ofstxt.close(); - - i++; - } - - vtkSmartPointer particleMesh = vtkSmartPointer::New(); - particleMesh->SetPoints(seed_points); - return particleMesh; -} - - - -int main(int argc, char* argv[]) -{ - if (argc != 17) - { - cout << " Usage: " - " " - "" - << endl; - return 1; - } - - string in_path(argv[1]); - string file_name(argv[2]); - int start = atoi(argv[3]); - int end = atoi(argv[4]); - int interval = atoi(argv[5]); - string out_path(argv[6]); - int num_seeds = atoi(argv[7]); - float xmin = (float)atof(argv[8]); - float xmax = (float)atof(argv[9]); - float ymin = (float)atof(argv[10]); - float ymax = (float)atof(argv[11]); - float zmin = (float)atof(argv[12]); - float zmax = (float)atof(argv[13]); - int input_seeds = atoi(argv[14]); - string seed_path(argv[15]); - int num_nodes = atoi(argv[16]); - - vtkSmartPointer particleMesh = vtkSmartPointer::New(); - - if (input_seeds == 0) - { - particleMesh = generateRandomSeeds(xmin, xmax, ymin, ymax, zmin, zmax, num_seeds, out_path); - } - else - { - particleMesh = readSeedInputFile(seed_path, out_path); - } - - // Write out starting location along with output file creation. - // Maybe don't create a mesh directly. - // - int* validSeeds = new int[num_seeds]; - for (int i = 0; i < num_seeds; i++) - validSeeds[i] = 1; - - for (int i = start; i <= end; i += interval) - { - int total_num_flows = 0; - - for (int n = 0; n < num_nodes; n++) - { - stringstream file; - file << in_path << "/" << file_name << "_" << n << "_" << i << ".vtk"; - vtkm::io::reader::VTKDataSetReader reader(file.str().c_str()); - vtkm::cont::DataSet input = reader.ReadDataSet(); - int num_flows = input.GetCellSet().GetNumberOfCells(); - total_num_flows += num_flows; - } - - vtkSmartPointer meshpoints = vtkSmartPointer::New(); - vtkSmartPointer xvec = vtkSmartPointer::New(); - vtkSmartPointer yvec = vtkSmartPointer::New(); - vtkSmartPointer zvec = vtkSmartPointer::New(); - - xvec->SetNumberOfValues(total_num_flows); - yvec->SetNumberOfValues(total_num_flows); - zvec->SetNumberOfValues(total_num_flows); - - cout << "The total number of flows is : " << total_num_flows << endl; - - xvec->SetName("xvec"); - yvec->SetName("yvec"); - zvec->SetName("zvec"); - int flow_counter = 0; - - for (int n = 0; n < num_nodes; n++) - { - stringstream file; - file << in_path << "/" << file_name << "_" << n << "_" << i << ".vtk"; - - cout << "Loading file : " << file.str() << endl; - vtkm::io::reader::VTKDataSetReader reader(file.str().c_str()); - vtkm::cont::DataSet input = reader.ReadDataSet(); - - auto pointArray = input.GetCoordinateSystem().GetData(); - int num_flows = input.GetCellSet(0).GetNumberOfCells(); - - for (int j = 0; j < num_flows; j++) - { - auto pt1 = pointArray.GetPortalConstControl().Get(j * 2 + 0); - auto pt2 = pointArray.GetPortalConstControl().Get(j * 2 + 1); - - meshpoints->InsertNextPoint(pt1[0], pt1[1], pt1[2]); - xvec->SetValue(flow_counter, pt2[0]); - yvec->SetValue(flow_counter, pt2[1]); - zvec->SetValue(flow_counter, pt2[2]); - flow_counter++; - } - } - - vtkSmartPointer mesh = vtkSmartPointer::New(); - mesh->SetPoints(meshpoints); - mesh->GetPointData()->AddArray(xvec); - mesh->GetPointData()->AddArray(yvec); - mesh->GetPointData()->AddArray(zvec); - - cout << "Added arrays and points to unstructured grid" << endl; - - vtkSmartPointer triangulation = vtkSmartPointer::New(); - triangulation->SetInputData(mesh); - triangulation->Update(); - - cout << "Completed triangulation" << endl; - - vtkSmartPointer flowMesh = vtkSmartPointer::New(); - flowMesh = triangulation->GetOutput(); - - vtkSmartPointer probe = vtkSmartPointer::New(); - - probe->SetSourceData(flowMesh); - probe->SetInputData(particleMesh); - probe->Update(); - - vtkSmartPointer validInterpolations = vtkSmartPointer::New(); - validInterpolations->DeepCopy( - probe->GetOutput()->GetPointData()->GetArray(probe->GetValidPointMaskArrayName())); - - vtkSmartPointer xlocation = - vtkDoubleArray::SafeDownCast(probe->GetOutput()->GetPointData()->GetArray("xvec")); - vtkSmartPointer ylocation = - vtkDoubleArray::SafeDownCast(probe->GetOutput()->GetPointData()->GetArray("yvec")); - vtkSmartPointer zlocation = - vtkDoubleArray::SafeDownCast(probe->GetOutput()->GetPointData()->GetArray("zvec")); - - vtkSmartPointer new_locations = vtkSmartPointer::New(); - - for (int k = 0; k < num_seeds; k++) - { - if (validSeeds[k]) - { - if (validInterpolations->GetValue(k)) - { - { - stringstream filetxt; - filetxt << out_path << "/particle" << (k + 1) << ".txt"; - ofstream ofstxt; - ofstxt.open(filetxt.str().c_str(), ofstream::out | ofstream::app); - ofstxt << xlocation->GetValue(k) << " " << ylocation->GetValue(k) << " " - << zlocation->GetValue(k) << " " << i << "\n"; - ofstxt.close(); - } - // Write location to file. - { - stringstream file2; - file2 << out_path << "/particle" << (k + 1) << ".lines"; - ofstream ofs; - ofs.open(file2.str().c_str(), ofstream::out | ofstream::app); - ofs << xlocation->GetValue(k) << "," << ylocation->GetValue(k) << "," - << zlocation->GetValue(k) << "\n"; - ofs.close(); - } - } - else - { - validSeeds[k] = 0; - } - } - new_locations->InsertNextPoint( - xlocation->GetValue(k), ylocation->GetValue(k), zlocation->GetValue(k)); - } - particleMesh->SetPoints(new_locations); - } // Loop over all input files - - return 0; -} diff --git a/examples/posthocinterpolation/runScript.sh b/examples/posthocinterpolation/runScript.sh deleted file mode 100755 index eb26998d5..000000000 --- a/examples/posthocinterpolation/runScript.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -NUM_NODES="1" -INTERVAL="" #write frequency -INPUT="" #path to input basis flows -FILENAME="basisflows" -START=$INTERVAL -END="" #end time -OUTPUT="output" -NUMSEEDS="" #number of seeds -XMIN="" #data set bounds -XMAX="" -YMIN="" -YMAX="" -ZMIN="" -ZMAX="" -INPUT_SEEDS="1" #use input seed file (1) or generate random seeds in the domain (0) -SEED_FILE="" #path to seed file X Y Z T0 TN .. T0 -- seed start time TN -- seed end time. Implementation not available yet - - -rm -rf output -mkdir output -./PostHocInterpolation $INPUT $FILENAME $START $END $INTERVAL $OUTPUT $NUMSEEDS $XMIN $XMAX $YMIN $YMAX $ZMIN $ZMAX $INPUT_SEEDS $SEED_FILE $NUM_NODES