.. _program_listing_file_src_pcms_transfer_copy.h: Program Listing for File copy.h =============================== |exhale_lsh| :ref:`Return to documentation for file ` (``src/pcms/transfer/copy.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #ifndef PCMS_TRANSFER_FIELD2_H_ #define PCMS_TRANSFER_FIELD2_H_ #include "pcms/field/field.h" #include "pcms/field/field_data.h" #include "pcms/field/function_space.h" #include "pcms/utility/assert.h" #include "pcms/utility/profile.h" #include "pcms/utility/types.h" #include "pcms/transfer/transfer_operator.hpp" #include #include namespace pcms { namespace detail { template void CheckCopyCompatible(const Field& source, const Field& target) { if (&source.GetLayout() != &target.GetLayout()) { throw pcms_error("Copy: source and target layouts differ"); } const auto& sd = source.GetData(); const auto& td = target.GetData(); if (sd.GetValueType() != td.GetValueType() || !SameValueBasis(sd.GetValueBasis(), td.GetValueBasis())) { throw pcms_error("Copy: source and target value type/basis differ"); } } } // namespace detail template class Copy : public TransferOperator { public: Copy(const FunctionSpace& source_space, const FunctionSpace& target_space) { auto source_layout = source_space.GetLayout(); auto target_layout = target_space.GetLayout(); if (source_layout.get() != target_layout.get()) { throw pcms_error("Copy: source and target function spaces have " "different layouts"); } } void Apply(const Field& source, Field& target) const override { PCMS_FUNCTION_TIMER; detail::CheckCopyCompatible(source, target); target.SetDOFHolderData(source.GetDOFHolderData()); } }; } // namespace pcms #endif // PCMS_TRANSFER_FIELD2_H_