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

passive scalar

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 25, 2022, 09:37
Default passive scalar
  #1
Member
 
chen112p's Avatar
 
Junting Chen
Join Date: Feb 2016
Location: Ontario Canada
Posts: 38
Rep Power: 10
chen112p is on a distinguished road
Hello, I am wondering if anyone has help me on this issue.

I am trying to use scalarCodedSource to inject some particles in the domain and transport these particles in a transient simulation. The issue I'm experiencing is the selectionMode setting (cellSet) in scalarCodedSourceCoeffs does not allow me to only apply the source to selected cell set. When using mesh.C() or mesh.V(), the entire mesh got selected.

Code:
nox_01
{
    type            scalarTransport;
    libs            ("libsolverFunctionObjects.so");
    field           nox;
	D 				1e-5;
    log no;
    writeControl     writeTime; 
    fvOptions
    {
        noxSource
    {
    type            scalarCodedSource;
	name            noxSource;
    scalarCodedSourceCoeffs
    {
        selectionMode   cellSet;
		cellSet			nox;
        fields          (nox);
        name            noxSource;

        codeInclude
        #{
			#include "OFstream.H"
			#include "fvMesh.H"
			#include "fvMatrices.H"
			#include "DimensionedField.H"
			#include "fvm.H"
        #};

        codeCorrect
        #{
            //Pout<< "**codeCorrect**" << endl;
        #};

        codeAddSup
        #{
	        const Time& time = mesh().time();
            const scalarField& V = mesh_.V();
            const vectorField& C = mesh_.C();
            scalarField& heSource = eqn.source();
            Pout<<V.size();
            forAll(C, i)
            {
                heSource[i] += 10;
            };
        #};
        codeConstrain
        #{
            //Pout<< "**codeConstrain**" << endl;
        #};
    }
}
    }
}

Im also uploading my test case here if anyone wants to do a test run.
Attached Files
File Type: zip scalar_transport.zip (12.6 KB, 0 views)
chen112p is offline   Reply With Quote

Old   June 25, 2022, 11:42
Lightbulb
  #2
Member
 
chen112p's Avatar
 
Junting Chen
Join Date: Feb 2016
Location: Ontario Canada
Posts: 38
Rep Power: 10
chen112p is on a distinguished road
I guess the only way to select cells is still using cellZone like this...

Code:
const label zoneID = mesh_.cellZones().findZoneID("nox");
const cellZone& zone = mesh_.cellZones()[zoneID];
const cellZoneMesh& zoneMesh = zone.zoneMesh();
const labelList& cellsZone = zoneMesh[zoneID]; 
volScalarField Flg_
(	
IOobject
  (
	"Flg_",
        mesh_.time().timeName(),
	mesh_
  ),
mesh_,
dimensionedScalar("Flg_", dimensionSet(0,0,-1,0,0,0,0), 0.0)
);
forAll(cellsZone, cI)
{
	Flg_[cellsZone[cI]] += 1.0 * 10;
}

eqn += Flg_;

Last edited by chen112p; June 25, 2022 at 12:44.
chen112p 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
Peng Robinson Equation of state shock77 OpenFOAM Running, Solving & CFD 0 November 18, 2021 05:48
problem during mpi in server: expected Scalar, found on line 0 the word 'nan' muth OpenFOAM Running, Solving & CFD 3 August 27, 2018 05:18
Division by zero exception - loop over scalarField Pat84 OpenFOAM Programming & Development 6 February 18, 2017 06:57
Diverging solution in transonicMRFDyMFoam tsalter OpenFOAM Running, Solving & CFD 30 July 7, 2014 07:20
compressible flow in turbocharger riesotto OpenFOAM 50 May 26, 2014 02:47


All times are GMT -4. The time now is 11:41.