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

create volTensorField from volScalarField

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

Like Tree1Likes
  • 1 Post By boger

Reply
 
LinkBack Thread Tools Display Modes
Old   November 11, 2010, 06:27
Default create volTensorField from volScalarField
  #1
Senior Member
 
Steven van Haren
Join Date: Aug 2010
Location: The Netherlands
Posts: 149
Rep Power: 6
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, 10:19
Default
  #2
Senior Member
 
David Boger
Join Date: Mar 2009
Location: Penn State Applied Research Laboratory
Posts: 146
Rep Power: 7
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 likes this.
__________________
David A. Boger
boger is offline   Reply With Quote

Old   November 15, 2010, 03:23
Default
  #3
Senior Member
 
Steven van Haren
Join Date: Aug 2010
Location: The Netherlands
Posts: 149
Rep Power: 6
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, 02:22
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 774
Rep Power: 17
olesen will become famous soon enough
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, 03:16
Default
  #5
Senior Member
 
Steven van Haren
Join Date: Aug 2010
Location: The Netherlands
Posts: 149
Rep Power: 6
stevenvanharen is on a distinguished road
Ok, thanks!

Code:
Cool
stevenvanharen is offline   Reply With Quote

Reply

Thread Tools
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 On
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 12 August 22, 2013 07:32
how to create a volScalarField of mesh.V() ??? sebware OpenFOAM Programming & Development 4 July 6, 2011 10:17
Actuator disk model audrich FLUENT 0 September 21, 2009 07:06
Where's the singularity/mesh flaw? audrich FLUENT 3 August 4, 2009 01:07
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 11:55


All times are GMT -4. The time now is 12:44.