Addition of GhostCellField API to the Dataset Class
AddGhostCellField function for Dataset class setGhostCellName function for GhostCellClassify class setGhostCellName function for GhostCellClassify class added default ghost cell name in Dataset class Default ghost cell field name defined in GhostCellClassify class Default ghost cell field name for GhostCellClassify class Unit test for ghost field name check Unit test for ghost field name check updated Default ghost field name updated Get function for GhostCellClassify and default ghost name UnitTestStreamlineFilter updated with AddGhostCellField AddGhostCellField and GetGlobalGhostCellFieldName propagated GhostCellClassify constructor now defined in header file Assigned default values to dataset class members GhostSet and GhostCellName default values set for GhostSet and GhostCellName in dataset constructor Constructor removed from dataset class and noexcept for GetGlobalGhostName added Dataset constructor with noexcept additions to make sure default move constructor has not changed GhostSetName field made as a shared pointer since string class is not noexcept AddGhostCellField funtion added without field name hasGhostCellField added and unit tests updated for addGhostCellField hasGhostCellField added and unit tests updated for addGhostCellField GetGhostCellField and GetGhostCellFieldName functions added to Dataset GetGhostCellField and GetGhostCellFieldName functions added to Dataset debugging UnitTestCellLocatorGerneral for CUDA error UnitTestCellLocatorGeneral testing for error UnitTestCellLocatorGeneral testing for cude error UnitTestCellLocatorGeneral error resolution UnitTestCellLocatorGeneral error resolution UnitTestCellLocatorGeneral error resolution print statement removed Minor updates to Dataset class files GlobalGhostCellFieldName implementation revised to return a static variable GhostSet member removed, hasGhostCellField, constructor, copystructure updated GetGhostCellField and GetGhostCellFieldName made cosistent with GetField Fixes to a few function calls
This commit is contained in:
parent
d4ee1379b1
commit
aa01c51cb9
@ -14,6 +14,23 @@ namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
VTKM_CONT std::string& GlobalGhostCellFieldName() noexcept
|
||||
{
|
||||
static std::string GhostCellName("vtkGhostCells");
|
||||
return GhostCellName;
|
||||
}
|
||||
|
||||
VTKM_CONT const std::string& GetGlobalGhostCellFieldName() noexcept
|
||||
{
|
||||
return GlobalGhostCellFieldName();
|
||||
}
|
||||
|
||||
VTKM_CONT void SetGlobalGhostCellFieldName(const std::string& name) noexcept
|
||||
{
|
||||
GlobalGhostCellFieldName() = name;
|
||||
}
|
||||
|
||||
void DataSet::Clear()
|
||||
{
|
||||
this->CoordSystems.clear();
|
||||
@ -39,6 +56,7 @@ void DataSet::CopyStructure(const vtkm::cont::DataSet& source)
|
||||
{
|
||||
this->CoordSystems = source.CoordSystems;
|
||||
this->CellSet = source.CellSet;
|
||||
this->GhostCellName = source.GhostCellName;
|
||||
}
|
||||
|
||||
const vtkm::cont::Field& DataSet::GetField(vtkm::Id index) const
|
||||
|
@ -24,9 +24,25 @@ namespace vtkm
|
||||
namespace cont
|
||||
{
|
||||
|
||||
VTKM_CONT_EXPORT VTKM_CONT std::string& GlobalGhostCellFieldName() noexcept;
|
||||
|
||||
VTKM_CONT_EXPORT VTKM_CONT const std::string& GetGlobalGhostCellFieldName() noexcept;
|
||||
|
||||
VTKM_CONT_EXPORT VTKM_CONT void SetGlobalGhostCellFieldName(const std::string& name) noexcept;
|
||||
|
||||
class VTKM_CONT_EXPORT DataSet
|
||||
{
|
||||
public:
|
||||
DataSet() = default;
|
||||
|
||||
DataSet(vtkm::cont::DataSet&&) = default;
|
||||
|
||||
DataSet(const vtkm::cont::DataSet&) = default;
|
||||
|
||||
vtkm::cont::DataSet& operator=(vtkm::cont::DataSet&&) = default;
|
||||
|
||||
vtkm::cont::DataSet& operator=(const vtkm::cont::DataSet&) = default;
|
||||
|
||||
VTKM_CONT void Clear();
|
||||
|
||||
/// Get the number of cells contained in this DataSet
|
||||
@ -59,6 +75,32 @@ public:
|
||||
return (this->GetFieldIndex(name, vtkm::cont::Field::Association::Cells) != -1);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
bool HasGhostCellField() const
|
||||
{
|
||||
if (this->GhostCellName)
|
||||
{
|
||||
return this->HasCellField(*this->GhostCellName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const std::string& GetGhostCellFieldName() const
|
||||
{
|
||||
if (this->HasGhostCellField())
|
||||
{
|
||||
return *this->GhostCellName;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("No Ghost Cell Field Name");
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
bool HasPointField(const std::string& name) const
|
||||
{
|
||||
@ -103,6 +145,23 @@ public:
|
||||
}
|
||||
//@}
|
||||
|
||||
/// Returns the first cell field that matches the provided name.
|
||||
/// Will throw an exception if no match is found
|
||||
//@{
|
||||
VTKM_CONT
|
||||
const vtkm::cont::Field& GetGhostCellField() const
|
||||
{
|
||||
if (this->HasGhostCellField())
|
||||
{
|
||||
return this->GetCellField(*(this->GhostCellName));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("No Ghost Cell Field");
|
||||
}
|
||||
}
|
||||
//@}
|
||||
|
||||
/// Returns the first point field that matches the provided name.
|
||||
/// Will throw an exception if no match is found
|
||||
//@{
|
||||
@ -153,6 +212,25 @@ public:
|
||||
this->AddField(make_FieldCell(fieldName, field));
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void AddGhostCellField(const std::string& fieldName, const vtkm::cont::UnknownArrayHandle& field)
|
||||
{
|
||||
this->GhostCellName.reset(new std::string(fieldName));
|
||||
this->AddField(make_FieldCell(fieldName, field));
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void AddGhostCellField(const vtkm::cont::UnknownArrayHandle& field)
|
||||
{
|
||||
this->AddGhostCellField(GetGlobalGhostCellFieldName(), field);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void AddGhostCellField(const vtkm::cont::Field& field)
|
||||
{
|
||||
this->AddGhostCellField(field.GetName(), field.GetData());
|
||||
}
|
||||
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT void AddCellField(const std::string& fieldName,
|
||||
const vtkm::cont::ArrayHandle<T, Storage>& field)
|
||||
@ -284,6 +362,7 @@ private:
|
||||
std::vector<vtkm::cont::CoordinateSystem> CoordSystems;
|
||||
std::map<FieldCompare::Key, vtkm::cont::Field, FieldCompare> Fields;
|
||||
vtkm::cont::UnknownCellSet CellSet;
|
||||
std::shared_ptr<std::string> GhostCellName;
|
||||
};
|
||||
|
||||
} // namespace cont
|
||||
|
@ -308,8 +308,9 @@ namespace entity_extraction
|
||||
//-----------------------------------------------------------------------------
|
||||
VTKM_CONT GhostCellRemove::GhostCellRemove()
|
||||
{
|
||||
this->SetActiveField("vtkmGhostCells");
|
||||
this->SetFieldsToPass("vtkmGhostCells", vtkm::filter::FieldSelection::Mode::Exclude);
|
||||
this->SetActiveField(vtkm::cont::GetGlobalGhostCellFieldName());
|
||||
this->SetFieldsToPass(vtkm::cont::GetGlobalGhostCellFieldName(),
|
||||
vtkm::filter::FieldSelection::Mode::Exclude);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -94,7 +94,7 @@ vtkm::cont::DataSet MakeUniform(vtkm::Id numI,
|
||||
ds = vtkm::cont::DataSetBuilderUniform::Create(vtkm::Id3(numI + 1, numJ + 1, numK + 1));
|
||||
auto ghosts = StructuredGhostCellArray(numI, numJ, numK, numLayers, addMidGhost);
|
||||
|
||||
ds.AddCellField("vtkmGhostCells", ghosts);
|
||||
ds.AddGhostCellField(ghosts);
|
||||
|
||||
return ds;
|
||||
}
|
||||
@ -128,7 +128,7 @@ vtkm::cont::DataSet MakeRectilinear(vtkm::Id numI,
|
||||
|
||||
auto ghosts = StructuredGhostCellArray(numI, numJ, numK, numLayers, addMidGhost);
|
||||
|
||||
ds.AddCellField("vtkmGhostCells", ghosts);
|
||||
ds.AddGhostCellField(ghosts);
|
||||
|
||||
return ds;
|
||||
}
|
||||
@ -205,7 +205,7 @@ vtkm::cont::DataSet MakeExplicit(vtkm::Id numI, vtkm::Id numJ, vtkm::Id numK, in
|
||||
|
||||
auto ghosts = StructuredGhostCellArray(numI, numJ, numK, numLayers);
|
||||
|
||||
ds.AddCellField("vtkmGhostCells", ghosts);
|
||||
ds.AddGhostCellField(ghosts);
|
||||
|
||||
return ds;
|
||||
}
|
||||
|
@ -88,6 +88,7 @@ private:
|
||||
|
||||
namespace mesh_info
|
||||
{
|
||||
|
||||
VTKM_CONT vtkm::cont::DataSet GhostCellClassify::DoExecute(const vtkm::cont::DataSet& input)
|
||||
{
|
||||
const vtkm::cont::UnknownCellSet& cellset = input.GetCellSet();
|
||||
@ -142,7 +143,7 @@ VTKM_CONT vtkm::cont::DataSet GhostCellClassify::DoExecute(const vtkm::cont::Dat
|
||||
}
|
||||
|
||||
auto output = this->CreateResult(input);
|
||||
output.AddCellField("vtkmGhostCells", ghosts);
|
||||
output.AddGhostCellField(this->GhostCellName, ghosts);
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,17 @@ namespace mesh_info
|
||||
class VTKM_FILTER_MESH_INFO_EXPORT GhostCellClassify : public vtkm::filter::NewFilter
|
||||
{
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData) override;
|
||||
std::string GhostCellName;
|
||||
|
||||
public:
|
||||
VTKM_CONT GhostCellClassify()
|
||||
: NewFilter()
|
||||
, GhostCellName(vtkm::cont::GetGlobalGhostCellFieldName())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT void SetGhostCellName(const std::string& fieldName) { this->GhostCellName = fieldName; }
|
||||
VTKM_CONT const std::string& GetGhostCellName() { return this->GhostCellName; }
|
||||
};
|
||||
} // namespace mesh_info
|
||||
class VTKM_DEPRECATED(1.8, "Use vtkm::filter::mesh_info::GhostCellClassify.") GhostCellClassify
|
||||
|
@ -60,7 +60,7 @@ vtkm::cont::DataSet MakeRectilinear(vtkm::Id numI, vtkm::Id numJ, vtkm::Id numK)
|
||||
return ds;
|
||||
}
|
||||
|
||||
void TestStructured()
|
||||
void TestStructured(std::string GhostFieldName = "")
|
||||
{
|
||||
std::cout << "Testing ghost cells for structured datasets." << std::endl;
|
||||
|
||||
@ -99,14 +99,18 @@ void TestStructured()
|
||||
ds = MakeRectilinear(nx, ny, nz);
|
||||
|
||||
vtkm::filter::mesh_info::GhostCellClassify addGhost;
|
||||
|
||||
if (GhostFieldName != "")
|
||||
addGhost.SetGhostCellName(GhostFieldName);
|
||||
auto output = addGhost.Execute(ds);
|
||||
|
||||
//Validate the output.
|
||||
VTKM_TEST_ASSERT(output.HasCellField("vtkmGhostCells"),
|
||||
std::string correctFieldName = vtkm::cont::GetGlobalGhostCellFieldName();
|
||||
if (GhostFieldName != "")
|
||||
correctFieldName = GhostFieldName;
|
||||
VTKM_TEST_ASSERT(output.HasCellField(correctFieldName),
|
||||
"Ghost cells array not found in output");
|
||||
vtkm::Id numCells = output.GetNumberOfCells();
|
||||
auto fieldArray = output.GetCellField("vtkmGhostCells").GetData();
|
||||
auto fieldArray = output.GetCellField(addGhost.GetGhostCellName()).GetData();
|
||||
VTKM_TEST_ASSERT(fieldArray.GetNumberOfValues() == numCells,
|
||||
"Wrong number of values in ghost cell array");
|
||||
|
||||
@ -134,7 +138,7 @@ void TestStructured()
|
||||
|
||||
void TestGhostCellClassify()
|
||||
{
|
||||
TestStructured();
|
||||
TestStructured("MyGhostFieldName");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ void TestAMRStreamline(bool useSL)
|
||||
ghosts[idx] = vtkm::CellClassification::Normal;
|
||||
idx++;
|
||||
}
|
||||
dsOuter.AddCellField("vtkmGhostCells", ghosts);
|
||||
dsOuter.AddGhostCellField(vtkm::cont::make_ArrayHandle(ghosts, vtkm::CopyFlag::On));
|
||||
|
||||
//Create a partitioned dataset with 1 inner and 1 outer.
|
||||
vtkm::cont::PartitionedDataSet pds;
|
||||
|
@ -111,7 +111,7 @@ void TestAMRStreamline(FilterType fType, bool useThreaded)
|
||||
ghosts[idx] = vtkm::CellClassification::Normal;
|
||||
idx++;
|
||||
}
|
||||
dsOuter.AddCellField("vtkmGhostCells", ghosts);
|
||||
dsOuter.AddGhostCellField(vtkm::cont::make_ArrayHandle(ghosts, vtkm::CopyFlag::On));
|
||||
|
||||
//Create a partitioned dataset with 1 inner and 1 outer.
|
||||
vtkm::cont::PartitionedDataSet pds;
|
||||
|
@ -184,9 +184,9 @@ public:
|
||||
{
|
||||
this->InitializeLocator(dataSet.GetCoordinateSystem(), dataSet.GetCellSet());
|
||||
|
||||
if (dataSet.HasCellField("vtkmGhostCells"))
|
||||
if (dataSet.HasGhostCellField())
|
||||
{
|
||||
auto arr = dataSet.GetCellField("vtkmGhostCells").GetData();
|
||||
auto arr = dataSet.GetGhostCellField().GetData();
|
||||
vtkm::cont::ArrayCopyShallowIfPossible(arr, this->GhostCellArray);
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +192,10 @@ inline vtkm::cont::DataSet CreateExplicitFromStructuredDataSet(const vtkm::Bound
|
||||
}
|
||||
|
||||
if (addGhost)
|
||||
output.AddField(input.GetField("vtkmGhostCells"));
|
||||
{
|
||||
output.AddGhostCellField(input.GetGhostCellField());
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user