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
23ffbab4
Commit
23ffbab4
authored
15 years ago
by
Andrew Heather
Browse files
Options
Downloads
Patches
Plain Diff
BUG: lagrangian/intermediate - clause in table integration not handled
parent
b3630c3f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lagrangian/intermediate/submodels/IO/DataEntry/Table/Table.C
+31
-21
31 additions, 21 deletions
...rangian/intermediate/submodels/IO/DataEntry/Table/Table.C
with
31 additions
and
21 deletions
src/lagrangian/intermediate/submodels/IO/DataEntry/Table/Table.C
+
31
−
21
View file @
23ffbab4
...
...
@@ -94,46 +94,56 @@ Type Foam::Table<Type>::integrate(const scalar x1, const scalar x2) const
Type
sum
=
pTraits
<
Type
>::
zero
;
// Return zero if out of bounds
if
((
x1
>
table_
[
table_
.
size
()
-
1
]
.
first
())
||
(
x2
<
table_
[
0
].
first
()))
if
((
x1
>
table_
.
last
()
.
first
())
||
(
x2
<
table_
[
0
].
first
()))
{
return
sum
;
}
// Find
star
t index
// Find
nex
t index
greater than x1
label
id1
=
0
;
while
((
table_
[
id1
].
first
()
<
x1
)
&&
(
id1
<
table_
.
size
()))
{
id1
++
;
}
// Find
end
index
// Find
next
index
less than x2
label
id2
=
table_
.
size
()
-
1
;
while
((
table_
[
id2
].
first
()
>
x2
)
&&
(
id2
>=
1
))
{
id2
--
;
}
// Integrate table body
for
(
label
i
=
id1
;
i
<
id2
;
i
++
)
if
((
id1
-
id2
)
==
1
)
{
sum
+=
(
table_
[
i
].
second
()
+
table_
[
i
+
1
].
second
())
*
(
table_
[
i
+
1
].
first
()
-
table_
[
i
].
first
());
// x1 and x2 lie within 1 interval
sum
=
0
.
5
*
(
value
(
x1
)
+
value
(
x2
))
*
(
x2
-
x1
);
}
sum
*=
0
.
5
;
// Add table ends (partial segments)
if
(
id1
>
0
)
{
sum
+=
0
.
5
*
(
value
(
x1
)
+
table_
[
id1
].
second
())
*
(
table_
[
id1
].
first
()
-
x1
);
}
if
(
id2
<
table_
.
size
()
-
1
)
else
{
sum
+=
0
.
5
*
(
table_
[
id2
].
second
()
+
value
(
x2
))
*
(
x2
-
table_
[
id2
].
first
());
// x1 and x2 cross multiple intervals
// Integrate table body
for
(
label
i
=
id1
;
i
<
id2
;
i
++
)
{
sum
+=
(
table_
[
i
].
second
()
+
table_
[
i
+
1
].
second
())
*
(
table_
[
i
+
1
].
first
()
-
table_
[
i
].
first
());
}
sum
*=
0
.
5
;
// Add table ends (partial segments)
if
(
id1
>
0
)
{
sum
+=
0
.
5
*
(
value
(
x1
)
+
table_
[
id1
].
second
())
*
(
table_
[
id1
].
first
()
-
x1
);
}
if
(
id2
<
table_
.
size
()
-
1
)
{
sum
+=
0
.
5
*
(
table_
[
id2
].
second
()
+
value
(
x2
))
*
(
x2
-
table_
[
id2
].
first
());
}
}
return
sum
;
...
...
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