CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Expanding an Implicit Scalar Source term to a Vector or Tensor (https://www.cfd-online.com/Forums/openfoam-solving/225137-expanding-implicit-scalar-source-term-vector-tensor.html)

ScalarVectorTensor March 16, 2020 06:02

Expanding an Implicit Scalar Source term to a Vector or Tensor
 
Hello Foamers,

I have a question concerning the expansion of an implicit scalar source term to a vector or tensor.

The term in question is written in code in the form of -fvm::Sp(A,B) where A is a scalar and B is a vector. As is known simply inserting A in the form of a vector or a tensor will cause OpenFoam to fail. The first thing that I thought to try was to simply insert the term explicity -(A^ B) for the vector interpretation and (A&B) for the tensor interpretation. This successfully compiles however when ran is unstable and eventually fails one the with the Courant number trending to infinity (1*10^84) followed by openFoam crashing. Shrinking the timestep by setting a Courant number maximum can delay this, however eventually the timestep becomes exceedingly for all intents and purposes ceases to proceed.

To test that it was the explicit nature of the term causing the crash I did a calculation with the scalar interpretation of A as explicit (A*B) or fvc::Sp(A, B) and the calculation fails in the same way. This is what caused me to believe that the term must be implicit for the calculation to be successful. The following is a series of thoughts I have and things I have already tried.

1/ Function to evaluate implicitly Vectors and Tensors
I do recall this being raised a few years ago on this forum however the issue never seemed to be resolved, hence I am raising it again as new versions of openFoam have been released since then. Did anyone ever code a function for this that I am unaware of that can simply be copied into the fvm::Sp source code files? Also how much effort would be required to code such a function to make fvm::Sp accept tensors and vectors?

2/ Using Multiple implicit scalar terms to represent a vector term
I think this may be a dead end but I was attempting to finesse the problem in the following way. Define the vector, Define a scalar interpretation of the vector (3 scalar terms representing each component (Ax, Ay and Az)) and then attempting to do the following fvm::Sp(Ax, B^i) fvm::Sp(Ay, B^j) fvm::Sp(Az, B^k) where i, j and k are defined as constant vectors (1,0,0), (0,1,0) and (0,0,1) respectively. The alternative representation (fvm::Sp(Ax, B)^i) (fvm::Sp(Ay, B)^j) (fvm::Sp(Az, B)^k) was also attempted to no avail as well as outside of the equation defining 3 volVectorFields Ux= U ^ i and expressing the terms as follows fvm::Sp(Ax, Bx) fvm::Sp(Ay, By) fvm::Sp(Az, Bz). Even if there is a way to make it work I do not yet have an idea about how to expand it to a tensor representation.

3/ Splitting the equation itself into 3 components for a vector source term
I was also working on the following, splitting the equation itself in the following way,

fvVectorMatrix BEqnx
(
LeftHandSide ==
- (fvm::Sp(Ax,Bx))
);

However I could not figure out how to recombine the equations at the end as further operations mandate the equations being recombined into a single fvVectorMatrix (BEqn) after the computation. Like with the previous point I do not yet have an idea about how to expand it to a tensor representation if successful.

As you can see I am at a little bit of a loss as to how to proceed with this issue. Hence I am hoping that one of you can help me out.

Thanks,

ScalarVectorTensor

Note A and B in this case are general quantities with no physical meaning used for explaining the coding issues, I am not in a position to comment on the nature of the solver and simulation itself (or possibly in a limited way).


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