Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
openfoam
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
openfoam
Commits
dfe98fdf
Commit
dfe98fdf
authored
4 years ago
by
Andrew Heather
Committed by
Mattijs Janssens
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ENH: linearInterpolationWeights - protect against and provide early exit if input values are equal
parent
2811c054
No related branches found
No related tags found
1 merge request
!414
Feature function1 limit range
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/OpenFOAM/interpolations/interpolationWeights/linearInterpolationWeights/linearInterpolationWeights.C
+16
-2
16 additions, 2 deletions
...s/linearInterpolationWeights/linearInterpolationWeights.C
with
16 additions
and
2 deletions
src/OpenFOAM/interpolations/interpolationWeights/linearInterpolationWeights/linearInterpolationWeights.C
+
16
−
2
View file @
dfe98fdf
...
...
@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019
-2020
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -160,7 +160,7 @@ bool Foam::linearInterpolationWeights::integrationWeights
scalarField
&
weights
)
const
{
if
(
t2
<
t1
-
VSMALL
)
if
(
t2
<
t1
-
ROOT
VSMALL
)
{
FatalErrorInFunction
<<
"Integration should be in positive direction."
...
...
@@ -173,6 +173,20 @@ bool Foam::linearInterpolationWeights::integrationWeights
//- Find lower or equal index
const
label
i1
=
findLower
(
samples_
,
t1
,
0
,
lessEqOp
<
scalar
>
());
if
(
t2
<=
t1
+
ROOTVSMALL
)
{
// Early exit if 1 and t2 are approximately equal
bool
anyChanged
=
(
indices
.
size
()
!=
1
||
indices
[
0
]
!=
i1
);
indices
.
setSize
(
1
);
weights
.
setSize
(
1
);
indices
[
0
]
=
i1
;
weights
[
0
]
=
scalar
(
0
);
return
anyChanged
;
}
//- Find lower index
const
label
i2
=
findLower
(
samples_
,
t2
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment