Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thm segregate #3

Open
wants to merge 57 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
7ef2468
:construction: THM code
kks32 Nov 20, 2019
7d438ac
successful compiling
shyaan Nov 21, 2019
af2067b
:hammer: Fix run function in Geothermal and refactor typo in Geotherm…
kks32 Nov 21, 2019
6f53037
:hammer: :dart: Fix CircleCI compile with Dealii path
kks32 Nov 21, 2019
4d7a203
add setp-dof
shyaan Dec 10, 2019
aed4424
derivation
shyaan Jan 15, 2020
ea67808
add some new lines
shyaan Feb 4, 2020
531d086
Merge branch 'thm' of https://github.com/cb-geo/thm into thm
shyaan Feb 4, 2020
3306755
setup_dofs
shyaan Feb 5, 2020
8953baf
simlified
shyaan Mar 3, 2020
2a9edd1
add vscode
shyaan Mar 6, 2020
37378b8
add data collection
shyaan Mar 7, 2020
26973de
add new namespace
shyaan Mar 8, 2020
321774d
add new namespace
shyaan Mar 8, 2020
1ecc328
reorganaizing
shyaan Mar 8, 2020
4268735
change boundary
shyaan Mar 9, 2020
fdd4287
segregate
shyaan Mar 10, 2020
4de1472
revise
shyaan Mar 12, 2020
4da1d64
major reivise
shyaan Mar 15, 2020
051dd0a
bracket
shyaan Mar 15, 2020
c96b8db
ajust the form
shyaan Mar 15, 2020
6aff33b
ADD INITIAL CONDITION
shyaan Mar 16, 2020
04ebbf3
build
shyaan Mar 16, 2020
9b477c3
add quadratrue_points
shyaan Mar 17, 2020
34b5048
after debug
shyaan Mar 23, 2020
948ff88
:dart: Use THM container for CircleCI
kks32 Apr 1, 2020
7bded89
:pencil: :art: Fix formatting
kks32 Apr 1, 2020
5e7f419
:fire: Remove codecoverage in CI
kks32 Apr 1, 2020
de08307
Place the system matrix assembing outside
shyaan Apr 2, 2020
d103f92
ADD TIMER
shyaan Apr 2, 2020
e1a325e
:clock: Refactor timer class
kks32 Apr 2, 2020
a8213eb
:art: Fix formatting
kks32 Apr 2, 2020
2cbe6a2
add convection term and parameter with physical meaning
shyaan Apr 3, 2020
b20437c
Merge branch 'thm_segregate' of https://github.com/cb-geo/thm into th…
shyaan Apr 3, 2020
3c8b1c0
debug the rhs problem
shyaan Apr 10, 2020
baead91
add test
shyaan Apr 17, 2020
e685379
add GMRES and coupling effects
shyaan Apr 18, 2020
43a9c17
typo checking
shyaan Apr 28, 2020
3e9d699
add gravity and more boundary
shyaan May 4, 2020
3306a3e
input parameter from txt file
shyaan May 11, 2020
5bebcb3
inport parameter from parameter.txt
shyaan May 11, 2020
eb4af06
add get_parameter fucntion to get pamameter from txt file
shyaan May 12, 2020
6b8470a
change txt to csv
shyaan May 13, 2020
f545078
add distribution
shyaan May 15, 2020
3164158
:wrench: Fix CPP check error in boundary values
kks32 May 25, 2020
34dbe9a
:wrench: Fix CPP check error in boundary values temp boundary
kks32 May 25, 2020
fc43fb5
:pencil: :art: Fix clang-format errors
kks32 May 25, 2020
230bedd
:wrench: Fix missing csv in external
kks32 May 25, 2020
9e63672
change the parameters
shyaan May 25, 2020
96b4cb1
Merge branch 'thm_segregate' of https://github.com/cb-geo/thm into th…
shyaan May 25, 2020
a6e2ea1
amend all names of variables
shyaan May 26, 2020
cdca305
amend the format and add solver settins to input file
shyaan May 29, 2020
cd51db7
setup a benchmark case
shyaan Jun 4, 2020
1300f3c
adjust format
shyaan Jun 4, 2020
57f1df9
amend the constructor
shyaan Jun 4, 2020
7d5d18e
adjust format
shyaan Jun 4, 2020
dea94b7
remove idle sys matrix
shyaan Jun 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ endif()
# so we provide an option similar to BUILD_TESTING, but just for THM.
option(THM_BUILD_TESTING "enable testing for thm" ON)

