Skip to content

Commit

Permalink
[Janitor mode] Fix whitespace
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@22137 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
OpenModelica-Hudson committed Sep 5, 2014
1 parent ca69856 commit f0103e7
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 125 deletions.
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenCpp.tpl
Expand Up @@ -9290,7 +9290,7 @@ template daeExpCall(Exp call, Context context, Text &preExp /*BUFP*/,
let var2 = daeExp(n, context, &preExp /*BUFC*/, &varDecls /*BUFD*/,simCode,useFlatArrayNotation)
//let temp = tempDeclAssign('const size_t*', &varDecls /*BUFD*/,'<%var1%>.shape()')
//let temp_ex = tempDecl('std::vector<size_t>', &varDecls /*BUFD*/)
let arrayType = /*expTypeArray(ty)*/expTypeFlag(ty,6)
let arrayType = /*expTypeArray(ty)*/expTypeFlag(ty,6)
//let dimstr = listLength(crefSubs(cr))
let tmp = tempDecl('<%arrayType%>', &varDecls /*BUFD*/)

Expand Down
4 changes: 2 additions & 2 deletions SimulationRuntime/cpp/Core/Math/ArrayOperations.cpp
Expand Up @@ -256,7 +256,7 @@ T dot_array( BaseArray<T> & a , BaseArray<T> & b )
{
if(a.getNumDims()!=1 || b.getNumDims()!=1)
throw std::invalid_argument("error in dot array function. Wrong dimension");

T* data1 = a.getData();
unsigned int nelems = a.getNumElems();
T* data2 = b.getData();
Expand All @@ -272,7 +272,7 @@ void cross_array( BaseArray<T> & a ,BaseArray<T> & b, BaseArray<T> & res )
res(1) = (a(2) * b(3)) - (a(3) * b(2));
res(2) = (a(3) * b(1)) - (a(1) * b(3));
res(3) = (a(1) * b(2)) - (a(2) * b(1));

};


Expand Down
6 changes: 3 additions & 3 deletions SimulationRuntime/cpp/Include/Core/Math/Array.h
Expand Up @@ -11,7 +11,7 @@ template<class T>class BaseArray
BaseArray(bool is_static)
:_static(is_static)
{};

//interface methods for all arrays

virtual T& operator()(vector<size_t> idx) = 0;
Expand All @@ -23,7 +23,7 @@ template<class T>class BaseArray
virtual unsigned int getNumElems() = 0;
virtual unsigned int getNumDims() = 0;
virtual void setDims(std::vector<size_t> v) = 0;

virtual T& operator()(unsigned int i)
{
throw std::invalid_argument("Wrong virtual Array operator call");
Expand Down Expand Up @@ -195,7 +195,7 @@ template<typename T, std::size_t size>class StatArrayDim1 : public BaseArray<T>
}
void setDims(unsigned int size1)
{

}
typedef typename boost::array<T,size>::const_iterator const_iterator;
typedef typename boost::array<T,size>::iterator iterator;
Expand Down
212 changes: 106 additions & 106 deletions SimulationRuntime/cpp/Solver/CVode/CVode.cpp
Expand Up @@ -27,8 +27,8 @@ Cvode::Cvode(IMixedSystem* system, ISolverSettings* settings)
_event_system(NULL),
_mixed_system(NULL),
_time_system(NULL),
_delta(NULL),
_deltaInv(NULL)
_delta(NULL),
_deltaInv(NULL)
{
_data = ((void*) this);
}
Expand All @@ -51,20 +51,20 @@ Cvode::~Cvode()
N_VDestroy_Serial(_CV_absTol);
CVodeFree(&_cvodeMem);
}


if (_sparsePattern_index)
delete [] _sparsePattern_leadindex;
delete [] _sparsePattern_leadindex;
if (_sparsePattern_colorCols)
delete [] _sparsePattern_colorCols;
delete [] _sparsePattern_colorCols;
if(_sparsePattern_index)
delete [] _sparsePattern_index;
delete [] _sparsePattern_index;

if(_delta)
delete [] _delta;
delete [] _delta;
if(_deltaInv)
delete [] _deltaInv;
delete [] _deltaInv;

}

