|
[Sponsors] |
convert a "volScalarField" to an "fvScalarMatrix" |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 20, 2018, 09:00 |
convert a "volScalarField" to an "fvScalarMatrix"
|
#1 |
Senior Member
A. Min
Join Date: Mar 2015
Posts: 308
Rep Power: 12 |
Hi
How can I convert a "volScalarField" to an "fvScalarMatrix"? I want to add a volScalarField term to energy Eqn. Thanks |
|
January 21, 2018, 12:22 |
|
#2 |
Senior Member
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 22 |
Adding a volScalarField to a fvScalarMatrix is as simple as this:
Code:
volScalarField source = ...; fvScalarMatrix equation = ...; equation == source; |
|
January 21, 2018, 13:53 |
|
#3 | |
Senior Member
A. Min
Join Date: Mar 2015
Posts: 308
Rep Power: 12 |
Quote:
Yes, I did it by chance and it didn't give me any error😁 I thought that these kind of variables are different. Again thanks |
||
January 21, 2018, 17:24 |
|
#4 |
Senior Member
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 22 |
Even though types of variables are different they can be operated that way just fine giving you the result that you might expect.
|
|
April 3, 2020, 07:14 |
Upside down
|
#5 |
Member
Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 57
Rep Power: 9 |
Hi Foamers,
I would like to save the values of the fvScalarMatrix after solving it. But the operator "==" doesn't work upside down, I mean, assigning the values of the fvScalarMatrix to a volScalarField. Do you know how to do it? Thanks, |
|
April 3, 2020, 11:41 |
|
#6 |
Senior Member
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 314
Rep Power: 15 |
Hi,
you can't do this because a volScalarField is a scalar variable. fvScalarMatrix is an equation for a scalar variable. What do you want to save from it? |
|
April 3, 2020, 11:48 |
|
#7 |
Member
Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 57
Rep Power: 9 |
Hi agustinvo,
I would like to save the solution of the fvScalarMatrix and then, pass the solution as a volScalarField to another fvScalarMatrix something like: Code:
fvScalarMatrix equation0 (); equation0.solve(); fvScalarMatrix equation1 (blablablah=solution of equation0) |
|
April 3, 2020, 12:29 |
|
#8 |
Senior Member
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 314
Rep Power: 15 |
Well, when you solve your fvScalarMatrix equation0 you compute the value of a certain variable var0. Then just add it as a source term into equation1.
|
|
April 3, 2020, 12:38 |
|
#9 |
Member
Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 57
Rep Power: 9 |
The problem is that the dependent variable of equation0 is not the same as the one in equation1...
Thanks for your quick reply, |
|
April 3, 2020, 12:59 |
|
#10 |
Senior Member
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 314
Rep Power: 15 |
That is not a problem! Look:
Code:
fvScalarMatrix TEqn ( fvm::div(phi, T) - fvm::laplacian(alphaEff, T) == fvOptions(T) ); You can add later on T in a source term of any other equation, like Code:
tmp<fvVectorMatrix> tUEqn ( fvm::div(phi, U) + turbulence->divDevReff(U) == g*beta*(T-TRef) + fvOptions(U) ); Last edited by agustinvo; April 3, 2020 at 13:05. Reason: Code |
|
April 3, 2020, 13:19 |
|
#11 |
Member
Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 57
Rep Power: 9 |
My code is something like:
Code:
fvScalarMatrix STransfer ( K*S2Sat - fvm::Sp(K,S2) ); STransfer.solve(); fvScalarMatrix S2Eqn ( fvm::ddt(alpha2, S2) + fvm::div(alphaPhi2, S2) == STransfer ); S2Eqn.solve(); fvScalarMatrix S1Eqn ( fvm::ddt(alpha1, S1) + fvm::div(alphaPhi1, S1) == -STransfer ); S1Eqn.solve(); That's one of the problems and probably I would face more after solving this one... Thanks in advance, PD: Do not hesitate to sent my a private message. |
|
April 3, 2020, 16:26 |
|
#12 |
Senior Member
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 22 |
You may want to use S2 field for which S2Eqn equation has been solved for
Code:
fvScalarMatrix S1Eqn ( fvm::ddt(alpha1, S1) + fvm::div(alphaPhi1, S1) == -(K*S2Sat - K*S2) ); S1Eqn.solve(); |
|
April 4, 2020, 05:15 |
|
#13 |
Senior Member
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 314
Rep Power: 15 |
Indeed, this is what it was planned to add.
|
|
April 6, 2020, 13:11 |
|
#14 |
Member
Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 57
Rep Power: 9 |
Thanks for your help Zeppo and agustinvo.
I have compiled that code and I'm trying it at a simple case. |
|
Tags |
openfoam, programing |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Tool to convert OpenFoam mesh to SU2 mesh (2D and 3D) | Combas | SU2 | 45 | October 16, 2024 18:26 |
[snappyHexMesh] Convert stl files and multi region | abrunet | OpenFOAM Meshing & Mesh Conversion | 1 | July 1, 2014 11:15 |
convert a structured multiblock grid to an one unstructured: modification of cells | Mirage | ANSYS | 0 | July 18, 2012 10:14 |
ImageMagick will not convert jpg to mpg | musahossein | Main CFD Forum | 1 | December 2, 2011 11:44 |