Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 18 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ endif()

#
# VTK
find_package(VTK 5.10 REQUIRED NO_MODULE)
find_package(VTK 6 NO_MODULE)
if(NOT VTK_FOUND)
find_package(VTK 5.10 REQUIRED NO_MODULE)
endif()
if(VTK_FOUND)
message(STATUS "VTK found ${VTK_DIR}")
include(${VTK_USE_FILE})
Expand Down Expand Up @@ -135,11 +138,11 @@ endif()

#
# Eigen
find_package(EIGEN 3.0 REQUIRED)
#
if(EIGEN_FOUND)
find_package(Eigen3 REQUIRED)
if(EIGEN3_FOUND)
message(STATUS "eigen found ${EIGEN_DIR} ${EIGEN_INCLUDE_DIR}")
include_directories(${EIGEN_INCLUDE_DIR})
# include_directories(${EIGEN3_INCLUDE_DIR})
# include( ${EIGEN3_USE_FILE} )
else()
message(STATUS "eigen not found")
endif()
Expand Down Expand Up @@ -178,7 +181,7 @@ endif()

#
# CGAL
find_package(CGAL 4.3 REQUIRED)
find_package(CGAL REQUIRED)
#
if(CGAL_FOUND)
message( STATUS "CGAL found ${CGAL_DIR}" )
Expand All @@ -189,6 +192,15 @@ else()
message( STATUS "CGAL not found" )
endif()

#
# GSL
find_package(GSL REQUIRED)
if(GSL_FOUND)
message(STATUS "GSL found ${GSL_DIR}")
else()
message(STATUS "GSL not found")
endif()

#
include_directories( SYSTEM )

