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
5c31fcfb
Commit
5c31fcfb
authored
Aug 5, 2021
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add missing dot product for discrete P0 vector functions
parent
cd25d595
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!108
Add missing dot product for discrete P0 vector functions
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/language/utils/EmbeddedIDiscreteFunctionMathFunctions.cpp
+50
-29
50 additions, 29 deletions
...language/utils/EmbeddedIDiscreteFunctionMathFunctions.cpp
src/scheme/DiscreteFunctionP0Vector.hpp
+14
-0
14 additions, 0 deletions
src/scheme/DiscreteFunctionP0Vector.hpp
with
64 additions
and
29 deletions
src/language/utils/EmbeddedIDiscreteFunctionMathFunctions.cpp
+
50
−
29
View file @
5c31fcfb
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include
<language/utils/EmbeddedIDiscreteFunctionUtils.hpp>
#include
<language/utils/EmbeddedIDiscreteFunctionUtils.hpp>
#include
<mesh/IMesh.hpp>
#include
<mesh/IMesh.hpp>
#include
<scheme/DiscreteFunctionP0.hpp>
#include
<scheme/DiscreteFunctionP0.hpp>
#include
<scheme/DiscreteFunctionP0Vector.hpp>
#include
<scheme/DiscreteFunctionUtils.hpp>
#include
<scheme/DiscreteFunctionUtils.hpp>
#include
<scheme/IDiscreteFunction.hpp>
#include
<scheme/IDiscreteFunction.hpp>
#include
<scheme/IDiscreteFunctionDescriptor.hpp>
#include
<scheme/IDiscreteFunctionDescriptor.hpp>
...
@@ -318,10 +319,27 @@ template <size_t Dimension>
...
@@ -318,10 +319,27 @@ template <size_t Dimension>
std
::
shared_ptr
<
const
IDiscreteFunction
>
std
::
shared_ptr
<
const
IDiscreteFunction
>
dot
(
const
std
::
shared_ptr
<
const
IDiscreteFunction
>&
f
,
const
std
::
shared_ptr
<
const
IDiscreteFunction
>&
g
)
dot
(
const
std
::
shared_ptr
<
const
IDiscreteFunction
>&
f
,
const
std
::
shared_ptr
<
const
IDiscreteFunction
>&
g
)
{
{
Assert
((
f
->
dataType
()
==
ASTNodeDataType
::
vector_t
and
f
->
descriptor
().
type
()
==
DiscreteFunctionType
::
P0
)
and
Assert
(((
f
->
descriptor
().
type
()
==
DiscreteFunctionType
::
P0Vector
)
and
(
g
->
descriptor
().
type
()
==
DiscreteFunctionType
::
P0Vector
))
or
((
f
->
dataType
()
==
ASTNodeDataType
::
vector_t
and
f
->
descriptor
().
type
()
==
DiscreteFunctionType
::
P0
)
and
(
g
->
dataType
()
==
ASTNodeDataType
::
vector_t
and
g
->
descriptor
().
type
()
==
DiscreteFunctionType
::
P0
)
and
(
g
->
dataType
()
==
ASTNodeDataType
::
vector_t
and
g
->
descriptor
().
type
()
==
DiscreteFunctionType
::
P0
)
and
(
f
->
dataType
().
dimension
()
==
g
->
dataType
().
dimension
()));
(
f
->
dataType
().
dimension
()
==
g
->
dataType
().
dimension
())));
if
((
f
->
descriptor
().
type
()
==
DiscreteFunctionType
::
P0Vector
)
and
(
g
->
descriptor
().
type
()
==
DiscreteFunctionType
::
P0Vector
))
{
using
DiscreteFunctionResultType
=
DiscreteFunctionP0
<
Dimension
,
double
>
;
using
DiscreteFunctionType
=
DiscreteFunctionP0Vector
<
Dimension
,
double
>
;
const
DiscreteFunctionType
&
f_vector
=
dynamic_cast
<
const
DiscreteFunctionType
&>
(
*
f
);
const
DiscreteFunctionType
&
g_vector
=
dynamic_cast
<
const
DiscreteFunctionType
&>
(
*
g
);
if
(
f_vector
.
size
()
!=
g_vector
.
size
())
{
throw
NormalError
(
"operands have different dimension"
);
}
else
{
return
std
::
make_shared
<
const
DiscreteFunctionResultType
>
(
dot
(
f_vector
,
g_vector
));
}
}
else
{
using
DiscreteFunctionResultType
=
DiscreteFunctionP0
<
Dimension
,
double
>
;
using
DiscreteFunctionResultType
=
DiscreteFunctionP0
<
Dimension
,
double
>
;
switch
(
f
->
dataType
().
dimension
())
{
switch
(
f
->
dataType
().
dimension
())
{
...
@@ -348,13 +366,16 @@ dot(const std::shared_ptr<const IDiscreteFunction>& f, const std::shared_ptr<con
...
@@ -348,13 +366,16 @@ dot(const std::shared_ptr<const IDiscreteFunction>& f, const std::shared_ptr<con
}
}
}
}
}
}
}
std
::
shared_ptr
<
const
IDiscreteFunction
>
std
::
shared_ptr
<
const
IDiscreteFunction
>
dot
(
const
std
::
shared_ptr
<
const
IDiscreteFunction
>&
f
,
const
std
::
shared_ptr
<
const
IDiscreteFunction
>&
g
)
dot
(
const
std
::
shared_ptr
<
const
IDiscreteFunction
>&
f
,
const
std
::
shared_ptr
<
const
IDiscreteFunction
>&
g
)
{
{
if
((
f
->
dataType
()
==
ASTNodeDataType
::
vector_t
and
f
->
descriptor
().
type
()
==
DiscreteFunctionType
::
P0
)
and
if
(((
f
->
descriptor
().
type
()
==
DiscreteFunctionType
::
P0Vector
)
and
(
g
->
descriptor
().
type
()
==
DiscreteFunctionType
::
P0Vector
))
or
((
f
->
dataType
()
==
ASTNodeDataType
::
vector_t
and
f
->
descriptor
().
type
()
==
DiscreteFunctionType
::
P0
)
and
(
g
->
dataType
()
==
ASTNodeDataType
::
vector_t
and
g
->
descriptor
().
type
()
==
DiscreteFunctionType
::
P0
)
and
(
g
->
dataType
()
==
ASTNodeDataType
::
vector_t
and
g
->
descriptor
().
type
()
==
DiscreteFunctionType
::
P0
)
and
(
f
->
dataType
().
dimension
()
==
g
->
dataType
().
dimension
()))
{
(
f
->
dataType
().
dimension
()
==
g
->
dataType
().
dimension
()))
)
{
std
::
shared_ptr
mesh
=
getCommonMesh
({
f
,
g
});
std
::
shared_ptr
mesh
=
getCommonMesh
({
f
,
g
});
if
(
mesh
.
use_count
()
==
0
)
{
if
(
mesh
.
use_count
()
==
0
)
{
...
...
This diff is collapsed.
Click to expand it.
src/scheme/DiscreteFunctionP0Vector.hpp
+
14
−
0
View file @
5c31fcfb
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include
<scheme/IDiscreteFunction.hpp>
#include
<scheme/IDiscreteFunction.hpp>
#include
<algebra/Vector.hpp>
#include
<mesh/Connectivity.hpp>
#include
<mesh/Connectivity.hpp>
#include
<mesh/ItemArray.hpp>
#include
<mesh/ItemArray.hpp>
#include
<mesh/Mesh.hpp>
#include
<mesh/Mesh.hpp>
...
@@ -194,6 +195,19 @@ class DiscreteFunctionP0Vector : public IDiscreteFunction
...
@@ -194,6 +195,19 @@ class DiscreteFunctionP0Vector : public IDiscreteFunction
return
product
;
return
product
;
}
}
PUGS_INLINE
friend
DiscreteFunctionP0
<
Dimension
,
double
>
dot
(
const
DiscreteFunctionP0Vector
&
f
,
const
DiscreteFunctionP0Vector
&
g
)
{
Assert
(
f
.
mesh
()
==
g
.
mesh
(),
"functions are nor defined on the same mesh"
);
Assert
(
f
.
size
()
==
g
.
size
());
DiscreteFunctionP0
<
Dimension
,
double
>
result
{
f
.
m_mesh
};
parallel_for
(
f
.
m_mesh
->
numberOfCells
(),
PUGS_LAMBDA
(
CellId
cell_id
)
{
result
[
cell_id
]
=
dot
(
Vector
{
f
[
cell_id
]},
Vector
{
g
[
cell_id
]});
});
return
result
;
}
DiscreteFunctionP0Vector
(
const
std
::
shared_ptr
<
const
MeshType
>&
mesh
,
size_t
size
)
DiscreteFunctionP0Vector
(
const
std
::
shared_ptr
<
const
MeshType
>&
mesh
,
size_t
size
)
:
m_mesh
{
mesh
},
m_cell_arrays
{
mesh
->
connectivity
(),
size
}
:
m_mesh
{
mesh
},
m_cell_arrays
{
mesh
->
connectivity
(),
size
}
{}
{}
...
...
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