11#include <similie/misc/domain_contains.hpp>
12#include <similie/misc/macros.hpp>
13#include <similie/misc/specialization.hpp>
14#include <similie/tensor/character.hpp>
15#include <similie/tensor/tensor_impl.hpp>
17#include "coboundary.hpp"
18#include "codifferential.hpp"
28 tensor::TensorIndex MetricIndex,
29 tensor::TensorNatIndex LaplacianDummyIndex,
30 tensor::TensorIndex CochainTag,
31 misc::Specialization<tensor::Tensor> DualTensorBufferType,
32 misc::Specialization<tensor::Tensor> TensorType,
33 misc::Specialization<tensor::Tensor> HodgeStarType,
34 misc::Specialization<tensor::Tensor> DualHodgeStarType,
36TensorType codifferential_of_coboundary(
37 ExecSpace
const& exec_space,
38 TensorType out_tensor,
40 HodgeStarType hodge_star,
41 DualHodgeStarType dual_hodge_star,
42 DualTensorBufferType dual_tensor_buffer)
46 LaplacianDummyIndex::size() - coboundary_output_index::rank(),
49 tensor::TensorAntisymmetricIndex,
50 codifferential_hodge_output_indices>;
51 using dual_codifferential_hodge_input_indices = ddc::type_seq_merge_t<
52 ddc::detail::TypeSeq<LaplacianDummyIndex>,
53 codifferential_hodge_output_indices>;
55 tensor::TensorAntisymmetricIndex,
56 dual_codifferential_hodge_input_indices>;
58 CochainTag::rank() + 1,
59 typename detail::NonSpectatorDimension<
61 typename TensorType::non_indices_domain_t>::type>(exec_space);
64 typename detail::NonSpectatorDimension<
66 typename TensorType::non_indices_domain_t>::type>(exec_space);
68 coboundary_dual_tensor_index::rank() + 1,
69 typename detail::NonSpectatorDimension<
71 typename TensorType::non_indices_domain_t>::type>(exec_space);
73 coboundary_dual_tensor_index::rank(),
74 typename detail::NonSpectatorDimension<
76 typename TensorType::non_indices_domain_t>::type>(exec_space);
78 SIMILIE_DEBUG_LOG(
"similie_deriv_and_apply_first_hodge_star_for_codifferential_of_coboundary");
79 ddc::parallel_for_each(
80 "similie_deriv_and_apply_first_hodge_star_for_codifferential_of_coboundary",
82 dual_tensor_buffer.non_indices_domain(),
83 KOKKOS_LAMBDA(
typename TensorType::non_indices_domain_t::discrete_element_type elem) {
84 [[maybe_unused]] tensor::TensorAccessor<coboundary_output_index>
86 std::array<double, coboundary_output_index::access_size()> derivative_alloc {};
89 ddc::DiscreteDomain<coboundary_output_index>,
91 typename TensorType::memory_space>
92 derivative_span(derivative_alloc.data(), derivative_accessor.domain());
95 Coboundary<LaplacianDummyIndex, CochainTag>::run(
97 [&](
auto sampled_elem,
auto cochain_elem) {
98 auto const clamped_elem =
misc::
100 return tensor.mem(clamped_elem, cochain_elem);
107 tensor_prod(dual_tensor_buffer[elem], derivative_tensor, hodge_star[elem]);
110 SIMILIE_DEBUG_LOG(
"similie_deriv_and_apply_second_hodge_star_for_codifferential_of_coboundary");
111 ddc::parallel_for_each(
112 "similie_deriv_and_apply_second_hodge_star_for_codifferential_of_coboundary",
114 out_tensor.non_indices_domain(),
115 KOKKOS_LAMBDA(
typename TensorType::non_indices_domain_t::discrete_element_type elem) {
116 [[maybe_unused]] tensor::TensorAccessor<dual_codifferential_index>
117 dual_codifferential_accessor;
118 std::array<double, dual_codifferential_index::access_size()>
119 dual_codifferential_alloc {};
122 ddc::DiscreteDomain<dual_codifferential_index>,
123 Kokkos::layout_right,
124 typename TensorType::memory_space>
125 dual_codifferential_span(
126 dual_codifferential_alloc.data(),
127 dual_codifferential_accessor.domain());
130 TransposedCoboundary<LaplacianDummyIndex, coboundary_dual_tensor_index>::run(
132 [&](
auto sampled_elem,
auto dual_elem) {
134 dual_tensor_buffer.non_indices_domain(),
138 return dual_tensor_buffer.mem(sampled_elem, dual_elem);
145 tensor_prod(out_tensor[elem], dual_codifferential, dual_hodge_star[elem]);
147 (LaplacianDummyIndex::size() * (coboundary_output_index::rank() + 1) + 1)
150 out_tensor[elem] *= -1;
157template <
class LaplacianDummyIndex,
class CochainTag>
158concept ZeroRankLaplacianCochain = CochainTag::rank() == 0;
160template <
class LaplacianDummyIndex,
class CochainTag>
161concept IntermediateRankLaplacianCochain
162 = CochainTag::rank() > 0 && CochainTag::rank() < LaplacianDummyIndex::size();
164template <
class LaplacianDummyIndex,
class CochainTag>
165concept TopRankLaplacianCochain = CochainTag::rank() == LaplacianDummyIndex::size();
174template <
class... Args>
185 requires(detail::ZeroRankLaplacianCochain<LaplacianDummyIndex, CochainTag>)
195 using MemorySpace =
typename TensorType::memory_space;
196 using AllocatorType = ddc::KokkosAllocator<double, MemorySpace>;
197 using CodifferentialOfCoboundaryIndex
201 using CoboundaryHodgeInputIndices
204 CodifferentialOfCoboundaryIndex::size() - CoboundaryOutputIndex::rank(),
205 CodifferentialOfCoboundaryIndex>;
206 using DualCoboundaryHodgeInputIndices = ddc::type_seq_merge_t<
207 ddc::detail::TypeSeq<CodifferentialOfCoboundaryIndex>,
208 CoboundaryHodgeOutputIndices>;
209 using DualCoboundaryHodgeOutputIndices = ddc::type_seq_remove_t<
211 ddc::detail::TypeSeq<CodifferentialOfCoboundaryIndex>>;
212 using CoboundaryDualTensorIndex = misc::
213 convert_type_seq_to_t<tensor::TensorAntisymmetricIndex, CoboundaryHodgeOutputIndices>;
215 using DerivativeHodgeStarDomainType = ddc::cartesian_prod_t<
216 typename MetricType::non_indices_domain_t,
218 using DualDerivativeHodgeStarDomainType = ddc::cartesian_prod_t<
219 typename MetricType::non_indices_domain_t,
222 DualCoboundaryHodgeOutputIndices>>;
223 using DerivativeDualTensorDomainType = ddc::cartesian_prod_t<
224 typename TensorType::non_indices_domain_t,
225 ddc::DiscreteDomain<CoboundaryDualTensorIndex>>;
227 using DerivativeHodgeStarAllocType
228 = ddc::Chunk<double, DerivativeHodgeStarDomainType, AllocatorType>;
229 using DualDerivativeHodgeStarAllocType
230 = ddc::Chunk<double, DualDerivativeHodgeStarDomainType, AllocatorType>;
231 using DerivativeDualTensorAllocType
232 = ddc::Chunk<double, DerivativeDualTensorDomainType, AllocatorType>;
234 using DerivativeHodgeStarTensorType = tensor::
235 Tensor<double, DerivativeHodgeStarDomainType, Kokkos::layout_right, MemorySpace>;
236 using DualDerivativeHodgeStarTensorType = tensor::
237 Tensor<double, DualDerivativeHodgeStarDomainType, Kokkos::layout_right, MemorySpace>;
238 using DerivativeDualTensorType = tensor::
239 Tensor<double, DerivativeDualTensorDomainType, Kokkos::layout_right, MemorySpace>;
240 ExecSpace m_exec_space;
241 std::optional<DerivativeHodgeStarAllocType> m_derivative_hodge_star_alloc;
242 std::optional<DualDerivativeHodgeStarAllocType> m_dual_derivative_hodge_star_alloc;
243 std::optional<DerivativeDualTensorAllocType> m_derivative_dual_tensor_alloc;
244 std::optional<DerivativeHodgeStarTensorType> m_derivative_hodge_star;
245 std::optional<DualDerivativeHodgeStarTensorType> m_dual_derivative_hodge_star;
246 std::optional<DerivativeDualTensorType> m_derivative_dual_tensor_buffer;
250 ExecSpace
const& exec_space,
251 DerivativeHodgeStarTensorType&& derivative_hodge_star,
252 DualDerivativeHodgeStarTensorType&& dual_derivative_hodge_star,
253 DerivativeDualTensorType&& derivative_dual_tensor_buffer)
254 : m_exec_space(exec_space)
255 , m_derivative_hodge_star(std::move(derivative_hodge_star))
256 , m_dual_derivative_hodge_star(std::move(dual_derivative_hodge_star))
257 , m_derivative_dual_tensor_buffer(std::move(derivative_dual_tensor_buffer))
262 ExecSpace
const& exec_space,
266 PositionType position)
267 : m_exec_space(exec_space)
271 derivative_hodge_star_accessor;
274 DualCoboundaryHodgeOutputIndices>> dual_derivative_hodge_star_accessor;
276 derivative_dual_tensor_accessor;
278 m_derivative_hodge_star_alloc.emplace(
279 DerivativeHodgeStarDomainType(
280 metric.non_indices_domain(),
281 derivative_hodge_star_accessor.domain()),
283 m_dual_derivative_hodge_star_alloc.emplace(
284 DualDerivativeHodgeStarDomainType(
285 metric.non_indices_domain(),
286 dual_derivative_hodge_star_accessor.domain()),
288 m_derivative_dual_tensor_alloc.emplace(
289 DerivativeDualTensorDomainType(
290 tensor.non_indices_domain(),
291 derivative_dual_tensor_accessor.
domain()),
294 m_derivative_hodge_star.emplace(*m_derivative_hodge_star_alloc);
295 m_dual_derivative_hodge_star.emplace(*m_dual_derivative_hodge_star_alloc);
296 m_derivative_dual_tensor_buffer.emplace(*m_derivative_dual_tensor_alloc);
300 *m_derivative_hodge_star,
305 DualCoboundaryHodgeOutputIndices>(
307 *m_dual_derivative_hodge_star,
312 TensorType run(TensorType laplacian_tensor, TensorType tensor)
314 return detail::codifferential_of_coboundary<
316 CodifferentialOfCoboundaryIndex,
321 *m_derivative_hodge_star,
322 *m_dual_derivative_hodge_star,
323 *m_derivative_dual_tensor_buffer);
328 tensor::TensorIndex MetricIndex,
329 tensor::TensorNatIndex LaplacianDummyIndex,
330 tensor::TensorIndex CochainTag,
332 misc::Specialization<tensor::Tensor> TensorType,
333 misc::Specialization<tensor::Tensor> MetricType,
334 misc::Specialization<tensor::Tensor> PositionType>
344 ExecSpace
const& exec_space,
345 TensorType laplacian_tensor,
348 PositionType position)
357 ExecSpace>(exec_space, laplacian_tensor, tensor, metric, position);
368 requires(detail::IntermediateRankLaplacianCochain<LaplacianDummyIndex, CochainTag>)
369class StagedLaplacian<
378 using MemorySpace =
typename TensorType::memory_space;
379 using AllocatorType = ddc::KokkosAllocator<double, MemorySpace>;
380 using CodifferentialOfCoboundaryIndex
384 using CoboundaryHodgeInputIndices
387 CodifferentialOfCoboundaryIndex::size() - CoboundaryOutputIndex::rank(),
388 CodifferentialOfCoboundaryIndex>;
389 using DualCoboundaryHodgeInputIndices = ddc::type_seq_merge_t<
390 ddc::detail::TypeSeq<CodifferentialOfCoboundaryIndex>,
391 CoboundaryHodgeOutputIndices>;
392 using DualCoboundaryHodgeOutputIndices = ddc::type_seq_remove_t<
394 ddc::detail::TypeSeq<CodifferentialOfCoboundaryIndex>>;
395 using CoboundaryDualTensorIndex = misc::
396 convert_type_seq_to_t<tensor::TensorAntisymmetricIndex, CoboundaryHodgeOutputIndices>;
398 using CodifferentialHodgeInputIndices
401 LaplacianDummyIndex::size() - CochainTag::rank(),
402 LaplacianDummyIndex>;
403 using DualCodifferentialHodgeInputIndices = ddc::type_seq_merge_t<
404 ddc::detail::TypeSeq<LaplacianDummyIndex>,
405 CodifferentialHodgeOutputIndices>;
406 using DualCodifferentialHodgeOutputIndices = ddc::type_seq_remove_t<
408 ddc::detail::TypeSeq<LaplacianDummyIndex>>;
411 CodifferentialHodgeOutputIndices>;
414 using DerivativeHodgeStarDomainType = ddc::cartesian_prod_t<
415 typename MetricType::non_indices_domain_t,
417 using DualDerivativeHodgeStarDomainType = ddc::cartesian_prod_t<
418 typename MetricType::non_indices_domain_t,
421 DualCoboundaryHodgeOutputIndices>>;
422 using DerivativeDualTensorDomainType = ddc::cartesian_prod_t<
423 typename TensorType::non_indices_domain_t,
424 ddc::DiscreteDomain<CoboundaryDualTensorIndex>>;
425 using HodgeStarDomainType = ddc::cartesian_prod_t<
426 typename MetricType::non_indices_domain_t,
428 using DualHodgeStarDomainType = ddc::cartesian_prod_t<
429 typename MetricType::non_indices_domain_t,
432 DualCodifferentialHodgeOutputIndices>>;
433 using DualTensorDomainType = ddc::cartesian_prod_t<
434 typename TensorType::non_indices_domain_t,
435 ddc::DiscreteDomain<CodifferentialDualTensorIndex>>;
436 using CodifferentialDomainType = ddc::cartesian_prod_t<
437 typename TensorType::non_indices_domain_t,
438 ddc::DiscreteDomain<CodifferentialOutputIndex>>;
440 using DerivativeHodgeStarAllocType
441 = ddc::Chunk<double, DerivativeHodgeStarDomainType, AllocatorType>;
442 using DualDerivativeHodgeStarAllocType
443 = ddc::Chunk<double, DualDerivativeHodgeStarDomainType, AllocatorType>;
444 using DerivativeDualTensorAllocType
445 = ddc::Chunk<double, DerivativeDualTensorDomainType, AllocatorType>;
446 using HodgeStarAllocType = ddc::Chunk<double, HodgeStarDomainType, AllocatorType>;
447 using DualHodgeStarAllocType = ddc::Chunk<double, DualHodgeStarDomainType, AllocatorType>;
448 using DualTensorAllocType = ddc::Chunk<double, DualTensorDomainType, AllocatorType>;
449 using CodifferentialAllocType = ddc::Chunk<double, CodifferentialDomainType, AllocatorType>;
450 using CoboundaryOfCodifferentialAllocType
451 = ddc::Chunk<double, typename TensorType::discrete_domain_type, AllocatorType>;
453 using DerivativeHodgeStarTensorType = tensor::
454 Tensor<double, DerivativeHodgeStarDomainType, Kokkos::layout_right, MemorySpace>;
455 using DualDerivativeHodgeStarTensorType = tensor::
456 Tensor<double, DualDerivativeHodgeStarDomainType, Kokkos::layout_right, MemorySpace>;
457 using DerivativeDualTensorType = tensor::
458 Tensor<double, DerivativeDualTensorDomainType, Kokkos::layout_right, MemorySpace>;
459 using HodgeStarTensorType
461 using DualHodgeStarTensorType
465 using CodifferentialTensorType
467 ExecSpace m_exec_space;
468 std::optional<DerivativeHodgeStarAllocType> m_derivative_hodge_star_alloc;
469 std::optional<DualDerivativeHodgeStarAllocType> m_dual_derivative_hodge_star_alloc;
470 std::optional<DerivativeDualTensorAllocType> m_derivative_dual_tensor_alloc;
471 std::optional<HodgeStarAllocType> m_hodge_star_alloc;
472 std::optional<DualHodgeStarAllocType> m_dual_hodge_star_alloc;
473 std::optional<DualTensorAllocType> m_dual_tensor_alloc;
474 std::optional<CodifferentialAllocType> m_codifferential_alloc;
475 std::optional<CoboundaryOfCodifferentialAllocType> m_coboundary_of_codifferential_alloc;
476 std::optional<DerivativeHodgeStarTensorType> m_derivative_hodge_star;
477 std::optional<DualDerivativeHodgeStarTensorType> m_dual_derivative_hodge_star;
478 std::optional<DerivativeDualTensorType> m_derivative_dual_tensor_buffer;
479 std::optional<HodgeStarTensorType> m_hodge_star;
480 std::optional<DualHodgeStarTensorType> m_dual_hodge_star;
481 std::optional<DualTensorType> m_dual_tensor_buffer;
482 std::optional<CodifferentialTensorType> m_codifferential_tensor_buffer;
483 std::optional<TensorType> m_coboundary_of_codifferential_buffer;
487 ExecSpace
const& exec_space,
488 DerivativeHodgeStarTensorType derivative_hodge_star,
489 DualDerivativeHodgeStarTensorType dual_derivative_hodge_star,
490 DerivativeDualTensorType derivative_dual_tensor_buffer,
491 HodgeStarTensorType hodge_star,
492 DualHodgeStarTensorType dual_hodge_star,
493 DualTensorType dual_tensor_buffer,
494 CodifferentialTensorType codifferential_tensor_buffer,
495 TensorType coboundary_of_codifferential_buffer)
496 : m_exec_space(exec_space)
497 , m_derivative_hodge_star(derivative_hodge_star)
498 , m_dual_derivative_hodge_star(dual_derivative_hodge_star)
499 , m_derivative_dual_tensor_buffer(derivative_dual_tensor_buffer)
500 , m_hodge_star(hodge_star)
501 , m_dual_hodge_star(dual_hodge_star)
502 , m_dual_tensor_buffer(dual_tensor_buffer)
503 , m_codifferential_tensor_buffer(codifferential_tensor_buffer)
504 , m_coboundary_of_codifferential_buffer(coboundary_of_codifferential_buffer)
509 ExecSpace
const& exec_space,
510 TensorType laplacian_tensor,
513 PositionType position)
514 : m_exec_space(exec_space)
518 derivative_hodge_star_accessor;
521 DualCoboundaryHodgeOutputIndices>> dual_derivative_hodge_star_accessor;
523 derivative_dual_tensor_accessor;
525 CodifferentialHodgeInputIndices,
526 CodifferentialHodgeOutputIndices>> hodge_star_accessor;
529 DualCodifferentialHodgeOutputIndices>> dual_hodge_star_accessor;
533 m_derivative_hodge_star_alloc.emplace(
534 DerivativeHodgeStarDomainType(
535 metric.non_indices_domain(),
536 derivative_hodge_star_accessor.domain()),
538 m_dual_derivative_hodge_star_alloc.emplace(
539 DualDerivativeHodgeStarDomainType(
540 metric.non_indices_domain(),
541 dual_derivative_hodge_star_accessor.domain()),
543 m_derivative_dual_tensor_alloc.emplace(
544 DerivativeDualTensorDomainType(
545 tensor.non_indices_domain(),
546 derivative_dual_tensor_accessor.
domain()),
548 m_hodge_star_alloc.emplace(
549 HodgeStarDomainType(metric.non_indices_domain(), hodge_star_accessor.domain()),
551 m_dual_hodge_star_alloc.emplace(
552 DualHodgeStarDomainType(
553 metric.non_indices_domain(),
554 dual_hodge_star_accessor.domain()),
556 m_dual_tensor_alloc.emplace(
557 DualTensorDomainType(tensor.non_indices_domain(), dual_tensor_accessor.
domain()),
559 m_codifferential_alloc.emplace(
560 CodifferentialDomainType(
561 tensor.non_indices_domain(),
562 codifferential_accessor.
domain()),
564 m_coboundary_of_codifferential_alloc.emplace(laplacian_tensor.domain(), AllocatorType());
566 m_derivative_hodge_star.emplace(*m_derivative_hodge_star_alloc);
567 m_dual_derivative_hodge_star.emplace(*m_dual_derivative_hodge_star_alloc);
568 m_derivative_dual_tensor_buffer.emplace(*m_derivative_dual_tensor_alloc);
569 m_hodge_star.emplace(*m_hodge_star_alloc);
570 m_dual_hodge_star.emplace(*m_dual_hodge_star_alloc);
571 m_dual_tensor_buffer.emplace(*m_dual_tensor_alloc);
572 m_codifferential_tensor_buffer.emplace(*m_codifferential_alloc);
573 m_coboundary_of_codifferential_buffer.emplace(*m_coboundary_of_codifferential_alloc);
577 *m_derivative_hodge_star,
582 DualCoboundaryHodgeOutputIndices>(
584 *m_dual_derivative_hodge_star,
588 CodifferentialHodgeInputIndices,
589 CodifferentialHodgeOutputIndices>(exec_space, *m_hodge_star, metric, position);
592 DualCodifferentialHodgeOutputIndices>(
599 TensorType run(TensorType laplacian_tensor, TensorType tensor)
601 auto exec_spaces = Kokkos::Experimental::partition_space(m_exec_space, 1, 1);
603 detail::codifferential_of_coboundary<
605 CodifferentialOfCoboundaryIndex,
610 *m_derivative_hodge_star,
611 *m_dual_derivative_hodge_star,
612 *m_derivative_dual_tensor_buffer);
623 std::move(*m_hodge_star),
624 std::move(*m_dual_hodge_star),
625 std::move(*m_dual_tensor_buffer))
626 .run(*m_codifferential_tensor_buffer, tensor);
628 deriv<LaplacianDummyIndex, codifferential_index_t<LaplacianDummyIndex, CochainTag>>(
630 *m_coboundary_of_codifferential_buffer,
631 *m_codifferential_tensor_buffer);
633 exec_spaces[0].fence();
634 exec_spaces[1].fence();
636 auto coboundary_of_codifferential_buffer = *m_coboundary_of_codifferential_buffer;
637 SIMILIE_DEBUG_LOG(
"similie_add_coboundary_of_codifferential_contribution_to_laplacian");
638 ddc::parallel_for_each(
639 "similie_add_coboundary_of_codifferential_contribution_to_laplacian",
641 laplacian_tensor.domain(),
642 KOKKOS_LAMBDA(
typename TensorType::discrete_element_type elem) {
643 laplacian_tensor.mem(elem) += coboundary_of_codifferential_buffer.mem(elem);
646 return laplacian_tensor;
651 tensor::TensorIndex MetricIndex,
652 tensor::TensorNatIndex LaplacianDummyIndex,
653 tensor::TensorIndex CochainTag,
654 misc::Specialization<tensor::Tensor> TensorType,
655 misc::Specialization<tensor::Tensor> MetricType,
656 misc::Specialization<tensor::Tensor> PositionType,
658 requires(detail::TopRankLaplacianCochain<LaplacianDummyIndex, CochainTag>)
669 using MemorySpace =
typename TensorType::memory_space;
670 using AllocatorType = ddc::KokkosAllocator<double, MemorySpace>;
671 using CodifferentialHodgeInputIndices
674 LaplacianDummyIndex::size() - CochainTag::rank(),
675 LaplacianDummyIndex>;
676 using DualCodifferentialHodgeInputIndices = ddc::type_seq_merge_t<
677 ddc::detail::TypeSeq<LaplacianDummyIndex>,
678 CodifferentialHodgeOutputIndices>;
679 using DualCodifferentialHodgeOutputIndices = ddc::type_seq_remove_t<
681 ddc::detail::TypeSeq<LaplacianDummyIndex>>;
684 CodifferentialHodgeOutputIndices>;
687 using HodgeStarDomainType = ddc::cartesian_prod_t<
688 typename MetricType::non_indices_domain_t,
690 using DualHodgeStarDomainType = ddc::cartesian_prod_t<
691 typename MetricType::non_indices_domain_t,
694 DualCodifferentialHodgeOutputIndices>>;
695 using DualTensorDomainType = ddc::cartesian_prod_t<
696 typename TensorType::non_indices_domain_t,
697 ddc::DiscreteDomain<CodifferentialDualTensorIndex>>;
698 using CodifferentialDomainType = ddc::cartesian_prod_t<
699 typename TensorType::non_indices_domain_t,
700 ddc::DiscreteDomain<CodifferentialOutputIndex>>;
702 using HodgeStarAllocType = ddc::Chunk<double, HodgeStarDomainType, AllocatorType>;
703 using DualHodgeStarAllocType = ddc::Chunk<double, DualHodgeStarDomainType, AllocatorType>;
704 using DualTensorAllocType = ddc::Chunk<double, DualTensorDomainType, AllocatorType>;
705 using CodifferentialAllocType = ddc::Chunk<double, CodifferentialDomainType, AllocatorType>;
707 using HodgeStarTensorType
709 using DualHodgeStarTensorType
713 using CodifferentialTensorType
715 ExecSpace m_exec_space;
716 std::optional<HodgeStarAllocType> m_hodge_star_alloc;
717 std::optional<DualHodgeStarAllocType> m_dual_hodge_star_alloc;
718 std::optional<DualTensorAllocType> m_dual_tensor_alloc;
719 std::optional<CodifferentialAllocType> m_codifferential_alloc;
720 std::optional<HodgeStarTensorType> m_hodge_star;
721 std::optional<DualHodgeStarTensorType> m_dual_hodge_star;
722 std::optional<DualTensorType> m_dual_tensor_buffer;
723 std::optional<CodifferentialTensorType> m_codifferential_tensor_buffer;
727 ExecSpace
const& exec_space,
728 HodgeStarTensorType&& hodge_star,
729 DualHodgeStarTensorType&& dual_hodge_star,
730 DualTensorType&& dual_tensor_buffer,
731 CodifferentialTensorType&& codifferential_tensor_buffer)
732 : m_exec_space(exec_space)
733 , m_hodge_star(std::move(hodge_star))
734 , m_dual_hodge_star(std::move(dual_hodge_star))
735 , m_dual_tensor_buffer(std::move(dual_tensor_buffer))
736 , m_codifferential_tensor_buffer(std::move(codifferential_tensor_buffer))
741 ExecSpace
const& exec_space,
745 PositionType position)
746 : m_exec_space(exec_space)
749 CodifferentialHodgeInputIndices,
750 CodifferentialHodgeOutputIndices>> hodge_star_accessor;
753 DualCodifferentialHodgeOutputIndices>> dual_hodge_star_accessor;
757 m_hodge_star_alloc.emplace(
758 HodgeStarDomainType(metric.non_indices_domain(), hodge_star_accessor.domain()),
760 m_dual_hodge_star_alloc.emplace(
761 DualHodgeStarDomainType(
762 metric.non_indices_domain(),
763 dual_hodge_star_accessor.domain()),
765 m_dual_tensor_alloc.emplace(
766 DualTensorDomainType(tensor.non_indices_domain(), dual_tensor_accessor.
domain()),
768 m_codifferential_alloc.emplace(
769 CodifferentialDomainType(
770 tensor.non_indices_domain(),
771 codifferential_accessor.
domain()),
774 m_hodge_star.emplace(*m_hodge_star_alloc);
775 m_dual_hodge_star.emplace(*m_dual_hodge_star_alloc);
776 m_dual_tensor_buffer.emplace(*m_dual_tensor_alloc);
777 m_codifferential_tensor_buffer.emplace(*m_codifferential_alloc);
780 CodifferentialHodgeInputIndices,
781 CodifferentialHodgeOutputIndices>(exec_space, *m_hodge_star, metric, position);
784 DualCodifferentialHodgeOutputIndices>(
791 TensorType run(TensorType laplacian_tensor, TensorType tensor)
802 std::move(*m_hodge_star),
803 std::move(*m_dual_hodge_star),
804 std::move(*m_dual_tensor_buffer))
805 .run(*m_codifferential_tensor_buffer, tensor);
806 return sil::exterior::
807 deriv<LaplacianDummyIndex, codifferential_index_t<LaplacianDummyIndex, CochainTag>>(
810 *m_codifferential_tensor_buffer);
815 tensor::TensorIndex MetricIndex,
816 tensor::TensorNatIndex LaplacianDummyIndex,
817 tensor::TensorIndex CochainTag,
818 misc::Specialization<tensor::Tensor> TensorType,
819 misc::Specialization<tensor::Tensor> DerivativeHodgeStarType,
820 misc::Specialization<tensor::Tensor> DualDerivativeHodgeStarType,
821 misc::Specialization<tensor::Tensor> DerivativeDualTensorBufferType,
823 requires(detail::ZeroRankLaplacianCochain<LaplacianDummyIndex, CochainTag>)
825 ExecSpace
const& exec_space,
826 TensorType laplacian_tensor,
828 DerivativeHodgeStarType hodge_star,
829 DualDerivativeHodgeStarType dual_hodge_star,
830 DerivativeDualTensorBufferType dual_tensor_buffer)
832 using codifferential_of_coboundary_index
835 return detail::codifferential_of_coboundary<
837 codifferential_of_coboundary_index,
861 requires(detail::IntermediateRankLaplacianCochain<LaplacianDummyIndex, CochainTag>)
863 ExecSpace
const& exec_space,
864 TensorType laplacian_tensor,
866 DerivativeHodgeStarType derivative_hodge_star,
867 DualDerivativeHodgeStarType dual_derivative_hodge_star,
868 DerivativeDualTensorBufferType derivative_dual_tensor_buffer,
869 HodgeStarType hodge_star,
870 DualHodgeStarType dual_hodge_star,
871 DualTensorBufferType dual_tensor_buffer,
872 CodifferentialTensorBufferType codifferential_tensor_buffer,
873 CoboundaryOfCodifferentialBufferType coboundary_of_codifferential_buffer)
875 using codifferential_of_coboundary_index
878 auto exec_spaces = Kokkos::Experimental::partition_space(exec_space, 1, 1);
880 detail::codifferential_of_coboundary<
882 codifferential_of_coboundary_index,
887 derivative_hodge_star,
888 dual_derivative_hodge_star,
889 derivative_dual_tensor_buffer);
893 codifferential_tensor_buffer,
899 deriv<LaplacianDummyIndex, codifferential_index_t<LaplacianDummyIndex, CochainTag>>(
901 coboundary_of_codifferential_buffer,
902 codifferential_tensor_buffer);
904 exec_spaces[0].fence();
905 exec_spaces[1].fence();
907 SIMILIE_DEBUG_LOG(
"similie_add_coboundary_of_codifferential_contribution_to_laplacian");
908 ddc::parallel_for_each(
909 "similie_add_coboundary_of_codifferential_contribution_to_laplacian",
911 laplacian_tensor.domain(),
912 KOKKOS_LAMBDA(
typename TensorType::discrete_element_type elem) {
913 laplacian_tensor.mem(elem) += coboundary_of_codifferential_buffer.mem(elem);
916 return laplacian_tensor;
929 requires(detail::TopRankLaplacianCochain<LaplacianDummyIndex, CochainTag>)
931 ExecSpace
const& exec_space,
932 TensorType laplacian_tensor,
934 HodgeStarType hodge_star,
935 DualHodgeStarType dual_hodge_star,
936 DualTensorBufferType dual_tensor_buffer,
937 CodifferentialTensorBufferType codifferential_tensor_buffer)
941 codifferential_tensor_buffer,
950 CochainTag>>(exec_space, laplacian_tensor, codifferential_tensor_buffer);
static constexpr discrete_domain_type domain()
constexpr auto tangent_basis(ExecSpace const &exec_space)
ddc::detail::convert_type_seq_to_discrete_domain_t< ddc::type_seq_merge_t< ddc::detail::TypeSeq< misc::convert_type_seq_to_t< tensor::TensorFullIndex, Indices1 > >, std::conditional_t<(ddc::type_seq_size_v< Indices2 >==0), ddc::detail::TypeSeq<>, ddc::detail::TypeSeq< misc::convert_type_seq_to_t< tensor::TensorAntisymmetricIndex, Indices2 > > > > > hodge_star_domain_t
TensorType laplacian(ExecSpace const &exec_space, TensorType laplacian_tensor, TensorType tensor, DerivativeHodgeStarType hodge_star, DualDerivativeHodgeStarType dual_hodge_star, DerivativeDualTensorBufferType dual_tensor_buffer)
StagedLaplacian< MetricIndex, LaplacianDummyIndex, CochainTag, TensorType, MetricType, PositionType, ExecSpace > make_staged_laplacian(ExecSpace const &exec_space, TensorType laplacian_tensor, TensorType tensor, MetricType metric, PositionType position)
coboundary_tensor_t< TagToAddToCochain, CochainTag, TensorType > deriv(ExecSpace const &exec_space, coboundary_tensor_t< TagToAddToCochain, CochainTag, TensorType > coboundary_tensor, TensorType tensor)
HodgeStarType fill_discrete_hodge_star(ExecSpace const &exec_space, HodgeStarType hodge_star, MetricType metric, PositionType position)
codifferential_tensor_t< TagToRemoveFromCochain, CochainTag, TensorType > codifferential(ExecSpace const &exec_space, codifferential_tensor_t< TagToRemoveFromCochain, CochainTag, TensorType > codifferential_tensor, TensorType tensor, HodgeStarType hodge_star, DualHodgeStarType dual_hodge_star, DualTensorType dual_tensor_buffer)
typename detail::CodifferentialIndex< TagToRemoveFromCochain, CochainTag >::type codifferential_index_t
typename detail::CodifferentialHodgeOutputIndexSeq< EndId, T >::type codifferential_hodge_output_indices_t
typename detail::CoboundaryIndex< TagToAddToCochain, CochainTag >::type coboundary_index_t
KOKKOS_FUNCTION Elem clamp_to_domain(BatchDomain const &batch_domain, Elem const &elem)
KOKKOS_FUNCTION bool domain_contains(ddc::DiscreteDomain< DDim... > dom, ddc::DiscreteElement< ODDim... > elem)
typename detail::ConvertTypeSeqTo< T, Seq >::type convert_type_seq_to_t
Tensor(ddc::Chunk< ElementType, SupportType, Allocator >) -> Tensor< ElementType, SupportType, Kokkos::layout_right, typename Allocator::memory_space >
detail::Upper< T >::type upper_t
Tensor< ElementType, ddc::DiscreteDomain< ProdDDim... >, LayoutStridedPolicy, MemorySpace > tensor_prod(Tensor< ElementType, ddc::DiscreteDomain< ProdDDim... >, LayoutStridedPolicy, MemorySpace > prod_tensor, Tensor< ElementType, ddc::DiscreteDomain< DDim1... >, LayoutStridedPolicy, MemorySpace > tensor1, Tensor< ElementType, ddc::DiscreteDomain< DDim2... >, LayoutStridedPolicy, MemorySpace > tensor2)
detail::Uncharacterize< Index >::type uncharacterize_t
detail::Lower< T >::type lower_t
detail::TensorAccessorForDomain< Dom >::type tensor_accessor_for_domain_t
The top-level namespace of SimiLie.