Skip to content

Commit

Permalink
Fix compilation with USE_AUTODIFF=OFF
Browse files Browse the repository at this point in the history
Thanks to Matvey Kraposhin
  • Loading branch information
kirill-terekhov committed Jun 1, 2018
1 parent f518784 commit 1e58380
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 deletions.
15 changes: 14 additions & 1 deletion Examples/OldDrawGrid/main.cpp
Expand Up @@ -1693,10 +1693,19 @@ void draw_screen()
{ {
if (source_tag.isDefined(visualization_type)) if (source_tag.isDefined(visualization_type))
{ {
if (source_tag.GetDataType() == DATA_REAL || source_tag.GetDataType() == DATA_INTEGER || source_tag.GetDataType() == DATA_BULK || source_tag.GetDataType() == DATA_VARIABLE) if (source_tag.GetDataType() == DATA_REAL ||
source_tag.GetDataType() == DATA_INTEGER ||
source_tag.GetDataType() == DATA_BULK
#if defined(USE_AUTODIFF)
||
source_tag.GetDataType() == DATA_VARIABLE
#endif
)
{ {
#if defined(USE_AUTODIFF)
if (source_tag.GetDataType() == DATA_VARIABLE) if (source_tag.GetDataType() == DATA_VARIABLE)
printf("I can show only value for data of type variable\n"); printf("I can show only value for data of type variable\n");
#endif
float min = 1.0e20, max = -1.0e20; float min = 1.0e20, max = -1.0e20;
printf("prepearing data for visualization\n"); printf("prepearing data for visualization\n");
if (visualization_tag.isValid()) if (visualization_tag.isValid())
Expand Down Expand Up @@ -1760,6 +1769,7 @@ void draw_screen()
} }
else val += wgt * static_cast<double>(v[comp]); else val += wgt * static_cast<double>(v[comp]);
} }
#if defined(USE_AUTODIFF)
else if (source_tag.GetDataType() == DATA_VARIABLE) else if (source_tag.GetDataType() == DATA_VARIABLE)
{ {
Storage::var_array v = jt->VariableArray(source_tag); Storage::var_array v = jt->VariableArray(source_tag);
Expand All @@ -1772,6 +1782,7 @@ void draw_screen()
} }
else val += wgt * static_cast<double>(v[comp].GetValue()); else val += wgt * static_cast<double>(v[comp].GetValue());
} }
#endif
vol += wgt; vol += wgt;
} }
res = val / vol; res = val / vol;
Expand Down Expand Up @@ -1832,6 +1843,7 @@ void draw_screen()
} }
else val += wgt * static_cast<double>(v[comp]); else val += wgt * static_cast<double>(v[comp]);
} }
#if defined(USE_AUTODIFF)
else if (source_tag.GetDataType() == DATA_VARIABLE) else if (source_tag.GetDataType() == DATA_VARIABLE)
{ {
Storage::var_array v = jt->VariableArray(source_tag); Storage::var_array v = jt->VariableArray(source_tag);
Expand All @@ -1844,6 +1856,7 @@ void draw_screen()
} }
else val += wgt * v[comp].GetValue(); else val += wgt * v[comp].GetValue();
} }
#endif
vol += wgt; vol += wgt;
} }
res = val / vol; res = val / vol;
Expand Down
3 changes: 2 additions & 1 deletion Source/Autodiff/model.cpp
@@ -1,5 +1,5 @@
#include "inmost_model.h" #include "inmost_model.h"

#if defined(USE_AUTODIFF) && defined(USE_MESH) && defined(USE_SOLVER)


