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

Double Inner Product of Two Second Rank Tensors

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

Like Tree4Likes
  • 1 Post By Tobermory
  • 2 Post By Tobermory
  • 1 Post By rtyme06

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 8, 2020, 10:50
Angry Double Inner Product of Two Second Rank Tensors
  #1
New Member
 
idrees khan
Join Date: Jun 2019
Posts: 27
Rep Power: 3
idrees khan is on a distinguished road
Hello,
sorry to say i post so many times but no one is going to answer my question.


I'm going to add Temperature equation to viscoelasticFluidFoam solver(screenshort is attached).


fvScalarMatrix TEqn
(
fvm::ddt(T)
+ fvm::div(phi,T)
- fvm::laplacian(DT,T)
- 1.0/rho/Cv * (gamma*visco.tau() && Foam::symm(fvc::grad(U))+ (Foam::exp( -C11*(T - To) / (C21 + T - To) )*etaS*Foam::symm(fvc::grad(U)))&& Foam:fvc::grad(U)))
);

TEqn.relax();
TEqn.solve();


when i add and compile with "wmake" getting error's(screenshort is attached)


after this i removed the term "&& Foam:fvc::grad(U)))" and compile with wmake it work.
kindly any one who know guide me that i may fix this problem.
regards
idrees
idrees khan is offline   Reply With Quote

Old   December 8, 2020, 14:06
Default
  #2
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 116
Rep Power: 4
Tobermory is on a distinguished road
Well, the error message is telling you that you are trying to do the double inner product of a double (ie scalar) and a tensor. Unsurprisingly it can't do this.

Also not surprising is that the code compiles when you remove the part that follows the &&, since that just leaves the left hand side of the && which is a scalar.

The question you need to ask yourself now is: why is the left hand side a scalar and not a tensor?

It's impossible to debug from your partial listing - but here are a few pieces of advice. Start by stripping back the equation and feed terms in from the right hand side. E.g. start with the symm(grad(U))&&grad(U) term, and note that one is a symm tensor, the other isn't. Get that to work, then start adding the other terms. Look for examples of similar coding in the library applications - do a grep on symm(grad(U)) for example to find these. Read the error messages carefully and think about what it's telling you - I know there's a lot of text there ... but within the text often hides the solution.

Good luck.
idrees khan likes this.
Tobermory is offline   Reply With Quote

Old   December 9, 2020, 05:04
Default
  #3
New Member
 
idrees khan
Join Date: Jun 2019
Posts: 27
Rep Power: 3
idrees khan is on a distinguished road
Quote:
Originally Posted by Tobermory View Post
Well, the error message is telling you that you are trying to do the double inner product of a double (ie scalar) and a tensor. Unsurprisingly it can't do this.

Also not surprising is that the code compiles when you remove the part that follows the &&, since that just leaves the left hand side of the && which is a scalar.

The question you need to ask yourself now is: why is the left hand side a scalar and not a tensor?

It's impossible to debug from your partial listing - but here are a few pieces of advice. Start by stripping back the equation and feed terms in from the right hand side. E.g. start with the symm(grad(U))&&grad(U) term, and note that one is a symm tensor, the other isn't. Get that to work, then start adding the other terms. Look for examples of similar coding in the library applications - do a grep on symm(grad(U)) for example to find these. Read the error messages carefully and think about what it's telling you - I know there's a lot of text there ... but within the text often hides the solution.

Good luck.
Dear Tobermory,
Bundle thanks for your reply.
Actually I'm going to review the paper (link for the paper doi:10.1016/j.cnsns.2010.07.006

Author: T. Chinyoka at University of Cape Town ).
here solvent viscosity etaS(T) = Foam::exp( -C11*(T - To) / (C21 + T - To) )*etaS,which is basically a scalar, polymeric viscosity etaP(T) and relaxation Time Lambda(T) for the simplicity instead of Arrhenius law i"m going to use WLF to update parameters like viscosity and relaxation time.


(Foam::exp( -C11*(T - To) / (C21 + T - To) )*etaS*Foam::symm(fvc::grad(U)))&& Foam:fvc::grad(U)))
it is basically given in the paper like so (please have a look the temperature equation in paper)
but what i know that the value of etaS(T) is scalar and Foam::symm(fvc::grad(U)) tensor of rank 2 when i multiply it should be tensor again.but i don't why its scalar.
Also I'll try what you suggest me.

regards
Idrees
idrees khan is offline   Reply With Quote

