mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-05 01:49:02 +00:00
Convert LagrangianStructures filter to NewFilter
This commit is contained in:
parent
3ae5302c3d
commit
ee31217da5
@ -17,7 +17,7 @@
|
||||
#include <vtkm/cont/DataSetBuilderRectilinear.h>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/cont/Initialize.h>
|
||||
#include <vtkm/filter/Lagrangian.h>
|
||||
#include <vtkm/filter/flow/Lagrangian.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -79,7 +79,7 @@ int main(int argc, char** argv)
|
||||
vtkm::cont::InitializeOptions::DefaultAnyDevice | vtkm::cont::InitializeOptions::Strict;
|
||||
vtkm::cont::Initialize(argc, argv, opts);
|
||||
|
||||
vtkm::filter::Lagrangian lagrangianFilter;
|
||||
vtkm::filter::flow::Lagrangian lagrangianFilter;
|
||||
lagrangianFilter.SetResetParticles(true);
|
||||
vtkm::Float32 stepSize = 0.01f;
|
||||
lagrangianFilter.SetStepSize(stepSize);
|
||||
|
@ -39,6 +39,8 @@ set(deprecated_headers
|
||||
ImageDifference.h
|
||||
ImageMedian.h
|
||||
Instantiations.h
|
||||
Lagrangian.h
|
||||
LagrangianStructures.h
|
||||
Mask.h
|
||||
MaskPoints.h
|
||||
MeshQuality.h
|
||||
@ -89,8 +91,6 @@ set(common_headers
|
||||
FilterTraits.h
|
||||
PolicyBase.h
|
||||
PolicyDefault.h
|
||||
Lagrangian.h
|
||||
LagrangianStructures.h
|
||||
)
|
||||
|
||||
vtkm_declare_headers(${common_headers})
|
||||
@ -100,8 +100,6 @@ set(common_header_template_sources
|
||||
FilterDataSetWithField.hxx
|
||||
FilterField.hxx
|
||||
Filter.hxx
|
||||
Lagrangian.hxx
|
||||
LagrangianStructures.hxx
|
||||
)
|
||||
|
||||
vtkm_declare_headers(${common_header_template_sources})
|
||||
|
@ -7,97 +7,26 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_Lagrangian_h
|
||||
#define vtk_m_filter_Lagrangian_h
|
||||
|
||||
#include <vtkm/filter/FilterDataSetWithField.h>
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/filter/flow/Lagrangian.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
class Lagrangian : public vtkm::filter::FilterDataSetWithField<Lagrangian>
|
||||
VTKM_DEPRECATED(1.8, "Use vtkm/filter/flow/Lagrangian.h instead of vtkm/filter/Lagrangian.h")
|
||||
inline void Lagrangian_deprecated() {}
|
||||
|
||||
inline void Lagrangian_deprecated_warning()
|
||||
{
|
||||
public:
|
||||
using SupportedTypes = vtkm::TypeListFieldVec3;
|
||||
|
||||
VTKM_CONT
|
||||
Lagrangian();
|
||||
|
||||
VTKM_CONT
|
||||
void SetRank(vtkm::Id val) { this->rank = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetInitFlag(bool val) { this->initFlag = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetExtractFlows(bool val) { this->extractFlows = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetResetParticles(bool val) { this->resetParticles = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetStepSize(vtkm::Float32 val) { this->stepSize = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetWriteFrequency(vtkm::Id val) { this->writeFrequency = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetSeedResolutionInX(vtkm::Id val) { this->x_res = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetSeedResolutionInY(vtkm::Id val) { this->y_res = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetSeedResolutionInZ(vtkm::Id val) { this->z_res = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetCustomSeedResolution(vtkm::Id val) { this->cust_res = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetSeedingResolution(vtkm::Id3 val) { this->SeedRes = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void UpdateSeedResolution(vtkm::cont::DataSet input);
|
||||
|
||||
VTKM_CONT
|
||||
void InitializeSeedPositions(const vtkm::cont::DataSet& input);
|
||||
|
||||
VTKM_CONT
|
||||
void InitializeCoordinates(const vtkm::cont::DataSet& input,
|
||||
std::vector<Float64>& xC,
|
||||
std::vector<Float64>& yC,
|
||||
std::vector<Float64>& zC);
|
||||
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(
|
||||
const vtkm::cont::DataSet& input,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& field,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||
|
||||
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||
|
||||
private:
|
||||
vtkm::Id rank;
|
||||
bool initFlag;
|
||||
bool extractFlows;
|
||||
bool resetParticles;
|
||||
vtkm::Float32 stepSize;
|
||||
vtkm::Id x_res, y_res, z_res;
|
||||
vtkm::Id cust_res;
|
||||
vtkm::Id3 SeedRes;
|
||||
vtkm::Id writeFrequency;
|
||||
};
|
||||
Lagrangian_deprecated();
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
#include <vtkm/filter/Lagrangian.hxx>
|
||||
}
|
||||
}
|
||||
|
||||
#endif // vtk_m_filter_Lagrangian_h
|
||||
#endif //vtk_m_filter_Lagrangian_h
|
||||
|
@ -1,9 +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.
|
||||
//============================================================================
|
@ -7,85 +7,28 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_LagrangianStructures_h
|
||||
#define vtk_m_filter_LagrangianStructures_h
|
||||
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
|
||||
#include <vtkm/filter/FilterDataSetWithField.h>
|
||||
|
||||
#include <vtkm/filter/flow/worklet/GridEvaluators.h>
|
||||
#include <vtkm/filter/flow/worklet/ParticleAdvection.h>
|
||||
#include <vtkm/filter/flow/worklet/Stepper.h>
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/filter/flow/LagrangianStructures.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
class LagrangianStructures : public vtkm::filter::FilterDataSetWithField<LagrangianStructures>
|
||||
VTKM_DEPRECATED(
|
||||
1.8,
|
||||
"Use vtkm/filter/flow/LagrangianStructures.h instead of vtkm/filter/LagrangianStructures.h")
|
||||
inline void LagrangianStructures_deprecated() {}
|
||||
|
||||
inline void LagrangianStructures_deprecated_warning()
|
||||
{
|
||||
public:
|
||||
using SupportedTypes = vtkm::TypeListFieldVec3;
|
||||
LagrangianStructures_deprecated();
|
||||
}
|
||||
|
||||
LagrangianStructures();
|
||||
}
|
||||
}
|
||||
|
||||
void SetStepSize(vtkm::FloatDefault s) { this->StepSize = s; }
|
||||
vtkm::FloatDefault GetStepSize() { return this->StepSize; }
|
||||
|
||||
void SetNumberOfSteps(vtkm::Id n) { this->NumberOfSteps = n; }
|
||||
vtkm::Id GetNumberOfSteps() { return this->NumberOfSteps; }
|
||||
|
||||
void SetAdvectionTime(vtkm::FloatDefault advectionTime) { this->AdvectionTime = advectionTime; }
|
||||
vtkm::FloatDefault GetAdvectionTime() { return this->AdvectionTime; }
|
||||
|
||||
void SetUseAuxiliaryGrid(bool useAuxiliaryGrid) { this->UseAuxiliaryGrid = useAuxiliaryGrid; }
|
||||
bool GetUseAuxiliaryGrid() { return this->UseAuxiliaryGrid; }
|
||||
|
||||
void SetAuxiliaryGridDimensions(vtkm::Id3 auxiliaryDims) { this->AuxiliaryDims = auxiliaryDims; }
|
||||
vtkm::Id3 GetAuxiliaryGridDimensions() { return this->AuxiliaryDims; }
|
||||
|
||||
void SetUseFlowMapOutput(bool useFlowMapOutput) { this->UseFlowMapOutput = useFlowMapOutput; }
|
||||
bool GetUseFlowMapOutput() { return this->UseFlowMapOutput; }
|
||||
|
||||
void SetOutputFieldName(std::string outputFieldName) { this->OutputFieldName = outputFieldName; }
|
||||
std::string GetOutputFieldName() { return this->OutputFieldName; }
|
||||
|
||||
inline void SetFlowMapOutput(vtkm::cont::ArrayHandle<vtkm::Vec3f>& flowMap)
|
||||
{
|
||||
this->FlowMapOutput = flowMap;
|
||||
}
|
||||
inline vtkm::cont::ArrayHandle<vtkm::Vec3f> GetFlowMapOutput() { return this->FlowMapOutput; }
|
||||
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(
|
||||
const vtkm::cont::DataSet& input,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& field,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
||||
|
||||
//Map a new field onto the resulting dataset after running the filter
|
||||
//this call is only valid after calling DoExecute
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||
|
||||
private:
|
||||
vtkm::FloatDefault StepSize;
|
||||
vtkm::Id NumberOfSteps;
|
||||
vtkm::FloatDefault AdvectionTime;
|
||||
bool UseAuxiliaryGrid = false;
|
||||
vtkm::Id3 AuxiliaryDims;
|
||||
bool UseFlowMapOutput = false;
|
||||
std::string OutputFieldName;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> FlowMapOutput;
|
||||
};
|
||||
|
||||
} // namespace filter
|
||||
} // namespace vtkm
|
||||
|
||||
#include <vtkm/filter/LagrangianStructures.hxx>
|
||||
|
||||
#endif // vtk_m_filter_LagrangianStructures_h
|
||||
#endif //vtk_m_filter_LagrangnianStructures_h
|
||||
|
@ -7,11 +7,14 @@
|
||||
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
## PURPOSE. See the above copyright notice for more information.
|
||||
##============================================================================
|
||||
|
||||
set(flow_headers
|
||||
FlowTypes.h
|
||||
NewFilterParticleAdvection.h
|
||||
NewFilterParticleAdvectionSteadyState.h
|
||||
NewFilterParticleAdvectionUnsteadyState.h
|
||||
Lagrangian.h
|
||||
LagrangianStructures.h
|
||||
ParticleAdvection.h
|
||||
Pathline.h
|
||||
PathParticle.h
|
||||
@ -29,6 +32,8 @@ set(flow_sources
|
||||
)
|
||||
|
||||
set(flow_device_sources
|
||||
Lagrangian.cxx
|
||||
LagrangianStructures.cxx
|
||||
NewFilterParticleAdvectionSteadyState.cxx
|
||||
NewFilterParticleAdvectionUnsteadyState.cxx
|
||||
StreamSurface.cxx
|
||||
|
@ -8,35 +8,23 @@
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_Lagrangian_hxx
|
||||
#define vtk_m_filter_Lagrangian_hxx
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayHandleIndex.h>
|
||||
#include <vtkm/cont/ArrayPortalToIterators.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DataSetBuilderExplicit.h>
|
||||
#include <vtkm/cont/DataSetBuilderRectilinear.h>
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
#include <vtkm/cont/ErrorFilterExecution.h>
|
||||
|
||||
#include <vtkm/filter/flow/Lagrangian.h>
|
||||
#include <vtkm/filter/flow/worklet/Field.h>
|
||||
#include <vtkm/filter/flow/worklet/GridEvaluators.h>
|
||||
#include <vtkm/filter/flow/worklet/ParticleAdvection.h>
|
||||
#include <vtkm/filter/flow/worklet/Particles.h>
|
||||
#include <vtkm/filter/flow/worklet/RK4Integrator.h>
|
||||
#include <vtkm/filter/flow/worklet/Stepper.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <string.h>
|
||||
|
||||
static vtkm::Id cycle = 0;
|
||||
static vtkm::cont::ArrayHandle<vtkm::Particle> BasisParticles;
|
||||
static vtkm::cont::ArrayHandle<vtkm::Particle> BasisParticlesOriginal;
|
||||
static vtkm::cont::ArrayHandle<vtkm::Id> BasisParticlesValidity;
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
namespace flow
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -96,30 +84,8 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline VTKM_CONT Lagrangian::Lagrangian()
|
||||
: vtkm::filter::FilterDataSetWithField<Lagrangian>()
|
||||
, rank(0)
|
||||
, initFlag(true)
|
||||
, extractFlows(false)
|
||||
, resetParticles(true)
|
||||
, stepSize(1.0f)
|
||||
, x_res(0)
|
||||
, y_res(0)
|
||||
, z_res(0)
|
||||
, cust_res(0)
|
||||
, SeedRes(vtkm::Id3(1, 1, 1))
|
||||
, writeFrequency(0)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline void Lagrangian::UpdateSeedResolution(const vtkm::cont::DataSet input)
|
||||
void Lagrangian::UpdateSeedResolution(const vtkm::cont::DataSet input)
|
||||
{
|
||||
vtkm::cont::UnknownCellSet cell_set = input.GetCellSet();
|
||||
|
||||
@ -129,9 +95,9 @@ inline void Lagrangian::UpdateSeedResolution(const vtkm::cont::DataSet input)
|
||||
cell_set.AsCellSet<vtkm::cont::CellSetStructured<1>>();
|
||||
vtkm::Id dims1 = cell_set1.GetPointDimensions();
|
||||
this->SeedRes[0] = dims1;
|
||||
if (this->cust_res)
|
||||
if (this->CustRes)
|
||||
{
|
||||
this->SeedRes[0] = dims1 / this->x_res;
|
||||
this->SeedRes[0] = dims1 / this->ResX;
|
||||
}
|
||||
}
|
||||
else if (cell_set.CanConvert<vtkm::cont::CellSetStructured<2>>())
|
||||
@ -141,10 +107,10 @@ inline void Lagrangian::UpdateSeedResolution(const vtkm::cont::DataSet input)
|
||||
vtkm::Id2 dims2 = cell_set2.GetPointDimensions();
|
||||
this->SeedRes[0] = dims2[0];
|
||||
this->SeedRes[1] = dims2[1];
|
||||
if (this->cust_res)
|
||||
if (this->CustRes)
|
||||
{
|
||||
this->SeedRes[0] = dims2[0] / this->x_res;
|
||||
this->SeedRes[1] = dims2[1] / this->y_res;
|
||||
this->SeedRes[0] = dims2[0] / this->ResX;
|
||||
this->SeedRes[1] = dims2[1] / this->ResY;
|
||||
}
|
||||
}
|
||||
else if (cell_set.CanConvert<vtkm::cont::CellSetStructured<3>>())
|
||||
@ -155,18 +121,18 @@ inline void Lagrangian::UpdateSeedResolution(const vtkm::cont::DataSet input)
|
||||
this->SeedRes[0] = dims3[0];
|
||||
this->SeedRes[1] = dims3[1];
|
||||
this->SeedRes[2] = dims3[2];
|
||||
if (this->cust_res)
|
||||
if (this->CustRes)
|
||||
{
|
||||
this->SeedRes[0] = dims3[0] / this->x_res;
|
||||
this->SeedRes[1] = dims3[1] / this->y_res;
|
||||
this->SeedRes[2] = dims3[2] / this->z_res;
|
||||
this->SeedRes[0] = dims3[0] / this->ResX;
|
||||
this->SeedRes[1] = dims3[1] / this->ResY;
|
||||
this->SeedRes[2] = dims3[2] / this->ResZ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline void Lagrangian::InitializeSeedPositions(const vtkm::cont::DataSet& input)
|
||||
void Lagrangian::InitializeSeedPositions(const vtkm::cont::DataSet& input)
|
||||
{
|
||||
vtkm::Bounds bounds = input.GetCoordinateSystem().GetBounds();
|
||||
|
||||
@ -181,11 +147,11 @@ inline void Lagrangian::InitializeSeedPositions(const vtkm::cont::DataSet& input
|
||||
z_spacing = (double)(bounds.Z.Max - bounds.Z.Min) / (double)(this->SeedRes[2] - 1);
|
||||
// Divide by zero handling for 2D data set. How is this handled
|
||||
|
||||
BasisParticles.Allocate(this->SeedRes[0] * this->SeedRes[1] * this->SeedRes[2]);
|
||||
BasisParticlesValidity.Allocate(this->SeedRes[0] * this->SeedRes[1] * this->SeedRes[2]);
|
||||
this->BasisParticles.Allocate(this->SeedRes[0] * this->SeedRes[1] * this->SeedRes[2]);
|
||||
this->BasisParticlesValidity.Allocate(this->SeedRes[0] * this->SeedRes[1] * this->SeedRes[2]);
|
||||
|
||||
auto portal1 = BasisParticles.WritePortal();
|
||||
auto portal2 = BasisParticlesValidity.WritePortal();
|
||||
auto portal1 = this->BasisParticles.WritePortal();
|
||||
auto portal2 = this->BasisParticlesValidity.WritePortal();
|
||||
|
||||
vtkm::Id id = 0;
|
||||
for (int z = 0; z < this->SeedRes[2]; z++)
|
||||
@ -210,10 +176,10 @@ inline void Lagrangian::InitializeSeedPositions(const vtkm::cont::DataSet& input
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline void Lagrangian::InitializeCoordinates(const vtkm::cont::DataSet& input,
|
||||
std::vector<Float64>& xC,
|
||||
std::vector<Float64>& yC,
|
||||
std::vector<Float64>& zC)
|
||||
void Lagrangian::InitializeCoordinates(const vtkm::cont::DataSet& input,
|
||||
std::vector<Float64>& xC,
|
||||
std::vector<Float64>& yC,
|
||||
std::vector<Float64>& zC)
|
||||
{
|
||||
vtkm::Bounds bounds = input.GetCoordinateSystem().GetBounds();
|
||||
|
||||
@ -244,36 +210,29 @@ inline void Lagrangian::InitializeCoordinates(const vtkm::cont::DataSet& input,
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
inline VTKM_CONT vtkm::cont::DataSet Lagrangian::DoExecute(
|
||||
const vtkm::cont::DataSet& input,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& field,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy>)
|
||||
VTKM_CONT vtkm::cont::DataSet Lagrangian::DoExecute(const vtkm::cont::DataSet& input)
|
||||
{
|
||||
|
||||
if (cycle == 0)
|
||||
if (this->Cycle == 0)
|
||||
{
|
||||
InitializeSeedPositions(input);
|
||||
BasisParticlesOriginal.Allocate(this->SeedRes[0] * this->SeedRes[1] * this->SeedRes[2]);
|
||||
vtkm::cont::ArrayCopy(BasisParticles, BasisParticlesOriginal);
|
||||
this->InitializeSeedPositions(input);
|
||||
vtkm::cont::ArrayCopy(this->BasisParticles, this->BasisParticlesOriginal);
|
||||
}
|
||||
|
||||
if (this->writeFrequency == 0)
|
||||
if (this->WriteFrequency == 0)
|
||||
{
|
||||
throw vtkm::cont::ErrorFilterExecution(
|
||||
"Write frequency can not be 0. Use SetWriteFrequency().");
|
||||
}
|
||||
vtkm::cont::ArrayHandle<vtkm::Particle> basisParticleArray;
|
||||
vtkm::cont::ArrayCopy(BasisParticles, basisParticleArray);
|
||||
vtkm::cont::ArrayCopy(this->BasisParticles, basisParticleArray);
|
||||
|
||||
cycle += 1;
|
||||
this->Cycle += 1;
|
||||
const vtkm::cont::UnknownCellSet& cells = input.GetCellSet();
|
||||
const vtkm::cont::CoordinateSystem& coords =
|
||||
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
|
||||
vtkm::Bounds bounds = input.GetCoordinateSystem().GetBounds();
|
||||
|
||||
using FieldHandle = vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>;
|
||||
using FieldHandle = vtkm::cont::ArrayHandle<vtkm::Vec3f>;
|
||||
using FieldType = vtkm::worklet::flow::VelocityField<FieldHandle>;
|
||||
using GridEvalType = vtkm::worklet::flow::GridEvaluator<FieldType>;
|
||||
using RK4Type = vtkm::worklet::flow::RK4Integrator<GridEvalType>;
|
||||
@ -282,9 +241,12 @@ inline VTKM_CONT vtkm::cont::DataSet Lagrangian::DoExecute(
|
||||
vtkm::worklet::flow::ParticleAdvection particleadvection;
|
||||
vtkm::worklet::flow::ParticleAdvectionResult<vtkm::Particle> res;
|
||||
|
||||
FieldType velocities(field, fieldMeta.GetAssociation());
|
||||
const auto field = input.GetField(this->GetActiveFieldName());
|
||||
FieldType velocities(field.GetData().AsArrayHandle<vtkm::cont::ArrayHandle<vtkm::Vec3f>>(),
|
||||
field.GetAssociation());
|
||||
|
||||
GridEvalType gridEval(coords, cells, velocities);
|
||||
Stepper rk4(gridEval, static_cast<vtkm::Float32>(this->stepSize));
|
||||
Stepper rk4(gridEval, static_cast<vtkm::Float32>(this->StepSize));
|
||||
|
||||
res = particleadvection.Run(rk4, basisParticleArray, 1); // Taking a single step
|
||||
auto particles = res.Particles;
|
||||
@ -292,58 +254,76 @@ inline VTKM_CONT vtkm::cont::DataSet Lagrangian::DoExecute(
|
||||
vtkm::cont::DataSet outputData;
|
||||
vtkm::cont::DataSetBuilderRectilinear dataSetBuilder;
|
||||
|
||||
if (cycle % this->writeFrequency == 0)
|
||||
if (this->Cycle % this->WriteFrequency == 0)
|
||||
{
|
||||
/* Steps to create a structured dataset */
|
||||
UpdateSeedResolution(input);
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> BasisParticlesDisplacement;
|
||||
BasisParticlesDisplacement.Allocate(this->SeedRes[0] * this->SeedRes[1] * this->SeedRes[2]);
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> basisParticlesDisplacement;
|
||||
basisParticlesDisplacement.Allocate(this->SeedRes[0] * this->SeedRes[1] * this->SeedRes[2]);
|
||||
DisplacementCalculation displacement;
|
||||
this->Invoke(displacement, particles, BasisParticlesOriginal, BasisParticlesDisplacement);
|
||||
this->Invoke(displacement, particles, this->BasisParticlesOriginal, basisParticlesDisplacement);
|
||||
std::vector<Float64> xC, yC, zC;
|
||||
InitializeCoordinates(input, xC, yC, zC);
|
||||
outputData = dataSetBuilder.Create(xC, yC, zC);
|
||||
outputData.AddPointField("valid", BasisParticlesValidity);
|
||||
outputData.AddPointField("displacement", BasisParticlesDisplacement);
|
||||
outputData.AddPointField("valid", this->BasisParticlesValidity);
|
||||
outputData.AddPointField("displacement", basisParticlesDisplacement);
|
||||
|
||||
if (this->resetParticles)
|
||||
if (this->ResetParticles)
|
||||
{
|
||||
InitializeSeedPositions(input);
|
||||
BasisParticlesOriginal.Allocate(this->SeedRes[0] * this->SeedRes[1] * this->SeedRes[2]);
|
||||
vtkm::cont::ArrayCopy(BasisParticles, BasisParticlesOriginal);
|
||||
this->InitializeSeedPositions(input);
|
||||
vtkm::cont::ArrayCopy(this->BasisParticles, this->BasisParticlesOriginal);
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::cont::ArrayCopy(particles, BasisParticles);
|
||||
vtkm::cont::ArrayCopy(particles, this->BasisParticles);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ValidityCheck check(bounds);
|
||||
this->Invoke(check, particles, BasisParticlesValidity);
|
||||
vtkm::cont::ArrayCopy(particles, BasisParticles);
|
||||
this->Invoke(check, particles, this->BasisParticlesValidity);
|
||||
vtkm::cont::ArrayCopy(particles, this->BasisParticles);
|
||||
}
|
||||
|
||||
return outputData;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
template <typename DerivedPolicy>
|
||||
inline VTKM_CONT bool Lagrangian::MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy>)
|
||||
{
|
||||
if (field.IsWholeDataSetField())
|
||||
{
|
||||
result.AddField(field);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} //vtkm::filter::flow
|
||||
|
||||
|
||||
//Deprecated filter: vtkm::filter::Lagrangian
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
static vtkm::Id deprecatedLagrange_Cycle = 0;
|
||||
static vtkm::cont::ArrayHandle<vtkm::Particle> deprecatedLagrange_BasisParticles;
|
||||
static vtkm::cont::ArrayHandle<vtkm::Particle> deprecatedLagrange_BasisParticlesOriginal;
|
||||
static vtkm::cont::ArrayHandle<vtkm::Id> deprecatedLagrange_BasisParticlesValidity;
|
||||
|
||||
|
||||
VTKM_CONT vtkm::cont::DataSet Lagrangian::DoExecute(const vtkm::cont::DataSet& input)
|
||||
{
|
||||
//Initialize the filter with the static variables
|
||||
this->SetCycle(deprecatedLagrange_Cycle);
|
||||
this->SetBasisParticles(deprecatedLagrange_BasisParticles);
|
||||
this->SetBasisParticlesOriginal(deprecatedLagrange_BasisParticlesOriginal);
|
||||
this->SetBasisParticleValidity(deprecatedLagrange_BasisParticlesValidity);
|
||||
|
||||
//call the base class
|
||||
auto output = vtkm::filter::flow::Lagrangian::DoExecute(input);
|
||||
|
||||
//Set the static variables with the current values.
|
||||
deprecatedLagrange_Cycle = this->GetCycle();
|
||||
deprecatedLagrange_BasisParticles = this->GetBasisParticles();
|
||||
deprecatedLagrange_BasisParticlesOriginal = this->GetBasisParticlesOriginal();
|
||||
deprecatedLagrange_BasisParticlesValidity = this->GetBasisParticleValidity();
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
#endif
|
157
vtkm/filter/flow/Lagrangian.h
Normal file
157
vtkm/filter/flow/Lagrangian.h
Normal file
@ -0,0 +1,157 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_flow_Lagrangian_h
|
||||
#define vtk_m_filter_flow_Lagrangian_h
|
||||
|
||||
#include <vtkm/Particle.h>
|
||||
#include <vtkm/filter/NewFilterField.h>
|
||||
#include <vtkm/filter/flow/vtkm_filter_flow_export.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
namespace flow
|
||||
{
|
||||
|
||||
class VTKM_FILTER_FLOW_EXPORT Lagrangian : public vtkm::filter::NewFilterField
|
||||
{
|
||||
public:
|
||||
VTKM_CONT
|
||||
bool CanThread() const override { return false; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetInitFlag(bool val) { this->InitFlag = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetExtractFlows(bool val) { this->ExtractFlows = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetResetParticles(bool val) { this->ResetParticles = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetStepSize(vtkm::Float32 val) { this->StepSize = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetWriteFrequency(vtkm::Id val) { this->WriteFrequency = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetSeedResolutionInX(vtkm::Id val) { this->ResX = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetSeedResolutionInY(vtkm::Id val) { this->ResY = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetSeedResolutionInZ(vtkm::Id val) { this->ResZ = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetCustomSeedResolution(vtkm::Id val) { this->CustRes = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetSeedingResolution(vtkm::Id3 val) { this->SeedRes = val; }
|
||||
|
||||
VTKM_CONT
|
||||
void UpdateSeedResolution(vtkm::cont::DataSet input);
|
||||
|
||||
VTKM_CONT
|
||||
void InitializeSeedPositions(const vtkm::cont::DataSet& input);
|
||||
|
||||
VTKM_CONT
|
||||
void SetCycle(vtkm::Id cycle) { this->Cycle = cycle; }
|
||||
VTKM_CONT
|
||||
vtkm::Id GetCycle() const { return this->Cycle; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetBasisParticles(const vtkm::cont::ArrayHandle<vtkm::Particle>& basisParticles)
|
||||
{
|
||||
this->BasisParticles = basisParticles;
|
||||
}
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<vtkm::Particle> GetBasisParticles() const { return this->BasisParticles; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetBasisParticlesOriginal(const vtkm::cont::ArrayHandle<vtkm::Particle>& basisParticles)
|
||||
{
|
||||
this->BasisParticlesOriginal = basisParticles;
|
||||
}
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<vtkm::Particle> GetBasisParticlesOriginal() const
|
||||
{
|
||||
return this->BasisParticlesOriginal;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void SetBasisParticleValidity(const vtkm::cont::ArrayHandle<vtkm::Id>& valid)
|
||||
{
|
||||
this->BasisParticlesValidity = valid;
|
||||
}
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> GetBasisParticleValidity() const
|
||||
{
|
||||
return this->BasisParticlesValidity;
|
||||
}
|
||||
|
||||
protected: // make this protected so the deprecated version can override.
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData) override;
|
||||
|
||||
private:
|
||||
VTKM_CONT
|
||||
void InitializeCoordinates(const vtkm::cont::DataSet& input,
|
||||
std::vector<Float64>& xC,
|
||||
std::vector<Float64>& yC,
|
||||
std::vector<Float64>& zC);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Particle> BasisParticles;
|
||||
vtkm::cont::ArrayHandle<vtkm::Particle> BasisParticlesOriginal;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> BasisParticlesValidity;
|
||||
vtkm::Id CustRes = 0;
|
||||
vtkm::Id Cycle = 0;
|
||||
bool ExtractFlows = false;
|
||||
bool InitFlag = true;
|
||||
bool ResetParticles = true;
|
||||
vtkm::Id ResX = 1;
|
||||
vtkm::Id ResY = 1;
|
||||
vtkm::Id ResZ = 1;
|
||||
vtkm::FloatDefault StepSize;
|
||||
vtkm::Id3 SeedRes = { 1, 1, 1 };
|
||||
vtkm::Id WriteFrequency = 0;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} //vtkm::filter::flow
|
||||
|
||||
|
||||
//Deprecated Lagrangian filter
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
class VTKM_FILTER_FLOW_EXPORT VTKM_DEPRECATED(
|
||||
1.9,
|
||||
"Use vtkm::filter::flow::Lagrangian. "
|
||||
"Note that the new version of the filter no longer relies on global "
|
||||
"variables to record particle position from one time step to the next. "
|
||||
"It is important to keep a reference to _the same object_. "
|
||||
"If you create a new filter object, the seeds will be reinitialized.") Lagrangian
|
||||
: public vtkm::filter::flow::Lagrangian
|
||||
{
|
||||
private:
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData) override;
|
||||
};
|
||||
|
||||
}
|
||||
} //vtkm::filter
|
||||
|
||||
|
||||
|
||||
#endif // #define vtk_m_filter_flow_Lagrangian_h
|
@ -7,25 +7,27 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_filter_LagrangianStructures_hxx
|
||||
#define vtk_m_filter_LagrangianStructures_hxx
|
||||
|
||||
#include <vtkm/Particle.h>
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/ArrayHandleIndex.h>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/cont/ErrorFilterExecution.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
#include <vtkm/filter/flow/LagrangianStructures.h>
|
||||
|
||||
#include <vtkm/filter/flow/worklet/Field.h>
|
||||
#include <vtkm/filter/flow/worklet/GridEvaluators.h>
|
||||
#include <vtkm/filter/flow/worklet/Particles.h>
|
||||
#include <vtkm/filter/flow/worklet/LagrangianStructures.h>
|
||||
#include <vtkm/filter/flow/worklet/ParticleAdvection.h>
|
||||
#include <vtkm/filter/flow/worklet/RK4Integrator.h>
|
||||
#include <vtkm/filter/flow/worklet/Stepper.h>
|
||||
|
||||
#include <vtkm/worklet/LagrangianStructures.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
namespace flow
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
@ -60,25 +62,13 @@ public:
|
||||
|
||||
} //detail
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline VTKM_CONT LagrangianStructures::LagrangianStructures()
|
||||
: vtkm::filter::FilterDataSetWithField<LagrangianStructures>()
|
||||
{
|
||||
OutputFieldName = std::string("FTLE");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
inline VTKM_CONT vtkm::cont::DataSet LagrangianStructures::DoExecute(
|
||||
const vtkm::cont::DataSet& input,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& field,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>&)
|
||||
VTKM_CONT vtkm::cont::DataSet LagrangianStructures::DoExecute(const vtkm::cont::DataSet& input)
|
||||
{
|
||||
using Structured2DType = vtkm::cont::CellSetStructured<2>;
|
||||
using Structured3DType = vtkm::cont::CellSetStructured<3>;
|
||||
|
||||
using FieldHandle = vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>;
|
||||
using FieldHandle = vtkm::cont::ArrayHandle<vtkm::Vec3f>;
|
||||
using FieldType = vtkm::worklet::flow::VelocityField<FieldHandle>;
|
||||
using GridEvaluator = vtkm::worklet::flow::GridEvaluator<FieldType>;
|
||||
using IntegratorType = vtkm::worklet::flow::RK4Integrator<GridEvaluator>;
|
||||
@ -131,8 +121,10 @@ inline VTKM_CONT vtkm::cont::DataSet LagrangianStructures::DoExecute(
|
||||
else
|
||||
{
|
||||
vtkm::cont::Invoker invoke;
|
||||
const auto field = input.GetField(this->GetActiveFieldName());
|
||||
|
||||
FieldType velocities(field, fieldMeta.GetAssociation());
|
||||
FieldType velocities(field.GetData().AsArrayHandle<vtkm::cont::ArrayHandle<vtkm::Vec3f>>(),
|
||||
field.GetAssociation());
|
||||
GridEvaluator evaluator(input.GetCoordinateSystem(), input.GetCellSet(), velocities);
|
||||
Stepper integrator(evaluator, stepSize);
|
||||
vtkm::worklet::flow::ParticleAdvection particles;
|
||||
@ -149,14 +141,14 @@ inline VTKM_CONT vtkm::cont::DataSet LagrangianStructures::DoExecute(
|
||||
vtkm::cont::UnknownCellSet lcsCellSet = lcsInput.GetCellSet();
|
||||
if (lcsCellSet.IsType<Structured2DType>())
|
||||
{
|
||||
using AnalysisType = vtkm::worklet::LagrangianStructures<2>;
|
||||
using AnalysisType = vtkm::worklet::flow::LagrangianStructures<2>;
|
||||
AnalysisType ftleCalculator(advectionTime, lcsCellSet);
|
||||
vtkm::worklet::DispatcherMapField<AnalysisType> dispatcher(ftleCalculator);
|
||||
dispatcher.Invoke(lcsInputPoints, lcsOutputPoints, outputField);
|
||||
}
|
||||
else if (lcsCellSet.IsType<Structured3DType>())
|
||||
{
|
||||
using AnalysisType = vtkm::worklet::LagrangianStructures<3>;
|
||||
using AnalysisType = vtkm::worklet::flow::LagrangianStructures<3>;
|
||||
AnalysisType ftleCalculator(advectionTime, lcsCellSet);
|
||||
vtkm::worklet::DispatcherMapField<AnalysisType> dispatcher(ftleCalculator);
|
||||
dispatcher.Invoke(lcsInputPoints, lcsOutputPoints, outputField);
|
||||
@ -169,23 +161,6 @@ inline VTKM_CONT vtkm::cont::DataSet LagrangianStructures::DoExecute(
|
||||
return output;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename DerivedPolicy>
|
||||
inline VTKM_CONT bool LagrangianStructures::MapFieldOntoOutput(
|
||||
vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy>)
|
||||
{
|
||||
if (field.IsWholeDataSetField())
|
||||
{
|
||||
result.AddField(field);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
#endif
|
||||
} // namespace vtkm::filter::flow
|
80
vtkm/filter/flow/LagrangianStructures.h
Normal file
80
vtkm/filter/flow/LagrangianStructures.h
Normal file
@ -0,0 +1,80 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_flow_LagrangianStructures_h
|
||||
#define vtk_m_filter_flow_LagrangianStructures_h
|
||||
|
||||
#include <vtkm/filter/NewFilterField.h>
|
||||
#include <vtkm/filter/flow/FlowTypes.h>
|
||||
#include <vtkm/filter/flow/vtkm_filter_flow_export.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
namespace flow
|
||||
{
|
||||
|
||||
class VTKM_FILTER_FLOW_EXPORT LagrangianStructures : public vtkm::filter::NewFilterField
|
||||
{
|
||||
public:
|
||||
VTKM_CONT
|
||||
bool CanThread() const override { return false; }
|
||||
|
||||
void SetStepSize(vtkm::FloatDefault s) { this->StepSize = s; }
|
||||
vtkm::FloatDefault GetStepSize() { return this->StepSize; }
|
||||
|
||||
void SetNumberOfSteps(vtkm::Id n) { this->NumberOfSteps = n; }
|
||||
vtkm::Id GetNumberOfSteps() { return this->NumberOfSteps; }
|
||||
|
||||
void SetAdvectionTime(vtkm::FloatDefault advectionTime) { this->AdvectionTime = advectionTime; }
|
||||
vtkm::FloatDefault GetAdvectionTime() { return this->AdvectionTime; }
|
||||
|
||||
void SetUseAuxiliaryGrid(bool useAuxiliaryGrid) { this->UseAuxiliaryGrid = useAuxiliaryGrid; }
|
||||
bool GetUseAuxiliaryGrid() { return this->UseAuxiliaryGrid; }
|
||||
|
||||
void SetAuxiliaryGridDimensions(vtkm::Id3 auxiliaryDims) { this->AuxiliaryDims = auxiliaryDims; }
|
||||
vtkm::Id3 GetAuxiliaryGridDimensions() { return this->AuxiliaryDims; }
|
||||
|
||||
void SetUseFlowMapOutput(bool useFlowMapOutput) { this->UseFlowMapOutput = useFlowMapOutput; }
|
||||
bool GetUseFlowMapOutput() { return this->UseFlowMapOutput; }
|
||||
|
||||
void SetOutputFieldName(std::string outputFieldName) { this->OutputFieldName = outputFieldName; }
|
||||
std::string GetOutputFieldName() { return this->OutputFieldName; }
|
||||
|
||||
inline void SetFlowMapOutput(vtkm::cont::ArrayHandle<vtkm::Vec3f>& flowMap)
|
||||
{
|
||||
this->FlowMapOutput = flowMap;
|
||||
}
|
||||
inline vtkm::cont::ArrayHandle<vtkm::Vec3f> GetFlowMapOutput() { return this->FlowMapOutput; }
|
||||
|
||||
private:
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData) override;
|
||||
|
||||
vtkm::FloatDefault AdvectionTime;
|
||||
vtkm::Id3 AuxiliaryDims;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> FlowMapOutput;
|
||||
std::string OutputFieldName = "FTLE";
|
||||
vtkm::FloatDefault StepSize = 1.0f;
|
||||
vtkm::Id NumberOfSteps = 0;
|
||||
bool UseAuxiliaryGrid = false;
|
||||
bool UseFlowMapOutput = false;
|
||||
};
|
||||
|
||||
}
|
||||
struct VTKM_DEPRECATED(1.8, "Use vtkm::filter::flow::LagrangianStructures.") LagrangianStructures
|
||||
: vtkm::filter::flow::LagrangianStructures
|
||||
{
|
||||
using vtkm::filter::flow::LagrangianStructures::LagrangianStructures;
|
||||
};
|
||||
}
|
||||
} // namespace vtkm
|
||||
|
||||
#endif // vtk_m_filter_flow_LagrangianStructures_h
|
@ -15,6 +15,8 @@ set(headers
|
||||
DataSetIntegrator.h
|
||||
DataSetIntegratorSteadyState.h
|
||||
DataSetIntegratorUnsteadyState.h
|
||||
GridMetaData.h
|
||||
LagrangianStructureHelpers.h
|
||||
Messenger.h
|
||||
ParticleAdvector.h
|
||||
ParticleMessenger.h
|
||||
|
@ -7,14 +7,16 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_worklet_lcs_GridMetaData_h
|
||||
#define vtk_m_worklet_lcs_GridMetaData_h
|
||||
#ifndef vtkm_filter_flow_internal_GridMetaData_h
|
||||
#define vtkm_filter_flow_internal_GridMetaData_h
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace worklet
|
||||
namespace filter
|
||||
{
|
||||
namespace detail
|
||||
namespace flow
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
class GridMetaData
|
||||
@ -86,8 +88,9 @@ private:
|
||||
vtkm::Id RowSize;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace worklet
|
||||
} // namespace vtkm
|
||||
}
|
||||
}
|
||||
}
|
||||
} //vtkm::filter::flow::internal
|
||||
|
||||
#endif //vtk_m_worklet_lcs_GridMetaData_h
|
||||
#endif //vtkm_filter_flow_internal_GridMetaData_h
|
@ -7,8 +7,8 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_worklet_lcs_LagrangianStructureHelpers_h
|
||||
#define vtk_m_worklet_lcs_LagrangianStructureHelpers_h
|
||||
#ifndef vtkm_filter_flow_internal_LagrangianStructureHelpers_h
|
||||
#define vtkm_filter_flow_internal_LagrangianStructureHelpers_h
|
||||
|
||||
#include <vtkm/Matrix.h>
|
||||
#include <vtkm/Swap.h>
|
||||
@ -16,9 +16,11 @@
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace worklet
|
||||
namespace filter
|
||||
{
|
||||
namespace detail
|
||||
namespace flow
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
@ -198,7 +200,9 @@ VTKM_EXEC_CONT void Jacobi(vtkm::Matrix<T, 3, 3> tensor, vtkm::Vec<T, 3>& eigen)
|
||||
eigen[2] = w2;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace worklet
|
||||
} // namespace vtkm
|
||||
#endif //vtk_m_worklet_lcs_LagrangianStructureHelpers_h
|
||||
}
|
||||
}
|
||||
}
|
||||
} //vtkm::filter::flow::internal
|
||||
|
||||
#endif //vtkm_filter_flow_internal_LagrangianStructureHelpers_h
|
@ -9,6 +9,8 @@
|
||||
##============================================================================
|
||||
|
||||
set(filter_unit_tests
|
||||
UnitTestLagrangianFilter.cxx
|
||||
UnitTestLagrangianStructuresFilter.cxx
|
||||
UnitTestStreamlineFilter.cxx
|
||||
UnitTestStreamlineFilterWarpX.cxx
|
||||
UnitTestStreamSurfaceFilter.cxx
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <vtkm/cont/CellLocatorBoundingIntervalHierarchy.h>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/filter/Lagrangian.h>
|
||||
#include <vtkm/filter/flow/Lagrangian.h>
|
||||
#include <vtkm/worklet/testing/GenerateTestDataSets.h>
|
||||
|
||||
namespace
|
||||
@ -28,7 +28,7 @@ std::vector<vtkm::cont::DataSet> MakeDataSets()
|
||||
|
||||
for (auto& ds : dataSets)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_64> velocityField;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> velocityField;
|
||||
velocityField.Allocate(numPoints);
|
||||
|
||||
auto velocityPortal = velocityField.WritePortal();
|
||||
@ -37,7 +37,8 @@ std::vector<vtkm::cont::DataSet> MakeDataSets()
|
||||
for (vtkm::Id j = 0; j < dims[1]; j++)
|
||||
for (vtkm::Id k = 0; k < dims[2]; k++)
|
||||
{
|
||||
velocityPortal.Set(count, vtkm::Vec3f_64(0.1, 0.1, 0.1));
|
||||
vtkm::FloatDefault val = static_cast<vtkm::FloatDefault>(0.1);
|
||||
velocityPortal.Set(count, vtkm::Vec3f(val, val, val));
|
||||
count++;
|
||||
}
|
||||
ds.AddPointField("velocity", velocityField);
|
||||
@ -50,7 +51,7 @@ void TestLagrangianFilterMultiStepInterval()
|
||||
{
|
||||
vtkm::Id maxCycles = 5;
|
||||
vtkm::Id write_interval = 5;
|
||||
vtkm::filter::Lagrangian lagrangianFilter2;
|
||||
vtkm::filter::flow::Lagrangian lagrangianFilter2;
|
||||
lagrangianFilter2.SetResetParticles(true);
|
||||
lagrangianFilter2.SetStepSize(0.1f);
|
||||
lagrangianFilter2.SetWriteFrequency(write_interval);
|
||||
@ -87,19 +88,6 @@ void TestLagrangianFilterMultiStepInterval()
|
||||
void TestLagrangian()
|
||||
{
|
||||
TestLagrangianFilterMultiStepInterval();
|
||||
|
||||
// This gets around a bug where the LagrangianFilter allows VTK-m to crash during the program
|
||||
// exit handlers. The problem is that vtkm/filter/Lagrangian.hxx declares several static
|
||||
// ArrayHandles. The developers have been warned that this is a terrible idea for many reasons
|
||||
// (c.f. https://gitlab.kitware.com/vtk/vtk-m/-/merge_requests/1945), but this has not been
|
||||
// fixed yet. One of the bad things that can happen is that during the C++ exit handler,
|
||||
// the static ArrayHandles could be closed after the device APIs, which could lead to errors
|
||||
// when it tries to free the memory. This has been seen for this test. This hack gets
|
||||
// around it, but eventually these static declarations should really, really, really, really
|
||||
// be removed.
|
||||
BasisParticles.ReleaseResources();
|
||||
BasisParticlesOriginal.ReleaseResources();
|
||||
BasisParticlesValidity.ReleaseResources();
|
||||
}
|
||||
|
||||
int UnitTestLagrangianFilter(int argc, char* argv[])
|
@ -12,7 +12,7 @@
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/filter/LagrangianStructures.h>
|
||||
#include <vtkm/filter/flow/LagrangianStructures.h>
|
||||
#include <vtkm/worklet/testing/GenerateTestDataSets.h>
|
||||
|
||||
namespace auxiliary
|
||||
@ -336,7 +336,7 @@ void Test2DLCS()
|
||||
vtkm::cont::make_ArrayHandle(fieldVec, vtkm::CopyFlag::On);
|
||||
inputData.AddPointField("velocity", fieldHandle);
|
||||
|
||||
vtkm::filter::LagrangianStructures lagrangianStructures;
|
||||
vtkm::filter::flow::LagrangianStructures lagrangianStructures;
|
||||
lagrangianStructures.SetStepSize(0.025f);
|
||||
lagrangianStructures.SetNumberOfSteps(500);
|
||||
lagrangianStructures.SetAdvectionTime(0.025f * 500);
|
||||
@ -380,7 +380,7 @@ void Test3DLCS()
|
||||
vtkm::cont::make_ArrayHandle(fieldVec, vtkm::CopyFlag::On);
|
||||
input.AddPointField("velocity", fieldHandle);
|
||||
|
||||
vtkm::filter::LagrangianStructures lagrangianStructures;
|
||||
vtkm::filter::flow::LagrangianStructures lagrangianStructures;
|
||||
lagrangianStructures.SetStepSize(0.01f);
|
||||
lagrangianStructures.SetNumberOfSteps(500);
|
||||
lagrangianStructures.SetAdvectionTime(0.01f * 500);
|
@ -15,12 +15,13 @@ set(headers
|
||||
Field.h
|
||||
GridEvaluators.h
|
||||
GridEvaluatorStatus.h
|
||||
Stepper.h
|
||||
IntegratorStatus.h
|
||||
LagrangianStructures.h
|
||||
Particles.h
|
||||
ParticleAdvectionWorklets.h
|
||||
RK4Integrator.h
|
||||
TemporalGridEvaluators.h
|
||||
Stepper.h
|
||||
StreamSurface.h
|
||||
)
|
||||
|
||||
|
@ -7,21 +7,24 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_worklet_LagrangianStructures_h
|
||||
#define vtk_m_worklet_LagrangianStructures_h
|
||||
|
||||
#ifndef vtk_m_filter_flow_worklet_LagrangianStructures_h
|
||||
#define vtk_m_filter_flow_worklet_LagrangianStructures_h
|
||||
|
||||
#include <vtkm/Matrix.h>
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
|
||||
#include <vtkm/worklet/lcs/GridMetaData.h>
|
||||
#include <vtkm/worklet/lcs/LagrangianStructureHelpers.h>
|
||||
#include <vtkm/filter/flow/internal/GridMetaData.h>
|
||||
#include <vtkm/filter/flow/internal/LagrangianStructureHelpers.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace worklet
|
||||
{
|
||||
namespace flow
|
||||
{
|
||||
|
||||
template <vtkm::IdComponent dimensions>
|
||||
class LagrangianStructures;
|
||||
@ -77,10 +80,10 @@ public:
|
||||
vtkm::MatrixSetRow(jacobian, 0, vtkm::Vec<Scalar, 2>(f1x, f1y));
|
||||
vtkm::MatrixSetRow(jacobian, 1, vtkm::Vec<Scalar, 2>(f2x, f2y));
|
||||
|
||||
detail::ComputeLeftCauchyGreenTensor(jacobian);
|
||||
vtkm::filter::flow::internal::ComputeLeftCauchyGreenTensor(jacobian);
|
||||
|
||||
vtkm::Vec<Scalar, 2> eigenValues;
|
||||
detail::Jacobi(jacobian, eigenValues);
|
||||
vtkm::filter::flow::internal::Jacobi(jacobian, eigenValues);
|
||||
|
||||
Scalar delta = eigenValues[0];
|
||||
// Check if we need to clamp these values
|
||||
@ -99,7 +102,7 @@ public:
|
||||
// To calculate FTLE field
|
||||
Scalar EndTime;
|
||||
// To assist in calculation of indices
|
||||
detail::GridMetaData GridData;
|
||||
vtkm::filter::flow::internal::GridMetaData GridData;
|
||||
};
|
||||
|
||||
template <>
|
||||
@ -168,10 +171,10 @@ public:
|
||||
vtkm::MatrixSetRow(jacobian, 1, vtkm::Vec<Scalar, 3>(f2x, f2y, f2z));
|
||||
vtkm::MatrixSetRow(jacobian, 2, vtkm::Vec<Scalar, 3>(f3x, f3y, f3z));
|
||||
|
||||
detail::ComputeLeftCauchyGreenTensor(jacobian);
|
||||
vtkm::filter::flow::internal::ComputeLeftCauchyGreenTensor(jacobian);
|
||||
|
||||
vtkm::Vec<Scalar, 3> eigenValues;
|
||||
detail::Jacobi(jacobian, eigenValues);
|
||||
vtkm::filter::flow::internal::Jacobi(jacobian, eigenValues);
|
||||
|
||||
Scalar delta = eigenValues[0];
|
||||
// Given endTime is in units where start time is 0. else do endTime-startTime
|
||||
@ -183,10 +186,11 @@ public:
|
||||
// To calculate FTLE field
|
||||
Scalar EndTime;
|
||||
// To assist in calculation of indices
|
||||
detail::GridMetaData GridData;
|
||||
vtkm::filter::flow::internal::GridMetaData GridData;
|
||||
};
|
||||
|
||||
} // worklet
|
||||
} // vtkm
|
||||
}
|
||||
}
|
||||
} //vtkm::worklet::flow
|
||||
|
||||
#endif //vtk_m_worklet_LagrangianStructures_h
|
||||
#endif //vtk_m_filter_flow_worklet_LagrangianStructures_h
|
@ -11,8 +11,6 @@
|
||||
set(unit_tests
|
||||
UnitTestFieldMetadata.cxx
|
||||
UnitTestFieldSelection.cxx
|
||||
UnitTestLagrangianFilter.cxx
|
||||
UnitTestLagrangianStructuresFilter.cxx
|
||||
UnitTestMapFieldMergeAverage.cxx
|
||||
UnitTestMapFieldPermutation.cxx
|
||||
UnitTestMultiBlockFilter.cxx
|
||||
|
@ -23,7 +23,6 @@ set(headers
|
||||
KdTree3D.h # Deprecated
|
||||
KernelSplatter.h
|
||||
Keys.h
|
||||
LagrangianStructures.h
|
||||
MaskIndices.h
|
||||
MaskNone.h
|
||||
MaskSelect.h
|
||||
@ -73,7 +72,6 @@ set(sources_device
|
||||
add_subdirectory(internal)
|
||||
add_subdirectory(colorconversion)
|
||||
add_subdirectory(cosmotools)
|
||||
add_subdirectory(lcs)
|
||||
add_subdirectory(splatkernels)
|
||||
add_subdirectory(spatialstructure)
|
||||
add_subdirectory(wavelets)
|
||||
|
@ -1,16 +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.
|
||||
##============================================================================
|
||||
|
||||
set(headers
|
||||
GridMetaData.h
|
||||
LagrangianStructureHelpers.h
|
||||
)
|
||||
|
||||
vtkm_declare_headers(${headers})
|
Loading…
Reference in New Issue
Block a user