MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
maia::coupling Namespace Reference

Classes

struct  Mapping
 Multi-to-multi mapping class. More...
 
class  range
 Simple implementation of c++20 range. More...
 

Functions

template<MInt nDim, class S , class T , class M , class C >
void setBoundaryForce (S &src, T &tgt, M &mapping, C conversion)
 Setting the boundary force from one surface collector to the other. More...
 
template<MInt nDim, class S , class T , class M , class C >
void setBoundaryForceAndTorque (S &src, T &tgt, M &mapping, C conversion)
 Setting the boundary force and torque from one surface collector to the other. More...
 
template<MInt nDim, class S , class T , class M , class C >
void setBoundaryVelocity (S &src, T &tgt, M &mapping, C conversion)
 Setting the boundary velocity from one surface collector to the other. More...
 

Function Documentation

◆ setBoundaryForce()

template<MInt nDim, class S , class T , class M , class C >
void maia::coupling::setBoundaryForce ( S &  src,
T &  tgt,
M &  mapping,
conversion 
)

Looping over all source surfaces (e.g. cells) and apply the forces to all mapped target surfaces (e.g. bodies)

Author
Julian Vorspohl j.vor.nosp@m.spoh.nosp@m.l@aia.nosp@m..rwt.nosp@m.h-aac.nosp@m.hen..nosp@m.de
Template Parameters
nDimNumber of dimensions
SSource collector type
TTarget collector type
MMapping type
CConversion factor type
Parameters
[in]srcSource collector of surfaces
[out]tgtTarget collector of surfaces
[in]mappingMapping between source and target surfaces
[in]conversionCoversion factors between source and target unit system

Definition at line 37 of file surfacecoupling.h.

37 {
38 tgt.resetForce();
39
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;
44 }
45
46 for(auto&& tgtId : mapping[srcId]) {
47 tgt.addForce(tgtId, force);
48 }
49 }
50}
int32_t MInt
Definition: maiatypes.h:62

◆ setBoundaryForceAndTorque()

template<MInt nDim, class S , class T , class M , class C >
void maia::coupling::setBoundaryForceAndTorque ( S &  src,
T &  tgt,
M &  mapping,
conversion 
)

Looping over all source surfaces (e.g. cells) and apply the forces to all mapped target surfaces (e.g. bodies)

Author
Julian Vorspohl j.vor.nosp@m.spoh.nosp@m.l@aia.nosp@m..rwt.nosp@m.h-aac.nosp@m.hen..nosp@m.de
Template Parameters
nDimNumber of dimensions
SSource collector type
TTarget collector type
MMapping type
CConversion factor type
Parameters
[in]srcSource collector of surfaces
[out]tgtTarget collector of surfaces
[in]mappingMapping between source and target surfaces
[in]conversionCoversion factors between source and target unit system

Definition at line 71 of file surfacecoupling.h.

71 {
72 static constexpr MInt nRot = (nDim == 3) ? 3 : 1;
73
74 tgt.resetForce();
75 tgt.resetTorque();
76
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;
82 }
83
84 for(auto&& tgtId : mapping[srcId]) {
85 tgt.addForce(tgtId, force);
86
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;
90 }
91
92 std::array<MFloat, nRot> torque{};
93 if constexpr(nDim == 3) {
94 torque = maia::math::cross(force, r);
95 } else if constexpr(nDim == 2) {
96 torque[0] = force[0] * r[1] - force[1] * r[0];
97 }
98
99 tgt.addTorque(tgtId, torque);
100 }
101 }
102 }
103}
void cross(const T *const u, const T *const v, T *const c)
Definition: maiamath.h:101

◆ setBoundaryVelocity()

template<MInt nDim, class S , class T , class M , class C >
void maia::coupling::setBoundaryVelocity ( S &  src,
T &  tgt,
M &  mapping,
conversion 
)

Looping over all source surfaces (e.g. cells) and apply the forces to all mapped target surfaces (e.g. bodies)

Author
Julian Vorspohl j.vor.nosp@m.spoh.nosp@m.l@aia.nosp@m..rwt.nosp@m.h-aac.nosp@m.hen..nosp@m.de
Template Parameters
nDimNumber of dimensions
SSource collector type
TTarget collector type
MMapping type
CConversion factor type
Parameters
[in]srcSource collector of surfaces
[out]tgtTarget collector of surfaces
[in]mappingMapping between source and target surfaces
[in]conversionCoversion factors between source and target unit system

Definition at line 124 of file surfacecoupling.h.

124 {
125 static constexpr MInt nRot = (nDim == 3) ? 3 : 1;
126
127 if(mapping.size() == 0) {
128 return;
129 }
130
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;
136 }
137
138 std::array<MFloat, nRot> angularVelocity{};
139 src.getAngularVelocity(srcId, angularVelocity);
140 for(MInt n = 0; n < nRot; n++) {
141 angularVelocity[n] *= conversion.angularVelocity;
142 }
143
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;
148 }
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];
154 }
155
156 tgt.setVelocity(tgtId, velocity);
157 tgt.addVelocity(tgtId, rotationalVelocity);
158 }
159 }
160}