34#include "turbulentTransportModel.H"
44Eigen::MatrixXd
rand(label rows, label cols,
double min,
47 std::srand(
static_cast<long unsigned int>
48 (std::chrono::high_resolution_clock::now().time_since_epoch().count()));
49 Eigen::MatrixXd matr = Eigen::MatrixXd::Random(rows, cols);
50 matr = (matr.array() + 1) / 2;
51 matr = matr.array() * (max - min);
52 matr = matr.array() + min;
56Eigen::MatrixXd
rand(label rows, Eigen::MatrixXd minMax)
58 std::srand(
static_cast<long unsigned int>
59 (std::chrono::high_resolution_clock::now().time_since_epoch().count()));
60 label cols = minMax.rows();
61 Eigen::MatrixXd matr = Eigen::MatrixXd::Random(rows, cols);
62 matr = (matr.array() + 1) / 2;
64 for (label
i = 0;
i < cols;
i++)
66 matr.col(
i) = matr.col(
i).array() * (minMax(
i, 1) - minMax(
i, 0));
67 matr.col(
i) = matr.col(
i).array() + (minMax(
i, 0));
78 if (abs(round(ratio) - ratio) < std::sqrt(SMALL))
95 para->
mesh.lookupObject<incompressible::turbulenceModel>(
"turbulenceProperties");
97 if (tur.type() ==
"Stokes" || tur.type() ==
"Maxwell"
98 || tur.type() ==
"laminarModel")
113 List<T> a = ListListOps::combine<List<T>>(doubleList,
114 accessOp<List<T>>());
116 inplaceUniqueSort(a);
119 uniqueOrder(a, order);
120 List<T> b(order.size());
122 for (label
i = 0;
i < order.size(); ++
i)
127 a.resize(order.size());
140 Eigen::JacobiSVD<Eigen::MatrixXd> svd_holder(origin, Eigen::ComputeThinU | Eigen::ComputeThinV);
142 Eigen::MatrixXd
U = svd_holder.matrixU();
143 Eigen::MatrixXd V = svd_holder.matrixV();
144 Eigen::MatrixXd
D = svd_holder.singularValues();
147 Eigen::MatrixXd
S(V.cols(),
U.cols());
150 for (
unsigned int i = 0;
i <
D.size(); ++
i) {
153 S(
i,
i) = 1 /
D(
i, 0);
158 return V *
S *
U.transpose();
162Eigen::MatrixXd
invertMatrix(Eigen::MatrixXd& matrixToInvert,
const word inversionMethod){
164 Info <<
"Inversion method : " << inversionMethod << endl;
165 if(inversionMethod ==
"pinv_eigen_based"){
168 else if(inversionMethod ==
"direct"){
169 return matrixToInvert.inverse();
171 else if(inversionMethod ==
"fullPivLu"){
172 return matrixToInvert.fullPivLu().inverse();
174 else if(inversionMethod ==
"partialPivLu"){
175 return matrixToInvert.partialPivLu().inverse();
177 else if(inversionMethod ==
"householderQr"){
178 return matrixToInvert.householderQr().solve(Eigen::MatrixXd::Identity(matrixToInvert.rows(), matrixToInvert.cols()));
180 else if(inversionMethod ==
"colPivHouseholderQr"){
181 return matrixToInvert.colPivHouseholderQr().inverse();
183 else if(inversionMethod ==
"fullPivHouseholderQr"){
184 return matrixToInvert.fullPivHouseholderQr().inverse();
186 else if(inversionMethod ==
"completeOrthogonalDecomposition"){
187 return matrixToInvert.completeOrthogonalDecomposition().pseudoInverse();
189 else if(inversionMethod ==
"jacobiSvd")
191 return matrixToInvert.jacobiSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(Eigen::MatrixXd::Identity(matrixToInvert.rows(), matrixToInvert.cols()));
193 else if(inversionMethod ==
"llt")
195 return matrixToInvert.llt().solve(Eigen::MatrixXd::Identity(matrixToInvert.rows(), matrixToInvert.cols()));
197 else if(inversionMethod ==
"ldlt")
199 Eigen::LLT<Eigen::MatrixXd> lltOfA(matrixToInvert);
200 return lltOfA.solve(Eigen::MatrixXd::Identity(matrixToInvert.rows(), matrixToInvert.cols()));
202 else if(inversionMethod ==
"bdcSvd")
204 return matrixToInvert.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(Eigen::MatrixXd::Identity(matrixToInvert.rows(), matrixToInvert.cols()));
207 Info <<
"Unkwown inversion method, solving with : completeOrthogonalDecomposition" << endl;
208 return matrixToInvert.completeOrthogonalDecomposition().pseudoInverse();
Header file of the ITHACAstream class, it contains the implementation of several methods for input ou...
Header file of the ITHACAutilities namespace.
Class for the definition of some general parameters, the parameters must be defined from the file ITH...
fvMesh & mesh
Mesh object defined locally.
static ITHACAparameters * getInstance()
Gets an instance of ITHACAparameters, to be used if the instance is already existing.
Namespace to implement some useful assign operation of OF fields.
bool isInteger(double ratio)
This function checks if ratio is an integer.
Eigen::MatrixXd invertMatrix(Eigen::MatrixXd &matrixToInvert, const word inversionMethod)
Invert a matrix given the method name in the ITHACAdict.
Eigen::MatrixXd pinv_eigen_based(Eigen::MatrixXd &origin, const float er)
Using the Eigen library, using the SVD decomposition method to solve the matrix pseudo-inverse,...
Eigen::MatrixXd rand(label rows, label cols, double min, double max)
Generates random matrix with random values in an interval.
bool isTurbulent()
This function checks if the case is turbulent.
List< T > combineList(List< List< T > > &doubleList)
Combine a list of list into a single list with unique elements.
volScalarField S(IOobject("S", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), T.mesh(), dimensionedScalar("zero", dimensionSet(0, 0, -1, 1, 0, 0, 0), 0))