# Add -O0 to remove optimizations when using gcc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this, please pass -DCMAKE_BUILD_TYPE=Debug when compiling

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make "DCMAKE_BUILD_TYPE=Debug" ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmake -DCMAKE_BUILD_TYPE=Debug

IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
ENDIF(CMAKE_COMPILER_IS_GNUCC)

# CMake Modules
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

Expand Down Expand Up @@ -71,6 +77,7 @@ DEAL_II_INITIALIZE_CACHED_VARIABLES()
PROJECT(${TARGET})
DEAL_II_INVOKE_AUTOPILOT()


#add_library(lthm SHARED ${thm_src})

# add_executable(geothm ${thm_SOURCE_DIR}/src/main.cc)
Expand Down
3 changes: 2 additions & 1 deletion include/boundaryvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ double TemperatureDirichletBoundaryValues<dim>::value(
// Assert(dim == 3, ExcNotImplemented());

const double time = this->get_time();
return T0 + 10. * sin(time / (5*3600*24) * 3.1415926); // boundary value is set to zero in
// return T0 + 10. * sin(time / (0.5*3600*24) * 3.1415926); // boundary value is set to zero in
// this case
return T0 ;
}

// template <int dim>
Expand Down
79 changes: 47 additions & 32 deletions include/geothermal.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ class CoupledTH {
unsigned int timestep_number; // n_t

const double theta = 0.5;
const double period = 25*3600*24;
const double time_step = period / 50;
const double period = 1*3600*24;
const double time_step = period / 20;
};

