Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93693724
generic_mesh1d.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
Sat, Nov 30, 18:43
Size
4 KB
Mime Type
text/x-c
Expires
Mon, Dec 2, 18:43 (1 d, 20 h)
Engine
blob
Format
Raw Data
Handle
22687936
Attached To
rSPECMICP SpecMiCP / ReactMiCP
generic_mesh1d.cpp
View Options
/* =============================================================================
Copyright (c) 2014 - 2016
F. Georget <fabieng@princeton.edu> Princeton University
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
============================================================================= */
#include "generic_mesh1d.hpp"
namespace
specmicp
{
namespace
mesh
{
GenericMesh1D
::
GenericMesh1D
(
const
Vector
&
coords
,
scalar_t
section
)
:
Mesh1D
(
coords
.
rows
()),
m_section
(
section
),
m_data
(
coords
.
rows
(),
4
),
m_face_coord
(
coords
.
rows
()
-
1
)
{
// radius
m_data
.
col
(
coord
)
=
coords
;
// Radius of the faces
for
(
index_t
element
=
0
;
element
<
nb_elements
();
++
element
)
{
m_face_coord
(
element
)
=
(
coords
(
element
+
1
)
+
coords
(
element
))
/
2.0
;
}
// Volume at the left of the cell
m_data
(
0
,
cell_vol_0
)
=
0.0
;
for
(
index_t
node
=
1
;
node
<
nb_nodes
();
++
node
)
{
m_data
(
node
,
cell_vol_0
)
=
m_section
*
(
coords
(
node
)
-
m_face_coord
(
node
-
1
));
}
// Volume of the cell at the right of the node
for
(
index_t
node
=
0
;
node
<
nb_nodes
()
-
1
;
++
node
)
{
m_data
(
node
,
cell_vol_1
)
=
m_section
*
(
m_face_coord
(
node
)
-
coords
(
node
));
}
m_data
(
nb_nodes
()
-
1
,
cell_vol_1
)
=
0.0
;
}
Mesh1DPtr
uniform_mesh1d
(
const
Uniform1DMeshGeometry
&
geometry
)
{
Vector
coords
(
geometry
.
nb_nodes
);
for
(
auto
node
=
0
;
node
<
geometry
.
nb_nodes
;
++
node
)
{
coords
(
node
)
=
node
*
geometry
.
dx
;
}
Mesh1DPtr
mesh
=
generic_mesh1d
(
coords
,
geometry
.
section
);
return
mesh
;
}
Mesh1DPtr
generic_mesh1d
(
const
Vector
&
coords
,
scalar_t
section
)
{
return
std
::
static_pointer_cast
<
Mesh1D
>
(
std
::
make_shared
<
GenericMesh1D
>
(
coords
,
section
));
}
Mesh1DPtr
SPECMICP_DLL_PUBLIC
ramp_mesh1d
(
const
Ramp1DMeshGeometry
&
geometry
)
{
const
scalar_t
b
=
geometry
.
dx_min
;
const
scalar_t
a
=
(
geometry
.
dx_max
-
geometry
.
dx_min
)
/
geometry
.
length_ramp
;
std
::
vector
<
scalar_t
>
coords
;
coords
.
reserve
(
ceil
(
geometry
.
length_plateau
/
geometry
.
dx_max
+
2
*
geometry
.
length_ramp
/
(
geometry
.
dx_max
+
geometry
.
dx_min
)
)
+
5
);
scalar_t
x
=
0
;
coords
.
push_back
(
x
);
while
(
x
<
geometry
.
length_ramp
)
{
scalar_t
hbar
=
a
*
x
+
b
;
scalar_t
mult
=
std
::
floor
(
hbar
/
geometry
.
dx_min
);
scalar_t
rem
=
hbar
-
mult
*
geometry
.
dx_min
;
if
(
rem
/
geometry
.
dx_min
<
0.5
)
x
+=
mult
*
geometry
.
dx_min
;
else
x
+=
(
mult
+
1
)
*
geometry
.
dx_min
;
coords
.
push_back
(
x
);
}
while
(
x
<
geometry
.
length_plateau
+
geometry
.
length_ramp
)
{
x
+=
geometry
.
dx_max
;
coords
.
push_back
(
x
);
}
Vector
eig_coords
=
Eigen
::
Map
<
Vector
>
(
coords
.
data
(),
coords
.
size
());
return
generic_mesh1d
(
eig_coords
,
geometry
.
section
);
}
}
//end namespace mesh
}
//end namespace specmicp
Event Timeline
Log In to Comment