Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F65047348
material_points_factory.cc
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
Fri, May 31, 08:59
Size
2 KB
Mime Type
text/x-c
Expires
Sun, Jun 2, 08:59 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17974474
Attached To
R9482 SP4E_Homework_Ashtari_Sieber
material_points_factory.cc
View Options
#include "material_points_factory.hh"
#include "compute_temperature.hh"
#include "csv_reader.hh"
#include "csv_writer.hh"
#include "material_point.hh"
#include <cmath>
#include <iostream>
/* -------------------------------------------------------------------------- */
std
::
unique_ptr
<
Particle
>
MaterialPointsFactory
::
createParticle
()
{
return
std
::
make_unique
<
MaterialPoint
>
();
}
/* -------------------------------------------------------------------------- */
SystemEvolution
&
MaterialPointsFactory
::
createSimulation
(
const
std
::
string
&
fname
,
Real
timestep
,
int
argc
,
char
**
argv
)
{
this
->
system_evolution
=
std
::
make_unique
<
SystemEvolution
>
(
std
::
make_unique
<
System
>
());
CsvReader
reader
(
fname
);
reader
.
read
(
this
->
system_evolution
->
getSystem
());
// check if it is a square number
auto
N
=
this
->
system_evolution
->
getSystem
().
getNbParticles
();
int
side
=
std
::
sqrt
(
N
);
if
(
side
*
side
!=
N
)
throw
std
::
runtime_error
(
"number of particles is not square"
);
Real
length
,
rho_C
,
kappa
;
std
::
string
BC_type
;
std
::
stringstream
(
argv
[
argc
-
4
])
>>
BC_type
;
// The 4th trailing argument: the type of boundary condition.
std
::
stringstream
(
argv
[
argc
-
3
])
>>
length
;
// The 3rd trailing argument: length of the domain.
std
::
stringstream
(
argv
[
argc
-
2
])
>>
rho_C
;
// The 2nd trailing argument: density times heat capacity.
std
::
stringstream
(
argv
[
argc
-
1
])
>>
kappa
;
// The 1st trailing argument: thermal conductivity.
auto
temperature
=
std
::
make_shared
<
ComputeTemperature
>
(
timestep
,
length
,
rho_C
,
kappa
,
BC_type
);
this
->
system_evolution
->
addCompute
(
temperature
);
return
*
system_evolution
;
}
/* -------------------------------------------------------------------------- */
ParticlesFactoryInterface
&
MaterialPointsFactory
::
getInstance
()
{
if
(
not
ParticlesFactoryInterface
::
factory
)
ParticlesFactoryInterface
::
factory
=
new
MaterialPointsFactory
;
return
*
factory
;
}
/* -------------------------------------------------------------------------- */
Event Timeline
Log In to Comment