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
Community
integration-cfmesh
Commits
6332402a
Commit
6332402a
authored
May 25, 2015
by
Franjo
Browse files
Implemented sending of coordinates with range
parent
fc671971
Changes
4
Hide whitespace changes
Inline
Side-by-side
meshLibrary/utilities/helperClasses/parallelHelpers/meshOctreeCubeCoordinatesScalar/meshOctreeCubeCoordinatesScalar.H
View file @
6332402a
...
...
@@ -22,20 +22,20 @@ License
along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
labelledM
eshOctre
e
CubeCoordinates
m
eshOctreCubeCoordinates
Scalar
Description
A class containing
point label and
meshOctreeCubeCoordinates.
A class containing meshOctreeCubeCoordinates
and a scalar value
.
It is used for exchanging data over processors
SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef
labelledM
eshOctreeCubeCoordinates_H
#define
labelledM
eshOctreeCubeCoordinates_H
#ifndef
m
eshOctreeCubeCoordinates
Scalar
_H
#define
m
eshOctreeCubeCoordinates
Scalar
_H
#include
"
label
.H"
#include
"
scalar
.H"
#include
"meshOctreeCubeCoordinates.H"
#include
"contiguous.H"
...
...
@@ -45,129 +45,137 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class
labelledM
eshOctreeCubeCoordinates Declaration
Class
m
eshOctreeCubeCoordinates
Scalar
Declaration
\*---------------------------------------------------------------------------*/
class
labelledM
eshOctreeCubeCoordinates
class
m
eshOctreeCubeCoordinates
Scalar
{
// Private data
//-
label
label
cLabel
_
;
//-
scalar
scalar
sValue
_
;
//- cube coordinates
meshOctreeCubeCoordinates
coordinates_
;
public:
// Constructors
//- Null construct
labelledM
eshOctreeCubeCoordinates
()
m
eshOctreeCubeCoordinates
Scalar
()
:
cLabel_
(
-
1
),
sValue_
(
0.0
),
coordinates_
()
{}
//- Construct from label and cube coordinates
labelledM
eshOctreeCubeCoordinates
m
eshOctreeCubeCoordinates
Scalar
(
const
label
cl
,
const
scalar
s
,
const
meshOctreeCubeCoordinates
&
cc
)
:
cLabel_
(
cl
),
sValue_
(
s
),
coordinates_
(
cc
)
{}
// Destructor
~
labelledM
eshOctreeCubeCoordinates
()
~
m
eshOctreeCubeCoordinates
Scalar
()
{}
// Member functions
//- return cube label
inline
label
cubeLabel
()
const
inline
scalar
scalarValue
()
const
{
return
cLabel
_
;
return
sValue
_
;
}
//- return the value
inline
const
meshOctreeCubeCoordinates
&
coordinates
()
const
{
return
coordinates_
;
}
// Member operators
inline
void
operator
=
(
const
labelledM
eshOctreeCubeCoordinates
&
l
cc
)
inline
bool
operator
<
(
const
m
eshOctreeCubeCoordinates
Scalar
&
s
cc
)
const
{
cLabel_
=
lcc
.
cLabel_
;
coordinates_
=
lcc
.
coordinates_
;
if
(
coordinates_
<
scc
.
coordinates_
)
return
true
;
return
false
;
}
inline
void
operator
=
(
const
meshOctreeCubeCoordinatesScalar
&
scc
)
{
sValue_
=
scc
.
sValue_
;
coordinates_
=
scc
.
coordinates_
;
}
inline
bool
operator
==
(
const
labelledM
eshOctreeCubeCoordinates
&
l
cc
const
m
eshOctreeCubeCoordinates
Scalar
&
s
cc
)
const
{
if
(
c
Label
_
==
l
cc
.
c
Label
_
)
if
(
c
oordinates
_
==
s
cc
.
c
oordinates
_
)
return
true
;
return
false
;
}
inline
bool
operator
!=
(
const
labelledM
eshOctreeCubeCoordinates
&
l
cc
const
m
eshOctreeCubeCoordinates
Scalar
&
s
cc
)
const
{
return
!
this
->
operator
==
(
l
cc
);
return
!
this
->
operator
==
(
s
cc
);
}
// Friend operators
friend
Ostream
&
operator
<<
(
Ostream
&
os
,
const
labelledM
eshOctreeCubeCoordinates
&
l
cc
const
m
eshOctreeCubeCoordinates
Scalar
&
s
cc
)
{
os
<<
token
::
BEGIN_LIST
;
os
<<
l
cc
.
cLabel
_
<<
token
::
SPACE
;
os
<<
l
cc
.
coordinates_
<<
token
::
END_LIST
;
os
<<
s
cc
.
sValue
_
<<
token
::
SPACE
;
os
<<
s
cc
.
coordinates_
<<
token
::
END_LIST
;
// Check state of Ostream
os
.
check
(
"operator<<(Ostream&, const
labelledM
eshOctre
e
CubeCoordinates&"
"operator<<(Ostream&, const
m
eshOctreCubeCoordinates
Scalar
&"
);
return
os
;
}
friend
Istream
&
operator
>>
(
Istream
&
is
,
labelledM
eshOctreeCubeCoordinates
&
l
cc
m
eshOctreeCubeCoordinates
Scalar
&
s
cc
)
{
// Read beginning of
labelledM
eshOctre
e
CubeCoordinates
is
.
readBegin
(
"
labelledM
eshOctre
e
CubeCoordinates"
);
is
>>
l
cc
.
cLabel
_
;
is
>>
l
cc
.
coordinates_
;
// Read end of
labelledM
eshOctre
e
CubeCoordinates
is
.
readEnd
(
"
labelledM
eshOctre
e
CubeCoordinates"
);
// Read beginning of
m
eshOctreCubeCoordinates
Scalar
is
.
readBegin
(
"
m
eshOctreCubeCoordinates
Scalar
"
);
is
>>
s
cc
.
sValue
_
;
is
>>
s
cc
.
coordinates_
;
// Read end of
m
eshOctreCubeCoordinates
Scalar
is
.
readEnd
(
"
m
eshOctreCubeCoordinates
Scalar
"
);
// Check state of Istream
is
.
check
(
"operator>>(Istream&,
labelledM
eshOctre
e
CubeCoordinates"
);
is
.
check
(
"operator>>(Istream&,
m
eshOctreCubeCoordinates
Scalar
"
);
return
is
;
}
};
//- Specify data associated with
labelledM
eshOctre
e
CubeCoordinates
//- Specify data associated with
m
eshOctreCubeCoordinates
Scalar
//- type is contiguous
template
<
>
inline
bool
contiguous
<
labelledM
eshOctreeCubeCoordinates
>
()
{
return
true
;}
inline
bool
contiguous
<
m
eshOctreeCubeCoordinates
Scalar
>
()
{
return
true
;}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
meshLibrary/utilities/octrees/meshOctree/meshOctree.H
View file @
6332402a
...
...
@@ -138,6 +138,14 @@ public:
//- find a cube containing the vertex
label
findLeafContainingVertex
(
const
point
&
)
const
;
//- find leaves within the given range from the given point
void
findLeavesInSphere
(
const
point
&
,
const
scalar
,
DynList
<
label
>&
)
const
;
//- is octree a quadtree or an octree
inline
bool
isQuadtree
()
const
;
...
...
@@ -334,6 +342,15 @@ public:
LongList
<
meshOctreeCubeCoordinates
>&
dataToReceive
)
const
;
//- exchange requests with other processors generating the octree
void
exchangeRequestsWithNeighbourProcessors
(
const
LongList
<
meshOctreeCubeCoordinates
>&
dataToSend
,
const
LongList
<
scalar
>&
rangesToSend
,
LongList
<
meshOctreeCubeCoordinates
>&
dataToReceive
,
LongList
<
scalar
>&
receivedRanges
)
const
;
//- neighbour processors of the current one
inline
const
labelList
&
neiProcs
()
const
;
};
...
...
meshLibrary/utilities/octrees/meshOctree/meshOctreeNeighbourSearches.C
View file @
6332402a
...
...
@@ -91,6 +91,18 @@ label meshOctree::findLeafContainingVertex
return
meshOctreeCubeBasic
::
OTHERPROC
;
}
void
meshOctree
::
findLeavesInSphere
(
const
point
&
c
,
const
scalar
r
,
DynList
<
label
>&
containedLeaves
)
const
{
containedLeaves
.
clear
();
initialCubePtr_
->
leavesInSphere
(
rootBox_
,
c
,
r
,
containedLeaves
);
}
label
meshOctree
::
findNeighbourOverNode
(
const
meshOctreeCubeCoordinates
&
cc
,
...
...
meshLibrary/utilities/octrees/meshOctree/meshOctreeParallelCommunication.C
View file @
6332402a
...
...
@@ -188,6 +188,226 @@ void meshOctree::exchangeRequestsWithNeighbourProcessors
toOtherProc
<<
toProcs
[
neiProcI
];
}
}
void
meshOctree
::
exchangeRequestsWithNeighbourProcessors
(
const
LongList
<
meshOctreeCubeCoordinates
>&
dataToSend
,
const
LongList
<
scalar
>&
rangesToSend
,
LongList
<
meshOctreeCubeCoordinates
>&
dataToReceive
,
LongList
<
scalar
>&
receivedRanges
)
const
{
if
(
!
Pstream
::
parRun
()
||
(
neiProcs_
.
size
()
==
0
)
)
{
//- this is a serial run
return
;
}
List
<
LongList
<
meshOctreeCubeCoordinates
>
>
toProcs
(
neiProcs_
.
size
(),
LongList
<
meshOctreeCubeCoordinates
>
()
);
List
<
LongList
<
scalar
>
>
attributesToProcs
(
neiProcs_
.
size
(),
LongList
<
scalar
>
()
);
meshOctreeCubeCoordinates
minCoord
,
maxCoord
;
forAll
(
dataToSend
,
i
)
{
dataToSend
[
i
].
neighbourRange
(
minCoord
,
maxCoord
);
const
scalar
size
=
dataToSend
[
i
].
size
(
rootBox_
);
const
label
nLayers
=
ceil
(
rangesToSend
[
i
]
/
size
);
minCoord
=
meshOctreeCubeCoordinates
(
minCoord
.
posX
()
-
nLayers
,
minCoord
.
posY
()
-
nLayers
,
minCoord
.
posZ
()
-
nLayers
,
minCoord
.
level
()
);
maxCoord
=
meshOctreeCubeCoordinates
(
nLayers
+
maxCoord
.
posX
(),
nLayers
+
maxCoord
.
posY
(),
nLayers
+
maxCoord
.
posZ
(),
maxCoord
.
level
()
);
# ifdef OCTREE_DEBUG
label
counter
(
0
);
# endif
forAll
(
neiProcs_
,
procI
)
{
if
(
maxCoord
>=
neiRange_
[
procI
].
first
()
)
{
if
(
minCoord
<=
neiRange_
[
procI
].
second
()
)
{
toProcs
[
procI
].
append
(
dataToSend
[
i
]);
attributesToProcs
[
procI
].
append
(
rangesToSend
[
i
]);
# ifdef OCTREE_DEBUG
++
counter
;
# endif
}
}
else
{
break
;
}
}
}
//- send an receive the size of data chunk which will be exchanged
forAll
(
neiProcs_
,
neiProcI
)
{
OPstream
toOtherProc
(
Pstream
::
blocking
,
neiProcs_
[
neiProcI
],
sizeof
(
label
)
);
toOtherProc
<<
toProcs
[
neiProcI
].
size
();
}
labelList
sizeOfOtherProc
(
neiProcs_
.
size
());
forAll
(
neiProcs_
,
neiProcI
)
{
IPstream
fromOtherProc
(
Pstream
::
blocking
,
neiProcs_
[
neiProcI
],
sizeof
(
label
)
);
fromOtherProc
>>
sizeOfOtherProc
[
neiProcI
];
}
//- exchange data between processors
//- upper-diagonal communication
forAll
(
neiProcs_
,
neiProcI
)
{
if
(
sizeOfOtherProc
[
neiProcI
]
==
0
)
continue
;
if
(
neiProcs_
[
neiProcI
]
>=
Pstream
::
myProcNo
()
)
continue
;
//- receive data from other processor
IPstream
fromOtherProc
(
Pstream
::
scheduled
,
neiProcs_
[
neiProcI
]);
dataToReceive
.
appendFromStream
(
fromOtherProc
);
}
forAll
(
neiProcs_
,
neiProcI
)
{
if
(
toProcs
[
neiProcI
].
size
()
==
0
)
continue
;
if
(
neiProcs_
[
neiProcI
]
<=
Pstream
::
myProcNo
()
)
continue
;
//- send data to other processor
OPstream
toOtherProc
(
Pstream
::
scheduled
,
neiProcs_
[
neiProcI
]);
toOtherProc
<<
toProcs
[
neiProcI
];
}
//- lower-diagonal communication
forAllReverse
(
neiProcs_
,
neiProcI
)
{
if
(
sizeOfOtherProc
[
neiProcI
]
==
0
)
continue
;
if
(
neiProcs_
[
neiProcI
]
<=
Pstream
::
myProcNo
()
)
continue
;
//- receive data from other processor
IPstream
fromOtherProc
(
Pstream
::
scheduled
,
neiProcs_
[
neiProcI
]);
dataToReceive
.
appendFromStream
(
fromOtherProc
);
}
forAllReverse
(
neiProcs_
,
neiProcI
)
{
if
(
toProcs
[
neiProcI
].
size
()
==
0
)
continue
;
if
(
neiProcs_
[
neiProcI
]
>=
Pstream
::
myProcNo
()
)
continue
;
//- send data to other processor
OPstream
toOtherProc
(
Pstream
::
scheduled
,
neiProcs_
[
neiProcI
]);
toOtherProc
<<
toProcs
[
neiProcI
];
}
//- exchange attributes
//- exchange data between processors
//- upper-diagonal communication
forAll
(
neiProcs_
,
neiProcI
)
{
if
(
sizeOfOtherProc
[
neiProcI
]
==
0
)
continue
;
if
(
neiProcs_
[
neiProcI
]
>=
Pstream
::
myProcNo
()
)
continue
;
//- receive data from other processor
IPstream
fromOtherProc
(
Pstream
::
scheduled
,
neiProcs_
[
neiProcI
]);
receivedRanges
.
appendFromStream
(
fromOtherProc
);
}
forAll
(
neiProcs_
,
neiProcI
)
{
if
(
toProcs
[
neiProcI
].
size
()
==
0
)
continue
;
if
(
neiProcs_
[
neiProcI
]
<=
Pstream
::
myProcNo
()
)
continue
;
//- send data to other processor
OPstream
toOtherProc
(
Pstream
::
scheduled
,
neiProcs_
[
neiProcI
],
attributesToProcs
[
neiProcI
].
byteSize
()
);
toOtherProc
<<
attributesToProcs
[
neiProcI
];
}
//- lower-diagonal communication
forAllReverse
(
neiProcs_
,
neiProcI
)
{
if
(
sizeOfOtherProc
[
neiProcI
]
==
0
)
continue
;
if
(
neiProcs_
[
neiProcI
]
<=
Pstream
::
myProcNo
()
)
continue
;
//- receive data from other processor
IPstream
fromOtherProc
(
Pstream
::
scheduled
,
neiProcs_
[
neiProcI
]);
receivedRanges
.
appendFromStream
(
fromOtherProc
);
}
forAllReverse
(
neiProcs_
,
neiProcI
)
{
if
(
toProcs
[
neiProcI
].
size
()
==
0
)
continue
;
if
(
neiProcs_
[
neiProcI
]
>=
Pstream
::
myProcNo
()
)
continue
;
//- send data to other processor
OPstream
toOtherProc
(
Pstream
::
scheduled
,
neiProcs_
[
neiProcI
],
attributesToProcs
[
neiProcI
].
byteSize
()
);
toOtherProc
<<
attributesToProcs
[
neiProcI
];
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment