107 if (s.boundaryField()[BC_ind].type() ==
"fixedValue"
108 || s.boundaryField()[BC_ind].type() ==
"processor")
110 for (label i = 0; i < s.boundaryField()[BC_ind].size(); i++)
112 s.boundaryFieldRef()[BC_ind][i] = value;
115 else if (s.boundaryField()[BC_ind].type() ==
"fixedGradient")
117 fixedGradientFvPatchScalarField& Tpatch =
118 refCast<fixedGradientFvPatchScalarField>(s.boundaryFieldRef()[BC_ind]);
119 scalarField& gradTpatch = Tpatch.gradient();
120 forAll(gradTpatch, faceI)
122 gradTpatch[faceI] = value;
125 else if (s.boundaryField()[BC_ind].type() ==
"fixedFluxPressure")
127 for (label i = 0; i < s.boundaryField()[BC_ind].size(); i++)
129 s.boundaryFieldRef()[BC_ind][i] = value;
132 else if (s.boundaryField()[BC_ind].type() ==
"freestream")
134 for (label i = 0; i < s.boundaryField()[BC_ind].size(); 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 gradTpatch[faceI] = value;
147 else if (s.boundaryField()[BC_ind].type() ==
"calculated")
149 for (label i = 0; i < s.boundaryField()[BC_ind].size(); i++)
151 s.boundaryFieldRef()[BC_ind][i] = value;
154 else if (s.boundaryField()[BC_ind].type() ==
"empty")
161 Vector<double>& value)
163 if (s.boundaryField()[BC_ind].type() ==
"fixedValue")
165 for (label i = 0; i < s.boundaryField()[BC_ind].size(); i++)
167 s.boundaryFieldRef()[BC_ind][i] = value;
170 else if (s.boundaryField()[BC_ind].type() ==
"fixedGradient")
172 Info <<
"This Feature is not implemented for this boundary condition" << endl;
175 else if (s.boundaryField()[BC_ind].type() ==
"freestream")
177 for (label i = 0; i < s.boundaryField()[BC_ind].size(); i++)
179 s.boundaryFieldRef()[BC_ind][i] = value;
182 freestreamFvPatchField<vector>& Tpatch =
183 refCast<freestreamFvPatchField<vector >> (s.boundaryFieldRef()[BC_ind]);
184 vectorField& gradTpatch = Tpatch.freestreamValue();
185 forAll(gradTpatch, faceI)
187 gradTpatch[faceI] = value;
194 rec_field2, PtrList<volVectorField>& modes, label Nmodes,
195 Eigen::MatrixXd coeff_matrix)
197 for (label k = 0; k < coeff_matrix.cols(); k++)
199 for (label i = 0; i < Nmodes; i++)
203 rec_field2.append(coeff_matrix(i, k) * modes[i]);
207 rec_field2[k] += coeff_matrix(i, k) * modes[i];
216 rec_field2, PtrList<volScalarField>& modes, label Nmodes,
217 Eigen::MatrixXd coeff_matrix)
219 for (label k = 0; k < coeff_matrix.cols(); k++)
221 for (label i = 0; i < Nmodes; i++)
225 rec_field2.append(coeff_matrix(i, k) * modes[i]);
229 rec_field2[k] += coeff_matrix(i, k) * modes[i];
271 PtrList<volVectorField> snapshots, PtrList<volVectorField>& modes,
276 "The dimension of the coefficient matrix must correspond to the constructed parameter matrix 'mu_samples'");
277 std::vector<SPLINTER::RBFSpline> rbfsplines;
278 rbfsplines.reserve(coeff.rows());
281 Eigen::MatrixXd muSampRefined(
mu_samples.rows(), 0);
286 bool isConst = (
mu_samples.col(i).array() == firstVal).all();
291 muSampRefined.conservativeResize(muSampRefined.rows(),
292 muSampRefined.cols() + 1);
293 muSampRefined.col(muSampRefined.cols() - 1) =
mu_samples.col(i);
298 for (label i = 0; i < coeff.rows(); i++)
300 SPLINTER::DataTable samples;
305 SPLINTER::DenseVector x(muSampRefined.cols());
308 for (label k = 0; k < muSampRefined.cols(); k++)
310 x(k) = muSampRefined(j, k);
313 samples.addSample(x, coeff(i, j));
316 if (rbfBasis ==
"GAUSSIAN")
318 rbfsplines.push_back(SPLINTER::RBFSpline(samples,
319 SPLINTER::RadialBasisFunctionType::GAUSSIAN));
321 else if (rbfBasis ==
"THIN_PLATE")
323 rbfsplines.push_back(SPLINTER::RBFSpline(samples,
324 SPLINTER::RadialBasisFunctionType::THIN_PLATE_SPLINE));
326 else if (rbfBasis ==
"MULTI_QUADRIC")
328 rbfsplines.push_back(SPLINTER::RBFSpline(samples,
329 SPLINTER::RadialBasisFunctionType::MULTIQUADRIC));
331 else if (rbfBasis ==
"INVERSE_QUADRIC")
333 rbfsplines.push_back(SPLINTER::RBFSpline(samples,
334 SPLINTER::RadialBasisFunctionType::INVERSE_QUADRIC));
336 else if (rbfBasis ==
"INVERSE_MULTI_QUADRIC")
338 rbfsplines.push_back(SPLINTER::RBFSpline(samples,
339 SPLINTER::RadialBasisFunctionType::INVERSE_MULTIQUADRIC));
344 "Unknown string for rbfBasis. Valid types are 'GAUSSIAN', 'THIN_PLATE', 'MULTI_QUADRIC', 'INVERSE_QUADRIC', 'INVERSE_MULTI_QUADRIC'"
355 PtrList<volScalarField> snapshots, PtrList<volScalarField>& modes,
360 "The dimension of the coefficient matrix must correspond to the constructed parameter matrix 'mu_samples'");
361 std::vector<SPLINTER::RBFSpline> rbfsplines;
362 rbfsplines.reserve(coeff.rows());
365 Eigen::MatrixXd muSampRefined(
mu_samples.rows(), 0);
370 bool isConst = (
mu_samples.col(i).array() == firstVal).all();
375 muSampRefined.conservativeResize(muSampRefined.rows(),
376 muSampRefined.cols() + 1);
377 muSampRefined.col(muSampRefined.cols() - 1) =
mu_samples.col(i);
382 for (label i = 0; i < coeff.rows(); i++)
384 SPLINTER::DataTable samples;
389 SPLINTER::DenseVector x(muSampRefined.cols());
392 for (label k = 0; k < muSampRefined.cols(); k++)
394 x(k) = muSampRefined(j, k);
397 samples.addSample(x, coeff(i, j));
400 if (rbfBasis ==
"GAUSSIAN")
402 rbfsplines.push_back(SPLINTER::RBFSpline(samples,
403 SPLINTER::RadialBasisFunctionType::GAUSSIAN));
405 else if (rbfBasis ==
"THIN_PLATE")
407 rbfsplines.push_back(SPLINTER::RBFSpline(samples,
408 SPLINTER::RadialBasisFunctionType::THIN_PLATE_SPLINE));
410 else if (rbfBasis ==
"MULTI_QUADRIC")
412 rbfsplines.push_back(SPLINTER::RBFSpline(samples,
413 SPLINTER::RadialBasisFunctionType::MULTIQUADRIC));
415 else if (rbfBasis ==
"INVERSE_QUADRIC")
417 rbfsplines.push_back(SPLINTER::RBFSpline(samples,
418 SPLINTER::RadialBasisFunctionType::INVERSE_QUADRIC));
420 else if (rbfBasis ==
"INVERSE_MULTI_QUADRIC")
422 rbfsplines.push_back(SPLINTER::RBFSpline(samples,
423 SPLINTER::RadialBasisFunctionType::INVERSE_MULTIQUADRIC));
428 "Unknown string for rbfBasis. Valid types are 'GAUSSIAN', 'THIN_PLATE', 'MULTI_QUADRIC', 'INVERSE_QUADRIC', 'INVERSE_MULTI_QUADRIC'"
439 PtrList<volVectorField> snapshots, PtrList<volVectorField>& modes,
444 "The dimension of the coefficient matrix must correspond to the constructed parameter matrix 'mu_samples'");
445 std::vector<SPLINTER::BSpline> bsplines;
446 bsplines.reserve(coeff.rows());
449 Eigen::MatrixXd muSampRefined(
mu_samples.rows(), 0);
454 bool isConst = (
mu_samples.col(i).array() == firstVal).all();
459 muSampRefined.conservativeResize(muSampRefined.rows(),
460 muSampRefined.cols() + 1);
461 muSampRefined.col(muSampRefined.cols() - 1) =
mu_samples.col(i);
466 for (label i = 0; i < coeff.rows(); i++)
468 SPLINTER::DataTable samples;
473 SPLINTER::DenseVector x(muSampRefined.cols());
476 for (label k = 0; k < muSampRefined.cols(); k++)
478 x(k) = muSampRefined(j, k);
481 samples.addSample(x, coeff(i, j));
484 SPLINTER::BSpline bspline = SPLINTER::BSpline::Builder(samples).degree(
486 bsplines.push_back(bspline);
494 PtrList<volScalarField> snapshots, PtrList<volScalarField>& modes,
499 "The dimension of the coefficient matrix must correspond to the constructed parameter matrix 'mu_samples'");
500 std::vector<SPLINTER::BSpline> bsplines;
501 bsplines.reserve(coeff.rows());
504 Eigen::MatrixXd muSampRefined(
mu_samples.rows(), 0);
509 bool isConst = (
mu_samples.col(i).array() == firstVal).all();
514 muSampRefined.conservativeResize(muSampRefined.rows(),
515 muSampRefined.cols() + 1);
516 muSampRefined.col(muSampRefined.cols() - 1) =
mu_samples.col(i);
521 for (label i = 0; i < coeff.rows(); i++)
523 SPLINTER::DataTable samples;
528 SPLINTER::DenseVector x(muSampRefined.cols());
531 for (label k = 0; k < muSampRefined.cols(); k++)
533 x(k) = muSampRefined(j, k);
536 samples.addSample(x, coeff(i, j));
539 SPLINTER::BSpline bspline = SPLINTER::BSpline::Builder(samples).degree(
541 bsplines.push_back(bspline);
void reconstructFromMatrix(PtrList< volVectorField > &rec_field2, PtrList< volVectorField > &modes, label Nmodes, Eigen::MatrixXd coeff_matrix)
Exact reconstruction using a certain number of modes for vector list of fields and the projection coe...
std::vector< SPLINTER::BSpline > getCoeffManifoldSPL(PtrList< volVectorField > snapshots, PtrList< volVectorField > &modes, label splDeg=3)
Constructs the parameters-coefficients manifold for vector fields, based on the B-spline model.
std::vector< SPLINTER::RBFSpline > getCoeffManifoldRBF(PtrList< volVectorField > snapshots, PtrList< volVectorField > &modes, word rbfBasis="GAUSSIAN")
Constructs the parameters-coefficients manifold for vector fields, based on RBF-spline model.
Eigen::VectorXd getCoeffs(GeometricField< Type, PatchField, GeoMesh > &snapshot, PtrList< GeometricField< Type, PatchField, GeoMesh > > &modes, label Nmodes, bool consider_volumes)
Projects a snapshot on a basis function and gets the coefficients of the projection.