MCPcopy Create free account
hub / github.com/Kitware/VTK / GetField

Method GetField

IO/IOSS/vtkIOSSReaderInternal.cxx:1954–2071  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1952}
1953
1954vtkSmartPointer<vtkAbstractArray> vtkIOSSReaderInternal::GetField(const std::string& fieldname,
1955 Ioss::Region* region, const Ioss::GroupingEntity* group_entity, const DatabaseHandle& handle,
1956 int timestep, vtkIdTypeArray* ids_to_extract, const std::string& cache_key_suffix)
1957{
1958 const auto get_field = [&fieldname, &region, &timestep, &handle, this](
1959 const Ioss::GroupingEntity* entity) -> vtkSmartPointer<vtkAbstractArray>
1960 {
1961 if (!entity->field_exists(fieldname))
1962 {
1963 return nullptr;
1964 }
1965
1966 if (!vtkIOSSUtilities::IsFieldTransient(entity, fieldname))
1967 {
1968 // non-time dependent field.
1969 return vtkIOSSUtilities::GetData(entity, fieldname, /*transform=*/nullptr, &this->Cache);
1970 }
1971
1972 // determine state for transient data.
1973 const auto& stateVector = this->DatabaseTimes[handle.first];
1974 if (stateVector.empty())
1975 {
1976 // see paraview/paraview#20658 for why this is needed.
1977 return nullptr;
1978 }
1979
1980 auto iter = std::find_if(stateVector.begin(), stateVector.end(),
1981 [&](const std::pair<int, double>& pair)
1982 { return pair.second == this->TimestepValues[timestep]; });
1983
1984 if (iter == stateVector.end())
1985 {
1986 throw std::runtime_error("Invalid timestep chosen: " + vtk::to_string(timestep));
1987 }
1988 const int state = iter->first;
1989 region->begin_state(state);
1990 try
1991 {
1992 const std::string key = "__vtk_transient_" + fieldname + "_" + vtk::to_string(state) + "__";
1993 auto f =
1994 vtkIOSSUtilities::GetData(entity, fieldname, /*transform=*/nullptr, &this->Cache, key);
1995 region->end_state(state);
1996 return f;
1997 }
1998 catch (...)
1999 {
2000 region->end_state(state);
2001 std::rethrow_exception(std::current_exception());
2002 }
2003 };
2004
2005 const auto get_field_for_entity = [&]()
2006 {
2007 if (group_entity->type() == Ioss::EntityType::SIDESET)
2008 {
2009 // sidesets need to be handled specially. For sidesets, the fields are
2010 // available on nested sideblocks.
2011 std::vector<vtkSmartPointer<vtkAbstractArray>> arrays;

Callers 15

GetFieldsMethod · 0.95
ApplyDisplacementsMethod · 0.95
GetGlobalFieldsMethod · 0.95
GetNodalAttributesMethod · 0.45
GetElementAttributesMethod · 0.45
ApplyDisplacementsMethod · 0.45
RequestDataMethod · 0.45
RequestDataMethod · 0.45
RequestDataMethod · 0.45
RequestDataMethod · 0.45
RequestDataMethod · 0.45
RequestDataMethod · 0.45

Calls 15

ConvertFieldForVTKMethod · 0.95
IsFieldTransientFunction · 0.85
get_fieldFunction · 0.85
JoinArraysFunction · 0.85
field_existsMethod · 0.80
GetDataFunction · 0.70
to_stringFunction · 0.50
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
typeMethod · 0.45
push_backMethod · 0.45

Tested by 3

TestUniformDataSetFunction · 0.36
TestCurvilinearDataSetFunction · 0.36
TestExplicitDataSetFunction · 0.36