Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
99a1eee0
Commit
99a1eee0
authored
Nov 30, 2016
by
Andrew Heather
Browse files
ENH: Lagrangian - added functions to add particle data as fields on an object registry
parent
271c8c8c
Changes
24
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/fields/cloud/cloud.C
View file @
99a1eee0
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation |
Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -36,7 +36,6 @@ namespace Foam
word
cloud
::
defaultName
(
"defaultCloud"
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam
::
cloud
::
cloud
(
const
objectRegistry
&
obr
,
const
word
&
cloudName
)
...
...
@@ -70,4 +69,10 @@ void Foam::cloud::autoMap(const mapPolyMesh&)
}
void
Foam
::
cloud
::
writeObjects
(
objectRegistry
&
obr
)
const
{
NotImplemented
;
}
// ************************************************************************* //
src/OpenFOAM/fields/cloud/cloud.H
View file @
99a1eee0
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation |
Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -36,6 +36,7 @@ SourceFiles
#define cloud_H
#include "objectRegistry.H"
#include "IOField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
@@ -92,6 +93,24 @@ public:
//- Remap the cells of particles corresponding to the
// mesh topology change
virtual
void
autoMap
(
const
mapPolyMesh
&
);
// I-O
//- Read particle fields from objects in the obr registry
//virtual void readObjects(objectRegistry& obr);
//- Write particle fields as objects into the obr registry
virtual
void
writeObjects
(
objectRegistry
&
obr
)
const
;
//- Helper to construct IOField on a supplied object registry
template
<
class
Type
>
static
IOField
<
Type
>&
createIOField
(
const
word
&
fieldName
,
const
label
nParticle
,
objectRegistry
&
obr
);
};
...
...
@@ -101,6 +120,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "cloudTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
src/OpenFOAM/fields/cloud/cloudTemplates.C
0 → 100644
View file @
99a1eee0
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template
<
class
Type
>
Foam
::
IOField
<
Type
>&
Foam
::
cloud
::
createIOField
(
const
word
&
fieldName
,
const
label
nParticle
,
objectRegistry
&
obr
)
{
IOField
<
Type
>*
fieldPtr
(
new
IOField
<
Type
>
(
IOobject
(
fieldName
,
obr
.
time
().
timeName
(),
obr
,
IOobject
::
NO_READ
,
IOobject
::
AUTO_WRITE
),
nParticle
)
);
fieldPtr
->
store
();
return
*
fieldPtr
;
}
// ************************************************************************* //
src/lagrangian/basic/particle/particle.H
View file @
99a1eee0
...
...
@@ -574,6 +574,10 @@ public:
template
<
class
CloudType
>
static
void
writeFields
(
const
CloudType
&
c
);
//- Write particle fields as objects into the obr registry
template
<
class
CloudType
>
static
void
writeObjects
(
const
CloudType
&
c
,
objectRegistry
&
obr
);
//- Write the particle position and cell
void
writePosition
(
Ostream
&
)
const
;
...
...
src/lagrangian/basic/particle/particleTemplates.C
View file @
99a1eee0
...
...
@@ -162,7 +162,7 @@ void Foam::particle::writeFields(const CloudType& c)
IOPosition
<
CloudType
>
ioP
(
c
);
ioP
.
write
();
label
np
=
c
.
size
();
label
np
=
c
.
size
();
IOField
<
label
>
origProc
(
...
...
@@ -184,6 +184,29 @@ void Foam::particle::writeFields(const CloudType& c)
}
template
<
class
CloudType
>
void
Foam
::
particle
::
writeObjects
(
const
CloudType
&
c
,
objectRegistry
&
obr
)
{
label
np
=
c
.
size
();
IOField
<
vector
>&
position
(
cloud
::
createIOField
<
vector
>
(
"position"
,
np
,
obr
)
);
IOField
<
label
>&
origProc
(
cloud
::
createIOField
<
label
>
(
"origProc"
,
np
,
obr
));
IOField
<
label
>&
origId
(
cloud
::
createIOField
<
label
>
(
"origId"
,
np
,
obr
));
label
i
=
0
;
forAllConstIter
(
typename
CloudType
,
c
,
iter
)
{
position
[
i
]
=
iter
().
position_
;
origProc
[
i
]
=
iter
().
origProc_
;
origId
[
i
]
=
iter
().
origId_
;
i
++
;
}
}
template
<
class
TrackData
>
Foam
::
label
Foam
::
particle
::
track
(
const
vector
&
endPosition
,
TrackData
&
td
)
{
...
...
src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C
View file @
99a1eee0
...
...
@@ -895,4 +895,11 @@ void Foam::KinematicCloud<CloudType>::info()
}
template
<
class
CloudType
>
void
Foam
::
KinematicCloud
<
CloudType
>::
writeObjects
(
objectRegistry
&
obr
)
const
{
parcelType
::
writeObjects
(
*
this
,
obr
);
}
// ************************************************************************* //
src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H
View file @
99a1eee0
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation |
Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -612,6 +612,9 @@ public:
//- Print cloud information
void
info
();
//- Write particle fields as objects into the obr registry
virtual
void
writeObjects
(
objectRegistry
&
obr
)
const
;
};
...
...
src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C
View file @
99a1eee0
...
...
@@ -362,4 +362,11 @@ void Foam::ReactingCloud<CloudType>::writeFields() const
}
template
<
class
CloudType
>
void
Foam
::
ReactingCloud
<
CloudType
>::
writeObjects
(
objectRegistry
&
obr
)
const
{
CloudType
::
particleType
::
writeObjects
(
*
this
,
this
->
composition
(),
obr
);
}
// ************************************************************************* //
src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H
View file @
99a1eee0
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation |
Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -313,6 +313,9 @@ public:
//- Write the field data for the cloud
virtual
void
writeFields
()
const
;
//- Write particle fields as objects into the obr registry
virtual
void
writeObjects
(
objectRegistry
&
obr
)
const
;
};
...
...
src/lagrangian/intermediate/clouds/baseClasses/kinematicCloud/kinematicCloud.H
View file @
99a1eee0
...
...
@@ -63,11 +63,15 @@ public:
//- Runtime type information
TypeName
(
"kinematicCloud"
);
// Constructors
//- Null constructor
kinematicCloud
();
//- Destructor
virtual
~
kinematicCloud
();
// Member functions
...
...
@@ -92,26 +96,22 @@ public:
virtual
scalar
Dmax
()
const
=
0
;
// Fields
// Fields
//- Volume swept rate of parcels per cell
virtual
const
tmp
<
volScalarField
>
vDotSweep
()
const
=
0
;
//- Volume swept rate of parcels per cell
virtual
const
tmp
<
volScalarField
>
vDotSweep
()
const
=
0
;
//- Return the particle volume fraction field
// Note: for particles belonging to this cloud only
virtual
const
tmp
<
volScalarField
>
theta
()
const
=
0
;
//- Return the particle volume fraction field
// Note: for particles belonging to this cloud only
virtual
const
tmp
<
volScalarField
>
theta
()
const
=
0
;
//- Return the particle mass fraction field
// Note: for particles belonging to this cloud only
virtual
const
tmp
<
volScalarField
>
alpha
()
const
=
0
;
//- Return the particle mass fraction field
// Note: for particles belonging to this cloud only
virtual
const
tmp
<
volScalarField
>
alpha
()
const
=
0
;
//- Return the particle effective density field
// Note: for particles belonging to this cloud only
virtual
const
tmp
<
volScalarField
>
rhoEff
()
const
=
0
;
//- Destructor
virtual
~
kinematicCloud
();
//- Return the particle effective density field
// Note: for particles belonging to this cloud only
virtual
const
tmp
<
volScalarField
>
rhoEff
()
const
=
0
;
};
...
...
src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.H
View file @
99a1eee0
...
...
@@ -307,6 +307,10 @@ public:
template
<
class
CloudType
>
static
void
writeFields
(
const
CloudType
&
c
);
//- Write particle fields as objects into the obr registry
template
<
class
CloudType
>
static
void
writeObjects
(
const
CloudType
&
c
,
objectRegistry
&
obr
);
// Ostream Operator
...
...
src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcelIO.C
View file @
99a1eee0
...
...
@@ -274,6 +274,39 @@ void Foam::CollidingParcel<ParcelType>::writeFields(const CloudType& c)
}
template
<
class
ParcelType
>
template
<
class
CloudType
>
void
Foam
::
CollidingParcel
<
ParcelType
>::
writeObjects
(
const
CloudType
&
c
,
objectRegistry
&
obr
)
{
ParcelType
::
writeObjects
(
c
,
obr
);
label
np
=
c
.
size
();
IOField
<
vector
>&
f
(
cloud
::
createIOField
<
vector
>
(
"f"
,
np
,
obr
));
IOField
<
vector
>&
angularMomentum
(
cloud
::
createIOField
<
vector
>
(
"angularMomentum"
,
np
,
obr
)
);
IOField
<
vector
>&
torque
(
cloud
::
createIOField
<
vector
>
(
"torque"
,
np
,
obr
));
label
i
=
0
;
forAllConstIter
(
typename
CloudType
,
c
,
iter
)
{
const
CollidingParcel
<
ParcelType
>&
p
=
iter
();
f
[
i
]
=
p
.
f
();
angularMomentum
[
i
]
=
p
.
angularMomentum
();
torque
[
i
]
=
p
.
torque
();
i
++
;
}
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template
<
class
ParcelType
>
...
...
src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H
View file @
99a1eee0
...
...
@@ -660,6 +660,10 @@ public:
template
<
class
CloudType
>
static
void
writeFields
(
const
CloudType
&
c
);
//- Write particle fields as objects into the obr registry
template
<
class
CloudType
>
static
void
writeObjects
(
const
CloudType
&
c
,
objectRegistry
&
obr
);
// Ostream Operator
...
...
src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C
View file @
99a1eee0
...
...
@@ -171,7 +171,7 @@ void Foam::KinematicParcel<ParcelType>::writeFields(const CloudType& c)
{
ParcelType
::
writeFields
(
c
);
label
np
=
c
.
size
();
label
np
=
c
.
size
();
IOField
<
label
>
active
(
c
.
fieldIOobject
(
"active"
,
IOobject
::
NO_READ
),
np
);
IOField
<
label
>
typeId
(
c
.
fieldIOobject
(
"typeId"
,
IOobject
::
NO_READ
),
np
);
...
...
@@ -221,6 +221,55 @@ void Foam::KinematicParcel<ParcelType>::writeFields(const CloudType& c)
}
template
<
class
ParcelType
>
template
<
class
CloudType
>
void
Foam
::
KinematicParcel
<
ParcelType
>::
writeObjects
(
const
CloudType
&
c
,
objectRegistry
&
obr
)
{
DebugInFunction
<<
endl
;
ParcelType
::
writeObjects
(
c
,
obr
);
label
np
=
c
.
size
();
IOField
<
label
>&
active
(
cloud
::
createIOField
<
label
>
(
"active"
,
np
,
obr
));
IOField
<
label
>&
typeId
(
cloud
::
createIOField
<
label
>
(
"typeId"
,
np
,
obr
));
IOField
<
scalar
>&
nParticle
(
cloud
::
createIOField
<
scalar
>
(
"nParticle"
,
np
,
obr
)
);
IOField
<
scalar
>&
d
(
cloud
::
createIOField
<
scalar
>
(
"d"
,
np
,
obr
));
IOField
<
scalar
>&
dTarget
(
cloud
::
createIOField
<
scalar
>
(
"dTarget"
,
np
,
obr
));
IOField
<
vector
>&
U
(
cloud
::
createIOField
<
vector
>
(
"U"
,
np
,
obr
));
IOField
<
scalar
>&
rho
(
cloud
::
createIOField
<
scalar
>
(
"rho"
,
np
,
obr
));
IOField
<
scalar
>&
age
(
cloud
::
createIOField
<
scalar
>
(
"age"
,
np
,
obr
));
IOField
<
scalar
>&
tTurb
(
cloud
::
createIOField
<
scalar
>
(
"tTurb"
,
np
,
obr
));
IOField
<
vector
>&
UTurb
(
cloud
::
createIOField
<
vector
>
(
"UTurb"
,
np
,
obr
));
label
i
=
0
;
forAllConstIter
(
typename
CloudType
,
c
,
iter
)
{
const
KinematicParcel
<
ParcelType
>&
p
=
iter
();
active
[
i
]
=
p
.
active
();
typeId
[
i
]
=
p
.
typeId
();
nParticle
[
i
]
=
p
.
nParticle
();
d
[
i
]
=
p
.
d
();
dTarget
[
i
]
=
p
.
dTarget
();
U
[
i
]
=
p
.
U
();
rho
[
i
]
=
p
.
rho
();
age
[
i
]
=
p
.
age
();
tTurb
[
i
]
=
p
.
tTurb
();
UTurb
[
i
]
=
p
.
UTurb
();
i
++
;
}
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template
<
class
ParcelType
>
...
...
src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcel.H
View file @
99a1eee0
...
...
@@ -297,6 +297,10 @@ public:
template
<
class
CloudType
>
static
void
writeFields
(
const
CloudType
&
c
);
//- Write particle fields as objects into the obr registry
template
<
class
CloudType
>
static
void
writeObjects
(
const
CloudType
&
c
,
objectRegistry
&
obr
);
// Ostream operator
...
...
src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcelIO.C
View file @
99a1eee0
...
...
@@ -110,7 +110,7 @@ void Foam::MPPICParcel<ParcelType>::writeFields(const CloudType& c)
{
ParcelType
::
writeFields
(
c
);
label
np
=
c
.
size
();
label
np
=
c
.
size
();
IOField
<
vector
>
UCorrect
(
c
.
fieldIOobject
(
"UCorrect"
,
IOobject
::
NO_READ
),
np
);
...
...
@@ -130,6 +130,34 @@ void Foam::MPPICParcel<ParcelType>::writeFields(const CloudType& c)
}
template
<
class
ParcelType
>
template
<
class
CloudType
>
void
Foam
::
MPPICParcel
<
ParcelType
>::
writeObjects
(
const
CloudType
&
c
,
objectRegistry
&
obr
)
{
ParcelType
::
writeObjects
(
c
,
obr
);
label
np
=
c
.
size
();
IOField
<
vector
>&
UCorrect
(
cloud
::
createIOField
<
vector
>
(
"UCorrect"
,
np
,
obr
));
label
i
=
0
;
forAllConstIter
(
typename
CloudType
,
c
,
iter
)
{
const
MPPICParcel
<
ParcelType
>&
p
=
iter
();
UCorrect
[
i
]
=
p
.
UCorrect
();
i
++
;
}
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template
<
class
ParcelType
>
...
...
src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H
View file @
99a1eee0
...
...
@@ -433,7 +433,7 @@ public:
// I-O
//- Read
//- Read
- composition supplied
template
<
class
CloudType
,
class
CompositionType
>
static
void
readFields
(
...
...
@@ -445,7 +445,7 @@ public:
template
<
class
CloudType
>
static
void
readFields
(
CloudType
&
c
);
//- Write
//- Write
- composition supplied
template
<
class
CloudType
,
class
CompositionType
>
static
void
writeFields
(
...
...
@@ -453,10 +453,28 @@ public:
const
CompositionType
&
compModel
);
//- Read - composition
supplied
//- Read -
no
composition
template
<
class
CloudType
>
static
void
writeFields
(
const
CloudType
&
c
);
//- Write particle fields as objects into the obr registry
// - no composition
template
<
class
CloudType
>
static
void
writeObjects
(
const
CloudType
&
c
,
objectRegistry
&
obr
);
//- Write particle fields as objects into the obr registry
template
<
class
CloudType
,
class
CompositionType
>
static
void
writeObjects
(
const
CloudType
&
c
,
const
CompositionType
&
compModel
,
objectRegistry
&
obr
);
// Ostream Operator
...
...
src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelIO.C
View file @
99a1eee0
...
...
@@ -327,6 +327,108 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::writeFields
}
template
<
class
ParcelType
>
template
<
class
CloudType
>
void
Foam
::
ReactingMultiphaseParcel
<
ParcelType
>::
writeObjects
(
const
CloudType
&
c
,
objectRegistry
&
obr
)
{
ParcelType
::
writeObjects
(
c
,
obr
);
}
template
<
class
ParcelType
>
template
<
class
CloudType
,
class
CompositionType
>
void
Foam
::
ReactingMultiphaseParcel
<
ParcelType
>::
writeObjects
(
const
CloudType
&
c
,
const
CompositionType
&
compModel
,
objectRegistry
&
obr
)
{
ParcelType
::
writeObjects
(
c
,
obr
);
label
np
=
c
.
size
();
// Write the composition fractions
if
(
np
>
0
)
{
const
wordList
&
stateLabels
=
compModel
.
stateLabels
();
const
label
idGas
=
compModel
.
idGas
();
const
wordList
&
gasNames
=
compModel
.
componentNames
(
idGas
);
forAll
(
gasNames
,
j
)
{
const
word
fieldName
=
"Y"
+
gasNames
[
j
]
+
stateLabels
[
idGas
];
IOField
<
scalar
>&
YGas
(
cloud
::
createIOField
<
scalar
>
(
fieldName
,
np
,
obr
)
);
label
i
=
0
;