|
[Sponsors] |
August 8, 2019, 23:04 |
How to convert vectorField to volVectorField
|
#1 |
Member
Wenming Yang
Join Date: Jun 2018
Posts: 42
Rep Power: 8 |
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. |
|
August 12, 2019, 11:56 |
|
#2 | |
New Member
Sen Wang
Join Date: Jul 2018
Location: Singapore / Notre Dame, U.S.
Posts: 19
Blog Entries: 1
Rep Power: 8 |
Quote:
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! |
||
August 12, 2019, 22:56 |
|
#3 | |
Member
Wenming Yang
Join Date: Jun 2018
Posts: 42
Rep Power: 8 |
Quote:
Thank you for your reply. I think your first method works well. |
||
Tags |
field, geometricfield |
Thread Tools | Search this Thread |
Display Modes | |
|
|
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 |