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

Problems compiling with the 'diag' tensor function (diagonal components matrix)

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By herbert
  • 1 Post By deepsterblue

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 15, 2010, 10:55
Default Problems compiling with the 'diag' tensor function (diagonal components matrix)
  #1
New Member
 
Join Date: Jul 2009
Posts: 3
Rep Power: 17
danihuso is on a distinguished road
Hi everyone

I'm trying to create a strain rate function with only normal components (no shear). In order to do this I have to add the following code to src » transportModels » incompressible » viscosityModels » viscosityModel » viscosityModel.C:

Foam::tmp<Foam::volScalarField> Foam::viscosityModel::NormalStrainRate() const
{
return mag(diag(fvc::grad(U_)));
}

When I try to compile everything is fine but I get an error with the following description:

'diag' was not decleared in this scope

This is strange because I could use any other tensor operation function: symm, dev, skew, etc.. I don't get any error with them!!

Does anybody know why 'diag' is not declared? does it need any special heather file included (ie: #include fvCFD.H)?

Please could somebody reply this thread, everytime I post a thread in the OpenFOAM forum I never get a reply.

A reply would be appreciated

Thanks
danihuso is offline   Reply With Quote

Old   April 21, 2010, 12:55
Default
  #2
New Member
 
Sebastian W
Join Date: Nov 2009
Location: Germany
Posts: 16
Rep Power: 17
naval is on a distinguished road
I'm facing the same problem here.

Help would be greatly appreciated.

naval
naval is offline   Reply With Quote

Old   April 21, 2010, 15:39
Default
  #3
Senior Member
 
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 18
herbert is on a distinguished road
Hi,

did you try this?

return Foam::mag(Foam::diag(fvc::grad(U_)));

Sometimes it helps the compiler to find the right function.

Regards
herbert is offline   Reply With Quote

Old   April 22, 2010, 01:51
Default help
  #4
Member
 
mohsen kh
Join Date: Nov 2009
Posts: 41
Rep Power: 16
mohsenkh599 is an unknown quantity at this point
hi everyone
I have a new solver for two-phase modeling. but there is a problem while running any case (dam break for instance). when in ControlDict I put the write interval one second the solution diverge quickly but if I put it .05 second the solution converges. I could not understand how the write interval affects the convergence of the system.
please help as soon as possible
mohsenkh599 is offline   Reply With Quote

Old   April 22, 2010, 02:05
Default help
  #5
Member
 
mohsen kh
Join Date: Nov 2009
Posts: 41
Rep Power: 16
mohsenkh599 is an unknown quantity at this point
hi everyone
I need to work with asymmetric tensors in OpenFOAM. how can I implement a asymmetric tensor in a new solver in openfoam?
the best
mohsenkh599 is offline   Reply With Quote

Old   April 22, 2010, 07:28
Default
  #6
New Member
 
Sebastian W
Join Date: Nov 2009
Location: Germany
Posts: 16
Rep Power: 17
naval is on a distinguished road
Quote:
Originally Posted by herbert View Post
Hi,

did you try this?

return Foam::mag(Foam::diag(fvc::grad(U_)));

Sometimes it helps the compiler to find the right function.

Regards
Hi and thanks a lot for your reply.

I tried that one before, but I get this (now even more confusing) error:

Quote:
error: ‘diag’ is not a member of ‘Foam’
From your hint (and my understanding of the documentation) i take it that diag actually should be what the compiler claims it not to be - a member of Foam.

Any ideas what to try next?


Cheers,
naval
naval is offline   Reply With Quote

Old   April 22, 2010, 08:35
Default
  #7
Senior Member
 
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 18
herbert is on a distinguished road
Hi naval,

I know this is not the way such problems should be solved, but I would do it this way: Implement your own magDiag.

volTensorField gradU_ = fvc::grad(U_);
volScalarField strainRate_ =
Foam::sqrt(
Foam:ow(gradU_.component(tensor::XX), 2.0)
+ Foam:ow(gradU_.component(tensor::YY), 2.0)
+ Foam:ow(gradU_.component(tensor::ZZ), 2.0)
);
sina.s likes this.
herbert is offline   Reply With Quote

Old   April 22, 2010, 09:16
Default
  #8
New Member
 
Sebastian W
Join Date: Nov 2009
Location: Germany
Posts: 16
Rep Power: 17
naval is on a distinguished road
Unlike danihuso I actually need the resulting vector, not its magnitude.
Nevertheless I will try this approach and write my own diag.

Btw, your example doesn't compile, either (although I replaced the smilies ):

Quote:
error: no match for ‘operator+’ in ‘*(const double*)(f2P ++) + *(const Foam::Tensor<double>*)(f3P ++)’
... followed by lots of related errors and messages.
even if only add volTensorField gradU_ = fvc::grad(U_);.
I've got the feeling, that I'm missing sth basic, here.

Since I'm going to set up a new system on a new machine anyway I will be able to test diag with a freshly compiled OF in a couple of days. Hopefully with a little more luck.

Thanks a lot for your help and time,

Cheers,
naval
naval is offline   Reply With Quote

Old   April 22, 2010, 09:46
Default
  #9
New Member
 
Sebastian W
Join Date: Nov 2009
Location: Germany
Posts: 16
Rep Power: 17
naval is on a distinguished road
I'm babbling nonsense, here.
Your code compiles, of course.
I messed up some of my own code before when I was interrupted by the phone.

So a handmade diag will probably work.

Cheers,
naval
naval is offline   Reply With Quote

Old   March 4, 2011, 15:39
Default
  #10
Member
 
Hagen Müller
Join Date: Nov 2010
Posts: 34
Rep Power: 16
Hagen is on a distinguished road
Dear Foamers,

I face the same problem that you discussed above. The diag() operator does not work. I get the same error "‘diag’ was not declared in this scope"
Any new insights on that problem?

I also tried to wright my own diag(), but got stuck trying to assemble a vectorField from three scalarFields, which I defined as

scalarField a = TensorA.component(tensor::XX);
scalarField b = TensorA.component(tensor::YY);
scalarField c = TensorA.component(tensor::ZZ);

vectorField diagTensorA = vector(a, b, c);

This does not work. I would greatly appreciate any help on that issue.
Hagen is offline   Reply With Quote

Old   January 31, 2012, 10:31
Default diag removed?
  #11
New Member
 
Michael B Martell Jr
Join Date: Feb 2010
Location: Amherst, MA
Posts: 18
Rep Power: 16
theory37 is on a distinguished road
It appears as if diag has been removed for some reason. Solvers such as XiFoam have lines which used diag commented out and replaced by other things.

This is despite the fact that the user's guide continues to claim that diag exists. Any comments? Any simple workarounds?
theory37 is offline   Reply With Quote

Old   January 31, 2012, 11:23
Default
  #12
Senior Member
 
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25
deepsterblue will become famous soon enough
Use a diagTensor / diagTensorField instead.
sharonyue likes this.
__________________
Sandeep Menon
University of Massachusetts Amherst
https://github.com/smenon
deepsterblue is offline   Reply With Quote

Old   January 31, 2012, 11:45
Default Thanks
  #13
New Member
 
Michael B Martell Jr
Join Date: Feb 2010
Location: Amherst, MA
Posts: 18
Rep Power: 16
theory37 is on a distinguished road
Yep. Got that earlier this morning. Thanks Sandeep!
theory37 is offline   Reply With Quote

Reply

Tags
compile, diag, functions, matrix, tensor


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
Matrix storage and diagonal coeffients calculation santiagomarquezd OpenFOAM Programming & Development 16 January 14, 2022 05:48
Problems in compiling paraview in Suse 10.3 platform chiven OpenFOAM Installation 3 December 1, 2009 08:21
OpenFOAM version 1.6 details lakeat OpenFOAM Running, Solving & CFD 42 August 26, 2009 22:47
Problems compiling UDFs under SuSE 10.2 George FLUENT 1 February 21, 2007 09:36
Problems on Compiling UDF in FLUENT Strawberi-KeatKeat FLUENT 1 October 4, 2006 02:50


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