Expand Down
2 changes: 1 addition & 1 deletion Fijee/Biophysics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ add_library( FijeeBiophysics ${Fijee_H} ${HEADERS} ${SOURCES} )
# Add FijeeUtils target libraries
target_link_libraries( FijeeBiophysics ${Fijee_TARGET_LINK_LIBRARIES} )
# Install
install( TARGETS FijeeBiophysics EXPORT FijeeTargets LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
install( TARGETS FijeeBiophysics EXPORT FijeeTargets LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
2 changes: 1 addition & 1 deletion Fijee/Electrodes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ add_library( FijeeElectrodes ${Fijee_H} ${HEADERS} ${SOURCES} )
# Add FijeeUtils target libraries
target_link_libraries( FijeeElectrodes ${Fijee_TARGET_LINK_LIBRARIES} )
# Install
install( TARGETS FijeeElectrodes EXPORT FijeeTargets LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
install( TARGETS FijeeElectrodes EXPORT FijeeTargets LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
2 changes: 1 addition & 1 deletion Fijee/Finite_element_method_models/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ add_library( FijeeFEM ${Fijee_H} ${HEADERS} ${UFL_HEADERS} ${SOURCES} )
# Add FijeeUtils target libraries
target_link_libraries( FijeeFEM ${Fijee_TARGET_LINK_LIBRARIES} ${DOLFIN_LIBRARIES} )
# Install
install( TARGETS FijeeFEM EXPORT FijeeTargets LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
install( TARGETS FijeeFEM EXPORT FijeeTargets LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
2 changes: 1 addition & 1 deletion Fijee/Finite_element_method_models/Physics.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Solver::Physics::Physics()
std::string facets_collection_xml = (SDEsp::get_instance())->get_files_path_output_();
facets_collection_xml += "mesh_facets_subdomains.xml";
//
mesh_facets_collection_.reset( new MeshValueCollection< std::size_t > (*mesh_, facets_collection_xml) );
mesh_facets_collection_.reset( new MeshValueCollection< std::size_t > (mesh_, facets_collection_xml) );

//
// MeshDataCollection methode
Expand Down
29 changes: 18 additions & 11 deletions Fijee/Finite_element_method_models/SL_direct.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ Solver::SL_direct::SL_direct():Physics()
{
//
// Define the function space
V_.reset( new SLD_model::FunctionSpace(*mesh_) );
V_.reset( new SLD_model::FunctionSpace(mesh_) );

//
// Define boundary condition
perifery_.reset( new Periphery() );
// Initialize mesh function for boundary domains. We tag the boundaries
boundaries_.reset( new FacetFunction< size_t > (*mesh_) );
boundaries_.reset( new FacetFunction< size_t > (mesh_) );
boundaries_->set_all(0);
perifery_->mark(*boundaries_, 1);

Expand Down Expand Up @@ -155,6 +155,7 @@ Solver::SL_direct::operator () ( /*Solver::Phi& source,
// //
// // Define Dirichlet boundary conditions
// DirichletBC boundary_conditions(*V, source, perifery);
std::vector<std::shared_ptr<const DirichletBC>> bc;


///////////////////////////////////////////////
Expand All @@ -163,26 +164,32 @@ Solver::SL_direct::operator () ( /*Solver::Phi& source,

//
// Define variational forms
SLD_model::BilinearForm a(*V_, *V_);
SLD_model::LinearForm L(*V_);
SLD_model::BilinearForm a(V_, V_);
SLD_model::LinearForm L(V_);

//
// Anisotropy
// Bilinear
a.a_sigma = *sigma_;
a.dx = *domains_;
a.a_sigma = sigma_;
a.dx = domains_;
// Linear
L.J_source = source;
L.J_source = std::make_shared<Current_density>(source);
//
L.dx = *domains_;
L.ds = *boundaries_;
L.dx = domains_;
L.ds = boundaries_;

//
// Compute solution
Function u(V_);
//
LinearVariationalProblem problem(a, L, u);
LinearVariationalSolver solver(problem);
// LinearVariationalProblem problem(a, L, u);
// LinearVariationalSolver solver(problem);
LinearVariationalProblem problem(std::shared_ptr<const dolfin::Form> (&a),
std::shared_ptr<const dolfin::Form> (&L),
std::shared_ptr<dolfin::Function> (&u),
bc);
LinearVariationalSolver solver( (std::shared_ptr<LinearVariationalProblem> (&problem)) );

// krylov
solver.parameters["linear_solver"]
= (SDEsp::get_instance())->get_linear_solver_();
Expand Down
10 changes: 5 additions & 5 deletions Fijee/Finite_element_method_models/SL_subtraction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Solver::SL_subtraction::SL_subtraction():Physics()
// Define boundary condition
Periphery perifery;
// Initialize mesh function for boundary domains. We tag the boundaries
boundaries_.reset( new FacetFunction< size_t > (*mesh_) );
boundaries_.reset(new FacetFunction< size_t >(mesh_));
boundaries_->set_all(0);
perifery.mark(*boundaries_, 1);

Expand Down Expand Up @@ -163,7 +163,7 @@ Solver::SL_subtraction::operator () ( /*Solver::Phi& source,
//
// Anisotropy conductivity
// Bilinear form
a_->a_sigma = *sigma_;
a_->a_sigma = sigma_;
// a.dx = *domains_;
//
A_.reset( new Matrix() );
Expand Down Expand Up @@ -202,9 +202,9 @@ Solver::SL_subtraction::operator () ( /*Solver::Phi& source,
Vector L_;

// Linear
L.a_inf = a_inf;
L.a_sigma = *sigma_;
L.Phi_0 = source;
L.a_inf = std::make_shared<Sigma_isotrope>(a_inf);
L.a_sigma = sigma_;
L.Phi_0 = std::make_shared<Phi>(source);
//
// L.dx = *domains_;
// L.ds = *boundaries_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ Solver::Spheres_electric_monopole::Spheres_electric_monopole(const Spheres_elect
r0_values_ = that.r0_values_;
//
std::copy(that.r_sphere_, that.r_sphere_ + NUM_SPHERES, r_sphere_);
std::copy(that.sigma_, that.sigma_ + NUM_SPHERES, sigma_);
std::copy((double*)that.sigma_, ((double*)that.sigma_) + NUM_SPHERES * 2, (double*)sigma_);
//
std::copy(that.nu_, that.nu_ + NUM_ITERATIONS, nu_);
std::copy((double*)that.nu_, ((double*)that.nu_) + NUM_ITERATIONS * NUM_SPHERES, (double*)nu_);
std::copy(that.R_coeff_, that.R_coeff_ + NUM_ITERATIONS, R_coeff_);
//
for ( int n = 0 ; n < NUM_ITERATIONS ; n++ )
Expand Down Expand Up @@ -531,9 +531,9 @@ Solver::Spheres_electric_monopole::operator =( const Spheres_electric_monopole&
r0_values_ = that.r0_values_;
//
std::copy(that.r_sphere_, that.r_sphere_ + NUM_SPHERES, r_sphere_);
std::copy(that.sigma_, that.sigma_ + NUM_SPHERES, sigma_);
std::copy((double*)that.sigma_, ((double*)that.sigma_) + NUM_SPHERES * 2, (double*)sigma_);
//
std::copy(that.nu_, that.nu_ + NUM_ITERATIONS, nu_);
std::copy((double*)that.nu_, ((double*)that.nu_) + NUM_ITERATIONS * NUM_SPHERES, (double*)nu_);
std::copy(that.R_coeff_, that.R_coeff_ + NUM_ITERATIONS, R_coeff_);
//
for ( int n = 0 ; n < NUM_ITERATIONS ; n++ )
Expand Down
53 changes: 38 additions & 15 deletions Fijee/Finite_element_method_models/tCS_tACS.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ Solver::tCS_tACS::operator () ( /*Solver::Phi& source,
// //
// // PDE boundary conditions
// DirichletBC bc(*V_, *(electrodes_->get_current(0)), *boundaries_, 101);
std::vector<std::shared_ptr<const DirichletBC>> bc;


//
// Define variational forms
Expand All @@ -124,19 +126,25 @@ Solver::tCS_tACS::operator () ( /*Solver::Phi& source,
//
// Anisotropy
// Bilinear
a.a_sigma = *sigma_;
a.a_sigma = sigma_;
// a.dx = *domains_;


// Linear
L.I = *( electrodes_->get_current(local_sample) );
L.ds = *boundaries_;
L.I = electrodes_->get_current(local_sample);
L.ds = boundaries_;

//
// Compute solution
Function u(*V_);
LinearVariationalProblem problem(a, L, u/*, bc*/);
LinearVariationalSolver solver(problem);
Function u(V_);
// LinearVariationalProblem problem(a, L, u, bc);
// LinearVariationalSolver solver(problem);
LinearVariationalProblem problem(std::shared_ptr<const dolfin::Form> (&a),
std::shared_ptr<const dolfin::Form> (&L),
std::shared_ptr<dolfin::Function> (&u),
bc);
LinearVariationalSolver solver( (std::shared_ptr<LinearVariationalProblem> (&problem)) );

// krylov
solver.parameters["linear_solver"]
= (SDEsp::get_instance())->get_linear_solver_();
Expand Down Expand Up @@ -257,15 +265,23 @@ Solver::tCS_tACS::operator () ( /*Solver::Phi& source,


// Linear
L_field.u = u;
L_field.a_sigma = *sigma_;
L_field.u = std::shared_ptr<const GenericFunction> (&u);
L_field.a_sigma = sigma_;
// L.ds = *boundaries_;

//
// Compute solution
Function J(*V_current_density_);
LinearVariationalProblem problem_field(a_field, L_field, J/*, bc*/);
LinearVariationalSolver solver_field(problem_field);
Function J(V_current_density_);
// LinearVariationalProblem problem_field(a_field, L_field, J/*, bc*/);
// LinearVariationalSolver solver_field(problem_field);

LinearVariationalProblem problem_field(std::shared_ptr<const dolfin::Form> (&a_field),
std::shared_ptr<const dolfin::Form> (&L_field),
std::shared_ptr<dolfin::Function> (&J),
bc);
LinearVariationalSolver solver_field( (std::shared_ptr<LinearVariationalProblem> (&problem)) );


// krylov
solver_field.parameters["linear_solver"]
= (SDEsp::get_instance())->get_linear_solver_();
Expand Down Expand Up @@ -334,15 +350,22 @@ Solver::tCS_tACS::operator () ( /*Solver::Phi& source,


// Linear
L_E.u = u;
L_E.u = std::shared_ptr<const GenericFunction> (&u);
// L_Er.a_sigma = *sigma_;
// L.ds = *boundaries_;

//
// Compute solution
Function E(*V_E_);
LinearVariationalProblem problem_E(a_E, L_E, E/*, bc*/);
LinearVariationalSolver solver_E(problem_E);
Function E(V_E_);
// LinearVariationalProblem problem_E(a_E, L_E, E/*, bc*/);
// LinearVariationalSolver solver_E(problem_E);

LinearVariationalProblem problem_E(std::make_shared<const Form> (a_E),
std::make_shared<const Form> (L_E),
std::make_shared<Function> (E),
bc);
LinearVariationalSolver solver_E(std::make_shared<LinearVariationalProblem> (problem_E));

// krylov
solver_E.parameters["linear_solver"]
= (SDEsp::get_instance())->get_linear_solver_();
Expand Down
47 changes: 31 additions & 16 deletions Fijee/Finite_element_method_models/tCS_tDCS.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Solver::tCS_tDCS::operator () ( /*Solver::Phi& source,
// //
// // PDE boundary conditions
// DirichletBC bc(*V_, *(electrodes_->get_current(0)), *boundaries_, 101);
std::vector<std::shared_ptr<const DirichletBC>> bc;

//
// Define variational forms
Expand All @@ -117,21 +118,24 @@ Solver::tCS_tDCS::operator () ( /*Solver::Phi& source,
//
// Anisotropy
// Bilinear
a.a_sigma = *sigma_;
a.a_sigma = sigma_;
// a.dx = *domains_;
// std::cout << electrodes_->get_current(0)->information("T7").get_I_() << std::endl;

// Linear
L.I = *(electrodes_->get_current( /*local_sample*/ 0));
L.ds = *boundaries_;
L.I = electrodes_->get_current( /*local_sample*/ 0);
L.ds = boundaries_;

//
// Compute solution
Function u(*V_);
LinearVariationalProblem problem(a, L, u/*, bc*/);
LinearVariationalSolver solver(problem);
Function u(V_);
LinearVariationalProblem problem(std::shared_ptr<const dolfin::Form> (&a),
std::shared_ptr<const dolfin::Form> (&L),
std::shared_ptr<dolfin::Function> (&u),
bc);
LinearVariationalSolver solver( (std::shared_ptr<LinearVariationalProblem> (&problem)) );
// krylov
solver.parameters["linear_solver"]
solver.parameters["linear_solver"]
= (SDEsp::get_instance())->get_linear_solver_();
solver.parameters("krylov_solver")["maximum_iterations"]
= (SDEsp::get_instance())->get_maximum_iterations_();
Expand Down Expand Up @@ -225,15 +229,19 @@ Solver::tCS_tDCS::operator () ( /*Solver::Phi& source,


// Linear
L_field.u = u;
L_field.a_sigma = *sigma_;
L_field.u = std::shared_ptr<const GenericFunction> (&u);
L_field.a_sigma = sigma_;
// L.ds = *boundaries_;

//
// Compute solution
Function J(*V_current_density_);
LinearVariationalProblem problem_field(a_field, L_field, J/*, bc*/);
LinearVariationalSolver solver_field(problem_field);
Function J(V_current_density_);
// LinearVariationalProblem problem_field(a_field, L_field, J, bc);
LinearVariationalProblem problem_field(std::make_shared<const Form> (a_field),
std::make_shared<const Form> (L_field),
std::make_shared<Function> (J),
bc);
LinearVariationalSolver solver_field(std::make_shared<LinearVariationalProblem>(problem_field));
// krylov
solver_field.parameters["linear_solver"]
= (SDEsp::get_instance())->get_linear_solver_();
Expand Down Expand Up @@ -277,15 +285,22 @@ Solver::tCS_tDCS::operator () ( /*Solver::Phi& source,


// Linear
L_E.u = u;
L_E.u = std::shared_ptr<const GenericFunction> (&u);
// L_Er.a_sigma = *sigma_;
// L.ds = *boundaries_;

//
// Compute solution
Function E(*V_E_);
LinearVariationalProblem problem_E(a_E, L_E, E/*, bc*/);
LinearVariationalSolver solver_E(problem_E);
Function E(V_E_);
// LinearVariationalProblem problem_E(a_E, L_E, E, bc);
// LinearVariationalSolver solver_E(problem_E);

LinearVariationalProblem problem_E(std::make_shared<const Form> (a_E),
std::make_shared<const Form> (L_E),
std::make_shared<Function> (E),
bc);
LinearVariationalSolver solver_E(std::make_shared<LinearVariationalProblem> (problem_E));

// krylov
solver_E.parameters["linear_solver"]
= (SDEsp::get_instance())->get_linear_solver_();
Expand Down
Loading