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

Counterpart representation of fvc::grad ???

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 5, 2021, 19:16
Unhappy Counterpart representation of fvc::grad ???
  #1
Member
 
MNM
Join Date: Aug 2017
Posts: 69
Rep Power: 9
SHUBHAM9595 is on a distinguished road
Dear Foamers,

I'm trying to solve a Equation for a volVectorField (H) such that

\nabla \cdot H = - \nabla \cdot Z

where, Z is another volVectorField and is of less concern.

Here, apparently the H field is irrotational and thus should also satisfy \nabla \times H = 0.

To justify the above condition, the H is represented in terms of gradient of scalar potential H = \nabla \phi (as the curl of gradient of scalar function is always zero )

Now, after substitution, the initial equation can be rewritten as \nabla \cdot H = - \nabla \cdot Z  \Rightarrow \nabla^{2}\phi = \nabla \cdot Z which then can be solved by constructing a scalar matrix as shown below

Code:
 tmp<fvScalarMatrix> tphiHEqn
(
 fvm::laplacian(phiH)  == -fvc::div(Z) 
);
where phiH (scalar potential) is a volScalarField.
Now, it is very easy to represent/reconstruct the H in terms of this scalar potential using
Code:
volVectorField H = fvc::grad(phiH);
But I need to initialize phiH in terms of H, hence the question is how can we write phiH (volScalarField) in terms of H (volVectorField)??

Field dimensions for both field are as mentioned below
H = [0 -1 0 0 0 1 0];//A/m
phiH = [0 0 0 0 0 1 0];//A

I've already tried some workarounds which are mentioned below, but unfortunately they are unable to resolve the issue .

1.
Code:
phiH = fvc::surfaceIntegrate(fvc::flux(H));
here
flux will convert the volVectorField to surfScalar &
surfaceIntegrate will convert surfScalarField to volScalarField
However, the dimensions of RHS appear to be A.m2 whereas LHS have dim of A.


2.
Code:
phiH = fvc::domainIntegrate(Foam::mag(H));
domainIntegrate will multiply H by its grid volume....also leads to the incompatible dimension

3.
Code:
phiH = (fvc::average((fvc::flux(H))))
average will convert surfScalarField to volScalarField....also leads to the incompatible dimension



All suggestions/comments are welcome. Thanks in advance !!!
SHUBHAM9595 is offline   Reply With Quote

Old   November 7, 2021, 14:11
Default
  #2
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 736
Rep Power: 14
Tobermory will become famous soon enough
My advice is take a step back and think again about what you are trying to do. You effectively want to solve \nabla \phi  = H for \phi. Now, this equation is saying that the gradient of \phi at any point is determined by the local value of H ... but this means that you cannot calculate the value of \phi at that point just from the local gradient ... you need to find a point where you know the value of \phi (from a boundary condition), and then do a line integral from there to the point you are interested in. So, do you see now why you are struggling to find an analytical solution to this, based on the local values of H?

Or, a TLDR answer is - you can't do it that way; instead, why not just get OpenFOAM to solve the equation \nabla \phi  = H with appropriate BCs, as a precursor step? Good luck!
Tobermory is offline   Reply With Quote

Old   November 8, 2021, 15:01
Default
  #3
Member
 
MNM
Join Date: Aug 2017
Posts: 69
Rep Power: 9
SHUBHAM9595 is on a distinguished road
Hi Tobermory, thanks for your comment. Perhaps I was not able to mention the stuff in better way. As there is some misunderstanding which leads to the following part of your comment

Quote:
You effectively want to solve \nabla \phi = H.
As mentioned earlier, we want to solve the \nabla^{2} \phi = \nabla\cdot M to obtain \phi.

Later on using this scalar potential, we compute the H as H = \nabla \phi

Can you please elaborate the following statement ?
Quote:
why not just get OpenFOAM to solve the equation \nabla \phi  = H with appropriate BCs, as a precursor step?
SHUBHAM9595 is offline   Reply With Quote

Old   November 9, 2021, 05:32
Default
  #4
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 736
Rep Power: 14
Tobermory will become famous soon enough
No, no - I do understand what you mean ... Apologies if my comment:
Quote:
You effectively want to solve \nabla \phi  = H for \phi
was unclear. Recall that you asked earlier:
Quote:
But I need to initialize phiH in terms of H, hence the question is how can we write phiH (volScalarField) in terms of H (volVectorField)??
But \phi and H are linked by \nabla \phi  = H, and so if you want to express \phi in terms of H, then you have to solve the expression \nabla \phi  = H. That was the point of my initial paragraph - to get you to think about the fundamental of what you are trying to do, and why there is not a simple analytical answer to it.

For the second part, how to solve \nabla \phi  = H, it occurred to me that you could just set this up as an equation for OpenFOAM to solve, eg something like
Code:
 tmp<fvScalarMatrix> tphiBoundaryEqn
(
 fvm::grad(phiH)  == H 
);
supply the appropriate boundary conditions for H and let the code do the line integration to solve for phi. Just a suggestion - I haven't thought it all the way through. Let us know how you get on & good luck!
Tobermory is offline   Reply With Quote

Reply

Tags
gradient, volscalarfield, volvectorfield


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
Mathematical representation of fixedDisplacementZeroShear boundary condition Sargam05 OpenFOAM 14 January 11, 2022 07:55
[General] representation plugin cplusplus ParaView 0 January 20, 2017 05:19
2D Representation of surface values in 3D mrurq EnSight 6 February 25, 2016 06:01
[General] Representation "Surface" is displayed correctly, but Representation "Outline" is not macfly ParaView 4 March 22, 2014 10:54
OpenFOAM representation for a partial equation jimbean OpenFOAM Running, Solving & CFD 0 October 24, 2013 14:30


All times are GMT -4. The time now is 06:44.