Old   December 12, 2020, 12:01
Default
  #4
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 116
Rep Power: 4
Tobermory is on a distinguished road
Dear Idrees

I am running on the foundation version of OpenFOAM and so don't have direct access to viscoelasticFluidFoam, so I added the following coding to pisoFoam. As a result, I have had to hard code in some of the variables like tau etc. Regardless, this compiles fine and should show you how to modify your code. Note the way that I started testing syntax with variables tgradU, tmp1, tmp2 etc. This is a good, methodical debugging approach that is worth you copying.

Code:
	//define some dimensioned variables first
	dimensionedScalar DT("DT", dimensionSet(0, 2, -1, 0, 0, 0, 0), 0.002);
	dimensionedScalar rho("rho", dimensionSet(1, -3, 0, 0, 0, 0, 0), 1.0);
	dimensionedScalar Cp("Cp", dimensionSet(0, 2, -2, -1, 0, 0, 0), 1000);
	dimensionedScalar muS("muS", dimensionSet(1, -1, -1, 0, 0, 0, 0), 0.00001);
	dimensionedScalar muP("muP", dimensionSet(1, -1, -1, 0, 0, 0, 0), 0.00001);
	scalar gamma(1.0);

       //test syntax
	volTensorField tgradU = fvc::grad(U);
	volSymmTensorField tmp1 = symm(tgradU);
	volScalarField tmp2 = tmp1 && tgradU;
	volScalarField tmp3 = symm(tgradU) && tgradU;
	volScalarField tmp4 = symm(fvc::grad(U)) && fvc::grad(U);

        //define main quantities
	volSymmTensorField S = symm(fvc::grad(U));
	volSymmTensorField tau = muP*symm(fvc::grad(U));
	volScalarField Q = gamma*(tau && S) + muS*(S && fvc::grad(U));

       //attempt at T equation, using above variables
	fvScalarMatrix TEqn
	(
	    fvm::ddt(T)
	  + fvm::div(phi,T)
	  - fvm::laplacian(DT,T)
	  - (1.0/rho/Cp) * Q
	);

       //alternate T equation, without unnecessary additional variables (storage)
	fvScalarMatrix TEqn2
	(
	    fvm::ddt(T)
	  + fvm::div(phi,T)
	  - fvm::laplacian(DT,T)
	  - (1.0/rho/Cp) * (gamma*(muP*symm(fvc::grad(U)) && symm(fvc::grad(U))) + muS*(symm(fvc::grad(U)) && fvc::grad(U)))
	);
I hope this helps. Good luck.
idrees khan and Jun_93 like this.
Tobermory is offline   Reply With Quote

Old   December 14, 2020, 09:20
Thumbs up
  #5
New Member
 
raihan
Join Date: Feb 2015
Posts: 4
Rep Power: 7
rtyme06 is on a distinguished road
Tobermory you are awsome. Every advice you gave are pure gold. I hope young CFD people will learn a lot from this.
Tobermory likes this.
rtyme06 is offline   Reply With Quote

Old   December 14, 2020, 10:20
Default
  #6
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 116
Rep Power: 4
Tobermory is on a distinguished road
That's very kind - thank you; I am glad you appreciate my posts. This forum is a fantastic collection of people and their experiences, and I get out as much as I put in!
Tobermory is offline   Reply With Quote

Old   December 15, 2020, 11:19
Default
  #7
New Member
 
idrees khan
Join Date: Jun 2019
Posts: 27
Rep Power: 3
idrees khan is on a distinguished road
Quote:
Originally Posted by Tobermory View Post
Dear Idrees

I am running on the foundation version of OpenFOAM and so don't have direct access to viscoelasticFluidFoam, so I added the following coding to pisoFoam. As a result, I have had to hard code in some of the variables like tau etc. Regardless, this compiles fine and should show you how to modify your code. Note the way that I started testing syntax with variables tgradU, tmp1, tmp2 etc. This is a good, methodical debugging approach that is worth you copying.

