Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61898336
westergaard.cpp
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
Thu, May 9, 16:26
Size
6 KB
Mime Type
text/x-c++
Expires
Sat, May 11, 16:26 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17574267
Attached To
rTAMAAS tamaas
westergaard.cpp
View Options
/**
*
* @author Lucas Frérot <lucas.frerot@epfl.ch>
*
* @section LICENSE
*
* Copyright (©) 2017 EPFL (Ecole Polytechnique Fédérale de
* Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
* Solides)
*
* Tamaas 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.
*
* Tamaas 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 Tamaas. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "westergaard.hh"
#include "fft_plan_manager.hh"
#include "types.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_TAMAAS__
/* -------------------------------------------------------------------------- */
template
<
model_type
type
>
Westergaard
<
type
>::
Westergaard
(
Model
*
model
)
:
BEEngine
(
model
)
{
// Copy sizes
std
::
array
<
UInt
,
trait
::
dimension
>
sizes
;
std
::
copy
(
model
->
getDiscretization
().
begin
(),
model
->
getDiscretization
().
end
(),
sizes
.
begin
());
auto
hermitian_sizes
=
GridHermitian
<
Real
,
trait
::
dimension
>::
hermitianDimensions
(
sizes
);
// Copy boundary sizes
auto
sizes_it
=
sizes
.
begin
();
std
::
array
<
UInt
,
trait
::
boundary_dimension
>
boundary_hermitian_sizes
;
// Ignoring first dimension if model is volumetric
if
(
trait
::
dimension
>
trait
::
boundary_dimension
)
++
sizes_it
;
std
::
copy
(
sizes_it
,
sizes
.
end
(),
boundary_hermitian_sizes
.
begin
());
boundary_hermitian_sizes
=
GridHermitian
<
Real
,
trait
::
boundary_dimension
>::
hermitianDimensions
(
boundary_hermitian_sizes
);
constexpr
UInt
nb_components
=
trait
::
components
;
buffer
.
setNbComponents
(
nb_components
);
buffer
.
resize
(
boundary_hermitian_sizes
);
influence
.
setNbComponents
(
nb_components
*
nb_components
);
influence
.
resize
(
hermitian_sizes
);
}
/* -------------------------------------------------------------------------- */
template
<
model_type
type
>
void
Westergaard
<
type
>::
initInfluence
()
{
TAMAAS_EXCEPTION
(
"Not implemented"
);
}
#define INFLUENCE_BASIC_MACRO do { \
constexpr UInt bdim = trait::boundary_dimension; \
constexpr UInt comp = trait::components; \
auto wavevectors = \
FFTransform<Real, bdim>::computeFrequencies<true>(influence.sizes()); \
auto wave_begin = wavevectors.begin(bdim), wave_it = wavevectors.begin(bdim); \
auto inf_b = influence.begin(comp), \
inf_end = influence.end(comp); \
VectorProxy<Real> \
domain(const_cast<Real*>(model->getSystemSize().data()), bdim); \
Real E_star = model->getHertzModulus(); \
_Pragma("omp parallel for firstprivate(wave_it)") \
for (auto inf_it = inf_b ; \
inf_it < inf_end ; \
++inf_it) { \
wave_it = wave_begin; \
wave_it += inf_it - inf_b; \
VectorProxy<Real> q_vec(&(*wave_it), bdim); \
q_vec *= 2 * M_PI; \
q_vec /= domain; \
Real q = q_vec.l2norm(); \
*inf_it = 2. / (q*E_star); \
} \
influence(0) = 0; \
} while(0)
template
<>
void
Westergaard
<
model_type
::
basic_2d
>::
initInfluence
()
{
INFLUENCE_BASIC_MACRO
;
}
template
<>
void
Westergaard
<
model_type
::
basic_1d
>::
initInfluence
()
{
INFLUENCE_BASIC_MACRO
;
}
/* -------------------------------------------------------------------------- */
#define SOLVE_BASIC(op) do { \
Grid<Real, trait::boundary_dimension> \
& i = dynamic_cast<decltype(i)>(in); \
Grid<Real, trait::boundary_dimension> \
& o = dynamic_cast<decltype(o)>(out); \
\
auto & fwd = FFTPlanManager::get().createPlan(i, buffer); \
auto & bwd = FFTPlanManager::get().createPlan(o, buffer); \
\
fwd.forwardTransform(); \
buffer op influence; \
buffer(0) = 0; \
bwd.backwardTransform(); \
} while(0)
template
<>
void
Westergaard
<
model_type
::
basic_1d
>::
solveNeumann
(
GridBase
<
Real
>
&
in
,
GridBase
<
Real
>
&
out
)
try
{
SOLVE_BASIC
(
*=
);
}
catch
(
const
std
::
bad_cast
&
e
)
{
TAMAAS_EXCEPTION
(
"Neumann and dirichlet types do not match model type"
);
}
template
<>
void
Westergaard
<
model_type
::
basic_1d
>::
solveDirichlet
(
GridBase
<
Real
>
&
in
,
GridBase
<
Real
>
&
out
)
try
{
SOLVE_BASIC
(
/=
);
}
catch
(
const
std
::
bad_cast
&
e
)
{
TAMAAS_EXCEPTION
(
"Neumann and dirichlet types do not match model type"
);
}
template
<>
void
Westergaard
<
model_type
::
basic_2d
>::
solveNeumann
(
GridBase
<
Real
>
&
in
,
GridBase
<
Real
>
&
out
)
try
{
SOLVE_BASIC
(
*=
);
}
catch
(
const
std
::
bad_cast
&
e
)
{
TAMAAS_EXCEPTION
(
"Neumann and dirichlet types do not match model type"
);
}
template
<>
void
Westergaard
<
model_type
::
basic_2d
>::
solveDirichlet
(
GridBase
<
Real
>
&
in
,
GridBase
<
Real
>
&
out
)
try
{
SOLVE_BASIC
(
/=
);
}
catch
(
const
std
::
bad_cast
&
e
)
{
TAMAAS_EXCEPTION
(
"Neumann and dirichlet types do not match model type"
);
}
/* -------------------------------------------------------------------------- */
template
<
model_type
type
>
void
Westergaard
<
type
>::
solveNeumann
(
GridBase
<
Real
>
&
neumann
,
GridBase
<
Real
>
&
dirichlet
)
{
TAMAAS_EXCEPTION
(
"Not yet implemented"
);
}
/* -------------------------------------------------------------------------- */
template
<
model_type
type
>
void
Westergaard
<
type
>::
solveDirichlet
(
GridBase
<
Real
>
&
neumann
,
GridBase
<
Real
>
&
dirichlet
)
{
TAMAAS_EXCEPTION
(
"Not yet implemented"
);
}
/* -------------------------------------------------------------------------- */
/* Template instanciation */
/* -------------------------------------------------------------------------- */
template
class
Westergaard
<
model_type
::
basic_1d
>
;
template
class
Westergaard
<
model_type
::
basic_2d
>
;
template
class
Westergaard
<
model_type
::
surface_1d
>
;
template
class
Westergaard
<
model_type
::
surface_2d
>
;
template
class
Westergaard
<
model_type
::
volume_1d
>
;
template
class
Westergaard
<
model_type
::
volume_2d
>
;
/* -------------------------------------------------------------------------- */
__END_TAMAAS__
/* -------------------------------------------------------------------------- */
Event Timeline
Log In to Comment