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

 November 5, 2021, 18:16 Counterpart representation of fvc::grad ??? #1 Member   MNM Join Date: Aug 2017 Posts: 69 Rep Power: 8 Dear Foamers, I'm trying to solve a Equation for a volVectorField (H) such that where, Z is another volVectorField and is of less concern. Here, apparently the H field is irrotational and thus should also satisfy . To justify the above condition, the H is represented in terms of gradient of scalar potential (as the curl of gradient of scalar function is always zero ) Now, after substitution, the initial equation can be rewritten as which then can be solved by constructing a scalar matrix as shown below Code:  tmp 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 !!!

 November 7, 2021, 13:11 #2 Senior Member   Join Date: Apr 2020 Location: UK Posts: 705 Rep Power: 14 My advice is take a step back and think again about what you are trying to do. You effectively want to solve for . Now, this equation is saying that the gradient of at any point is determined by the local value of ... but this means that you cannot calculate the value of at that point just from the local gradient ... you need to find a point where you know the value of (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 ? Or, a TLDR answer is - you can't do it that way; instead, why not just get OpenFOAM to solve the equation with appropriate BCs, as a precursor step? Good luck!

November 8, 2021, 14:01
#3
Member

MNM
Join Date: Aug 2017
Posts: 69
Rep Power: 8
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 .
As mentioned earlier, we want to solve the to obtain .

Later on using this scalar potential, we compute the H as

Can you please elaborate the following statement ?
Quote:
 why not just get OpenFOAM to solve the equation with appropriate BCs, as a precursor step?

November 9, 2021, 04:32
#4
Senior Member

Join Date: Apr 2020
Location: UK
Posts: 705
Rep Power: 14
No, no - I do understand what you mean ... Apologies if my comment:
Quote:
 You effectively want to solve for
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 and are linked by , and so if you want to express in terms of , then you have to solve the expression . 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 , 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
(
);
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!