mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-05 01:49:02 +00:00
ad1e7b5bdb
This mechanism sets up CMake variables that allow a user to select which modules/libraries to create. Dependencies will be tracked down to ensure that all of a module's dependencies are also enabled. The modules are also arranged into groups. Groups allow you to set the enable flag for a group of modules at once. Thus, if you have several modules that are likely to be used together, you can create a group for them. This can be handy in converting user-friendly CMake options (such as `VTKm_ENABLE_RENDERING`) to the modules that enable that by pointing to the appropriate group.
94 lines
2.6 KiB
C++
94 lines
2.6 KiB
C++
//============================================================================
|
|
// 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.
|
|
//============================================================================
|
|
|
|
#include "ABCfield.h"
|
|
#include <iostream>
|
|
#include <vector>
|
|
#include <vtkm/Types.h>
|
|
#include <vtkm/cont/ArrayHandle.h>
|
|
#include <vtkm/cont/DataSet.h>
|
|
#include <vtkm/cont/DataSetBuilderUniform.h>
|
|
#include <vtkm/cont/Initialize.h>
|
|
#include <vtkm/filter/flow/Lagrangian.h>
|
|
|
|
using namespace std;
|
|
|
|
vtkm::cont::DataSet make3DUniformDataSet(double time)
|
|
{
|
|
ABCfield field;
|
|
|
|
double xmin, xmax, ymin, ymax, zmin, zmax;
|
|
xmin = 0.0;
|
|
ymin = 0.0;
|
|
zmin = 0.0;
|
|
|
|
xmax = 6.28;
|
|
ymax = 6.28;
|
|
zmax = 6.28;
|
|
|
|
int dims[3] = { 16, 16, 16 };
|
|
|
|
vtkm::cont::DataSetBuilderUniform dsb;
|
|
|
|
double xdiff = (xmax - xmin) / (dims[0] - 1);
|
|
double ydiff = (ymax - ymin) / (dims[1] - 1);
|
|
double zdiff = (zmax - zmin) / (dims[2] - 1);
|
|
|
|
vtkm::Id3 DIMS(dims[0], dims[1], dims[2]);
|
|
vtkm::Vec3f_64 ORIGIN(0, 0, 0);
|
|
vtkm::Vec3f_64 SPACING(xdiff, ydiff, zdiff);
|
|
|
|
vtkm::cont::DataSet dataset = dsb.Create(DIMS, ORIGIN, SPACING);
|
|
|
|
int numPoints = dims[0] * dims[1] * dims[2];
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::Vec3f_64> velocityField;
|
|
velocityField.Allocate(numPoints);
|
|
|
|
int count = 0;
|
|
for (int i = 0; i < dims[0]; i++)
|
|
{
|
|
for (int j = 0; j < dims[1]; j++)
|
|
{
|
|
for (int k = 0; k < dims[2]; k++)
|
|
{
|
|
double vec[3];
|
|
double loc[3] = { i * xdiff + xmin, j * ydiff + ymax, k * zdiff + zmin };
|
|
field.calculateVelocity(loc, time, vec);
|
|
velocityField.WritePortal().Set(count, vtkm::Vec3f_64(vec[0], vec[1], vec[2]));
|
|
count++;
|
|
}
|
|
}
|
|
}
|
|
dataset.AddPointField("velocity", velocityField);
|
|
return dataset;
|
|
}
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
auto opts =
|
|
vtkm::cont::InitializeOptions::DefaultAnyDevice | vtkm::cont::InitializeOptions::Strict;
|
|
vtkm::cont::Initialize(argc, argv, opts);
|
|
|
|
vtkm::filter::flow::Lagrangian lagrangianFilter;
|
|
lagrangianFilter.SetResetParticles(true);
|
|
vtkm::Float32 stepSize = 0.01f;
|
|
lagrangianFilter.SetStepSize(stepSize);
|
|
lagrangianFilter.SetWriteFrequency(10);
|
|
for (int i = 0; i < 100; i++)
|
|
{
|
|
vtkm::cont::DataSet inputData = make3DUniformDataSet((double)i * stepSize);
|
|
lagrangianFilter.SetActiveField("velocity");
|
|
vtkm::cont::DataSet extractedBasisFlows = lagrangianFilter.Execute(inputData);
|
|
}
|
|
return 0;
|
|
}
|