Code:
    //define some dimensioned variables first
    dimensionedScalar DT("DT", dimensionSet(0, 2, -1, 0, 0, 0, 0), 0.002);
    dimensionedScalar rho("rho", dimensionSet(1, -3, 0, 0, 0, 0, 0), 1.0);
    dimensionedScalar Cp("Cp", dimensionSet(0, 2, -2, -1, 0, 0, 0), 1000);
    dimensionedScalar muS("muS", dimensionSet(1, -1, -1, 0, 0, 0, 0), 0.00001);
    dimensionedScalar muP("muP", dimensionSet(1, -1, -1, 0, 0, 0, 0), 0.00001);
    scalar gamma(1.0);

       //test syntax
    volTensorField tgradU = fvc::grad(U);
    volSymmTensorField tmp1 = symm(tgradU);
    volScalarField tmp2 = tmp1 && tgradU;
    volScalarField tmp3 = symm(tgradU) && tgradU;
    volScalarField tmp4 = symm(fvc::grad(U)) && fvc::grad(U);

        //define main quantities
    volSymmTensorField S = symm(fvc::grad(U));
    volSymmTensorField tau = muP*symm(fvc::grad(U));
    volScalarField Q = gamma*(tau && S) + muS*(S && fvc::grad(U));

       //attempt at T equation, using above variables
    fvScalarMatrix TEqn
    (
        fvm::ddt(T)
      + fvm::div(phi,T)
      - fvm::laplacian(DT,T)
      - (1.0/rho/Cp) * Q
    );

       //alternate T equation, without unnecessary additional variables (storage)
    fvScalarMatrix TEqn2
    (
        fvm::ddt(T)
      + fvm::div(phi,T)
      - fvm::laplacian(DT,T)
      - (1.0/rho/Cp) * (gamma*(muP*symm(fvc::grad(U)) && symm(fvc::grad(U))) + muS*(symm(fvc::grad(U)) && fvc::grad(U)))
    );
I hope this helps. Good luck.

Dear Tobermory
Thank so much i add your techniques and compile it with "wmake"
now i added some other terms in temperature equation according to paper ( screenshort is attached) and compile it it work's.
but when i run solver (name viscoelasticFluidFoamUser) it gives me an error(screenshort is attached.) please have a look the paper which i send it to you.
regards
idrees khan
Attached Images
File Type: jpg Screenshot from 2020-12-15 17-05-34.jpg (95.6 KB, 3 views)
File Type: png Screenshot from 2020-12-15 17-15-10.png (55.8 KB, 5 views)
idrees khan is offline   Reply With Quote

Old   December 15, 2020, 11:31
Default
  #8
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 116
Rep Power: 4
Tobermory is on a distinguished road
Good news Idrees - it looks like you are pretty close. The error message
Code:
Argument of trancendental function not dimensionless
is basically telling you that you are trying to calculate a trancendental function (i.e. a log, exp or trig function) with a parameter that is not dimensionless.

Looking at your snapshot of your code, you have
Code:
exp(-E/(R*T)
, so this is perhaps where the error is occurring. I would suggest checking that the units of E and R are correct. Good luck.
Tobermory is offline   Reply With Quote

Old   December 17, 2020, 11:16
Red face
  #9
New Member
 
idrees khan
Join Date: Jun 2019
Posts: 27
Rep Power: 3
idrees khan is on a distinguished road
Quote:
Originally Posted by Tobermory View Post
Good news Idrees - it looks like you are pretty close. The error message
Code:
Argument of trancendental function not dimensionless
is basically telling you that you are trying to calculate a trancendental function (i.e. a log, exp or trig function) with a parameter that is not dimensionless.

Looking at your snapshot of your code, you have
Code:
exp(-E/(R*T)
, so this is perhaps where the error is occurring. I would suggest checking that the units of E and R are correct. Good luck.

Dear Tobermory
Thank you

I check that and exactly the problem was in exp(-E/(R*T) means in dimensions.
but now when i run it gives me the problem which seems that still some terms are not
dimensionally correct.


regards
Idrees
idrees khan is offline   Reply With Quote

Old   December 17, 2020, 11:19
Red face
  #10
New Member
 
idrees khan
Join Date: Jun 2019
Posts: 27
Rep Power: 3
idrees khan is on a distinguished road
Sorry i did't attached the screenshort here is screenshort of the erorr.
Attached Images
File Type: png Screenshot from 2020-12-17 17-00-59.png (85.7 KB, 5 views)
idrees khan is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
fvOptions npatricia OpenFOAM 6 May 23, 2018 06:21
CFD by anderson, chp 10.... supersonic flow over flat plate varunjain89 Main CFD Forum 18 May 11, 2018 08:31
Warning message C4133 while compiling Arminius Fluent UDF and Scheme Programming 0 October 2, 2017 12:44
Missing math.h header Travis FLUENT 4 January 15, 2009 12:48
REAL GAS UDF brian FLUENT 6 September 11, 2006 09:23


All times are GMT -4. The time now is 19:36.