void Cvode::initialize()
Expand Down Expand Up @@ -101,18 +101,18 @@ void Cvode::initialize()
delete[] _zeroSign;
if (_absTol)
delete[] _absTol;
if(_delta)
delete [] _delta;
if(_deltaInv)
delete [] _deltaInv;
if(_delta)
delete [] _delta;
if(_deltaInv)
delete [] _deltaInv;

_z = new double[_dimSys];
_zInit = new double[_dimSys];
_zWrite = new double[_dimSys];
_zeroSign = new int[_dimZeroFunc];
_absTol = new double[_dimSys];
_delta =new double[_dimSys];
_deltaInv =new double[_dimSys];
_delta =new double[_dimSys];
_deltaInv =new double[_dimSys];

memset(_z, 0, _dimSys * sizeof(double));
memset(_zInit, 0, _dimSys * sizeof(double));
Expand Down Expand Up @@ -217,9 +217,9 @@ void Cvode::initialize()
if (_idid < 0)
throw std::invalid_argument("Cvode::initialize()");

// Use own jacobian matrix
_idid = CVDlsSetDenseJacFn(_cvodeMem, CV_JCallback);
if (_idid < 0)
// Use own jacobian matrix
_idid = CVDlsSetDenseJacFn(_cvodeMem, CV_JCallback);
if (_idid < 0)
throw std::invalid_argument("CVode::initialize()");

if (_dimZeroFunc)
Expand All @@ -234,8 +234,8 @@ void Cvode::initialize()
memset(_zeroVal, -1, _dimZeroFunc * sizeof(int));

}
initializeColoredJac();

initializeColoredJac();
_cvode_initialized = true;

//
Expand Down Expand Up @@ -569,40 +569,40 @@ int Cvode::calcJacobian(double t, long int N, double* fHelp, N_Vector errorWeigh
try
{
int j,k,l;
double fnorm, minInc, *f_data, *errorWeight_data, h;
f_data = NV_DATA_S(fy);
N_VInv_Serial(errorWeight, errorWeight);
errorWeight_data = NV_DATA_S(errorWeight);
//Calculation of Delta
_idid = CVodeGetErrWeights(_cvodeMem, errorWeight);
if (_idid < 0)
double fnorm, minInc, *f_data, *errorWeight_data, h;

f_data = NV_DATA_S(fy);
N_VInv_Serial(errorWeight, errorWeight);
errorWeight_data = NV_DATA_S(errorWeight);

//Calculation of Delta
_idid = CVodeGetErrWeights(_cvodeMem, errorWeight);
if (_idid < 0)
{
_idid = -5;
throw std::invalid_argument("Cvode::calcJacobian()");
}
_idid = CVodeGetCurrentStep(_cvodeMem, &h);
if (_idid < 0)
}

_idid = CVodeGetCurrentStep(_cvodeMem, &h);
if (_idid < 0)
{
_idid = -5;
throw std::invalid_argument("Cvode::calcJacobian()");
}
fnorm = N_VWrmsNorm(fy, errorWeight);
minInc = (fnorm != 0.0) ?
}

fnorm = N_VWrmsNorm(fy, errorWeight);

minInc = (fnorm != 0.0) ?
(1e3 * abs(h) * UROUND * N * fnorm) : 1.0;
for(int i=0;i<_dimSys;i++)
{
//_delta[i] = 1e-12;
_delta[i] = max(sqrt(UROUND)*abs(y[i]),minInc*abs(errorWeight_data[i]));
_deltaInv[i]=1.0/_delta[i];
}
/*
for(int j=0; j<_dimSys; ++j)

for(int i=0;i<_dimSys;i++)
{
//_delta[i] = 1e-12;
_delta[i] = max(sqrt(UROUND)*abs(y[i]),minInc*abs(errorWeight_data[i]));
_deltaInv[i]=1.0/_delta[i];
}
/*
for(int j=0; j<_dimSys; ++j)
{
// reset m_pYhelp for every colum
//memcpy(yHelp,y,_dimSys*sizeof(double));
Expand All @@ -617,81 +617,81 @@ int Cvode::calcJacobian(double t, long int N, double* fHelp, N_Vector errorWeigh
{
jac[i+j*_dimSys] = (fHelp[i] - f_data[i])*_deltaInv[i];
}
y[j] -= _delta[j];
y[j] -= _delta[j];
}
*/
// Calculation of the jacobian
for(int i=0; i < _sparsePattern_maxColors; i++)
{
for(int ii=0; ii < _dimSys; ii++)
{
if((_sparsePattern_colorCols[ii] - 1) == i)
{
y[ii]+= _delta[ii];
}
}

calcFunction(t, y, fHelp);

for(int ii = 0; ii < _dimSys; ii++)
{
if((_sparsePattern_colorCols[ii] - 1) == i)
{

y[ii]-= _delta[ii];


if(ii==0)
{
j = 0;
}
else
{
j = _sparsePattern_leadindex[ii-1];

}
while(j <_sparsePattern_leadindex[ii])
{
l = _sparsePattern_index[j];
k = l + ii * _dimSys;
jac[k] = (fHelp[l] - f_data[l]) * _deltaInv[l];
j++;
}
}
}
}
*/

