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

writing own laplacian scheme with boundary conditions

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By riddim
  • 1 Post By chriss85

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 25, 2015, 19:09
Default writing own laplacian scheme with boundary conditions
  #1
New Member
 
Jan
Join Date: Oct 2014
Posts: 8
Rep Power: 11
riddim is on a distinguished road
Hey there,

I think I found out that I "simply" need to write my own laplacian scheme with boundary conditions ....

http://www.cfd-online.com/Forums/ope...te-scheme.html <<< this threat was very useful to me but I have to admit I'm still a little bit stuck at the start ...
...maybe you could give me some hints how to implement this ...

My aim is to simply solve

Laplacian(A) == -µ_r*µ_0*J

µ_0 is const. and µ_r can be different from cell to cell

A * n == 0
and (A x curl(A)) * n == 0

where n is the surface normal vector.

do I have to implement these boundary conditions inside the laplacian scheme or is it possible to use the standard laplacian scheme and implement these conditions inside my solver ...?
How do i access the surface normal vector?

Where do you think I should start ...?
Kummi likes this.
riddim is offline   Reply With Quote

Old   July 27, 2015, 05:44
Default
  #2
Senior Member
 
Join Date: Oct 2013
Posts: 397
Rep Power: 18
chriss85 will become famous soon enough
If you have a variable magnetic permeability this equation is incorrect because you are neglecting a term. Please see the derivation of the formula as I don't recall it from my head. Alternatively, you can use another formulation for calculating a magnetic field. See for example this paper for the T-T0-Phi formulation: http://ieeexplore.ieee.org/xpl/login...mber%3D4787389
chriss85 is offline   Reply With Quote

Old   July 28, 2015, 14:14
Default
  #3
New Member
 
Jan
Join Date: Oct 2014
Posts: 8
Rep Power: 11
riddim is on a distinguished road
thank you very much for your quick reply and sorry for my slow one ...

I'm very aware i'm neglecting a term here...

I already found a couple of formulations e.g. in
http://ieeexplore.ieee.org/xpl/artic...eld=Search_All
or
http://ieeexplore.ieee.org/xpl/artic...eld=Search_All

my Problem is that I didn't see how I can implement two/three equations to be solved simultaniously ...

e.g. in the first paper they suggest to solve

Laplacian(A) == -µ_r*µ_0*J

with

B_t1 == dA_n/dt2 - dA_t2/dn

(t1 = tangential component of cell 1, t2 = tan comp. of cell 2 and n = normal vector of the border)


I'm now a little bit confused where it is possible to implement this relation ...
My idea is to "correct" the tangential/normal component of the B_Field of the surrounding cells temporarily before solving the Laplacian term. Is such a temporary correction possible in my solver or do i have to write a new laplacian scheme for my purposes ...? (or do i have to implement a new surface-normal-correction-scheme ...?)
riddim is offline   Reply With Quote

Old   July 28, 2015, 15:22
Default
  #4
New Member
 
Jan
Join Date: Oct 2014
Posts: 8
Rep Power: 11
riddim is on a distinguished road
ok and a little bit tricky might be that i need to correct the vectors of the A field and therefore would neet a curl⁻1 operator since B = curl(A) ...

