# create volTensorField from volScalarField

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

 November 11, 2010, 07:27 create volTensorField from volScalarField #1 Senior Member   Steven van Haren Join Date: Aug 2010 Location: The Netherlands Posts: 149 Rep Power: 9 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?

 November 12, 2010, 11:19 #2 Senior Member   David Boger Join Date: Mar 2009 Location: Penn State Applied Research Laboratory Posts: 146 Rep Power: 10 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

 November 15, 2010, 04:23 #3 Senior Member   Steven van Haren Join Date: Aug 2010 Location: The Netherlands Posts: 149 Rep Power: 9 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.

November 16, 2010, 03:22
#4
Senior Member

Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 802
Rep Power: 21
Quote:
 Originally Posted by stevenvanharen ... 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.

 November 16, 2010, 04:16 #5 Senior Member   Steven van Haren Join Date: Aug 2010 Location: The Netherlands Posts: 149 Rep Power: 9 Ok, thanks! Code: `Cool`

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post dbxmcf OpenFOAM Running, Solving & CFD 12 August 22, 2013 07:32 sebware OpenFOAM Programming & Development 4 July 6, 2011 10:17 audrich FLUENT 0 September 21, 2009 07:06 audrich FLUENT 3 August 4, 2009 01:07 SSL FLUENT 2 January 26, 2008 12:55

All times are GMT -4. The time now is 13:00.