From 4d92d0668a3a3381c29eb68c39b51b3437b161de Mon Sep 17 00:00:00 2001 From: OpenModelica Hudson Date: Wed, 5 Mar 2014 16:34:57 +0000 Subject: [PATCH] [Janitor mode] Fix tabs git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19450 f25d12d1-65f4-0310-ae8a-bbce733d8d8e --- Compiler/Template/CodegenCpp.tpl | 130 +++++++++--------- .../cpp/Core/SimController/Initialization.cpp | 6 +- .../cpp/Core/SimController/Initialization.h | 2 +- .../Solver/SolverDefaultImplementation.cpp | 2 +- .../cpp/Core/Solver/SystemStateSelection.cpp | 48 +++---- .../cpp/Include/Core/Solver/ISolver.h | 2 +- .../Core/Solver/SolverDefaultImplementation.h | 6 +- .../Core/Solver/SystemStateSelection.h | 8 +- SimulationRuntime/cpp/Solver/CVode/CVode.cpp | 4 +- 9 files changed, 104 insertions(+), 104 deletions(-) diff --git a/Compiler/Template/CodegenCpp.tpl b/Compiler/Template/CodegenCpp.tpl index 06e1ab69685..73256e33bfe 100644 --- a/Compiler/Template/CodegenCpp.tpl +++ b/Compiler/Template/CodegenCpp.tpl @@ -575,17 +575,17 @@ case SIMCODE(modelInfo=MODELINFO(__)) then case {} then << int <%classname%>StateSelection::getDimStateSets() const - { - return 0; - } - int <%classname%>StateSelection::getDimCanditates() const - { - return 0; - } - int <%classname%>StateSelection::getDimDummyStates() const - { - return 0; - } + { + return 0; + } + int <%classname%>StateSelection::getDimCanditates() const + { + return 0; + } + int <%classname%>StateSelection::getDimDummyStates() const + { + return 0; + } >> else let statesets = (stateSets |> set hasindex i1 fromindex 0 => (match set @@ -595,18 +595,18 @@ case SIMCODE(modelInfo=MODELINFO(__)) then << - int <%classname%>StateSelection::getDimStateSets() const - { - return <%nStates%>; - } - int <%classname%>StateSelection::getDimCanditates() const - { - return <%nCandidates%>; - } - int <%classname%>StateSelection::getDimDummyStates() const - { - return <%nCandidates%>-<%nStates%>; - } + int <%classname%>StateSelection::getDimStateSets() const + { + return <%nStates%>; + } + int <%classname%>StateSelection::getDimCanditates() const + { + return <%nCandidates%>; + } + int <%classname%>StateSelection::getDimDummyStates() const + { + return <%nCandidates%>-<%nStates%>; + } >> ) ;separator="\n\n") @@ -627,30 +627,30 @@ case SIMCODE(modelInfo=MODELINFO(__)) then case {} then << void <%classname%>StateSelection::getStates(double* z) - { - - } - void <%classname%>StateSelection::setStates(const double* z) - { - - } + { + + } + void <%classname%>StateSelection::setStates(const double* z) + { + + } void <%classname%>StateSelection::getStateCanditates(double* z) { - + } void <%classname%>StateSelection::getAMatrix(multi_array & A) - { - + { + - } - void <%classname%>StateSelection::setAMatrix(multi_array& A) - { - - } - void <%classname%>StateSelection::initialize() - { - - } + } + void <%classname%>StateSelection::setAMatrix(multi_array& A) + { + + } + void <%classname%>StateSelection::initialize() + { + + } >> else let stateset = (stateSets |> set hasindex i1 fromindex 0 => (match set @@ -661,30 +661,30 @@ case SIMCODE(modelInfo=MODELINFO(__)) then << void <%classname%>StateSelection::getStates(double* z) - { - <%statesvarsset%> - } - void <%classname%>StateSelection::setStates(const double* z) - { - <%statesvarsget%> - } + { + <%statesvarsset%> + } + void <%classname%>StateSelection::setStates(const double* z) + { + <%statesvarsget%> + } void <%classname%>StateSelection::getStateCanditates(double* z) { - <%statescandidatesvarsset%> + <%statescandidatesvarsset%> } void <%classname%>StateSelection::getAMatrix(multi_array & A) - { - assign_array(A,<%arraycref(crA)%>); + { + assign_array(A,<%arraycref(crA)%>); - } - void <%classname%>StateSelection::setAMatrix(multi_array& A) - { - assign_array(<%arraycref(crA)%>,A); - } - void <%classname%>StateSelection::initialize() - { - fill_array( <%arraycref(crA)%>,0); - } + } + void <%classname%>StateSelection::setAMatrix(multi_array& A) + { + assign_array(<%arraycref(crA)%>,A); + } + void <%classname%>StateSelection::initialize() + { + fill_array( <%arraycref(crA)%>,0); + } >> @@ -696,7 +696,7 @@ case SIMCODE(modelInfo=MODELINFO(__)) then << - + <%stateset%> @@ -8923,9 +8923,9 @@ case _ then let jacvals = ( sparsepattern |> (cref,indexes) hasindex index0 => let jaccol = ( indexes |> i_index => - (match indexColumn case "1" then ' _<%matrixName%>jacobian(<%crefWithoutIndexOperator(cref,simCode)%>$pDER<%matrixName%>$indexdiff,0) = _<%matrixName%>jac_y(0);' - else ' _<%matrixName%>jacobian(<%index0%>,<%crefWithoutIndexOperator(cref,simCode)%>$pDER<%matrixName%>$indexdiff) = _<%matrixName%>jac_y(<%crefWithoutIndexOperator(cref,simCode)%>$pDER<%matrixName%>$indexdiff);' - ) + (match indexColumn case "1" then ' _<%matrixName%>jacobian(<%crefWithoutIndexOperator(cref,simCode)%>$pDER<%matrixName%>$indexdiff,0) = _<%matrixName%>jac_y(0);' + else ' _<%matrixName%>jacobian(<%index0%>,<%crefWithoutIndexOperator(cref,simCode)%>$pDER<%matrixName%>$indexdiff) = _<%matrixName%>jac_y(<%crefWithoutIndexOperator(cref,simCode)%>$pDER<%matrixName%>$indexdiff);' + ) ;separator="\n" ) diff --git a/SimulationRuntime/cpp/Core/SimController/Initialization.cpp b/SimulationRuntime/cpp/Core/SimController/Initialization.cpp index 7933d019ca0..fb76ea8e4d4 100644 --- a/SimulationRuntime/cpp/Core/SimController/Initialization.cpp +++ b/SimulationRuntime/cpp/Core/SimController/Initialization.cpp @@ -15,7 +15,7 @@ Initialization::~Initialization(void) void Initialization::initializeSystem() { - boost::shared_ptr continous_system = boost::dynamic_pointer_cast(_system); + boost::shared_ptr continous_system = boost::dynamic_pointer_cast(_system); boost::shared_ptr event_system =boost::dynamic_pointer_cast(_system); boost::shared_ptr mixed_system = boost::dynamic_pointer_cast(_system); int dim = event_system->getDimZeroFunc(); @@ -25,8 +25,8 @@ void Initialization::initializeSystem() _system->setInitial(true); //Initialization of continous equations and bounded parameters - _system->initialize(); - _solver->stateSelection(); + _system->initialize(); + _solver->stateSelection(); bool restart=true; int iter=0; bool cond_restart = true; diff --git a/SimulationRuntime/cpp/Core/SimController/Initialization.h b/SimulationRuntime/cpp/Core/SimController/Initialization.h index 7a4353d164b..8db24a0640d 100644 --- a/SimulationRuntime/cpp/Core/SimController/Initialization.h +++ b/SimulationRuntime/cpp/Core/SimController/Initialization.h @@ -9,6 +9,6 @@ class Initialization private: boost::shared_ptr _system; - boost::shared_ptr _solver; + boost::shared_ptr _solver; }; diff --git a/SimulationRuntime/cpp/Core/Solver/SolverDefaultImplementation.cpp b/SimulationRuntime/cpp/Core/Solver/SolverDefaultImplementation.cpp index 2080295f185..a6f7b906fdd 100644 --- a/SimulationRuntime/cpp/Core/Solver/SolverDefaultImplementation.cpp +++ b/SimulationRuntime/cpp/Core/Solver/SolverDefaultImplementation.cpp @@ -75,7 +75,7 @@ SolverDefaultImplementation::~SolverDefaultImplementation() { return _solverStatus; }; - + bool SolverDefaultImplementation::stateSelection() { return _state_selection->stateSelection(1); diff --git a/SimulationRuntime/cpp/Core/Solver/SystemStateSelection.cpp b/SimulationRuntime/cpp/Core/Solver/SystemStateSelection.cpp index 1d2417041b2..1ffe10dfe61 100644 --- a/SimulationRuntime/cpp/Core/Solver/SystemStateSelection.cpp +++ b/SimulationRuntime/cpp/Core/Solver/SystemStateSelection.cpp @@ -14,7 +14,7 @@ SystemStateSelection::SystemStateSelection(IMixedSystem* system) { _state_selection = dynamic_cast(system); if ( !_state_selection) - throw std::invalid_argument("No state selection system"); + throw std::invalid_argument("No state selection system"); } void SystemStateSelection::initialize() { @@ -40,33 +40,33 @@ SystemStateSelection::~SystemStateSelection() bool SystemStateSelection::stateSelection(int switchStates) { - if(!_initialized) - initialize(); - int res=0; + if(!_initialized) + initialize(); + int res=0; int* oldColPivot = new int[_dimStateCanditates]; int* oldRowPivot = new int[_dimDummyStates]; SparseMatrix stateset_matrix; - _system->getStateSetJacobian(stateset_matrix); - - /* call pivoting function to select the states */ + _system->getStateSetJacobian(stateset_matrix); + + /* call pivoting function to select the states */ memcpy(oldColPivot,_colPivot, _dimStateCanditates*sizeof(int)); memcpy(oldRowPivot, _rowPivot, _dimDummyStates*sizeof(int)); - - - /*workarround for c array*/ - double* jac = new double[_dimDummyStates*_dimStateCanditates]; - for(int i=0;i<_dimStateCanditates;i++) - for(int j= 0;j<_dimDummyStates;j++) - jac[i*_dimDummyStates+j]=stateset_matrix(i,j); - - - if((pivot(jac, _dimDummyStates, _dimStateCanditates, _rowPivot, _colPivot) != 0)) + + + /*workarround for c array*/ + double* jac = new double[_dimDummyStates*_dimStateCanditates]; + for(int i=0;i<_dimStateCanditates;i++) + for(int j= 0;j<_dimDummyStates;j++) + jac[i*_dimDummyStates+j]=stateset_matrix(i,j); + + + if((pivot(jac, _dimDummyStates, _dimStateCanditates, _rowPivot, _colPivot) != 0)) { - throw std::invalid_argument("Error, singular Jacobian for dynamic state selection at time"); - } - - /* if we have a new set throw event for reinitialization + throw std::invalid_argument("Error, singular Jacobian for dynamic state selection at time"); + } + + /* if we have a new set throw event for reinitialization and set the A matrix for set.x=A*(states) */ res = comparePivot(oldColPivot, _colPivot, switchStates); if(!switchStates) @@ -76,11 +76,11 @@ bool SystemStateSelection::stateSelection(int switchStates) } delete [] oldColPivot; delete [] oldRowPivot; - + if(res) return true; - else - return false; + else + return false; } void SystemStateSelection::setAMatrix(int* newEnable) diff --git a/SimulationRuntime/cpp/Include/Core/Solver/ISolver.h b/SimulationRuntime/cpp/Include/Core/Solver/ISolver.h index 37813d82297..64e711f53c1 100644 --- a/SimulationRuntime/cpp/Include/Core/Solver/ISolver.h +++ b/SimulationRuntime/cpp/Include/Core/Solver/ISolver.h @@ -62,7 +62,7 @@ class ISolver /// (Re-) initialize the solver virtual void initialize() = 0; - virtual bool stateSelection() = 0; + virtual bool stateSelection() = 0; /// Approximation of the numerical solution in a given time interval virtual void solve(const SOLVERCALL command = UNDEF_CALL) = 0; diff --git a/SimulationRuntime/cpp/Include/Core/Solver/SolverDefaultImplementation.h b/SimulationRuntime/cpp/Include/Core/Solver/SolverDefaultImplementation.h index a3a3a01dd25..778a6483602 100644 --- a/SimulationRuntime/cpp/Include/Core/Solver/SolverDefaultImplementation.h +++ b/SimulationRuntime/cpp/Include/Core/Solver/SolverDefaultImplementation.h @@ -59,7 +59,7 @@ class BOOST_EXTENSION_SOLVER_DECL SolverDefaultImplementation /// Called by solver after every successfull integration step (calls writeOutput) void writeToFile(const int& stp, const double& t, const double& h); - virtual bool stateSelection(); + virtual bool stateSelection(); protected: // Member variables @@ -121,8 +121,8 @@ class BOOST_EXTENSION_SOLVER_DECL SolverDefaultImplementation private: - - /// Definition of signum function + + /// Definition of signum function inline static int sgn (const double &c) { return (c < 0) ? -1 : ((c == 0) ? 0 : 1); diff --git a/SimulationRuntime/cpp/Include/Core/Solver/SystemStateSelection.h b/SimulationRuntime/cpp/Include/Core/Solver/SystemStateSelection.h index 476b707263e..5785f2b09ce 100644 --- a/SimulationRuntime/cpp/Include/Core/Solver/SystemStateSelection.h +++ b/SimulationRuntime/cpp/Include/Core/Solver/SystemStateSelection.h @@ -9,7 +9,7 @@ class BOOST_EXTENSION_STATESELECT_DECL SystemStateSelection ~SystemStateSelection(); bool stateSelection(int switchStates); - void initialize(); + void initialize(); private: void setAMatrix(int* newEnable); @@ -21,8 +21,8 @@ class BOOST_EXTENSION_STATESELECT_DECL SystemStateSelection int* _rowPivot; int* _colPivot; unsigned int _dimStates; - unsigned int _dimDummyStates; - unsigned int _dimStateCanditates; - bool _initialized; + unsigned int _dimDummyStates; + unsigned int _dimStateCanditates; + bool _initialized; }; diff --git a/SimulationRuntime/cpp/Solver/CVode/CVode.cpp b/SimulationRuntime/cpp/Solver/CVode/CVode.cpp index 1ac969a6e88..70de35af45f 100644 --- a/SimulationRuntime/cpp/Solver/CVode/CVode.cpp +++ b/SimulationRuntime/cpp/Solver/CVode/CVode.cpp @@ -243,7 +243,7 @@ void Cvode::solve(const SOLVERCALL action) // Solverstart CVodeCore(); - + } // Integration war nicht erfolgreich und wurde auch nicht vom User unterbrochen @@ -426,7 +426,7 @@ int Cvode::calcFunction(const double& time, const double* y, double* f) _continuous_system->setContinuousStates(y); _continuous_system->evaluate(IContinuous::CONTINUOUS); _continuous_system->getRHS(f); - + }//workaround until exception can be catch from c- libraries catch(std::exception& ex) {