Skip to content
GitLab
Menu
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
d2a2f27b
Commit
d2a2f27b
authored
Oct 20, 2008
by
Mark Olesen
Browse files
added xfer contructors to mesh classes
parent
96b24c46
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/meshes/polyMesh/polyMesh.C
View file @
d2a2f27b
...
...
@@ -425,6 +425,162 @@ Foam::polyMesh::polyMesh
}
Foam
::
polyMesh
::
polyMesh
(
const
IOobject
&
io
,
const
xfer
<
pointField
>&
points
,
const
xfer
<
faceList
>&
faces
,
const
xfer
<
labelList
>&
owner
,
const
xfer
<
labelList
>&
neighbour
,
const
bool
syncPar
)
:
objectRegistry
(
io
),
primitiveMesh
(),
points_
(
IOobject
(
"points"
,
instance
(),
meshSubDir
,
*
this
,
IOobject
::
NO_READ
,
IOobject
::
AUTO_WRITE
),
points
),
faces_
(
IOobject
(
"faces"
,
instance
(),
meshSubDir
,
*
this
,
IOobject
::
NO_READ
,
IOobject
::
AUTO_WRITE
),
faces
),
owner_
(
IOobject
(
"owner"
,
instance
(),
meshSubDir
,
*
this
,
IOobject
::
NO_READ
,
IOobject
::
AUTO_WRITE
),
owner
),
neighbour_
(
IOobject
(
"neighbour"
,
instance
(),
meshSubDir
,
*
this
,
IOobject
::
NO_READ
,
IOobject
::
AUTO_WRITE
),
neighbour
),
clearedPrimitives_
(
false
),
boundary_
(
IOobject
(
"boundary"
,
instance
(),
meshSubDir
,
*
this
,
IOobject
::
NO_READ
,
IOobject
::
AUTO_WRITE
),
*
this
,
0
),
bounds_
(
points_
,
syncPar
),
directions_
(
Vector
<
label
>::
zero
),
pointZones_
(
IOobject
(
"pointZones"
,
instance
(),
meshSubDir
,
*
this
,
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
),
*
this
,
0
),
faceZones_
(
IOobject
(
"faceZones"
,
instance
(),
meshSubDir
,
*
this
,
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
),
*
this
,
0
),
cellZones_
(
IOobject
(
"cellZones"
,
instance
(),
meshSubDir
,
*
this
,
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
),
*
this
,
0
),
globalMeshDataPtr_
(
NULL
),
moving_
(
false
),
changing_
(
false
),
curMotionTimeIndex_
(
time
().
timeIndex
()),
oldPointsPtr_
(
NULL
)
{
// Check if the faces and cells are valid
forAll
(
faces_
,
faceI
)
{
const
face
&
curFace
=
faces_
[
faceI
];
if
(
min
(
curFace
)
<
0
||
max
(
curFace
)
>
points_
.
size
())
{
FatalErrorIn
(
"polyMesh::polyMesh
\n
"
"(
\n
"
" const IOobject& io,
\n
"
" const pointField& points,
\n
"
" const faceList& faces,
\n
"
" const cellList& cells
\n
"
")
\n
"
)
<<
"Face "
<<
faceI
<<
"contains vertex labels out of range: "
<<
curFace
<<
" Max point index = "
<<
points_
.
size
()
<<
abort
(
FatalError
);
}
}
// Set the primitive mesh
initMesh
();
}
Foam
::
polyMesh
::
polyMesh
(
const
IOobject
&
io
,
...
...
@@ -602,6 +758,185 @@ Foam::polyMesh::polyMesh
}
Foam
::
polyMesh
::
polyMesh
(
const
IOobject
&
io
,
const
xfer
<
pointField
>&
points
,
const
xfer
<
faceList
>&
faces
,
const
xfer
<
cellList
>&
cells
,
const
bool
syncPar
)
:
objectRegistry
(
io
),
primitiveMesh
(),
points_
(
IOobject
(
"points"
,
instance
(),
meshSubDir
,
*
this
,
IOobject
::
NO_READ
,
IOobject
::
AUTO_WRITE
),
points
),
faces_
(
IOobject
(
"faces"
,
instance
(),
meshSubDir
,
*
this
,
IOobject
::
NO_READ
,
IOobject
::
AUTO_WRITE
),
faces
),
owner_
(
IOobject
(
"owner"
,
instance
(),
meshSubDir
,
*
this
,
IOobject
::
NO_READ
,
IOobject
::
AUTO_WRITE
),
0
),
neighbour_
(
IOobject
(
"neighbour"
,
instance
(),
meshSubDir
,
*
this
,
IOobject
::
NO_READ
,
IOobject
::
AUTO_WRITE
),
0
),
clearedPrimitives_
(
false
),
boundary_
(
IOobject
(
"boundary"
,
instance
(),
meshSubDir
,
*
this
,
IOobject
::
NO_READ
,
IOobject
::
AUTO_WRITE
),
*
this
,
0
),
bounds_
(
points_
,
syncPar
),
directions_
(
Vector
<
label
>::
zero
),
pointZones_
(
IOobject
(
"pointZones"
,
instance
(),
meshSubDir
,
*
this
,
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
),
*
this
,
0
),
faceZones_
(
IOobject
(
"faceZones"
,
instance
(),
meshSubDir
,
*
this
,
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
),
*
this
,
0
),
cellZones_
(
IOobject
(
"cellZones"
,
instance
(),
meshSubDir
,
*
this
,
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
),
*
this
,
0
),
globalMeshDataPtr_
(
NULL
),
moving_
(
false
),
changing_
(
false
),
curMotionTimeIndex_
(
time
().
timeIndex
()),
oldPointsPtr_
(
NULL
)
{
// Check if faces are valid
forAll
(
faces_
,
faceI
)
{
const
face
&
curFace
=
faces_
[
faceI
];
if
(
min
(
curFace
)
<
0
||
max
(
curFace
)
>
points_
.
size
())
{
FatalErrorIn
(
"polyMesh::polyMesh
\n
"
"(
\n
"
" const IOobject&,
\n
"
" const xfer<pointField>&,
\n
"
" const xfer<faceList>&,
\n
"
" const xfer<cellList>&
\n
"
")
\n
"
)
<<
"Face "
<<
faceI
<<
"contains vertex labels out of range: "
<<
curFace
<<
" Max point index = "
<<
points_
.
size
()
<<
abort
(
FatalError
);
}
}
const
cellList
&
cLst
=
cells
();
// Check if cells are valid
forAll
(
cLst
,
cellI
)
{
const
cell
&
curCell
=
cLst
[
cellI
];
if
(
min
(
curCell
)
<
0
||
max
(
curCell
)
>
faces_
.
size
())
{
FatalErrorIn
(
"polyMesh::polyMesh
\n
"
"(
\n
"
" const IOobject&,
\n
"
" const xfer<pointField>&,
\n
"
" const xfer<faceList>&,
\n
"
" const xfer<cellList>&
\n
"
")
\n
"
)
<<
"Cell "
<<
cellI
<<
"contains face labels out of range: "
<<
curCell
<<
" Max face index = "
<<
faces_
.
size
()
<<
abort
(
FatalError
);
}
}
// Set the primitive mesh
initMesh
(
cells
);
}
void
Foam
::
polyMesh
::
resetPrimitives
(
const
label
nUsedFaces
,
...
...
@@ -719,6 +1054,111 @@ void Foam::polyMesh::resetPrimitives
}
void
Foam
::
polyMesh
::
resetPrimitives
(
const
label
nUsedFaces
,
const
xfer
<
pointField
>&
points
,
const
xfer
<
faceList
>&
faces
,
const
xfer
<
labelList
>&
owner
,
const
xfer
<
labelList
>&
neighbour
,
const
labelList
&
patchSizes
,
const
labelList
&
patchStarts
,
const
bool
validBoundary
)
{
// Clear addressing. Keep geometric props for mapping.
clearAddressing
();
// Take over new primitive data.
points_
.
transfer
(
points
());
bounds_
=
boundBox
(
points_
,
validBoundary
);
faces_
.
transfer
(
faces
());
owner_
.
transfer
(
owner
());
neighbour_
.
transfer
(
neighbour
());
// Reset patch sizes and starts
forAll
(
boundary_
,
patchI
)
{
boundary_
[
patchI
]
=
polyPatch
(
boundary_
[
patchI
].
name
(),
patchSizes
[
patchI
],
patchStarts
[
patchI
],
patchI
,
boundary_
);
}
// Flags the mesh files as being changed
setInstance
(
time
().
timeName
());
// Check if the faces and cells are valid
forAll
(
faces_
,
faceI
)
{
const
face
&
curFace
=
faces_
[
faceI
];
if
(
min
(
curFace
)
<
0
||
max
(
curFace
)
>
points_
.
size
())
{
FatalErrorIn
(
"polyMesh::polyMesh::resetPrimitives
\n
"
"(
\n
"
" const label nUsedFaces,
\n
"
" const xfer<pointField>&,
\n
"
" const xfer<faceList>&,
\n
"
" const xfer<labelList>& owner,
\n
"
" const xfer<labelList>& neighbour,
\n
"
" const labelList& patchSizes,
\n
"
" const labelList& patchStarts
\n
"
")
\n
"
)
<<
"Face "
<<
faceI
<<
" contains vertex labels out of range: "
<<
curFace
<<
" Max point index = "
<<
points_
.
size
()
<<
abort
(
FatalError
);
}
}
// Set the primitive mesh from the owner_, neighbour_. Works
// out from patch end where the active faces stop.
initMesh
();
if
(
validBoundary
)
{
// Note that we assume that all the patches stay the same and are
// correct etc. so we can already use the patches to do
// processor-processor comms.
// Calculate topology for the patches (processor-processor comms etc.)
boundary_
.
updateMesh
();
// Calculate the geometry for the patches (transformation tensors etc.)
boundary_
.
calcGeometry
();
// Warn if global empty mesh (constructs globalData!)
if
(
globalData
().
nTotalPoints
()
==
0
||
globalData
().
nTotalCells
()
==
0
)
{
FatalErrorIn
(
"polyMesh::polyMesh::resetPrimitives
\n
"
"(
\n
"
" const label nUsedFaces,
\n
"
" const xfer<pointField>&,
\n
"
" const xfer<faceList>&,
\n
"
" const xfer<labelList>& owner,
\n
"
" const xfer<labelList>& neighbour,
\n
"
" const labelList& patchSizes,
\n
"
" const labelList& patchStarts
\n
"
")
\n
"
)
<<
"no points or no cells in mesh"
<<
endl
;
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam
::
polyMesh
::~
polyMesh
()
...
...
src/OpenFOAM/meshes/polyMesh/polyMesh.H
View file @
d2a2f27b
...
...
@@ -170,6 +170,9 @@ private:
//- Initialise the polyMesh from the given set of cells
void
initMesh
(
cellList
&
c
);
//- Initialise the polyMesh from the given set of cells
void
initMesh
(
const
xfer
<
cellList
>&
c
);
//- Calculate the valid directions in the mesh from the boundaries
void
calcDirections
()
const
;
...
...
@@ -226,6 +229,18 @@ public:
const
bool
syncPar
=
true
);
//- Construct without boundary from components.
// Boundary is added using addPatches() member function
polyMesh
(
const
IOobject
&
io
,
const
xfer
<
pointField
>&
points
,
const
xfer
<
faceList
>&
faces
,
const
xfer
<
labelList
>&
owner
,
const
xfer
<
labelList
>&
neighbour
,
const
bool
syncPar
=
true
);
//- Construct without boundary with cells rather than owner/neighbour.
// Boundary is added using addPatches() member function
polyMesh
...
...
@@ -237,6 +252,17 @@ public:
const
bool
syncPar
=
true
);
//- Construct without boundary with cells rather than owner/neighbour.
// Boundary is added using addPatches() member function
polyMesh
(
const
IOobject
&
io
,
const
xfer
<
pointField
>&
points
,
const
xfer
<
faceList
>&
faces
,
const
xfer
<
cellList
>&
cells
,
const
bool
syncPar
=
true
);
//- Construct from cell shapes
polyMesh
(
...
...
@@ -444,6 +470,23 @@ public:
const
bool
validBoundary
=
true
);
//- Reset mesh primitive data. Assumes all patch info correct
// (so does e.g. parallel communication). If not use
// validBoundary=false
// (still assumes patchStarts[0] = nInternalFaces and last
// patch ends at nActiveFaces) and change patches with addPatches.
void
resetPrimitives
(
const
label
nUsedFaces
,
const
xfer
<
pointField
>&
points
,
const
xfer
<
faceList
>&
faces
,
const
xfer
<
labelList
>&
owner
,
const
xfer
<
labelList
>&
neighbour
,
const
labelList
&
patchSizes
,
const
labelList
&
patchStarts
,
const
bool
validBoundary
=
true
);
// Storage management
...
...
src/OpenFOAM/meshes/polyMesh/polyMeshInitMesh.C
View file @
d2a2f27b
...
...
@@ -155,4 +155,10 @@ void Foam::polyMesh::initMesh(cellList& c)
}
void
Foam
::
polyMesh
::
initMesh
(
const
xfer
<
cellList
>&
clst
)
{
initMesh
(
clst
());
}
// ************************************************************************* //
src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C
View file @
d2a2f27b
...
...
@@ -29,16 +29,15 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace
Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug
(
primitiveMesh
,
0
);
defineTypeNameAndDebug
(
primitiveMesh
,
0
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
primitiveMesh
::
primitiveMesh
()
Foam
::
primitiveMesh
::
primitiveMesh
()
:
nInternalPoints_
(
0
),
// note: points are considered ordered on empty mesh
nPoints_
(
0
),
...
...
@@ -76,8 +75,8 @@ primitiveMesh::primitiveMesh()
// Construct from components
// WARNING: ASSUMES CORRECT ORDERING OF DATA.
primitiveMesh
::
primitiveMesh
// WARNING: ASSUMES CORRECT ORDERING OF DATA.
Foam
::
primitiveMesh
::
primitiveMesh
(
const
label
nPoints
,
const
label
nInternalFaces
,
...
...
@@ -114,14 +113,12 @@ primitiveMesh::primitiveMesh
faceCentresPtr_
(
NULL
),
cellVolumesPtr_
(
NULL
),
faceAreasPtr_
(
NULL
)
{
}
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
primitiveMesh
::~
primitiveMesh
()
Foam
::
primitiveMesh
::~
primitiveMesh
()
{
clearOut
();
}
...
...
@@ -129,7 +126,7 @@ primitiveMesh::~primitiveMesh()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool
primitiveMesh
::
calcPointOrder
bool
Foam
::
primitiveMesh
::
calcPointOrder
(
label
&
nInternalPoints
,
labelList
&
oldToNew
,
...
...
@@ -208,7 +205,7 @@ bool primitiveMesh::calcPointOrder
}
void
primitiveMesh
::
reset
void
Foam
::
primitiveMesh
::
reset
(
const
label
nPoints
,
const
label
nInternalFaces
,
...
...
@@ -264,13 +261,13 @@ void primitiveMesh::reset
}
void
primitiveMesh
::
reset
void
Foam
::
primitiveMesh
::
reset
(
const
label
nPoints
,
const
label
nInternalFaces
,
const
label
nFaces
,
const
label
nCells
,
cellList
&
c
cellList
&
c
lst
)
{
reset
...
...
@@ -281,11 +278,32 @@ void primitiveMesh::reset
nCells
);
cfPtr_
=