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-plus
Commits
dc1446d6
Commit
dc1446d6
authored
Jan 15, 2019
by
Mark Olesen
Browse files
ENH: add updateMesh(), movePoints() to volRegion
parent
671c4107
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/finiteVolume/functionObjects/volRegion/volRegion.C
View file @
dc1446d6
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-201
8
OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-201
9
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -51,6 +51,67 @@ Foam::functionObjects::volRegion::regionTypeNames_
});
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void
Foam
::
functionObjects
::
volRegion
::
calculateCache
()
{
regionID_
=
-
1
;
cellIds_
.
clear
();
switch
(
regionType_
)
{
case
vrtAll
:
{
nCells_
=
volMesh_
.
globalData
().
nTotalCells
();
V_
=
gSum
(
volMesh_
.
V
());
return
;
break
;
}
case
vrtCellSet
:
{
cellIds_
=
cellSet
(
volMesh_
,
regionName_
).
sortedToc
();
break
;
}
case
vrtCellZone
:
{
regionID_
=
volMesh_
.
cellZones
().
findZoneID
(
regionName_
);
if
(
regionID_
<
0
)
{
FatalErrorInFunction
<<
"Unknown cell zone name: "
<<
regionName_
<<
". Valid cell zones : "
<<
flatOutput
(
volMesh_
.
cellZones
().
names
())
<<
exit
(
FatalError
);
}
break
;
}
}
// Cached value for nCells()
nCells_
=
returnReduce
(
cellIDs
().
size
(),
sumOp
<
label
>
());
// Cached value for V()
V_
=
0
;
for
(
const
label
celli
:
cellIDs
())
{
V_
+=
volMesh_
.
V
()[
celli
];
}
reduce
(
V_
,
sumOp
<
scalar
>
());
if
(
!
nCells_
)
{
FatalErrorInFunction
<<
regionTypeNames_
[
regionType_
]
<<
"("
<<
regionName_
<<
"):"
<<
nl
<<
" Region has no cells"
<<
exit
(
FatalError
);
}
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void
Foam
::
functionObjects
::
volRegion
::
writeFileHeader
...
...
@@ -76,6 +137,9 @@ Foam::functionObjects::volRegion::volRegion
)
:
volMesh_
(
mesh
),
cellIds_
(),
nCells_
(
0
),
V_
(
Zero
),
regionType_
(
regionTypeNames_
.
lookupOrDefault
...
...
@@ -89,10 +153,6 @@ Foam::functionObjects::volRegion::volRegion
regionID_
(
-
1
)
{
read
(
dict
);
// Cache integral properties of the region for writeFileHeader
nCells_
=
nCells
();
V_
=
V
();
}
...
...
@@ -103,59 +163,18 @@ bool Foam::functionObjects::volRegion::read
const
dictionary
&
dict
)
{
regionID_
=
-
1
;
cellIds_
.
clear
();
switch
(
regionType_
)
{
case
vrt
CellSet
:
case
vrt
All
:
{
dict
.
readEntry
(
"name"
,
regionName_
);
cellIds_
=
cellSet
(
volMesh_
,
regionName_
).
sortedToc
();
if
(
nCells
()
==
0
)
{
FatalIOErrorInFunction
(
dict
)
<<
regionTypeNames_
[
regionType_
]
<<
"("
<<
regionName_
<<
"):"
<<
nl
<<
" Region has no cells"
<<
exit
(
FatalIOError
);
}
regionName_
=
volMesh_
.
name
();
break
;
}
case
vrtCellSet
:
case
vrtCellZone
:
{
dict
.
readEntry
(
"name"
,
regionName_
);
regionID_
=
volMesh_
.
cellZones
().
findZoneID
(
regionName_
);
if
(
regionID_
<
0
)
{
FatalIOErrorInFunction
(
dict
)
<<
"Unknown cell zone name: "
<<
regionName_
<<
". Valid cell zones : "
<<
flatOutput
(
volMesh_
.
cellZones
().
names
())
<<
exit
(
FatalIOError
);
}
if
(
nCells
()
==
0
)
{
FatalIOErrorInFunction
(
dict
)
<<
regionTypeNames_
[
regionType_
]
<<
"("
<<
regionName_
<<
"):"
<<
nl
<<
" Region has no cells"
<<
exit
(
FatalIOError
);
}
break
;
}
case
vrtAll
:
{
regionName_
=
volMesh_
.
name
();
break
;
}
...
...
@@ -165,9 +184,11 @@ bool Foam::functionObjects::volRegion::read
<<
"Unknown region type. Valid region types are:"
<<
flatOutput
(
regionTypeNames_
.
names
())
<<
nl
<<
exit
(
FatalIOError
);
break
;
}
}
calculateCache
();
return
true
;
}
...
...
@@ -192,35 +213,15 @@ const Foam::labelList& Foam::functionObjects::volRegion::cellIDs() const
}
Foam
::
label
Foam
::
functionObjects
::
volRegion
::
nCells
()
const
void
Foam
::
functionObjects
::
volRegion
::
updateMesh
(
const
mapPolyMesh
&
)
{
if
(
regionType_
==
vrtAll
)
{
return
volMesh_
.
globalData
().
nTotalCells
();
}
else
{
return
returnReduce
(
cellIDs
().
size
(),
sumOp
<
label
>
());
}
calculateCache
();
}
Foam
::
scalar
Foam
::
functionObjects
::
volRegion
::
V
()
const
void
Foam
::
functionObjects
::
volRegion
::
movePoints
(
const
polyMesh
&
)
{
if
(
regionType_
==
vrtAll
)
{
return
gSum
(
volMesh_
.
V
());
}
else
{
scalar
vol
=
0
;
for
(
const
label
celli
:
cellIDs
())
{
vol
+=
volMesh_
.
V
()[
celli
];
}
return
returnReduce
(
vol
,
sumOp
<
scalar
>
());
}
calculateCache
();
}
...
...
src/finiteVolume/functionObjects/volRegion/volRegion.H
View file @
dc1446d6
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-201
8
OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-201
9
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -80,6 +80,8 @@ namespace Foam
// Forward declarations
class
fvMesh
;
class
polyMesh
;
class
mapPolyMesh
;
namespace
functionObjects
{
...
...
@@ -97,12 +99,19 @@ class volRegion
//- The cell ids, from cellSet
labelList
cellIds_
;
// Cache
integral properties of the region for writeFileHeader
//
-
Cache
d total number of cells selected
label
nCells_
;
//- Cached total selection volume
scalar
V_
;
// Private Member Functions
//- Update cellIds, nCells, volume
void
calculateCache
();
public:
// Public data types
...
...
@@ -155,10 +164,7 @@ public:
virtual
~
volRegion
()
=
default
;
// Public Member Functions
//- Read from dictionary
bool
read
(
const
dictionary
&
dict
);
// Member Functions
//- Return the region type
inline
const
regionTypes
&
regionType
()
const
;
...
...
@@ -167,10 +173,20 @@ public:
const
labelList
&
cellIDs
()
const
;
//- Return the number of cells selected in the region
label
nCells
()
const
;
inline
label
nCells
()
const
;
//- Return total volume of the selected region
inline
scalar
V
()
const
;
//- Read from dictionary
virtual
bool
read
(
const
dictionary
&
dict
);
//- Update for changes of mesh
virtual
void
updateMesh
(
const
mapPolyMesh
&
);
//-
Return total volume of the reg
ion
scalar
V
()
const
;
//-
Update for mesh point-mot
ion
virtual
void
movePoints
(
const
polyMesh
&
)
;
};
...
...
src/finiteVolume/functionObjects/volRegion/volRegionI.H
View file @
dc1446d6
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation |
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -31,4 +31,17 @@ Foam::functionObjects::volRegion::regionType() const
return
regionType_
;
}
inline
Foam
::
label
Foam
::
functionObjects
::
volRegion
::
nCells
()
const
{
return
nCells_
;
}
inline
Foam
::
scalar
Foam
::
functionObjects
::
volRegion
::
V
()
const
{
return
V_
;
}
// ************************************************************************* //
Mark Olesen
@mark
mentioned in issue
#1194
·
Feb 06, 2019
mentioned in issue
#1194
mentioned in issue #1194
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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