Skip to content

Commit d7c7141

Browse files
committed
Fixes
1 parent db301b4 commit d7c7141

File tree

11 files changed

+113
-123
lines changed

11 files changed

+113
-123
lines changed

cmake/BuildAndInstallScripts.cmake

-16
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,4 @@ macro(INSTALL_LIB LIB)
4242
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
4343
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
4444
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
45-
46-
IF(NOT DEFINED AGROS_BUILD)
47-
IF(MSVC)
48-
MAKE_PATH(TARGET_DIR "${CMAKE_INSTALL_PREFIX}/bin")
49-
get_target_property(SOURCE_DEBUG_FILE ${LIB} LOCATION_Debug)
50-
MAKE_PATH(SOURCE_DEBUG_FILE ${SOURCE_DEBUG_FILE})
51-
get_target_property(SOURCE_RELEASE_FILE ${LIB} LOCATION_Release)
52-
MAKE_PATH(SOURCE_RELEASE_FILE ${SOURCE_RELEASE_FILE})
53-
add_custom_command(TARGET ${LIB}
54-
POST_BUILD
55-
COMMAND if not exist ${TARGET_DIR} mkdir ${TARGET_DIR}
56-
COMMAND if exist ${SOURCE_DEBUG_FILE} copy /Y ${SOURCE_DEBUG_FILE} ${TARGET_DIR}
57-
COMMAND if exist ${SOURCE_RELEASE_FILE} copy /Y ${SOURCE_RELEASE_FILE} ${TARGET_DIR})
58-
unset(TARGET_DIR)
59-
ENDIF()
60-
ENDIF()
6145
endmacro(INSTALL_LIB)

