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
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
Yuhao Liu
ogs
Commits
d4b14df2
Commit
d4b14df2
authored
9 years ago
by
Norihiro Watanabe
Browse files
Options
Downloads
Patches
Plain Diff
fix minor issues in ElementCoordinatesMappingLocal and its test
parent
f472c118
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MeshLib/ElementCoordinatesMappingLocal.cpp
+6
-7
6 additions, 7 deletions
MeshLib/ElementCoordinatesMappingLocal.cpp
Tests/MeshLib/TestCoordinatesMappingLocal.cpp
+10
-20
10 additions, 20 deletions
Tests/MeshLib/TestCoordinatesMappingLocal.cpp
with
16 additions
and
27 deletions
MeshLib/ElementCoordinatesMappingLocal.cpp
+
6
−
7
View file @
d4b14df2
...
...
@@ -25,7 +25,7 @@ ElementCoordinatesMappingLocal::ElementCoordinatesMappingLocal(
:
_coords
(
global_coords
)
{
assert
(
e
.
getDimension
()
<=
global_coords
.
getDimension
());
for
(
size_t
i
=
0
;
i
<
e
.
getNNodes
();
i
++
)
for
(
unsigned
i
=
0
;
i
<
e
.
getNNodes
();
i
++
)
_point_vec
.
push_back
(
MeshLib
::
Node
(
*
(
e
.
getNode
(
i
))));
getRotationMatrixToGlobal
(
e
,
global_coords
,
_point_vec
,
_matR2global
);
...
...
@@ -40,18 +40,18 @@ void ElementCoordinatesMappingLocal::rotateToLocal(
std
::
vector
<
MeshLib
::
Node
>
&
local_pt
)
const
{
// rotate the point coordinates
const
std
::
size_t
global_dim
=
global_coords
.
getDimension
();
const
unsigned
global_dim
=
global_coords
.
getDimension
();
Eigen
::
VectorXd
dx
=
Eigen
::
VectorXd
::
Zero
(
global_dim
);
Eigen
::
VectorXd
x_new
=
Eigen
::
VectorXd
::
Zero
(
3
);
for
(
std
::
size_t
i
=
0
;
i
<
ele
.
getNNodes
();
i
++
)
for
(
unsigned
i
=
0
;
i
<
ele
.
getNNodes
();
i
++
)
{
for
(
std
::
size_t
j
=
0
;
j
<
global_dim
;
j
++
)
for
(
unsigned
j
=
0
;
j
<
global_dim
;
j
++
)
dx
[
j
]
=
vec_pt
[
i
].
getCoords
()[
j
];
x_new
.
head
(
global_dim
)
=
matR2local
*
dx
;
local_pt
[
i
]
=
MeshLib
::
Node
(
x_new
.
data
());
}
}
;
}
void
ElementCoordinatesMappingLocal
::
getRotationMatrixToGlobal
(
const
Element
&
e
,
...
...
@@ -61,7 +61,7 @@ void ElementCoordinatesMappingLocal::getRotationMatrixToGlobal(
{
const
std
::
size_t
global_dim
=
global_coords
.
getDimension
();
// compute R in x=R*x' where x
is
original coordinates and x'
is
local coordinates
// compute R in x=R*x' where x
are
original coordinates and x'
are
local coordinates
matR
=
RotationMatrix
::
Zero
(
global_dim
,
global_dim
);
if
(
global_dim
==
e
.
getDimension
())
{
matR
=
RotationMatrix
::
Identity
(
global_dim
,
global_dim
);
...
...
@@ -82,7 +82,6 @@ void ElementCoordinatesMappingLocal::getRotationMatrixToGlobal(
MathLib
::
Vector3
plane_normal
;
double
d
;
GeoLib
::
getNewellPlane
(
pnts
,
plane_normal
,
d
);
//std::cout << "pn=" << plane_normal << std::endl;
// compute a rotation matrix to XY
MathLib
::
DenseMatrix
<
double
>
matToXY
(
3
,
3
,
0.0
);
GeoLib
::
computeRotationMatrixToXY
(
plane_normal
,
matToXY
);
...
...
This diff is collapsed.
Click to expand it.
Tests/MeshLib/TestCoordinatesMappingLocal.cpp
+
10
−
20
View file @
d4b14df2
...
...
@@ -86,7 +86,7 @@ class TestQuad4
static
MeshLib
::
Quad
*
createXYZ
()
{
MeshLib
::
Node
**
nodes
=
new
MeshLib
::
Node
*
[
e_nnodes
];
// rotate 4
0
degree around x axis
// rotate 4
5
degree around x axis
nodes
[
0
]
=
new
MeshLib
::
Node
(
1.0
,
0.7071067811865475
,
0.7071067811865475
);
nodes
[
1
]
=
new
MeshLib
::
Node
(
-
1.0
,
0.7071067811865475
,
0.7071067811865475
);
nodes
[
2
]
=
new
MeshLib
::
Node
(
-
1.0
,
-
0.7071067811865475
,
-
0.7071067811865475
);
...
...
@@ -118,6 +118,7 @@ class TestQuad4
};
#ifndef NDEBUG
void
debugOutput
(
MeshLib
::
Element
*
ele
,
MeshLib
::
ElementCoordinatesMappingLocal
&
mapping
)
{
std
::
cout
.
precision
(
12
);
...
...
@@ -136,6 +137,7 @@ void debugOutput(MeshLib::Element *ele, MeshLib::ElementCoordinatesMappingLocal
std
::
cout
<<
(
matR
*
v
).
transpose
()
<<
std
::
endl
;
}
}
#endif
// check if using the rotation matrix results in the original coordinates
#define CHECK_COORDS(ele, mapping)\
...
...
@@ -156,7 +158,7 @@ TEST(MeshLib, CoordinatesMappingLocalLowerDimLineY)
//debugOutput(ele, mapping);
double
exp_R
[
2
*
2
]
=
{
0
,
-
1
,
1
,
0
};
//row major
1
,
0
};
const
double
eps
(
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_ARRAY_NEAR
(
exp_R
,
matR
.
data
(),
matR
.
size
(),
eps
);
CHECK_COORDS
(
ele
,
mapping
);
...
...
@@ -170,7 +172,7 @@ TEST(MeshLib, CoordinatesMappingLocalLowerDimLineZ)
auto
matR
(
mapping
.
getRotationMatrixToGlobal
());
//debugOutput(ele, mapping);
double
exp_R
[
3
*
3
]
=
{
0
,
0
,
-
1
,
0
,
1
,
0
,
1
,
0
,
0
};
//row major
double
exp_R
[
3
*
3
]
=
{
0
,
0
,
-
1
,
0
,
1
,
0
,
1
,
0
,
0
};
const
double
eps
(
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_ARRAY_NEAR
(
exp_R
,
matR
.
data
(),
matR
.
size
(),
eps
);
CHECK_COORDS
(
ele
,
mapping
);
...
...
@@ -184,7 +186,7 @@ TEST(MeshLib, CoordinatesMappingLocalLowerDimLineXY)
//debugOutput(ele, mapping);
double
exp_R
[
2
*
2
]
=
{
0.70710678118654757
,
-
0.70710678118654757
,
0.70710678118654757
,
0.70710678118654757
};
//row major
0.70710678118654757
,
0.70710678118654757
};
const
double
eps
(
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_ARRAY_NEAR
(
exp_R
,
matR
.
data
(),
matR
.
size
(),
eps
);
CHECK_COORDS
(
ele
,
mapping
);
...
...
@@ -199,7 +201,7 @@ TEST(MeshLib, CoordinatesMappingLocalLowerDimLineXYZ)
double
exp_R
[
3
*
3
]
=
{
0.57735026918962584
,
-
0.81649658092772626
,
0
,
0.57735026918962584
,
0.40824829046386313
,
-
0.70710678118654757
,
0.57735026918962584
,
0.40824829046386313
,
0.70710678118654757
};
//row major
0.57735026918962584
,
0.40824829046386313
,
0.70710678118654757
};
const
double
eps
(
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_ARRAY_NEAR
(
exp_R
,
matR
.
data
(),
matR
.
size
(),
eps
);
CHECK_COORDS
(
ele
,
mapping
);
...
...
@@ -215,11 +217,7 @@ TEST(MeshLib, CoordinatesMappingLocalLowerDimQuadXZ)
// results when using GeoLib::ComputeRotationMatrixToXY()
double
exp_R
[
3
*
3
]
=
{
1
,
0
,
0
,
0
,
0
,
-
1
,
0
,
1
,
0
};
//row major
// // results when using GeoLib::ComputeRotationMatrixToXY2()
// double exp_R[3*3] = { -1, 0, 0,
// 0, 0, -1,
// 0, -1, 0}; //row major
0
,
1
,
0
};
const
double
eps
(
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_ARRAY_NEAR
(
exp_R
,
matR
.
data
(),
matR
.
size
(),
eps
);
...
...
@@ -236,11 +234,7 @@ TEST(MeshLib, CoordinatesMappingLocalLowerDimQuadYZ)
// results when using GeoLib::ComputeRotationMatrixToXY()
double
exp_R
[
3
*
3
]
=
{
0
,
0
,
1
,
0
,
1
,
0
,
-
1
,
0
,
0
};
//row major
// // results when using GeoLib::ComputeRotationMatrixToXY2()
// double exp_R[3*3] = { 0, 0, 1,
// -1, 0, 0,
// 0, -1, 0}; //row major
-
1
,
0
,
0
};
const
double
eps
(
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_ARRAY_NEAR
(
exp_R
,
matR
.
data
(),
matR
.
size
(),
eps
);
...
...
@@ -257,11 +251,7 @@ TEST(MeshLib, CoordinatesMappingLocalLowerDimQuadXYZ)
// results when using GeoLib::ComputeRotationMatrixToXY()
double
exp_R
[
3
*
3
]
=
{
1
,
0
,
0
,
0
,
0.70710678118654757
,
-
0.70710678118654757
,
0
,
0.70710678118654757
,
0.70710678118654757
};
//row major
// // results when using GeoLib::ComputeRotationMatrixToXY2()
// double exp_R[3*3] = { -1, 0, 0,
// 0, -0.70710678118654757, -0.70710678118654757,
// 0, -0.70710678118654757, 0.70710678118654757}; //row major
0
,
0.70710678118654757
,
0.70710678118654757
};
const
double
eps
(
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_ARRAY_NEAR
(
exp_R
,
matR
.
data
(),
matR
.
size
(),
eps
);
...
...
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