include/meltpooldg/particles/particle.hpp Source File

Developer Documentation: include/meltpooldg/particles/particle.hpp Source File
Developer Documentation
particle.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include <deal.II/base/config.h>
5
6#include <deal.II/base/array_view.h>
7#include <deal.II/base/exceptions.h>
8#include <deal.II/base/point.h>
9#include <deal.II/base/tensor.h>
10
11#include <deal.II/numerics/data_component_interpretation.h>
12
13#include <deal.II/particles/particle.h>
14#include <deal.II/particles/particle_accessor.h>
15
17
18#include <iostream>
19#include <string>
20#include <utility>
21#include <vector>
22
23namespace MeltPoolDG
24{
33 template <int dim, typename number>
35 {
36 public:
37 // Number of components of the angular velocity: one in 2D, three in 3D.
38 static constexpr unsigned int size_angular_velocity = dim - 3 % dim;
39
40 // Total number of scalar properties associated with each obstacle particle.
41 // Breakdown:
42 // - 2 * size_angular_velocity: angular velocity and angular acceleration
43 // - 2 * dim: velocity and acceleration
44 // - dim: (directional) force acting on the particle
45 // - size_angular_velocity: torque acting on the particle
46 // - 5: radius, volume, density, mass, moment of inertia, particle id
47 static constexpr unsigned int n_obstacle_properties =
48 2 * size_angular_velocity + 2 * dim + dim + size_angular_velocity + 6;
49
54 {
60 torque = force + dim,
66 // TODO: This is temporary and should be replaced by a proper deal.II ghost particle
67 // implementation
68 particle_id, // used to identify particles received from other processes
69 };
70
83 static std::pair<std::vector<std::string>,
84 std::vector<dealii::DataComponentInterpretation::DataComponentInterpretation>>
86 {
87 using namespace dealii::DataComponentInterpretation;
88 constexpr std::array<std::string_view, 12> property_strings = {{"velocity",
89 "acceleration",
90 "angular_velocity",
91 "angular_acceleration",
92 "force",
93 "torque",
94 "radius",
95 "volume",
96 "density",
97 "mass",
98 "moment_of_inertia",
99 "ID"}};
100
101 constexpr std::array<DataComponentInterpretation, 12> data_component_interpretation{
102 {component_is_part_of_vector,
103 component_is_part_of_vector,
104 dim == 3 ? component_is_part_of_vector : component_is_scalar,
105 dim == 3 ? component_is_part_of_vector : component_is_scalar,
106 component_is_part_of_vector,
107 dim == 3 ? component_is_part_of_vector : component_is_scalar,
108 component_is_scalar,
109 component_is_scalar,
110 component_is_scalar,
111 component_is_scalar,
112 component_is_scalar,
113 component_is_scalar}};
114
115 std::pair<std::vector<std::string>, std::vector<DataComponentInterpretation>>
116 property_names_and_interpretations;
117
118 property_names_and_interpretations.first.reserve(n_obstacle_properties);
119 property_names_and_interpretations.second.reserve(n_obstacle_properties);
120
121 for (unsigned int i = 0; i < property_strings.size(); ++i)
122 {
123 if (data_component_interpretation[i] == component_is_part_of_vector)
124 {
125 for (unsigned int j = 0; j < dim; ++j)
126 {
127 property_names_and_interpretations.first.emplace_back(property_strings[i]);
128 property_names_and_interpretations.second.emplace_back(
129 data_component_interpretation[i]);
130 }
131 }
132 else
133 {
134 property_names_and_interpretations.first.emplace_back(property_strings[i]);
135 property_names_and_interpretations.second.emplace_back(
136 data_component_interpretation[i]);
137 }
138 }
139 return property_names_and_interpretations;
140 }
141
150 template <typename VectorizedArrayType>
151 static dealii::Tensor<1, dim, VectorizedArrayType>
152 vector_to_center_of_gravity(const dealii::Point<dim, VectorizedArrayType> &loc,
153 dealii::Particles::PropertyPool<dim> &property_pool,
154 const typename dealii::Particles::PropertyPool<dim>::Handle handle);
155
164 template <typename VectorizedArrayType>
165 static dealii::Tensor<1, dim, VectorizedArrayType>
166 vector_to_surface(const dealii::Point<dim, VectorizedArrayType> &loc,
167 const dealii::Particles::ParticleAccessor<dim> &particle);
168
175 static dealii::Tensor<1, size_angular_velocity, number>
176 get_torque(const dealii::Particles::ParticleAccessor<dim> &particle);
177
182 static dealii::Tensor<1, size_angular_velocity, number>
183 get_torque(dealii::Particles::PropertyPool<dim> &property_pool,
184 typename dealii::Particles::PropertyPool<dim>::Handle handle);
185
193 static void
194 set_torque(const dealii::Tensor<1, size_angular_velocity, number> &torque,
195 dealii::Particles::ParticleAccessor<dim> &particle);
196
201 static void
202 set_torque(const dealii::Tensor<1, size_angular_velocity, number> &torque,
203 dealii::Particles::PropertyPool<dim> &property_pool,
204 typename dealii::Particles::PropertyPool<dim>::Handle handle);
205
213 static void
214 accumulate_torque(const dealii::Tensor<1, size_angular_velocity, number> &torque,
215 dealii::Particles::ParticleAccessor<dim> &particle);
216
221 static void
222 accumulate_torque(const dealii::Tensor<1, size_angular_velocity, number> &torque,
223 dealii::Particles::PropertyPool<dim> &property_pool,
224 typename dealii::Particles::PropertyPool<dim>::Handle handle);
225
232 static dealii::Tensor<1, dim, number>
233 get_force(const dealii::Particles::ParticleAccessor<dim> &particle);
234
239 static dealii::Tensor<1, dim, number>
240 get_force(dealii::Particles::PropertyPool<dim> &property_pool,
241 typename dealii::Particles::PropertyPool<dim>::Handle handle);
242
250 static void
251 set_force(const dealii::Tensor<1, dim, number> &force,
252 dealii::Particles::ParticleAccessor<dim> &particle);
253
258 static void
259 set_force(const dealii::Tensor<1, dim, number> &force,
260 dealii::Particles::PropertyPool<dim> &property_pool,
261 typename dealii::Particles::PropertyPool<dim>::Handle handle);
262
270 static void
271 accumulate_force(const dealii::Tensor<1, dim, number> &force,
272 dealii::Particles::ParticleAccessor<dim> &particle);
273
278 static void
279 accumulate_force(const dealii::Tensor<1, dim, number> &force,
280 dealii::Particles::PropertyPool<dim> &property_pool,
281 typename dealii::Particles::PropertyPool<dim>::Handle handle);
282
290 template <typename VectorizedArrayType>
291 static dealii::Tensor<1, dim, VectorizedArrayType>
292 get_velocity(const dealii::Particles::ParticleAccessor<dim> &particle);
293
294 static void
295 set_velocity(dealii::Particles::ParticleAccessor<dim> &particle,
296 const dealii::Tensor<1, dim, number> &velocity);
297
310 template <typename VectorizedArrayType>
311 static dealii::Tensor<1, dim, VectorizedArrayType>
312 get_velocity(const dealii::Particles::PropertyPool<dim> &property_pool,
313 typename dealii::Particles::PropertyPool<dim>::Handle handle);
314
333 template <typename VectorizedArrayType>
334 static dealii::Tensor<1, dim, VectorizedArrayType>
335 get_velocity(const dealii::Particles::ParticleAccessor<dim> &particle,
336 const dealii::Point<dim, VectorizedArrayType> &location);
337
360 template <typename VectorizedArrayType>
361 static dealii::Tensor<1, dim, VectorizedArrayType>
362 get_velocity(const dealii::Particles::PropertyPool<dim> &property_pool,
363 typename dealii::Particles::PropertyPool<dim>::Handle handle,
364 const dealii::Point<dim, VectorizedArrayType> &location);
365
375 static dealii::Tensor<1, dim, number>
376 get_acceleration(const dealii::Particles::ParticleAccessor<dim> &particle);
377
396 static dealii::Tensor<1, dim, number>
397 get_acceleration(const dealii::Particles::ParticleAccessor<dim> &particle,
398 const dealii::Point<dim, number> &location);
399
406 static void
407 set_acceleration(dealii::Particles::ParticleAccessor<dim> &particle,
408 const dealii::Tensor<1, dim, number> &acceleration);
409
416 static dealii::Tensor<1, size_angular_velocity, number>
417 get_angular_velocity(const dealii::Particles::ParticleAccessor<dim> &particle);
418
419
427 static dealii::Tensor<1, size_angular_velocity, number>
428 get_angular_velocity(const dealii::Particles::PropertyPool<dim> &property_pool,
429 typename dealii::Particles::PropertyPool<dim>::Handle handle);
430
437 static dealii::Tensor<1, size_angular_velocity, number>
438 get_angular_acceleration(const dealii::Particles::ParticleAccessor<dim> &particle);
439
446 static void
447 set_angular_acceleration(dealii::Particles::ParticleAccessor<dim> &particle,
448 const dealii::Tensor<1, size_angular_velocity, number> &acceleration);
449
464 static number
465 get_property(const dealii::Particles::ParticleAccessor<dim> &particle, Properties property);
466
484 static number
485 get_property(const dealii::Particles::PropertyPool<dim> &property_pool,
486 typename dealii::Particles::PropertyPool<dim>::Handle handle,
487 const Properties property);
488
505 static bool
506 is_in_cell(const dealii::Particles::ParticleAccessor<dim> &particle,
507 const dealii::CellAccessor<dim> &cell)
508 {
509 return particle.get_location().distance(cell.center()) <
510 get_property(particle, Properties::radius) + 0.5 * cell.diameter();
511 }
512
528 static bool
529 is_in_cell(dealii::Particles::PropertyPool<dim> &property_pool,
530 typename dealii::Particles::PropertyPool<dim>::Handle handle,
531 const dealii::CellAccessor<dim> &cell)
532 {
533 return property_pool.get_location(handle).distance(cell.center()) <
534 get_property(property_pool, handle, Properties::radius) + 0.5 * cell.diameter();
535 }
536
540 static number
541 get_characteristic_length(const dealii::Particles::ParticleAccessor<dim> &particle);
542 };
543} // namespace MeltPoolDG
544
545template <int dim, typename number>
546number
548 const dealii::Particles::ParticleAccessor<dim> &particle,
549 const Properties property)
550{
551 Assert(property >= Properties::radius,
552 dealii::ExcMessage(
553 "For access of particle velocities use the specific velocity getters!"));
554 return particle.get_properties()[property];
555}
556
557template <int dim, typename number>
558number
560 const dealii::Particles::PropertyPool<dim> &property_pool,
561 typename dealii::Particles::PropertyPool<dim>::Handle handle,
562 const Properties property)
563{
564 Assert(property >= Properties::radius,
565 dealii::ExcMessage(
566 "For access of particle velocities use the specific velocity getters!"));
567
568 // we use a const cast here as the property pool does not provide a const call to
569 // get_properties(). As we do not modify any properties here and only return a copy of the desired
570 // property this can be safely done.
571 return const_cast<dealii::Particles::PropertyPool<dim> &>(property_pool)
572 .get_properties(handle)[property];
573}
574
575template <int dim, typename number>
576auto
578 const dealii::Particles::ParticleAccessor<dim> &particle)
579 -> dealii::Tensor<1, size_angular_velocity, number>
580{
581 dealii::ArrayView<const number> properties = particle.get_properties();
582 dealii::Tensor<1, size_angular_velocity, number> angular_velocity;
583 for (unsigned int dimension = 0; dimension < size_angular_velocity; ++dimension)
584 angular_velocity[dimension] = properties[Properties::angular_velocity + dimension];
585 return angular_velocity;
586}
587
588template <int dim, typename number>
589auto
591 const dealii::Particles::PropertyPool<dim> &property_pool,
592 typename dealii::Particles::PropertyPool<dim>::Handle handle)
593 -> dealii::Tensor<1, size_angular_velocity, number>
594{
595 // We use a const cast here as the property pool does not provide a const call to
596 // get_properties(). As we do not modify any properties here and only return a copy of the desired
597 // property this can be safely done.
598 const dealii::ArrayView<const number> properties =
599 const_cast<dealii::Particles::PropertyPool<dim> &>(property_pool).get_properties(handle);
600
601 dealii::Tensor<1, size_angular_velocity, number> angular_velocity;
602 for (unsigned int dimension = 0; dimension < size_angular_velocity; ++dimension)
603 angular_velocity[dimension] = properties[Properties::angular_velocity + dimension];
604 return angular_velocity;
605}
606
607template <int dim, typename number>
608auto
610 const dealii::Particles::ParticleAccessor<dim> &particle)
611 -> dealii::Tensor<1, size_angular_velocity, number>
612{
613 dealii::ArrayView<const number> properties = particle.get_properties();
614 dealii::Tensor<1, size_angular_velocity, number> angular_acceleration;
615 for (int dimension = 0; dimension < size_angular_velocity; ++dimension)
616 angular_acceleration[dimension] = properties[Properties::angular_acceleration + dimension];
617 return angular_acceleration;
618}
619
620template <int dim, typename number>
621void
623 dealii::Particles::ParticleAccessor<dim> &particle,
624 const dealii::Tensor<1, size_angular_velocity, number> &angular_acceleration)
625{
626 dealii::ArrayView<number> properties = particle.get_properties();
627 for (unsigned dimension = 0; dimension < size_angular_velocity; ++dimension)
628 properties[Properties::angular_acceleration + dimension] = angular_acceleration[dimension];
629}
630
631template <int dim, typename number>
632dealii::Tensor<1, dim, number>
634 const dealii::Particles::ParticleAccessor<dim> &particle)
635{
636 dealii::ArrayView<const number> properties = particle.get_properties();
637 dealii::Tensor<1, dim, number> acceleration;
638 for (int dimension = 0; dimension < dim; ++dimension)
639 acceleration[dimension] = properties[Properties::acceleration + dimension];
640 return acceleration;
641}
642
643template <int dim, typename number>
644void
646 dealii::Particles::ParticleAccessor<dim> &particle,
647 const dealii::Tensor<1, dim, number> &acceleration)
648{
649 dealii::ArrayView<number> properties = particle.get_properties();
650 for (int dimension = 0; dimension < dim; ++dimension)
651 properties[Properties::acceleration + dimension] = acceleration[dimension];
652}
653
654template <int dim, typename number>
655auto
657 const dealii::Particles::ParticleAccessor<dim> &particle)
658 -> dealii::Tensor<1, size_angular_velocity, number>
659{
660 dealii::ArrayView<const number> properties = particle.get_properties();
661 dealii::Tensor<1, size_angular_velocity, number> torque;
662 for (unsigned i = 0; i < size_angular_velocity; ++i)
663 torque[i] = properties[Properties::torque + i];
664 return torque;
665}
666
667template <int dim, typename number>
668auto
670 dealii::Particles::PropertyPool<dim> &property_pool,
671 typename dealii::Particles::PropertyPool<dim>::Handle handle)
672 -> dealii::Tensor<1, size_angular_velocity, number>
673{
674 dealii::ArrayView<const number> properties = property_pool.get_properties(handle);
675 dealii::Tensor<1, size_angular_velocity, number> torque;
676 for (unsigned i = 0; i < size_angular_velocity; ++i)
677 torque[i] = properties[Properties::torque + i];
678 return torque;
679}
680
681template <int dim, typename number>
682void
684 const dealii::Tensor<1, size_angular_velocity, number> &torque,
685 dealii::Particles::ParticleAccessor<dim> &particle)
686{
687 dealii::ArrayView<number> properties = particle.get_properties();
688 for (unsigned i = 0; i < size_angular_velocity; ++i)
689 properties[Properties::torque + i] = torque[i];
690}
691
692template <int dim, typename number>
693void
695 const dealii::Tensor<1, size_angular_velocity, number> &torque,
696 dealii::Particles::PropertyPool<dim> &property_pool,
697 typename dealii::Particles::PropertyPool<dim>::Handle handle)
698{
699 dealii::ArrayView<number> properties = property_pool.get_properties(handle);
700 for (unsigned i = 0; i < size_angular_velocity; ++i)
701 properties[Properties::torque + i] = torque[i];
702}
703
704template <int dim, typename number>
705void
707 const dealii::Tensor<1, size_angular_velocity, number> &torque,
708 dealii::Particles::ParticleAccessor<dim> &particle)
709{
710 dealii::ArrayView<number> properties = particle.get_properties();
711 for (unsigned i = 0; i < size_angular_velocity; ++i)
712 properties[Properties::torque + i] += torque[i];
713}
714
715
716template <int dim, typename number>
717void
719 const dealii::Tensor<1, size_angular_velocity, number> &torque,
720 dealii::Particles::PropertyPool<dim> &property_pool,
721 typename dealii::Particles::PropertyPool<dim>::Handle handle)
722{
723 dealii::ArrayView<number> properties = property_pool.get_properties(handle);
724 for (unsigned i = 0; i < size_angular_velocity; ++i)
725 properties[Properties::torque + i] += torque[i];
726}
727
728template <int dim, typename number>
729void
731 const dealii::Tensor<1, dim, number> &force,
732 dealii::Particles::ParticleAccessor<dim> &particle)
733{
734 dealii::ArrayView<number> properties = particle.get_properties();
735 for (int dimension = 0; dimension < dim; ++dimension)
736 properties[Properties::force + dimension] = force[dimension];
737}
738
739template <int dim, typename number>
740void
742 const dealii::Tensor<1, dim, number> &force,
743 dealii::Particles::PropertyPool<dim> &property_pool,
744 typename dealii::Particles::PropertyPool<dim>::Handle handle)
745{
746 dealii::ArrayView<number> properties = property_pool.get_properties(handle);
747 for (int dimension = 0; dimension < dim; ++dimension)
748 properties[Properties::force + dimension] = force[dimension];
749}
750
751template <int dim, typename number>
752void
754 const dealii::Tensor<1, dim, number> &force,
755 dealii::Particles::ParticleAccessor<dim> &particle)
756{
757 dealii::ArrayView<number> properties = particle.get_properties();
758 for (int dimension = 0; dimension < dim; ++dimension)
759 properties[Properties::force + dimension] += force[dimension];
760}
761
762template <int dim, typename number>
763void
765 const dealii::Tensor<1, dim, number> &force,
766 dealii::Particles::PropertyPool<dim> &property_pool,
767 typename dealii::Particles::PropertyPool<dim>::Handle handle)
768{
769 dealii::ArrayView<number> properties = property_pool.get_properties(handle);
770 for (int dimension = 0; dimension < dim; ++dimension)
771 properties[Properties::force + dimension] += force[dimension];
772}
773
774template <int dim, typename number>
775dealii::Tensor<1, dim, number>
777 const dealii::Particles::ParticleAccessor<dim> &particle)
778{
779 dealii::ArrayView<const number> properties = particle.get_properties();
780 dealii::Tensor<1, dim, number> force;
781 for (int dimension = 0; dimension < dim; ++dimension)
782 force[dimension] = properties[Properties::force + dimension];
783 return force;
784}
785
786template <int dim, typename number>
787dealii::Tensor<1, dim, number>
789 dealii::Particles::PropertyPool<dim> &property_pool,
790 typename dealii::Particles::PropertyPool<dim>::Handle handle)
791{
792 dealii::ArrayView<const number> properties = property_pool.get_properties(handle);
793 dealii::Tensor<1, dim, number> force;
794 for (int dimension = 0; dimension < dim; ++dimension)
795 force[dimension] = properties[Properties::force + dimension];
796 return force;
797}
798
799template <int dim, typename number>
800template <typename VectorizedArrayType>
801dealii::Tensor<1, dim, VectorizedArrayType>
803 const dealii::Particles::ParticleAccessor<dim> &particle)
804{
805 dealii::ArrayView<const number> properties = particle.get_properties();
806 dealii::Tensor<1, dim, number> velocity;
807 for (int dimension = 0; dimension < dim; ++dimension)
808 velocity[dimension] = properties[Properties::velocity + dimension];
809 return velocity;
810}
811
812template <int dim, typename number>
813void
815 dealii::Particles::ParticleAccessor<dim> &particle,
816 const dealii::Tensor<1, dim, number> &velocity)
817{
818 dealii::ArrayView<number> properties = particle.get_properties();
819 for (int dimension = 0; dimension < dim; ++dimension)
820 properties[Properties::velocity + dimension] = velocity[dimension];
821}
822
823template <int dim, typename number>
824template <typename VectorizedArrayType>
825dealii::Tensor<1, dim, VectorizedArrayType>
827 const dealii::Particles::PropertyPool<dim> &property_pool,
828 const typename dealii::Particles::PropertyPool<dim>::Handle handle)
829{
830 // We use a const cast here as the property pool does not provide a const call to
831 // get_properties(). As we do not modify any properties here and only return a copy of the desired
832 // property this can be safely done.
833 dealii::ArrayView<const number> properties =
834 const_cast<dealii::Particles::PropertyPool<dim> &>(property_pool).get_properties(handle);
835
836 dealii::Tensor<1, dim, number> velocity;
837 for (int dimension = 0; dimension < dim; ++dimension)
838 velocity[dimension] = properties[Properties::velocity + dimension];
839 return velocity;
840}
841
842template <int dim, typename number>
843template <typename VectorizedArrayType>
844dealii::Tensor<1, dim, VectorizedArrayType>
846 const dealii::Particles::ParticleAccessor<dim> &particle,
847 const dealii::Point<dim, VectorizedArrayType> &location)
848{
849 Assert(dim == 2 or dim == 3, dealii::ExcMessage("Invalid dimension!"));
850
851 dealii::Point<dim, dealii::VectorizedArray<number>> vectorized_particle_location;
852 for (auto i = 0; i < dim; ++i)
853 vectorized_particle_location[i] = dealii::VectorizedArray<number>(particle.get_location()[i]);
854
855 dealii::Tensor<1, dim, VectorizedArrayType> distance_to_center =
856 location - vectorized_particle_location;
857 if constexpr (dim == 2)
858 {
859 return dealii::cross_product_2d(get_angular_velocity(particle)[0] * distance_to_center) +
860 get_velocity<VectorizedArrayType>(particle);
861 }
862 if constexpr (dim == 3)
863 {
864 return get_velocity<VectorizedArrayType>(particle) +
865 dealii::cross_product_3d(get_angular_velocity(particle), distance_to_center);
866 }
867 AssertThrow(false, dealii::ExcInternalError());
868}
869
870template <int dim, typename number>
871template <typename VectorizedArrayType>
872dealii::Tensor<1, dim, VectorizedArrayType>
874 const dealii::Particles::PropertyPool<dim> &property_pool,
875 const typename dealii::Particles::PropertyPool<dim>::Handle handle,
876 const dealii::Point<dim, VectorizedArrayType> &location)
877{
878 Assert(dim == 2 or dim == 3, dealii::ExcMessage("Invalid dimension!"));
879
880 dealii::Point<dim, dealii::VectorizedArray<number>> vectorized_particle_location;
881 for (auto i = 0; i < dim; ++i)
882 vectorized_particle_location[i] =
883 dealii::VectorizedArray<number>(property_pool.get_location(handle)[i]);
884
885 dealii::Tensor<1, dim, VectorizedArrayType> distance_to_center =
886 location - vectorized_particle_location;
887 if constexpr (dim == 2)
888 {
889 return dealii::cross_product_2d(get_angular_velocity(property_pool, handle)[0] *
890 distance_to_center) +
891 get_velocity<VectorizedArrayType>(property_pool, handle);
892 }
893 if constexpr (dim == 3)
894 {
895 return get_velocity<VectorizedArrayType>(property_pool, handle) +
896 dealii::cross_product_3d(get_angular_velocity(property_pool, handle),
897 distance_to_center);
898 }
899 AssertThrow(false, dealii::ExcInternalError());
900}
901
902template <int dim, typename number>
903template <typename VectorizedArrayType>
904auto
906 const dealii::Point<dim, VectorizedArrayType> &loc,
907 dealii::Particles::PropertyPool<dim> &property_pool,
908 const typename dealii::Particles::PropertyPool<dim>::Handle handle)
909 -> dealii::Tensor<1, dim, VectorizedArrayType>
910{
911 dealii::Point<dim, VectorizedArrayType> particle_loc;
912
913 for (int i = 0; i < dim; ++i)
914 particle_loc[i] = VectorizedArrayType(property_pool.get_location(handle)[i]);
915
916 return particle_loc - loc;
917}
918
919template <int dim, typename number>
920template <typename VectorizedArrayType>
921auto
923 const dealii::Point<dim, VectorizedArrayType> &loc,
924 const dealii::Particles::ParticleAccessor<dim> &particle)
925 -> dealii::Tensor<1, dim, VectorizedArrayType>
926{
927 dealii::Tensor<1, dim, VectorizedArrayType> vec_to_center = particle.get_location() - loc;
928 return (1 - get_property(Properties::radius) / vec_to_center.norm()) * vec_to_center;
929}
930
931template <int dim, typename number>
932dealii::Tensor<1, dim, number>
934 const dealii::Particles::ParticleAccessor<dim> &particle,
935 const dealii::Point<dim, number> &location)
936{
937 Assert(dim == 2 or dim == 3, dealii::ExcMessage("Invalid dimension!"));
938
939 dealii::Tensor<1, dim, number> distance_to_center = location - particle.get_location();
940 if constexpr (dim == 2)
941 {
942 return dealii::cross_product_2d(get_angular_acceleration(particle) * distance_to_center) +
943 get_acceleration(particle);
944 }
945 if constexpr (dim == 3)
946 {
947 return get_acceleration(particle) +
948 dealii::cross_product_3d(get_angular_acceleration(particle), distance_to_center);
949 }
950 AssertThrow(false, dealii::ExcInternalError());
951}
952
953template <int dim, typename number>
954number
956 const dealii::Particles::ParticleAccessor<dim> &particle)
957{
958 return particle.get_properties()[Properties::radius];
959}
Class representing a finite-sized spherical particle, intended for use with the obstacle field class.
Definition particle.hpp:35
static bool is_in_cell(dealii::Particles::PropertyPool< dim > &property_pool, typename dealii::Particles::PropertyPool< dim >::Handle handle, const dealii::CellAccessor< dim > &cell)
Estimates whether a particle identified in a property pool likely intersects a cell.
Definition particle.hpp:529
static std::pair< std::vector< std::string >, std::vector< dealii::DataComponentInterpretation::DataComponentInterpretation > > get_property_names_and_component_interpretation()
Provides the names and component interpretations of particle properties for output.
Definition particle.hpp:85
Properties
Enum to define the index of each property in the particle's property vector.
Definition particle.hpp:54
@ torque
Definition particle.hpp:60
@ radius
Definition particle.hpp:61
@ moment_of_inertia
Definition particle.hpp:65
@ force
Definition particle.hpp:59
@ volume
Definition particle.hpp:62
@ density
Definition particle.hpp:63
@ mass
Definition particle.hpp:64
@ angular_acceleration
Definition particle.hpp:58
@ velocity
Definition particle.hpp:55
@ angular_velocity
Definition particle.hpp:57
@ particle_id
Definition particle.hpp:68
@ acceleration
Definition particle.hpp:56
static dealii::Tensor< 1, size_angular_velocity, number > get_angular_acceleration(const dealii::Particles::ParticleAccessor< dim > &particle)
Returns the angular acceleration of a given particle.
Definition particle.hpp:609
static void set_velocity(dealii::Particles::ParticleAccessor< dim > &particle, const dealii::Tensor< 1, dim, number > &velocity)
Definition particle.hpp:814
static number get_property(const dealii::Particles::ParticleAccessor< dim > &particle, Properties property)
Provides access to a specific single-valued property of a given particle.
Definition particle.hpp:547
static dealii::Tensor< 1, size_angular_velocity, number > get_torque(const dealii::Particles::ParticleAccessor< dim > &particle)
Returns the torque vector acting on the given particle.
Definition particle.hpp:656
static constexpr unsigned int n_obstacle_properties
Definition particle.hpp:47
static void accumulate_force(const dealii::Tensor< 1, dim, number > &force, dealii::Particles::ParticleAccessor< dim > &particle)
Accumulates the specified force vector to the particle by adding its components into the particle's p...
Definition particle.hpp:753
static dealii::Tensor< 1, dim, VectorizedArrayType > vector_to_center_of_gravity(const dealii::Point< dim, VectorizedArrayType > &loc, dealii::Particles::PropertyPool< dim > &property_pool, const typename dealii::Particles::PropertyPool< dim >::Handle handle)
static bool is_in_cell(const dealii::Particles::ParticleAccessor< dim > &particle, const dealii::CellAccessor< dim > &cell)
Estimates whether a particle likely intersects or encloses a given cell.
Definition particle.hpp:506
static void set_angular_acceleration(dealii::Particles::ParticleAccessor< dim > &particle, const dealii::Tensor< 1, size_angular_velocity, number > &acceleration)
Sets the angular acceleration of the specified particle.
Definition particle.hpp:622
static void accumulate_torque(const dealii::Tensor< 1, size_angular_velocity, number > &torque, dealii::Particles::ParticleAccessor< dim > &particle)
Accumulates the specified torque vector to the particle by adding its components into the particle's ...
Definition particle.hpp:706
static dealii::Tensor< 1, dim, number > get_force(const dealii::Particles::ParticleAccessor< dim > &particle)
Returns the force vector acting on the given particle.
Definition particle.hpp:776
static dealii::Tensor< 1, dim, number > get_acceleration(const dealii::Particles::ParticleAccessor< dim > &particle)
Returns the translational acceleration of the specified particle.
Definition particle.hpp:633
static void set_torque(const dealii::Tensor< 1, size_angular_velocity, number > &torque, dealii::Particles::ParticleAccessor< dim > &particle)
Assigns the specified torque vector to the particle by writing its components into the particle's pro...
Definition particle.hpp:683
static dealii::Tensor< 1, size_angular_velocity, number > get_angular_velocity(const dealii::Particles::ParticleAccessor< dim > &particle)
Returns the angular velocity of the given particle.
Definition particle.hpp:577
static number get_characteristic_length(const dealii::Particles::ParticleAccessor< dim > &particle)
Definition particle.hpp:955
static void set_force(const dealii::Tensor< 1, dim, number > &force, dealii::Particles::ParticleAccessor< dim > &particle)
Assigns the specified force vector to the particle by writing its components into the particle's prop...
Definition particle.hpp:730
static constexpr unsigned int size_angular_velocity
Definition particle.hpp:38
static dealii::Tensor< 1, dim, VectorizedArrayType > vector_to_surface(const dealii::Point< dim, VectorizedArrayType > &loc, const dealii::Particles::ParticleAccessor< dim > &particle)
static dealii::Tensor< 1, dim, VectorizedArrayType > get_velocity(const dealii::Particles::ParticleAccessor< dim > &particle)
Returns the translational velocity vector of the specified particle, i.e., the velocity at the partic...
Definition particle.hpp:802
static void set_acceleration(dealii::Particles::ParticleAccessor< dim > &particle, const dealii::Tensor< 1, dim, number > &acceleration)
Sets the translational acceleration of the specified particle.
Definition particle.hpp:645
Interface for a general preconditioner.
Definition boundary_condition_functions.hpp:17