hermes2d/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ project(hermes2d)
622622
set(_FLAGS ${BUILD_FLAGS})
623623
set_target_properties(${HERMES_LIB} PROPERTIES COMPILE_FLAGS ${_FLAGS})
624624
endif()
625-
625+
626626
target_link_libraries( ${HERMES_LIB}
627627
${HERMES_COMMON_LIB}
628628
${GLUT_LIBRARY} ${GL_LIBRARY} ${GLEW_LIBRARY} ${PTHREAD_LIBRARY}
@@ -712,4 +712,4 @@ IF(EXISTS "hermes2d/test_examples")
712712
if(H2D_WITH_TEST_EXAMPLES)
713713
add_subdirectory(test_examples)
714714
endif(H2D_WITH_TEST_EXAMPLES)
715-
ENDIF(EXISTS "hermes2d/test_examples")
715+
ENDIF(EXISTS "hermes2d/test_examples")

hermes2d/include/norm_form.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ namespace Hermes
6464
class HERMES_API NormFormVol : public NormForm
6565
{
6666
public:
67-
NormFormVol(int i, int j);
67+
NormFormVol(int i, int j, FunctionsEvaluatedType functionType);
6868

6969
virtual Scalar value(int n, double *wt, Func<Scalar> *u, Func<Scalar> *v, GeomVol<double> *e) const = 0;
7070
};
@@ -73,7 +73,7 @@ namespace Hermes
7373
class HERMES_API NormFormSurf : public NormForm
7474
{
7575
public:
76-
NormFormSurf(int i, int j);
76+
NormFormSurf(int i, int j, FunctionsEvaluatedType functionType);
7777

7878
virtual Scalar value(int n, double *wt, Func<Scalar> *u, Func<Scalar> *v, GeomSurf<double> *e) const = 0;
7979
};
@@ -82,7 +82,7 @@ namespace Hermes
8282
class HERMES_API NormFormDG : public NormForm
8383
{
8484
public:
85-
NormFormDG(int i, int j);
85+
NormFormDG(int i, int j, FunctionsEvaluatedType functionType);
8686

8787
virtual Scalar value(int n, double *wt, DiscontinuousFunc<Scalar> *u, DiscontinuousFunc<Scalar> *v, GeomSurf<double> *e) const = 0;
8888
};
@@ -91,7 +91,7 @@ namespace Hermes
9191
class HERMES_API DefaultNormFormVol : public NormFormVol < Scalar >
9292
{
9393
public:
94-
DefaultNormFormVol(int i, int j, NormType normType);
94+
DefaultNormFormVol(int i, int j, NormType normType, FunctionsEvaluatedType functionType);
9595

9696
Scalar value(int n, double *wt, Func<Scalar> *u, Func<Scalar> *v, GeomVol<double> *e) const;
9797

@@ -103,7 +103,7 @@ namespace Hermes
103103
class HERMES_API DefaultNormFormSurf : public NormFormSurf < Scalar >
104104
{
105105
public:
106-
DefaultNormFormSurf(int i, int j, NormType normType);
106+
DefaultNormFormSurf(int i, int j, NormType normType, FunctionsEvaluatedType functionType);
107107

108108
Scalar value(int n, double *wt, Func<Scalar> *u, Func<Scalar> *v, GeomSurf<double> *e) const;
109109

hermes2d/src/adapt/error_calculator.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ namespace Hermes
381381
{
382382
for (int i = 0; i < component_count; i++)
383383
{
384-
this->add_error_form(new DefaultNormFormVol<Scalar>(i, i, normType));
384+
this->add_error_form(new DefaultNormFormVol<Scalar>(i, i, normType, SolutionsDifference));
385385
}
386386
}
387387

@@ -390,26 +390,22 @@ namespace Hermes
390390
{
391391
for (int i = 0; i < component_count; i++)
392392
{
393-
this->add_error_form(new DefaultNormFormVol<Scalar>(i, i, normType));
393+
this->add_error_form(new DefaultNormFormVol<Scalar>(i, i, normType, CoarseSolutions));
394394
}
395395
}
396396

397397
template<typename Scalar, NormType normType>
398398
double DefaultNormCalculator<Scalar, normType>::calculate_norms(std::vector<MeshFunctionSharedPtr<Scalar> >& solutions)
399399
{
400-
std::vector<MeshFunctionSharedPtr<Scalar> > zero_fine_solutions;
401-
for (unsigned short i = 0; i < solutions.size(); i++)
402-
zero_fine_solutions.push_back(MeshFunctionSharedPtr<Scalar>(new ZeroSolution<Scalar>(solutions[i]->get_mesh())));
403-
this->calculate_errors(solutions, zero_fine_solutions, false);
400+
this->calculate_errors(solutions, solutions, false);
404401

405402
return this->get_total_error_squared();
406403
}
407404

408405
template<typename Scalar, NormType normType>
409406
double DefaultNormCalculator<Scalar, normType>::calculate_norm(MeshFunctionSharedPtr<Scalar> solution)
410407
{
411-
MeshFunctionSharedPtr<Scalar> zero_fine_solution(new ZeroSolution<Scalar>(solution->get_mesh()));
412-
this->calculate_errors(solution, zero_fine_solution, false);
408+
this->calculate_errors(solution, solution, false);
413409

414410
return this->get_total_error_squared();
415411
}

hermes2d/src/norm_form.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,22 @@ namespace Hermes
7676
}
7777

7878
template<typename Scalar>
79-
NormFormVol<Scalar>::NormFormVol(int i, int j) : NormForm(i, j)
79+
NormFormVol<Scalar>::NormFormVol(int i, int j, FunctionsEvaluatedType functionType) : NormForm(i, j, functionType)
8080
{
8181
}
8282

8383
template<typename Scalar>
84-
NormFormSurf<Scalar>::NormFormSurf(int i, int j) : NormForm(i, j)
84+
NormFormSurf<Scalar>::NormFormSurf(int i, int j, FunctionsEvaluatedType functionType) : NormForm(i, j, functionType)
8585
{
8686
}
8787

8888
template<typename Scalar>
89-
NormFormDG<Scalar>::NormFormDG(int i, int j) : NormForm(i, j)
89+
NormFormDG<Scalar>::NormFormDG(int i, int j, FunctionsEvaluatedType functionType) : NormForm(i, j, functionType)
9090
{
9191
}
9292

9393
template<typename Scalar>
94-
DefaultNormFormVol<Scalar>::DefaultNormFormVol(int i, int j, NormType normType) : NormFormVol<Scalar>(i, j), normType(normType)
94+
DefaultNormFormVol<Scalar>::DefaultNormFormVol(int i, int j, NormType normType, FunctionsEvaluatedType functionType) : NormFormVol<Scalar>(i, j, functionType), normType(normType)
9595
{
9696
}
9797

@@ -116,7 +116,7 @@ namespace Hermes
116116
}
117117
}
118118
template<typename Scalar>
119-
DefaultNormFormSurf<Scalar>::DefaultNormFormSurf(int i, int j, NormType normType) : NormFormSurf<Scalar>(i, j), normType(normType)
119+
DefaultNormFormSurf<Scalar>::DefaultNormFormSurf(int i, int j, NormType normType, FunctionsEvaluatedType functionType) : NormFormSurf<Scalar>(i, j, functionType), normType(normType)
120120
{
121121
}
122122

