Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
wenqing
ogs
Commits
03432a85
Commit
03432a85
authored
7 years ago
by
wenqing
Browse files
Options
Downloads
Patches
Plain Diff
[Num] Added a function in NaturalCoordinatesMapping.cpp to
check the determinant of Jacobian
parent
b5e50851
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
NumLib/Fem/CoordinatesMapping/NaturalCoordinatesMapping.cpp
+38
-19
38 additions, 19 deletions
NumLib/Fem/CoordinatesMapping/NaturalCoordinatesMapping.cpp
with
38 additions
and
19 deletions
NumLib/Fem/CoordinatesMapping/NaturalCoordinatesMapping.cpp
+
38
−
19
View file @
03432a85
...
...
@@ -96,6 +96,28 @@ computeMappingMatrices(
{
}
static
void
checkJacobianDeterminant
(
const
double
detJ
)
{
if
(
detJ
<=
.0
)
{
if
(
detJ
==
.0
)
{
OGS_FATAL
(
"det J is zero. Please check whether:
\n
"
"
\t
element nodes may have the same coordinates,
\n
"
"
\t
or the coordinates of all nodes are not given in x "
"component for 1D problem,
\n
"
"
\t
or the coordinates of all nodes are not given in x-y "
"components for 2D problem,
\n
"
);
}
OGS_FATAL
(
"det J = %g is negative. Please check the orientation of the "
"element node numbering
\n
"
,
detJ
);
}
}
template
<
class
T_MESH_ELEMENT
,
class
T_SHAPE_FUNC
,
class
T_SHAPE_MATRICES
>
inline
typename
std
::
enable_if
<
T_SHAPE_FUNC
::
DIM
!=
0
>::
type
...
...
@@ -125,8 +147,7 @@ computeMappingMatrices(
shapemat
.
detJ
=
shapemat
.
J
.
determinant
();
if
(
shapemat
.
detJ
<=
.0
)
OGS_FATAL
(
"det J = %e is not positive.
\n
"
,
shapemat
.
detJ
);
checkJacobianDeterminant
(
shapemat
.
detJ
);
}
template
<
class
T_MESH_ELEMENT
,
class
T_SHAPE_FUNC
,
class
T_SHAPE_MATRICES
>
inline
...
...
@@ -168,24 +189,22 @@ computeMappingMatrices(
computeMappingMatrices
<
T_MESH_ELEMENT
,
T_SHAPE_FUNC
,
T_SHAPE_MATRICES
>
(
ele
,
natural_pt
,
ele_local_coord
,
shapemat
,
FieldType
<
ShapeMatrixType
::
DNDR_J
>
());
if
(
shapemat
.
detJ
>
0
)
{
//J^-1, dshape/dx
shapemat
.
invJ
.
noalias
()
=
shapemat
.
J
.
inverse
();
auto
const
nnodes
(
shapemat
.
dNdr
.
cols
());
auto
const
ele_dim
(
shapemat
.
dNdr
.
rows
());
assert
(
shapemat
.
dNdr
.
rows
()
==
ele
.
getDimension
());
const
unsigned
global_dim
=
ele_local_coord
.
getGlobalDimension
();
if
(
global_dim
==
ele_dim
)
{
shapemat
.
dNdx
.
topLeftCorner
(
ele_dim
,
nnodes
).
noalias
()
=
shapemat
.
invJ
*
shapemat
.
dNdr
;
}
else
{
auto
const
&
matR
=
ele_local_coord
.
getRotationMatrixToGlobal
();
// 3 x 3
auto
invJ_dNdr
=
shapemat
.
invJ
*
shapemat
.
dNdr
;
auto
dshape_global
=
matR
.
topLeftCorner
(
3u
,
ele_dim
)
*
invJ_dNdr
;
//3 x nnodes
shapemat
.
dNdx
=
dshape_global
.
topLeftCorner
(
global_dim
,
nnodes
);;
}
checkJacobianDeterminant
(
shapemat
.
detJ
);
//J^-1, dshape/dx
shapemat
.
invJ
.
noalias
()
=
shapemat
.
J
.
inverse
();
auto
const
nnodes
(
shapemat
.
dNdr
.
cols
());
auto
const
ele_dim
(
shapemat
.
dNdr
.
rows
());
assert
(
shapemat
.
dNdr
.
rows
()
==
ele
.
getDimension
());
const
unsigned
global_dim
=
ele_local_coord
.
getGlobalDimension
();
if
(
global_dim
==
ele_dim
)
{
shapemat
.
dNdx
.
topLeftCorner
(
ele_dim
,
nnodes
).
noalias
()
=
shapemat
.
invJ
*
shapemat
.
dNdr
;
}
else
{
OGS_FATAL
(
"det J = %e is not positive.
\n
"
,
shapemat
.
detJ
);
auto
const
&
matR
=
ele_local_coord
.
getRotationMatrixToGlobal
();
// 3 x 3
auto
invJ_dNdr
=
shapemat
.
invJ
*
shapemat
.
dNdr
;
auto
dshape_global
=
matR
.
topLeftCorner
(
3u
,
ele_dim
)
*
invJ_dNdr
;
//3 x nnodes
shapemat
.
dNdx
=
dshape_global
.
topLeftCorner
(
global_dim
,
nnodes
);;
}
}
...
...
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