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
357f2ed0
Commit
357f2ed0
authored
Mar 25, 2013
by
mattijs
Browse files
ENH: MeshObject: added debug output
parent
4ecfe5a4
Changes
10
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/Make/files
View file @
357f2ed0
...
...
@@ -367,6 +367,8 @@ $(cellShape)/cellShapeIOList.C
meshes/Identifiers/patch/patchIdentifier.C
meshes/MeshObject/meshObject.C
polyMesh = meshes/polyMesh
polyPatches = $(polyMesh)/polyPatches
...
...
src/OpenFOAM/meshes/MeshObject/MeshObject.C
View file @
357f2ed0
...
...
@@ -25,6 +25,7 @@ License
#include
"MeshObject.H"
#include
"objectRegistry.H"
#include
"IOstreams.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
...
...
@@ -59,6 +60,11 @@ const Type& Foam::MeshObject<Mesh, MeshObjectType, Type>::New
}
else
{
if
(
meshObject
::
debug
)
{
Pout
<<
"MeshObject::New(const Mesh&) : constructing new "
<<
Type
::
typeName
<<
endl
;
}
return
regIOobject
::
store
(
new
Type
(
mesh
));
}
}
...
...
@@ -87,6 +93,11 @@ const Type& Foam::MeshObject<Mesh, MeshObjectType, Type>::New
}
else
{
if
(
meshObject
::
debug
)
{
Pout
<<
"MeshObject::New(const Mesh&) : constructing new "
<<
Type
::
typeName
<<
endl
;
}
return
regIOobject
::
store
(
new
Type
(
mesh
,
d
));
}
}
...
...
@@ -116,6 +127,11 @@ const Type& Foam::MeshObject<Mesh, MeshObjectType, Type>::New
}
else
{
if
(
meshObject
::
debug
)
{
Pout
<<
"MeshObject(const Mesh&) : constructing new "
<<
Type
::
typeName
<<
endl
;
}
return
regIOobject
::
store
(
new
Type
(
mesh
,
d1
,
d2
));
}
}
...
...
@@ -146,6 +162,11 @@ const Type& Foam::MeshObject<Mesh, MeshObjectType, Type>::New
}
else
{
if
(
meshObject
::
debug
)
{
Pout
<<
"MeshObject(const Mesh&) : constructing new "
<<
Type
::
typeName
<<
endl
;
}
return
regIOobject
::
store
(
new
Type
(
mesh
,
d1
,
d2
,
d3
));
}
}
...
...
@@ -177,6 +198,11 @@ const Type& Foam::MeshObject<Mesh, MeshObjectType, Type>::New
}
else
{
if
(
meshObject
::
debug
)
{
Pout
<<
"MeshObject(const Mesh&) : constructing new "
<<
Type
::
typeName
<<
endl
;
}
return
regIOobject
::
store
(
new
Type
(
mesh
,
d1
,
d2
,
d3
,
d4
));
}
}
...
...
@@ -195,6 +221,12 @@ bool Foam::MeshObject<Mesh, MeshObjectType, Type>::Delete(const Mesh& mesh)
)
)
{
if
(
meshObject
::
debug
)
{
Pout
<<
"MeshObject::Delete(const Mesh&) : deleting "
<<
Type
::
typeName
<<
endl
;
}
return
mesh
.
thisDb
().
checkOut
(
const_cast
<
Type
&>
...
...
@@ -237,10 +269,22 @@ void Foam::meshObject::movePoints(objectRegistry& obr)
{
if
(
isA
<
MoveableMeshObject
<
Mesh
>
>
(
*
iter
()))
{
if
(
meshObject
::
debug
)
{
Pout
<<
"meshObject::movePoints(objectRegistry&) :"
<<
" movePoints on "
<<
iter
()
->
name
()
<<
endl
;
}
dynamic_cast
<
MoveableMeshObject
<
Mesh
>*>
(
iter
())
->
movePoints
();
}
else
{
if
(
meshObject
::
debug
)
{
Pout
<<
"meshObject::movePoints(objectRegistry&) :"
<<
" destroying "
<<
iter
()
->
name
()
<<
endl
;
}
obr
.
checkOut
(
*
iter
());
}
}
...
...
@@ -264,10 +308,21 @@ void Foam::meshObject::updateMesh(objectRegistry& obr, const mapPolyMesh& mpm)
{
if
(
isA
<
UpdateableMeshObject
<
Mesh
>
>
(
*
iter
()))
{
if
(
meshObject
::
debug
)
{
Pout
<<
"meshObject::updateMesh(objectRegistry&) :"
<<
" updateMesh on "
<<
iter
()
->
name
()
<<
endl
;
}
dynamic_cast
<
UpdateableMeshObject
<
Mesh
>*>
(
iter
())
->
updateMesh
(
mpm
);
}
else
{
if
(
meshObject
::
debug
)
{
Pout
<<
"meshObject::updateMesh(objectRegistry&) : destroying "
<<
iter
()
->
name
()
<<
endl
;
}
obr
.
checkOut
(
*
iter
());
}
}
...
...
@@ -284,6 +339,11 @@ void Foam::meshObject::clear(objectRegistry& obr)
forAllIter
(
typename
HashTable
<
MeshObjectType
<
Mesh
>*>
,
meshObjects
,
iter
)
{
if
(
meshObject
::
debug
)
{
Pout
<<
"meshObject::clear(objectRegistry&) : destroying "
<<
iter
()
->
name
()
<<
endl
;
}
obr
.
checkOut
(
*
iter
());
}
}
...
...
src/OpenFOAM/meshes/MeshObject/MeshObject.H
View file @
357f2ed0
...
...
@@ -164,20 +164,12 @@ class meshObject
{
public:
// Declare name of the class and its debug switch
ClassName
(
"meshObject"
);
// Constructors
meshObject
(
const
word
&
typeName
,
const
objectRegistry
&
obr
)
:
regIOobject
(
IOobject
(
typeName
,
obr
.
instance
(),
obr
)
)
{}
meshObject
(
const
word
&
typeName
,
const
objectRegistry
&
obr
);
// Static member functions
...
...
src/OpenFOAM/meshes/MeshObject/meshObject.C
0 → 100644
View file @
357f2ed0
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ 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
"MeshObject.H"
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
namespace
Foam
{
defineTypeNameAndDebug
(
meshObject
,
0
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam
::
meshObject
::
meshObject
(
const
word
&
typeName
,
const
objectRegistry
&
obr
)
:
regIOobject
(
IOobject
(
typeName
,
obr
.
instance
(),
obr
)
)
{}
// ************************************************************************* //
src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedFieldFvPatchField.C
View file @
357f2ed0
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011
-2013
OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
...
...
@@ -42,12 +42,9 @@ mappedFieldFvPatchField<Type>::mappedFieldFvPatchField
const
DimensionedField
<
Type
,
volMesh
>&
iF
)
:
mappedPatchBase
(
p
.
patch
()),
fixedValueFvPatchField
<
Type
>
(
p
,
iF
),
fieldName_
(
iF
.
name
()),
setAverage_
(
false
),
average_
(
pTraits
<
Type
>::
zero
),
interpolationScheme_
(
interpolationCell
<
Type
>::
typeName
)
mappedPatchBase
(
p
.
patch
()),
mappedPatchFieldBase
<
Type
>
(
*
this
,
*
this
)
{}
...
...
@@ -60,12 +57,9 @@ mappedFieldFvPatchField<Type>::mappedFieldFvPatchField
const
fvPatchFieldMapper
&
mapper
)
:
mappedPatchBase
(
p
.
patch
(),
ptf
),
fixedValueFvPatchField
<
Type
>
(
ptf
,
p
,
iF
,
mapper
),
fieldName_
(
ptf
.
fieldName_
),
setAverage_
(
ptf
.
setAverage_
),
average_
(
ptf
.
average_
),
interpolationScheme_
(
ptf
.
interpolationScheme_
)
mappedPatchBase
(
p
.
patch
(),
ptf
),
mappedPatchFieldBase
<
Type
>
(
*
this
,
*
this
,
ptf
)
{}
...
...
@@ -77,18 +71,10 @@ mappedFieldFvPatchField<Type>::mappedFieldFvPatchField
const
dictionary
&
dict
)
:
mappedPatchBase
(
p
.
patch
(),
dict
),
fixedValueFvPatchField
<
Type
>
(
p
,
iF
,
dict
),
fieldName_
(
dict
.
template
lookupOrDefault
<
word
>
(
"fieldName"
,
iF
.
name
())),
setAverage_
(
readBool
(
dict
.
lookup
(
"setAverage"
))),
average_
(
pTraits
<
Type
>
(
dict
.
lookup
(
"average"
))),
interpolationScheme_
(
interpolationCell
<
Type
>::
typeName
)
{
if
(
mode
()
==
mappedPatchBase
::
NEARESTCELL
)
{
dict
.
lookup
(
"interpolationScheme"
)
>>
interpolationScheme_
;
}
}
mappedPatchBase
(
p
.
patch
(),
dict
),
mappedPatchFieldBase
<
Type
>
(
*
this
,
*
this
,
dict
)
{}
template
<
class
Type
>
...
...
@@ -110,6 +96,7 @@ mappedFieldFvPatchField<Type>::mappedFieldFvPatchField
const
word
&
interpolationScheme
)
:
fixedValueFvPatchField
<
Type
>
(
p
,
iF
),
mappedPatchBase
(
p
.
patch
(),
...
...
@@ -118,11 +105,15 @@ mappedFieldFvPatchField<Type>::mappedFieldFvPatchField
samplePatch
,
distance
),
fixedValueFvPatchField
<
Type
>
(
p
,
iF
),
fieldName_
(
fieldName
),
setAverage_
(
setAverage
),
average_
(
average
),
interpolationScheme_
(
interpolationScheme
)
mappedPatchFieldBase
<
Type
>
(
*
this
,
*
this
,
fieldName
,
setAverage
,
average
,
interpolationScheme
)
{}
...
...
@@ -132,12 +123,9 @@ mappedFieldFvPatchField<Type>::mappedFieldFvPatchField
const
mappedFieldFvPatchField
<
Type
>&
ptf
)
:
mappedPatchBase
(
ptf
.
patch
().
patch
(),
ptf
),
fixedValueFvPatchField
<
Type
>
(
ptf
),
fieldName_
(
ptf
.
fieldName_
),
setAverage_
(
ptf
.
setAverage_
),
average_
(
ptf
.
average_
),
interpolationScheme_
(
ptf
.
interpolationScheme_
)
mappedPatchBase
(
ptf
.
patch
().
patch
(),
ptf
),
mappedPatchFieldBase
<
Type
>
(
ptf
)
{}
...
...
@@ -148,65 +136,14 @@ mappedFieldFvPatchField<Type>::mappedFieldFvPatchField
const
DimensionedField
<
Type
,
volMesh
>&
iF
)
:
mappedPatchBase
(
ptf
.
patch
().
patch
(),
ptf
),
fixedValueFvPatchField
<
Type
>
(
ptf
,
iF
),
fieldName_
(
ptf
.
fieldName_
),
setAverage_
(
ptf
.
setAverage_
),
average_
(
ptf
.
average_
),
interpolationScheme_
(
ptf
.
interpolationScheme_
)
mappedPatchBase
(
ptf
.
patch
().
patch
(),
ptf
),
mappedPatchFieldBase
<
Type
>
(
*
this
,
*
this
,
ptf
)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
<
class
Type
>
const
GeometricField
<
Type
,
fvPatchField
,
volMesh
>&
mappedFieldFvPatchField
<
Type
>::
sampleField
()
const
{
typedef
GeometricField
<
Type
,
fvPatchField
,
volMesh
>
fieldType
;
const
fvMesh
&
nbrMesh
=
refCast
<
const
fvMesh
>
(
sampleMesh
());
if
(
sameRegion
())
{
if
(
fieldName_
==
this
->
dimensionedInternalField
().
name
())
{
// Optimisation: bypass field lookup
return
dynamic_cast
<
const
fieldType
&>
(
this
->
dimensionedInternalField
()
);
}
else
{
const
fvMesh
&
thisMesh
=
this
->
patch
().
boundaryMesh
().
mesh
();
return
thisMesh
.
template
lookupObject
<
fieldType
>
(
fieldName_
);
}
}
else
{
return
nbrMesh
.
template
lookupObject
<
fieldType
>
(
fieldName_
);
}
}
template
<
class
Type
>
const
interpolation
<
Type
>&
mappedFieldFvPatchField
<
Type
>::
interpolator
()
const
{
if
(
!
interpolator_
.
valid
())
{
interpolator_
=
interpolation
<
Type
>::
New
(
interpolationScheme_
,
sampleField
()
);
}
return
interpolator_
();
}
template
<
class
Type
>
void
mappedFieldFvPatchField
<
Type
>::
updateCoeffs
()
{
...
...
@@ -215,132 +152,7 @@ void mappedFieldFvPatchField<Type>::updateCoeffs()
return
;
}
typedef
GeometricField
<
Type
,
fvPatchField
,
volMesh
>
fieldType
;
// Since we're inside initEvaluate/evaluate there might be processor
// comms underway. Change the tag we use.
int
oldTag
=
UPstream
::
msgType
();
UPstream
::
msgType
()
=
oldTag
+
1
;
const
fvMesh
&
thisMesh
=
this
->
patch
().
boundaryMesh
().
mesh
();
const
fvMesh
&
nbrMesh
=
refCast
<
const
fvMesh
>
(
sampleMesh
());
// Result of obtaining remote values
Field
<
Type
>
newValues
;
switch
(
mode
())
{
case
NEARESTCELL
:
{
const
mapDistribute
&
mapDist
=
this
->
mappedPatchBase
::
map
();
if
(
interpolationScheme_
!=
interpolationCell
<
Type
>::
typeName
)
{
// Need to do interpolation so need cells to sample
// Send back sample points to the processor that holds the cell
vectorField
samples
(
samplePoints
());
mapDist
.
reverseDistribute
(
(
sameRegion
()
?
thisMesh
.
nCells
()
:
nbrMesh
.
nCells
()),
point
::
max
,
samples
);
const
interpolation
<
Type
>&
interp
=
interpolator
();
newValues
.
setSize
(
samples
.
size
(),
pTraits
<
Type
>::
max
);
forAll
(
samples
,
cellI
)
{
if
(
samples
[
cellI
]
!=
point
::
max
)
{
newValues
[
cellI
]
=
interp
.
interpolate
(
samples
[
cellI
],
cellI
);
}
}
}
else
{
newValues
=
sampleField
();
}
mapDist
.
distribute
(
newValues
);
break
;
}
case
NEARESTPATCHFACE
:
case
NEARESTPATCHFACEAMI
:
{
const
label
nbrPatchID
=
nbrMesh
.
boundaryMesh
().
findPatchID
(
samplePatch
());
if
(
nbrPatchID
<
0
)
{
FatalErrorIn
(
"void mappedFieldFvPatchField<Type>::updateCoeffs()"
)
<<
"Unable to find sample patch "
<<
samplePatch
()
<<
" in region "
<<
sampleRegion
()
<<
" for patch "
<<
this
->
patch
().
name
()
<<
nl
<<
abort
(
FatalError
);
}
const
fieldType
&
nbrField
=
sampleField
();
newValues
=
nbrField
.
boundaryField
()[
nbrPatchID
];
this
->
distribute
(
newValues
);
break
;
}
case
NEARESTFACE
:
{
Field
<
Type
>
allValues
(
nbrMesh
.
nFaces
(),
pTraits
<
Type
>::
zero
);
const
fieldType
&
nbrField
=
sampleField
();
forAll
(
nbrField
.
boundaryField
(),
patchI
)
{
const
fvPatchField
<
Type
>&
pf
=
nbrField
.
boundaryField
()[
patchI
];
label
faceStart
=
pf
.
patch
().
patch
().
start
();
forAll
(
pf
,
faceI
)
{
allValues
[
faceStart
++
]
=
pf
[
faceI
];
}
}
this
->
distribute
(
allValues
);
newValues
.
transfer
(
allValues
);
break
;
}
default:
{
FatalErrorIn
(
"mappedFieldFvPatchField<Type>::updateCoeffs()"
)
<<
"Unknown sampling mode: "
<<
mode
()
<<
nl
<<
abort
(
FatalError
);
}
}
if
(
setAverage_
)
{
Type
averagePsi
=
gSum
(
this
->
patch
().
magSf
()
*
newValues
)
/
gSum
(
this
->
patch
().
magSf
());
if
(
mag
(
averagePsi
)
/
mag
(
average_
)
>
0
.
5
)
{
newValues
*=
mag
(
average_
)
/
mag
(
averagePsi
);
}
else
{
newValues
+=
(
average_
-
averagePsi
);
}
}
this
->
operator
==
(
newValues
);
this
->
operator
==
(
this
->
mappedField
());
if
(
debug
)
{
...
...
@@ -352,9 +164,6 @@ void mappedFieldFvPatchField<Type>::updateCoeffs()
<<
endl
;
}
// Restore tag
UPstream
::
msgType
()
=
oldTag
;
fixedValueFvPatchField
<
Type
>::
updateCoeffs
();
}
...
...
@@ -364,11 +173,7 @@ void mappedFieldFvPatchField<Type>::write(Ostream& os) const
{
fvPatchField
<
Type
>::
write
(
os
);
mappedPatchBase
::
write
(
os
);
os
.
writeKeyword
(
"fieldName"
)
<<
fieldName_
<<
token
::
END_STATEMENT
<<
nl
;
os
.
writeKeyword
(
"setAverage"
)
<<
setAverage_
<<
token
::
END_STATEMENT
<<
nl
;
os
.
writeKeyword
(
"average"
)
<<
average_
<<
token
::
END_STATEMENT
<<
nl
;
os
.
writeKeyword
(
"interpolationScheme"
)
<<
interpolationScheme_
<<
token
::
END_STATEMENT
<<
nl
;
mappedPatchFieldBase
<
Type
>::
write
(
os
);
this
->
writeEntry
(
"value"
,
os
);
}
...
...
src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedFieldFvPatchField.H
View file @
357f2ed0
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-201
2
OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-201
3
OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
...
...
@@ -75,6 +75,7 @@ SourceFiles
#define mappedFieldFvPatchField_H
#include
"mappedPatchBase.H"
#include
"mappedPatchFieldBase.H"
#include
"fixedValueFvPatchFields.H"
#include
"interpolation.H"
...
...
@@ -90,37 +91,10 @@ namespace Foam
template
<
class
Type
>
class
mappedFieldFvPatchField
:
public
fixedValueFvPatchField
<
Type
>
,
public
mappedPatchBase
,
public
fixedValueFv
PatchField
<
Type
>
public
mapped
PatchField
Base
<
Type
>
{
// Private data
//- Name of field to sample - defaults to field associated with this
// patchField if not specified
word
fieldName_
;
//- If true adjust the mapped field to maintain average value average_
const
bool
setAverage_
;
//- Average value the mapped field is adjusted to maintain if
// setAverage_ is set true
const
Type
average_
;
//- Interpolation scheme to use for nearestCell mode
word
interpolationScheme_
;
//- Pointer to the cell interpolator
mutable
autoPtr
<
interpolation
<
Type
>
>
interpolator_
;
// Private Member Functions
//- Field to sample. Either on my or nbr mesh
const
GeometricField
<
Type
,
fvPatchField
,
volMesh
>&
sampleField
()
const
;
//- Access the interpolation method
const
interpolation
<
Type
>&
interpolator
()
const
;