hermes2d/src/solver/runge_kutta.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ namespace Hermes
451451
}
452452

453453
// If max number of iterations was exceeded, fail.
454-
if (it >= newton_max_iter)
454+
if (it >= newton_max_iter && residual_norm > newton_tol)
455455
{
456456
this->tick();
457457
this->info("\tRunge-Kutta: time step duration: %f s.\n", this->last());

hermes2d/test_examples/01-poisson/main.cpp

+87-77
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ const bool HERMES_VISUALIZATION = true;
3232
// Set to "true" to enable VTK output.
3333
const bool VTK_VISUALIZATION = false;
3434
// Uniform polynomial degree of mesh elements.
35-
const int P_INIT = 3;
35+
const int P_INIT = 10;
3636
// Number of initial uniform mesh refinements.
37-
const int INIT_REF_NUM = 3;
37+
const int INIT_REF_NUM = 4;
3838

3939
// Problem parameters.
4040
// Thermal cond. of Al for temperatures around 20 deg Celsius.
@@ -49,81 +49,91 @@ const double FIXED_BDY_TEMP = 20;
4949
int main(int argc, char* argv[])
5050
{
5151
#ifdef WITH_PARALUTION
52-
HermesCommonApi.set_integral_param_value(matrixSolverType, SOLVER_PARALUTION_ITERATIVE);
52+
HermesCommonApi.set_integral_param_value(matrixSolverType, SOLVER_PARALUTION_ITERATIVE);
5353
#endif
5454

55-
// Load the mesh.
56-
MeshSharedPtr mesh(new Mesh);
57-
Hermes::Hermes2D::MeshReaderH2DXML mloader;
58-
mloader.load("domain.xml", mesh);
59-
60-
// Refine all elements, do it INIT_REF_NUM-times.
61-
for (unsigned int i = 0; i < INIT_REF_NUM; i++)
62-
mesh->refine_all_elements();
63-
64-
// Initialize essential boundary conditions.
65-
Hermes::Hermes2D::DefaultEssentialBCConst<double> bc_essential({ "Bottom", "Inner", "Outer", "Left" }, FIXED_BDY_TEMP);
66-
Hermes::Hermes2D::EssentialBCs<double> bcs(&bc_essential);
67-
68-
// Initialize space.
69-
SpaceSharedPtr<double> space(new Hermes::Hermes2D::H1Space<double>(mesh, &bcs, P_INIT));
70-
71-
std::cout << "Ndofs: " << space->get_num_dofs() << std::endl;
72-
73-
// Initialize the weak formulation.
74-
WeakFormSharedPtr<double> wf(new CustomWeakFormPoisson("Aluminum", new Hermes::Hermes1DFunction<double>(LAMBDA_AL), "Copper",
75-
new Hermes::Hermes1DFunction<double>(LAMBDA_CU), new Hermes::Hermes2DFunction<double>(VOLUME_HEAT_SRC)));
76-
77-
// Initialize the solution.
78-
MeshFunctionSharedPtr<double> sln(new Solution<double>);
79-
80-
// Initialize linear solver.
81-
Hermes::Hermes2D::LinearSolver<double> linear_solver(wf, space);
82-
83-
// Solve the linear problem.
84-
try
85-
{
86-
linear_solver.solve();
87-
88-
// Get the solution vector.
89-
double* sln_vector = linear_solver.get_sln_vector();
90-
91-
// Translate the solution vector into the previously initialized Solution.
92-
Hermes::Hermes2D::Solution<double>::vector_to_solution(sln_vector, space, sln);
93-
94-
// VTK output.
95-
if (VTK_VISUALIZATION)
96-
{
97-
// Output solution in VTK format.
98-
Hermes::Hermes2D::Views::Linearizer lin(FileExport);
99-
bool mode_3D = false;
100-
lin.save_solution_vtk(sln, "sln.vtk", "Temperature", mode_3D, 1);
101-
102-
// Output mesh and element orders in VTK format.
103-
Hermes::Hermes2D::Views::Orderizer ord;
104-
ord.save_mesh_vtk(space, "mesh.vtk");
105-
ord.save_orders_vtk(space, "ord.vtk");
106-
ord.save_markers_vtk(space, "markers.vtk");
107-
}
108-
109-
if (HERMES_VISUALIZATION)
110-
{
111-
// Visualize the solution.
112-
Hermes::Hermes2D::Views::ScalarView viewS("Solution", new Hermes::Hermes2D::Views::WinGeom(0, 0, 500, 400));
113-
Hermes::Hermes2D::Views::OrderView viewSp("Space", new Hermes::Hermes2D::Views::WinGeom(0, 400, 500, 400));
114-
viewS.get_linearizer()->set_criterion(Views::LinearizerCriterionFixed(0));
115-
viewS.show(sln);
116-
viewSp.show(space);
117-
viewS.wait_for_close();
118-
}
119-
}
120-
catch (Exceptions::Exception& e)
121-
{
122-
std::cout << e.info();
123-
}
124-
catch (std::exception& e)
125-
{
126-
std::cout << e.what();
127-
}
128-
return 0;
55+
// Load the mesh.
56+
MeshSharedPtr mesh(new Mesh);
57+
Hermes::Hermes2D::MeshReaderH2DXML mloader;
58+
mloader.load("domain.xml", mesh);
59+
60+
// Refine all elements, do it INIT_REF_NUM-times.
61+
for (unsigned int i = 0; i < INIT_REF_NUM; i++)
62+
mesh->refine_all_elements();
63+
64+
// Initialize essential boundary conditions.
65+
Hermes::Hermes2D::DefaultEssentialBCConst<double> bc_essential({ "Bottom", "Inner", "Outer", "Left" }, FIXED_BDY_TEMP);
66+
Hermes::Hermes2D::EssentialBCs<double> bcs(&bc_essential);
67+
68+
// Initialize space.
69+
SpaceSharedPtr<double> space(new Hermes::Hermes2D::H1Space<double>(mesh, &bcs, P_INIT));
70+
std::cout << "Ndofs: " << space->get_num_dofs() << std::endl;
71+
72+
// Initialize the weak formulation.
73+
WeakFormSharedPtr<double> wf(new CustomWeakFormPoisson("Aluminum", new Hermes::Hermes1DFunction<double>(LAMBDA_AL), "Copper",
74+
new Hermes::Hermes1DFunction<double>(LAMBDA_CU), new Hermes::Hermes2DFunction<double>(VOLUME_HEAT_SRC)));
75+
76+
// Initialize the solution.
77+
MeshFunctionSharedPtr<double> sln(new Solution<double>);
78+
79+
// Initialize linear solver.
80+
Hermes::Hermes2D::LinearSolver<double> linear_solver(wf, space);
81+
82+
#ifdef WITH_PARALUTION
83+
linear_solver.get_linear_matrix_solver()->as_IterSolver()->set_solver_type(Hermes::Solvers::IterSolverType::BiCGStab);
84+
linear_solver.get_linear_matrix_solver()->as_IterSolver()->set_precond(new Hermes::Preconditioners::ParalutionPrecond<double>(Hermes::Preconditioners::PreconditionerType::Jacobi));
85+
linear_solver.get_linear_matrix_solver()->as_IterSolver()->set_tolerance(1e-8, Hermes::Solvers::AbsoluteTolerance);
86+
linear_solver.get_linear_matrix_solver()->as_IterSolver()->set_verbose_output(true);
87+
#endif
88+
89+
// Store the matrix.
90+
linear_solver.output_matrix();
91+
linear_solver.set_matrix_export_format(Hermes::Algebra::MatrixExportFormat::EXPORT_FORMAT_MATRIX_MARKET);
92+
93+
// Solve the linear problem.
94+
try
95+
{
96+
linear_solver.solve();
97+
98+
// Get the solution vector.
99+
double* sln_vector = linear_solver.get_sln_vector();
100+
101+
// Translate the solution vector into the previously initialized Solution.
102+
Hermes::Hermes2D::Solution<double>::vector_to_solution(sln_vector, space, sln);
103+
104+
// VTK output.
105+
if (VTK_VISUALIZATION)
106+
{
107+
// Output solution in VTK format.
108+
Hermes::Hermes2D::Views::Linearizer lin(FileExport);
109+
bool mode_3D = false;
110+
lin.save_solution_vtk(sln, "sln.vtk", "Temperature", mode_3D, 1);
111+
112+
// Output mesh and element orders in VTK format.
113+
Hermes::Hermes2D::Views::Orderizer ord;
114+
ord.save_mesh_vtk(space, "mesh.vtk");
115+
ord.save_orders_vtk(space, "ord.vtk");
116+
ord.save_markers_vtk(space, "markers.vtk");
117+
}
118+
119+
if (HERMES_VISUALIZATION)
120+
{
121+
// Visualize the solution.
122+
Hermes::Hermes2D::Views::ScalarView viewS("Solution", new Hermes::Hermes2D::Views::WinGeom(0, 0, 500, 400));
123+
Hermes::Hermes2D::Views::OrderView viewSp("Space", new Hermes::Hermes2D::Views::WinGeom(0, 400, 500, 400));
124+
viewS.get_linearizer()->set_criterion(Views::LinearizerCriterionFixed(0));
125+
viewS.show(sln);
126+
viewSp.show(space);
127+
viewS.wait_for_close();
128+
}
129+
}
130+
catch (Exceptions::Exception& e)
131+
{
132+
std::cout << e.info();
133+
}
134+
catch (std::exception& e)
135+
{
136+
std::cout << e.what();
137+
}
138+
return 0;
129139
}

hermes2d/test_examples/14-error-calculation/definitions.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ static double custom_fn(int n, double *wt, DiscontinuousFunc<double> *u, Discont
1616
return result;
1717
}
1818

19-
CustomNormFormVol::CustomNormFormVol(int i, int j) : NormFormVol<double>(i, j)
19+
CustomNormFormVol::CustomNormFormVol(int i, int j) : NormFormVol<double>(i, j, CoarseSolutions)
2020
{
2121
this->set_area(HERMES_ANY);
2222
}
2323

24-
CustomNormFormSurf::CustomNormFormSurf(int i, int j) : NormFormSurf<double>(i, j)
24+
CustomNormFormSurf::CustomNormFormSurf(int i, int j) : NormFormSurf<double>(i, j, CoarseSolutions)
2525
{
2626
this->set_area(HERMES_ANY);
2727
}
2828

29-
CustomNormFormDG::CustomNormFormDG(int i, int j) : NormFormDG<double>(i, j)
29+
CustomNormFormDG::CustomNormFormDG(int i, int j) : NormFormDG<double>(i, j, CoarseSolutions)
3030
{
3131
}
3232

hermes2d/test_examples/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ add_subdirectory("13-FCT")
3030

3131
add_subdirectory("14-error-calculation")
3232

33-
add_subdirectory("15-adaptivity-matrix-reuse-simple")
33+
# add_subdirectory("15-adaptivity-matrix-reuse-simple")
3434

35-
add_subdirectory("16-adaptivity-matrix-reuse-layer-interior")
35+
# add_subdirectory("16-adaptivity-matrix-reuse-layer-interior")

hermes_common/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ project(hermes_common)
224224
# options. Linking of optional libraries for the different Hermeses ({1, 2, 3}D)
225225
# is controled in their respective CMakeLists.txt. Note that for unselected
226226
# TPL's, the respective variables will be empty.
227-
228227
target_link_libraries( ${HERMES_COMMON_LIB}
229228
${EXODUSII_LIBRARIES}
230229
${HDF5_LIBRARY}
@@ -300,4 +299,5 @@ project(hermes_common)
300299
install(FILES ${INC_SOLVER_INTERFACES} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/hermes_common/solvers/interfaces)
301300
install(FILES ${INC_STRUCTURES} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/hermes_common/data_structures)
302301
install(FILES ${INC_ALGEBRA} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/hermes_common/algebra)
303-
install(FILES ${INC_UTIL} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/hermes_common/util)
302+
install(FILES ${INC_UTIL} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/hermes_common/util)
303+

0 commit comments

Comments
 (0)