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

Fields and mesh access from lagrangian submodel

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 8, 2020, 09:47
Default Fields and mesh access from lagrangian submodel
  #1
New Member
 
Örjan Fjällborg
Join Date: Aug 2019
Posts: 4
Rep Power: 7
klorfj is on a distinguished road
Hi everyone!

I have big trouble with getting access to fields, for example the mass fraction Y species fields, inside a lagrangian submodel:

-
Code:
-> FOAM FATAL ERROR:
Sum of mass fractions is zero for species 4(N2 O2 CO2 H2O)
I try to access the mesh and load a thermodynamic package, which should load the Y fields in a multiComponentMixture, with the following code:

Code:
// -------------------------------------------------------------------
//  Name:			calculate
//- Update surface reactions
//  Parameters:
//  dt				(I) - timestep
//  Re				(I) - Surface Reynolds number 
// (see \intermediate\parcels\Templates\ReactingHeterogeneousParcel.C)
//  nu				(I) - Surface nu number, mus/rhos 
// (see \intermediate\parcels\Templates\ReactingHeterogeneousParcel.C)
//  celli			(I) - Cell index
//  d				(I) - Diameter [m]
//  T				(I) - Temperature [K]
//  Tc				(I) - Continuous phase Temperature [K]
//  pc				(I) - Continuous phase pressure [Pa]
//  rhoc			(I) - Continuous phase density [kg/m3]
//  Uc				(I) - Continuous phase velocity [m/s]
//  mass			(I) - Mass [kg]
//  Ysolid			(I) - Mass fract. of remaining components in bed
//  F			  (I/O) - Cohesion factor 0 - 1	(summarized progress 
//						  of all reactions)
//  N				(I) - Flux of species emitted from particle
//  NCpW		  (I/?) - Sum Ni*Cpi*Wi of emission species, not used
//  dMassSolid	  (I/O) - Solid-phase mass transfer [kg]
//						  (Fe3O4, Fe2O3, CaCO3, CaO, Dolomite, MgO, 
//						  H2O)
//  dMassSRCarrier(I/O) - Carrier-phase mass transfer [kg]
//						  (O2, H2O, CO2, N2)
//  Returns:		Heat of reaction [J]
// -------------------------------------------------------------------
template<class CloudType>
Foam::scalar Foam::BEDSIMheterogeneousRate<CloudType>::calculate
(
    const scalar dt,
    const scalar Re,
    const scalar nu,
    const label celli,
    const scalar d,
    const scalar T,
    const scalar Tc,
    const scalar pc,
    const scalar rhoc,
    const vector Uc,    //New Uc local gas velocity vector
    const scalar mass,
    const scalarField& YSolid,
    scalarField& F,
    const scalar N,
    scalar& NCpW,
    scalarField& dMassSolid,
    scalarField& dMassSRCarrier
) const
{
	const objectRegistry& db = this->owner().db();
	const volVectorField& U = db.lookupObject<volVectorField>("U");
	const fvMesh& mesh = U.mesh();

	autoPtr<rhoReactionThermo> pMix(rhoReactionThermo::New(mesh));
	rhoReactionThermo& mix = pMix();
	SLGThermo slgThermo(mesh, mix);

...

}
Using the code below which works everywhere else except in the lagrangian model gives a compilation error

Code:
const objectRegistry& db = db();
const volVectorField& U = db().lookupObject<volVectorField>("U");
Code:
lnInclude/BEDSIMheterogeneousRate.C:549:60: error: expected primary-expression before ‘>’ token
  const volVectorField& U = db().lookupObject<volVectorField>("U");
I hope someone can help me!

/Örjan
klorfj is offline   Reply With Quote

Old   January 10, 2020, 06:36
Default
  #2
Member
 
Join Date: Sep 2010
Location: Leipzig, Germany
Posts: 96
Rep Power: 16
oswald is on a distinguished road
You only have direct access to fields that are defined the cloud, if you are lucky. You can try with something like
Code:
this->owner().Uc()
for the carrier velocity.


Check your relevant ...Cloud.H in lagrangian/intermediate/clouds/Templates/...Cloud, there you will find a section with Member Functions giving you access to some fields.
oswald is offline   Reply With Quote

Old   January 13, 2020, 02:48
Default
  #3
New Member
 
Örjan Fjällborg
Join Date: Aug 2019
Posts: 4
Rep Power: 7
klorfj is on a distinguished road
Thanks Oswald!

I found that I actually can access the Y fields via the mesh in the lagrangian model:


const fvMesh& mesh = this->owner().T().mesh();
const volScalarField& n2 = mesh.lookupObject<volScalarField>("N2");
const volScalarField& o2 = mesh.lookupObject<volScalarField>("O2");
const volScalarField& co2 = mesh.lookupObject<volScalarField>("CO2");
const volScalarField& h2o = mesh.lookupObject<volScalarField>("H2O");
const volVectorField& U = mesh.lookupObject<volVectorField>("U");

autoPtr<rhoReactionThermo> pMix(rhoReactionThermo::New(mesh));


But there is still something that is different with the mesh, because of the error when creating the thermodynamic package.

I think that when the termodynamic package is created, some problem with the mesh forces basicMultiComponentMixture.C to initialize the species Y_ fields to zero!

Can the mesh be checked for consistency to find out what's the problem?

Best regards!
/Örjan
klorfj 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
[snappyHexMesh] SnappyHexMesh/splitMeshRegion : region1 in zone "-1" GuiMagyar OpenFOAM Meshing & Mesh Conversion 3 August 4, 2023 13:38
foam-extend-4.1 release hjasak OpenFOAM Announcements from Other Sources 19 July 16, 2021 06:02
decomposePar problem: Cell 0contains face labels out of range vaina74 OpenFOAM Pre-Processing 37 July 20, 2020 06:38
[mesh manipulation] Importing Multiple Meshes thomasnwalshiii OpenFOAM Meshing & Mesh Conversion 18 December 19, 2015 19:57
an odd(at least for me!) reconstructPar error on a field immortality OpenFOAM Running, Solving & CFD 3 June 3, 2013 23:36


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