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 Community New Posts Updated Threads Search

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, 09:50
Angry Double Inner Product of Two Second Rank Tensors
  #1
Member
 
idrees khan
Join Date: Jun 2019
Posts: 36
Rep Power: 6
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, 13:06
Default
  #2
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 666
Rep Power: 14
Tobermory will become famous soon enough
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, 04:04
Default
  #3
Member
 
idrees khan
Join Date: Jun 2019
Posts: 36
Rep Power: 6
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, 11:01
Default
  #4
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 666
Rep Power: 14
Tobermory will become famous soon enough
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, 08:20
Thumbs up
  #5
New Member
 
raihan
Join Date: Feb 2015
Posts: 9
Rep Power: 11
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, 09:20
Default
  #6
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 666
Rep Power: 14
Tobermory will become famous soon enough
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, 10:19
Default
  #7
Member
 
idrees khan
Join Date: Jun 2019
Posts: 36
Rep Power: 6
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, 13 views)
File Type: png Screenshot from 2020-12-15 17-15-10.png (55.8 KB, 17 views)
idrees khan is offline   Reply With Quote

Old   December 15, 2020, 10:31
Default
  #8
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 666
Rep Power: 14
Tobermory will become famous soon enough
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, 10:16
Red face
  #9
Member
 
idrees khan
Join Date: Jun 2019
Posts: 36
Rep Power: 6
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, 10:19
Red face
  #10
Member
 
idrees khan
Join Date: Jun 2019
Posts: 36
Rep Power: 6
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, 12 views)
idrees khan is offline   Reply With Quote

Old   February 23, 2021, 02:59
Default How to write the the dot product of gradU and gradviscosity(T) in openFoam
  #11
Member
 
idrees khan
Join Date: Jun 2019
Posts: 36
Rep Power: 6
idrees khan is on a distinguished road
Dear Tobermory,
kindly if you could guide me about the last term (have a look the screenshot please)

Code:
(delU.delmuS(T))/rho_
where muS is solvent viscosity just like etaP(T)(polymer viscosity ) define by



Code:
volScalarField muS   = Foam::exp( -C11_*(T - To_) / (C21_ + T - To_) )*etaS_;
how to write it


should i write it like

Code:
 fvc:: laplacian(muS /rho_, U, "laplacian(muS ,U)")
regards
idrees khan
Attached Images
File Type: png Habla Paper(Momentum equation).png (61.5 KB, 14 views)
idrees khan is offline   Reply With Quote

Old   February 23, 2021, 04:15
Default
  #12
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 666
Rep Power: 14
Tobermory will become famous soon enough
Which "last" term are you trying to write, buddy? The Laplacian
\nabla \cdot (\eta \nabla U) or the "last" term in the equation \nabla U \cdot \nabla\eta?

From your post:
Code:
 fvc:: laplacian(muS /rho_, U, "laplacian(muS ,U)")
it looks like you are writing the Laplacian, in explicit (fvc) formulation. If it's the last term you want, then you'll need something like
Code:
fvc::grad(U) & fvc::grad(mu)
Whichever, try it and see what the compiler says. Best way to learn, my friend. Good luck.
Tobermory is offline   Reply With Quote

Old   February 23, 2021, 05:13
Default
  #13
Member
 
idrees khan
Join Date: Jun 2019
Posts: 36
Rep Power: 6
idrees khan is on a distinguished road
Dear Tobermory,
Thank you,

I was talking about this
\nabla U \cdot \nabla\eta?

Code:
fvc::grad(U) & fvc::grad(mu)
where
Code:
volScalarField muS   = Foam::exp( -C11_*(T - To_) / (C21_ + T - To_) )*etaS_;
but my question if i want to write it implicitly/explicitly how i'll write it?
we know with fvm,sp,suSp(depends upon the sign) respectively will write implicitly and fvc explicitly,

if I write it like
Code:
fvc::grad(U) & fvc::grad(mu)
it will write explicitly.
kindly correct me if I'm wrong.


regards
idrees khan
idrees khan is offline   Reply With Quote

Reply


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 05:21
CFD by anderson, chp 10.... supersonic flow over flat plate varunjain89 Main CFD Forum 18 May 11, 2018 07:31
Warning message C4133 while compiling Arminius Fluent UDF and Scheme Programming 0 October 2, 2017 11:44
Missing math.h header Travis FLUENT 4 January 15, 2009 11:48
REAL GAS UDF brian FLUENT 6 September 11, 2006 08:23


All times are GMT -4. The time now is 15:14.