inverse of a matrix or solution of implicit equation
Hej,
I am looking for a way to solve the following equation Code:
a_i = c1 * a_j * du_i / dx_j + c2 Code:
a_1 = c1 * a_1 * du_1/dx_1 + c1 * a_2 * du_1 / dx_2 + c1 * a_3 * du_1 / dx_3 + c2 The idea is to rewrite this into an explicit form, by taking a_1 to the other side. I was also looking into a form to solve this with the build in fvMatrix of OF, unfortunately you can basically only insert div, grad (or other derivative forms) and source. However, source (fvm::Sp(scalar, solvableVariable))cannot take a tensor as it would be required from du_i/dx_j as a multiplication factor for vector a The other idea is to take the coefficient matrix (A_ij) in every cell and divide the right hand side by this. Code:
A_ij*a_j = S_i => a_j = A_ij^1 * S_i OpenFOAM version used is 2.1. 
Further checking this, I found a function inv(const tensorField&), which I believe takes the inverse of a tensor, but I am unsure for what it takes the inverse, either the tensor in every cell or the overall tensor (the field itself).
I now assumed that it takes the inverse of every tensor in the cells and the following code came out for the following equation (IA_ij) * a_j = S_i > a_j = (IA_ij)^1 * S_i Code:
// velocity gradient matrix, M_ij 
solution found
The solution was a little bit easier than first assumed. OpenFOAM has a great operator definition which lets you divide by a tensor :)
So in case you have an equation A_ij x_j = s_i and you want to solve for x_j, where A is a second order tensor (for example the gradient of velocity, grad(U) ) and x and s are vectors, the one simply divides by A_ij as in Code:
volVectorField s(g); // g is the gravity field Code:
volVectorField s(g); // g is the gravity field 
Dear Roman,
I need to calculate a vector using anothor vector and a matrix by formula: Code:
a=[X^T X]^1 X^T y, Is there any possible to do that by openFOAM? Regards, 
Quote:

All times are GMT 4. The time now is 06:22. 