Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
jonathan.drechsel_at_mailbox.tu-dresden.de
dune-elasticity
Commits
5f333c65
Commit
5f333c65
authored
May 12, 2020
by
oliver.sander_at_tu-dresden.de
Browse files
Merge branch 'feature/sum-energy' into 'master'
SumEnergy: Allow more than two local energies See merge request
!34
parents
1936cb4a
1725de32
Changes
1
Hide whitespace changes
Inline
Side-by-side
dune/elasticity/materials/sumenergy.hh
View file @
5f333c65
#ifndef DUNE_ELASTICITY_MATERIALS_SUMENERGY_HH
#define DUNE_ELASTICITY_MATERIALS_SUMENERGY_HH
#include <vector>
#include <dune/common/fmatrix.hh>
#include <dune/common/fmatrixev.hh>
...
...
@@ -24,26 +26,38 @@ class SumEnergy
public:
/** \brief Constructor with a set of material parameters
* \param parameters The material parameters
*/
/** \brief Constructor with two local energies (compatibility for old interface)*/
SumEnergy
(
std
::
shared_ptr
<
Elasticity
::
LocalEnergy
<
LocalView
,
field_type
>>
a
,
std
::
shared_ptr
<
Elasticity
::
LocalEnergy
<
LocalView
,
field_type
>>
b
)
:
a_
(
a
),
b_
(
b
)
{
addLocalEnergy
(
a
);
addLocalEnergy
(
b
);
}
/** \brief Default Constructor*/
SumEnergy
()
{}
/** \brief Add a local energy to be part of the sum */
void
addLocalEnergy
(
std
::
shared_ptr
<
Elasticity
::
LocalEnergy
<
LocalView
,
field_type
>>
localEnergy
)
{
localEnergies_
.
push_back
(
localEnergy
);
}
/** \brief Assemble the energy for a single element */
field_type
energy
(
const
LocalView
&
localView
,
const
std
::
vector
<
field_type
>&
localConfiguration
)
const
{
return
a_
->
energy
(
localView
,
localConfiguration
)
+
b_
->
energy
(
localView
,
localConfiguration
);
field_type
sum
=
0.
;
for
(
const
auto
&
localEnergy
:
localEnergies_
)
sum
+=
localEnergy
->
energy
(
localView
,
localConfiguration
);
return
sum
;
}
private:
std
::
shared_ptr
<
Elasticity
::
L
ocal
E
nerg
y
<
LocalView
,
field_type
>>
a_
;
std
::
shared_ptr
<
Elasticity
::
LocalEnergy
<
LocalView
,
field_type
>>
b
_
;
// vector containing pointers to the l
ocal
e
nerg
ies
std
::
vector
<
std
::
shared_ptr
<
Elasticity
::
LocalEnergy
<
LocalView
,
field_type
>>
>
localEnergies
_
;
};
}
// namespace Dune::Elasticity
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment