25#ifndef FRAME_CHANGE_F_3D_HH
26#define FRAME_CHANGE_F_3D_HH
39#define M_PI 3.14159265358979323846
47 std::vector<T> axisDirection_, T w_, T scale_)
48 :
AnalyticalF3D<T,T>(3), axisPoint(axisPoint_), axisDirection(axisDirection_),
49 w(w_), scale(scale_) { }
55 output[0] = (axisDirection[1]*(x[2]-axisPoint[2]) - axisDirection[2]*(x[1]-axisPoint[1]))*w*scale;
56 output[1] = (axisDirection[2]*(x[0]-axisPoint[0]) - axisDirection[0]*(x[2]-axisPoint[2]))*w*scale;
57 output[2] = (axisDirection[0]*(x[1]-axisPoint[1]) - axisDirection[1]*(x[0]-axisPoint[0]))*w*scale;
65 std::vector<T> axisDirection_, T w_, T ri_, T ro_, T scale_)
66 :
AnalyticalF3D<T,T>(3), axisPoint(axisPoint_), axisDirection(axisDirection_),
67 w(w_), ri(ri_), ro(ro_), scale(scale_) { }
74 if ( (
util::sqrt((x[0]-axisPoint[0])*(x[0]-axisPoint[0])+(x[1]-axisPoint[1])*(x[1]-axisPoint[1])) < ri) || (
util::sqrt((x[0]-axisPoint[0])*(x[0]-axisPoint[0])+(x[1]-axisPoint[1])*(x[1]-axisPoint[1])) >= ro) ) {
85 if ( (axisDirection[2] && (x[0] == axisPoint[0])) || (axisDirection[1] && (x[2] == axisPoint[2])) || (axisDirection[0] && (x[1] == axisPoint[1])) ) {
87 if ( (axisDirection[2] && (x[1] < axisPoint[1])) || (axisDirection[1] && (x[0] < axisPoint[0])) || (axisDirection[0] && (x[2] < axisPoint[2])) ) {
91 si[0] = axisDirection[0]*x[0] + axisDirection[1]*(axisPoint[0]+sign*ri) + axisDirection[2]*x[0];
92 si[1] = axisDirection[0]*x[1] + axisDirection[1]*x[1] + axisDirection[2]*(axisPoint[1]+sign*ri);
93 si[2] = axisDirection[0]*(axisPoint[2]+sign*ri) + axisDirection[1]*x[2] + axisDirection[2]*x[2];
95 so[0] = axisDirection[0]*x[0] + axisDirection[1]*(axisPoint[0]+sign*ro) + axisDirection[2]*x[0];
96 so[1] = axisDirection[0]*x[1] + axisDirection[1]*x[1] + axisDirection[2]*(axisPoint[1]+sign*ro);
97 so[2] = axisDirection[0]*(axisPoint[2]+sign*ro) + axisDirection[1]*x[2] + axisDirection[2]*x[2];
102 if ( (axisDirection[2] && (x[0] < axisPoint[0])) || (axisDirection[1] && (x[2] < axisPoint[2])) || (axisDirection[0] && (x[1] < axisPoint[1])) ) {
105 if ( (axisDirection[2] && (x[1] < axisPoint[1])) || (axisDirection[1] && (x[0] < axisPoint[0])) || (axisDirection[0] && (x[2] < axisPoint[2])) ) {
108 alpha =
util::atan( ( sign2*(axisDirection[0]*(x[2]-axisPoint[2]) + axisDirection[1]*(x[0]-axisPoint[0]) + axisDirection[2]*(x[1]-axisPoint[1]) ) ) / \
109 (sign1*(axisDirection[0]*(x[1]-axisPoint[1]) + axisDirection[1]*(x[2]-axisPoint[2]) + axisDirection[2]*(x[0]-axisPoint[0]))) );
110 si[0] = axisDirection[0]*x[0] + axisDirection[1]*sign2*
util::sin(alpha)*ri + axisDirection[2]*sign1*
util::cos(alpha)*ri;
111 si[1] = axisDirection[0]*sign1*
util::cos(alpha)*ri + axisDirection[1]*x[1] + axisDirection[2]*sign2*
util::sin(alpha)*ri;
112 si[2] = axisDirection[0]*sign2*
util::sin(alpha)*ri + axisDirection[1]*sign1*
util::cos(alpha)*ri + axisDirection[2]*x[2];
113 so[0] = axisDirection[0]*x[0] + axisDirection[1]*sign2*
util::sin(alpha)*ro + axisDirection[2]*sign1*
util::cos(alpha)*ro;
114 so[1] = axisDirection[0]*sign1*
util::cos(alpha)*ro + axisDirection[1]*x[1] + axisDirection[2]*sign2*
util::sin(alpha)*ro;
115 so[2] = axisDirection[0]*sign2*
util::sin(alpha)*ro + axisDirection[1]*sign1*
util::cos(alpha)*ro + axisDirection[2]*x[2];
122 bool b0 = (L[0] == 0.);
123 bool b1 = (L[1] == 0.);
124 bool b2 = (L[2] == 0.);
126 output[0] = ((axisDirection[1]*(axisPoint[2]-si[2]) - axisDirection[2]*(axisPoint[1]-si[1])) *
127 (1 - (axisDirection[1]*(x[2]-si[2])/(L[2]+b2) + axisDirection[2]*(x[1]-si[1])/(L[1]+b1))) )*w*scale;
128 output[1] = ((axisDirection[2]*(axisPoint[0]-si[0]) - axisDirection[0]*(axisPoint[2]-si[2])) *
129 (1 - (axisDirection[2]*(x[0]-si[0])/(L[0]+b0) + axisDirection[0]*(x[2]-si[2])/(L[2]+b2))) )*w*scale;
130 output[2] = ((axisDirection[0]*(axisPoint[1]-si[1]) - axisDirection[1]*(axisPoint[0]-si[0])) *
131 (1 - (axisDirection[0]*(x[1]-si[1])/(L[1]+b1) + axisDirection[1]*(x[0]-si[0])/(L[0]+b0))) )*w*scale;
139 std::vector<T> axisDirection_, T w_, T scale_, T additive_)
140 :
AnalyticalF3D<T,T>(1), w(w_), scale(scale_), additive(additive_)
144 for (
int i = 0; i < 3; ++i) {
154 T radiusSquared = ((x[1]-axisPoint[1])*(x[1]-axisPoint[1])
155 +(x[2]-axisPoint[2])*(x[2]-axisPoint[2]))*axisDirection[0]
156 + ((x[0]-axisPoint[0])*(x[0]-axisPoint[0])
157 +(x[2]-axisPoint[2])*(x[2]-axisPoint[2]))*axisDirection[1]
158 + ((x[1]-axisPoint[1])*(x[1]-axisPoint[1])
159 +(x[0]-axisPoint[0])*(x[0]-axisPoint[0]))*axisDirection[2];
160 output[0] = scale*w*w/2*radiusSquared+additive;
167 T maxVelocity, T radius, T n, T scale)
169 _radius(radius), _maxVelocity(maxVelocity), _n(n), _scale(scale) { }
173 :
AnalyticalF3D<T,T>(3), _radius(radius), _maxVelocity(maxVelocity), _n(n), _scale(scale)
179 std::vector<T> normalTmp;
180 normalTmp.push_back(normal0);
181 normalTmp.push_back(normal1);
182 normalTmp.push_back(normal2 );
188 int material, T maxVelocity, T n, T distance2Wall, T scale)
189 :
AnalyticalF3D<T,T>(3), _maxVelocity(maxVelocity), _n(n), _scale(scale)
192 std::vector<T> normalTmp;
193 normalTmp.push_back(superGeometry.
getStatistics().computeDiscreteNormal(material)[0]);
194 normalTmp.push_back(superGeometry.
getStatistics().computeDiscreteNormal(material)[1]);
195 normalTmp.push_back(superGeometry.
getStatistics().computeDiscreteNormal(material)[2]);
200 for (
int iD = 0; iD < 3; iD++) {
209 if (useMeanVelocity) {
215CirclePowerLaw3D<T>::CirclePowerLaw3D(
bool useMeanVelocity, T center0, T center1, T center2, T normal0, T normal1, T normal2, T radius, T Velocity, T n, T scale)
216 :
CirclePowerLaw3D<T>(center0, center1, center2, normal0, normal1, normal2, radius, Velocity, n, scale)
218 if (useMeanVelocity) {
225 :
CirclePowerLaw3D<T>(superGeometry, material, Velocity, n, distance2Wall, scale)
227 if (useMeanVelocity) {
235 output[0] = _scale*_maxVelocity*_normal[0]*(1.-
util::pow(
util::sqrt((x[1]-_center[1])*(x[1]-_center[1])+(x[2]-_center[2])*(x[2]-_center[2]))/_radius, (_n + 1.)/_n));
236 output[1] = _scale*_maxVelocity*_normal[1]*(1.-
util::pow(
util::sqrt((x[0]-_center[0])*(x[0]-_center[0])+(x[2]-_center[2])*(x[2]-_center[2]))/_radius, (_n + 1.)/_n));
237 output[2] = _scale*_maxVelocity*_normal[2]*(1.-
util::pow(
util::sqrt((x[1]-_center[1])*(x[1]-_center[1])+(x[0]-_center[0])*(x[0]-_center[0]))/_radius, (_n + 1.)/_n));
243 T maxVelocity, T radius, T n, T turbulenceIntensity, T scale)
244 :
CirclePowerLaw3D<T>(center, normal, maxVelocity, radius, n, scale), _turbulenceIntensity(turbulenceIntensity), _generator(_rd()), _dist(0.0, 1.0) { }
248 T normal1, T normal2, T radius, T maxVelocity, T n, T turbulenceIntensity, T scale)
249 :
CirclePowerLaw3D<T>(center0, center1, center2, normal0, normal1, normal2, radius, maxVelocity, n, scale), _turbulenceIntensity(turbulenceIntensity), _generator(_rd()), _dist(0.0, 1.0) { }
253 int material, T maxVelocity, T distance2Wall, T n, T turbulenceIntensity, T scale)
254 :
CirclePowerLaw3D<T>(superGeometry, material, maxVelocity, n, distance2Wall, scale), _turbulenceIntensity(turbulenceIntensity), _generator(_rd()), _dist(0.0, 1.0) { }
260 if (useMeanVelocity) {
261 this->
_maxVelocity = ((1. + 1./n) * (2. + 1./n)) / 2. * Velocity;
265CirclePowerLawTurbulent3D<T>::CirclePowerLawTurbulent3D(
bool useMeanVelocity, T center0, T center1, T center2, T normal0, T normal1, T normal2, T radius, T Velocity, T n, T turbulenceIntensity, T scale)
266 :
CirclePowerLawTurbulent3D(center0, center1, center2, normal0, normal1, normal2, radius, Velocity, n, turbulenceIntensity, scale)
268 if (useMeanVelocity) {
269 this->
_maxVelocity = ((1. + 1./n) * (2. + 1./n)) / 2. * Velocity;
277 if (useMeanVelocity) {
278 this->
_maxVelocity = ((1. + 1./n) * (2. + 1./n)) / 2. * Velocity;
285 T meanVelocity = this->_maxVelocity * 2.0 / ((1. + 1./this->_n) * (2. + 1./this->_n));
287 if ( 1.-
util::sqrt((x[1]-this->_center[1])*(x[1]-this->_center[1])+(x[2]-this->_center[2])*(x[2]-this->_center[2]))/this->_radius < 0.) {
291 output[0] = this->_scale*this->_maxVelocity*this->_normal[0]*
292 (
util::pow(1.-
util::sqrt((x[1]-this->_center[1])*(x[1]-this->_center[1])+(x[2]-this->_center[2])*(x[2]-this->_center[2]))/this->_radius, 1./this->_n));
293 output[0] += _dist(_generator) * _turbulenceIntensity * meanVelocity;
295 if ( 1.-
util::sqrt((x[0]-this->_center[0])*(x[0]-this->_center[0])+(x[2]-this->_center[2])*(x[2]-this->_center[2]))/this->_radius < 0.) {
299 output[1] = this->_scale*this->_maxVelocity*this->_normal[1]*
300 (
util::pow(1.-
util::sqrt((x[0]-this->_center[0])*(x[0]-this->_center[0])+(x[2]-this->_center[2])*(x[2]-this->_center[2]))/this->_radius, 1./this->_n));
301 output[1] += _dist(_generator) * _turbulenceIntensity * meanVelocity;
303 if ( 1.-
util::sqrt((x[1]-this->_center[1])*(x[1]-this->_center[1])+(x[0]-this->_center[0])*(x[0]-this->_center[0]))/this->_radius < 0.) {
307 output[2] = this->_scale*this->_maxVelocity*this->_normal[2]*
308 (
util::pow(1.-
util::sqrt((x[1]-this->_center[1])*(x[1]-this->_center[1])+(x[0]-this->_center[0])*(x[0]-this->_center[0]))/this->_radius, 1./this->_n));
309 output[2] += _dist(_generator) * _turbulenceIntensity * meanVelocity;
318 T maxVelocity, T radius, T scale)
323 T normal1, T normal2, T radius, T maxVelocity, T scale)
324 :
CirclePowerLaw3D<T>(center0, center1, center2, normal0, normal1, normal2, radius, maxVelocity, 1., scale) { }
328 int material, T maxVelocity, T distance2Wall, T scale)
329 :
CirclePowerLaw3D<T>(superGeometry, material, maxVelocity, 1., distance2Wall, scale) { }
335 if (useMeanVelocity) {
342 :
CirclePoiseuille3D(center0, center1, center2, normal0, normal1, normal2, radius, Velocity, scale)
344 if (useMeanVelocity) {
353 if (useMeanVelocity) {
358template <
typename T,
typename DESCRIPTOR>
364 this->
getName() =
"CirclePoiseuilleStrainRate3D";
368template <
typename T,
typename DESCRIPTOR>
375 T DuDy = (T) maxVelocity*(-2.*(y-(lengthY))/((lengthY)*(lengthY)));
376 T DuDz = (T) maxVelocity*(-2.*(z-(lengthZ))/((lengthZ)*(lengthZ)));
384 output[0] = (DuDx + DuDx)/2.;
385 output[1] = (DuDy + DvDx)/2.;
386 output[2] = (DuDz + DwDx)/2.;
387 output[3] = (DvDx + DuDy)/2.;
388 output[4] = (DvDy + DvDy)/2.;
389 output[5] = (DvDz + DwDy)/2.;
390 output[6] = (DwDx + DuDz)/2.;
391 output[7] = (DwDy + DvDz)/2.;
392 output[8] = (DwDz + DwDz)/2.;
403 :
AnalyticalF3D<T,T>(3), clout(std::cout,
"RectanglePoiseille3D"), x0(x0_), x1(x1_),
404 x2(x2_), maxVelocity(maxVelocity_) { }
409 int material_, std::vector<T>& maxVelocity_, T offsetX, T offsetY, T offsetZ)
410 :
AnalyticalF3D<T,T>(3), clout(std::cout,
"RectanglePoiseuille3D"), maxVelocity(maxVelocity_)
428 x1[1] = max[1] + offsetY;
429 x2[2] = max[2] + offsetZ;
439 x1[0] = max[0] + offsetX;
440 x2[2] = max[2] + offsetZ;
450 x1[0] = max[0] + offsetX;
451 x2[1] = max[1] + offsetY;
454 clout <<
"Error: constructor from material number works only for axis-orthogonal planes" << std::endl;
462 std::vector<T> velocity(3,T());
465 std::vector<std::vector<T> > n(4,std::vector<T>(3,0));
466 std::vector<std::vector<T> > s(4,std::vector<T>(3,0));
467 for (
int iD = 0; iD < 3; iD++) {
468 n[0][iD] = x1[iD] - x0[iD];
469 n[1][iD] = -x1[iD] + x0[iD];
470 n[2][iD] = x2[iD] - x0[iD];
471 n[3][iD] = -x2[iD] + x0[iD];
477 for (
int iP = 0; iP < 4; iP++) {
483 std::vector<T> A(4,0);
484 std::vector<T> B(4,0);
485 std::vector<T> C(4,0);
486 std::vector<T> D(4,0);
488 for (
int iP = 0; iP < 4; iP++) {
492 D[iP] = -(s[iP][0]*n[iP][0] + s[iP][1]*n[iP][1] + s[iP][2]*n[iP][2]);
496 std::vector<T> d(4,0);
498 for (
int iP = 0; iP < 4; iP++) {
499 aabbcc = A[iP]*A[iP] + B[iP]*B[iP] + C[iP]*C[iP];
504 std::vector<T> l(2,0);
508 T positionFactor = 16.*d[0]/l[0]*d[1]/l[0]*d[2]/l[1]*d[3]/l[1];
510 output[0] = maxVelocity[0]*positionFactor;
511 output[1] = maxVelocity[1]*positionFactor;
512 output[2] = maxVelocity[2]*positionFactor;
519 std::vector<T>& x2_, std::vector<T>& maxVelocity_,
int numOfPolynoms_)
520 :
AnalyticalF3D<T,T>(3), clout(std::cout,
"RectangleTrigonometricPoiseille3D"), x0(x0_), x1(x1_),
521 x2(x2_), maxVelocity(maxVelocity_), numOfPolynoms(numOfPolynoms_)
529 int material_, std::vector<T>& maxVelocity_, T offsetX, T offsetY, T offsetZ,
int numOfPolynoms_)
530 :
AnalyticalF3D<T,T>(3), clout(std::cout,
"RectangleTrigonometricPoiseuille3D"), maxVelocity(maxVelocity_),
531 numOfPolynoms(numOfPolynoms_)
533 std::vector<T> min = superGeometry_.
getStatistics().getMinPhysR(material_);
534 std::vector<T> max = superGeometry_.
getStatistics().getMaxPhysR(material_);
549 x1[1] = max[1] + offsetY;
550 x2[2] = max[2] + offsetZ;
560 x1[0] = max[0] + offsetX;
561 x2[2] = max[2] + offsetZ;
571 x1[0] = max[0] + offsetX;
572 x2[1] = max[1] + offsetY;
575 clout <<
"Error: constructor from material number works only for axis-orthogonal planes" << std::endl;
587 for (
int i=1; i<=numOfPolynoms; ++i) {
596 profilePeak = sumMax;
597 profileRatioAvgToPeak = sumAvg / sumMax;
610 return profileRatioAvgToPeak;
619 std::vector<std::vector<T> > n(4,std::vector<T>(3,0));
620 std::vector<std::vector<T> > s(4,std::vector<T>(3,0));
621 for (
int iD = 0; iD < 3; iD++) {
622 n[0][iD] = x1[iD] - x0[iD];
623 n[1][iD] = -x1[iD] + x0[iD];
624 n[2][iD] = x2[iD] - x0[iD];
625 n[3][iD] = -x2[iD] + x0[iD];
631 for (
int iP = 0; iP < 4; iP++) {
637 std::vector<T> A(4,0);
638 std::vector<T> B(4,0);
639 std::vector<T> C(4,0);
640 std::vector<T> D(4,0);
642 for (
int iP = 0; iP < 4; iP++) {
646 D[iP] = -(s[iP][0]*n[iP][0] + s[iP][1]*n[iP][1] + s[iP][2]*n[iP][2]);
650 std::vector<T> d(4,0);
652 for (
int iP = 0; iP < 4; iP++) {
653 aabbcc = A[iP]*A[iP] + B[iP]*B[iP] + C[iP]*C[iP];
658 std::vector<T> l(2,0);
662 std::vector<T> dl(2,0);
669 for (
int i=1; i<=numOfPolynoms; ++i) {
675 output[0] = maxVelocity[0] * ( sumPoly / profilePeak);
676 output[1] = maxVelocity[1] * ( sumPoly / profilePeak);
677 output[2] = maxVelocity[2] * ( sumPoly / profilePeak);
684 :
AnalyticalF3D<T,T>(3), clout(std::cout,
"EllipticPoiseuille3D"), _center(center),
685 _a2(a*a), _b2(b*b), _maxVel(maxVel) { }
692 T rad2 = _a2*_b2 /((_b2-_a2)*cosOmega2 + _a2) ;
699 output[2] = _maxVel*(-x2+1);
709 :
AnalyticalF3D<T,T>(3), K(K_), mu(mu_), gradP(gradP_), radius(radius_), eps(eps_)
711 this->
getName() =
"AnalyticalPorousVelocity3D";
714 std::vector<T> normalTmp;
715 normalTmp.push_back(superGeometry.
getStatistics().computeDiscreteNormal(material)[0]);
716 normalTmp.push_back(superGeometry.
getStatistics().computeDiscreteNormal(material)[1]);
717 normalTmp.push_back(superGeometry.
getStatistics().computeDiscreteNormal(material)[2]);
736 dist[0] = normal[0]*
util::sqrt((x[1]-center[1])*(x[1]-center[1])+(x[2]-center[2])*(x[2]-center[2]));
737 dist[1] = normal[1]*
util::sqrt((x[0]-center[0])*(x[0]-center[0])+(x[2]-center[2])*(x[2]-center[2]));
738 dist[2] = normal[2]*
util::sqrt((x[1]-center[1])*(x[1]-center[1])+(x[0]-center[0])*(x[0]-center[0]));
744 output[0] *= normal[0]/eps;
745 output[1] *= normal[1]/eps;
746 output[2] *= normal[2]/eps;
759template<
typename T,
typename S>
761 std::vector<T> referenceVector, std::vector<T> orientation)
763 _referenceVector(referenceVector),
764 _orientation(orientation)
770template<
typename T,
typename S>
793 T n_dot = n_x * n_ref;
811 T normal =
norm(cross);
815 n_orient = orientation;
819 std::cout <<
"orientation vector does not fit" << std::endl;
821 if ((cross * orientation) > T()) {
824 if ((cross * orientation) < T()) {
835template<
typename T,
typename S>
840 _rotAxisDirection(rotAxisDirection),
848template<
typename T,
typename S>
857 for (
int i = 0; i < 3; ++i) {
858 x_tmp[i] = x[i] - _origin[i];
879 for (
int j=0; j<3; j++) {
893template<
typename T,
typename S>
895 std::vector<T> cylinderOrigin)
897 _cylinderOrigin(cylinderOrigin)
899 this->
getName() =
"CylinderToCartesian3D";
904template<
typename T,
typename S>
915template<
typename T,
typename S>
919 _cartesianOrigin(cartesianOrigin),
920 _orientation(orientation)
923 std::vector<T> origin(3,T());
924 T e3[3]= {T(),T(),T()};
927 T tmp[3] = {T(),T(),T()};
930 std::vector<T> htmp(tmp,tmp+3);
935template<
typename T,
typename S>
940 _cartesianOrigin(cartesianOrigin),
941 _axisDirection(axisDirection),
942 _orientation(orientation)
948template<
typename T,
typename S>
950 T cartesianOriginX, T cartesianOriginY, T cartesianOriginZ,
951 T axisDirectionX, T axisDirectionY, T axisDirectionZ,
952 T orientationX, T orientationY, T orientationZ)
970template<
typename T,
typename S>
973 T x_rot[3] = {T(),T(),T()};
984 normalAxisDir =
normalize(normalAxisDir);
990 normal = orientation;
993 T tmp[3] = {T(),T(),T()};
994 tmp[0] = axisDirection[0];
995 tmp[1] = axisDirection[1];
996 tmp[2] = axisDirection[2];
1005 T x_rot_help[2] = {T(),T()};
1006 x_rot_help[0] = x_rot[0];
1007 x_rot_help[1] = x_rot[1];
1009 T output_help[2] = {T(),T()};
1010 car2pol(output_help, x_rot_help);
1012 output[0] = output_help[0];
1013 output[1] = output_help[1];
1014 output[2] = x_rot[2] - _cartesianOrigin[2];
1019template<
typename T,
typename S>
1022 return _axisDirection;
1026template<
typename T,
typename S>
1029 return _axisDirection;
1033template<
typename T,
typename S>
1036 return _cartesianOrigin;
1040template<
typename T,
typename S>
1043 return _cartesianOrigin;
1047template<
typename T,
typename S>
1050 std::vector<T> Null(3,T());
1051 T e3[3] = {T(),T(),T()};
1055 T tmp[3] = {T(),T(),T()};
1057 for (
int i=0; i<3; ++i) {
1058 _axisDirection[i] = tmp[i];
1067template<
typename T,
typename S>
1078template<
typename T,
typename S>
1088template<
typename T,
typename S>
1090 std::vector<T> cartesianOrigin, std::vector<T> axisDirection)
1092 _cartesianOrigin(cartesianOrigin),
1093 _axisDirection(axisDirection)
1100template<
typename T,
typename S>
1103 T x_rot[3] = {T(),T(),T()};
1113 normalAxisDir =
normalize(normalAxisDir);
1118 T tmp[3] = {T(),T(),T()};
1119 for (
int i=0; i<3; ++i) {
1120 tmp[i] = axisDirection[i];
1122 T alpha[1] = {T(0)};
1135 for (
int i=0; i<3; ++i) {
1136 difference[i] = x_rot[i] - _cartesianOrigin[i];
1140 for (
int i = 0; i <= 2; ++i) {
1141 distance += difference[i]*difference[i];
1145 car2pol(output, x_rot);
1146 output[0] = distance;
1147 output[2] =
util::acos(difference[2]/output[0]);
1161template<
typename T,
typename S>
1164 T radParticle, T mu0)
1172 _radParticle(radParticle),
1179template<
typename T,
typename S>
1184 T outputTmp[3] = {T(), T(), T()};
1189 relPosition[0] = (x[0] - _car2cyl.getCartesianOrigin()[0]);
1190 relPosition[1] = (x[1] - _car2cyl.getCartesianOrigin()[1]);
1191 relPosition[2] = (x[2] - _car2cyl.getCartesianOrigin()[2]);
1193 T tmp[3] = {T(),T(),T()};
1198 T test = relPosition * normalAxis;
1200 if ( (rad > _radWire && rad <= _cutoff*_radWire) &&
1201 (T(0) <= test && test <= _length) ) {
1203 magneticForcePolar[0] = _factor/
util::pow(rad, 3)
1208 outputTmp[0] = magneticForcePolar[0]*
util::cos(phi)
1210 outputTmp[1] = magneticForcePolar[0]*
util::sin(phi)
1221 T tmp2[3] = {T(),T(),T()};
1222 for (
int i = 0; i<3; ++i) {
1223 tmp2[i] = _car2cyl.getAxisDirection()[i];
1227 std::vector<T> origin(3, T());
1229 rotRAxis(output,outputTmp);
1232 output[0] = outputTmp[0];
1233 output[1] = outputTmp[1];
1238 output[0] = outputTmp[0];
1239 output[1] = outputTmp[1];
1240 output[2] = outputTmp[1];
1245template<
typename T,
typename S>
1260template<
typename T,
typename S>
1265 T outputTmp[3] = {T(), T(), T()};
1270 relPosition[0] = (x[0] - _car2cyl.getCartesianOrigin()[0]);
1271 relPosition[1] = (x[1] - _car2cyl.getCartesianOrigin()[1]);
1272 relPosition[2] = (x[2] - _car2cyl.getCartesianOrigin()[2]);
1274 T tmp[3] = {T(), T(), T()};
1279 T test = relPosition * normalAxis;
1281 if ( (rad > _radWire && rad <= _cutoff * _radWire) &&
1282 (T(0) <= test && test <= _length) ) {
1284 magneticFieldPolar[0] = _factor /
util::pow(rad, 2)
1289 outputTmp[0] = magneticFieldPolar[0] *
util::cos(phi)
1290 - magneticFieldPolar[1] *
util::sin(phi);
1291 outputTmp[1] = magneticFieldPolar[0] *
util::sin(phi)
1292 + magneticFieldPolar[1] *
util::cos(phi);
1302 T tmp2[3] = {T(), T(), T()};
1303 for (
int i = 0; i < 3; ++i) {
1304 tmp2[i] = _car2cyl.getAxisDirection()[i];
1308 std::vector<T> origin(3, T());
1310 rotRAxis(output, outputTmp);
1313 output[0] = outputTmp[0];
1314 output[1] = outputTmp[1];
1319 output[0] = outputTmp[0];
1320 output[1] = outputTmp[1];
1321 output[2] = outputTmp[1];
AnalyticalF are applications from DD to XD, where X is set by the constructor.
AnalyticalPorousVelocity3D(SuperGeometry< T, 3 > &superGeometry, int material, T K_, T mu_, T gradP_, T radius_, T eps_=T(1))
bool operator()(T output[], const T input[]) override
olb::Vector< T, 3 > normal
olb::Vector< T, 3 > center
This class calculates the angle alpha between vector _referenceVector and any other vector x.
AngleBetweenVectors3D(std::vector< T > referenceVector, std::vector< T > orientation)
constructor defines _referenceVector and _orientation
bool operator()(T output[], const S x[]) override
operator writes angle between x and _referenceVector inro output field
This class converts Cartesian coordinates of point x to cylindrical coordinates wrote into output fie...
olb::Vector< T, 3 > const & getAxisDirection() const
Read only access to _axisDirection.
olb::Vector< T, 3 > _cartesianOrigin
origin of the Cartesian coordinate system
olb::Vector< T, 3 > const & getCartesianOrigin() const
Read only access to _catesianOrigin.
bool operator()(T output[], const S x[]) override
operator writes cylindrical coordinates of Cartesian point x into output field, output[0] = radius ( ...
CartesianToCylinder3D(olb::Vector< T, 3 > cartesianOrigin, T &angle, olb::Vector< T, 3 > orientation={T(1), T(), T()})
olb::Vector< T, 3 > _axisDirection
direction of the axis along which the cylindrical coordinates are calculated
void setAngle(T angle)
Read and write access to _axisDirection using angle.
olb::Vector< T, 3 > _orientation
direction to know orientation for math positive to obtain angle phi of Cartesian point x
This class converts Cartesian coordinates of point x to polar coordinates wrote into output field (ou...
bool operator()(T output[], const S x[]) override
operator writes shperical coordinates of Cartesian point x into output field, output[0] = radius ( >=...
CartesianToSpherical3D(std::vector< T > cartesianOrigin, std::vector< T > axisDirection)
Velocity profile for util::round pipes and a laminar flow of a Newtonian fluid: u(r)=u_max*(1-(r/R)^2...
CirclePoiseuille3D(std::vector< T > axisPoint, std::vector< T > axisDirection, T maxVelocity, T radius, T scale=T(1))
bool operator()(T output[], const T input[]) override
CirclePoiseuilleStrainRate3D(UnitConverter< T, DESCRIPTOR > const &converter, T ly)
This functor returns a quadratic Poiseuille profile for use with a pipe with util::round cross-sectio...
bool operator()(T output[], const T x[]) override
olb::Vector< T, 3 > _center
CirclePowerLaw3D(olb::Vector< T, 3 > axisPoint, std::vector< T > axisDirection, T maxVelocity, T radius, T n, T scale=T(1))
Velocity profile for util::round pipes and turbulent flows: u(r)=u_max*(1-r/R)^(1/n) The exponent n c...
CirclePowerLawTurbulent3D(std::vector< T > axisPoint_, std::vector< T > axisDirection, T maxVelocity, T radius, T n=7, T turbulenceIntensity=0.05, T scale=T(1))
bool operator()(T output[], const T x[]) override
bool operator()(T output[], const S x[]) override
operator writes Cartesian coordinates of cylinder coordinates x[0] = radius >= 0, x[1] = phi in [0,...
CylinderToCartesian3D(std::vector< T > cylinderOrigin)
constructor defines _cylinderOrigin
EllipticPoiseuille3D(std::vector< T > center, T a, T b, T maxVel)
bool operator()(T output[], const T x[]) override
std::string & getName()
read and write access to name
T _factor
factor = mu0*4/3.*PI*radParticle^3*_Mp*radWire^2/r^3
MagneticFieldFromCylinder3D(CartesianToCylinder3D< T, S > &car2cyl, T length, T radWire, T cutoff, T Mw)
bool operator()(T output[], const S x[]) override
operator writes the magnetic force in a point x util::round a cylindrical wire into output field
T _Mw
saturation magnetization wire, linear scaling factor
T _factor
factor = mu0*4/3.*PI*radParticle^3*_Mp*radWire^2/r^3
T _radParticle
particle radius, cubic scaling factor
T _Mw
saturation magnetization wire, linear scaling factor
MagneticForceFromCylinder3D(CartesianToCylinder3D< T, S > &car2cyl, T length, T radWire, T cutoff, T Mw, T Mp=T(1), T radParticle=T(1), T mu0=4 *3.14159265e-7)
Magnetic field that creates magnetization in wire has to be orthogonal to the wire.
bool operator()(T output[], const S x[]) override
operator writes the magnetic force in a point x util::round a cylindrical wire into output field
T _Mp
magnetization particle, linear scaling factor
T _mu0
permeability constant, linear scaling factor
class for marking output with some text
This class converts polar coordinates of point x (x[0] = radius, x[1] = phi) to Cartesian coordinates...
RectanglePoiseuille3D(olb::Vector< T, 3 > &x0_, olb::Vector< T, 3 > &x1_, olb::Vector< T, 3 > &x2_, std::vector< T > &maxVelocity_)
bool operator()(T output[], const T x[]) override
RectangleTrigonometricPoiseuille3D(std::vector< T > &x0_, std::vector< T > &x1_, std::vector< T > &x2_, std::vector< T > &maxVelocity, int numOfPolynoms_=1)
bool operator()(T output[], const T x[]) override
RotatingLinear3D(std::vector< T > axisPoint_, std::vector< T > axisDirection_, T w_, T scale_=1)
bool operator()(T output[], const T x[]) override
RotatingLinearAnnulus3D(std::vector< T > axisPoint_, std::vector< T > axisDirection_, T w_, T ri_, T ro_, T scale_=1)
bool operator()(T output[], const T x[])
RotatingQuadratic1D(std::vector< T > axisPoint_, std::vector< T > axisDirection_, T w_, T scale_=1, T additive_=0)
std::vector< T > axisPoint
std::vector< T > axisDirection
bool operator()(T output[], const T x[]) override
This class saves coordinates of the resulting point after rotation in the output field.
RotationRoundAxis3D(olb::Vector< T, 3 > origin, olb::Vector< T, 3 > rotAxisDirection, T alpha)
constructor defines _rotAxisDirection, _alpha and _origin
bool operator()(T output[], const S x[]) override
operator writes coordinates of the resulting point after rotation of x by angle _alpha in math positi...
bool operator()(T output[], const S x[]) override
operator writes spherical coordinates of Cartesian coordinates of x (x[0] = radius,...
Representation of a statistic for a parallel 2D geometry.
SuperGeometryStatistics< T, D > & getStatistics()
Returns the statistics object.
Conversion between physical and lattice units, as well as discretization.
constexpr T getCharPhysVelocity() const
return characteristic velocity in physical units
This file contains two different classes of functors, in the FIRST part.
This file contains two different classes of functors, in the FIRST part.
cpu::simd::Pack< T > sqrt(cpu::simd::Pack< T > value)
std::vector< T > fromVector3(const Vector< T, 3 > &vec)
ADf< T, DIM > atan2(const T &y, const ADf< T, DIM > &x)
ADf< T, DIM > sin(const ADf< T, DIM > &a)
cpu::simd::Pack< T > pow(cpu::simd::Pack< T > base, cpu::simd::Pack< T > exp)
ADf< T, DIM > cosh(const ADf< T, DIM > &a)
cpu::simd::Pack< T > fabs(cpu::simd::Pack< T > value)
Vector< T, D > normalize(const Vector< T, D > &a)
ADf< T, DIM > acos(const ADf< T, DIM > &a)
bool nearZero(const ADf< T, DIM > &a)
ADf< T, DIM > tanh(const ADf< T, DIM > &a)
ADf< T, DIM > atan(const ADf< T, DIM > &a)
ADf< T, DIM > cos(const ADf< T, DIM > &a)
Top level namespace for all of OpenLB.
constexpr T norm(const ScalarVector< T, D, IMPL > &a)
Euclidean vector norm.
constexpr Vector< T, 3 > crossProduct3D(const ScalarVector< T, 3, IMPL > &a, const ScalarVector< T, 3, IMPL_ > &b) any_platform
constexpr Vector< T, D > normalize(const ScalarVector< T, D, IMPL > &a, T scale=T{1})
Representation of a parallel 2D geometry – header file.