|
[Sponsors] |
January 25, 2013, 03:48 |
create volTensorField out of volScalarFields
|
#1 | |
New Member
Join Date: Mar 2012
Posts: 18
Rep Power: 14 |
Hello everybody,
I want to create a volTensorField out of a couple of volScalarFields. The tensor should look (for example) like this JacobiMatrix=(m1, m2+m1, 0, m5*m3, m4, 0, m0, m2/m1, m2). The Moments m0-m5 are defined like this Code:
Info<< "Reading field m0" << endl; volScalarField m0 ( IOobject ( "m0", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); For example: Code:
Info<< "Define tensorfield jacobiMatrix" << endl; volTensorField jacobiMatrix ( IOobject ( "jacobiMatrix", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, dimensionedTensor ( "zero", dimensionSet(0, 0, 0, 0, 0, 0, 0), tensor::zero ) ); Code:
jacobiMatrix.component(0) = m1; jacobiMatrix.component(1) = m2+m1; … Quote:
|
||
January 25, 2013, 04:50 |
|
#2 |
Member
Jim Knopf
Join Date: Dec 2010
Posts: 60
Rep Power: 15 |
You could do a loop over all cells and then compute your components like:
Code:
// const Foam::cellList cells = mesh.cells() forAll(cells,cellI) { JacobiMatrix[cellI].component(0) = m1[cellI]+m2[cellI]; // same for all the others } Best Regards Jim |
|
January 25, 2013, 07:40 |
|
#3 |
New Member
Join Date: Mar 2012
Posts: 18
Rep Power: 14 |
Thanks a lot, it is working.
But I have to write forAll(mesh.cells(),cellI) {... I already read that it's not a good style. But I did not find an answer on the question, how a good style would look like. Last edited by anton_lias; January 25, 2013 at 08:33. Reason: mesh.cells |
|
December 20, 2014, 23:10 |
|
#4 |
Member
Jack
Join Date: Aug 2012
Posts: 47
Rep Power: 13 |
I know this is an old post, but did you (or anyone else) find a more compact solution to this problem? Would be much appreciated!
|
|
December 22, 2014, 09:13 |
|
#5 |
Senior Member
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25 |
What you're looking for here is the replace() member function:
Code:
jacobiMatrix.replace(0, m0); jacobiMatrix.replace(1, m1); jacobiMatrix.replace(2, m2); ... ... jacobiMatrix.replace(8, m8); |
|
December 22, 2014, 10:44 |
|
#6 |
Member
Jack
Join Date: Aug 2012
Posts: 47
Rep Power: 13 |
Brilliant, thanks!
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
create the file *.foam | phongstar | OpenFOAM | 12 | October 14, 2018 18:06 |
Possible to create cyliner baffle (internal) using topoSet or stl Mesh? | keepfit | OpenFOAM | 4 | February 19, 2017 14:40 |
[ICEM] how to create a 2d tri mesh with quad mesh in the boundary layer | seal2013 | ANSYS Meshing & Geometry | 3 | October 6, 2013 16:09 |
Problems with Mirror tools when create block | nigel332 | Pointwise & Gridgen | 4 | September 26, 2013 20:21 |
About create interface! | xinzhiyu2008 | STAR-CCM+ | 2 | August 6, 2010 20:47 |