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

Method PutField

IO/IOSS/vtkIOSSModel.cxx:931–968  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

929
930 template <typename T, typename IossGroupingEntityT, typename DatasetT>
931 void PutField(IossGroupingEntityT* block, const std::string& name, int numComponents,
932 const std::vector<std::vector<vtkIdType>>& lIds, const std::vector<DatasetT*>& datasets,
933 int association) const
934 {
935 assert(datasets.size() == lIds.size());
936 const size_t totalSize = std::accumulate(lIds.begin(), lIds.end(), static_cast<size_t>(0),
937 [](size_t sum, const std::vector<vtkIdType>& ids) { return sum + ids.size(); });
938
939 using Dispatcher = vtkArrayDispatch::DispatchByValueType<vtkArrayDispatch::AllTypes>;
940 const bool createAOS = numComponents <= 3 || numComponents == 6;
941 PutFieldWorker<T> worker(numComponents, totalSize, createAOS);
942 for (size_t dsIndex = 0; dsIndex < datasets.size(); ++dsIndex)
943 {
944 auto& ds = datasets[dsIndex];
945 auto& lids = lIds[dsIndex];
946 worker.SetSourceIds(&lids);
947 if (auto array = ds->GetAttributes(association)->GetArray(name.c_str()))
948 {
949 if (!Dispatcher::Execute(array, worker))
950 {
951 vtkLogF(ERROR, "Failed to dispatch array %s", name.c_str());
952 }
953 }
954 }
955
956 if (createAOS)
957 {
958 block->put_field_data(name, worker.AOSData);
959 }
960 else
961 {
962 for (int comp = 0; comp < numComponents; ++comp)
963 {
964 const auto compName = name + vtk::to_string(comp + 1);
965 block->put_field_data(compName, worker.SOAData[comp]);
966 }
967 }
968 }
969
970 void DefineFields(Ioss::GroupingEntity* block,
971 const std::vector<std::tuple<std::string, Ioss::Field::BasicType, int>>& fields,

Callers

nothing calls this directly

Calls 11

put_field_dataMethod · 0.80
assertFunction · 0.50
ExecuteFunction · 0.50
to_stringFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
SetSourceIdsMethod · 0.45
GetArrayMethod · 0.45
GetAttributesMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected