Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
377831ba
Commit
377831ba
authored
Apr 19, 2021
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add copy_to utilities for ItemValue and ItemArray
parent
67a002b5
No related branches found
No related tags found
1 merge request
!89
Add missing compatibility check when affecting lists to R^d or R^dxd
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/mesh/ItemArray.hpp
+13
-0
13 additions, 0 deletions
src/mesh/ItemArray.hpp
src/mesh/ItemValue.hpp
+13
-0
13 additions, 0 deletions
src/mesh/ItemValue.hpp
tests/test_ItemArray.cpp
+4
-0
4 additions, 0 deletions
tests/test_ItemArray.cpp
tests/test_ItemValue.cpp
+13
-0
13 additions, 0 deletions
tests/test_ItemValue.cpp
with
43 additions
and
0 deletions
src/mesh/ItemArray.hpp
+
13
−
0
View file @
377831ba
...
@@ -47,6 +47,19 @@ class ItemArray
...
@@ -47,6 +47,19 @@ class ItemArray
return
image
;
return
image
;
}
}
template
<
typename
ConnectivityPtr2
>
friend
PUGS_INLINE
void
copy_to
(
const
ItemArray
<
std
::
add_const_t
<
DataType
>
,
item_type
,
ConnectivityPtr
>&
source
,
const
ItemArray
<
DataType
,
item_type
,
ConnectivityPtr2
>&
destination
);
template
<
typename
ConnectivityPtr2
>
friend
PUGS_INLINE
void
copy_to
(
const
ItemArray
<
DataType
,
item_type
,
ConnectivityPtr
>&
source
,
const
ItemArray
<
std
::
remove_const_t
<
DataType
>
,
item_type
,
ConnectivityPtr2
>&
destination
)
{
Assert
(
destination
.
connectivity_ptr
()
==
source
.
connectivity_ptr
());
copy_to
(
source
.
m_values
,
destination
.
m_values
);
}
PUGS_INLINE
PUGS_INLINE
bool
bool
isBuilt
()
const
noexcept
isBuilt
()
const
noexcept
...
...
This diff is collapsed.
Click to expand it.
src/mesh/ItemValue.hpp
+
13
−
0
View file @
377831ba
...
@@ -47,6 +47,19 @@ class ItemValue
...
@@ -47,6 +47,19 @@ class ItemValue
return
image
;
return
image
;
}
}
template
<
typename
ConnectivityPtr2
>
friend
PUGS_INLINE
void
copy_to
(
const
ItemValue
<
std
::
add_const_t
<
DataType
>
,
item_type
,
ConnectivityPtr
>&
source
,
const
ItemValue
<
DataType
,
item_type
,
ConnectivityPtr2
>&
destination
);
template
<
typename
ConnectivityPtr2
>
friend
PUGS_INLINE
void
copy_to
(
const
ItemValue
<
DataType
,
item_type
,
ConnectivityPtr
>&
source
,
const
ItemValue
<
std
::
remove_const_t
<
DataType
>
,
item_type
,
ConnectivityPtr2
>&
destination
)
{
Assert
(
destination
.
connectivity_ptr
()
==
source
.
connectivity_ptr
());
copy_to
(
source
.
m_values
,
destination
.
m_values
);
}
PUGS_INLINE
PUGS_INLINE
bool
bool
isBuilt
()
const
noexcept
isBuilt
()
const
noexcept
...
...
This diff is collapsed.
Click to expand it.
tests/test_ItemArray.cpp
+
4
−
0
View file @
377831ba
...
@@ -169,11 +169,15 @@ TEST_CASE("ItemArray", "[mesh]")
...
@@ -169,11 +169,15 @@ TEST_CASE("ItemArray", "[mesh]")
CellArray
<
const
int
>
const_cell_array
;
CellArray
<
const
int
>
const_cell_array
;
const_cell_array
=
copy
(
cell_array
);
const_cell_array
=
copy
(
cell_array
);
CellArray
<
int
>
duplicated_cell_array
{
connectivity
,
cell_array
.
sizeOfArrays
()};
copy_to
(
const_cell_array
,
duplicated_cell_array
);
cell_array
.
fill
(
0
);
cell_array
.
fill
(
0
);
REQUIRE
(
is_same
(
cell_array
,
0
));
REQUIRE
(
is_same
(
cell_array
,
0
));
REQUIRE
(
is_same
(
cell_array_const_view
,
0
));
REQUIRE
(
is_same
(
cell_array_const_view
,
0
));
REQUIRE
(
is_same
(
const_cell_array
,
static_cast
<
std
::
int64_t
>
(
parallel
::
rank
())));
REQUIRE
(
is_same
(
const_cell_array
,
static_cast
<
std
::
int64_t
>
(
parallel
::
rank
())));
REQUIRE
(
is_same
(
duplicated_cell_array
,
static_cast
<
std
::
int64_t
>
(
parallel
::
rank
())));
}
}
SECTION
(
"WeakItemArray"
)
SECTION
(
"WeakItemArray"
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_ItemValue.cpp
+
13
−
0
View file @
377831ba
...
@@ -191,6 +191,19 @@ TEST_CASE("ItemValue", "[mesh]")
...
@@ -191,6 +191,19 @@ TEST_CASE("ItemValue", "[mesh]")
Array
<
size_t
>
values
{
3
+
cell_value
.
numberOfItems
()};
Array
<
size_t
>
values
{
3
+
cell_value
.
numberOfItems
()};
REQUIRE_THROWS_AS
(
cell_value
=
values
,
AssertError
);
REQUIRE_THROWS_AS
(
cell_value
=
values
,
AssertError
);
}
}
SECTION
(
"invalid copy_to"
)
{
const
Mesh
<
Connectivity
<
2
>>&
mesh_2d
=
*
MeshDataBaseForTests
::
get
().
cartesianMesh2D
();
const
Connectivity
<
2
>&
connectivity_2d
=
mesh_2d
.
connectivity
();
const
Mesh
<
Connectivity
<
3
>>&
mesh_3d
=
*
MeshDataBaseForTests
::
get
().
cartesianMesh3D
();
const
Connectivity
<
3
>&
connectivity_3d
=
mesh_3d
.
connectivity
();
CellValue
<
int
>
cell_2d_value
{
connectivity_2d
};
CellValue
<
int
>
cell_3d_value
{
connectivity_3d
};
REQUIRE_THROWS_AS
(
copy_to
(
cell_2d_value
,
cell_3d_value
),
AssertError
);
}
}
}
#endif // NDEBUG
#endif // NDEBUG
}
}
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
sign in
to comment