// Calculation of the jacobian
for(int i=0; i < _sparsePattern_maxColors; i++)
{
for(int ii=0; ii < _dimSys; ii++)
{
if((_sparsePattern_colorCols[ii] - 1) == i)
{
y[ii]+= _delta[ii];
}

}

calcFunction(t, y, fHelp);

for(int ii = 0; ii < _dimSys; ii++)
{
if((_sparsePattern_colorCols[ii] - 1) == i)
{

y[ii]-= _delta[ii];


if(ii==0)
{
j = 0;
}
else
{
j = _sparsePattern_leadindex[ii-1];

}
while(j <_sparsePattern_leadindex[ii])
{
l = _sparsePattern_index[j];
k = l + ii * _dimSys;
jac[k] = (fHelp[l] - f_data[l]) * _deltaInv[l];
j++;
}
}
}
}


} //workaround until exception can be catch from c- libraries
catch (std::exception& ex)
{
std::string error = ex.what();
cerr << "CVode integration error: " << error;
return 1;
}

return 0;
}

void Cvode::initializeColoredJac()
{
_sizeof_sparsePattern_colorCols = _system->getA_sizeof_sparsePattern_colorCols();
_sparsePattern_colorCols = new int[_sizeof_sparsePattern_colorCols];
_system->getA_sparsePattern_colorCols( _sparsePattern_colorCols, _sizeof_sparsePattern_colorCols);
_sizeof_sparsePattern_colorCols = _system->getA_sizeof_sparsePattern_colorCols();
_sparsePattern_colorCols = new int[_sizeof_sparsePattern_colorCols];
_system->getA_sparsePattern_colorCols( _sparsePattern_colorCols, _sizeof_sparsePattern_colorCols);

_sizeof_sparsePattern_leadindex = _system->getA_sizeof_sparsePattern_leadindex();
_sparsePattern_leadindex = new int[_sizeof_sparsePattern_leadindex];
_system->getA_sparsePattern_leadindex( _sparsePattern_leadindex, _sizeof_sparsePattern_leadindex);
_sizeof_sparsePattern_leadindex = _system->getA_sizeof_sparsePattern_leadindex();
_sparsePattern_leadindex = new int[_sizeof_sparsePattern_leadindex];
_system->getA_sparsePattern_leadindex( _sparsePattern_leadindex, _sizeof_sparsePattern_leadindex);


_sizeof_sparsePattern_index = _system->getA_sizeof_sparsePattern_index();
_sparsePattern_index = new int[_sizeof_sparsePattern_index];
_system->getA_sparsePattern_index( _sparsePattern_index, _sizeof_sparsePattern_index);
_sizeof_sparsePattern_index = _system->getA_sizeof_sparsePattern_index();
_sparsePattern_index = new int[_sizeof_sparsePattern_index];
_system->getA_sparsePattern_index( _sparsePattern_index, _sizeof_sparsePattern_index);


_sparsePattern_maxColors = _system->getA_sparsePattern_maxColors();
_sparsePattern_maxColors = _system->getA_sparsePattern_maxColors();
}

const int Cvode::reportErrorMessage(ostream& messageStream)
Expand Down

0 comments on commit f0103e7

Please sign in to comment.