CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Problems compiling with the 'diag' tensor function (diagonal components matrix) (http://www.cfd-online.com/Forums/openfoam-programming-development/73720-problems-compiling-diag-tensor-function-diagonal-components-matrix.html)

danihuso March 15, 2010 10:55

Problems compiling with the 'diag' tensor function (diagonal components matrix)
 
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

naval April 21, 2010 11:55

I'm facing the same problem here.

Help would be greatly appreciated.

naval

herbert April 21, 2010 14:39

Hi,

did you try this?

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

Sometimes it helps the compiler to find the right function.

Regards

mohsenkh599 April 22, 2010 00:51

help
 
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 April 22, 2010 01:05

help
 
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

naval April 22, 2010 06:28

Quote:

Originally Posted by herbert (Post 255706)
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

herbert April 22, 2010 07:35

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::pow(gradU_.component(tensor::XX), 2.0)
+ Foam::pow(gradU_.component(tensor::YY), 2.0)
+ Foam::pow(gradU_.component(tensor::ZZ), 2.0)
);

naval April 22, 2010 08:16

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 April 22, 2010 08:46

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

Hagen March 4, 2011 15:39

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.

theory37 January 31, 2012 10:31

diag removed?
 
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. :mad: Any comments? Any simple workarounds?

deepsterblue January 31, 2012 11:23

Use a diagTensor / diagTensorField instead.

theory37 January 31, 2012 11:45

Thanks
 
Yep. Got that earlier this morning. Thanks Sandeep!


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