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
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
Mojtaba Abdolkhani
ogs
Commits
eb60a58a
Commit
eb60a58a
authored
8 years ago
by
Norihiro Watanabe
Browse files
Options
Downloads
Patches
Plain Diff
fix a bug in LocalToGlobalIndexMap for multiple variables with multiple components
parent
f003f778
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
NumLib/DOF/LocalToGlobalIndexMap.cpp
+33
-14
33 additions, 14 deletions
NumLib/DOF/LocalToGlobalIndexMap.cpp
NumLib/DOF/LocalToGlobalIndexMap.h
+23
-3
23 additions, 3 deletions
NumLib/DOF/LocalToGlobalIndexMap.h
with
56 additions
and
17 deletions
NumLib/DOF/LocalToGlobalIndexMap.cpp
+
33
−
14
View file @
eb60a58a
...
@@ -48,35 +48,54 @@ LocalToGlobalIndexMap::findGlobalIndices(
...
@@ -48,35 +48,54 @@ LocalToGlobalIndexMap::findGlobalIndices(
LocalToGlobalIndexMap
::
LocalToGlobalIndexMap
(
LocalToGlobalIndexMap
::
LocalToGlobalIndexMap
(
std
::
vector
<
std
::
unique_ptr
<
MeshLib
::
MeshSubsets
>>&&
mesh_subsets
,
std
::
vector
<
std
::
unique_ptr
<
MeshLib
::
MeshSubsets
>>&&
mesh_subsets
,
NumLib
::
ComponentOrder
const
order
)
NumLib
::
ComponentOrder
const
order
)
:
LocalToGlobalIndexMap
(
std
::
move
(
mesh_subsets
),
std
::
vector
<
unsigned
>
(
mesh_subsets
.
size
(),
1
),
order
)
{
}
LocalToGlobalIndexMap
::
LocalToGlobalIndexMap
(
std
::
vector
<
std
::
unique_ptr
<
MeshLib
::
MeshSubsets
>>&&
mesh_subsets
,
std
::
vector
<
unsigned
>
const
&
vec_var_n_components
,
NumLib
::
ComponentOrder
const
order
)
:
_mesh_subsets
(
std
::
move
(
mesh_subsets
)),
:
_mesh_subsets
(
std
::
move
(
mesh_subsets
)),
_mesh_component_map
(
_mesh_subsets
,
order
)
_mesh_component_map
(
_mesh_subsets
,
order
)
{
{
// construct a mapping table to get a global component ID from a variableID & a variable comp ID
_map_varCompID_to_globalCompID
.
resize
(
vec_var_n_components
.
size
());
{
unsigned
global_component_ID
=
0
;
for
(
unsigned
i
=
0
;
i
<
vec_var_n_components
.
size
();
i
++
)
for
(
unsigned
j
=
0
;
j
<
vec_var_n_components
[
i
];
j
++
)
_map_varCompID_to_globalCompID
[
i
].
push_back
(
global_component_ID
++
);
}
// For all MeshSubsets and each of their MeshSubset's and each element
// For all MeshSubsets and each of their MeshSubset's and each element
// of that MeshSubset save a line of global indices.
// of that MeshSubset save a line of global indices.
_variable_component_offsets
.
reserve
(
_mesh_subsets
.
size
());
std
::
size_t
offset
=
0
;
std
::
size_t
offset
=
0
;
for
(
int
variable_id
=
0
;
variable_id
<
static_cast
<
int
>
(
_mesh_subse
ts
.
size
());
for
(
int
variable_id
=
0
;
variable_id
<
static_cast
<
int
>
(
vec_var_n_componen
ts
.
size
());
++
variable_id
)
++
variable_id
)
{
{
_variable_component_offsets
.
push_back
(
offset
);
for
(
int
component_id
=
0
;
component_id
<
static_cast
<
int
>
(
vec_var_n_components
[
variable_id
]);
auto
const
&
mss
=
*
_mesh_subsets
[
variable_id
];
for
(
int
component_id
=
0
;
component_id
<
static_cast
<
int
>
(
mss
.
size
());
++
component_id
)
++
component_id
)
{
{
MeshLib
::
MeshSubset
const
&
ms
=
mss
.
getMeshSubset
(
component_id
);
std
::
size_t
const
mesh_id
=
ms
.
getMeshID
();
auto
const
global_component_id
=
auto
const
global_component_id
=
getGlobalComponent
(
variable_id
,
component_id
);
getGlobalComponent
(
variable_id
,
component_id
);
findGlobalIndices
(
ms
.
elementsBegin
(),
ms
.
elementsEnd
(),
ms
.
getNodes
(),
auto
const
&
mss
=
*
_mesh_subsets
[
global_component_id
];
mesh_id
,
global_component_id
,
global_component_id
);
for
(
int
subset_id
=
0
;
subset_id
<
static_cast
<
int
>
(
mss
.
size
());
++
subset_id
)
{
MeshLib
::
MeshSubset
const
&
ms
=
mss
.
getMeshSubset
(
subset_id
);
std
::
size_t
const
mesh_id
=
ms
.
getMeshID
();
findGlobalIndices
(
ms
.
elementsBegin
(),
ms
.
elementsEnd
(),
ms
.
getNodes
(),
mesh_id
,
global_component_id
,
global_component_id
);
}
// increase by number of components of that variable
offset
+=
mss
.
size
();
}
}
// increase by number of components of that variable
offset
+=
mss
.
size
();
}
}
}
}
...
@@ -87,7 +106,7 @@ LocalToGlobalIndexMap::LocalToGlobalIndexMap(
...
@@ -87,7 +106,7 @@ LocalToGlobalIndexMap::LocalToGlobalIndexMap(
NumLib
::
MeshComponentMap
&&
mesh_component_map
)
NumLib
::
MeshComponentMap
&&
mesh_component_map
)
:
_mesh_subsets
(
std
::
move
(
mesh_subsets
)),
:
_mesh_subsets
(
std
::
move
(
mesh_subsets
)),
_mesh_component_map
(
std
::
move
(
mesh_component_map
)),
_mesh_component_map
(
std
::
move
(
mesh_component_map
)),
_
variable_component_offsets
(
1
,
0
)
// Single variable only.
_
map_varCompID_to_globalCompID
(
1
,
std
::
vector
<
int
>
(
1
,
0
)
)
// Single variable only.
{
{
// There is only on mesh_subsets in the vector _mesh_subsets.
// There is only on mesh_subsets in the vector _mesh_subsets.
assert
(
_mesh_subsets
.
size
()
==
1
);
assert
(
_mesh_subsets
.
size
()
==
1
);
...
...
This diff is collapsed.
Click to expand it.
NumLib/DOF/LocalToGlobalIndexMap.h
+
23
−
3
View file @
eb60a58a
...
@@ -44,8 +44,24 @@ public:
...
@@ -44,8 +44,24 @@ public:
public:
public:
/// Creates a MeshComponentMap internally and stores the global indices for
/// Creates a MeshComponentMap internally and stores the global indices for
/// each mesh element of the given mesh_subsets.
/// each mesh element of the given mesh_subsets.
explicit
LocalToGlobalIndexMap
(
///
/// \attention This constructor assumes the number of the given mesh subsets
/// is equal to the number of variables, i.e. every variable has a single component.
LocalToGlobalIndexMap
(
std
::
vector
<
std
::
unique_ptr
<
MeshLib
::
MeshSubsets
>>&&
mesh_subsets
,
NumLib
::
ComponentOrder
const
order
);
/// Creates a MeshComponentMap internally and stores the global indices for
/// each mesh element of the given mesh_subsets.
///
/// \param mesh_subsets a vector of components
/// \param vec_var_n_components a vector of the number of variable components.
/// The size of the vector should be equal to the number of variables. Sum of the entries
/// should be equal to the size of the mesh_subsets.
/// \param order type of ordering values in a vector
LocalToGlobalIndexMap
(
std
::
vector
<
std
::
unique_ptr
<
MeshLib
::
MeshSubsets
>>&&
mesh_subsets
,
std
::
vector
<
std
::
unique_ptr
<
MeshLib
::
MeshSubsets
>>&&
mesh_subsets
,
std
::
vector
<
unsigned
>
const
&
vec_var_n_components
,
NumLib
::
ComponentOrder
const
order
);
NumLib
::
ComponentOrder
const
order
);
/// Derive a LocalToGlobalIndexMap constrained to a set of mesh subsets and
/// Derive a LocalToGlobalIndexMap constrained to a set of mesh subsets and
...
@@ -73,6 +89,10 @@ public:
...
@@ -73,6 +89,10 @@ public:
std
::
size_t
size
()
const
;
std
::
size_t
size
()
const
;
std
::
size_t
getNumberOfVariables
()
const
{
return
_map_varCompID_to_globalCompID
.
size
();
}
std
::
size_t
getNumberOfVariableComponents
(
int
variable_id
)
const
{
return
_map_varCompID_to_globalCompID
[
variable_id
].
size
();
}
std
::
size_t
getNumberOfComponents
()
const
{
return
_mesh_subsets
.
size
();
}
std
::
size_t
getNumberOfComponents
()
const
{
return
_mesh_subsets
.
size
();
}
RowColumnIndices
operator
()(
std
::
size_t
const
mesh_item_id
,
const
unsigned
component_id
)
const
;
RowColumnIndices
operator
()(
std
::
size_t
const
mesh_item_id
,
const
unsigned
component_id
)
const
;
...
@@ -139,7 +159,7 @@ private:
...
@@ -139,7 +159,7 @@ private:
std
::
size_t
getGlobalComponent
(
int
const
variable_id
,
std
::
size_t
getGlobalComponent
(
int
const
variable_id
,
int
const
component_id
)
const
int
const
component_id
)
const
{
{
return
_
variable_component_offsets
[
variable_id
]
+
component_id
;
return
_
map_varCompID_to_globalCompID
[
variable_id
]
[
component_id
]
;
}
}
private
:
private
:
...
@@ -156,7 +176,7 @@ private:
...
@@ -156,7 +176,7 @@ private:
/// \see _rows
/// \see _rows
Table
const
&
_columns
=
_rows
;
Table
const
&
_columns
=
_rows
;
std
::
vector
<
int
>
_
variable_component_offsets
;
std
::
vector
<
std
::
vector
<
int
>
>
_
map_varCompID_to_globalCompID
;
#ifndef NDEBUG
#ifndef NDEBUG
/// Prints first rows of the table, every line, and the mesh component map.
/// Prints first rows of the table, every line, and the mesh component map.
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
LocalToGlobalIndexMap
const
&
map
);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
LocalToGlobalIndexMap
const
&
map
);
...
...
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