Skip to content

Commit d43c8ee

Browse files
committed
initial commit.
0 parents  commit d43c8ee

File tree

13 files changed

+2002
-0
lines changed

13 files changed

+2002
-0
lines changed

CMakeLists.txt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
##
2+
# CMake script for the step-42 tutorial program:
3+
##
4+
5+
# Set the name of the project and target:
6+
SET(TARGET "LDGPoisson")
7+
8+
# Declare all source files the target consists of:
9+
SET(TARGET_SRC
10+
${TARGET}.cc
11+
Functions.cc
12+
)
13+
14+
# Define the output that should be cleaned:
15+
SET(CLEAN_UP_FILES *.vtu *.pvtu *.visit)
16+
17+
# Usually, you will not need to modify anything beyond this point...
18+
19+
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
20+
21+
FIND_PACKAGE(deal.II 8.0 QUIET
22+
HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
23+
)
24+
IF(NOT ${deal.II_FOUND})
25+
MESSAGE(FATAL_ERROR "\n"
26+
"*** Could not locate deal.II. ***\n\n"
27+
"You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n"
28+
"or set an environment variable \"DEAL_II_DIR\" that contains this path."
29+
)
30+
ENDIF()
31+
32+
#
33+
# Are all dependencies fullfilled?
34+
#
35+
IF( NOT DEAL_II_WITH_MPI OR
36+
NOT DEAL_II_WITH_P4EST OR
37+
NOT DEAL_II_WITH_TRILINOS )
38+
MESSAGE(FATAL_ERROR "
39+
Error! The deal.II library found at ${DEAL_II_PATH} was not configured with
40+
DEAL_II_WITH_MPI = ON
41+
DEAL_II_WITH_P4EST = ON
42+
DEAL_II_WITH_TRILINOS = ON
43+
One or all of these are OFF in your installation but are required for this tutorial step."
44+
)
45+
ENDIF()
46+
47+
DEAL_II_INITIALIZE_CACHED_VARIABLES()
48+
PROJECT(${TARGET})
49+
50+
DEAL_II_INVOKE_AUTOPILOT()

Functions.cc

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// @sect3{Functions.cc}
2+
// In this file we keep right hand side function, Dirichlet boundary
3+
// conditions and solution to our Poisson equation problem. Since
4+
// these classes and functions have been discussed extensively in
5+
// the deal.ii tutorials we won't discuss them any further.
6+
#include <deal.II/base/function.h>
7+
#include <deal.II/base/tensor_function.h>
8+
#include <deal.II/lac/vector.h>
9+
#include <cmath>
10+
11+
using namespace dealii;
12+
13+
template <int dim>
14+
class RightHandSide : public Function<dim>
15+
{
16+
public:
17+
RightHandSide() : Function<dim>(1)
18+
{}
19+
20+
virtual double value(const Point<dim> &p,
21+
const unsigned int component = 0 ) const;
22+
};
23+
24+
template <int dim>
25+
class DirichletBoundaryValues : public Function<dim>
26+
{
27+
public:
28+
DirichletBoundaryValues() : Function<dim>(1)
29+
{}
30+
31+
virtual double value(const Point<dim> &p,
32+
const unsigned int component = 0 ) const;
33+
};
34+
35+
template<int dim>
36+
class TrueSolution : public Function<dim>
37+
{
38+
public:
39+
TrueSolution() : Function<dim>(dim+1)
40+
{}
41+
42+
virtual void vector_value(const Point<dim> & p,
43+
Vector<double> &valuess) const;
44+
};
45+
46+
template <int dim>
47+
double
48+
RightHandSide<dim>::
49+
value(const Point<dim> &p,
50+
const unsigned int ) const
51+
{
52+
const double x = p[0];
53+
const double y = p[1];
54+
return 4*M_PI*M_PI*(cos(2*M_PI*y) - sin(2*M_PI*x));
55+
56+
}
57+
58+
template <int dim>
59+
double
60+
DirichletBoundaryValues<dim>::
61+
value(const Point<dim> &p,
62+
const unsigned int ) const
63+
{
64+
const double x = p[0];
65+
const double y = p[1];
66+
return cos(2*M_PI*y) -sin(2*M_PI*x) - x;
67+
}
68+
69+
70+
template <int dim>
71+
void
72+
TrueSolution<dim>::
73+
vector_value(const Point<dim> &p,
74+
Vector<double> &values) const
75+
{
76+
Assert(values.size() == dim+1,
77+
ExcDimensionMismatch(values.size(), dim+1) );
78+
79+
double x = p[0];
80+
double y = p[1];
81+
82+
values(0) = 1 + 2*M_PI*cos(2*M_PI*x);
83+
values(1) = 2*M_PI*sin(2*M_PI*y);
84+
85+
values(2) = cos(2*M_PI*y) - sin(2*M_PI*x) - x;
86+
}

0 commit comments

Comments
 (0)