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
c380d6d4
Commit
c380d6d4
authored
13 years ago
by
mattijs
Browse files
Options
Downloads
Patches
Plain Diff
BUG: extendedLeastSquares: incorrect indexing. Added 2D detection.
parent
3e26473b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/finiteVolume/finiteVolume/gradSchemes/extendedLeastSquaresGrad/extendedLeastSquaresVectors.C
+113
-21
113 additions, 21 deletions
...es/extendedLeastSquaresGrad/extendedLeastSquaresVectors.C
with
113 additions
and
21 deletions
src/finiteVolume/finiteVolume/gradSchemes/extendedLeastSquaresGrad/extendedLeastSquaresVectors.C
+
113
−
21
View file @
c380d6d4
...
@@ -110,6 +110,38 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
...
@@ -110,6 +110,38 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
const
labelUList
&
owner
=
mesh_
.
owner
();
const
labelUList
&
owner
=
mesh_
.
owner
();
const
labelUList
&
neighbour
=
mesh_
.
neighbour
();
const
labelUList
&
neighbour
=
mesh_
.
neighbour
();
// Determine number of dimensions and (for 2D) missing dimension
label
nDims
=
0
;
label
twoD
=
-
1
;
for
(
direction
dir
=
0
;
dir
<
vector
::
nComponents
;
dir
++
)
{
if
(
mesh
.
geometricD
()[
dir
]
==
1
)
{
nDims
++
;
}
else
{
twoD
=
dir
;
}
}
if
(
nDims
==
1
)
{
FatalErrorIn
(
"extendedLeastSquaresVectors::makeLeastSquaresVectors() const"
)
<<
"Found a mesh with only one geometric dimension : "
<<
mesh
.
geometricD
()
<<
exit
(
FatalError
);
}
else
if
(
nDims
==
2
)
{
Info
<<
"extendedLeastSquares : detected "
<<
nDims
<<
" valid directions. Missing direction "
<<
twoD
<<
nl
<<
endl
;
}
const
volVectorField
&
C
=
mesh
.
C
();
const
volVectorField
&
C
=
mesh
.
C
();
// Set up temporary storage for the dd tensor (before inversion)
// Set up temporary storage for the dd tensor (before inversion)
...
@@ -122,7 +154,7 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
...
@@ -122,7 +154,7 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
vector
d
=
C
[
nei
]
-
C
[
own
];
vector
d
=
C
[
nei
]
-
C
[
own
];
const
symmTensor
wdd
(
1
.
0
/
magSqr
(
d
[
facei
])
*
sqr
(
d
[
facei
]
));
const
symmTensor
wdd
(
1
.
0
/
magSqr
(
d
)
*
sqr
(
d
));
dd
[
own
]
+=
wdd
;
dd
[
own
]
+=
wdd
;
dd
[
nei
]
+=
wdd
;
dd
[
nei
]
+=
wdd
;
...
@@ -147,6 +179,28 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
...
@@ -147,6 +179,28 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
}
}
}
}
// Check for missing dimensions
// Add the missing eigenvector (such that it does not
// affect the determinant)
if
(
nDims
==
2
)
{
forAll
(
dd
,
cellI
)
{
if
(
twoD
==
0
)
{
dd
[
cellI
].
xx
()
=
1
;
}
else
if
(
twoD
==
1
)
{
dd
[
cellI
].
yy
()
=
1
;
}
else
{
dd
[
cellI
].
zz
()
=
1
;
}
}
}
scalarField
detdd
(
det
(
dd
));
scalarField
detdd
(
det
(
dd
));
Info
<<
"max(detdd) = "
<<
max
(
detdd
)
<<
nl
Info
<<
"max(detdd) = "
<<
max
(
detdd
)
<<
nl
...
@@ -170,7 +224,8 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
...
@@ -170,7 +224,8 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
(
(
"extendedLeastSquaresVectors::"
"extendedLeastSquaresVectors::"
"makeLeastSquaresVectors() const"
"makeLeastSquaresVectors() const"
)
<<
"nAddCells exceeds maxNaddCells"
)
<<
"nAddCells exceeds maxNaddCells ("
<<
maxNaddCells
<<
")"
<<
exit
(
FatalError
);
<<
exit
(
FatalError
);
}
}
...
@@ -188,21 +243,36 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
...
@@ -188,21 +243,36 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
if
(
cellj
!=
i
)
if
(
cellj
!=
i
)
{
{
if
(
cellj
!=
-
1
)
vector
dCij
=
(
mesh
.
C
()[
cellj
]
-
mesh
.
C
()[
i
]);
{
vector
dCij
=
(
mesh
.
C
()[
cellj
]
-
mesh
.
C
()[
i
]);
symmTensor
ddij
=
symmTensor
ddij
=
dd
[
i
]
+
(
1
.
0
/
magSqr
(
dCij
))
*
sqr
(
dCij
);
dd
[
i
]
+
(
1
.
0
/
magSqr
(
dCij
))
*
sqr
(
dCij
);
scalar
detddij
=
det
(
ddij
);
// Add the missing eigenvector (such that it does not
// affect the determinant)
if
(
detddij
>
maxDetddij
)
if
(
nDims
==
2
)
{
if
(
twoD
==
0
)
{
ddij
.
xx
()
=
1
;
}
else
if
(
twoD
==
1
)
{
{
addCell
=
cellj
;
ddij
.
yy
()
=
1
;
maxDetddij
=
detddij
;
}
else
{
ddij
.
zz
()
=
1
;
}
}
}
}
scalar
detddij
=
det
(
ddij
);
if
(
detddij
>
maxDetddij
)
{
addCell
=
cellj
;
maxDetddij
=
detddij
;
}
}
}
}
}
}
}
...
@@ -213,6 +283,25 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
...
@@ -213,6 +283,25 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
additionalCells_
[
nAddCells
++
][
1
]
=
addCell
;
additionalCells_
[
nAddCells
++
][
1
]
=
addCell
;
vector
dCij
=
mesh
.
C
()[
addCell
]
-
mesh
.
C
()[
i
];
vector
dCij
=
mesh
.
C
()[
addCell
]
-
mesh
.
C
()[
i
];
dd
[
i
]
+=
(
1
.
0
/
magSqr
(
dCij
))
*
sqr
(
dCij
);
dd
[
i
]
+=
(
1
.
0
/
magSqr
(
dCij
))
*
sqr
(
dCij
);
// Add the missing eigenvector (such that it does not
// affect the determinant)
if
(
nDims
==
2
)
{
if
(
twoD
==
0
)
{
dd
[
i
].
xx
()
=
1
;
}
else
if
(
twoD
==
1
)
{
dd
[
i
].
yy
()
=
1
;
}
else
{
dd
[
i
].
zz
()
=
1
;
}
}
detdd
[
i
]
=
det
(
dd
[
i
]);
detdd
[
i
]
=
det
(
dd
[
i
]);
}
}
}
}
...
@@ -220,10 +309,16 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
...
@@ -220,10 +309,16 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
additionalCells_
.
setSize
(
nAddCells
);
additionalCells_
.
setSize
(
nAddCells
);
Info
<<
"max(detdd) = "
<<
max
(
detdd
)
<<
nl
reduce
(
nAddCells
,
sumOp
<
label
>
());
<<
"min(detdd) = "
<<
min
(
detdd
)
<<
nl
if
(
nAddCells
)
<<
"average(detdd) = "
<<
average
(
detdd
)
<<
nl
{
<<
"nAddCells/nCells = "
<<
scalar
(
nAddCells
)
/
mesh
.
nCells
()
<<
endl
;
Info
<<
"max(detdd) = "
<<
max
(
detdd
)
<<
nl
<<
"min(detdd) = "
<<
min
(
detdd
)
<<
nl
<<
"average(detdd) = "
<<
average
(
detdd
)
<<
nl
<<
"nAddCells/nCells = "
<<
scalar
(
nAddCells
)
/
mesh
.
globalData
().
nTotalCells
()
<<
endl
;
}
// Invert the dd tensor
// Invert the dd tensor
const
symmTensorField
invDd
(
inv
(
dd
));
const
symmTensorField
invDd
(
inv
(
dd
));
...
@@ -237,11 +332,8 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
...
@@ -237,11 +332,8 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
vector
d
=
C
[
nei
]
-
C
[
own
];
vector
d
=
C
[
nei
]
-
C
[
own
];
lsP
[
facei
]
=
lsP
[
facei
]
=
(
1
.
0
/
magSqr
(
d
))
*
(
invDd
[
own
]
&
d
);
(
1
.
0
/
magSqr
(
d
[
facei
]))
*
(
invDd
[
owner
[
facei
]]
&
d
);
lsN
[
facei
]
=
((
-
1
.
0
)
/
magSqr
(
d
))
*
(
invDd
[
nei
]
&
d
);
lsN
[
facei
]
=
((
-
1
.
0
)
/
magSqr
(
d
[
facei
]))
*
(
invDd
[
neighbour
[
facei
]]
&
d
);
}
}
forAll
(
blsP
,
patchI
)
forAll
(
blsP
,
patchI
)
...
...
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