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

create volTensorField from volScalarField

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By boger

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 11, 2010, 07:27
Default create volTensorField from volScalarField
  #1
Senior Member
 
Steven van Haren
Join Date: Aug 2010
Location: The Netherlands
Posts: 149
Rep Power: 16
stevenvanharen is on a distinguished road
Hi does anyone have an idea how to create a volTensorField from volScalarField.

For instance I have volScalarField a and want to create the following volTensorField:

random example:

[a , 0 ,0,
a, 0 ,0,
0, 0, a]

How do I program this?
stevenvanharen is offline   Reply With Quote

Old   November 12, 2010, 11:19
Default
  #2
Senior Member
 
David Boger
Join Date: Mar 2009
Location: Penn State Applied Research Laboratory
Posts: 146
Rep Power: 17
boger is on a distinguished road
You could always set each value explicitly; e.g.
Code:
    forAll(T,cellI)
    {
      T[cellI].xx() = a[cellI];
    }
but in your case, what about something like this:
Code:
    tensor select(1,0,0,1,0,0,0,0,1);
    T = a*select;
or more directly
Code:
T = a*tensor(1,0,0,1,0,0,0,0,1);
In all cases, a is a volScalarField and T a volTensorField.
codder and clarence like this.
__________________
David A. Boger
boger is offline   Reply With Quote

Old   November 15, 2010, 04:23
Default
  #3
Senior Member
 
Steven van Haren
Join Date: Aug 2010
Location: The Netherlands
Posts: 149
Rep Power: 16
stevenvanharen is on a distinguished road
Hi David,

no I solved it like this:

volTensorField T
(
IOobject
(
"Transform",
runTime.timeName(),
mesh
//IOobject::NO_READ
//IOobject::NO_WRITE
),
mesh,
tensor(0,0,0,0,0,0,0,0,0)
);
T=tensor(0,0,0,0,0,0,1,0,0)+(tensor(0,-1,0,0,0,0,0,0,0)*sin(theta))+(tensor(0,0,1,0,0,0,0 ,0,0)*cos(theta))+(tensor(0,0,0,0,-1,0,0,0,0)*cos(theta))+(tensor(0,0,0,0,0,-1,0,0,0)*sin(theta));
T.write();

Where theta is a volScalarField.

So there really is no constructor which can handle volScalarFields as an argument I guess.

P.S. How do I post code like you? Couldn't find how to do it but it looks more nice.
stevenvanharen is offline   Reply With Quote

Old   November 16, 2010, 03:22
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by stevenvanharen View Post
...
P.S. How do I post code like you? Couldn't find how to do it but it looks more nice.
If you are posting with the WYSIWYG forum editor, use the '#' from the toolbar. This wraps "[ CODE ]" ... "[/ CODE ]" tags around the selected text, but of course without the spaces that I've need to add in order to post it.
olesen is offline   Reply With Quote

Old   November 16, 2010, 04:16
Default
  #5
Senior Member
 
Steven van Haren
Join Date: Aug 2010
Location: The Netherlands
Posts: 149
Rep Power: 16
stevenvanharen is on a distinguished road
Ok, thanks!

Code:
Cool
stevenvanharen is offline   Reply With Quote

Reply


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
How to create initiate a volScalarField p without reading from disk NO_READ does not seem to work dbxmcf OpenFOAM Running, Solving & CFD 14 March 25, 2022 07:08
how to create a volScalarField of mesh.V() ??? sebware OpenFOAM Programming & Development 12 June 25, 2019 04:34
Actuator disk model audrich FLUENT 0 September 21, 2009 08:06
Where's the singularity/mesh flaw? audrich FLUENT 3 August 4, 2009 02:07
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 12:55


All times are GMT -4. The time now is 02:29.