Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78011991
constitutive_law.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Aug 17, 20:23
Size
7 KB
Mime Type
text/x-c++
Expires
Mon, Aug 19, 20:23 (2 d)
Engine
blob
Format
Raw Data
Handle
19959443
Attached To
rAKA akantu
constitutive_law.hh
View Options
/**
* @file constitutive_law.hh
*
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Feb 21 2018
*
* @brief Mother class for all constitutive laws
*
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "data_accessor.hh"
#include "mesh_events.hh"
#include "parsable.hh"
#include "parser.hh"
/* -------------------------------------------------------------------------- */
#include "internal_field.hh"
#include "random_internal_field.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_CONSTITUTIVE_LAW_HH__
#define __AKANTU_CONSTITUTIVE_LAW_HH__
/* -------------------------------------------------------------------------- */
namespace
akantu
{
template
<
class
ConstitutiveLawsHandler_
>
class
ConstitutiveLaw
:
public
DataAccessor
<
Element
>
,
public
Parsable
{
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public
:
using
ConstitutiveLawsHandler
=
ConstitutiveLawsHandler_
;
ConstitutiveLaw
(
const
ConstitutiveLaw
&
law
)
=
delete
;
ConstitutiveLaw
&
operator
=
(
const
ConstitutiveLaw
&
law
)
=
delete
;
/// Initialize constitutive law with defaults
ConstitutiveLaw
(
ConstitutiveLawsHandler
&
handler
,
const
ID
&
id
=
""
,
ElementKind
element_kind
=
_ek_regular
);
/// Destructor
~
ConstitutiveLaw
()
override
;
protected
:
void
initialize
();
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public
:
template
<
typename
T
>
inline
void
registerInternal
(
std
::
shared_ptr
<
InternalField
<
T
>>
&
vect
);
inline
void
unregisterInternal
(
const
ID
&
id
);
/// initialize the constitutive law computed parameter
virtual
void
initConstitutiveLaw
();
/// save the internals in the previous_state if needed
virtual
void
savePreviousState
();
/// restore the internals from previous_state if needed
virtual
void
restorePreviousState
();
/// add an element to the local mesh filter
inline
UInt
addElement
(
ElementType
type
,
UInt
element
,
GhostType
ghost_type
);
inline
UInt
addElement
(
const
Element
&
element
);
/// add many elements at once
void
addElements
(
const
Array
<
Element
>
&
elements_to_add
);
/// remove many element at once
void
removeElements
(
const
Array
<
Element
>
&
elements_to_remove
);
/// function to print the contain of the class
void
printself
(
std
::
ostream
&
stream
,
int
indent
=
0
)
const
override
;
protected
:
/// resize the internals arrrays
virtual
void
resizeInternals
();
/// function called to update the internal parameters when the
/// modifiable parameters are modified
virtual
void
updateInternalParameters
()
{}
public
:
virtual
void
onElementsAdded
(
const
Array
<
Element
>
&
/*unused*/
,
const
NewElementsEvent
&
/*unused*/
);
virtual
void
onElementsRemoved
(
const
Array
<
Element
>
&
element_list
,
const
ElementTypeMapArray
<
UInt
>
&
new_numbering
,
const
RemovedElementsEvent
&
event
);
public
:
template
<
typename
T
>
const
InternalField
<
T
>
&
getInternal
(
const
ID
&
id
)
const
{
auto
it
=
internal_vectors
.
find
(
getID
()
+
":"
+
id
);
if
(
it
!=
internal_vectors
.
end
()
and
aka
::
is_of_type
<
InternalField
<
T
>>
(
*
it
->
second
))
{
return
aka
::
as_type
<
InternalField
<
T
>>
(
*
it
->
second
);
}
AKANTU_SILENT_EXCEPTION
(
"The material "
<<
name
<<
"("
<<
getID
()
<<
") does not contain an internal "
<<
id
<<
" ("
<<
(
getID
()
+
":"
+
id
)
<<
")"
);
}
template
<
typename
T
>
InternalField
<
T
>
&
getInternal
(
const
ID
&
id
)
{
auto
it
=
internal_vectors
.
find
(
getID
()
+
":"
+
id
);
if
(
it
!=
internal_vectors
.
end
()
and
aka
::
is_of_type
<
InternalField
<
T
>>
(
*
it
->
second
))
{
return
aka
::
as_type
<
InternalField
<
T
>>
(
*
it
->
second
);
}
AKANTU_SILENT_EXCEPTION
(
"The material "
<<
name
<<
"("
<<
getID
()
<<
") does not contain an internal "
<<
id
<<
" ("
<<
(
getID
()
+
":"
+
id
)
<<
")"
);
}
template
<
typename
T
>
inline
bool
isInternal
(
const
ID
&
id
,
const
ElementKind
&
element_kind
)
const
{
auto
it
=
internal_vectors
.
find
(
this
->
getID
()
+
":"
+
id
);
return
(
it
!=
internal_vectors
.
end
()
and
aka
::
is_of_type
<
InternalField
<
T
>>
(
*
it
->
second
)
and
aka
::
as_type
<
InternalField
<
T
>>
(
*
it
->
second
).
getElementKind
()
!=
element_kind
);
}
template
<
typename
T
>
const
Array
<
T
>
&
getArray
(
const
ID
&
id
,
ElementType
type
,
GhostType
ghost_type
=
_not_ghost
)
const
;
template
<
typename
T
>
Array
<
T
>
&
getArray
(
const
ID
&
id
,
ElementType
type
,
GhostType
ghost_type
=
_not_ghost
);
template
<
typename
T
>
inline
void
setParam
(
const
ID
&
param
,
T
value
);
inline
const
Parameter
&
getParam
(
const
ID
&
param
)
const
;
template
<
typename
T
>
void
flattenInternal
(
const
std
::
string
&
field_id
,
ElementTypeMapArray
<
T
>
&
internal_flat
,
const
GhostType
ghost_type
=
_not_ghost
,
ElementKind
element_kind
=
_ek_not_defined
)
const
;
/* ------------------------------------------------------------------------
*/
/* Accessors */
/* ------------------------------------------------------------------------
*/
public
:
AKANTU_GET_MACRO
(
Name
,
name
,
const
std
::
string
&
);
AKANTU_GET_MACRO
(
ID
,
id
,
const
ID
&
);
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST
(
ElementFilter
,
element_filter
,
UInt
);
template
<
typename
T
>
ElementTypeMap
<
UInt
>
getInternalDataPerElem
(
const
ID
&
id
,
ElementKind
element_kind
)
const
;
protected
:
bool
isInit
()
const
{
return
is_init
;
}
/* ------------------------------------------------------------------------
*/
/* Class Members */
/* ------------------------------------------------------------------------
*/
private
:
/// boolean to know if the constitutive law has been initialized
bool
is_init
{
false
};
std
::
map
<
ID
,
std
::
shared_ptr
<
InternalFieldBase
>>
internal_vectors
;
protected
:
ID
id
;
/// constitutive law name
std
::
string
name
;
/// list of element handled by the constitutive law
ElementTypeMapArray
<
UInt
>
element_filter
;
// Constitutive law handler for which this is a constitutive law
ConstitutiveLawsHandler
&
handler
;
};
}
// namespace akantu
#include "constitutive_law_tmpl.hh"
#endif
Event Timeline
Log In to Comment