30template<
typename Type>
31void assignIF(GeometricField<Type, fvPatchField, volMesh>& s,
34 for (label i = 0; i < s.internalField().size(); i++)
41 GeometricField<scalar, fvPatchField, volMesh>& field, scalar value);
43 GeometricField<vector, fvPatchField, volMesh>& field, vector value);
45template<
typename Type>
46void assignIF(GeometricField<Type, fvPatchField, volMesh>& s,
47 Type& value, List<label>& indices)
49 for (label i = 0; i < indices.size(); i++)
51 s.ref()[indices[i]] = value;
55template void assignIF(GeometricField<scalar, fvPatchField, volMesh>& s,
56 scalar& value, List<label>& indices);
57template void assignIF(GeometricField<vector, fvPatchField, volMesh>& s,
58 vector& value, List<label>& indices);
60template<
typename Type>
61void assignIF(GeometricField<Type, fvPatchField, volMesh>& s,
62 Type& value, label index)
64 s.ref()[index] = value;
67template void assignIF(GeometricField<scalar, fvPatchField, volMesh>& field,
68 scalar& value, label index);
69template void assignIF(GeometricField<vector, fvPatchField, volMesh>& field,
70 vector& value, label index);
74 for (label i = 0; i < L.size(); i++)
80void assignBC(GeometricField<scalar, fvPatchField, volMesh>& s, label BC_ind,
83 label sizeBC = s.boundaryField()[BC_ind].size();
84 List<double> valueList(sizeBC);
86 for (label i = 0; i < sizeBC; i++)
94void assignBC(GeometricField<scalar, fvPatchField, volMesh>& s, label BC_ind,
95 Eigen::MatrixXd valueVec)
97 label sizeBC = s.boundaryField()[BC_ind].size();
98 M_Assert(sizeBC == valueVec.size(),
99 "The size of the given values matrix has to be equal to the dimension of the boundaryField");
100 List<double> valueList(sizeBC);
102 for (label i = 0; i < sizeBC; i++)
104 valueList[i] = valueVec(i);
111void assignBC(GeometricField<scalar, fvPatchField, volMesh>& s, label BC_ind,
112 List<double> valueList)
114 word typeBC = s.boundaryField()[BC_ind].type();
115 label sizeBC = s.boundaryField()[BC_ind].size();
116 M_Assert(sizeBC == valueList.size(),
117 "The size of the given values list has to be equal to the dimension of the boundaryField");
120 if (typeBC ==
"fixedGradient")
122 fixedGradientFvPatchScalarField& Tpatch =
123 refCast<fixedGradientFvPatchScalarField>(s.boundaryFieldRef()[BC_ind]);
124 scalarField& gradTpatch = Tpatch.gradient();
125 forAll(gradTpatch, faceI)
127 double value = valueList[faceI];
128 gradTpatch[faceI] = value;
131 else if (typeBC ==
"freestream")
133 for (label i = 0; i < sizeBC; i++)
135 double value = valueList[i];
136 s.boundaryFieldRef()[BC_ind][i] = value;
139 freestreamFvPatchField<scalar>& Tpatch =
140 refCast<freestreamFvPatchField<scalar >> (s.boundaryFieldRef()[BC_ind]);
141 scalarField& gradTpatch = Tpatch.freestreamValue();
142 forAll(gradTpatch, faceI)
144 double value = valueList[faceI];
145 gradTpatch[faceI] = value;
148 else if (typeBC ==
"empty" || typeBC ==
"zeroGradient")
154 if (typeBC !=
"fixedGradient" && typeBC !=
"freestream" && typeBC !=
"empty"
155 && typeBC !=
"zeroGradient" && typeBC !=
"fixedValue" && typeBC !=
"calculated"
156 && typeBC !=
"fixedFluxPressure" && typeBC !=
"processor"
157 && typeBC !=
"nutkWallFunction" && typeBC !=
"mixedEnergy")
159 word message =
"Pay attention, your typeBC " + typeBC +
" for " + s.name() +
160 " is not included into the developed ones. Your BC will be treated as a classical fixedValue.";
164 catch (
const word message)
168 WarningInFunction << message << endl;
172 for (label i = 0; i < sizeBC; i++)
174 double value = valueList[i];
175 s.boundaryFieldRef()[BC_ind][i] = value;
180void assignBC(GeometricField<vector, fvPatchField, volMesh>& s, label BC_ind,
183 M_Assert(value.size() == 3,
184 "The size of the given vector has to be equal to 3 for the 3 components");
185 label sizeBC = s.boundaryField()[BC_ind].size();
186 List<vector> valueList(sizeBC);
188 for (label i = 0; i < sizeBC; i++)
190 valueList[i] = value;
196void assignBC(GeometricField<tensor, fvPatchField, volMesh>& s, label BC_ind,
199 M_Assert(value.size() == 9,
200 "The size of the given vector has to be equal to 3x3 for the 3x3 components");
201 label sizeBC = s.boundaryField()[BC_ind].size();
202 List<tensor> valueList(sizeBC);
204 for (label i = 0; i < sizeBC; i++)
206 valueList[i] = value;
212void assignBC(GeometricField<vector, fvPatchField, volMesh>& s, label BC_ind,
213 Eigen::MatrixXd valueVec)
215 label sizeBC = s.boundaryField()[BC_ind].size();
216 M_Assert(sizeBC * 3 == valueVec.size(),
217 "The size of the given values matrix has to be equal to 3 times the dimension of the boundaryField");
218 List<vector> valueList(sizeBC);
220 for (label i = 0; i < sizeBC; i++)
222 for (label j = 0; j < 3; j++)
224 valueList[i].component(j) = valueVec(i * 3 + j);
231void assignBC(GeometricField<tensor, fvPatchField, volMesh>& s, label BC_ind,
232 Eigen::MatrixXd valueVec)
234 label sizeBC = s.boundaryField()[BC_ind].size();
235 M_Assert(sizeBC * 9 == valueVec.size(),
236 "The size of the given values matrix has to be equal to 9 times the dimension of the boundaryField");
237 List<tensor> valueList(sizeBC);
239 for (label i = 0; i < sizeBC; i++)
241 for (label j = 0; j < 9; j++)
243 valueList[i].component(j) = valueVec(i * 9 + j);
249void assignBC(GeometricField<vector, pointPatchField, pointMesh>& s,
251 Eigen::MatrixXd valueVec)
253 label sizeBC = s.boundaryField()[BC_ind].size();
254 M_Assert(sizeBC * 3 == valueVec.size(),
255 "The size of the given values matrix has to be equal to 3 times the dimension of the boundaryField");
256 List<vector> valueList(sizeBC);
258 for (label i = 0; i < sizeBC; i++)
260 valueList[i].component(0) = valueVec(i * 3);
261 valueList[i].component(1) = valueVec(i * 3 + 1);
262 valueList[i].component(2) = valueVec(i * 3 + 2);
268void assignBC(GeometricField<vector, pointPatchField, pointMesh>& s,
272 label sizeBC = s.boundaryField()[BC_ind].size();
273 List<double> valueList(sizeBC);
275 for (label i = 0; i < sizeBC; i++)
277 valueList[i] = value;
283void assignBC(GeometricField<scalar, fvsPatchField, surfaceMesh>& s,
284 label BC_ind, Eigen::MatrixXd valueVec)
286 label sizeBC = s.boundaryField()[BC_ind].size();
287 M_Assert(sizeBC == valueVec.rows() && valueVec.cols() == 1,
288 "The given matrix must be a column one with the size equal to 3 times the dimension of the boundaryField");
289 List<scalar> valueList(sizeBC);
291 for (label i = 0; i < sizeBC; i++)
293 valueList[i] = valueVec(i);
299void assignBC(GeometricField<vector, fvsPatchField, surfaceMesh>& s,
300 label BC_ind, Eigen::MatrixXd valueVec)
302 label sizeBC = s.boundaryField()[BC_ind].size();
303 M_Assert(sizeBC * 3 == valueVec.rows() && valueVec.cols() == 1,
304 "The given matrix must be a column one with the size equal to the dimension of the boundaryField");
305 List<vector> valueList(sizeBC);
307 for (label i = 0; i < sizeBC; i++)
309 valueList[i].component(0) = valueVec(i * 3);
310 valueList[i].component(1) = valueVec(i * 3 + 1);
311 valueList[i].component(2) = valueVec(i * 3 + 2);
318void assignBC(GeometricField<vector, fvPatchField, volMesh>& s, label BC_ind,
319 List<vector> valueList)
321 word typeBC = s.boundaryField()[BC_ind].type();
322 label sizeBC = s.boundaryField()[BC_ind].size();
323 M_Assert(sizeBC == valueList.size(),
324 "The size of the given values list has to be equal to the dimension of the boundaryField");
327 if (s.boundaryField()[BC_ind].type() ==
"fixedGradient")
329 Info <<
"This Feature is not implemented for this boundary condition" << endl;
332 else if (s.boundaryField()[BC_ind].type() ==
"freestream")
334 for (label i = 0; i < s.boundaryField()[BC_ind].size(); i++)
336 s.boundaryFieldRef()[BC_ind][i] = valueList[i];
339 freestreamFvPatchField<vector>& Tpatch =
340 refCast<freestreamFvPatchField<vector >> (s.boundaryFieldRef()[BC_ind]);
341 vectorField& gradTpatch = Tpatch.freestreamValue();
342 forAll(gradTpatch, faceI)
344 gradTpatch[faceI] = valueList[faceI];
347 else if (s.boundaryField()[BC_ind].type() ==
"empty"
348 || s.boundaryField()[BC_ind].type() ==
"zeroGradient")
354 if (typeBC !=
"fixedGradient" && typeBC !=
"freestream" && typeBC !=
"empty"
355 && typeBC !=
"zeroGradient" && typeBC !=
"fixedValue" && typeBC !=
"calculated"
356 && typeBC !=
"processor")
358 word message =
"Pay attention, your typeBC " + typeBC +
" for " + s.name() +
359 " is not included into the developed ones. Your BC will be treated as a classical fixedValue.";
363 catch (
const word message)
367 WarningInFunction << message << endl;
371 for (label i = 0; i < sizeBC; i++)
373 s.boundaryFieldRef()[BC_ind][i] = valueList[i];
379void assignBC(GeometricField<vector, pointPatchField, pointMesh>& s,
381 List<vector> valueList)
383 word typeBC = s.boundaryField()[BC_ind].type();
384 label sizeBC = s.boundaryField()[BC_ind].size();
385 M_Assert(sizeBC == valueList.size(),
386 "The size of the given values list has to be equal to the dimension of the boundaryField");
388 if (s.boundaryField()[BC_ind].type() ==
"fixedGradient")
390 Info <<
"This Feature is not implemented for this boundary condition" << endl;
393 else if (s.boundaryField()[BC_ind].type() ==
"empty"
394 || s.boundaryField()[BC_ind].type() ==
"zeroGradient")
400 if (typeBC !=
"fixedGradient" && typeBC !=
"freestream" && typeBC !=
"empty"
401 && typeBC !=
"zeroGradient" && typeBC !=
"fixedValue" && typeBC !=
"calculated"
402 && typeBC !=
"processor")
404 word message =
"Pay attention, your typeBC " + typeBC +
" for " + s.name() +
405 " is not included into the developed ones. Your BC will be treated as a classical fixedValue.";
409 catch (
const word message)
411 cerr <<
"WARNING: " << message << endl;
414 for (label i = 0; i < sizeBC; i++)
416 s.boundaryFieldRef()[BC_ind].patchInternalField()()[i] == valueList[i];
421void assignBC(GeometricField<tensor, fvPatchField, volMesh>& s, label BC_ind,
422 List<tensor> valueList)
424 word typeBC = s.boundaryField()[BC_ind].type();
425 label sizeBC = s.boundaryField()[BC_ind].size();
426 M_Assert(sizeBC == valueList.size(),
427 "The size of the given values list has to be equal to the dimension of the boundaryField");
430 if (s.boundaryField()[BC_ind].type() ==
"fixedGradient")
432 Info <<
"This Feature is not implemented for this boundary condition" << endl;
435 else if (s.boundaryField()[BC_ind].type() ==
"freestream")
437 for (label i = 0; i < s.boundaryField()[BC_ind].size(); i++)
439 s.boundaryFieldRef()[BC_ind][i] = valueList[i];
442 freestreamFvPatchField<tensor>& Tpatch =
443 refCast<freestreamFvPatchField<tensor >> (s.boundaryFieldRef()[BC_ind]);
444 tensorField& gradTpatch = Tpatch.freestreamValue();
445 forAll(gradTpatch, faceI)
447 gradTpatch[faceI] = valueList[faceI];
450 else if (s.boundaryField()[BC_ind].type() ==
"empty"
451 || s.boundaryField()[BC_ind].type() ==
"zeroGradient")
457 if (typeBC !=
"fixedGradient" && typeBC !=
"freestream" && typeBC !=
"empty"
458 && typeBC !=
"zeroGradient" && typeBC !=
"fixedValue" && typeBC !=
"calculated"
459 && typeBC !=
"processor")
461 word message =
"Pay attention, your typeBC " + typeBC +
" for " + s.name() +
462 " is not included into the developed ones. Your BC will be treated as a classical fixedValue.";
466 catch (
const word message)
470 WarningInFunction << message << endl;
474 for (label i = 0; i < sizeBC; i++)
476 s.boundaryFieldRef()[BC_ind][i] = valueList[i];
482void assignBC(GeometricField<vector, pointPatchField, pointMesh>& s,
483 label BC_ind, vector value)
485 M_Assert(value.size() == 3,
486 "The size of the given vector has to be equal to 3 for the 3 components");
487 label sizeBC = s.boundaryField()[BC_ind].size();
488 List<vector> valueList(sizeBC);
490 for (label i = 0; i < sizeBC; i++)
492 valueList[i] = value;
498void assignBC(GeometricField<vector, pointPatchField, pointMesh>& s,
500 List<double> valueList)
502 word typeBC = s.boundaryField()[BC_ind].type();
503 label sizeBC = s.boundaryField()[BC_ind].size();
504 M_Assert(sizeBC == valueList.size(),
505 "The size of the given values list has to be equal to the dimension of the boundaryField");
508 if (s.boundaryField()[BC_ind].type() ==
"fixedGradient")
510 Info <<
"This Feature is not implemented for this boundary condition" << endl;
513 else if (typeBC ==
"empty")
519 if (typeBC !=
"fixedGradient" && typeBC !=
"freestream" && typeBC !=
"empty"
520 && typeBC !=
"zeroGradient" && typeBC !=
"fixedValue" && typeBC !=
"calculated"
521 && typeBC !=
"processor")
523 word message =
"Pay attention, your typeBC " + typeBC +
" for " + s.name() +
524 " is not included into the developed ones. Your BC will be treated as a classical fixedValue.";
528 catch (
const word message)
530 cerr <<
"WARNING: " << message << endl;
533 for (label i = 0; i < sizeBC; i++)
535 double value = valueList[i];
537 s.primitiveFieldRef()[BC_ind][i] = value;
543template<
typename Type>
544void assignBC(GeometricField<Type, fvsPatchField, surfaceMesh>& s,
546 List<Type>& valueList)
548 word typeBC = s.boundaryField()[BC_ind].type();
549 label sizeBC = s.boundaryField()[BC_ind].size();
550 M_Assert(sizeBC == valueList.size(),
551 "The size of the given values list has to be equal to the dimension of the boundaryField");
554 if (s.boundaryField()[BC_ind].type() ==
"fixedGradient")
556 fixedGradientFvPatchField<Type>& Tpatch =
557 refCast<fixedGradientFvPatchField<Type >> (s.boundaryFieldRef()[BC_ind]);
558 Field<Type>& gradTpatch = Tpatch.gradient();
559 forAll(gradTpatch, faceI)
561 gradTpatch[faceI] = valueList[faceI];
564 else if (s.boundaryField()[BC_ind].type() ==
"freestream")
566 for (label i = 0; i < s.boundaryField()[BC_ind].size(); i++)
568 s.boundaryFieldRef()[BC_ind][i] = valueList[i];
571 freestreamFvPatchField<Type>& Tpatch =
572 refCast<freestreamFvPatchField<Type >> (s.boundaryFieldRef()[BC_ind]);
573 Field<Type>& gradTpatch = Tpatch.freestreamValue();
574 forAll(gradTpatch, faceI)
576 gradTpatch[faceI] = valueList[faceI];
579 else if (s.boundaryField()[BC_ind].type() ==
"empty"
580 || s.boundaryField()[BC_ind].type() ==
"zeroGradient")
586 if (typeBC !=
"fixedGradient" && typeBC !=
"freestream" && typeBC !=
"empty"
587 || typeBC !=
"zeroGradient" && typeBC !=
"fixedValue" && typeBC !=
"calculated"
588 && typeBC !=
"fixedFluxPressure" && typeBC !=
"processor")
590 word message =
"Pay attention, your typeBC " + typeBC +
" for " + s.name() +
591 " is not included into the developed ones. Your BC will be treated as a classical fixedValue.";
595 catch (
const word message)
599 WarningInFunction << message << endl;
603 for (label i = 0; i < s.boundaryField()[BC_ind].size(); i++)
605 s.boundaryFieldRef()[BC_ind][i] = valueList[i];
611 GeometricField<scalar, fvsPatchField, surfaceMesh>& s, label BC_ind,
612 List<scalar>& valueList);
614 GeometricField<vector, fvsPatchField, surfaceMesh>& s, label BC_ind,
615 List<vector>& valueList);
617template<
typename Type>
618void assignBC(GeometricField<Type, fvsPatchField, surfaceMesh>& s,
622 label sizeBC = s.boundaryField()[BC_ind].size();
623 List<Type> valueList(sizeBC);
625 for (label i = 0; i < sizeBC; i++)
627 valueList[i] = value;
634 GeometricField<scalar, fvsPatchField, surfaceMesh>& s, label BC_ind,
637 GeometricField<vector, fvsPatchField, surfaceMesh>& s, label BC_ind,
640template<
typename Type>
645 forAll(field.mesh().boundary(), i)
647 if (field.boundaryField()[i].type() ==
"zeroGradient" ||
648 field.boundaryField()[i].type() ==
"fixedGradient")
657 GeometricField<scalar, fvPatchField, volMesh>& field, scalar& value);
659 GeometricField<vector, fvPatchField, volMesh>& field, vector& value);
661template<
typename Type>
667 forAll(field.mesh().boundary(), i)
669 if (field.boundaryField()[i].type() ==
"fixedValue")
678 GeometricField<vector, fvPatchField, volMesh>& field);
680 GeometricField<scalar, fvPatchField, volMesh>& field);
682template<
typename Type>
684 Eigen::MatrixXd Box, Type value)
686 M_Assert(Box.rows() == 2
688 "The box must be a 2*3 matrix shaped in this way: \nBox = \t|x0, y0, z0|\n\t|x1, yi, z1|\n");
690 for (label i = 0; i < field.internalField().size(); i++)
692 auto cx = field.mesh().C()[i].component(vector::X);
693 auto cy = field.mesh().C()[i].component(vector::Y);
694 auto cz = field.mesh().C()[i].component(vector::Z);
696 if (cx >= Box(0, 0) && cy >= Box(0, 1) && cz >= Box(0, 2) && cx <= Box(1, 0)
697 && cy <= Box(1, 1) && cz <= Box(1, 2) )
699 field.ref()[i] = value;
703 for (label i = 0; i < field.boundaryField().size(); i++)
705 for (label j = 0; j < field.boundaryField()[i].size(); j++)
707 if (field.boundaryField()[i].type() ==
"fixedValue"
708 || field.boundaryField()[i].type() ==
"calculated")
710 auto cx = field.mesh().C().boundaryField()[i][j][0];
711 auto cy = field.mesh().C().boundaryField()[i][j][1];
712 auto cz = field.mesh().C().boundaryField()[i][j][2];
714 if (cx >= Box(0, 0) && cy >= Box(0, 1) && cz >= Box(0, 2) && cx <= Box(1, 0)
715 && cy <= Box(1, 1) && cz <= Box(1, 2) )
717 field.boundaryFieldRef()[i][j] = value;
724template void setBoxToValue(GeometricField<scalar, fvPatchField, volMesh>&
725 field, Eigen::MatrixXd Box, scalar value);
726template void setBoxToValue(GeometricField<vector, fvPatchField, volMesh>&
727 field, Eigen::MatrixXd Box, vector value);
729template<
typename Type>
731 labelList& movingIDS, List<Type>& originalList)
733 M_Assert(ind2set.size() == value2set.size(),
734 "The size of the indices must be equal to the size of the values list");
735 M_Assert(originalList.size() >= value2set.size(),
736 "The size of the original list of values must be bigger than the size of the list of values you want to set");
737 labelList ind_ok(ind2set);
739 for (label i = 0; i < ind2set.size(); i++)
741 for (label k = 0; k < movingIDS.size(); k++)
743 if (ind2set[i] == movingIDS[k])
751 for (label i = 0; i < ind2set.size(); i++)
753 originalList[ind_ok[i]] = value2set[i];
758 labelList& movingIDS, List<scalar>& originalList);
760 labelList& movingIDS, List<vector>& originalList);
764 GeometricField<Type, fvPatchField, volMesh>& field, word BCtype,
767 field.boundaryFieldRef().set(BC_ind, fvPatchField<Type>::New(BCtype,
768 field.mesh().boundary()[BC_ind], field));
771template void changeBCtype<scalar>
772(GeometricField<scalar, fvPatchField, volMesh>& field, word BCtype,
774template void changeBCtype<vector>
775(GeometricField<vector, fvPatchField, volMesh>& field, word BCtype,
778template<
typename Type>
780 GeometricField<Type, fvPatchField, volMesh>& field, label BC_ind,
781 List<Type>& value, List<Type>& grad, List<scalar>& valueFrac)
783 std::string message =
"Patch is NOT mixed. It is of type: " +
784 field.boundaryField()[BC_ind].type();
785 M_Assert(field.boundaryField()[BC_ind].type() ==
"mixed", message.c_str());
787 if (field.boundaryField()[BC_ind].type() ==
"mixed")
789 mixedFvPatchField<Type>& Tpatch =
790 refCast<mixedFvPatchField<Type >> (field.boundaryFieldRef()[BC_ind]);
791 Field<Type>& valueTpatch = Tpatch.refValue();
792 Field<Type>& gradTpatch = Tpatch.refGrad();
793 Field<scalar>& valueFracTpatch = Tpatch.valueFraction();
796 valueFracTpatch = valueFrac;
800template void assignMixedBC<scalar>(
801 GeometricField<scalar, fvPatchField, volMesh>& field, label BC_ind,
802 List<scalar>& value, List<scalar>& grad, List<scalar>& valueFrac);
804template void assignMixedBC<vector>(
805 GeometricField<vector, fvPatchField, volMesh>& field, label BC_ind,
806 List<vector>& value, List<vector>& grad, List<scalar>& valueFrac);
813template void setToZero(volScalarField& f1);
814template void setToZero(volVectorField& f1);
815template void setToZero(volTensorField& f1);