CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Solve algebraic equation for field

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By agustinvo

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 8, 2019, 17:33
Default Solve algebraic equation for field
  #1
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21
jherb is on a distinguished road
I would like to add an equation like the following to my solver:


A \vec{y} = \vec{b}


A is a 3x3 matrix, \vec{y} and \vec{b} are 3-dim vectors. All are fields (volVectorField, volTensorField), so are functions of the location (cells).


Does a build-in method exists in OpenFOAM to solve such an equation (actually solving this equation for all cells)?


Thank you for any help.
jherb is offline   Reply With Quote

Old   May 9, 2019, 02:49
Default
  #2
Senior Member
 
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 313
Rep Power: 15
agustinvo is on a distinguished road
Hi


just write


Code:
y=B/A
When doing this with a tensor A and a vector B, it does


Code:
y = inv(A) * B
Please check here.
jherb likes this.
agustinvo is offline   Reply With Quote

Old   May 12, 2019, 09:50
Default
  #3
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 723
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
See https://www.linkedin.com/pulse/openf...menico-lahaye/ and references cited.

Kind wishes, Domenico Lahaye.
dlahaye is offline   Reply With Quote

Old   May 22, 2019, 07:01
Default
  #4
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21
jherb is on a distinguished road
Quote:
Originally Posted by agustinvo View Post
Hi


just write


Code:
y=B/A
When doing this with a tensor A and a vector B, it does


Code:
y = inv(A) * B
Please check here.

Thank you. This works.
jherb is offline   Reply With Quote

Old   July 9, 2019, 14:47
Default
  #5
Senior Member
 
Syavash Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18
syavash is on a distinguished road
Quote:
Originally Posted by jherb View Post
Thank you. This works.
Dear Joachim,

Would you give some elaboration on what the type of vector and matrix is?
I have a similar problem in which I have defined the matrix of coefficient as

Code:
scalarSquareMatrix A(3, 3, 0);
and the coefficient vector and the unknown vector as

Code:
scalarDiagonalMatrix Coeff(3, 0);
scalarDiagonalMatrix xx(3, 0);
But when I input the following line in my code
Code:
xx = Coeff/A;
I get a bunch of errors. I suppose I should change the types of the matrix and vectors but I am not sure how.

Syavash
syavash is offline   Reply With Quote

Old   July 9, 2019, 18:21
Default
  #6
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21
jherb is on a distinguished road
This is the principle implementation I use:
Code:
    volVectorField rightSide
    (
        something
    );

    volTensorField leftSide
    (
        I
    );

    volVectorField result = inv(leftSide) & rightSide;
jherb is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting the height of the stream in the free channel kevinmccartin CFX 12 October 13, 2022 21:43
Domain Reference Pressure and mass flow inlet boundary AdidaKK CFX 75 August 20, 2018 05:37
Problem with Velocity Poisson Equation and Vector Potential Poisson Equation mykkujinu2201 Main CFD Forum 1 August 12, 2017 13:15
error message cuteapathy CFX 14 March 20, 2012 06:45
solve equation michaelsmit OpenFOAM Running, Solving & CFD 4 March 24, 2011 05:35


All times are GMT -4. The time now is 12:51.