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

How to convert vectorField to volVectorField

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 8, 2019, 23:04
Default How to convert vectorField to volVectorField
  #1
Member
 
Wenming Yang
Join Date: Jun 2018
Posts: 42
Rep Power: 8
ywem is on a distinguished road
Dear Foamers,
I am working on solving an equation like

fvm::ddt(M)
+fvm::div(phi, M)
==
-(M-M0)/tau

where tau is a constant, M and M0 are volVectorField. M0 is calculated by M0=H*tem1/mag(H), here I calculate tem1 as follows,

scalarField tem1(0.0);
forAll(H,i)
{
tem1[i] = 1.0/Foam::tanh(gamma.value()*mag(H).ref()[i])-1.0/(gamma.value()*mag(H).ref()[i]);
}

H is a volVectorField. M, M0, and H are defined in the file createFields.H. But when I typed

M0=H*tem1/mag(H)

and compiled, the following error occur,

error: no match for ‘operator*’ (operand types are ‘Foam::tmp<Foam::GeometricField<Foam::Tensor<doubl e>, Foam::fvPatchField, Foam::volMesh> >’ and ‘Foam::scalarField {aka Foam::Field<double>}’)

It seems that tem1 must be a geometricField. Can anyone help me for this problem? Thanks in advance.
ywem is offline   Reply With Quote

Old   August 12, 2019, 11:56
Default
  #2
New Member
 
Sen Wang
Join Date: Jul 2018
Location: Singapore / Notre Dame, U.S.
Posts: 19
Blog Entries: 1
Rep Power: 8
wangsen992 is on a distinguished road
Quote:
Originally Posted by ywem View Post
scalarField tem1(0.0);
forAll(H,i)
{
tem1[i] = 1.0/Foam::tanh(gamma.value()*mag(H).ref()[i])-1.0/(gamma.value()*mag(H).ref()[i]);
}

H is a volVectorField. M, M0, and H are defined in the file createFields.H. But when I typed

M0=H*tem1/mag(H)
Hi there,

I'm new to the code part of OpenFOAM but I will try to help with the best of my understanding.

If you go back to section 3.2.1 of the programmer's guide, you will see that scalarField is only a typedef-declared class name for List<Type>, which is distinctively different from geometricField<Type>. The problem here lies in the fact that there is no way for the operator to match the values since one is a List while the other includes the mesh.

The solution here, I suppose, is to initiate tem1 in 0/ directory as well, and initialize it with the equation you used.

Another solution is to use the static function (geometricField<Type>::New())[https://www.openfoam.com/documentati...b1bfde253137a] and calculate your tem1.

I hope this would give some ideas.

Cheers!
wangsen992 is offline   Reply With Quote

Old   August 12, 2019, 22:56
Default
  #3
Member
 
Wenming Yang
Join Date: Jun 2018
Posts: 42
Rep Power: 8
ywem is on a distinguished road
Quote:
Originally Posted by wangsen992 View Post
Hi there,

I'm new to the code part of OpenFOAM but I will try to help with the best of my understanding.

If you go back to section 3.2.1 of the programmer's guide, you will see that scalarField is only a typedef-declared class name for List<Type>, which is distinctively different from geometricField<Type>. The problem here lies in the fact that there is no way for the operator to match the values since one is a List while the other includes the mesh.

The solution here, I suppose, is to initiate tem1 in 0/ directory as well, and initialize it with the equation you used.

Another solution is to use the static function (geometricField<Type>::New())[https://www.openfoam.com/documentati...b1bfde253137a] and calculate your tem1.

I hope this would give some ideas.

Cheers!
Dear Wang,
Thank you for your reply.
I think your first method works well.
ywem is offline   Reply With Quote

Reply

Tags
field, geometricfield

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
difference volVectorField and vectorField annan OpenFOAM 10 July 5, 2022 05:53
dot product of vectorField and volVectorField sahm OpenFOAM 2 August 28, 2017 03:56
How to extract ONLY ONE Boundary data to make a VectorField File from volVectorField hy1112006 OpenFOAM Programming & Development 2 April 14, 2016 12:11
convert a structured multiblock grid to an one unstructured: modification of cells Mirage ANSYS 0 July 18, 2012 09:14


All times are GMT -4. The time now is 01:19.