namespace INMOST namespace INMOST
{ {
Expand Down Expand Up @@ -273,3 +273,4 @@ namespace INMOST
return ret; return ret;
} }
} }
#endif
3 changes: 3 additions & 0 deletions Source/Headers/inmost_expression.h
Expand Up @@ -2283,6 +2283,9 @@ __INLINE INMOST_DATA_REAL_TYPE get_table(INMOST_DATA_RE




#else //USE_AUTODIFF #else //USE_AUTODIFF
__INLINE bool check_nans(INMOST_DATA_REAL_TYPE val) {return val != val;}
__INLINE bool check_infs(INMOST_DATA_REAL_TYPE val) {return std::isinf(val);}
__INLINE bool check_nans_infs(INMOST_DATA_REAL_TYPE val) {return check_nans(val) || check_infs(val);}
__INLINE void assign(INMOST_DATA_INTEGER_TYPE & Arg, INMOST_DATA_INTEGER_TYPE Val) {Arg = Val;} __INLINE void assign(INMOST_DATA_INTEGER_TYPE & Arg, INMOST_DATA_INTEGER_TYPE Val) {Arg = Val;}
__INLINE void assign(INMOST_DATA_INTEGER_TYPE & Arg, INMOST_DATA_REAL_TYPE Val) {Arg = Val;} __INLINE void assign(INMOST_DATA_INTEGER_TYPE & Arg, INMOST_DATA_REAL_TYPE Val) {Arg = Val;}
__INLINE void assign(INMOST_DATA_REAL_TYPE & Arg, INMOST_DATA_INTEGER_TYPE Val) {Arg = Val;} __INLINE void assign(INMOST_DATA_REAL_TYPE & Arg, INMOST_DATA_INTEGER_TYPE Val) {Arg = Val;}
Expand Down
9 changes: 5 additions & 4 deletions Source/Headers/inmost_nonlinear.h
Expand Up @@ -17,11 +17,12 @@ namespace INMOST


class NonlinearSolver class NonlinearSolver
{ {
Automatizator & aut; //Automatizator & aut;
public: public:
NonlinearSolver(Automatizator & aut) : aut(aut) {} //NonlinearSolver(Automatizator & aut) : aut(aut) {}
NonlinearSolver(const NonlinearSolver & b) : aut(b.aut) {} NonlinearSolver() {}
NonlinearSolver & operator =(NonlinearSolver const & b) {aut = b.aut; return *this;} NonlinearSolver(const NonlinearSolver & b) /*: aut(b.aut)*/ {}
NonlinearSolver & operator =(NonlinearSolver const & b) {/*aut = b.aut;*/ return *this;}
~NonlinearSolver() {} ~NonlinearSolver() {}


RequestedAction GetAction() const; RequestedAction GetAction() const;
Expand Down
2 changes: 1 addition & 1 deletion Source/Headers/inmost_operator.h
Expand Up @@ -3,7 +3,7 @@


#include "inmost_variable.h" #include "inmost_variable.h"


#if defined(USE_AUTODIFF) && defined(USE_MESH) #if defined(USE_AUTODIFF) && defined(USE_MESH) && defined(USE_SOLVER)


namespace INMOST namespace INMOST
{ {
Expand Down
6 changes: 6 additions & 0 deletions Source/Mesh/parallel.cpp
Expand Up @@ -2334,12 +2334,14 @@ namespace INMOST
//array_data_send.resize(had_s+s*tag.GetBytesSize()); //array_data_send.resize(had_s+s*tag.GetBytesSize());
if( s ) if( s )
{ {
#if defined(USE_AUTODIFF)
if( tag.GetDataType() == DATA_VARIABLE ) if( tag.GetDataType() == DATA_VARIABLE )
{ {
REPORT_VAL("data size: ", s); REPORT_VAL("data size: ", s);
REPORT_VAL("data capacity: ", GetDataCapacity(*eit,tag)); REPORT_VAL("data capacity: ", GetDataCapacity(*eit,tag));
REPORT_VAL("array size: ", had_s); REPORT_VAL("array size: ", had_s);
} }
#endif
array_data_send.resize(had_s+GetDataCapacity(*eit,tag)); array_data_send.resize(had_s+GetDataCapacity(*eit,tag));
GetData(*eit,tag,0,s,&array_data_send[had_s]); GetData(*eit,tag,0,s,&array_data_send[had_s]);
//REPORT_VAL("size",s); //REPORT_VAL("size",s);
Expand All @@ -2364,13 +2366,15 @@ namespace INMOST
//array_data_send.resize(had_s+s*tag.GetBytesSize()); //array_data_send.resize(had_s+s*tag.GetBytesSize());
if( s ) if( s )
{ {
#if defined(USE_AUTODIFF)
if( tag.GetDataType() == DATA_VARIABLE ) if( tag.GetDataType() == DATA_VARIABLE )
{ {
REPORT_VAL("on element ",Element(this,*eit).GlobalID()); REPORT_VAL("on element ",Element(this,*eit).GlobalID());
REPORT_VAL("position: ", had_s); REPORT_VAL("position: ", had_s);
REPORT_VAL("data capacity: ", GetDataCapacity(*eit,tag)); REPORT_VAL("data capacity: ", GetDataCapacity(*eit,tag));
REPORT_VAL("size: ", s); REPORT_VAL("size: ", s);
} }
#endif
array_data_send.resize(had_s+GetDataCapacity(*eit,tag)); array_data_send.resize(had_s+GetDataCapacity(*eit,tag));
if (tag.GetDataType() == DATA_REFERENCE) if (tag.GetDataType() == DATA_REFERENCE)
{ {
Expand Down Expand Up @@ -2630,13 +2634,15 @@ namespace INMOST
{ {
if( !select || GetMarker(*eit,select) ) if( !select || GetMarker(*eit,select) )
{ {
#if defined(USE_AUTODIFF)
if( tag.GetDataType() == DATA_VARIABLE ) if( tag.GetDataType() == DATA_VARIABLE )
{ {
REPORT_VAL("on element ",Element(this,*eit).GlobalID()); REPORT_VAL("on element ",Element(this,*eit).GlobalID());
REPORT_VAL("position ", pos); REPORT_VAL("position ", pos);
REPORT_VAL("capacity ", GetDataCapacity(&array_data_recv[pos],size,tag)); REPORT_VAL("capacity ", GetDataCapacity(&array_data_recv[pos],size,tag));
REPORT_VAL("size ", size); REPORT_VAL("size ", size);
} }
#endif
op(tag,Element(this,*eit),&array_data_recv[pos],size); op(tag,Element(this,*eit),&array_data_recv[pos],size);
pos += GetDataCapacity(&array_data_recv[pos],size,tag); pos += GetDataCapacity(&array_data_recv[pos],size,tag);
//pos += size*tag.GetBytesSize(); //pos += size*tag.GetBytesSize();
Expand Down

0 comments on commit 1e58380

Please sign in to comment.