|
[Sponsors] |
February 21, 2021, 18:37 |
Compact BC using patchInternalField
|
#1 |
New Member
Giovanni Luddeni
Join Date: Jan 2021
Posts: 14
Rep Power: 5 |
Hi,
developing a set of BC for a plasma simulation (2 fluids model with drift-diffusion) I'm wasting quite a lot of time defining all the fields and constants for each test and I'm looking for a way to speed up the process, if possible. I'm using the codedMixed type (openfoam 6), since in general I have to implement Robin BC. Here an example of a simple and working one. Code:
ns { code #{ // CONST LOOKUP const scalar& pi = constant::mathematical::pi; const dictionary& physicalProperties = db().lookupObject<IOdictionary>("physicalProperties"); scalar& Kb = dimensionedScalar(physicalProperties.lookup("Kb")).value(); scalar& M_ion = dimensionedScalar(physicalProperties.lookup("M_ion")).value(); scalar& T0 = dimensionedScalar(physicalProperties.lookup("T0")).value(); // FILEDS LOOKUP const volScalarField& Ds_ = db().lookupObject<volScalarField>("Ds"); const volScalarField& ns_ = db().lookupObject<volScalarField>("ns"); // DECLARATIONS scalarField gradField = scalarField(patch().size()); scalar v_th, ns, Ds; // LOOP const labelUList& cell = patch().faceCells(); forAll(cell, faceID){ v_th = sqrt(8/pi*Kb*T0/M_ion); ns = ns_[cell[faceID]]; Ds = Ds_[cell[faceID]]; gradField[faceID] = -0.5*v_th*ns/Ds; } refGrad() = (gradField); #}; } I usually divide the code in this way: - lookup of constants, - lookup of fields, - definition of in-loop variables and loop on all faces. What I'm trying to understand is if it is possible to avoid the loop, looking up directly the internal fields next to the boundary patch and performing the calculations field-wise. I was looking into the function patchInternalField from the fvPatch reference, which states: Return given internal field next to patch as patch field.. This seems exactly what I need, but I can't find any example and I find challenging to understand from the reference how to implement it. Any idea? Does this whole thing make sense or should I give up and stick to the loops? I accept any suggestion! |
|
Tags |
codedboundarycondition, codedmixed |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to make a compact heatsink model in FloTHERM XT? | hank0301 | FloEFD, FloWorks & FloTHERM | 2 | April 16, 2017 19:26 |
Compact finite difference | arunsmec | Main CFD Forum | 5 | August 18, 2013 06:20 |
Bug in patchInternalField() | psosnows | OpenFOAM Bugs | 5 | October 12, 2011 05:22 |
Compact finite difference schemes | Tom Clay | Main CFD Forum | 4 | November 28, 2002 09:59 |
COMPACT CFD users? | Robert Kim | Main CFD Forum | 1 | January 13, 1999 13:20 |