|
[Sponsors] |
convert a "volScalarField" to an "fvScalarMatrix" |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 |
Senior Member
A. Min
Join Date: Mar 2015
Posts: 305
Rep Power: 12 ![]() |
Hi
How can I convert a "volScalarField" to an "fvScalarMatrix"? I want to add a volScalarField term to energy Eqn. Thanks |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21 ![]() |
Adding a volScalarField to a fvScalarMatrix is as simple as this:
Code:
volScalarField source = ...; fvScalarMatrix equation = ...; equation == source; |
|
![]() |
![]() |
![]() |
![]() |
#3 | |
Senior Member
A. Min
Join Date: Mar 2015
Posts: 305
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 |
||
![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21 ![]() |
Even though types of variables are different they can be operated that way just fine giving you the result that you might expect.
|
|
![]() |
![]() |
![]() |
![]() |
#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, |
|
![]() |
![]() |
![]() |
![]() |
#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? |
|
![]() |
![]() |
![]() |
![]() |
#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) |
|
![]() |
![]() |
![]() |
![]() |
#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.
|
|
![]() |
![]() |
![]() |
![]() |
#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, |
|
![]() |
![]() |
![]() |
![]() |
#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 12:05. Reason: Code |
|
![]() |
![]() |
![]() |
![]() |
#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. |
|
![]() |
![]() |
![]() |
![]() |
#12 |
Senior Member
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21 ![]() |
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(); |
|
![]() |
![]() |
![]() |
![]() |
#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.
|
|
![]() |
![]() |
![]() |
![]() |
#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 |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Tool to convert OpenFoam mesh to SU2 mesh (2D and 3D) | Combas | SU2 | 44 | March 12, 2024 00:35 |
[snappyHexMesh] Convert stl files and multi region | abrunet | OpenFOAM Meshing & Mesh Conversion | 1 | July 1, 2014 10:15 |
convert a structured multiblock grid to an one unstructured: modification of cells | Mirage | ANSYS | 0 | July 18, 2012 09:14 |
ImageMagick will not convert jpg to mpg | musahossein | Main CFD Forum | 1 | December 2, 2011 10:44 |