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
Commits
8760f6c9
Commit
8760f6c9
authored
Feb 20, 2019
by
Mark OLESEN
Committed by
Andrew Heather
Feb 20, 2019
Browse files
ENH: minor improvements to fvMeshDistribute (
#1211
)
- sorted field names for consistency, remove some local variables
parent
7da0b5be
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C
View file @
8760f6c9
...
...
@@ -193,34 +193,6 @@ Foam::labelList Foam::fvMeshDistribute::select
}
void
Foam
::
fvMeshDistribute
::
checkEqualWordList
(
const
string
&
msg
,
const
wordList
&
lst
)
{
// Check all procs have same names and in exactly same order.
List
<
wordList
>
allNames
(
Pstream
::
nProcs
());
allNames
[
Pstream
::
myProcNo
()]
=
lst
;
Pstream
::
gatherList
(
allNames
);
Pstream
::
scatterList
(
allNames
);
for
(
label
proci
=
1
;
proci
<
Pstream
::
nProcs
();
proci
++
)
{
if
(
allNames
[
proci
]
!=
allNames
[
0
])
{
FatalErrorInFunction
<<
"When checking for equal "
<<
msg
.
c_str
()
<<
" :"
<<
endl
<<
"processor0 has:"
<<
allNames
[
0
]
<<
endl
<<
"processor"
<<
proci
<<
" has:"
<<
allNames
[
proci
]
<<
endl
<<
msg
.
c_str
()
<<
" need to be synchronised on all processors."
<<
exit
(
FatalError
);
}
}
}
Foam
::
wordList
Foam
::
fvMeshDistribute
::
mergeWordList
(
const
wordList
&
procNames
)
{
List
<
wordList
>
allNames
(
Pstream
::
nProcs
());
...
...
@@ -233,7 +205,7 @@ Foam::wordList Foam::fvMeshDistribute::mergeWordList(const wordList& procNames)
{
mergedNames
.
insert
(
allNames
[
proci
]);
}
return
mergedNames
.
t
oc
();
return
mergedNames
.
sortedT
oc
();
}
...
...
@@ -1851,71 +1823,32 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
mesh_
.
resetMotion
();
// Get data to send. Make sure is synchronised
const
wordList
volScalars
(
mesh_
.
names
(
volScalarField
::
typeName
));
checkEqualWordList
(
"volScalarFields"
,
volScalars
);
const
wordList
volVectors
(
mesh_
.
names
(
volVectorField
::
typeName
));
checkEqualWordList
(
"volVectorFields"
,
volVectors
);
const
wordList
volSphereTensors
(
mesh_
.
names
(
volSphericalTensorField
::
typeName
)
);
checkEqualWordList
(
"volSphericalTensorFields"
,
volSphereTensors
);
const
wordList
volSymmTensors
(
mesh_
.
names
(
volSymmTensorField
::
typeName
));
checkEqualWordList
(
"volSymmTensorFields"
,
volSymmTensors
);
const
wordList
volTensors
(
mesh_
.
names
(
volTensorField
::
typeName
));
checkEqualWordList
(
"volTensorField"
,
volTensors
);
const
wordList
surfScalars
(
mesh_
.
names
(
surfaceScalarField
::
typeName
));
checkEqualWordList
(
"surfaceScalarFields"
,
surfScalars
);
const
wordList
surfVectors
(
mesh_
.
names
(
surfaceVectorField
::
typeName
));
checkEqualWordList
(
"surfaceVectorFields"
,
surfVectors
);
const
wordList
surfSphereTensors
(
mesh_
.
names
(
surfaceSphericalTensorField
::
typeName
)
);
checkEqualWordList
(
"surfaceSphericalTensorFields"
,
surfSphereTensors
);
const
wordList
surfSymmTensors
(
mesh_
.
names
(
surfaceSymmTensorField
::
typeName
)
);
checkEqualWordList
(
"surfaceSymmTensorFields"
,
surfSymmTensors
);
const
wordList
surfTensors
(
mesh_
.
names
(
surfaceTensorField
::
typeName
));
checkEqualWordList
(
"surfaceTensorFields"
,
surfTensors
);
typedef
volScalarField
::
Internal
dimScalType
;
const
wordList
dimScalars
(
mesh_
.
names
(
dimScalType
::
typeName
));
checkEqualWordList
(
"volScalarField::Internal"
,
dimScalars
);
typedef
volVectorField
::
Internal
dimVecType
;
const
wordList
dimVectors
(
mesh_
.
names
(
dimVecType
::
typeName
));
checkEqualWordList
(
"volVectorField::Internal"
,
dimVectors
);
HashTable
<
wordList
>
allFieldNames
;
typedef
volSphericalTensorField
::
Internal
dimSphereType
;
const
wordList
dimSphereTensors
(
mesh_
.
names
(
dimSphereType
::
typeName
));
checkEqualWordList
(
"volSphericalTensorField::Internal"
,
dimSphereTensors
);
getFieldNames
<
volScalarField
>
(
mesh_
,
allFieldNames
);
getFieldNames
<
volVectorField
>
(
mesh_
,
allFieldNames
);
getFieldNames
<
volSphericalTensorField
>
(
mesh_
,
allFieldNames
);
getFieldNames
<
volSymmTensorField
>
(
mesh_
,
allFieldNames
);
getFieldNames
<
volTensorField
>
(
mesh_
,
allFieldNames
);
typedef
volSymmTensorField
::
Internal
dimSymmTensorType
;
const
wordList
dimSymmTensors
(
mesh_
.
names
(
dimSymmTensorType
::
typeName
));
checkEqualWordList
(
"volSymmTensorField::Internal"
,
dimSymmTensors
);
getFieldNames
<
surfaceScalarField
>
(
mesh_
,
allFieldNames
);
getFieldNames
<
surfaceVectorField
>
(
mesh_
,
allFieldNames
);
getFieldNames
<
surfaceSphericalTensorField
>
(
mesh_
,
allFieldNames
);
getFieldNames
<
surfaceSymmTensorField
>
(
mesh_
,
allFieldNames
);
getFieldNames
<
surfaceTensorField
>
(
mesh_
,
allFieldNames
);
typedef
volTensorField
::
Internal
dimTensorType
;
const
wordList
dimTensors
(
mesh_
.
names
(
dimTensorType
::
typeName
));
checkEqualWordList
(
"volTensorField::Internal"
,
dimTensors
);
getFieldNames
<
volScalarField
::
Internal
>
(
mesh_
,
allFieldNames
);
getFieldNames
<
volVectorField
::
Internal
>
(
mesh_
,
allFieldNames
);
getFieldNames
<
volSphericalTensorField
::
Internal
>
(
mesh_
,
allFieldNames
);
getFieldNames
<
volSymmTensorField
::
Internal
>
(
mesh_
,
allFieldNames
);
getFieldNames
<
volTensorField
::
Internal
>
(
mesh_
,
allFieldNames
);
// Find patch to temporarily put exposed and processor faces into.
label
oldInternalPatchi
=
findNonEmptyPatch
();
// Delete processor patches, starting from the back. Move all faces into
// oldInternalPatchi.
labelList
repatchFaceMap
;
...
...
@@ -2095,57 +2028,75 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
);
// volFields
sendFields
<
volScalarField
>
(
recvProc
,
volScalars
,
subsetter
,
str
);
sendFields
<
volVectorField
>
(
recvProc
,
volVectors
,
subsetter
,
str
);
sendFields
<
volScalarField
>
(
recvProc
,
allFieldNames
,
subsetter
,
str
);
sendFields
<
volVectorField
>
(
recvProc
,
allFieldNames
,
subsetter
,
str
);
sendFields
<
volSphericalTensorField
>
(
recvProc
,
volSphereTensor
s
,
allFieldName
s
,
subsetter
,
str
);
sendFields
<
volSymmTensorField
>
(
recvProc
,
volSymmTensors
,
allFieldNames
,
subsetter
,
str
);
sendFields
<
volTensorField
>
(
recvProc
,
allFieldNames
,
subsetter
,
str
);
sendFields
<
volTensorField
>
(
recvProc
,
volTensors
,
subsetter
,
str
);
// surfaceFields
sendFields
<
surfaceScalarField
>
(
recvProc
,
surfScalar
s
,
allFieldName
s
,
subsetter
,
str
);
sendFields
<
surfaceVectorField
>
(
recvProc
,
surfVector
s
,
allFieldName
s
,
subsetter
,
str
);
sendFields
<
surfaceSphericalTensorField
>
(
recvProc
,
surfSphereTensor
s
,
allFieldName
s
,
subsetter
,
str
);
sendFields
<
surfaceSymmTensorField
>
(
recvProc
,
surfSymmTensor
s
,
allFieldName
s
,
subsetter
,
str
);
sendFields
<
surfaceTensorField
>
(
recvProc
,
surfTensor
s
,
allFieldName
s
,
subsetter
,
str
);
...
...
@@ -2154,35 +2105,35 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
sendFields
<
volScalarField
::
Internal
>
(
recvProc
,
dimScalar
s
,
allFieldName
s
,
subsetter
,
str
);
sendFields
<
volVectorField
::
Internal
>
(
recvProc
,
dimVector
s
,
allFieldName
s
,
subsetter
,
str
);
sendFields
<
volSphericalTensorField
::
Internal
>
(
recvProc
,
dimSphereTensor
s
,
allFieldName
s
,
subsetter
,
str
);
sendFields
<
volSymmTensorField
::
Internal
>
(
recvProc
,
dimSymmTensor
s
,
allFieldName
s
,
subsetter
,
str
);
sendFields
<
volTensorField
::
Internal
>
(
recvProc
,
dimTensor
s
,
allFieldName
s
,
subsetter
,
str
);
...
...
@@ -2391,142 +2342,126 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
receiveFields
<
volScalarField
>
(
sendProc
,
volScalar
s
,
allFieldName
s
,
domainMesh
,
vsf
,
fieldDicts
.
subDict
(
volScalarField
::
typeName
)
fieldDicts
);
receiveFields
<
volVectorField
>
(
sendProc
,
volVector
s
,
allFieldName
s
,
domainMesh
,
vvf
,
fieldDicts
.
subDict
(
volVectorField
::
typeName
)
fieldDicts
);
receiveFields
<
volSphericalTensorField
>
(
sendProc
,
volSphereTensor
s
,
allFieldName
s
,
domainMesh
,
vsptf
,
fieldDicts
.
subDict
(
volSphericalTensorField
::
typeName
)
fieldDicts
);
receiveFields
<
volSymmTensorField
>
(
sendProc
,
volSymmTensor
s
,
allFieldName
s
,
domainMesh
,
vsytf
,
fieldDicts
.
subDict
(
volSymmTensorField
::
typeName
)
fieldDicts
);
receiveFields
<
volTensorField
>
(
sendProc
,
volTensor
s
,
allFieldName
s
,
domainMesh
,
vtf
,
fieldDicts
.
subDict
(
volTensorField
::
typeName
)
fieldDicts
);
// Surface fields
receiveFields
<
surfaceScalarField
>
(
sendProc
,
surfScalar
s
,
allFieldName
s
,
domainMesh
,
ssf
,
fieldDicts
.
subDict
(
surfaceScalarField
::
typeName
)
fieldDicts
);
receiveFields
<
surfaceVectorField
>
(
sendProc
,
surfVector
s
,
allFieldName
s
,
domainMesh
,
svf
,
fieldDicts
.
subDict
(
surfaceVectorField
::
typeName
)
fieldDicts
);
receiveFields
<
surfaceSphericalTensorField
>
(
sendProc
,
surfSphereTensor
s
,
allFieldName
s
,
domainMesh
,
ssptf
,
fieldDicts
.
subDict
(
surfaceSphericalTensorField
::
typeName
)
fieldDicts
);
receiveFields
<
surfaceSymmTensorField
>
(
sendProc
,
surfSymmTensor
s
,
allFieldName
s
,
domainMesh
,
ssytf
,
fieldDicts
.
subDict
(
surfaceSymmTensorField
::
typeName
)
fieldDicts
);
receiveFields
<
surfaceTensorField
>
(
sendProc
,
surfTensor
s
,
allFieldName
s
,
domainMesh
,
stf
,
fieldDicts
.
subDict
(
surfaceTensorField
::
typeName
)
fieldDicts
);
// Dimensioned fields
receiveFields
<
volScalarField
::
Internal
>
(
sendProc
,
dimScalar
s
,
allFieldName
s
,
domainMesh
,
dsf
,
fieldDicts
.
subDict
(
volScalarField
::
Internal
::
typeName
)
fieldDicts
);
receiveFields
<
volVectorField
::
Internal
>
(
sendProc
,
dimVector
s
,
allFieldName
s
,
domainMesh
,
dvf
,
fieldDicts
.
subDict
(
volVectorField
::
Internal
::
typeName
)
fieldDicts
);
receiveFields
<
volSphericalTensorField
::
Internal
>
(
sendProc
,
dimSphereTensor
s
,
allFieldName
s
,
domainMesh
,
dstf
,
fieldDicts
.
subDict
(
volSphericalTensorField
::
Internal
::
typeName
)
fieldDicts
);
receiveFields
<
volSymmTensorField
::
Internal
>
(
sendProc
,
dimSymmTensor
s
,
allFieldName
s
,
domainMesh
,
dsytf
,
fieldDicts
.
subDict
(
volSymmTensorField
::
Internal
::
typeName
)
fieldDicts
);
receiveFields
<
volTensorField
::
Internal
>
(
sendProc
,
dimTensor
s
,
allFieldName
s
,
domainMesh
,
dtf
,
fieldDicts
.
subDict
(
volTensorField
::
Internal
::
typeName
)
fieldDicts
);
}
const
fvMesh
&
domainMesh
=
domainMeshPtr
();
...
...
src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.H
View file @
8760f6c9
...
...
@@ -100,9 +100,6 @@ class fvMeshDistribute
const
label
value
);
//- Check all procs have same names and in exactly same order.
static
void
checkEqualWordList
(
const
string
&
,
const
wordList
&
);
//- Merge wordlists over all processors
static
wordList
mergeWordList
(
const
wordList
&
);
...
...
@@ -293,14 +290,25 @@ class fvMeshDistribute
const
labelList
&
sourcePointMaster
,
Ostream
&
toDomain
);
//- Get sorted names of GeoField, optionally test
//- that all procs have the same names.
template
<
class
GeoField
>
static
void
getFieldNames
(
const
fvMesh
&
mesh
,
HashTable
<
wordList
>&
allFieldNames
,
const
bool
syncPar
=
true
);
//- Send subset of fields
template
<
class
GeoField
>
static
void
sendFields
(
const
label
domain
,
const
wordList
&
f
ieldNames
,
const
fvMeshSubset
&
,
Ostream
&
toNbr
const
HashTable
<
wordList
>
&
allF
ieldNames
,
const
fvMeshSubset
&
subsetter
,
Ostream
&
);
//- Receive mesh. Opposite of sendMesh
...
...
@@ -324,10 +332,10 @@ class fvMeshDistribute
static
void
receiveFields
(
const
label
domain
,
const
wordList
&
f
ieldNames
,
fvMesh
&
,
PtrList
<
GeoField
>&
,
const
dictionary
&
f
ieldDict
s
const
HashTable
<
wordList
>
&
allF
ieldNames
,
fvMesh
&
mesh
,
PtrList
<
GeoField
>&
fields
,
const
dictionary
&
allF
ield
s
Dict
);
//- No copy construct
...
...
src/dynamicMesh/fvMeshDistribute/fvMeshDistributeTemplates.C
View file @
8760f6c9
...
...
@@ -45,13 +45,13 @@ void Foam::fvMeshDistribute::printFieldInfo(const fvMesh& mesh)
//<< " value:" << fld
<<
endl
;
for
All
(
fld
.
boundaryField
()
,
patchi
)
for
(
const
auto
&
patchFld
:
fld
.
boundaryField
())
{
Pout
<<
" "
<<
patch
i
<<
' '
<<
fld
.
boundaryField
()[
patch
i
]
.
patch
().
name
()
<<
' '
<<
fld
.
boundaryField
()[
patch
i
]
.
type
()
<<
' '
<<
fld
.
boundaryField
()[
patch
i
]
.
size
()
<<
end
l
;
Pout
<<
" "
<<
patch
Fld
.
patch
().
index
()
<<
' '
<<
patch
Fld
.
patch
().
name
()
<<
' '
<<
patch
Fld
.
type
()
<<
' '
<<
patch
Fld
.
size
()
<<
n
l
;
}
}
}
...
...
@@ -287,11 +287,49 @@ void Foam::fvMeshDistribute::correctBoundaryConditions()
}
template
<
class
GeoField
>
void
Foam
::
fvMeshDistribute
::
getFieldNames
(
const
fvMesh
&
mesh
,
HashTable
<
wordList
>&
allFieldNames
,
const
bool
syncPar
)
{
wordList
&
list
=
allFieldNames
(
GeoField
::
typeName
);
list
=
mesh
.
sortedNames
<
GeoField
>
();
// Check all procs have same names
if
(
syncPar
)
{
List
<
wordList
>
allNames
(
Pstream
::
nProcs
());
allNames
[
Pstream
::
myProcNo
()]
=
list
;
Pstream
::
gatherList
(
allNames
);
Pstream
::
scatterList
(
allNames
);
for
(
label
proci
=
1
;
proci
<
Pstream
::
nProcs
();
proci
++
)
{
if
(
allNames
[
proci
]
!=
allNames
[
0
])
{
FatalErrorInFunction
<<
"When checking for equal "
<<
GeoField
::
typeName
<<
" :"
<<
nl
<<
"processor0 has:"
<<
allNames
[
0
]
<<
endl
<<
"processor"
<<
proci
<<
" has:"
<<
allNames
[
proci
]
<<
nl
<<
GeoField
::
typeName
<<
" need to be synchronised on all processors."
<<
exit
(
FatalError
);
}
}
}
}
template
<
class
GeoField
>
void
Foam
::
fvMeshDistribute
::
sendFields
(
const
label
domain
,
const
wordList
&
f
ieldNames
,
const
HashTable
<
wordList
>
&
allF
ieldNames
,
const
fvMeshSubset
&
subsetter
,
Ostream
&
toNbr
)
...
...
@@ -315,24 +353,28 @@ void Foam::fvMeshDistribute::sendFields
// volVectorField {U {internalField ..; boundaryField ..;}}
const
wordList
&
fieldNames
=
allFieldNames
.
lookup
(
GeoField
::
typeName
,
wordList
::
null
());
toNbr
<<
GeoField
::
typeName
<<
token
::
NL
<<
token
::
BEGIN_BLOCK
<<
token
::
NL
;
forAll
(
fieldNames
,
i
)
for
(
const
word
&
fieldName
:
fieldNames
)
{
if
(
debug
)
{
Pout
<<
"Subsetting field "
<<
fieldName
s
[
i
]
Pout
<<
"Subsetting field "
<<
fieldName
<<
" for domain:"
<<
domain
<<
endl
;
}
// Send all fieldNames. This has to be exactly the same set as is
// being received!
const
GeoField
&
fld
=
subsetter
.
baseMesh
().
lookupObject
<
GeoField
>
(
fieldName
s
[
i
]
);
subsetter
.
baseMesh
().
lookupObject
<
GeoField
>
(
fieldName
);
tmp
<
GeoField
>
tsubfld
=
subsetter
.
interpolate
(
fld
);
toNbr
<<
fieldName
s
[
i
]
<<
token
::
NL
<<
token
::
BEGIN_BLOCK
<<
fieldName
<<
token
::
NL
<<
token
::
BEGIN_BLOCK
<<
tsubfld
<<
token
::
NL
<<
token
::
END_BLOCK
<<
token
::
NL
;
}
...
...
@@ -344,45 +386,53 @@ template<class GeoField>
void
Foam
::
fvMeshDistribute
::
receiveFields
(
const
label
domain
,
const
wordList
&
f
ieldNames
,
const
HashTable
<
wordList
>
&
allF
ieldNames
,
fvMesh
&
mesh
,
PtrList
<
GeoField
>&
fields
,
const
dictionary
&
f
ieldDict
s
const
dictionary
&
allF
ield
s
Dict
)
{
// Opposite of sendFields
const
wordList
&
fieldNames
=
allFieldNames
.
lookup
(
GeoField
::
typeName
,
wordList
::
null
());