Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
OpenFOAM-plus
Commits
734c2019
Commit
734c2019
authored
Sep 28, 2017
by
mattijs
Browse files
BUG: redistributePar: transfer particles correctly. Fixes
#605
.
parent
5d8edc21
Changes
12
Hide whitespace changes
Inline
Side-by-side
applications/utilities/parallelProcessing/redistributePar/Make/files
View file @
734c2019
passivePositionParticleCloud.C
parLagrangianRedistributor.C
parFvFieldReconstructor.C
loadOrCreateMesh.C
...
...
applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.C
View file @
734c2019
...
...
@@ -25,7 +25,7 @@ License
#include
"ListOps.H"
#include
"parLagrangianRedistributor.H"
#include
"passiveParticleCloud.H"
#include
"passiveP
ositionP
articleCloud.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
...
...
@@ -133,7 +133,7 @@ void Foam::parLagrangianRedistributor::findClouds
Foam
::
autoPtr
<
Foam
::
mapDistributeBase
>
Foam
::
parLagrangianRedistributor
::
redistributeLagrangianPositions
(
passiveParticleCloud
&
lpi
passiveP
ositionP
articleCloud
&
lpi
)
const
{
//Debug(lpi.size());
...
...
@@ -147,7 +147,7 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions
{
// List of lists of particles to be transferred for all of the
// neighbour processors
List
<
IDLList
<
passiveParticle
>>
particleTransferLists
List
<
IDLList
<
passiveP
ositionP
article
>>
particleTransferLists
(
Pstream
::
nProcs
()
);
...
...
@@ -156,17 +156,15 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions
labelList
destProc
(
lpi
.
size
());
label
particleI
=
0
;
forAllIter
(
passiveParticleCloud
,
lpi
,
iter
)
forAllIter
(
passiveP
ositionP
articleCloud
,
lpi
,
iter
)
{
passiveParticle
&
ppi
=
iter
();
passiveP
ositionP
article
&
ppi
=
iter
();
label
destProcI
=
destinationProcID_
[
ppi
.
cell
()];
label
destCellI
=
destinationCell_
[
ppi
.
cell
()];
ppi
.
cell
()
=
destCellI
;
destProc
[
particleI
++
]
=
destProcI
;
//Pout<< "Sending particle:" << ppi << " to processor " << destProcI
// << " to cell " << destCellI << endl;
particleTransferLists
[
destProcI
].
append
(
lpi
.
remove
(
&
ppi
));
}
...
...
@@ -202,11 +200,11 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions
lpi
.
rename
(
cloudName
+
"_old"
);
// New cloud on tgtMesh
passiveParticleCloud
lagrangianPositions
passiveP
ositionP
articleCloud
lagrangianPositions
(
tgtMesh_
,
cloudName
,
IDLList
<
passiveParticle
>
()
IDLList
<
passiveP
ositionP
article
>
()
);
...
...
@@ -222,32 +220,28 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions
{
UIPstream
particleStream
(
procI
,
pBufs
);
IDLList
<
passiveParticle
>
newParticles
// Receive particles and locate them
IDLList
<
passivePositionParticle
>
newParticles
(
particleStream
,
passiveParticle
::
iNew
(
tgtMesh_
)
passiveP
ositionP
article
::
iNew
(
tgtMesh_
)
);
forAllIter
(
IDLList
<
passiveParticle
>
,
IDLList
<
passiveP
ositionP
article
>
,
newParticles
,
newpIter
)
{
passiveParticle
&
newp
=
newpIter
();
newp
.
relocate
();
passivePositionParticle
&
newp
=
newpIter
();
lagrangianPositions
.
addParticle
(
newParticles
.
remove
(
&
newp
));
}
}
}
//OFstream::debug = 1;
//Debug(lagrangianPositions.size());
IOPosition
<
passiveParticleCloud
>
(
lagrangianPositions
).
write
();
//OFstream::debug = 0;
IOPosition
<
passivePositionParticleCloud
>
(
lagrangianPositions
).
write
();
// Restore cloud name
lpi
.
rename
(
cloudName
);
...
...
@@ -300,7 +294,7 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions
)
const
{
// Load cloud and send particle
passiveParticleCloud
lpi
(
srcMesh_
,
cloudName
,
false
);
passiveP
ositionP
articleCloud
lpi
(
srcMesh_
,
cloudName
,
false
);
return
redistributeLagrangianPositions
(
lpi
);
}
...
...
applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.H
View file @
734c2019
...
...
@@ -49,7 +49,7 @@ namespace Foam
class
mapDistributePolyMesh
;
class
mapDistributeBase
;
class
IOobjectList
;
class
passiveParticleCloud
;
class
passiveP
ositionP
articleCloud
;
/*---------------------------------------------------------------------------*\
Class parLagrangianRedistributor Declaration
...
...
@@ -112,7 +112,7 @@ public:
//- Redistribute and write lagrangian positions
autoPtr
<
mapDistributeBase
>
redistributeLagrangianPositions
(
passiveParticleCloud
&
cloud
passiveP
ositionP
articleCloud
&
cloud
)
const
;
//- Read, redistribute and write lagrangian positions
...
...
@@ -153,7 +153,7 @@ public:
template
<
class
Container
>
static
void
readLagrangianFields
(
const
passiveParticleCloud
&
cloud
,
const
passiveP
ositionP
articleCloud
&
cloud
,
const
IOobjectList
&
objects
,
const
HashSet
<
word
>&
selectedFields
);
...
...
@@ -163,7 +163,7 @@ public:
void
redistributeStoredLagrangianFields
(
const
mapDistributeBase
&
map
,
passiveParticleCloud
&
cloud
passiveP
ositionP
articleCloud
&
cloud
)
const
;
};
...
...
applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributorRedistributeFields.C
View file @
734c2019
...
...
@@ -29,7 +29,7 @@ License
#include
"mapDistributePolyMesh.H"
#include
"cloud.H"
#include
"CompactIOField.H"
#include
"passiveParticleCloud.H"
#include
"passiveP
ositionP
articleCloud.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
...
...
@@ -223,7 +223,7 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFieldFields
template
<
class
Container
>
void
Foam
::
parLagrangianRedistributor
::
readLagrangianFields
(
const
passiveParticleCloud
&
cloud
,
const
passiveP
ositionP
articleCloud
&
cloud
,
const
IOobjectList
&
objects
,
const
HashSet
<
word
>&
selectedFields
)
...
...
@@ -272,7 +272,7 @@ template<class Container>
void
Foam
::
parLagrangianRedistributor
::
redistributeStoredLagrangianFields
(
const
mapDistributeBase
&
map
,
passiveParticleCloud
&
cloud
passiveP
ositionP
articleCloud
&
cloud
)
const
{
HashTable
<
Container
*>
fields
...
...
applications/utilities/parallelProcessing/redistributePar/passivePositionParticle.H
0 → 100644
View file @
734c2019
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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/>.
Class
Foam::passivePositionParticle
Description
Passive particle, transferring in old format (i.e. position instead of
coordinates). Used for e.g. redistributePar.
SourceFiles
passivePositionParticle.H
\*---------------------------------------------------------------------------*/
#ifndef passivePositionParticle_H
#define passivePositionParticle_H
#include
"passiveParticle.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace
Foam
{
/*---------------------------------------------------------------------------*\
Class passivePositionParticle Declaration
\*---------------------------------------------------------------------------*/
class
passivePositionParticle
:
public
passiveParticle
{
// Private member data
//- Cached position
point
position_
;
public:
// Constructors
//- Construct from Istream in old format
passivePositionParticle
(
const
polyMesh
&
mesh
,
Istream
&
is
,
bool
readFields
,
bool
newFormat
)
:
passiveParticle
(
mesh
,
is
,
readFields
,
newFormat
),
position_
(
position
())
{}
//- Construct as copy
passivePositionParticle
(
const
passivePositionParticle
&
p
)
:
passiveParticle
(
p
),
position_
(
p
.
position_
)
{}
//- Construct and return a clone
virtual
autoPtr
<
particle
>
clone
()
const
{
return
autoPtr
<
particle
>
(
new
passivePositionParticle
(
*
this
));
}
//- Factory class to read-construct particles used for
// parallel transfer
class
iNew
{
const
polyMesh
&
mesh_
;
public:
iNew
(
const
polyMesh
&
mesh
)
:
mesh_
(
mesh
)
{}
autoPtr
<
passivePositionParticle
>
operator
()(
Istream
&
is
)
const
{
return
autoPtr
<
passivePositionParticle
>
(
// Read in old format
new
passivePositionParticle
(
mesh_
,
is
,
true
,
false
)
);
}
};
// Friend Operators
friend
Ostream
&
operator
<<
(
Ostream
&
os
,
const
passivePositionParticle
&
ppi
)
{
// Copy data into old format structure. Exact opposite of
// particleIO.C reading old format.
struct
oldParticle
{
vector
position
;
label
celli
;
label
facei
;
scalar
stepFraction
;
label
tetFacei
;
label
tetPti
;
label
origProc
;
label
origId
;
}
p
;
p
.
position
=
ppi
.
position_
;
p
.
celli
=
ppi
.
cell
();
p
.
facei
=
ppi
.
face
();
p
.
stepFraction
=
ppi
.
stepFraction
();
p
.
tetFacei
=
ppi
.
tetFace
();
p
.
tetPti
=
ppi
.
tetPt
();
p
.
origProc
=
ppi
.
origProc
();
p
.
origId
=
ppi
.
origId
();
if
(
os
.
format
()
==
IOstream
::
ASCII
)
{
os
<<
p
.
position
<<
token
::
SPACE
<<
p
.
celli
<<
token
::
SPACE
<<
p
.
facei
<<
token
::
SPACE
<<
p
.
stepFraction
<<
token
::
SPACE
<<
p
.
tetFacei
<<
token
::
SPACE
<<
p
.
tetPti
<<
token
::
SPACE
<<
p
.
origProc
<<
token
::
SPACE
<<
p
.
origId
;
}
else
{
const
std
::
size_t
sizeofFields
(
sizeof
(
oldParticle
)
-
offsetof
(
oldParticle
,
position
)
);
os
.
write
(
reinterpret_cast
<
const
char
*>
(
&
p
.
position
),
sizeofFields
);
}
return
os
;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
}
// End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
applications/utilities/parallelProcessing/redistributePar/passivePositionParticleCloud.C
0 → 100644
View file @
734c2019
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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
"passivePositionParticleCloud.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace
Foam
{
defineTemplateTypeNameAndDebug
(
Cloud
<
passivePositionParticle
>
,
0
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam
::
passivePositionParticleCloud
::
passivePositionParticleCloud
(
const
polyMesh
&
mesh
,
const
word
&
cloudName
,
bool
readFields
)
:
Cloud
<
passivePositionParticle
>
(
mesh
,
cloudName
,
false
)
{
if
(
readFields
)
{
passivePositionParticle
::
readFields
(
*
this
);
}
}
Foam
::
passivePositionParticleCloud
::
passivePositionParticleCloud
(
const
polyMesh
&
mesh
,
const
word
&
cloudName
,
const
IDLList
<
passivePositionParticle
>&
particles
)
:
Cloud
<
passivePositionParticle
>
(
mesh
,
cloudName
,
particles
)
{}
// ************************************************************************* //
applications/utilities/parallelProcessing/redistributePar/passivePositionParticleCloud.H
0 → 100644
View file @
734c2019
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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/>.
Class
Foam::passivePositionParticleCloud
Description
A Cloud of passive position particles
SourceFiles
passivePositionParticleCloud.C
\*---------------------------------------------------------------------------*/
#ifndef passivePositionParticleCloud_H
#define passivePositionParticleCloud_H
#include
"Cloud.H"
#include
"passivePositionParticle.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace
Foam
{
/*---------------------------------------------------------------------------*\
Class passivePositionParticleCloud Declaration
\*---------------------------------------------------------------------------*/
class
passivePositionParticleCloud
:
public
Cloud
<
passivePositionParticle
>
{
// Private Member Functions
//- Disallow default bitwise copy construct
passivePositionParticleCloud
(
const
passivePositionParticleCloud
&
);
//- Disallow default bitwise assignment
void
operator
=
(
const
passivePositionParticleCloud
&
);
public:
// Constructors
//- Construct given mesh
passivePositionParticleCloud
(
const
polyMesh
&
,
const
word
&
cloudName
=
"defaultCloud"
,
bool
readFields
=
true
);
//- Construct from mesh, cloud name, and a list of particles
passivePositionParticleCloud
(
const
polyMesh
&
mesh
,
const
word
&
cloudName
,
const
IDLList
<
passivePositionParticle
>&
particles
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
}
// End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
applications/utilities/parallelProcessing/redistributePar/redistributePar.C
View file @
734c2019
...
...
@@ -80,7 +80,7 @@ Usage
#include
"parFvFieldReconstructor.H"
#include
"parLagrangianRedistributor.H"
#include
"unmappedPassiveParticleCloud.H"
#include
"unmappedPassiveP
ositionP
articleCloud.H"
#include
"hexRef8Data.H"
#include
"meshRefinement.H"
#include
"pointFields.H"
...
...
@@ -1908,7 +1908,7 @@ void readLagrangian
const
fvMesh
&
mesh
,
const
wordList
&
cloudNames
,
const
HashSet
<
word
>&
selectedLagrangianFields
,
PtrList
<
unmappedPassiveParticleCloud
>&
clouds
PtrList
<
unmappedPassiveP
ositionP
articleCloud
>&
clouds
)
{
(
void
)
mesh
.
tetBasePtIs
();
...
...
@@ -1919,13 +1919,13 @@ void readLagrangian
clouds
.
set
(
i
,
new
unmappedPassiveParticleCloud
(
mesh
,
cloudNames
[
i
],
false
)
new
unmappedPassiveP
ositionP
articleCloud
(
mesh
,
cloudNames
[
i
],
false
)
);
//forAllConstIter
//(
// unmappedPassiveParticleCloud,
// unmappedPassiveP
ositionP
articleCloud,
// clouds[i],
// iter
//)
...
...
@@ -2087,7 +2087,7 @@ void redistributeLagrangian
const
fvMesh
&
mesh
,
const
label
nOldCells
,
const
mapDistributePolyMesh
&
distMap
,
PtrList
<
unmappedPassiveParticleCloud
>&
clouds
PtrList
<
unmappedPassiveP
ositionP
articleCloud
>&
clouds
)
{
if
(
clouds
.
size
())
...
...
@@ -2958,7 +2958,7 @@ int main(int argc, char *argv[])
);
// Read lagrangian fields and store on cloud (objectRegistry)
PtrList
<
unmappedPassiveParticleCloud
>
clouds
(
cloudNames
.
size
());
PtrList
<
unmappedPassiveP
ositionP
articleCloud
>
clouds
(
cloudNames
.
size
());
readLagrangian
(
mesh
,
...
...
applications/utilities/parallelProcessing/redistributePar/unmappedPassiveParticleCloud.H
→
applications/utilities/parallelProcessing/redistributePar/unmappedPassiveP
ositionP
articleCloud.H
View file @
734c2019
...
...
@@ -22,21 +22,21 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::unmappedPassiveParticleCloud
Foam::unmappedPassiveP
ositionP
articleCloud
Description
passiveParticleCloud but with autoMap and writing disabled.
Only used
for its objectRegistry to store lagrangian fields
passiveP
ositionP
articleCloud but with autoMap and writing disabled.
Only used
for its objectRegistry to store lagrangian fields
SourceFiles
unmappedPassiveParticleCloud.C
unmappedPassiveP
ositionP
articleCloud.C
\*---------------------------------------------------------------------------*/
#ifndef unmappedPassiveParticleCloud_H
#define unmappedPassiveParticleCloud_H
#ifndef unmappedPassiveP
ositionP
articleCloud_H