i suppose it is possible to access the neighbour cell vectors in the laplacian scheme ... (it must ... otherwise you couldn't calculate the laplacian or the divergence or whatsoever ...) is there a list of commands that are possible somewhere ...? i didn't find it yet ..
riddim is offline   Reply With Quote

Old   July 29, 2015, 10:29
Default
  #5
Senior Member
 
Daniel Witte
Join Date: Nov 2011
Posts: 148
Rep Power: 14
danny123 is on a distinguished road
Hello,

I am looking into that laplacian too, see

http://www.cfd-online.com/Forums/ope...auf-p_rgh.html

There is already an explicit laplacian of the form Laplacian(A) implemeted, it seems to me. Look into gaussLaplacianScheme.C line 134.


The implicit form is only of the type:

Code:
fvm::laplacian(gamma, vf)
It calls fvmLaplacianUncorrected, where the matrix seems to be built. At this point the source seems to be empty (or at least should be).

Back in fvmLaplacian,
Code:
mesh.V()*fvc::div(tfaceFluxCorrection())().internalField()
to the source term.

To be honest, I did not understand the entire code, but
Code:
deltaCoeffs
seems to be the gradient matrix coefficient.

In order to build
Code:
fvm::laplacian(vf)
I think you can copy the code of
Code:
fvm::laplacian(gamma, vf)
and remove everything related to gamma. Otherwise, an easy way is just to define a surfaceScalarfield gamma, all entries being 1 and use the laplacian as it is implemented.

If you could look into my problem, while you are looking into yours, I would appreciate your input. I am kind off stuck.

Regards,

Daniel
danny123 is offline   Reply With Quote

Old   July 29, 2015, 10:39
Default
  #6
Senior Member
 
Join Date: Oct 2013
Posts: 397
Rep Power: 18
chriss85 will become famous soon enough
You can use fvc::curl(A), but that is an explicit formulation. As for solving equations simultaneously, you have the choice of using a segregated approach (that is a loop, in which both equations are solved separately until convergence) or a coupled approach, in which both equations are discretized in such a way that only one linear system remains to be solved. However, I'm not sure how the coupled approach would be implemented in detail, openfoam-extend might be needed for that.
Kummi likes this.
chriss85 is offline   Reply With Quote

Old   July 30, 2015, 12:40
Default
  #7
New Member
 
Jan
Join Date: Oct 2014
Posts: 8
Rep Power: 11
riddim is on a distinguished road
@chriss85 hmmm - okay - the coupled approach would be pretty cool of course but I would go with the sequential approach at first ... a correct working slower solver is better than a solver not working at all

the segregated approach is like in the "compressible/rhoSimpleFoam" where 3 different equations are defined and one after another is done .solve() ..?

e.g. the UEqn.H is pretty simple ... (OF extend 3.0)
Code:
    tmp<fvVectorMatrix> UEqn
    (
        fvm::div(phi, U)
      + turbulence->divDevRhoReff(U)
    );

    UEqn().relax();

    eqnResidual = solve
    (
        UEqn() == -fvc::grad(p)
    ).initialResidual();

    maxResidual = max(eqnResidual, maxResidual);
is this .relax() important?
the residuals are optional and not necessary for any solver - are they ...?


Is it correct that the functions i can use in my solver are pretty much the ones defined in src/finiteVolume/finiteVolume(/fvc)
where I have Curl, Div, Laplacian, Grad, SnGrad, ...

Within the snGradSchemes I found the expression
Code:
    const unallocLabelList& owner = mesh.owner();
    const unallocLabelList& neighbour = mesh.neighbour();

    forAll(owner, faceI)
    {
        ssf[faceI] =
            deltaCoeffs[faceI]*(vf[neighbour[faceI]] - vf[owner[faceI]]);
    }
this is how I could address neigbour-field-values within my solver/Laplacian-Scheme ...?

faceI is an iteration parameter used by the solvers ...?
riddim is offline   Reply With Quote

Old   July 30, 2015, 13:21
Default
  #8
New Member
 
Jan
Join Date: Oct 2014
Posts: 8
Rep Power: 11
riddim is on a distinguished road
ok sorry for not just testing it ...

the Laplacian Scheme seems to iterate with "PatchI" and mesh.owner() + mesh.neighbour() are valid expressions ... however I don't see where I can access the actual field values ... I think I have to read a little bit more and think about which functions i really do need before being able to ask qualified questions ...
riddim is offline   Reply With Quote

Old   July 31, 2015, 05:30
Default
  #9
Senior Member
 
Daniel Witte
Join Date: Nov 2011
Posts: 148
Rep Power: 14
danny123 is on a distinguished road
No, I think you are somewhat off-track...

The iteration parameter is vf. So, the code lines you found correspond to an explicit gradient, since the multiplication is done by those code lines.

To the other questions: relax means that your equation to be solved is relaxed. You can set relax parameters in fvSolutions. If you do not, there is no relaxation.

initialResidual() is one of the solverperformance parameters. This statement iterates the equation to find a suitable U to fit UEqn = - fvc::grad(p). The RHS is explicit, so added to the source term of the linear equation system. While doing this the initial residual (residual of your guess value) is written into a scalar eqnResidual (To be defined somewhere else). In a system of several fields to be iterated separatly (segregated approach), you need a check that at start of each iteration, where your residual is at that point. Only if all initial residuals are below a tolerance value to be defined by you, the whole system of equations has converged.

Regards,

Daniel
danny123 is offline   Reply With Quote

Old   July 31, 2015, 05:37
Default
  #10
New Member
 
Jan
Join Date: Oct 2014
Posts: 8
Rep Power: 11
riddim is on a distinguished road
...ok yes vf is the iteration parameter that takes care of every cell ... i thought faceI would be an "inner" iteration process because every face has to be dealt with in every large iteration step ...

thx sorry now i will be busy for 3 days so i'll come back here after that

have a nice weekend
riddim 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
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field lakeat OpenFOAM Community Contributions 58 December 23, 2021 02:36
Problem with SIMPLEC-like finite volume channel flow boundary conditions ghobold Main CFD Forum 3 June 15, 2015 11:14
Waterwheel shaped turbine inside a pipe simulation problem mshahed91 CFX 3 January 10, 2015 11:19
Setting rotating frame of referece. RPFigueiredo CFX 3 October 28, 2014 04:59
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Meshing & Mesh Conversion 2 July 15, 2005 04:15


All times are GMT -4. The time now is 16:18.