template <int dim>
Expand Down Expand Up @@ -170,13 +170,14 @@ void CoupledTH<dim>::make_grid_and_dofs() {
sparsity_pattern.copy_from(T_dsp);

// forming system matrixes and initialize these matrixes
T_system_matrix.reinit(sparsity_pattern);
T_mass_matrix.reinit(sparsity_pattern);
T_stiffness_matrix.reinit(sparsity_pattern);
T_convection_matrix.reinit(sparsity_pattern);
T_stiffness_matrix.reinit(sparsity_pattern);
T_system_matrix.reinit(sparsity_pattern);
T_system_rhs.reinit(dof_handler.n_dofs());
T_solution.reinit(dof_handler.n_dofs());
old_T_solution.reinit(dof_handler.n_dofs());
T_system_rhs.reinit(dof_handler.n_dofs());


// sparsity pattern for P
DynamicSparsityPattern P_dsp(dof_handler.n_dofs()); // sparsity
Expand All @@ -185,12 +186,13 @@ void CoupledTH<dim>::make_grid_and_dofs() {
sparsity_pattern.copy_from(P_dsp);

// forming system matrixes and initialize these matrixes
P_system_matrix.reinit(sparsity_pattern);
P_mass_matrix.reinit(sparsity_pattern);
P_stiffness_matrix.reinit(sparsity_pattern);
P_system_matrix.reinit(sparsity_pattern);
P_system_rhs.reinit(dof_handler.n_dofs());
P_solution.reinit(dof_handler.n_dofs());
old_P_solution.reinit(dof_handler.n_dofs());
P_system_rhs.reinit(dof_handler.n_dofs());


// constraints.clear();
// DoFTools::make_hanging_node_constraints(
Expand All @@ -203,12 +205,16 @@ void CoupledTH<dim>::make_grid_and_dofs() {

template <int dim>
void CoupledTH<dim>::assemble_P_system() {

cbgeo::Clock timer;
timer.tick();

// reset matreix to zero
// p_mass_matrix = 0;
// p_stiffness_matrix = 0;
P_stiffness_matrix = 0;
P_mass_matrix = 0;
P_stiffness_matrix = 0;
P_system_matrix = 0;
P_system_rhs = 0;
P_solution = 0;

// Getting T values
QGauss<dim> T_quadrature_formula(T_degree + 1);
Expand Down Expand Up @@ -354,15 +360,15 @@ void CoupledTH<dim>::assemble_P_system() {
}

// ADD DIRICLET BOUNDARY
{
P_boundary.set_time(time);

P_boundary.set_time(time);

std::map<types::global_dof_index, double> P_bd_values;
VectorTools::interpolate_boundary_values(dof_handler, 1, P_boundary,
std::map<types::global_dof_index, double> P_bd_values;
VectorTools::interpolate_boundary_values(dof_handler, 1, P_boundary,
P_bd_values);
MatrixTools::apply_boundary_values(P_bd_values, P_system_matrix, P_solution,
MatrixTools::apply_boundary_values(P_bd_values, P_system_matrix, P_solution,
P_system_rhs);

}
timer.tock("assemble_P_system");
}

Expand All @@ -371,8 +377,12 @@ void CoupledTH<dim>::assemble_T_system() {
cbgeo::Clock timer;
timer.tick();
// reset matreix to zero
// T_mass_matrix = 0;
// T_stiffness_matrix = 0;
T_stiffness_matrix = 0;
T_mass_matrix = 0;
T_stiffness_matrix = 0;
T_system_matrix = 0;
T_system_rhs = 0;
T_solution = 0;

// Getting T values
QGauss<dim> T_quadrature_formula(T_degree + 1);
Expand Down Expand Up @@ -478,8 +488,8 @@ void CoupledTH<dim>::assemble_T_system() {
// time_step * (1 - theta) * grad_phi_i_T * old_T_sol_grads[q]) *
// T_fe_values.JxW(q);
T_local_rhs(i) +=
(phi_i_T * T_source_values[q] +
time_step * phi_i_T * old_T_sol_values[q]) * T_fe_values.JxW(q);
(time_step * T_source_values[q] + old_T_sol_values[q]) *
phi_i_T * T_fe_values.JxW(q);
}
}

Expand All @@ -494,8 +504,9 @@ void CoupledTH<dim>::assemble_T_system() {
QT_bd_values);
for (unsigned int q = 0; q < T_n_face_q_points; ++q) {
for (unsigned int i = 0; i < T_dofs_per_cell; ++i) {
T_local_rhs(i) += -T_fe_face_values.shape_value(i, q) *
QT_bd_values[q] * T_fe_face_values.JxW(q);
T_local_rhs(i) += -time_step / EquationData::c_T *
T_fe_face_values.shape_value(i, q) *
QT_bd_values[q] * T_fe_face_values.JxW(q);
}
}
}
Expand Down Expand Up @@ -525,17 +536,18 @@ void CoupledTH<dim>::assemble_T_system() {

}

// ADD DIRICLET BOUNDARY
T_boundary.set_time(time);
//ADD DIRICHLET BOUNDARY
{
T_boundary.set_time(time);

std::map<types::global_dof_index, double> T_bd_values;
VectorTools::interpolate_boundary_values(dof_handler, 1, T_boundary,
T_bd_values);
MatrixTools::apply_boundary_values(T_bd_values, T_system_matrix, T_solution,
std::map<types::global_dof_index, double> T_bd_values;
VectorTools::interpolate_boundary_values(dof_handler, 1, T_boundary,
T_bd_values); //i表示边界的index
MatrixTools::apply_boundary_values(T_bd_values, T_system_matrix, T_solution,
T_system_rhs);

}
timer.tock("assemble_T_system");

}

template <int dim>
Expand Down Expand Up @@ -585,8 +597,9 @@ void CoupledTH<dim>::run() {
VectorTools::interpolate(dof_handler,
EquationData::TemperatureInitialValues<dim>(),
old_T_solution);
VectorTools::interpolate(
dof_handler, EquationData::PressureInitialValues<dim>(), old_P_solution);
VectorTools::interpolate(dof_handler,
EquationData::PressureInitialValues<dim>(),
old_P_solution);

do {
std::cout << "\nTimestep " << timestep_number;
Expand All @@ -603,5 +616,7 @@ void CoupledTH<dim>::run() {
++timestep_number;
std::cout << "\nt=" << time << ", dt=" << time_step << '.' << std::endl
<< std::endl;
old_T_solution = T_solution;
// old_P_solution = P_solution;
} while (time <= period);
}
11 changes: 7 additions & 4 deletions include/globalvariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

namespace EquationData {
const double perm = 1e-9;
const double c_T = 1.2e6;
const double lam = 1000;
const double c_w = 1e6;
// const double c_T = 1.2e6;
const double c_T = 1;
// const double lam = 1.2;
const double lam = 0;
// const double c_w = 1e6;
const double c_w = 6;
const double B_w = 1e9;
const double T0 = 0;
const double T0 = 273.15;
const double P0 = 100000.;

} // namespace EquationData
Binary file modified thm
Binary file not shown.