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;
317 T radius, T cassonViscosity, T pressureDrop, T yieldStress, T scale)
319 _radius(radius), _cassonViscosity(cassonViscosity), _pressureDrop(pressureDrop), _yieldStress(yieldStress), _scale(scale) { }
324 T r_c = _yieldStress / (_pressureDrop / 2.);
326 r[0] =
util::sqrt((x[1]-_center[1])*(x[1]-_center[1])+(x[2]-_center[2])*(x[2]-_center[2]));
327 r[1] =
util::sqrt((x[0]-_center[0])*(x[0]-_center[0])+(x[2]-_center[2])*(x[2]-_center[2]));
328 r[2] =
util::sqrt((x[1]-_center[1])*(x[1]-_center[1])+(x[0]-_center[0])*(x[0]-_center[0]));
330 T preFac = 1. / _cassonViscosity;
331 for (std::size_t d = 0; d < 3; ++d) {
335 output[d] =_scale * _normal[d] * preFac * ((_radius*_radius - r[d]*r[d])*_pressureDrop / 4.0 +
344 T maxVelocity, T radius, T scale)
349 T normal1, T normal2, T radius, T maxVelocity, T scale)
350 :
CirclePowerLaw3D<T>(center0, center1, center2, normal0, normal1, normal2, radius, maxVelocity, 1., scale) { }
354 int material, T maxVelocity, T distance2Wall, T scale)
355 :
CirclePowerLaw3D<T>(superGeometry, material, maxVelocity, 1., distance2Wall, scale) { }
361 if (useMeanVelocity) {
368 :
CirclePoiseuille3D(center0, center1, center2, normal0, normal1, normal2, radius, Velocity, scale)
370 if (useMeanVelocity) {
379 if (useMeanVelocity) {
384template <
typename T,
typename DESCRIPTOR>
390 this->
getName() =
"CirclePoiseuilleStrainRate3D";
394template <
typename T,
typename DESCRIPTOR>
401 T DuDy = (T) maxVelocity*(-2.*(y-(lengthY))/((lengthY)*(lengthY)));
402 T DuDz = (T) maxVelocity*(-2.*(z-(lengthZ))/((lengthZ)*(lengthZ)));
410 output[0] = (DuDx + DuDx)/2.;
411 output[1] = (DuDy + DvDx)/2.;
412 output[2] = (DuDz + DwDx)/2.;
413 output[3] = (DvDx + DuDy)/2.;
414 output[4] = (DvDy + DvDy)/2.;
415 output[5] = (DvDz + DwDy)/2.;
416 output[6] = (DwDx + DuDz)/2.;
417 output[7] = (DwDy + DvDz)/2.;
418 output[8] = (DwDz + DwDz)/2.;
429 :
AnalyticalF3D<T,T>(3), clout(std::cout,
"RectanglePoiseille3D"), x0(x0_), x1(x1_),
430 x2(x2_), maxVelocity(maxVelocity_) { }
435 int material_, std::vector<T>& maxVelocity_, T offsetX, T offsetY, T offsetZ)
436 :
AnalyticalF3D<T,T>(3), clout(std::cout,
"RectanglePoiseuille3D"), maxVelocity(maxVelocity_)
454 x1[1] = max[1] + offsetY;
455 x2[2] = max[2] + offsetZ;
465 x1[0] = max[0] + offsetX;
466 x2[2] = max[2] + offsetZ;
476 x1[0] = max[0] + offsetX;
477 x2[1] = max[1] + offsetY;
480 clout <<
"Error: constructor from material number works only for axis-orthogonal planes" << std::endl;
488 std::vector<T> velocity(3,T());
491 std::vector<std::vector<T> > n(4,std::vector<T>(3,0));
492 std::vector<std::vector<T> > s(4,std::vector<T>(3,0));
493 for (
int iD = 0; iD < 3; iD++) {
494 n[0][iD] = x1[iD] - x0[iD];
495 n[1][iD] = -x1[iD] + x0[iD];
496 n[2][iD] = x2[iD] - x0[iD];
497 n[3][iD] = -x2[iD] + x0[iD];
503 for (
int iP = 0; iP < 4; iP++) {
509 std::vector<T> A(4,0);
510 std::vector<T> B(4,0);
511 std::vector<T> C(4,0);
512 std::vector<T> D(4,0);
514 for (
int iP = 0; iP < 4; iP++) {
518 D[iP] = -(s[iP][0]*n[iP][0] + s[iP][1]*n[iP][1] + s[iP][2]*n[iP][2]);
522 std::vector<T> d(4,0);
524 for (
int iP = 0; iP < 4; iP++) {
525 aabbcc = A[iP]*A[iP] + B[iP]*B[iP] + C[iP]*C[iP];
530 std::vector<T> l(2,0);
534 T positionFactor = 16.*d[0]/l[0]*d[1]/l[0]*d[2]/l[1]*d[3]/l[1];
536 output[0] = maxVelocity[0]*positionFactor;
537 output[1] = maxVelocity[1]*positionFactor;
538 output[2] = maxVelocity[2]*positionFactor;
545 std::vector<T>& x2_, std::vector<T>& maxVelocity_,
int numOfPolynoms_)
546 :
AnalyticalF3D<T,T>(3), clout(std::cout,
"RectangleTrigonometricPoiseille3D"), x0(x0_), x1(x1_),
547 x2(x2_), maxVelocity(maxVelocity_), numOfPolynoms(numOfPolynoms_)
555 int material_, std::vector<T>& maxVelocity_, T offsetX, T offsetY, T offsetZ,
int numOfPolynoms_)
556 :
AnalyticalF3D<T,T>(3), clout(std::cout,
"RectangleTrigonometricPoiseuille3D"), maxVelocity(maxVelocity_),
557 numOfPolynoms(numOfPolynoms_)
559 std::vector<T> min = superGeometry_.
getStatistics().getMinPhysR(material_);
560 std::vector<T> max = superGeometry_.
getStatistics().getMaxPhysR(material_);
575 x1[1] = max[1] + offsetY;
576 x2[2] = max[2] + offsetZ;
586 x1[0] = max[0] + offsetX;
587 x2[2] = max[2] + offsetZ;
597 x1[0] = max[0] + offsetX;
598 x2[1] = max[1] + offsetY;
601 clout <<
"Error: constructor from material number works only for axis-orthogonal planes" << std::endl;
613 for (
int i=1; i<=numOfPolynoms; ++i) {
622 profilePeak = sumMax;
623 profileRatioAvgToPeak = sumAvg / sumMax;
636 return profileRatioAvgToPeak;
645 std::vector<std::vector<T> > n(4,std::vector<T>(3,0));
646 std::vector<std::vector<T> > s(4,std::vector<T>(3,0));
647 for (
int iD = 0; iD < 3; iD++) {
648 n[0][iD] = x1[iD] - x0[iD];
649 n[1][iD] = -x1[iD] + x0[iD];
650 n[2][iD] = x2[iD] - x0[iD];
651 n[3][iD] = -x2[iD] + x0[iD];
657 for (
int iP = 0; iP < 4; iP++) {
663 std::vector<T> A(4,0);
664 std::vector<T> B(4,0);
665 std::vector<T> C(4,0);
666 std::vector<T> D(4,0);
668 for (
int iP = 0; iP < 4; iP++) {
672 D[iP] = -(s[iP][0]*n[iP][0] + s[iP][1]*n[iP][1] + s[iP][2]*n[iP][2]);
676 std::vector<T> d(4,0);
678 for (
int iP = 0; iP < 4; iP++) {
679 aabbcc = A[iP]*A[iP] + B[iP]*B[iP] + C[iP]*C[iP];
684 std::vector<T> l(2,0);
688 std::vector<T> dl(2,0);
695 for (
int i=1; i<=numOfPolynoms; ++i) {
701 output[0] = maxVelocity[0] * ( sumPoly / profilePeak);
702 output[1] = maxVelocity[1] * ( sumPoly / profilePeak);
703 output[2] = maxVelocity[2] * ( sumPoly / profilePeak);
710 :
AnalyticalF3D<T,T>(3), clout(std::cout,
"EllipticPoiseuille3D"), _center(center),
711 _a2(a*a), _b2(b*b), _maxVel(maxVel) { }
718 T rad2 = _a2*_b2 /((_b2-_a2)*cosOmega2 + _a2) ;
725 output[2] = _maxVel*(-x2+1);
735 :
AnalyticalF3D<T,T>(3), K(K_), mu(mu_), gradP(gradP_), radius(radius_), eps(eps_)
737 this->
getName() =
"AnalyticalPorousVelocity3D";
740 std::vector<T> normalTmp;
741 normalTmp.push_back(superGeometry.
getStatistics().computeDiscreteNormal(material)[0]);
742 normalTmp.push_back(superGeometry.
getStatistics().computeDiscreteNormal(material)[1]);
743 normalTmp.push_back(superGeometry.
getStatistics().computeDiscreteNormal(material)[2]);
762 dist[0] = normal[0]*
util::sqrt((x[1]-center[1])*(x[1]-center[1])+(x[2]-center[2])*(x[2]-center[2]));
763 dist[1] = normal[1]*
util::sqrt((x[0]-center[0])*(x[0]-center[0])+(x[2]-center[2])*(x[2]-center[2]));
764 dist[2] = normal[2]*
util::sqrt((x[1]-center[1])*(x[1]-center[1])+(x[0]-center[0])*(x[0]-center[0]));
770 output[0] *= normal[0]/eps;
771 output[1] *= normal[1]/eps;
772 output[2] *= normal[2]/eps;
785template<
typename T,
typename S>
787 std::vector<T> referenceVector, std::vector<T> orientation)
789 _referenceVector(referenceVector),
790 _orientation(orientation)
796template<
typename T,
typename S>
819 T n_dot = n_x * n_ref;
837 T normal =
norm(cross);
841 n_orient = orientation;
845 std::cout <<
"orientation vector does not fit" << std::endl;
847 if ((cross * orientation) > T()) {
850 if ((cross * orientation) < T()) {
861template<
typename T,
typename S>
866 _rotAxisDirection(rotAxisDirection),
874template<
typename T,
typename S>
883 for (
int i = 0; i < 3; ++i) {
884 x_tmp[i] = x[i] - _origin[i];
905 for (
int j=0; j<3; j++) {
919template<
typename T,
typename S>
921 std::vector<T> cylinderOrigin)
923 _cylinderOrigin(cylinderOrigin)
925 this->
getName() =
"CylinderToCartesian3D";
930template<
typename T,
typename S>
941template<
typename T,
typename S>
945 _cartesianOrigin(cartesianOrigin),
946 _orientation(orientation)
949 std::vector<T> origin(3,T());
950 T e3[3]= {T(),T(),T()};
953 T tmp[3] = {T(),T(),T()};
956 std::vector<T> htmp(tmp,tmp+3);
961template<
typename T,
typename S>
966 _cartesianOrigin(cartesianOrigin),
967 _axisDirection(axisDirection),
968 _orientation(orientation)
974template<
typename T,
typename S>
976 T cartesianOriginX, T cartesianOriginY, T cartesianOriginZ,
977 T axisDirectionX, T axisDirectionY, T axisDirectionZ,
978 T orientationX, T orientationY, T orientationZ)
996template<
typename T,
typename S>
999 T x_rot[3] = {T(),T(),T()};
1010 normalAxisDir =
normalize(normalAxisDir);
1016 normal = orientation;
1019 T tmp[3] = {T(),T(),T()};
1020 tmp[0] = axisDirection[0];
1021 tmp[1] = axisDirection[1];
1022 tmp[2] = axisDirection[2];
1031 T x_rot_help[2] = {T(),T()};
1032 x_rot_help[0] = x_rot[0];
1033 x_rot_help[1] = x_rot[1];
1035 T output_help[2] = {T(),T()};
1036 car2pol(output_help, x_rot_help);
1038 output[0] = output_help[0];
1039 output[1] = output_help[1];
1040 output[2] = x_rot[2] - _cartesianOrigin[2];
1045template<
typename T,
typename S>
1048 return _axisDirection;
1052template<
typename T,
typename S>
1055 return _axisDirection;
1059template<
typename T,
typename S>
1062 return _cartesianOrigin;
1066template<
typename T,
typename S>
1069 return _cartesianOrigin;
1073template<
typename T,
typename S>
1076 std::vector<T> Null(3,T());
1077 T e3[3] = {T(),T(),T()};
1081 T tmp[3] = {T(),T(),T()};
1083 for (
int i=0; i<3; ++i) {
1084 _axisDirection[i] = tmp[i];
1093template<
typename T,
typename S>
1104template<
typename T,
typename S>
1114template<
typename T,
typename S>
1116 std::vector<T> cartesianOrigin, std::vector<T> axisDirection)
1118 _cartesianOrigin(cartesianOrigin),
1119 _axisDirection(axisDirection)
1126template<
typename T,
typename S>
1129 T x_rot[3] = {T(),T(),T()};
1139 normalAxisDir =
normalize(normalAxisDir);
1144 T tmp[3] = {T(),T(),T()};
1145 for (
int i=0; i<3; ++i) {
1146 tmp[i] = axisDirection[i];
1148 T alpha[1] = {T(0)};
1161 for (
int i=0; i<3; ++i) {
1162 difference[i] = x_rot[i] - _cartesianOrigin[i];
1166 for (
int i = 0; i <= 2; ++i) {
1167 distance += difference[i]*difference[i];
1171 car2pol(output, x_rot);
1172 output[0] = distance;
1173 output[2] =
util::acos(difference[2]/output[0]);
1187template<
typename T,
typename S>
1190 T radParticle, T mu0)
1198 _radParticle(radParticle),
1205template<
typename T,
typename S>
1210 T outputTmp[3] = {T(), T(), T()};
1215 relPosition[0] = (x[0] - _car2cyl.getCartesianOrigin()[0]);
1216 relPosition[1] = (x[1] - _car2cyl.getCartesianOrigin()[1]);
1217 relPosition[2] = (x[2] - _car2cyl.getCartesianOrigin()[2]);
1219 T tmp[3] = {T(),T(),T()};
1224 T test = relPosition * normalAxis;
1226 if ( (rad > _radWire && rad <= _cutoff*_radWire) &&
1227 (T(0) <= test && test <= _length) ) {
1229 magneticForcePolar[0] = _factor/
util::pow(rad, 3)
1234 outputTmp[0] = magneticForcePolar[0]*
util::cos(phi)
1236 outputTmp[1] = magneticForcePolar[0]*
util::sin(phi)
1247 T tmp2[3] = {T(),T(),T()};
1248 for (
int i = 0; i<3; ++i) {
1249 tmp2[i] = _car2cyl.getAxisDirection()[i];
1253 std::vector<T> origin(3, T());
1255 rotRAxis(output,outputTmp);
1258 output[0] = outputTmp[0];
1259 output[1] = outputTmp[1];
1264 output[0] = outputTmp[0];
1265 output[1] = outputTmp[1];
1266 output[2] = outputTmp[1];
1271template<
typename T,
typename S>
1286template<
typename T,
typename S>
1291 T outputTmp[3] = {T(), T(), T()};
1296 relPosition[0] = (x[0] - _car2cyl.getCartesianOrigin()[0]);
1297 relPosition[1] = (x[1] - _car2cyl.getCartesianOrigin()[1]);
1298 relPosition[2] = (x[2] - _car2cyl.getCartesianOrigin()[2]);
1300 T tmp[3] = {T(), T(), T()};
1305 T test = relPosition * normalAxis;
1307 if ( (rad > _radWire && rad <= _cutoff * _radWire) &&
1308 (T(0) <= test && test <= _length) ) {
1310 magneticFieldPolar[0] = _factor /
util::pow(rad, 2)
1315 outputTmp[0] = magneticFieldPolar[0] *
util::cos(phi)
1316 - magneticFieldPolar[1] *
util::sin(phi);
1317 outputTmp[1] = magneticFieldPolar[0] *
util::sin(phi)
1318 + magneticFieldPolar[1] *
util::cos(phi);
1328 T tmp2[3] = {T(), T(), T()};
1329 for (
int i = 0; i < 3; ++i) {
1330 tmp2[i] = _car2cyl.getAxisDirection()[i];
1334 std::vector<T> origin(3, T());
1336 rotRAxis(output, outputTmp);
1339 output[0] = outputTmp[0];
1340 output[1] = outputTmp[1];
1345 output[0] = outputTmp[0];
1346 output[1] = outputTmp[1];
1347 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)
bool operator()(T output[], const T x[]) override
CircleCasson3D(olb::Vector< T, 3 > axisPoint, std::vector< T > axisDirection, T radius, T cassonViscosity, T pressureDrop, T yieldStress, T scale=1.0)
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.
ADf< T, DIM > abs(const ADf< T, DIM > &a)
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)
Expr pow(Expr base, Expr exp)
ADf< T, DIM > cosh(const ADf< T, DIM > &a)
Vector< T, D > normalize(const Vector< T, D > &a)
ADf< T, DIM > acos(const ADf< T, DIM > &a)
bool nearZero(T a) any_platform
return true if a is close to zero
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 max(const ScalarVector< T, D, IMPL > &v)
constexpr T norm(const ScalarVector< T, D, IMPL > &a) any_platform
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.