Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-curvedgrid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iwr
dune-curvedgrid
Commits
01eb2b82
Commit
01eb2b82
authored
4 years ago
by
Lisa Julia Nebel
Browse files
Options
Downloads
Patches
Plain Diff
Add Functor representing a cylinder in 3d
parent
8c013aba
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/curvedgrid/geometries/cylinder.hh
+89
-0
89 additions, 0 deletions
dune/curvedgrid/geometries/cylinder.hh
with
89 additions
and
0 deletions
dune/curvedgrid/geometries/cylinder.hh
0 → 100644
+
89
−
0
View file @
01eb2b82
#ifndef DUNE_CURVEDGRID_CYLINDER_GRIDFUNCTION_HH
#define DUNE_CURVEDGRID_CYLINDER_GRIDFUNCTION_HH
#include
<cmath>
#include
<dune/common/fmatrix.hh>
#include
<dune/common/fvector.hh>
#include
<dune/curvedgrid/gridfunctions/analyticgridfunction.hh>
namespace
Dune
{
/// \brief Functor representing a cylinder in 3D
template
<
class
T
=
double
>
class
CylinderProjection
{
static
const
int
dim
=
3
;
using
Domain
=
FieldVector
<
T
,
dim
>
;
using
Jacobian
=
FieldMatrix
<
T
,
dim
,
dim
>
;
T
radius_
;
public:
CylinderProjection
(
T
radius
)
:
radius_
(
radius
)
{}
/// \brief Project the coordinate to the cylinder at origin with radius
// leaving the x[2] coordinate as it is
Domain
operator
()
(
const
Domain
&
x
)
const
{
Domain
point
;
double
radiusOverNorm
=
radius_
/
std
::
sqrt
(
x
[
0
]
*
x
[
0
]
+
x
[
1
]
*
x
[
1
]);
point
[
0
]
=
radiusOverNorm
*
x
[
0
];
point
[
1
]
=
radiusOverNorm
*
x
[
1
];
point
[
2
]
=
x
[
2
];
return
point
;
}
/// \brief derivative of the projection to the cylinder
friend
auto
derivative
(
const
CylinderProjection
&
cylinder
)
{
return
[
r
=
cylinder
.
radius_
](
const
Domain
&
x
)
{
Jacobian
out
;
auto
nrm
=
std
::
sqrt
(
x
[
0
]
*
x
[
0
]
+
x
[
1
]
*
x
[
1
]);
for
(
int
i
=
0
;
i
<
dim
-
1
;
++
i
)
for
(
int
j
=
0
;
j
<
dim
-
1
;
++
j
)
out
[
i
][
j
]
=
r
*
((
i
==
j
?
1
:
0
)
-
(
x
[
i
]
/
nrm
)
*
(
x
[
j
]
/
nrm
))
/
nrm
;
for
(
int
i
=
0
;
i
<
dim
-
1
;
++
i
)
{
out
[
2
][
i
]
=
0
;
out
[
i
][
2
]
=
0
;
}
out
[
2
][
2
]
=
1
;
return
out
;
};
}
/// \brief normal vector, only points into x[0]-x[1]-direction, does not depend on x[2]
Domain
normal
(
const
Domain
&
x
)
const
{
Domain
nVec
=
{
0
,
0
,
0
};
nVec
[
0
]
=
x
[
0
]
/
std
::
sqrt
(
x
[
0
]
*
x
[
0
]
+
x
[
1
]
*
x
[
1
]);
nVec
[
1
]
=
x
[
1
]
/
std
::
sqrt
(
x
[
0
]
*
x
[
0
]
+
x
[
1
]
*
x
[
1
]);
return
nVec
;
}
/// \brief mean curvature of the cylinder is 1/(2*radius)
T
mean_curvature
(
const
Domain
&
/*x*/
)
const
{
return
T
(
1
)
/
(
2
*
radius_
);
}
/// \brief area of the cylinder
T
area
(
T
height
)
const
{
return
2
*
M_PI
*
radius_
*
height
;
}
};
/// \brief construct a grid function representing a cylinder parametrization
template
<
class
Grid
,
class
T
>
auto
cylinderGridFunction
(
T
radius
)
{
return
analyticGridFunction
<
Grid
>
(
CylinderProjection
<
T
>
{
radius
});
}
}
// end namespace Dune
#endif // DUNE_CURVEDGRID_CYLINDER_GRIDFUNCTION_HH
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment