7#ifndef SURFACECOUPLING_H_
8#define SURFACECOUPLING_H_
36template <MInt nDim,
class S,
class T,
class M,
class C>
40 for(
MInt srcId = 0; srcId < src.size(); srcId++) {
41 std::array<MFloat, nDim> force{};
42 for(
MInt n = 0; n < nDim; n++) {
43 force[n] = src.force(srcId, n) * conversion.force;
46 for(
auto&& tgtId : mapping[srcId]) {
47 tgt.addForce(tgtId, force);
70template <MInt nDim,
class S,
class T,
class M,
class C>
72 static constexpr MInt nRot = (nDim == 3) ? 3 : 1;
77 for(
MInt srcId = 0; srcId < src.size(); srcId++) {
78 for(
MInt j = 0; j < src.noForces(); j++) {
79 std::array<MFloat, nDim> force{};
80 for(
MInt n = 0; n < nDim; n++) {
81 force[n] = src.force(srcId, j, n) * conversion.force;
84 for(
auto&& tgtId : mapping[srcId]) {
85 tgt.addForce(tgtId, force);
87 std::array<MFloat, nDim> r{};
88 for(
MInt n = 0; n < nDim; n++) {
89 r[n] = (src.surfaceCenter(srcId, j, n) - tgt.a_bodyCenter(tgtId, n)) * conversion.length;
92 std::array<MFloat, nRot> torque{};
93 if constexpr(nDim == 3) {
95 }
else if constexpr(nDim == 2) {
96 torque[0] = force[0] * r[1] - force[1] * r[0];
99 tgt.addTorque(tgtId, torque);
123template <MInt nDim,
class S,
class T,
class M,
class C>
125 static constexpr MInt nRot = (nDim == 3) ? 3 : 1;
127 if(mapping.size() == 0) {
131 for(
MInt srcId = 0; srcId < src.size(); srcId++) {
132 std::array<MFloat, nDim> velocity{};
133 src.getVelocity(srcId, velocity);
134 for(
MInt n = 0; n < nDim; n++) {
135 velocity[n] *= conversion.velocity;
138 std::array<MFloat, nRot> angularVelocity{};
139 src.getAngularVelocity(srcId, angularVelocity);
140 for(
MInt n = 0; n < nRot; n++) {
141 angularVelocity[n] *= conversion.angularVelocity;
144 for(
auto&& tgtId : mapping[srcId]) {
145 std::array<MFloat, nDim> r{};
146 for(
MInt n = 0; n < nDim; n++) {
147 r[n] = (tgt.cellCenter(tgtId, n) - src.a_bodyCenter(srcId, n)) * conversion.length;
149 std::array<MFloat, nDim> rotationalVelocity{};
150 IF_CONSTEXPR(nDim == 3) { rotationalVelocity =
maia::math::cross(r, angularVelocity); }
151 else IF_CONSTEXPR(nDim == 2) {
152 rotationalVelocity[0] = angularVelocity[0] * r[0];
153 rotationalVelocity[1] = angularVelocity[0] * r[1];
156 tgt.setVelocity(tgtId, velocity);
157 tgt.addVelocity(tgtId, rotationalVelocity);
199 std::vector<MInt>::const_iterator bb =
m_mapped.begin() +
b;
200 std::vector<MInt>::const_iterator ee =
m_mapped.begin() + e;
245 for(
MUint j = 0; j < noNewKeys; j++) {
254 std::cerr <<
"Map insert shouldnt reach this case" << std::endl;
Simple implementation of c++20 range.
void setBoundaryForceAndTorque(S &src, T &tgt, M &mapping, C conversion)
Setting the boundary force and torque from one surface collector to the other.
void setBoundaryForce(S &src, T &tgt, M &mapping, C conversion)
Setting the boundary force from one surface collector to the other.
void setBoundaryVelocity(S &src, T &tgt, M &mapping, C conversion)
Setting the boundary velocity from one surface collector to the other.
void cross(const T *const u, const T *const v, T *const c)
Multi-to-multi mapping class.
std::vector< MUint > m_offsets
range< std::vector< MInt >::const_iterator > operator[](const MInt i) const
range< std::vector< MInt >::const_iterator > get(const MUint i) const
std::vector< MInt > m_mapped
MInt & insert(const MInt i)