Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F88835671
container_mesh.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
Sun, Oct 20, 22:22
Size
8 KB
Mime Type
text/x-c++
Expires
Tue, Oct 22, 22:22 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
21824600
Attached To
rLIBMULTISCALE LibMultiScale
container_mesh.hh
View Options
/**
* @file container_mesh.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date Mon Sep 08 23:40:22 2014
*
* @brief This is the abstract container for mesh data
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* LibMultiScale 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.
*
* LibMultiScale 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 LibMultiScale. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __LIBMULTISCALE_CONTAINER_MESH_HH__
#define __LIBMULTISCALE_CONTAINER_MESH_HH__
/* -------------------------------------------------------------------------- */
#include "container.hh"
#include "container_array.hh"
#include "ref_point_data.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
template
<
typename
ContNodes
,
typename
ContElems
>
class
ContainerMesh
:
public
Container_base
<
typename
ContNodes
::
Ref
>
{
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
public
:
typedef
ContNodes
ContainerNodes
;
typedef
ContElems
ContainerElems
;
typedef
typename
ContNodes
::
iterator
iterator
;
typedef
typename
ContNodes
::
Ref
Ref
;
typedef
typename
ContElems
::
Ref
RefElem
;
typedef
ContainerMesh
<
ContainerArray
<
Ref
>
,
ContainerArray
<
RefElem
>>
ContainerSubset
;
static
const
UInt
Dim
=
ContainerNodes
::
Dim
;
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public
:
ContainerMesh
(
ContNodes
&
cN
,
ContElems
&
cEl
);
ContainerMesh
();
virtual
~
ContainerMesh
();
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public
:
void
incRelease
()
{
Container_base
<
typename
ContNodes
::
Ref
>::
incRelease
();
container_nodes
->
incRelease
();
container_elems
->
incRelease
();
};
void
setRelease
(
UInt
rel
)
{
Container_base
<
typename
ContNodes
::
Ref
>::
setRelease
(
rel
);
container_nodes
->
setRelease
(
rel
);
container_elems
->
setRelease
(
rel
);
};
operator
ContainerNodes
&
()
{
LM_FATAL
(
"silent conversion from ContainerMesh to ContainerNode is not allowed"
);
return
*
container_nodes
;
}
iterator
getIterator
(
DOFType
dt
=
dt_local
)
{
return
container_nodes
->
getIterator
(
dt
);
};
void
add
(
const
Ref
&
node
)
{
container_nodes
->
add
(
node
);
}
Ref
&
get
(
UInt
index
)
{
return
container_nodes
->
get
(
index
);
}
void
empty
()
{
container_nodes
->
empty
();
container_elems
->
empty
();
}
UInt
nbElem
(
DOFType
dt
=
dt_local
)
{
return
container_nodes
->
nbElem
(
dt
);
};
template
<
typename
ContNodesPristine
>
void
computeAlteredConnectivity
(
ContNodesPristine
&
contNodes
);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public
:
ContNodes
&
getArray
()
{
return
this
->
getContainerNodes
();
};
ContNodes
&
getContainerNodes
()
{
return
*
container_nodes
;
};
ContElems
&
getContainerElems
()
{
return
*
container_elems
;
};
UInt
subIndex2Index
(
UInt
index
)
{
LM_ASSERT
(
nodeIndexList
.
nbElem
()
>
0
,
"nodeIndexList was not initialized: did you call "
<<
"computeAlteredConnectivity method ?"
);
return
nodeIndexList
.
searchInSorted
(
index
);
};
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private
:
ContNodes
*
container_nodes
;
ContElems
*
container_elems
;
ContainerArray
<
UInt
>
nodeIndexList
;
bool
self_allocated
;
};
/* -------------------------------------------------------------------------- */
template
<
typename
ContNodes
,
typename
ContElems
>
ContainerMesh
<
ContNodes
,
ContElems
>::
ContainerMesh
(
ContNodes
&
cN
,
ContElems
&
cEl
)
:
container_nodes
(
&
cN
),
container_elems
(
&
cEl
)
{
self_allocated
=
false
;
}
/* -------------------------------------------------------------------------- */
template
<
typename
ContNodes
,
typename
ContElems
>
ContainerMesh
<
ContNodes
,
ContElems
>::
ContainerMesh
()
:
container_nodes
(
new
ContNodes
()),
container_elems
(
new
ContElems
())
{
self_allocated
=
true
;
}
/* -------------------------------------------------------------------------- */
template
<
typename
ContNodes
,
typename
ContElems
>
ContainerMesh
<
ContNodes
,
ContElems
>::~
ContainerMesh
()
{
if
(
self_allocated
)
{
delete
(
container_nodes
);
delete
(
container_elems
);
}
}
/* -------------------------------------------------------------------------- */
template
<
typename
ContNodes
,
typename
ContElems
>
template
<
typename
ContNodesPristine
>
void
ContainerMesh
<
ContNodes
,
ContElems
>::
computeAlteredConnectivity
(
ContNodesPristine
&
contNodes
)
{
std
::
vector
<
UInt
>
connectivity
;
typename
ContElems
::
iterator
itElem
=
container_elems
->
getIterator
();
for
(
typename
ContElems
::
Ref
el
=
itElem
.
getFirst
();
!
itElem
.
end
();
el
=
itElem
.
getNext
())
{
el
.
globalIndexes
(
connectivity
);
for
(
UInt
n
=
0
;
n
<
connectivity
.
size
();
++
n
)
nodeIndexList
.
addInSorted
(
connectivity
[
n
]);
}
ContainerArray
<
UInt
>::
iterator
itNdIndex
=
nodeIndexList
.
getIterator
();
for
(
UInt
n_index
=
itNdIndex
.
getFirst
();
!
itNdIndex
.
end
();
n_index
=
itNdIndex
.
getNext
())
{
container_nodes
->
add
(
contNodes
.
get
(
n_index
));
}
// recompute the connectivity
std
::
vector
<
UInt
>
altered_connectivity
;
for
(
UInt
i
=
0
;
i
<
container_elems
->
nbElem
();
++
i
)
{
typename
ContainerElems
::
Ref
&
el
=
container_elems
->
get
(
i
);
el
.
globalIndexes
(
connectivity
);
altered_connectivity
.
resize
(
connectivity
.
size
());
for
(
UInt
n
=
0
;
n
<
connectivity
.
size
();
++
n
)
altered_connectivity
[
n
]
=
nodeIndexList
.
searchInSorted
(
connectivity
[
n
]);
el
.
setAlteredConnectivity
(
altered_connectivity
);
}
}
/* -------------------------------------------------------------------------- */
template
<
UInt
_Dim
>
class
RefGenericElem
{
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
public
:
static
const
UInt
Dim
=
_Dim
;
public
:
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
public
:
void
setConnectivity
(
Real
*
conn
,
UInt
nb_nodes_per_element
)
{
this
->
conn
.
resize
(
nb_nodes_per_element
);
for
(
UInt
i
=
0
;
i
<
nb_nodes_per_element
;
++
i
)
{
this
->
conn
[
i
]
=
conn
[
i
];
}
}
bool
operator
==
(
RefGenericElem
&
e
)
{
LM_TOIMPLEMENT
;
return
true
;
};
//! return the local indexes (in DOF vector) for connected nodes
inline
void
localIndexes
(
std
::
vector
<
UInt
>
&
nodes
)
{
nodes
=
this
->
conn
;
}
inline
void
setAlteredConnectivity
(
std
::
vector
<
UInt
>
&
altered_connectivity
)
{
LM_TOIMPLEMENT
;
};
inline
std
::
vector
<
UInt
>
&
getAlteredConnectivity
()
{
LM_TOIMPLEMENT
;
};
inline
bool
isAltered
()
{
return
false
;
};
Real
stress
(
UInt
coord
)
{
LM_TOIMPLEMENT
;
};
Real
strain
(
UInt
coord
)
{
LM_TOIMPLEMENT
;
};
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
// private:
std
::
vector
<
UInt
>
conn
;
};
template
<
UInt
Dim
>
class
ContainerGenericMesh
:
public
ContainerMesh
<
ContainerArray
<
RefPointData
<
Dim
>>
,
ContainerArray
<
RefGenericElem
<
Dim
>>>
{};
__END_LIBMULTISCALE__
#endif
/* __LIBMULTISCALE_CONTAINER_MESH_HH__ */
Event Timeline
Log In to Comment