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
09d9c5cc
Commit
09d9c5cc
authored
May 20, 2020
by
Mark OLESEN
Browse files
ENH: consistent autoPtr handling in PatchFunction1
parent
2659c48f
Changes
11
Hide whitespace changes
Inline
Side-by-side
etc/codeTemplates/dynamicCode/codedPatchFunction1Template.C
View file @
09d9c5cc
...
...
@@ -108,21 +108,21 @@ ${typeName}PatchFunction1${FieldType}
$
{
typeName
}
PatchFunction1
$
{
FieldType
}
::
$
{
typeName
}
PatchFunction1
$
{
FieldType
}
(
const
$
{
typeName
}
PatchFunction1
$
{
FieldType
}
&
ut
const
$
{
typeName
}
PatchFunction1
$
{
FieldType
}
&
rhs
)
:
PatchFunction1
<
$
{
TemplateType
}
>
(
ut
)
PatchFunction1
<
$
{
TemplateType
}
>
(
rhs
)
{}
$
{
typeName
}
PatchFunction1
$
{
FieldType
}
::
$
{
typeName
}
PatchFunction1
$
{
FieldType
}
(
const
$
{
typeName
}
PatchFunction1
$
{
FieldType
}
&
ut
,
const
$
{
typeName
}
PatchFunction1
$
{
FieldType
}
&
rhs
,
const
polyPatch
&
pp
)
:
PatchFunction1
<
$
{
TemplateType
}
>
(
ut
,
pp
)
PatchFunction1
<
$
{
TemplateType
}
>
(
rhs
,
pp
)
{}
...
...
@@ -137,7 +137,6 @@ ${typeName}PatchFunction1${FieldType}::value
//{{{ begin code
$
{
code
}
//}}} end code
}
...
...
etc/codeTemplates/dynamicCode/codedPatchFunction1Template.H
View file @
09d9c5cc
...
...
@@ -81,13 +81,13 @@ public:
const
bool
faceValues
=
true
);
//- Construct
as copy
//- Co
py co
nstruct
$
{
typeName
}
PatchFunction1
$
{
FieldType
}
(
const
$
{
typeName
}
PatchFunction1
$
{
FieldType
}
&
);
//- Construct
as copy
, resetting patch
//- Co
py co
nstruct, resetting patch
$
{
typeName
}
PatchFunction1
$
{
FieldType
}
(
const
$
{
typeName
}
PatchFunction1
$
{
FieldType
}
&
,
...
...
@@ -122,20 +122,20 @@ public:
// Member Functions
//- Return value as a function of (scalar) independent variable
virtual
tmp
<
Field
<
$
{
TemplateType
}
>>
value
(
const
scalar
x
)
const
;
//- Return value as a function of (scalar) independent variable
virtual
tmp
<
Field
<
$
{
TemplateType
}
>>
value
(
const
scalar
x
)
const
;
//- Is value constant (i.e. independent of x)
virtual
bool
constant
()
const
{
return
false
;
}
//- Is value constant (i.e. independent of x)
virtual
bool
constant
()
const
{
return
false
;
}
//- Is value uniform (i.e. independent of coordinate)
virtual
bool
uniform
()
const
{
return
false
;
}
//- Is value uniform (i.e. independent of coordinate)
virtual
bool
uniform
()
const
{
return
false
;
}
};
...
...
src/meshTools/PatchFunction1/CodedField/CodedField.C
View file @
09d9c5cc
...
...
@@ -105,13 +105,6 @@ Foam::PatchFunction1Types::CodedField<Type>::codeDict
?
dict
:
dict
.
subDict
(
name_
)
);
//return
//(
// dict.found(name_)
// ? dict.subDict(name_)
// : dict
//);
}
...
...
@@ -154,8 +147,7 @@ Foam::PatchFunction1Types::CodedField<Type>::CodedField
PatchFunction1
<
Type
>
(
pp
,
entryName
,
dict
,
faceValues
),
codedBase
(),
dict_
(
dict
),
//name_(dict.getCompat<word>("name", {{"redirectType", 1706}}))
name_
(
dict
.
lookupOrDefault
<
word
>
(
"name"
,
entryName
))
name_
(
dict
.
getOrDefault
<
word
>
(
"name"
,
entryName
))
{
updateLibrary
(
name_
);
}
...
...
@@ -164,27 +156,27 @@ Foam::PatchFunction1Types::CodedField<Type>::CodedField
template
<
class
Type
>
Foam
::
PatchFunction1Types
::
CodedField
<
Type
>::
CodedField
(
const
CodedField
<
Type
>&
ut
const
CodedField
<
Type
>&
rhs
)
:
PatchFunction1
<
Type
>
(
ut
),
PatchFunction1
<
Type
>
(
rhs
),
codedBase
(),
dict_
(
ut
.
dict_
),
name_
(
ut
.
name_
)
dict_
(
rhs
.
dict_
),
name_
(
rhs
.
name_
)
{}
template
<
class
Type
>
Foam
::
PatchFunction1Types
::
CodedField
<
Type
>::
CodedField
(
const
CodedField
<
Type
>&
ut
,
const
CodedField
<
Type
>&
rhs
,
const
polyPatch
&
pp
)
:
PatchFunction1
<
Type
>
(
ut
,
pp
),
PatchFunction1
<
Type
>
(
rhs
,
pp
),
codedBase
(),
dict_
(
ut
.
dict_
),
name_
(
ut
.
name_
)
dict_
(
rhs
.
dict_
),
name_
(
rhs
.
name_
)
{}
...
...
@@ -194,7 +186,7 @@ template<class Type>
const
Foam
::
PatchFunction1
<
Type
>&
Foam
::
PatchFunction1Types
::
CodedField
<
Type
>::
redirectFunction
()
const
{
if
(
!
redirectFunctionPtr_
.
valid
()
)
if
(
!
redirectFunctionPtr_
)
{
// Construct a PatchFunction1 containing the input code
dictionary
completeDict
(
dict_
);
...
...
@@ -206,7 +198,7 @@ Foam::PatchFunction1Types::CodedField<Type>::redirectFunction() const
dictionary
dict
;
dict
.
add
(
name_
,
completeDict
);
redirectFunctionPtr_
.
set
redirectFunctionPtr_
.
re
set
(
PatchFunction1
<
Type
>::
New
(
...
...
@@ -214,7 +206,7 @@ Foam::PatchFunction1Types::CodedField<Type>::redirectFunction() const
name_
,
dict
,
this
->
faceValues_
)
.
ptr
()
)
);
}
return
*
redirectFunctionPtr_
;
...
...
@@ -228,7 +220,7 @@ Foam::PatchFunction1Types::CodedField<Type>::value
const
scalar
x
)
const
{
//
Make
sure library containing user-defined
fvPatchField
is up-to-date
//
En
sure library containing user-defined
code
is up-to-date
updateLibrary
(
name_
);
return
redirectFunction
().
value
(
x
);
...
...
@@ -243,7 +235,7 @@ Foam::PatchFunction1Types::CodedField<Type>::integrate
const
scalar
x2
)
const
{
//
Make
sure library containing user-defined
fvPatchField
is up-to-date
//
En
sure library containing user-defined
code
is up-to-date
updateLibrary
(
name_
);
return
redirectFunction
().
integrate
(
x1
,
x2
);
...
...
src/meshTools/PatchFunction1/CodedField/CodedField.H
View file @
09d9c5cc
...
...
@@ -97,9 +97,9 @@ class CodedField
public
PatchFunction1
<
Type
>
,
protected
codedBase
{
// Private
d
ata
// Private
D
ata
//- Dictionary contents for the
boundary condi
tion
//- Dictionary contents for the
func
tion
const
dictionary
dict_
;
const
word
name_
;
...
...
@@ -136,7 +136,7 @@ class CodedField
public:
// Static
d
ata
m
embers
// Static
D
ata
M
embers
//- Name of the C code template to be used
static
constexpr
const
char
*
const
codeTemplateC
...
...
@@ -147,8 +147,7 @@ public:
=
"codedPatchFunction1Template.H"
;
// Runtime type information
//- Runtime type information
TypeName
(
"coded"
);
...
...
@@ -164,13 +163,13 @@ public:
const
bool
faceValues
=
true
);
//- Copy construct
or
explicit
CodedField
(
const
CodedField
<
Type
>&
ut
);
//- Copy construct
explicit
CodedField
(
const
CodedField
<
Type
>&
rhs
);
//- Copy construct
or
setting patch
//- Copy construct
,
setting patch
explicit
CodedField
(
const
CodedField
<
Type
>&
ut
,
const
CodedField
<
Type
>&
rhs
,
const
polyPatch
&
pp
);
...
...
src/meshTools/PatchFunction1/ConstantField/ConstantField.H
View file @
09d9c5cc
...
...
@@ -60,7 +60,7 @@ class ConstantField
:
public
PatchFunction1
<
Type
>
{
// Private
d
ata
// Private
D
ata
//- Is uniform?
bool
isUniform_
;
...
...
@@ -90,7 +90,7 @@ class ConstantField
public:
// Runtime type information
//
-
Runtime type information
TypeName
(
"constant"
);
...
...
@@ -118,7 +118,7 @@ public:
const
bool
faceValues
=
true
);
//- Copy construct
or
//- Copy construct
explicit
ConstantField
(
const
ConstantField
<
Type
>&
cnst
);
//- Copy constructor setting patch
...
...
src/meshTools/PatchFunction1/ConstantField/ConstantFieldI.H
View file @
09d9c5cc
...
...
@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -40,10 +41,8 @@ Foam::PatchFunction1Types::ConstantField<Type>::value
{
return
this
->
transform
(
value_
);
}
else
{
return
value_
;
}
return
value_
;
}
...
...
@@ -57,12 +56,10 @@ Foam::PatchFunction1Types::ConstantField<Type>::integrate
{
if
(
this
->
coordSys_
.
active
())
{
return
(
x2
-
x1
)
*
this
->
transform
(
value_
);
}
else
{
return
(
x2
-
x1
)
*
value_
;
return
(
x2
-
x1
)
*
this
->
transform
(
value_
);
}
return
(
x2
-
x1
)
*
value_
;
}
...
...
src/meshTools/PatchFunction1/MappedFile/AverageField.C
View file @
09d9c5cc
...
...
@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -40,11 +41,11 @@ Foam::AverageField<Type>::AverageField(const label size)
template
<
class
Type
>
Foam
::
AverageField
<
Type
>::
AverageField
(
const
Field
<
Type
>&
f
,
const
Field
<
Type
>&
f
ld
,
const
Type
&
average
)
:
Field
<
Type
>
(
f
),
Field
<
Type
>
(
f
ld
),
average_
(
average
)
{}
...
...
src/meshTools/PatchFunction1/MappedFile/AverageField.H
View file @
09d9c5cc
...
...
@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -53,7 +54,7 @@ class AverageField
:
public
Field
<
Type
>
{
// Private
d
ata
// Private
D
ata
//- The average of the field
Type
average_
;
...
...
@@ -64,16 +65,16 @@ public:
// Constructors
//- Construct from size (does not set values)
AverageField
(
const
label
size
);
explicit
AverageField
(
const
label
size
);
//- Construct from components
AverageField
(
const
Field
<
Type
>&
,
const
Type
&
average
);
AverageField
(
const
Field
<
Type
>&
fld
,
const
Type
&
average
);
//- Construct from Istream
AverageField
(
Istream
&
);
explicit
AverageField
(
Istream
&
is
);
// Member
f
unctions
// Member
F
unctions
const
Type
&
average
()
const
;
...
...
src/meshTools/PatchFunction1/MappedFile/MappedFile.C
View file @
09d9c5cc
...
...
@@ -45,7 +45,7 @@ Foam::PatchFunction1Types::MappedFile<Type>::MappedFile
dictConstructed_
(
true
),
fieldTableName_
(
entryName
),
setAverage_
(
dict
.
lookupOrDefault
(
"setAverage"
,
false
)),
perturb_
(
dict
.
lookupOrDefault
(
"perturb"
,
1e-5
)),
perturb_
(
dict
.
lookupOrDefault
<
scalar
>
(
"perturb"
,
1e-5
)),
pointsName_
(
dict
.
lookupOrDefault
<
word
>
(
"points"
,
"points"
)),
mapMethod_
(
...
...
@@ -63,7 +63,7 @@ Foam::PatchFunction1Types::MappedFile<Type>::MappedFile
endSampleTime_
(
-
1
),
endSampledValues_
(
0
),
endAverage_
(
Zero
),
offset_
()
offset_
(
nullptr
)
{
if
(
dict
.
found
(
"offset"
))
{
...
...
@@ -99,7 +99,7 @@ Foam::PatchFunction1Types::MappedFile<Type>::MappedFile
dictConstructed_
(
false
),
fieldTableName_
(
fieldTableName
),
setAverage_
(
dict
.
lookupOrDefault
(
"setAverage"
,
false
)),
perturb_
(
dict
.
lookupOrDefault
(
"perturb"
,
1e-5
)),
perturb_
(
dict
.
lookupOrDefault
<
scalar
>
(
"perturb"
,
1e-5
)),
pointsName_
(
dict
.
lookupOrDefault
<
word
>
(
"points"
,
"points"
)),
mapMethod_
(
...
...
@@ -117,7 +117,7 @@ Foam::PatchFunction1Types::MappedFile<Type>::MappedFile
endSampleTime_
(
-
1
),
endSampledValues_
(
0
),
endAverage_
(
Zero
),
offset_
()
offset_
(
nullptr
)
{
if
(
dict
.
found
(
"offset"
))
{
...
...
@@ -241,7 +241,7 @@ void Foam::PatchFunction1Types::MappedFile<Type>::checkTable
const
polyMesh
&
mesh
=
this
->
patch_
.
boundaryMesh
().
mesh
();
// Initialise
if
(
mapperPtr_
.
empty
()
)
if
(
!
mapperPtr_
)
{
// Reread values and interpolate
fileName
samplePointsFile
...
...
@@ -296,7 +296,6 @@ void Foam::PatchFunction1Types::MappedFile<Type>::checkTable
}
// Read the times for which data is available
const
fileName
samplePointsDir
=
samplePointsFile
.
path
();
sampleTimes_
=
Time
::
findTimes
(
samplePointsDir
);
...
...
@@ -479,7 +478,7 @@ Foam::PatchFunction1Types::MappedFile<Type>::value
checkTable
(
x
);
auto
tfld
=
tmp
<
Field
<
Type
>>::
New
(
startSampledValues_
.
size
());
Field
<
Type
>
&
fld
=
tfld
.
ref
();
auto
&
fld
=
tfld
.
ref
();
Type
wantedAverage
;
if
(
endSampleTime_
==
-
1
)
...
...
@@ -563,7 +562,7 @@ Foam::PatchFunction1Types::MappedFile<Type>::value
}
// Apply offset to mapped values
if
(
offset_
.
valid
()
)
if
(
offset_
)
{
fld
+=
offset_
->
value
(
x
);
}
...
...
@@ -600,8 +599,8 @@ void Foam::PatchFunction1Types::MappedFile<Type>::writeData
{
PatchFunction1
<
Type
>::
writeData
(
os
);
// Check if field name explicitly provided
(e.g. through timeVaryingMapped
// bc)
// Check if field name explicitly provided
//
(e.g. through timeVaryingMapped
bc)
if
(
dictConstructed_
)
{
os
.
writeEntry
(
this
->
name
(),
type
());
...
...
@@ -630,7 +629,7 @@ void Foam::PatchFunction1Types::MappedFile<Type>::writeData
mapMethod_
);
if
(
offset_
.
valid
()
)
if
(
offset_
)
{
offset_
->
writeData
(
os
);
}
...
...
src/meshTools/PatchFunction1/coordinateScaling.C
View file @
09d9c5cc
...
...
@@ -5,8 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -31,6 +30,8 @@ License
template
<
class
Type
>
Foam
::
coordinateScaling
<
Type
>::
coordinateScaling
()
:
coordSys_
(
nullptr
),
scale_
(),
active_
(
false
)
{}
...
...
@@ -49,9 +50,9 @@ Foam::coordinateScaling<Type>::coordinateScaling
:
nullptr
),
scale_
(
3
),
active_
(
coordSys_
.
valid
(
))
active_
(
bool
(
coordSys_
))
{
for
(
direction
dir
=
0
;
dir
<
vector
::
nComponents
;
dir
++
)
for
(
direction
dir
=
0
;
dir
<
vector
::
nComponents
;
++
dir
)
{
const
word
key
(
"scale"
+
Foam
::
name
(
dir
+
1
));
...
...
@@ -65,18 +66,11 @@ Foam::coordinateScaling<Type>::coordinateScaling
template
<
class
Type
>
Foam
::
coordinateScaling
<
Type
>::
coordinateScaling
(
const
coordinateScaling
&
c
s
)
Foam
::
coordinateScaling
<
Type
>::
coordinateScaling
(
const
coordinateScaling
&
rh
s
)
:
coordSys_
(
cs
.
coordSys_
.
clone
()),
scale_
(
cs
.
scale_
),
active_
(
cs
.
active_
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template
<
class
Type
>
Foam
::
coordinateScaling
<
Type
>::~
coordinateScaling
()
coordSys_
(
rhs
.
coordSys_
.
clone
()),
scale_
(
rhs
.
scale_
),
active_
(
rhs
.
active_
)
{}
...
...
@@ -89,13 +83,13 @@ Foam::tmp<Foam::Field<Type>> Foam::coordinateScaling<Type>::transform
const
Field
<
Type
>&
p0
)
const
{
tmp
<
Field
<
Type
>>
tfld
(
new
Field
<
Type
>
(
p0
)
)
;
Field
<
Type
>
&
fld
=
tfld
.
ref
();
auto
tfld
=
tmp
<
Field
<
Type
>>
::
New
(
p0
);
auto
&
fld
=
tfld
.
ref
();
if
(
coordSys_
.
valid
()
)
if
(
coordSys_
)
{
const
vectorField
local
(
coordSys_
->
localPosition
(
pos
));
for
(
direction
dir
=
0
;
dir
<
vector
::
nComponents
;
dir
++
)
for
(
direction
dir
=
0
;
dir
<
vector
::
nComponents
;
++
dir
)
{
if
(
scale_
.
set
(
dir
))
{
...
...
@@ -109,9 +103,9 @@ Foam::tmp<Foam::Field<Type>> Foam::coordinateScaling<Type>::transform
return
coordSys_
->
transform
(
pos
,
fld
);
}
else
else
if
(
scale_
.
size
())
{
for
(
direction
dir
=
0
;
dir
<
vector
::
nComponents
;
dir
++
)
for
(
direction
dir
=
0
;
dir
<
vector
::
nComponents
;
++
dir
)
{
if
(
scale_
.
set
(
dir
))
{
...
...
@@ -122,15 +116,16 @@ Foam::tmp<Foam::Field<Type>> Foam::coordinateScaling<Type>::transform
);
}
}
return
fld
;
}
return
tfld
;
}
template
<
class
Type
>
void
Foam
::
coordinateScaling
<
Type
>::
writeEntry
(
Ostream
&
os
)
const
{
if
(
coordSys_
.
valid
()
)
if
(
coordSys_
)
{
coordSys_
->
writeEntry
(
coordinateSystem
::
typeName_
(),
os
);
}
...
...
src/meshTools/PatchFunction1/coordinateScaling.H
View file @
09d9c5cc
...
...
@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018
-2020
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -55,15 +55,15 @@ namespace Foam
template
<
class
Type
>
class
coordinateScaling
{
// Private
d
ata
// Private
D
ata
//- Local co
-
ordinate system
//- Local coordinate system
const
autoPtr
<
coordinateSystem
>
coordSys_
;
//- In local co
-
ordinate system component-wise scaling
//- In local coordinate system component-wise scaling
PtrList
<
Function1
<
Type
>>
scale_
;
//- Cache
d
whether any scaling or coordinate system
//- Cache whether any scaling or coordinate system
bool
active_
;
...
...
@@ -76,25 +76,25 @@ public:
// Constructors
//-
C
onstruct
null
//-
Default c
onstruct
coordinateScaling
();
//- Construct from registry and dictionary
coordinateScaling
(
const
objectRegistry
&
,
const
dictionary
&
const
objectRegistry
&
obr
,
const
dictionary
&
dict
);
//- Construct copy
coordinateScaling
(
const
coordinateScaling
&
);
coordinateScaling
(
const
coordinateScaling
&
rhs
);
//- Destructor
virtual
~
coordinateScaling
();
virtual
~
coordinateScaling
()
=
default
;
// Member
f
unctions
// Member
F
unctions
//- Has any scaling or coordinate transformation
bool
active
()
const
...
...
@@ -116,12 +116,13 @@ public:
)
const
;
//- Write dictionary entry
virtual
void
writeEntry
(
Ostream
&
)
const
;
virtual
void
writeEntry
(
Ostream
&
os
)
const
;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Template specializations