Commit db17e69e authored by Pit Nestle's avatar Pit Nestle

Distortion Example rework

parent 14860d7a
Pipeline #7274 failed with stages
in 6785 minutes and 11 seconds
......@@ -530,9 +530,12 @@ if (COMISO_BUILD_EXAMPLES )
add_subdirectory (Examples/small_mosek_native)
endif()
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/small_mosek_fusion_sdp/CMakeLists.txt" )
add_subdirectory (Examples/small_mosek_fusion_sdp)
add_subdirectory (Examples/small_mosek_fusion_sdp)
endif()
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/distortion_adolc/CMakeLists.txt" )
add_subdirectory (Examples/distortion_adolc)
endif()
endif (COMISO_BUILD_EXAMPLES )
# Only create install target, when we are building CoMISo standalone
......
include (CoMISoExample)
acg_add_executable (distortion_adolc ${sources} ${headers} )
# enable rpath linking
set_target_properties(distortion_adolc PROPERTIES INSTALL_RPATH_USE_LINK_PATH 1)
target_link_libraries (distortion_adolc
CoMISo
${COMISO_LINK_LIBRARIES}
)
//== COMPILE-TIME PACKAGE REQUIREMENTS ========================================
#include <CoMISo/Config/config.hh>
#include <iostream>
#if (COMISO_ADOLC_AVAILABLE && COMISO_EIGEN3_AVAILABLE)
#include <CoMISo/Utils/StopWatch.hh>
#include <vector>
#include <CoMISo/NSolver/LinearConstraint.hh>
#include <CoMISo/NSolver/NPDerivativeChecker.hh>
#include <CoMISo/NSolver/NProblemInterfaceADOLC.hh>
#include <CoMISo/NSolver/IPOPTSolver.hh>
#include <CoMISo/NSolver/NewtonSolver.hh>
class Problem_Distortion : public COMISO::NProblemInterfaceADOLC
{
public:
typedef Eigen::Matrix<adouble, 2, 2> Matrix2ad;
std::vector<Eigen::Vector3d> vertices;
Problem_Distortion() : COMISO::NProblemInterfaceADOLC()
{}
virtual int n_unknowns()
{
return 0;
}
virtual void initial_x(double* _x)
{
}
virtual adouble eval_f_adouble(const adouble* _x)
{
adouble result = 0;
return result;
}
virtual void store_result(const double* _x)
{
}
virtual bool constant_gradient() const { return false; }
virtual bool constant_hessian() const { return false; }
virtual bool sparse_gradient() { return false;}
virtual bool sparse_hessian () { return true;}
void addVertex(double x, double y, double z)
{
vertices.push_back(Eigen::Vector3d(x,y,z));
}
bool addTriangle()
};
// Example main
int main(void)
{
return 0;
}
#else
int main(void)
{
std::cerr << "Warning: Example cannot be executed since either EIGEN3 or ADOLC is not available..." << std::endl;
return 0;
}
#endif
//== COMPILE-TIME PACKAGE REQUIREMENTS ========================================
#include <CoMISo/Config/config.hh>
#include <iostream>
#if (COMISO_ADOLC_AVAILABLE && COMISO_EIGEN3_AVAILABLE)
#include <CoMISo/Utils/StopWatch.hh>
#include <vector>
#include <CoMISo/NSolver/LinearConstraint.hh>
#include <CoMISo/NSolver/NPDerivativeChecker.hh>
#include <CoMISo/NSolver/NProblemInterfaceADOLC.hh>
#include <CoMISo/NSolver/IPOPTSolver.hh>
#include <CoMISo/NSolver/NewtonSolver.hh>
class Problem_Distortion : public COMISO::NProblemInterfaceADOLC
{
public:
typedef Eigen::Matrix<adouble, 2, 2> Matrix2ad;
//Base Mesh
std::vector<Eigen::Vector3d> mesh_vertices;
unsigned int mesh_vertex_count;
//Parametrization Mesh
std::vector<Eigen::Vector2d> param_vertices;
unsigned int param_vertex_count;
//Triangle Vertex Indices
std::vector<unsigned int[3]> triangles;
Problem_Distortion() : COMISO::NProblemInterfaceADOLC(), vertex_count(0)
{}
virtual int n_unknowns()
{
return 0;
}
virtual void initial_x(double* _x)
{
}
virtual adouble eval_f_adouble(const adouble* _x)
{
adouble result = 0;
return result;
}
virtual void store_result(const double* _x)
{
}
virtual bool constant_gradient() const { return false; }
virtual bool constant_hessian() const { return false; }
virtual bool sparse_gradient() { return false;}
virtual bool sparse_hessian () { return true;}
void addMeshVertex(double x, double y, double z)
{
this->mesh_vertices.push_back(Eigen::Vector3d(x,y,z));
this->vertex_count++;
}
void addParamVertex(double x, double y, double z)
{
this->param_vertices.push_back(Eigen::Vector3d(x,y,z));
this->param_evertex_count++;
}
bool addTriangle(unsigned int v0, unsigned int v1, unsigned int v2)
{
if (vertex_count < v0 || vertex_count < v1 || vertex_count < c2)
{
std::cerr << "Problem_Distorion::addTriangle() : Vertex index out of range." << std::endl;
}
}
};
// Example main
int main(void)
{
return 0;
}
#else
int main(void)
{
std::cerr << "Warning: Example cannot be executed since either EIGEN3 or ADOLC is not available..." << std::endl;
return 0;
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment