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

create volVectorField using volScalarField

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By Tobermory

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 26, 2025, 10:15
Default create volVectorField using volScalarField
  #1
New Member
 
Nicholas Langbein
Join Date: Nov 2024
Posts: 21
Rep Power: 2
Nicholas_Langbein is on a distinguished road
Hello guys,

i am new to openfoam, i have a variable volScalarField f_sl which is calculated from strain rate multiplied with some constants and then dimensionedScalar (with dimension length) -- now volScalarField is m/s velocity

i want to make this volVectorField with f_sl as Z Component to create fvc::flux() using this volVectorField to use for convection.

Please can someone give an idea how to make volScalarField to volVectorField

i saw volScalarField to volVectorField

but Uvec.internalField().replace(vector::X,avgUx.inter nalField()); dosent work
Nicholas_Langbein is offline   Reply With Quote

Old   February 26, 2025, 11:32
Default
  #2
nhj
New Member
 
Join Date: Sep 2024
Posts: 1
Rep Power: 0
nhj is on a distinguished road
Hi Nicholas,


off the top of my head, you could try iterating over your volVectorField and assigning the component from f_sl directly to each field element, sort of along the lines of:


Code:
// Define your vector field

volVectorField f;


// This loops over each cell of your mesh
forAll(f_sl, celli){
    //Access the z component of your vector field and assign the cell value of the strain rate 
    f[celli].z() = f_sl[celli]; 

}

// ...

Let me know if you figure out a more efficient way of doing this though.

cheers
nhj is offline   Reply With Quote

Old   February 27, 2025, 04:04
Default
  #3
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 836
Blog Entries: 1
Rep Power: 19
dlahaye is on a distinguished road
Not sure.

Using the .flux member function of the volScalarField?
dlahaye is offline   Reply With Quote

Old   February 27, 2025, 04:54
Default
  #4
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 825
Rep Power: 16
Tobermory will become famous soon enough
Quote:
Originally Posted by Nicholas_Langbein View Post
Hello guys,
i am new to openfoam, i have a variable volScalarField f_sl which is calculated from strain rate multiplied with some constants and then dimensionedScalar (with dimension length) -- now volScalarField is m/s velocity

i want to make this volVectorField with f_sl as Z Component
If I understand right, you want to create a volVectorField where the z component is the value of the scalar, and the x/y components are zero? If so, then that's really easy - try something like:

Code:
        vector v0(0,0,1);
        volVectorField v1
                (
                   IOobject ("v1", mesh().time().name(), mesh(), IOobject::NO_READ, IOobject::AUTO_WRITE ),
                   mesh(),
                   v0
                );
        v1 *= f_sl;
olesen likes this.
Tobermory is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Using createPatch and cyclicAMI in FOAM Extend to create periodicbox manuc OpenFOAM Running, Solving & CFD 1 April 12, 2022 11:36
OpenFoam "Permission denied" and "command not found" problems. iyidaniel@yahoo.co.uk OpenFOAM Running, Solving & CFD 11 January 2, 2018 06:47
using chemkin JMDag2004 OpenFOAM Pre-Processing 2 March 8, 2016 22:38
Can't create VolScalarField based on a Dimensioned Scalar pupo OpenFOAM Programming & Development 3 November 23, 2014 17:29
Actuator disk model audrich FLUENT 0 September 21, 2009 07:06


All times are GMT -4. The time now is 23:17.