View Issue Details

IDProjectCategoryView StatusLast Update
0001017OpenFOAMBugpublic2013-09-19 15:56
Reporteruser352Assigned Tohenry  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
PlatformIBM iDataPlexOSRedHat LinuxOS Version6
Summary0001017: det(tensor) returns incorrect units.
DescriptionAs part of my simulations I need to compute the determinant of the velocity gradient tensor. I then use this scalar value for other operations, so the units must be correct.

The velocity gradient tensor (gradU) produces the correct units of (1/time). However, taking the determinant of that tensor yields a scalar that also has the units of (1/time), but the correct units are (1/time^3).

I have identified the problem. in $FOAM_SRC/OpenFOAM/dimensionedTypes/dimensionedTensor/dimensionedTensor.C, line 88 reads that the dimensions of the resulting scalar after computing the determinant are
pow(dt.dimensions(), tensor::dim)

My understanding is that dt.dimensions() returns the dimension vector, in the case of grad(U), dt.dimensions() = [0 0 -1 0 0 0 0]. tensor::dim is the order of the tensor, which for a rank 2 tensor is 3. So [0 0 -1 0 0 0 0]^(3) = [0 0 -1 0 0 0 0].

So the definition for the dimension of the resulting scalar is incorrect with an order 1 dimension in the tensor. The same problem exist for the symmetric and spherical tensors.
Steps To ReproduceI have included the code used to generate the respective fields.

        volTensorField gradU
        (
                IOobject
                (
                        "gradU",
                        runTime.timeName(),
                        mesh,
                        IOobject::NO_READ,
                        IOobject::NO_WRITE
                ),
                fvc::grad(U)
        );
        gradU.write();

        volScalarField detGradU
        (
                IOobject
                (
                        "detGradU",
                        runTime.timeName(),
                        mesh,
                        IOobject::NO_READ,
                        IOobject::NO_WRITE
                ),
                det(gradU)
        );
        detGradU.write();
TagsNo tags attached.

Activities

user352

2013-09-18 17:35

  ~0002500

I believe it would be correct to multiply, rather that perform a power operation. This would produce the correct dimensions.

dt.dimensions() * tensor::dim

As dt.dimensions() is a vector representing the exponents of the units, multiplying the exponents is true in general. Remember (x^2)^3 = x^6 (i.e., 2*3=6)

henry

2013-09-19 15:56

manager   ~0002504

Resolved by commit 01285215de4e5dc0225cee0437764858c80ccbd2

Issue History

Date Modified Username Field Change
2013-09-17 06:22 user352 New Issue
2013-09-18 17:35 user352 Note Added: 0002500
2013-09-19 15:56 henry Note Added: 0002504
2013-09-19 15:56 henry Status new => resolved
2013-09-19 15:56 henry Resolution open => fixed
2013-09-19 15:56 henry Assigned To => henry