From 634f274a04be263ee1b4577f98774176d01c7719 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 27 Jul 2020 17:14:53 -0400 Subject: [PATCH] whitespace cleanup: replace tabs and remove trailing whitespace --- lib/awpmd/ivutils/include/cerf.h | 40 +- lib/awpmd/ivutils/include/refobj.h | 10 +- lib/awpmd/systems/interact/TCP/wpmd.h | 78 +- lib/colvars/colvar_arithmeticpath.h | 2 +- lib/colvars/colvargrid.h | 2 +- lib/gpu/cudpp_mini/cudpp_plan.h | 26 +- lib/gpu/cudpp_mini/cutil.h | 198 ++--- lib/message/cslib/src/STUBS_MPI/mpi_dummy.h | 12 +- lib/poems/POEMSChain.h | 94 +-- lib/poems/SystemProcessor.h | 436 +++++------ lib/poems/body23joint.h | 6 +- lib/poems/colmatrix.h | 36 +- lib/poems/defines.h | 6 +- lib/poems/joint.h | 16 +- lib/poems/matrixfun.h | 20 +- lib/poems/mixedjoint.h | 10 +- lib/poems/onbody.h | 20 +- lib/poems/onsolver.h | 26 +- lib/poems/poemslist.h | 58 +- lib/poems/poemsnodelib.h | 132 ++-- lib/poems/poemstree.h | 790 ++++++++++---------- lib/poems/poemstreenode.h | 36 +- lib/poems/points.h | 6 +- lib/poems/system.h | 42 +- lib/poems/virtualcolmatrix.h | 34 +- lib/poems/virtualmatrix.h | 96 +-- lib/poems/workspace.h | 68 +- 27 files changed, 1150 insertions(+), 1150 deletions(-) diff --git a/lib/awpmd/ivutils/include/cerf.h b/lib/awpmd/ivutils/include/cerf.h index b094c4144f..71b2508381 100644 --- a/lib/awpmd/ivutils/include/cerf.h +++ b/lib/awpmd/ivutils/include/cerf.h @@ -26,7 +26,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// Put together by John Smith john at arrows dot demon dot co dot uk, +// Put together by John Smith john at arrows dot demon dot co dot uk, // using ideas by others. // // Calculate erf(z) for complex z. @@ -34,7 +34,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // The code includes some hard coded constants that are intended to // give about 14 decimal places of accuracy. This is appropriate for -// 64-bit floating point numbers. +// 64-bit floating point numbers. // // Oct 1999: Fixed a typo that in // const Complex cerf_continued_fraction( const Complex z ) @@ -46,14 +46,14 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Abramowitz and Stegun: (eqn: 7.1.14) gives this continued // fraction for erfc(z) // -// erfc(z) = sqrt(pi).exp(-z^2). 1 1/2 1 3/2 2 5/2 +// erfc(z) = sqrt(pi).exp(-z^2). 1 1/2 1 3/2 2 5/2 // --- --- --- --- --- --- ... // z + z + z + z + z + z + // // This is evaluated using Lentz's method, as described in the narative // of Numerical Recipes in C. // -// The continued fraction is true providing real(z)>0. In practice we +// The continued fraction is true providing real(z)>0. In practice we // like real(z) to be significantly greater than 0, say greater than 0.5. // template< class Complex> @@ -63,9 +63,9 @@ const Complex cerfc_continued_fraction( const Complex z ) double eps = 1e-15 ; // large enough so that 1.0+eps > 1.0, when using // the floating point arithmetic // - // first calculate z+ 1/2 1 + // first calculate z+ 1/2 1 // --- --- ... - // z + z + + // z + z + Complex f(z) ; Complex C(f) ; Complex D(0.0) ; @@ -80,7 +80,7 @@ const Complex cerfc_continued_fraction( const Complex z ) C = z + a/C ; if (D.real() == 0.0 && D.imag() == 0.0) - D = tiny ; + D = tiny ; D = 1.0 / D ; @@ -134,9 +134,9 @@ const Complex cerf_series( const Complex z ) return sum * 2.0 / sqrt(M_PI) ; } - + // -// Numerical Recipes quotes a formula due to Rybicki for evaluating +// Numerical Recipes quotes a formula due to Rybicki for evaluating // Dawson's Integral: // // exp(-x^2) integral exp(t^2).dt = 1/sqrt(pi) lim sum exp(-(z-n.h)^2) / n @@ -151,9 +151,9 @@ const Complex cerf_rybicki( const Complex z ) double h = 0.2 ; // numerical experiment suggests this is small enough // - // choose an even n0, and then shift z->z-n0.h and n->n-h. - // n0 is chosen so that real((z-n0.h)^2) is as small as possible. - // + // choose an even n0, and then shift z->z-n0.h and n->n-h. + // n0 is chosen so that real((z-n0.h)^2) is as small as possible. + // int n0 = 2*(int) (floor( z.imag()/(2*h) + 0.5 )) ; Complex z0( 0.0, n0*h ) ; @@ -161,14 +161,14 @@ const Complex cerf_rybicki( const Complex z ) Complex sum(0.0,0.0) ; // // limits of sum chosen so that the end sums of the sum are - // fairly small. In this case exp(-(35.h)^2)=5e-22 + // fairly small. In this case exp(-(35.h)^2)=5e-22 // // for (int np=-35; np<=35; np+=2) { Complex t( zp.real(), zp.imag()-np*h) ; Complex b( exp(t*t) / (np+n0) ) ; - sum += b ; + sum += b ; } sum = sum * 2 * exp(-z*z) / M_PI ; @@ -180,7 +180,7 @@ template< class Complex> const Complex cerf( const Complex z ) { // - // Use the method appropriate to size of z - + // Use the method appropriate to size of z - // there probably ought to be an extra option for NaN z, or infinite z // // @@ -194,20 +194,20 @@ const Complex cerf( const Complex z ) // // Footnote: -// +// // Using the definitions from Abramowitz and Stegun (7.3.1, 7.3.2) // The fresnel intgerals defined as: // // / t=x // C(x) = | cos(pi/2 t^2) dt // / -// t=0 +// t=0 // // and // / t=x // S(x) = | sin(pi/2 t^2) dt // / -// t=0 +// t=0 // // These can be derived from erf(x) using 7.3.22 // @@ -216,8 +216,8 @@ const Complex cerf( const Complex z ) // 2 // // -------------------------------------------------------------------------- -// Some test examples - -// comparative data taken from Abramowitz and Stegun table 7.9. +// Some test examples - +// comparative data taken from Abramowitz and Stegun table 7.9. // Table 7.9 tabulates w(z), where w(z) = exp(-z*z) erfc(iz) // I have copied twelve values of w(z) from the table, and separately // calculated them using this code. The results are identical. diff --git a/lib/awpmd/ivutils/include/refobj.h b/lib/awpmd/ivutils/include/refobj.h index 848704dc40..a1a4feb0ff 100644 --- a/lib/awpmd/ivutils/include/refobj.h +++ b/lib/awpmd/ivutils/include/refobj.h @@ -2,9 +2,9 @@ * * Copyright (c), Ilya Valuev 2006 All Rights Reserved. * - * Author : Ilya Valuev, MIPT, Moscow, Russia + * Author : Ilya Valuev, MIPT, Moscow, Russia * - * Project : ivutils + * Project : ivutils * *****************************************************************************/ /*s**************************************************************************** @@ -250,7 +250,7 @@ public: if(man){ iterator it=base_t::begin(); for(;it!=base_t::end();++it) - if(*it) + if(*it) delete (*it); } base_t::clear(); @@ -427,7 +427,7 @@ class RefObject{ void *ref_data; int ref_count; public: - + protected: virtual void delete_data(void *data); virtual void *new_data(); @@ -437,7 +437,7 @@ protected: class RefA: public RefObject{ - + public: refA(){ ref_data = new A; diff --git a/lib/awpmd/systems/interact/TCP/wpmd.h b/lib/awpmd/systems/interact/TCP/wpmd.h index e5a7c27697..e118b76f36 100644 --- a/lib/awpmd/systems/interact/TCP/wpmd.h +++ b/lib/awpmd/systems/interact/TCP/wpmd.h @@ -2,12 +2,12 @@ * * Copyright (c), Ilya Valuev 2005 All Rights Reserved. * - * Author : Ilya Valuev, MIPT, Moscow, Russia + * Author : Ilya Valuev, MIPT, Moscow, Russia * - * Project : GridMD, ivutils + * Project : GridMD, ivutils * *****************************************************************************/ - + /*s**************************************************************************** * $Log: wpmd.h,v $ * Revision 1.4 2011/06/11 16:53:55 valuev @@ -134,8 +134,8 @@ *******************************************************************************/ # ifndef WPMD_H # define WPMD_H - -/** @file wpmd.h + +/** @file wpmd.h @brief Classes for Wave Packet Molecular Dynamics of two component plasma. */ # ifndef _USE_MATH_DEFINES @@ -143,7 +143,7 @@ # endif # include # include -# include +# include # include "logexc.h" # include "cvector_3.h" # include "pairhash.h" @@ -168,7 +168,7 @@ const double h_plank2 = h_plank * 2.; inline cdouble cerf_div(const cdouble &z, const cdouble &c=i_unit){ if((fabs(real(z))+fabs(imag(z)))<1e-8) return c*two_over_sqr_pi; - else + else return cerf(z*c)/z; } @@ -176,7 +176,7 @@ inline cdouble cerf_div(const cdouble &z, const cdouble &c=i_unit){ inline double erf_div(const double &z, double c=1){ if(fabs(z)<1e-8) return c*two_over_sqr_pi; - else + else return erf(z*c)/z; } @@ -247,7 +247,7 @@ public: OverlapDeriv():I0(0),I1(0),IDD(10){} - + void set1(const WavePacket& w1_) { w1=w1_; d1.set(w1); @@ -330,7 +330,7 @@ public: enum {NORM_UNDEFINED, NORM_CALCULATED, NORM_FACTORIZED, NORM_INVERTED}; int norm_matrix_state[2]; - + // Arrays for temporal data chmatrix IDD; // Second derivatives of the overlap integral (used in Norm matrix) vector ID, IDYs; // First derivatives of the overlap integral (used in Norm matrix) @@ -346,7 +346,7 @@ public: /// HARTREE Hartree product (no antisymmetrization) \n /// DPRODUCT product of det0*det1 of antisymmetrized functions for spins 0, 1 \n /// UHF unrestricted Hartree-Fock - enum APPROX {HARTREE, DPRODUCT, UHF } approx; + enum APPROX {HARTREE, DPRODUCT, UHF } approx; ///\em Sets overlap matrix element to zero if the overlap norm is less than this value double ovl_tolerance; @@ -375,14 +375,14 @@ public: ///\en 0 -- indicates that the inter-partition force should be full, and energy half,\n /// 1 -- inter-partition force and energy counts one half (LAMMPS compatibility) - int newton_pair; + int newton_pair; //int myid; ///<\en id for partitions - + ///\en Partition arrays storing the tags of particles. The initial tags should be >0. /// If the tag stored is <0, then the particle is ghost with -tag. /// partition1[2] is for ions, 0, 1 for each electron spin - vector partition1[3]; + vector partition1[3]; //vector partition2[3]; ///<\en 2 for ions @@ -391,7 +391,7 @@ public: } - ///\en 1 -- all my, -1 all other, 2 -- my mixed term, -2 -- other mixed term + ///\en 1 -- all my, -1 all other, 2 -- my mixed term, -2 -- other mixed term int check_ee(int s1,int icj1,int ick2){ //printf(" (%d %d) ",partition1[s1][icj1],partition1[s1][ick2]); int c1=(int)(partition1[s1][icj1]>0); @@ -402,8 +402,8 @@ public: int tag2=abs(partition1[s1][ick2]); int num=tag_index(tag1-1,tag2-1); if(num<0){ // compare wave packets - int cmp= s1<2 ? - wp[s1][icj1].compare(wp[s1][ick2],1e-15) : + int cmp= s1<2 ? + wp[s1][icj1].compare(wp[s1][ick2],1e-15) : compare_vec(xi[icj1],xi[ick2],1e-15); if((cmp>0 && c1) || (cmp<0 && c2)) res= 2; // my mixed term @@ -421,12 +421,12 @@ public: } ///\en Returns electron-electron inter-partition multipliers for energy (first) and force (second) - /// for a 4- and 2- electron additive terms (all inter-partition interactions are + /// for a 4- and 2- electron additive terms (all inter-partition interactions are /// calculated only once based on particle tags) /// If force multiplier is zero, then the term may be omitted (energy will also be zero). /// NOW ASSIGNS BASED ON THE FIRST PAIR ONLY pair check_part1(int s1,int icj1,int ick2){ - int res=check_ee(s1,icj1,ick2); + int res=check_ee(s1,icj1,ick2); if(res==1){ // my term //printf(" *\n"); return make_pair(1.,1.); // all at my partition @@ -439,7 +439,7 @@ public: //printf(" *\n"); return make_pair(1.,1.); // my inter-partition } - else if(res==-2){ + else if(res==-2){ //printf(" \n"); return make_pair(0., newton_pair ? 0.0 : 1. ); // other inter-partition: must add force if newton comm is off } @@ -447,18 +447,18 @@ public: } ///\en Returns elctron-ion inter-partition multipliers for energy (first) and force (second) - /// for ion-electron additive terms (all inter-partition interactions are + /// for ion-electron additive terms (all inter-partition interactions are /// calculated only once based on particle tags) /// If force multiplier is zero, then the term may be omitted (energy will also be zero). /// BASED ON ION ATTACHMENT pair check_part1ei(int s1,int icj1,int ick2, int ion){ //printf("%d ",partition1[2][ion]); int ci=(int)(partition1[2][ion]>0); - + if(!newton_pair){ // care about mixed terms int cee=check_ee(s1,icj1,ick2); if((cee==2 || cee==-2) || (ci && cee==-1) || (!ci && cee==1)) // all mixed variants - make_pair(0., 1. ); // other inter-partition: must add force if newton comm is off + make_pair(0., 1. ); // other inter-partition: must add force if newton comm is off } if(ci){ //printf(" *\n"); @@ -471,7 +471,7 @@ public: } ///\en Returns ion-ion inter-partition multipliers for energy (first) and force (second) - /// for ion-electron additive terms (all inter-partition interactions are + /// for ion-electron additive terms (all inter-partition interactions are /// calculated only once based on particle tags) /// If force multiplier is zero, then the term may be omitted (energy will also be zero). pair check_part1ii(int ion1, int ion2){ @@ -485,7 +485,7 @@ public: norm_matrix_state[0] = norm_matrix_state[1] = NORM_UNDEFINED; ovl_tolerance=0.; approx = DPRODUCT; - + me=m_electron; one_h=1./h_plank; h2_me=h_sq/me; @@ -530,11 +530,11 @@ protected: ///\en resizes all internal arrays according to new electrons added virtual void resize(int flag); public: - - - + + + ///\en Prepares to setup a new system of particles using \ref add_ion() and add_electron(). - /// There is no need to call this function when using + /// There is no need to call this function when using /// \ref set_electrons() and \ref set_ions() to setup particles. virtual void reset(){ for(int s=0;s<2;s++){ @@ -556,10 +556,10 @@ public: //e 0x4 -- PBC along Z //e cell specifies the lengths of the simulation box in all directions //e if PBCs are used, the corresponding coordinates of electrons and ions - //e in periodic directions must be within the range [0, cell[per_dir]) + //e in periodic directions must be within the range [0, cell[per_dir]) //e @returns 1 if OK int set_pbc(const Vector_3P pcell=NULL, int pbc_=0x7); - + ///\en Setup electrons: forms internal wave packet representations. /// If PBCs are used the coords must be within a range [0, cell). /// Default electron mass is AWPMD::me. @@ -572,9 +572,9 @@ public: ///\en Adds an ion with charge q and position x, /// \return id of the ion starting from 0 - /// The tags must be nonzero, >0 for the local particle, <0 for ghost particle. + /// The tags must be nonzero, >0 for the local particle, <0 for ghost particle. /// Unique particle id is abs(tag). - /// Default tag (0) means inserting the current particle id as local particle. + /// Default tag (0) means inserting the current particle id as local particle. int add_ion(double q, const Vector_3 &x, int tag=0){ qi.push_back(q); xi.push_back(x); @@ -586,24 +586,24 @@ public: } - //e calculates interaction in the system of ni ions + electrons + //e calculates interaction in the system of ni ions + electrons //e the electonic subsystem must be previously setup by set_electrons, ionic by set_ions //e the iterators are describing ionic system only // 0x1 -- give back ion forces // 0x2 -- add ion forces to the existing set // 0x4 -- calculate derivatives for electronic time step (NOT IMPLEMENTED) //e if PBCs are used the coords must be within a range [0, cell) - virtual int interaction(int flag=0, Vector_3P fi=NULL, Vector_3P fe_x=NULL, + virtual int interaction(int flag=0, Vector_3P fi=NULL, Vector_3P fe_x=NULL, Vector_3P fe_p=NULL, double *fe_w=NULL, double *fe_pw=NULL, Vector_2P fe_c=NULL); //e same as interaction, but using Hartee factorization (no antisymmetrization) - virtual int interaction_hartree(int flag=0, Vector_3P fi=NULL, Vector_3P fe_x=NULL, + virtual int interaction_hartree(int flag=0, Vector_3P fi=NULL, Vector_3P fe_x=NULL, Vector_3P fe_p=NULL, double *fe_w=NULL, double *fe_pw=NULL, Vector_2P fe_c=NULL); ///\en Calculates ion-ion interactions and updates Eii and ion forces if requested. This function /// is called form intaraction() and interaction_hartree if calc_ii is set. virtual int interaction_ii(int flag,Vector_3P fi=NULL); - + //e Calculates Norm matrix //e The result is saved in AWPMD::Norm[s] void norm_matrix(int s); @@ -642,7 +642,7 @@ public: } ///\en Prepares force arrays according to \a flag setting for interaction() - virtual void clear_forces(int flagi,Vector_3P fi, Vector_3P fe_x, + virtual void clear_forces(int flagi,Vector_3P fi, Vector_3P fe_x, Vector_3P fe_p, double *fe_w, double *fe_pw, Vector_2P fe_c=NULL); @@ -651,7 +651,7 @@ public: /// Default mass (-1) is the electron mass AWPMD::me. WavePacket create_wp(Vector_3 &x, Vector_3 &v, double &w, double &pw, double mass=-1); - + }; diff --git a/lib/colvars/colvar_arithmeticpath.h b/lib/colvars/colvar_arithmeticpath.h index 97d42a1bbc..552edf23e3 100644 --- a/lib/colvars/colvar_arithmeticpath.h +++ b/lib/colvars/colvar_arithmeticpath.h @@ -77,7 +77,7 @@ void ArithmeticPathBase::computeValue() { exponent_tmp += weights[j_elem] * frame_element_distances[i_frame][j_elem] * weights[j_elem] * frame_element_distances[i_frame][j_elem]; } exponent_tmp = exponent_tmp * -1.0 * lambda; - // prevent underflow if the argument of cvm::exp is less than -708.4 + // prevent underflow if the argument of cvm::exp is less than -708.4 if (exponent_tmp > -708.4) { exponent_tmp = cvm::exp(exponent_tmp); } else { diff --git a/lib/colvars/colvargrid.h b/lib/colvars/colvargrid.h index 6008f2068b..314a92b8c6 100644 --- a/lib/colvars/colvargrid.h +++ b/lib/colvars/colvargrid.h @@ -210,7 +210,7 @@ public: /// parameters from another grid, but doesn't reallocate stuff; /// setup() must be called after that; colvar_grid(colvar_grid const &g) : colvarparse(), - nd(g.nd), + nd(g.nd), nx(g.nx), mult(g.mult), data(), diff --git a/lib/gpu/cudpp_mini/cudpp_plan.h b/lib/gpu/cudpp_mini/cudpp_plan.h index bf1263db13..675adbecf3 100644 --- a/lib/gpu/cudpp_mini/cudpp_plan.h +++ b/lib/gpu/cudpp_mini/cudpp_plan.h @@ -3,13 +3,13 @@ // ------------------------------------------------------------- // $Revision: 3572$ // $Date: 2010-11-23 13:04:43 -0700 (Tue, 23 Nov 2010) $ -// ------------------------------------------------------------- +// ------------------------------------------------------------- // This source code is distributed under the terms of license.txt // in the root directory of this source distribution. -// ------------------------------------------------------------- +// ------------------------------------------------------------- #ifndef __CUDPP_PLAN_H__ #define __CUDPP_PLAN_H__ - + typedef void* KernelPointer; extern "C" size_t getNumCTAs(KernelPointer kernel); @@ -30,10 +30,10 @@ void computeNumCTAs(T kernel, unsigned int bytesDynamicSharedMem, size_t threads /** @brief Base class for CUDPP Plan data structures * * CUDPPPlan and its subclasses provide the internal (i.e. not visible to the - * library user) infrastructure for planning algorithm execution. They + * library user) infrastructure for planning algorithm execution. They * own intermediate storage for CUDPP algorithms as well as, in some cases, * information about optimal execution configuration for the present hardware. - * + * */ class CUDPPPlan { @@ -91,7 +91,7 @@ public: CUDPPScanPlan *m_scanPlan; //!< @internal Compact performs a scan of type unsigned int using this plan unsigned int* m_d_outputIndices; //!< @internal Output address of compacted elements; this is the result of scan - + }; class CUDPPRadixSortPlan : public CUDPPPlan @@ -99,7 +99,7 @@ class CUDPPRadixSortPlan : public CUDPPPlan public: CUDPPRadixSortPlan(CUDPPConfiguration config, size_t numElements); virtual ~CUDPPRadixSortPlan(); - + bool m_bKeysOnly; bool m_bManualCoalesce; bool m_bUsePersistentCTAs; @@ -123,22 +123,22 @@ class CUDPPSparseMatrixVectorMultiplyPlan : public CUDPPPlan public: CUDPPSparseMatrixVectorMultiplyPlan(CUDPPConfiguration config, size_t numNZElts, const void *A, - const unsigned int *rowindx, + const unsigned int *rowindx, const unsigned int *indx, size_t numRows); virtual ~CUDPPSparseMatrixVectorMultiplyPlan(); CUDPPSegmentedScanPlan *m_segmentedScanPlan; //!< @internal Performs a segmented scan of type T using this plan void *m_d_prod; //!< @internal Vector of products (of an element in A and its corresponding (thats is - //! belongs to the same row) element in x; this is the input and output of + //! belongs to the same row) element in x; this is the input and output of //! segmented scan unsigned int *m_d_flags; //!< @internal Vector of flags where a flag is set if an element of A is the first element //! of its row; this is the flags vector for segmented scan unsigned int *m_d_rowFinalIndex; //!< @internal Vector of row end indices, which for each row specifies an index in A - //! which is the last element of that row. Resides in GPU memory. + //! which is the last element of that row. Resides in GPU memory. unsigned int *m_d_rowIndex; //!< @internal Vector of row end indices, which for each row specifies an index in A - //! which is the first element of that row. Resides in GPU memory. - unsigned int *m_d_index; //!<@internal Vector of column numbers one for each element in A - void *m_d_A; //!<@internal The A matrix + //! which is the first element of that row. Resides in GPU memory. + unsigned int *m_d_index; //!<@internal Vector of column numbers one for each element in A + void *m_d_A; //!<@internal The A matrix unsigned int *m_rowFinalIndex; //!< @internal Vector of row end indices, which for each row specifies an index in A //! which is the last element of that row. Resides in CPU memory. size_t m_numRows; //!< Number of rows diff --git a/lib/gpu/cudpp_mini/cutil.h b/lib/gpu/cudpp_mini/cutil.h index fbf139cda3..7d1fcc17ee 100644 --- a/lib/gpu/cudpp_mini/cutil.h +++ b/lib/gpu/cudpp_mini/cutil.h @@ -1,32 +1,32 @@ /* * Copyright 1993-2006 NVIDIA Corporation. All rights reserved. * -* NOTICE TO USER: +* NOTICE TO USER: * -* This source code is subject to NVIDIA ownership rights under U.S. and -* international Copyright laws. +* This source code is subject to NVIDIA ownership rights under U.S. and +* international Copyright laws. * -* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE -* CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR -* IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH -* REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF -* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. -* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, -* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS -* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE -* OR PERFORMANCE OF THIS SOURCE CODE. +* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE +* CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR +* IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH +* REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF +* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. +* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, +* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE +* OR PERFORMANCE OF THIS SOURCE CODE. * -* U.S. Government End Users. This source code is a "commercial item" as -* that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of -* "commercial computer software" and "commercial computer software -* documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) -* and is provided to the U.S. Government only as a commercial end item. -* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through -* 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the +* U.S. Government End Users. This source code is a "commercial item" as +* that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of +* "commercial computer software" and "commercial computer software +* documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) +* and is provided to the U.S. Government only as a commercial end item. +* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through +* 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the * source code with only those rights set forth herein. */ - + /* CUda UTility Library */ @@ -36,7 +36,7 @@ #include #ifdef _WIN32 -# pragma warning( disable : 4996 ) // disable deprecated warning +# pragma warning( disable : 4996 ) // disable deprecated warning #endif #ifdef __cplusplus @@ -50,8 +50,8 @@ extern "C" { # else # define DLL_MAPPING __declspec(dllimport) # endif -#else -# define DLL_MAPPING +#else +# define DLL_MAPPING #endif #ifdef _WIN32 @@ -64,7 +64,7 @@ extern "C" { //////////////////////////////////////////////////////////////////////////// //! CUT bool type //////////////////////////////////////////////////////////////////////////// - enum CUTBoolean + enum CUTBoolean { CUTFalse = 0, CUTTrue = 1 @@ -72,11 +72,11 @@ extern "C" { //////////////////////////////////////////////////////////////////////////// //! Deallocate memory allocated within Cutil - //! @param pointer to memory + //! @param pointer to memory //////////////////////////////////////////////////////////////////////////// DLL_MAPPING void CUTIL_API - cutFree( void* ptr); + cutFree( void* ptr); //////////////////////////////////////////////////////////////////////////// //! Helper for bank conflict checking (should only be used with the @@ -95,7 +95,7 @@ extern "C" { DLL_MAPPING void CUTIL_API cutCheckBankAccess( unsigned int tidx, unsigned int tidy, unsigned int tidz, - unsigned int bdimx, unsigned int bdimy, + unsigned int bdimx, unsigned int bdimy, unsigned int bdimz, const char* file, const int line, const char* aname, const int index); @@ -141,8 +141,8 @@ extern "C" { //! deallocate the memory //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API - cutReadFilef( const char* filename, float** data, unsigned int* len, + CUTBoolean CUTIL_API + cutReadFilef( const char* filename, float** data, unsigned int* len, bool verbose = false); //////////////////////////////////////////////////////////////////////////// @@ -157,8 +157,8 @@ extern "C" { //! deallocate the memory //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API - cutReadFiled( const char* filename, double** data, unsigned int* len, + CUTBoolean CUTIL_API + cutReadFiled( const char* filename, double** data, unsigned int* len, bool verbose = false); //////////////////////////////////////////////////////////////////////////// @@ -173,7 +173,7 @@ extern "C" { //! deallocate the memory //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API + CUTBoolean CUTIL_API cutReadFilei( const char* filename, int** data, unsigned int* len, bool verbose = false); //////////////////////////////////////////////////////////////////////////// @@ -183,13 +183,13 @@ extern "C" { //! @param data uninitialized pointer, returned initialized and pointing to //! the data read //! @param len number of data elements in data, -1 on error - //! @note If a NULL pointer is passed to this function and it is + //! @note If a NULL pointer is passed to this function and it is //! initialized within Cutil then cutFree() has to be used to //! deallocate the memory //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API - cutReadFileui( const char* filename, unsigned int** data, + CUTBoolean CUTIL_API + cutReadFileui( const char* filename, unsigned int** data, unsigned int* len, bool verbose = false); //////////////////////////////////////////////////////////////////////////// @@ -199,13 +199,13 @@ extern "C" { //! @param data uninitialized pointer, returned initialized and pointing to //! the data read //! @param len number of data elements in data, -1 on error - //! @note If a NULL pointer is passed to this function and it is + //! @note If a NULL pointer is passed to this function and it is //! initialized within Cutil then cutFree() has to be used to //! deallocate the memory //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API - cutReadFileb( const char* filename, char** data, unsigned int* len, + CUTBoolean CUTIL_API + cutReadFileb( const char* filename, char** data, unsigned int* len, bool verbose = false); //////////////////////////////////////////////////////////////////////////// @@ -220,12 +220,12 @@ extern "C" { //! deallocate the memory //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API - cutReadFileub( const char* filename, unsigned char** data, + CUTBoolean CUTIL_API + cutReadFileub( const char* filename, unsigned char** data, unsigned int* len, bool verbose = false); //////////////////////////////////////////////////////////////////////////// - //! Write a data file \filename containing single precision floating point + //! Write a data file \filename containing single precision floating point //! data //! @return CUTTrue if writing the file succeeded, otherwise false //! @param filename name of the file to write @@ -234,12 +234,12 @@ extern "C" { //! @param epsilon epsilon for comparison //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API + CUTBoolean CUTIL_API cutWriteFilef( const char* filename, const float* data, unsigned int len, const float epsilon, bool verbose = false); //////////////////////////////////////////////////////////////////////////// - //! Write a data file \filename containing double precision floating point + //! Write a data file \filename containing double precision floating point //! data //! @return CUTTrue if writing the file succeeded, otherwise false //! @param filename name of the file to write @@ -248,7 +248,7 @@ extern "C" { //! @param epsilon epsilon for comparison //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API + CUTBoolean CUTIL_API cutWriteFiled( const char* filename, const float* data, unsigned int len, const double epsilon, bool verbose = false); @@ -260,7 +260,7 @@ extern "C" { //! @param len number of data elements in data, -1 on error //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API + CUTBoolean CUTIL_API cutWriteFilei( const char* filename, const int* data, unsigned int len, bool verbose = false); @@ -272,8 +272,8 @@ extern "C" { //! @param len number of data elements in data, -1 on error //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API - cutWriteFileui( const char* filename,const unsigned int* data, + CUTBoolean CUTIL_API + cutWriteFileui( const char* filename,const unsigned int* data, unsigned int len, bool verbose = false); //////////////////////////////////////////////////////////////////////////// @@ -284,8 +284,8 @@ extern "C" { //! @param len number of data elements in data, -1 on error //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API - cutWriteFileb( const char* filename, const char* data, unsigned int len, + CUTBoolean CUTIL_API + cutWriteFileb( const char* filename, const char* data, unsigned int len, bool verbose = false); //////////////////////////////////////////////////////////////////////////// @@ -296,7 +296,7 @@ extern "C" { //! @param len number of data elements in data, -1 on error //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API + CUTBoolean CUTIL_API cutWriteFileub( const char* filename,const unsigned char* data, unsigned int len, bool verbose = false); @@ -307,7 +307,7 @@ extern "C" { //! @param data handle to the data read //! @param w width of the image //! @param h height of the image - //! @note If a NULL pointer is passed to this function and it is + //! @note If a NULL pointer is passed to this function and it is //! initialized within Cutil then cutFree() has to be used to //! deallocate the memory //////////////////////////////////////////////////////////////////////////// @@ -326,11 +326,11 @@ extern "C" { //////////////////////////////////////////////////////////////////////////// DLL_MAPPING CUTBoolean CUTIL_API - cutLoadPPMub( const char* file, unsigned char** data, + cutLoadPPMub( const char* file, unsigned char** data, unsigned int *w,unsigned int *h); //////////////////////////////////////////////////////////////////////////// - //! Load PPM image file (with unsigned char as data element type), padding + //! Load PPM image file (with unsigned char as data element type), padding //! 4th component //! @return CUTTrue if reading the file succeeded, otherwise false //! @param file name of the image file @@ -340,7 +340,7 @@ extern "C" { //////////////////////////////////////////////////////////////////////////// DLL_MAPPING CUTBoolean CUTIL_API - cutLoadPPM4ub( const char* file, unsigned char** data, + cutLoadPPM4ub( const char* file, unsigned char** data, unsigned int *w,unsigned int *h); //////////////////////////////////////////////////////////////////////////// @@ -350,13 +350,13 @@ extern "C" { //! @param data handle to the data read //! @param w width of the image //! @param h height of the image - //! @note If a NULL pointer is passed to this function and it is + //! @note If a NULL pointer is passed to this function and it is //! initialized within Cutil then cutFree() has to be used to //! deallocate the memory //////////////////////////////////////////////////////////////////////////// DLL_MAPPING CUTBoolean CUTIL_API - cutLoadPGMi( const char* file, unsigned int** data, + cutLoadPGMi( const char* file, unsigned int** data, unsigned int* w, unsigned int* h); //////////////////////////////////////////////////////////////////////////// @@ -366,13 +366,13 @@ extern "C" { //! @param data handle to the data read //! @param w width of the image //! @param h height of the image - //! @note If a NULL pointer is passed to this function and it is + //! @note If a NULL pointer is passed to this function and it is //! initialized within Cutil then cutFree() has to be used to //! deallocate the memory //////////////////////////////////////////////////////////////////////////// DLL_MAPPING CUTBoolean CUTIL_API - cutLoadPGMs( const char* file, unsigned short** data, + cutLoadPGMs( const char* file, unsigned short** data, unsigned int* w, unsigned int* h); //////////////////////////////////////////////////////////////////////////// @@ -381,7 +381,7 @@ extern "C" { //! @param data handle to the data read //! @param w width of the image //! @param h height of the image - //! @note If a NULL pointer is passed to this function and it is + //! @note If a NULL pointer is passed to this function and it is //! initialized within Cutil then cutFree() has to be used to //! deallocate the memory //////////////////////////////////////////////////////////////////////////// @@ -399,7 +399,7 @@ extern "C" { //////////////////////////////////////////////////////////////////////////// DLL_MAPPING CUTBoolean CUTIL_API - cutSavePGMub( const char* file, unsigned char* data, + cutSavePGMub( const char* file, unsigned char* data, unsigned int w, unsigned int h); //////////////////////////////////////////////////////////////////////////// @@ -411,11 +411,11 @@ extern "C" { //////////////////////////////////////////////////////////////////////////// DLL_MAPPING CUTBoolean CUTIL_API - cutSavePPMub( const char* file, unsigned char *data, + cutSavePPMub( const char* file, unsigned char *data, unsigned int w, unsigned int h); //////////////////////////////////////////////////////////////////////////// - //! Save PPM image file (with unsigned char as data element type, padded to + //! Save PPM image file (with unsigned char as data element type, padded to //! 4 bytes) //! @param file name of the image file //! @param data handle to the data read @@ -424,7 +424,7 @@ extern "C" { //////////////////////////////////////////////////////////////////////////// DLL_MAPPING CUTBoolean CUTIL_API - cutSavePPM4ub( const char* file, unsigned char *data, + cutSavePPM4ub( const char* file, unsigned char *data, unsigned int w, unsigned int h); //////////////////////////////////////////////////////////////////////////// @@ -465,15 +465,15 @@ extern "C" { //////////////////////////////////////////////////////////////////////////// // Command line arguments: General notes - // * All command line arguments begin with '--' followed by the token; + // * All command line arguments begin with '--' followed by the token; // token and value are separated by '='; example --samples=50 - // * Arrays have the form --model=[one.obj,two.obj,three.obj] + // * Arrays have the form --model=[one.obj,two.obj,three.obj] // (without whitespaces) //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //! Check if command line argument \a flag-name is given - //! @return CUTTrue if command line argument \a flag_name has been given, + //! @return CUTTrue if command line argument \a flag_name has been given, //! otherwise 0 //! @param argc argc as passed to main() //! @param argv argv as passed to main() @@ -481,7 +481,7 @@ extern "C" { //////////////////////////////////////////////////////////////////////////// DLL_MAPPING CUTBoolean CUTIL_API - cutCheckCmdLineFlag( const int argc, const char** argv, + cutCheckCmdLineFlag( const int argc, const char** argv, const char* flag_name); //////////////////////////////////////////////////////////////////////////// @@ -495,7 +495,7 @@ extern "C" { //////////////////////////////////////////////////////////////////////////// DLL_MAPPING CUTBoolean CUTIL_API - cutGetCmdLineArgumenti( const int argc, const char** argv, + cutGetCmdLineArgumenti( const int argc, const char** argv, const char* arg_name, int* val); //////////////////////////////////////////////////////////////////////////// @@ -509,7 +509,7 @@ extern "C" { //////////////////////////////////////////////////////////////////////////// DLL_MAPPING CUTBoolean CUTIL_API - cutGetCmdLineArgumentf( const int argc, const char** argv, + cutGetCmdLineArgumentf( const int argc, const char** argv, const char* arg_name, float* val); //////////////////////////////////////////////////////////////////////////// @@ -523,7 +523,7 @@ extern "C" { //////////////////////////////////////////////////////////////////////////// DLL_MAPPING CUTBoolean CUTIL_API - cutGetCmdLineArgumentstr( const int argc, const char** argv, + cutGetCmdLineArgumentstr( const int argc, const char** argv, const char* arg_name, char** val); //////////////////////////////////////////////////////////////////////////// @@ -538,8 +538,8 @@ extern "C" { //////////////////////////////////////////////////////////////////////////// DLL_MAPPING CUTBoolean CUTIL_API - cutGetCmdLineArgumentListstr( const int argc, const char** argv, - const char* arg_name, char** val, + cutGetCmdLineArgumentListstr( const int argc, const char** argv, + const char* arg_name, char** val, unsigned int* len); //////////////////////////////////////////////////////////////////////////// @@ -556,46 +556,46 @@ extern "C" { //////////////////////////////////////////////////////////////////////////// //! Compare two float arrays - //! @return CUTTrue if \a reference and \a data are identical, + //! @return CUTTrue if \a reference and \a data are identical, //! otherwise CUTFalse //! @param reference handle to the reference data / gold image //! @param data handle to the computed data //! @param len number of elements in reference and data //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API + CUTBoolean CUTIL_API cutComparef( const float* reference, const float* data, const unsigned int len); //////////////////////////////////////////////////////////////////////////// //! Compare two integer arrays - //! @return CUTTrue if \a reference and \a data are identical, + //! @return CUTTrue if \a reference and \a data are identical, //! otherwise CUTFalse //! @param reference handle to the reference data / gold image //! @param data handle to the computed data //! @param len number of elements in reference and data //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API - cutComparei( const int* reference, const int* data, - const unsigned int len ); + CUTBoolean CUTIL_API + cutComparei( const int* reference, const int* data, + const unsigned int len ); //////////////////////////////////////////////////////////////////////////// //! Compare two unsigned char arrays - //! @return CUTTrue if \a reference and \a data are identical, + //! @return CUTTrue if \a reference and \a data are identical, //! otherwise CUTFalse //! @param reference handle to the reference data / gold image //! @param data handle to the computed data //! @param len number of elements in reference and data //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API + CUTBoolean CUTIL_API cutCompareub( const unsigned char* reference, const unsigned char* data, - const unsigned int len ); + const unsigned int len ); //////////////////////////////////////////////////////////////////////////////// //! Compare two integer arrays witha n epsilon tolerance for equality - //! @return CUTTrue if \a reference and \a data are identical, + //! @return CUTTrue if \a reference and \a data are identical, //! otherwise CUTFalse //! @param reference handle to the reference data / gold image //! @param data handle to the computed data @@ -609,7 +609,7 @@ extern "C" { //////////////////////////////////////////////////////////////////////////// //! Compare two float arrays with an epsilon tolerance for equality - //! @return CUTTrue if \a reference and \a data are identical, + //! @return CUTTrue if \a reference and \a data are identical, //! otherwise CUTFalse //! @param reference handle to the reference data / gold image //! @param data handle to the computed data @@ -617,14 +617,14 @@ extern "C" { //! @param epsilon epsilon to use for the comparison //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API + CUTBoolean CUTIL_API cutComparefe( const float* reference, const float* data, const unsigned int len, const float epsilon ); //////////////////////////////////////////////////////////////////////////// - //! Compare two float arrays using L2-norm with an epsilon tolerance for + //! Compare two float arrays using L2-norm with an epsilon tolerance for //! equality - //! @return CUTTrue if \a reference and \a data are identical, + //! @return CUTTrue if \a reference and \a data are identical, //! otherwise CUTFalse //! @param reference handle to the reference data / gold image //! @param data handle to the computed data @@ -632,7 +632,7 @@ extern "C" { //! @param epsilon epsilon to use for the comparison //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API + CUTBoolean CUTIL_API cutCompareL2fe( const float* reference, const float* data, const unsigned int len, const float epsilon ); @@ -645,7 +645,7 @@ extern "C" { //! @param name of the new timer, 0 if the creation failed //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API + CUTBoolean CUTIL_API cutCreateTimer( unsigned int* name); //////////////////////////////////////////////////////////////////////////// @@ -654,7 +654,7 @@ extern "C" { //! @param name of the timer to delete //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API + CUTBoolean CUTIL_API cutDeleteTimer( unsigned int name); //////////////////////////////////////////////////////////////////////////// @@ -662,7 +662,7 @@ extern "C" { //! @param name name of the timer to start //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API + CUTBoolean CUTIL_API cutStartTimer( const unsigned int name); //////////////////////////////////////////////////////////////////////////// @@ -670,7 +670,7 @@ extern "C" { //! @param name name of the timer to stop //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API + CUTBoolean CUTIL_API cutStopTimer( const unsigned int name); //////////////////////////////////////////////////////////////////////////// @@ -678,27 +678,27 @@ extern "C" { //! @param name name of the timer to reset. //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - CUTBoolean CUTIL_API + CUTBoolean CUTIL_API cutResetTimer( const unsigned int name); //////////////////////////////////////////////////////////////////////////// - //! Returns total execution time in milliseconds for the timer over all + //! Returns total execution time in milliseconds for the timer over all //! runs since the last reset or timer creation. //! @param name name of the timer to return the time of //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - float CUTIL_API + float CUTIL_API cutGetTimerValue( const unsigned int name); //////////////////////////////////////////////////////////////////////////// - //! Return the average time in milliseconds for timer execution as the + //! Return the average time in milliseconds for timer execution as the //! total time for the timer dividied by the number of completed (stopped) //! runs the timer has made. //! Excludes the current running time if the timer is currently running. //! @param name name of the timer to return the time of //////////////////////////////////////////////////////////////////////////// DLL_MAPPING - float CUTIL_API + float CUTIL_API cutGetAverageTimerValue( const unsigned int name); //////////////////////////////////////////////////////////////////////////// @@ -764,7 +764,7 @@ extern "C" { fprintf(stderr, "Cut error in file '%s' in line %i.\n", \ __FILE__, __LINE__); \ exit(EXIT_FAILURE); \ - } + } //! Check for CUDA error # define CUT_CHECK_ERROR(errorMessage) do { \ @@ -802,7 +802,7 @@ extern "C" { // void macros for performance reasons # define CUT_CHECK_ERROR(errorMessage) # define CUT_CHECK_ERROR_GL() -# define CUT_CONDITION( val) +# define CUT_CONDITION( val) # define CU_SAFE_CALL_NO_SYNC( call) call # define CU_SAFE_CALL( call) call # define CUDA_SAFE_CALL_NO_SYNC( call) call diff --git a/lib/message/cslib/src/STUBS_MPI/mpi_dummy.h b/lib/message/cslib/src/STUBS_MPI/mpi_dummy.h index 2919e4c3a2..0c18c97d28 100644 --- a/lib/message/cslib/src/STUBS_MPI/mpi_dummy.h +++ b/lib/message/cslib/src/STUBS_MPI/mpi_dummy.h @@ -44,28 +44,28 @@ static void MPI_Init(int *, char ***) {} static MPI_Comm MPI_Comm_f2c(MPI_Comm world) {return world;} static void MPI_Comm_rank(MPI_Comm, int *) {} static void MPI_Comm_size(MPI_Comm, int *) {} - + static void MPI_Open_port(MPI_Info, char *) {} static void MPI_Close_port(const char *) {} -static void MPI_Comm_accept(const char *, MPI_Info, int, +static void MPI_Comm_accept(const char *, MPI_Info, int, MPI_Comm, MPI_Comm *) {} -static void MPI_Comm_connect(const char *, MPI_Info, int, +static void MPI_Comm_connect(const char *, MPI_Info, int, MPI_Comm, MPI_Comm *) {} static void MPI_Comm_split(MPI_Comm, int, int, MPI_Comm *) {} static void MPI_Comm_free(MPI_Comm *) {} static void MPI_Send(const void *, int, MPI_Datatype, int, int, MPI_Comm) {} -static void MPI_Recv(void *, int, MPI_Datatype, int, int, +static void MPI_Recv(void *, int, MPI_Datatype, int, int, MPI_Comm, MPI_Status *) {} -static void MPI_Allreduce(const void *in, void *out, int, MPI_Datatype type, +static void MPI_Allreduce(const void *in, void *out, int, MPI_Datatype type, MPI_Op op, MPI_Comm) { if (type == MPI_INT) *((int *) out) = *((int *) in); } static void MPI_Scan(const void *in, void *out, int, MPI_Datatype intype, - MPI_Op op,MPI_Comm) + MPI_Op op,MPI_Comm) { if (intype == MPI_INT) *((int *) out) = *((int *) in); } diff --git a/lib/poems/POEMSChain.h b/lib/poems/POEMSChain.h index 9f0db59333..c846d27e0c 100644 --- a/lib/poems/POEMSChain.h +++ b/lib/poems/POEMSChain.h @@ -3,7 +3,7 @@ * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * DESCRIPTION: SEE READ-ME * * FILE NAME: PoemsChain.h * - * AUTHORS: See Author List * + * AUTHORS: See Author List * * GRANTS: See Grants List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * LICENSE: Please see License Agreement * @@ -11,7 +11,7 @@ * ADMINISTRATOR: Prof. Kurt Anderson * * Computational Dynamics Lab * * Rensselaer Polytechnic Institute * - * 110 8th St. Troy NY 12180 * + * 110 8th St. Troy NY 12180 * * CONTACT: anderk5@rpi.edu * *_________________________________________________________________________*/ @@ -21,54 +21,54 @@ #include "poemslist.h" struct ChildRingData { - List * childRing; - int entranceNodeId; + List * childRing; + int entranceNodeId; }; struct POEMSChain{ - ~POEMSChain(){ - for(int i = 0; i < childChains.GetNumElements(); i++) - { - delete childChains(i); - } + ~POEMSChain(){ + for(int i = 0; i < childChains.GetNumElements(); i++) + { + delete childChains(i); + } listOfNodes.DeleteValues(); - } - //void printTreeStructure(int tabs); - //void getTreeAsList(List * temp); - List listOfNodes; - List childChains; - POEMSChain * parentChain; - List childRings; - - - void printTreeStructure(int tabs){ - for(int i = 0; i < tabs; i++) - { - cout << "\t"; - } - cout << "Chain: "; - for(int i = 0; i < listOfNodes.GetNumElements(); i++) - { - cout << *(listOfNodes(i)) << " "; - } - cout << endl; - for(int i = 0; i < childChains.GetNumElements(); i++) - { - childChains(i)->printTreeStructure(tabs + 1); - } - } - void getTreeAsList(List * temp) - { - for(int i = 0; i < listOfNodes.GetNumElements(); i++) - { - int * integer = new int; - *integer = *(listOfNodes(i)); - temp->Append(integer); - } - for(int i = 0; i < childChains.GetNumElements(); i++) - { - childChains(i)->getTreeAsList(temp); - } - } + } + //void printTreeStructure(int tabs); + //void getTreeAsList(List * temp); + List listOfNodes; + List childChains; + POEMSChain * parentChain; + List childRings; + + + void printTreeStructure(int tabs){ + for(int i = 0; i < tabs; i++) + { + cout << "\t"; + } + cout << "Chain: "; + for(int i = 0; i < listOfNodes.GetNumElements(); i++) + { + cout << *(listOfNodes(i)) << " "; + } + cout << endl; + for(int i = 0; i < childChains.GetNumElements(); i++) + { + childChains(i)->printTreeStructure(tabs + 1); + } + } + void getTreeAsList(List * temp) + { + for(int i = 0; i < listOfNodes.GetNumElements(); i++) + { + int * integer = new int; + *integer = *(listOfNodes(i)); + temp->Append(integer); + } + for(int i = 0; i < childChains.GetNumElements(); i++) + { + childChains(i)->getTreeAsList(temp); + } + } }; #endif diff --git a/lib/poems/SystemProcessor.h b/lib/poems/SystemProcessor.h index f376890e99..4fc8785dd7 100644 --- a/lib/poems/SystemProcessor.h +++ b/lib/poems/SystemProcessor.h @@ -3,7 +3,7 @@ * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * DESCRIPTION: SEE READ-ME * * FILE NAME: SystemProcessor.h * - * AUTHORS: See Author List * + * AUTHORS: See Author List * * GRANTS: See Grants List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * LICENSE: Please see License Agreement * @@ -11,7 +11,7 @@ * ADMINISTRATOR: Prof. Kurt Anderson * * Computational Dynamics Lab * * Rensselaer Polytechnic Institute * - * 110 8th St. Troy NY 12180 * + * 110 8th St. Troy NY 12180 * * CONTACT: anderk5@rpi.edu * *_________________________________________________________________________*/ @@ -23,47 +23,47 @@ struct POEMSNode { - List links; - List taken; - int idNumber; - bool visited; - - ~POEMSNode(){ - for(int i = 0; i < taken.GetNumElements(); i++) - { - delete taken(i); - } - }; + List links; + List taken; + int idNumber; + bool visited; + + ~POEMSNode(){ + for(int i = 0; i < taken.GetNumElements(); i++) + { + delete taken(i); + } + }; }; class SystemProcessor{ private: - Tree nodes; - static void POEMSNodeDelete_cb(void *node) { - delete (POEMSNode *) node; - } - List headsOfSystems; - List > ringsInSystem; - POEMSNode * findSingleLink(TreeNode * aNode); - POEMSChain * AddNewChain(POEMSNode * currentNode); - bool setLinkVisited(POEMSNode * firstNode, POEMSNode * secondNode); + Tree nodes; + static void POEMSNodeDelete_cb(void *node) { + delete (POEMSNode *) node; + } + List headsOfSystems; + List > ringsInSystem; + POEMSNode * findSingleLink(TreeNode * aNode); + POEMSChain * AddNewChain(POEMSNode * currentNode); + bool setLinkVisited(POEMSNode * firstNode, POEMSNode * secondNode); public: - SystemProcessor(void); - - ~SystemProcessor(void) { - headsOfSystems.DeleteValues(); - for(int i = 0; i < ringsInSystem.GetNumElements(); i++) - { - for(int k = 0; k < ringsInSystem(i)->GetNumElements(); i++) - { - delete (*ringsInSystem(i))(k); - } - } - }; - void processArray(int** links, int numLinks); - List * getSystemData(); - int getNumberOfHeadChains(); + SystemProcessor(void); + + ~SystemProcessor(void) { + headsOfSystems.DeleteValues(); + for(int i = 0; i < ringsInSystem.GetNumElements(); i++) + { + for(int k = 0; k < ringsInSystem(i)->GetNumElements(); i++) + { + delete (*ringsInSystem(i))(k); + } + } + }; + void processArray(int** links, int numLinks); + List * getSystemData(); + int getNumberOfHeadChains(); }; SystemProcessor::SystemProcessor(void){ @@ -73,145 +73,145 @@ SystemProcessor::SystemProcessor(void){ void SystemProcessor::processArray(int** links, int numLinks) { - bool * false_var; //holds the value false; needed because a constant cannot be put into a list; the list requires a - //reference. - for(int i = 0; i < numLinks; i++) //go through all the links in the input array - { - if(!nodes.Find(links[i][0])) //if the first node in the pair is not found in the storage tree - { - POEMSNode * newNode = new POEMSNode; //make a new node -// forDeletion.Append(newNode); - newNode->idNumber = links[i][0]; //set its ID to the value - newNode->visited = false; //set it to be unvisited - nodes.Insert(links[i][0], links[i][0], (void *) newNode); //and add it to the tree storage structure - } - if(!nodes.Find(links[i][1])) //repeat process for the other half of each link - { - POEMSNode * newNode = new POEMSNode; -// forDeletion.Append(newNode); - newNode->idNumber = links[i][1]; - newNode->visited = false; - nodes.Insert(links[i][1], links[i][1], (void *) newNode); - } - POEMSNode * firstNode = (POEMSNode *)nodes.Find(links[i][0]); //now that we are sure both nodes exist, - POEMSNode * secondNode = (POEMSNode *)nodes.Find(links[i][1]); //we can get both of them out of the tree - firstNode->links.Append(secondNode); //and add the link from the first to the second... - false_var = new bool; - *false_var = false; //make a new false boolean to note that the link between these two - firstNode->taken.Append(false_var); //has not already been taken, and append it to the taken list - secondNode->links.Append(firstNode); //repeat process for link from second node to first - false_var = new bool; - *false_var = false; - secondNode->taken.Append(false_var); - } - - TreeNode * temp = nodes.GetRoot(); //get the root node of the node storage tree - POEMSNode * currentNode; - do - { - currentNode = findSingleLink(temp); //find the start of the next available chain - if(currentNode != NULL) - { - headsOfSystems.Append(AddNewChain(currentNode)); //and add it to the headsOfSystems list of chains - } - } - while(currentNode != NULL); //repeat this until all chains have been added + bool * false_var; //holds the value false; needed because a constant cannot be put into a list; the list requires a + //reference. + for(int i = 0; i < numLinks; i++) //go through all the links in the input array + { + if(!nodes.Find(links[i][0])) //if the first node in the pair is not found in the storage tree + { + POEMSNode * newNode = new POEMSNode; //make a new node +// forDeletion.Append(newNode); + newNode->idNumber = links[i][0]; //set its ID to the value + newNode->visited = false; //set it to be unvisited + nodes.Insert(links[i][0], links[i][0], (void *) newNode); //and add it to the tree storage structure + } + if(!nodes.Find(links[i][1])) //repeat process for the other half of each link + { + POEMSNode * newNode = new POEMSNode; +// forDeletion.Append(newNode); + newNode->idNumber = links[i][1]; + newNode->visited = false; + nodes.Insert(links[i][1], links[i][1], (void *) newNode); + } + POEMSNode * firstNode = (POEMSNode *)nodes.Find(links[i][0]); //now that we are sure both nodes exist, + POEMSNode * secondNode = (POEMSNode *)nodes.Find(links[i][1]); //we can get both of them out of the tree + firstNode->links.Append(secondNode); //and add the link from the first to the second... + false_var = new bool; + *false_var = false; //make a new false boolean to note that the link between these two + firstNode->taken.Append(false_var); //has not already been taken, and append it to the taken list + secondNode->links.Append(firstNode); //repeat process for link from second node to first + false_var = new bool; + *false_var = false; + secondNode->taken.Append(false_var); + } + + TreeNode * temp = nodes.GetRoot(); //get the root node of the node storage tree + POEMSNode * currentNode; + do + { + currentNode = findSingleLink(temp); //find the start of the next available chain + if(currentNode != NULL) + { + headsOfSystems.Append(AddNewChain(currentNode)); //and add it to the headsOfSystems list of chains + } + } + while(currentNode != NULL); //repeat this until all chains have been added } POEMSChain * SystemProcessor::AddNewChain(POEMSNode * currentNode){ - if(currentNode == NULL) //Termination condition; if the currentNode is null, then return null - { - return NULL; - } - int * tmp; - POEMSNode * nextNode = NULL; //nextNode stores the proposed next node to add to the chain. this will be checked to make sure no backtracking is occurring before being assigned as the current node. - POEMSChain * newChain = new POEMSChain; //make a new POEMSChain object. This will be the object returned + if(currentNode == NULL) //Termination condition; if the currentNode is null, then return null + { + return NULL; + } + int * tmp; + POEMSNode * nextNode = NULL; //nextNode stores the proposed next node to add to the chain. this will be checked to make sure no backtracking is occurring before being assigned as the current node. + POEMSChain * newChain = new POEMSChain; //make a new POEMSChain object. This will be the object returned - if(currentNode->links.GetNumElements() == 0) //if we have no links from this node, then the whole chain is only one node. Add this node to the chain and return it; mark node as visited for future reference - { - currentNode->visited = true; - tmp = new int; - *tmp = currentNode->idNumber; - newChain->listOfNodes.Append(tmp); - return newChain; - } - while(currentNode->links.GetNumElements() <= 2) //we go until we get to a node that branches, or both branches have already been taken both branches can already be taken if a loop with no spurs is found in the input data - { - currentNode->visited = true; - tmp = new int; - *tmp = currentNode->idNumber; - newChain->listOfNodes.Append(tmp); //append the current node to the chain & mark as visited - //cout << "Appending node " << currentNode->idNumber << " to chain" << endl; - nextNode = currentNode->links.GetHeadElement()->value; //the next node is the first or second value stored in the links array - //of the current node. We get the first value... - if(!setLinkVisited(currentNode, nextNode)) //...and see if it points back to where we came from. If it does... - { //either way, we set this link as visited - if(currentNode->links.GetNumElements() == 1) //if it does, then if that is the only link to this node, we're done with the chain, so append the chain to the list and return the newly created chain - { -// headsOfSystems.Append(newChain); - return newChain; - } - nextNode = currentNode->links.GetHeadElement()->next->value;//follow the other link if there is one, so we go down the chain - if(!setLinkVisited(currentNode, nextNode)) //mark link as followed, so we know not to backtrack - { - // headsOfSystems.Append(newChain); - return newChain; //This condition, where no branches have occurred but both links have already - //been taken can only occur in a loop with no spurs; add this loop to the - //system (currently added as a chain for consistency), and return. - } - } - currentNode = nextNode; //set the current node to be the next node in the chain - } - currentNode->visited = true; - tmp = new int; - *tmp = currentNode->idNumber; - newChain->listOfNodes.Append(tmp); //append the last node before branch (node shared jointly with branch chains) - //re-mark as visited, just to make sure - ListElement * tempNode = currentNode->links.GetHeadElement(); //go through all of the links, one at a time that branch - POEMSChain * tempChain = NULL; //temporary variable to hold data - while(tempNode != NULL) //when we have followed all links, stop - { - if(setLinkVisited(tempNode->value, currentNode)) //dont backtrack, or create closed loops - { - tempChain = AddNewChain(tempNode->value); //Add a new chain created out of the next node down that link - tempChain->parentChain = newChain; //set the parent to be this chain - newChain->childChains.Append(tempChain); //append the chain to this chain's list of child chains - } - tempNode = tempNode->next; //go to process the next chain - } - //headsOfSystems.Append(newChain); //append this chain to the system list - return newChain; + if(currentNode->links.GetNumElements() == 0) //if we have no links from this node, then the whole chain is only one node. Add this node to the chain and return it; mark node as visited for future reference + { + currentNode->visited = true; + tmp = new int; + *tmp = currentNode->idNumber; + newChain->listOfNodes.Append(tmp); + return newChain; + } + while(currentNode->links.GetNumElements() <= 2) //we go until we get to a node that branches, or both branches have already been taken both branches can already be taken if a loop with no spurs is found in the input data + { + currentNode->visited = true; + tmp = new int; + *tmp = currentNode->idNumber; + newChain->listOfNodes.Append(tmp); //append the current node to the chain & mark as visited + //cout << "Appending node " << currentNode->idNumber << " to chain" << endl; + nextNode = currentNode->links.GetHeadElement()->value; //the next node is the first or second value stored in the links array + //of the current node. We get the first value... + if(!setLinkVisited(currentNode, nextNode)) //...and see if it points back to where we came from. If it does... + { //either way, we set this link as visited + if(currentNode->links.GetNumElements() == 1) //if it does, then if that is the only link to this node, we're done with the chain, so append the chain to the list and return the newly created chain + { +// headsOfSystems.Append(newChain); + return newChain; + } + nextNode = currentNode->links.GetHeadElement()->next->value;//follow the other link if there is one, so we go down the chain + if(!setLinkVisited(currentNode, nextNode)) //mark link as followed, so we know not to backtrack + { + // headsOfSystems.Append(newChain); + return newChain; //This condition, where no branches have occurred but both links have already + //been taken can only occur in a loop with no spurs; add this loop to the + //system (currently added as a chain for consistency), and return. + } + } + currentNode = nextNode; //set the current node to be the next node in the chain + } + currentNode->visited = true; + tmp = new int; + *tmp = currentNode->idNumber; + newChain->listOfNodes.Append(tmp); //append the last node before branch (node shared jointly with branch chains) + //re-mark as visited, just to make sure + ListElement * tempNode = currentNode->links.GetHeadElement(); //go through all of the links, one at a time that branch + POEMSChain * tempChain = NULL; //temporary variable to hold data + while(tempNode != NULL) //when we have followed all links, stop + { + if(setLinkVisited(tempNode->value, currentNode)) //dont backtrack, or create closed loops + { + tempChain = AddNewChain(tempNode->value); //Add a new chain created out of the next node down that link + tempChain->parentChain = newChain; //set the parent to be this chain + newChain->childChains.Append(tempChain); //append the chain to this chain's list of child chains + } + tempNode = tempNode->next; //go to process the next chain + } + //headsOfSystems.Append(newChain); //append this chain to the system list + return newChain; } POEMSNode * SystemProcessor::findSingleLink(TreeNode * aNode) //This function takes the root of a search tree containing POEMSNodes and returns a POEMSNode corresponding to the start of a chain in the //system. It finds a node that has not been visited before, and only has one link; this node will be used as the head of the chain. { - if(aNode == NULL) - { - return NULL; - } - POEMSNode * returnVal = (POEMSNode *)aNode->GetAuxData(); //get the poemsnode data out of the treenode - POEMSNode * detectLoneLoops = NULL; //is used to handle a loop that has no protruding chains - if(returnVal->visited == false) - { - detectLoneLoops = returnVal; //if we find any node that has not been visited yet, save it - } - if(returnVal->links.GetNumElements() == 1 && returnVal->visited == false) //see if it has one element and hasnt been visited already - { - return returnVal; //return the node is it meets this criteria - } - returnVal = findSingleLink(aNode->Left()); //otherwise, check the left subtree - if(returnVal == NULL) //and if we find nothing... - { - returnVal = findSingleLink(aNode->Right()); //check the right subtree - } - if(returnVal == NULL) //if we could not find any chains - { - returnVal = detectLoneLoops; //see if we found any nodes at all that havent been processed - } - return returnVal; //return what we find (will be NULL if no new chains are - //found) + if(aNode == NULL) + { + return NULL; + } + POEMSNode * returnVal = (POEMSNode *)aNode->GetAuxData(); //get the poemsnode data out of the treenode + POEMSNode * detectLoneLoops = NULL; //is used to handle a loop that has no protruding chains + if(returnVal->visited == false) + { + detectLoneLoops = returnVal; //if we find any node that has not been visited yet, save it + } + if(returnVal->links.GetNumElements() == 1 && returnVal->visited == false) //see if it has one element and hasnt been visited already + { + return returnVal; //return the node is it meets this criteria + } + returnVal = findSingleLink(aNode->Left()); //otherwise, check the left subtree + if(returnVal == NULL) //and if we find nothing... + { + returnVal = findSingleLink(aNode->Right()); //check the right subtree + } + if(returnVal == NULL) //if we could not find any chains + { + returnVal = detectLoneLoops; //see if we found any nodes at all that havent been processed + } + return returnVal; //return what we find (will be NULL if no new chains are + //found) } bool SystemProcessor::setLinkVisited(POEMSNode * firstNode, POEMSNode * secondNode) @@ -223,65 +223,65 @@ bool SystemProcessor::setLinkVisited(POEMSNode * firstNode, POEMSNode * secondNo //value for that particular link. Because each link is represented twice, (once at each node in the link), both of the boolean values need //to be set in the event that the link has to be set as visited. { - //cout << "Checking link between nodes " << firstNode->idNumber << " and " << secondNode->idNumber << "... "; - ListElement * tmp = firstNode->links.GetHeadElement(); //get the head element of the list of pointers for node 1 - ListElement * tmp2 = firstNode->taken.GetHeadElement(); //get the head element of the list of bool isVisited flags for node 1 - while(tmp->value != NULL || tmp2->value != NULL) //go through until we reach the end of the lists - { - if(tmp->value == secondNode) //if we find the link to the other node - { - if(*(tmp2->value) == true) //if the link has already been visited - { - //cout << "visited already" << endl; - return false; //return false to indicate that the link has been visited before this attempt - } - else //otherwise, visit it - { - *tmp2->value = true; - } - break; - } - tmp = tmp->next; //go check next link - tmp2 = tmp2->next; - } + //cout << "Checking link between nodes " << firstNode->idNumber << " and " << secondNode->idNumber << "... "; + ListElement * tmp = firstNode->links.GetHeadElement(); //get the head element of the list of pointers for node 1 + ListElement * tmp2 = firstNode->taken.GetHeadElement(); //get the head element of the list of bool isVisited flags for node 1 + while(tmp->value != NULL || tmp2->value != NULL) //go through until we reach the end of the lists + { + if(tmp->value == secondNode) //if we find the link to the other node + { + if(*(tmp2->value) == true) //if the link has already been visited + { + //cout << "visited already" << endl; + return false; //return false to indicate that the link has been visited before this attempt + } + else //otherwise, visit it + { + *tmp2->value = true; + } + break; + } + tmp = tmp->next; //go check next link + tmp2 = tmp2->next; + } - tmp = secondNode->links.GetHeadElement(); //now, if the link was unvisited, we need to go set the other node's list such that - //it also knows this link is being visited - tmp2 = secondNode->taken.GetHeadElement(); - while(tmp->value != NULL || tmp2->value != NULL) //go through the list - { - if(tmp->value == firstNode) //if we find the link - { - if(*(tmp2->value) == true) //and it has already been visited, then signal an error; this shouldnt ever happen - { - cout << "Error in parsing structure! Should never reach this condition! \n" << - "Record of visited links out of synch between two adjacent nodes.\n"; - return false; - } - else - { - *tmp2->value = true; //set the appropriate value to true to indicate this link has been visited - } - break; - } - tmp = tmp->next; - tmp2 = tmp2->next; - } - //cout << "not visited" << endl; - return true; //return true to indicate that this is the first time the link has been visited + tmp = secondNode->links.GetHeadElement(); //now, if the link was unvisited, we need to go set the other node's list such that + //it also knows this link is being visited + tmp2 = secondNode->taken.GetHeadElement(); + while(tmp->value != NULL || tmp2->value != NULL) //go through the list + { + if(tmp->value == firstNode) //if we find the link + { + if(*(tmp2->value) == true) //and it has already been visited, then signal an error; this shouldnt ever happen + { + cout << "Error in parsing structure! Should never reach this condition! \n" << + "Record of visited links out of synch between two adjacent nodes.\n"; + return false; + } + else + { + *tmp2->value = true; //set the appropriate value to true to indicate this link has been visited + } + break; + } + tmp = tmp->next; + tmp2 = tmp2->next; + } + //cout << "not visited" << endl; + return true; //return true to indicate that this is the first time the link has been visited } -List * SystemProcessor::getSystemData(void) //Gets the list of POEMSChains that comprise the system. Might eventually only - //return chains linked to the reference plane, but currently returns every chain - //in the system. +List * SystemProcessor::getSystemData(void) //Gets the list of POEMSChains that comprise the system. Might eventually only + //return chains linked to the reference plane, but currently returns every chain + //in the system. { - return &headsOfSystems; + return &headsOfSystems; } int SystemProcessor::getNumberOfHeadChains(void) //This function isnt implemented yet, and might be taken out entirely; this was a holdover - //from when I intended to return an array of chain pointers, rather than a list of chains - //It will probably be deleted once I finish figuring out exactly what needs to be returned + //from when I intended to return an array of chain pointers, rather than a list of chains + //It will probably be deleted once I finish figuring out exactly what needs to be returned { - return 0; + return 0; } #endif diff --git a/lib/poems/body23joint.h b/lib/poems/body23joint.h index 60253ac8a4..3beb5bd349 100644 --- a/lib/poems/body23joint.h +++ b/lib/poems/body23joint.h @@ -2,8 +2,8 @@ *_________________________________________________________________________* * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * DESCRIPTION: SEE READ-ME * - * FILE NAME: body23joint.h * - * AUTHORS: See Author List * + * FILE NAME: body23joint.h * + * AUTHORS: See Author List * * GRANTS: See Grants List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * LICENSE: Please see License Agreement * @@ -11,7 +11,7 @@ * ADMINISTRATOR: Prof. Kurt Anderson * * Computational Dynamics Lab * * Rensselaer Polytechnic Institute * - * 110 8th St. Troy NY 12180 * + * 110 8th St. Troy NY 12180 * * CONTACT: anderk5@rpi.edu * *_________________________________________________________________________*/ diff --git a/lib/poems/colmatrix.h b/lib/poems/colmatrix.h index 11fd85a928..0e4a85f784 100644 --- a/lib/poems/colmatrix.h +++ b/lib/poems/colmatrix.h @@ -3,7 +3,7 @@ * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * DESCRIPTION: SEE READ-ME * * FILE NAME: colmatrix.h * - * AUTHORS: See Author List * + * AUTHORS: See Author List * * GRANTS: See Grants List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * LICENSE: Please see License Agreement * @@ -11,7 +11,7 @@ * ADMINISTRATOR: Prof. Kurt Anderson * * Computational Dynamics Lab * * Rensselaer Polytechnic Institute * - * 110 8th St. Troy NY 12180 * + * 110 8th St. Troy NY 12180 * * CONTACT: anderk5@rpi.edu * *_________________________________________________________________________*/ @@ -62,23 +62,23 @@ public: void BasicMin(double& value, int& index); // fast matrix operations - friend void FastQuaternions(ColMatrix& q, Mat3x3& C); - friend void FastInvQuaternions(Mat3x3& C, ColMatrix& q); - friend void FastQuaternionDerivatives(ColMatrix& q, ColMatrix& omega, ColMatrix& qdot); - friend void FastTMult(Matrix& A, Vect6& B, ColMatrix& C); - friend void FastMult(Matrix& A, ColMatrix& B, Vect6& C); - friend void FastAssign(ColMatrix& A, ColMatrix& C); + friend void FastQuaternions(ColMatrix& q, Mat3x3& C); + friend void FastInvQuaternions(Mat3x3& C, ColMatrix& q); + friend void FastQuaternionDerivatives(ColMatrix& q, ColMatrix& omega, ColMatrix& qdot); + friend void FastTMult(Matrix& A, Vect6& B, ColMatrix& C); + friend void FastMult(Matrix& A, ColMatrix& B, Vect6& C); + friend void FastAssign(ColMatrix& A, ColMatrix& C); - friend void FastMult(Mat3x3& A, ColMatrix& B, Vect3& C); - friend void FastMult(Mat3x3& A, Vect3& B, ColMatrix& C); - friend void FastAssign(ColMatrix&A, Vect3& C); - - friend void EP_Derivatives(ColMatrix& q, ColMatrix& u, ColMatrix& qdot); - friend void EP_Transformation(ColMatrix& q, Mat3x3& C); - friend void EP_FromTransformation(ColMatrix& q, Mat3x3& C); - friend void EP_Normalize(ColMatrix& q); - friend void EPdotdot_udot(ColMatrix& Audot, ColMatrix& Aqdot, ColMatrix& Aq,ColMatrix& Aqddot); - friend void qdot_to_u(ColMatrix& q, ColMatrix& u, ColMatrix& qdot); + friend void FastMult(Mat3x3& A, ColMatrix& B, Vect3& C); + friend void FastMult(Mat3x3& A, Vect3& B, ColMatrix& C); + friend void FastAssign(ColMatrix&A, Vect3& C); + + friend void EP_Derivatives(ColMatrix& q, ColMatrix& u, ColMatrix& qdot); + friend void EP_Transformation(ColMatrix& q, Mat3x3& C); + friend void EP_FromTransformation(ColMatrix& q, Mat3x3& C); + friend void EP_Normalize(ColMatrix& q); + friend void EPdotdot_udot(ColMatrix& Audot, ColMatrix& Aqdot, ColMatrix& Aq,ColMatrix& Aqddot); + friend void qdot_to_u(ColMatrix& q, ColMatrix& u, ColMatrix& qdot); }; #endif diff --git a/lib/poems/defines.h b/lib/poems/defines.h index 455bc298d5..920e9d2070 100644 --- a/lib/poems/defines.h +++ b/lib/poems/defines.h @@ -2,8 +2,8 @@ *_________________________________________________________________________* * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * DESCRIPTION: SEE READ-ME * - * FILE NAME: defines.h * - * AUTHORS: See Author List * + * FILE NAME: defines.h * + * AUTHORS: See Author List * * GRANTS: See Grants List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * LICENSE: Please see License Agreement * @@ -11,7 +11,7 @@ * ADMINISTRATOR: Prof. Kurt Anderson * * Computational Dynamics Lab * * Rensselaer Polytechnic Institute * - * 110 8th St. Troy NY 12180 * + * 110 8th St. Troy NY 12180 * * CONTACT: anderk5@rpi.edu * *_________________________________________________________________________*/ diff --git a/lib/poems/joint.h b/lib/poems/joint.h index 17122af775..cdd742ee64 100644 --- a/lib/poems/joint.h +++ b/lib/poems/joint.h @@ -3,7 +3,7 @@ * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * DESCRIPTION: SEE READ-ME * * FILE NAME: joint.h * - * AUTHORS: See Author List * + * AUTHORS: See Author List * * GRANTS: See Grants List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * LICENSE: Please see License Agreement * @@ -11,7 +11,7 @@ * ADMINISTRATOR: Prof. Kurt Anderson * * Computational Dynamics Lab * * Rensselaer Polytechnic Institute * - * 110 8th St. Troy NY 12180 * + * 110 8th St. Troy NY 12180 * * CONTACT: anderk5@rpi.edu * *_________________________________________________________________________*/ @@ -29,7 +29,7 @@ enum JointType { PRISMATICJOINT = 3, SPHERICALJOINT = 4, BODY23JOINT = 5, - MIXEDJOINT = 6 + MIXEDJOINT = 6 }; class Body; @@ -51,7 +51,7 @@ protected: ColMatrix qdot; // generalized coordinate derivatives ColMatrix udot; // generalized speed derivatives ColMatrix qdotdot; - + Mat3x3 pk_C_ko; // transformation relationship for q = 0 Mat3x3 pk_C_k; // local transform @@ -94,14 +94,14 @@ public: Mat3x3* Get_pkCk(); Mat3x3* Get_kCpk(); - //void SetInitialState(VirtualMatrix& q, VirtualMatrix& u); - void SetInitialState(ColMatrix& q, ColMatrix& u); + //void SetInitialState(VirtualMatrix& q, VirtualMatrix& u); + void SetInitialState(ColMatrix& q, ColMatrix& u); void SetZeroOrientation(VirtualMatrix& C); void ResetQdot(); void ResetQ(); - bool ReadIn(std::istream& in); + bool ReadIn(std::istream& in); void WriteOut(std::ostream& out); - + virtual void WriteOutJointData(std::ostream& out) = 0; virtual bool ReadInJointData(std::istream& in) = 0; virtual Matrix GetForward_sP(); diff --git a/lib/poems/matrixfun.h b/lib/poems/matrixfun.h index 600b608ad3..82b0945aff 100644 --- a/lib/poems/matrixfun.h +++ b/lib/poems/matrixfun.h @@ -3,7 +3,7 @@ * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * DESCRIPTION: SEE READ-ME * * FILE NAME: matrixfun.h * - * AUTHORS: See Author List * + * AUTHORS: See Author List * * GRANTS: See Grants List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * LICENSE: Please see License Agreement * @@ -11,10 +11,10 @@ * ADMINISTRATOR: Prof. Kurt Anderson * * Computational Dynamics Lab * * Rensselaer Polytechnic Institute * - * 110 8th St. Troy NY 12180 * + * 110 8th St. Troy NY 12180 * * CONTACT: anderk5@rpi.edu * *_________________________________________________________________________*/ - + #ifndef MATRIXFUN_H #define MATRIXFUN_H @@ -44,22 +44,22 @@ Mat4x4 Inverse(Mat4x4& A); Mat6x6 Inverse(Mat6x6& A); // overloaded addition -Matrix operator+ (const VirtualMatrix &A, const VirtualMatrix &B); // addition -//Mat3x3 operator+ (const Mat3x3 &A, const Mat3x3 &B); // addition -//Matrix operator+ (const VirtualMatrix &A, const VirtualMatrix &B); // addition +Matrix operator+ (const VirtualMatrix &A, const VirtualMatrix &B); // addition +//Mat3x3 operator+ (const Mat3x3 &A, const Mat3x3 &B); // addition +//Matrix operator+ (const VirtualMatrix &A, const VirtualMatrix &B); // addition // overloaded subtraction -Matrix operator- (const VirtualMatrix &A, const VirtualMatrix &B); // subtraction +Matrix operator- (const VirtualMatrix &A, const VirtualMatrix &B); // subtraction // overloaded matrix multiplication Matrix operator* (const VirtualMatrix &A, const VirtualMatrix &B); // multiplication // overloaded scalar-matrix multiplication -Matrix operator* (const VirtualMatrix &A, double b); // overloaded * -Matrix operator* (double b, const VirtualMatrix &A); // overloaded * +Matrix operator* (const VirtualMatrix &A, double b); // overloaded * +Matrix operator* (double b, const VirtualMatrix &A); // overloaded * // overloaded negative -Matrix operator- (const VirtualMatrix &A); // negative +Matrix operator- (const VirtualMatrix &A); // negative Vect3 Cross(Vect3& a, Vect3& b); Mat3x3 CrossMat(Vect3& a); diff --git a/lib/poems/mixedjoint.h b/lib/poems/mixedjoint.h index 5f59b95f09..1cf972eec3 100644 --- a/lib/poems/mixedjoint.h +++ b/lib/poems/mixedjoint.h @@ -2,8 +2,8 @@ *_________________________________________________________________________* * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * DESCRIPTION: SEE READ-ME * - * FILE NAME: mixedjoint.h * - * AUTHORS: See Author List * + * FILE NAME: mixedjoint.h * + * AUTHORS: See Author List * * GRANTS: See Grants List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * LICENSE: Please see License Agreement * @@ -11,7 +11,7 @@ * ADMINISTRATOR: Prof. Kurt Anderson * * Computational Dynamics Lab * * Rensselaer Polytechnic Institute * - * 110 8th St. Troy NY 12180 * + * 110 8th St. Troy NY 12180 * * CONTACT: anderk5@rpi.edu * *_________________________________________________________________________*/ @@ -26,10 +26,10 @@ class MixedJoint : public Joint{ int numrots; int numtrans; Vect6 dofs; -public: +public: MixedJoint(); ~MixedJoint(); - + JointType GetType(); bool ReadInJointData(std::istream& in); void WriteOutJointData(std::ostream& out); diff --git a/lib/poems/onbody.h b/lib/poems/onbody.h index d9923773c7..b4514c77af 100644 --- a/lib/poems/onbody.h +++ b/lib/poems/onbody.h @@ -3,7 +3,7 @@ * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * DESCRIPTION: SEE READ-ME * * FILE NAME: onbody.h * - * AUTHORS: See Author List * + * AUTHORS: See Author List * * GRANTS: See Grants List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * LICENSE: Please see License Agreement * @@ -11,7 +11,7 @@ * ADMINISTRATOR: Prof. Kurt Anderson * * Computational Dynamics Lab * * Rensselaer Polytechnic Institute * - * 110 8th St. Troy NY 12180 * + * 110 8th St. Troy NY 12180 * * CONTACT: anderk5@rpi.edu * *_________________________________________________________________________*/ @@ -46,7 +46,7 @@ class OnBody { Vect3* gamma; // pointer to gamma vector Mat3x3* pk_C_k; // pointer to transformation - + Mat6x6 sI; // spatial inertias Mat6x6 sIhat; // recursive spatial inertias Mat6x6 sSC; // spatial shift @@ -68,16 +68,16 @@ class OnBody { ColMatrix* qdot; ColMatrix* udot; ColMatrix* qdotdot; - - ColMatrix* r; + + ColMatrix* r; ColMatrix* acc; ColMatrix* ang; // friend classes friend class OnSolver; - -public: + +public: OnBody(); ~OnBody(); int RecursiveSetup(InertialFrame* basebody); @@ -88,11 +88,11 @@ public: Mat3x3 GetN_C_K(); Vect3 LocalCart(); int GetBodyID(); - void CalculateAcceleration(); + void CalculateAcceleration(); void Setup(); void SetupInertialFrame(); - void LocalKinematics(); - void LocalTriangularization(Vect3& Torque, Vect3& Force); + void LocalKinematics(); + void LocalTriangularization(Vect3& Torque, Vect3& Force); void LocalForwardSubstitution(); }; diff --git a/lib/poems/onsolver.h b/lib/poems/onsolver.h index f32b5880a9..5048904463 100644 --- a/lib/poems/onsolver.h +++ b/lib/poems/onsolver.h @@ -3,7 +3,7 @@ * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * DESCRIPTION: SEE READ-ME * * FILE NAME: onsolver.h * - * AUTHORS: See Author List * + * AUTHORS: See Author List * * GRANTS: See Grants List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * LICENSE: Please see License Agreement * @@ -11,7 +11,7 @@ * ADMINISTRATOR: Prof. Kurt Anderson * * Computational Dynamics Lab * * Rensselaer Polytechnic Institute * - * 110 8th St. Troy NY 12180 * + * 110 8th St. Troy NY 12180 * * CONTACT: anderk5@rpi.edu * *_________________________________________________________________________*/ @@ -24,28 +24,28 @@ #include - + class OnSolver : public Solver { - OnBody inertialframe; + OnBody inertialframe; int numbodies; - OnBody** bodyarray; - ColMatrix** q; + OnBody** bodyarray; + ColMatrix** q; ColMatrix** qdot; - ColMatrix** qdotdot; + ColMatrix** qdotdot; ColMatrix** u; ColMatrix** udot; - - - + + + void DeleteModel(); int CreateTopologyArray(int i, OnBody* body); void CreateStateMatrixMaps(); - void GetType(); -public: + void GetType(); +public: OnSolver(); ~OnSolver(); void CreateModel(); - void Solve(double time, Matrix& FF); + void Solve(double time, Matrix& FF); }; #endif diff --git a/lib/poems/poemslist.h b/lib/poems/poemslist.h index 9882af013a..39a3af2b51 100644 --- a/lib/poems/poemslist.h +++ b/lib/poems/poemslist.h @@ -3,7 +3,7 @@ * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * DESCRIPTION: SEE READ-ME * * FILE NAME: poemslist.h * - * AUTHORS: See Author List * + * AUTHORS: See Author List * * GRANTS: See Grants List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * LICENSE: Please see License Agreement * @@ -11,7 +11,7 @@ * ADMINISTRATOR: Prof. Kurt Anderson * * Computational Dynamics Lab * * Rensselaer Polytechnic Institute * - * 110 8th St. Troy NY 12180 * + * 110 8th St. Troy NY 12180 * * CONTACT: anderk5@rpi.edu * *_________________________________________________________________________*/ @@ -51,7 +51,7 @@ public: S* operator()(int id); void Append(List * listToAppend); void DeleteValues(); - void RemoveElementAndDeleteValue(ListElement* ele); + void RemoveElementAndDeleteValue(ListElement* ele); void PrintList(); }; @@ -90,9 +90,9 @@ template List::~List(){ template void List::Append(List * listToAppend) { - tail->next = listToAppend->head; - listToAppend->head->prev = tail; - tail = listToAppend->tail; + tail->next = listToAppend->head; + listToAppend->head->prev = tail; + tail = listToAppend->tail; } template int List::GetNumElements(){ @@ -104,7 +104,7 @@ template ListElement* List::GetHeadElement(){ } template ListElement* List::GetTailElement(){ - return tail; + return tail; } @@ -145,16 +145,16 @@ template ListElement* List::Append(S* v){ if(numelements==1) head = tail = ele; else{ - /* + /* tail->next = ele; ele->prev = tail; - tail = ele;*/ - - ele->prev = tail; - tail = ele; - ele->prev->next = ele; - - } + tail = ele;*/ + + ele->prev = tail; + tail = ele; + ele->prev->next = ele; + + } return ele; } @@ -170,9 +170,9 @@ template ListElement* List::Prepend(S* v){ if(numelements==1) head = tail = ele; else{ - ele->next = head; - head = ele; - ele->next->prev = ele; + ele->next = head; + head = ele; + ele->next->prev = ele; } return ele; } @@ -193,12 +193,12 @@ template S* List::operator()(int id){ cerr << "ERROR: subscript out of bounds" << endl; exit(0); } - + ListElement* ele = head; for(int i=0;inext; } - + return ele->value; } @@ -214,15 +214,15 @@ template void List::RemoveElementAndDeleteValue(ListElement* ele) } template void List::PrintList(){ - cout<<"Printing List "<* ele = head; - cout<<*(ele->value)<<" "; - ele = ele->next; - for(int k =2; kvalue)<<" "; - ele = ele->next; - } - cout<<*(ele->value)<* ele = head; + cout<<*(ele->value)<<" "; + ele = ele->next; + for(int k =2; kvalue)<<" "; + ele = ele->next; + } + cout<<*(ele->value)<Left(), visit); // descend left - Postorder(t->Right(), visit); // descend right - visit(t); // visit the node - } + // the recursive scan terminates on a empty subtree + if (t != NULL) + { + Postorder(t->Left(), visit); // descend left + Postorder(t->Right(), visit); // descend right + visit(t); // visit the node + } } // preorder recursive scan of the nodes in a tree void Preorder (TreeNode *t, void visit(TreeNode* &t)) { - // the recursive scan terminates on a empty subtree - if (t != NULL) - { - visit(t); // visit the node - Preorder(t->Left(), visit); // descend left - Preorder(t->Right(), visit); // descend right - } + // the recursive scan terminates on a empty subtree + if (t != NULL) + { + visit(t); // visit the node + Preorder(t->Left(), visit); // descend left + Preorder(t->Right(), visit); // descend right + } } @@ -72,21 +72,21 @@ void Preorder (TreeNode *t, void visit(TreeNode* &t)) // The pointers have default value NULL TreeNode *GetTreeNode(int item,TreeNode *lptr,TreeNode *rptr) { - TreeNode *p; + TreeNode *p; - // call new to allocate the new node - // pass parameters lptr and rptr to the function - p = new TreeNode(item, lptr, rptr); + // call new to allocate the new node + // pass parameters lptr and rptr to the function + p = new TreeNode(item, lptr, rptr); - // if insufficient memory, terminatewith an error message - if (p == NULL) - { - cerr << "Memory allocation failure!\n"; - exit(1); - } + // if insufficient memory, terminatewith an error message + if (p == NULL) + { + cerr << "Memory allocation failure!\n"; + exit(1); + } - // return the pointer to the system generated memory - return p; + // return the pointer to the system generated memory + return p; } @@ -94,7 +94,7 @@ TreeNode *GetTreeNode(int item,TreeNode *lptr,TreeNode *rptr) void FreeTreeNode(TreeNode *p) { - delete p; + delete p; } @@ -102,61 +102,61 @@ void FreeTreeNode(TreeNode *p) // tests whether the node is a leaf node void CountLeaf (TreeNode *t, int& count) { - //use postorder descent - if(t !=NULL) - { - CountLeaf(t->Left(), count); // descend left - CountLeaf(t->Right(), count); // descend right + //use postorder descent + if(t !=NULL) + { + CountLeaf(t->Left(), count); // descend left + CountLeaf(t->Right(), count); // descend right - // check if node t is a leaf node (no descendants) - // if so, increment the variable count - if (t->Left() == NULL && t->Right() == NULL) - count++; - } + // check if node t is a leaf node (no descendants) + // if so, increment the variable count + if (t->Left() == NULL && t->Right() == NULL) + count++; + } } // the function uses the postorder scan. it computes the -// depth of the left and right subtrees of a node and +// depth of the left and right subtrees of a node and // returns the depth as 1 + max(depthLeft,depthRight). // the depth of an empty tree is -1 int Depth (TreeNode *t) { - int depthLeft, depthRight, depthval; + int depthLeft, depthRight, depthval; - if (t == NULL) - depthval = -1; - else - { - depthLeft = Depth(t->Left()); - depthRight = Depth(t->Right()); - depthval = 1+(depthLeft > depthRight?depthLeft:depthRight); - } - return depthval; + if (t == NULL) + depthval = -1; + else + { + depthLeft = Depth(t->Left()); + depthRight = Depth(t->Right()); + depthval = 1+(depthLeft > depthRight?depthLeft:depthRight); + } + return depthval; } void IndentBlanks(int num) { -// const int indentblock = 6; +// const int indentblock = 6; - for(int i = 0; i < num; i++) - cout << " "; + for(int i = 0; i < num; i++) + cout << " "; } void PrintTree (TreeNode *t, int level) { - //print tree with root t, as long as t!=NULL - if (t != NULL) - { - int indentUnit = 5; - // print right branch of tree t - PrintTree(t->Right(),level + 1); - // indent to current level; output node data - IndentBlanks(indentUnit*level); - cout << t->GetData() << endl; - // print left branch of tree t - PrintTree(t->Left(),level + 1); - } + //print tree with root t, as long as t!=NULL + if (t != NULL) + { + int indentUnit = 5; + // print right branch of tree t + PrintTree(t->Right(),level + 1); + // indent to current level; output node data + IndentBlanks(indentUnit*level); + cout << t->GetData() << endl; + // print left branch of tree t + PrintTree(t->Left(),level + 1); + } } #endif diff --git a/lib/poems/poemstree.h b/lib/poems/poemstree.h index 70750d4019..ee07a33255 100644 --- a/lib/poems/poemstree.h +++ b/lib/poems/poemstree.h @@ -3,7 +3,7 @@ * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * DESCRIPTION: SEE READ-ME * * FILE NAME: poemstree.h * - * AUTHORS: See Author List * + * AUTHORS: See Author List * * GRANTS: See Grants List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * LICENSE: Please see License Agreement * @@ -11,7 +11,7 @@ * ADMINISTRATOR: Prof. Kurt Anderson * * Computational Dynamics Lab * * Rensselaer Polytechnic Institute * - * 110 8th St. Troy NY 12180 * + * 110 8th St. Troy NY 12180 * * CONTACT: anderk5@rpi.edu * *_________________________________________________________________________*/ @@ -31,74 +31,74 @@ const int rightheavy = 1; class Tree{ protected: - // pointer to tree root and node most recently accessed - TreeNode *root; - TreeNode *current; + // pointer to tree root and node most recently accessed + TreeNode *root; + TreeNode *current; - // number of elements in the tree - int size; - // used by the copy constructor and assignment operator - TreeNode *CopyTree(TreeNode *t); + // number of elements in the tree + int size; + // used by the copy constructor and assignment operator + TreeNode *CopyTree(TreeNode *t); // callback function to delete aux data void (*DeleteAuxData)(void *); - // used by insert and delete method to re-establish - // the avl conditions after a node is added or deleted - // from a subtree - void SingleRotateLeft (TreeNode* &p); - void SingleRotateRight (TreeNode* &p); - void DoubleRotateLeft (TreeNode* &p); - void DoubleRotateRight (TreeNode* &p); - void UpdateLeftTree (TreeNode* &p, int &reviseBalanceFactor); - void UpdateRightTree (TreeNode* &p, int &reviseBalanceFactor); + // used by insert and delete method to re-establish + // the avl conditions after a node is added or deleted + // from a subtree + void SingleRotateLeft (TreeNode* &p); + void SingleRotateRight (TreeNode* &p); + void DoubleRotateLeft (TreeNode* &p); + void DoubleRotateRight (TreeNode* &p); + void UpdateLeftTree (TreeNode* &p, int &reviseBalanceFactor); + void UpdateRightTree (TreeNode* &p, int &reviseBalanceFactor); - // used by destructor, assignment operator and ClearList - void DeleteTree(TreeNode *t); - void ClearTree(TreeNode * &t); + // used by destructor, assignment operator and ClearList + void DeleteTree(TreeNode *t); + void ClearTree(TreeNode * &t); - // locate a node with data item and its parent in tree - // used by Find and Delete - TreeNode *FindNode(const int& item, TreeNode* & parent) const; + // locate a node with data item and its parent in tree + // used by Find and Delete + TreeNode *FindNode(const int& item, TreeNode* & parent) const; public: - // constructor, destructor - Tree(void); - ~Tree(void) - { - ClearTree(root); - }; + // constructor, destructor + Tree(void); + ~Tree(void) + { + ClearTree(root); + }; - // assignment operator - Tree& operator= (const Tree& rhs); + // assignment operator + Tree& operator= (const Tree& rhs); - // standard list handling methods - void * Find(int& item); - void * GetAuxData(int item) { + // standard list handling methods + void * Find(int& item); + void * GetAuxData(int item) { return (void *)(FindNode(item, root)->GetAuxData()); } void SetDeleteAuxData(void (*callback)(void *)) { DeleteAuxData = callback; } - void Insert(const int& item, const int& data, void * AuxData = NULL); - void Delete(const int& item); - void AVLInsert(TreeNode* &tree, TreeNode* newNode, int &reviseBalanceFactor); - void ClearList(void); - - // tree specific methods - void Update(const int& item); - TreeNode *GetRoot(void) const; + void Insert(const int& item, const int& data, void * AuxData = NULL); + void Delete(const int& item); + void AVLInsert(TreeNode* &tree, TreeNode* newNode, int &reviseBalanceFactor); + void ClearList(void); + + // tree specific methods + void Update(const int& item); + TreeNode *GetRoot(void) const; }; // constructor Tree::Tree(void) { - root = 0; - current = 0; - size = 0; + root = 0; + current = 0; + size = 0; DeleteAuxData = NULL; } @@ -107,418 +107,418 @@ Tree::Tree(void) // return root pointer TreeNode *Tree::GetRoot(void) const { - return root; + return root; } // assignment operator Tree& Tree::operator = (const Tree& rhs) { - // can't copy a tree to itself - if (this == &rhs) - return *this; + // can't copy a tree to itself + if (this == &rhs) + return *this; - // clear current tree. copy new tree into current object - ClearList(); - root = CopyTree(rhs.root); + // clear current tree. copy new tree into current object + ClearList(); + root = CopyTree(rhs.root); - // assign current to root and set the tree size - current = root; - size = rhs.size; + // assign current to root and set the tree size + current = root; + size = rhs.size; - // return reference to current object - return *this; + // return reference to current object + return *this; } // search for data item in the tree. if found, return its node // address and a pointer to its parent; otherwise, return NULL TreeNode *Tree::FindNode(const int& item, - TreeNode* & parent) const + TreeNode* & parent) const { - // cycle t through the tree starting with root - TreeNode *t = root; + // cycle t through the tree starting with root + TreeNode *t = root; - // the parent of the root is NULL - parent = NULL; + // the parent of the root is NULL + parent = NULL; - // terminate on empty subtree - while(t != NULL) - { - // stop on a match - if (item == t->data) - break; - else - { - // update the parent pointer and move right of left - parent = t; - if (item < t->data) - t = t->left; - else - t = t->right; - } - } + // terminate on empty subtree + while(t != NULL) + { + // stop on a match + if (item == t->data) + break; + else + { + // update the parent pointer and move right of left + parent = t; + if (item < t->data) + t = t->left; + else + t = t->right; + } + } - // return pointer to node; NULL if not found - return t; + // return pointer to node; NULL if not found + return t; } // search for item. if found, assign the node data to item void * Tree::Find(int& item) { - // we use FindNode, which requires a parent parameter - TreeNode *parent; + // we use FindNode, which requires a parent parameter + TreeNode *parent; - // search tree for item. assign matching node to current - current = FindNode (item, parent); + // search tree for item. assign matching node to current + current = FindNode (item, parent); - // if item found, assign data to item and return True - if (current != NULL) - { - item = current->data; + // if item found, assign data to item and return True + if (current != NULL) + { + item = current->data; return current->GetAuxData(); - } - else - // item not found in the tree. return False - return NULL; + } + else + // item not found in the tree. return False + return NULL; } void Tree::Insert(const int& item, const int& data, void * AuxData) { - // declare AVL tree node pointer; using base class method - // GetRoot. cast to larger node and assign root pointer - TreeNode *treeRoot, *newNode; - treeRoot = GetRoot(); + // declare AVL tree node pointer; using base class method + // GetRoot. cast to larger node and assign root pointer + TreeNode *treeRoot, *newNode; + treeRoot = GetRoot(); - // flag used by AVLInsert to rebalance nodes - int reviseBalanceFactor = 0; + // flag used by AVLInsert to rebalance nodes + int reviseBalanceFactor = 0; - // get a new AVL tree node with empty pointer fields - newNode = GetTreeNode(item,NULL,NULL); - newNode->data = data; - newNode->SetAuxData(AuxData); - // call recursive routine to actually insert the element - AVLInsert(treeRoot, newNode, reviseBalanceFactor); + // get a new AVL tree node with empty pointer fields + newNode = GetTreeNode(item,NULL,NULL); + newNode->data = data; + newNode->SetAuxData(AuxData); + // call recursive routine to actually insert the element + AVLInsert(treeRoot, newNode, reviseBalanceFactor); - // assign new values to data members in the base class - root = treeRoot; - current = newNode; - size++; + // assign new values to data members in the base class + root = treeRoot; + current = newNode; + size++; } void Tree::AVLInsert(TreeNode *&tree, TreeNode *newNode, int &reviseBalanceFactor) { - // flag indicates change node's balanceFactor will occur - int rebalanceCurrNode; + // flag indicates change node's balanceFactor will occur + int rebalanceCurrNode; - // scan reaches an empty tree; time to insert the new node - if (tree == NULL) - { - // update the parent to point at newNode - tree = newNode; + // scan reaches an empty tree; time to insert the new node + if (tree == NULL) + { + // update the parent to point at newNode + tree = newNode; - // assign balanceFactor = 0 to new node - tree->balanceFactor = balanced; - // broadcast message; balanceFactor value is modified - reviseBalanceFactor = 1; - } - // recursively move left if new data < current data - else if (newNode->data < tree->data) - { - AVLInsert(tree->left,newNode,rebalanceCurrNode); - // check if balanceFactor must be updated. - if (rebalanceCurrNode) - { - // went left from node that is left heavy. will - // violate AVL condition; use rotation (case 3) - if (tree->balanceFactor == leftheavy) - UpdateLeftTree(tree,reviseBalanceFactor); + // assign balanceFactor = 0 to new node + tree->balanceFactor = balanced; + // broadcast message; balanceFactor value is modified + reviseBalanceFactor = 1; + } + // recursively move left if new data < current data + else if (newNode->data < tree->data) + { + AVLInsert(tree->left,newNode,rebalanceCurrNode); + // check if balanceFactor must be updated. + if (rebalanceCurrNode) + { + // went left from node that is left heavy. will + // violate AVL condition; use rotation (case 3) + if (tree->balanceFactor == leftheavy) + UpdateLeftTree(tree,reviseBalanceFactor); - // went left from balanced node. will create - // node left on the left. AVL condition OK (case 1) - else if (tree->balanceFactor == balanced) - { - tree->balanceFactor = leftheavy; - reviseBalanceFactor = 1; - } - // went left from node that is right heavy. will - // balance the node. AVL condition OK (case 2) - else - { - tree->balanceFactor = balanced; - reviseBalanceFactor = 0; - } - } - else + // went left from balanced node. will create + // node left on the left. AVL condition OK (case 1) + else if (tree->balanceFactor == balanced) + { + tree->balanceFactor = leftheavy; + reviseBalanceFactor = 1; + } + // went left from node that is right heavy. will + // balance the node. AVL condition OK (case 2) + else + { + tree->balanceFactor = balanced; + reviseBalanceFactor = 0; + } + } + else // no balancing occurs; do not ask previous nodes - reviseBalanceFactor = 0; - } + reviseBalanceFactor = 0; + } // otherwise recursively move right else - { - AVLInsert(tree->right, newNode, rebalanceCurrNode); - // check if balanceFactor must be updated. - if (rebalanceCurrNode) - { - // went right from node that is left heavy. wil; - // balance the node. AVL condition OK (case 2) - if (tree->balanceFactor == leftheavy) - { - // scanning right subtree. node heavy on left. - // the node will become balanced - tree->balanceFactor = balanced; - reviseBalanceFactor = 0; - } - // went right from balanced node. will create - // node heavy on the right. AVL condition OK (case 1) - else if (tree->balanceFactor == balanced) - { - // node is balanced; will become heavy on right - tree->balanceFactor = rightheavy; - reviseBalanceFactor = 1; - } - // went right from node that is right heavy. will - // violate AVL condition; use rotation (case 3) - else - UpdateRightTree(tree, reviseBalanceFactor); - } - else - reviseBalanceFactor = 0; - } + { + AVLInsert(tree->right, newNode, rebalanceCurrNode); + // check if balanceFactor must be updated. + if (rebalanceCurrNode) + { + // went right from node that is left heavy. wil; + // balance the node. AVL condition OK (case 2) + if (tree->balanceFactor == leftheavy) + { + // scanning right subtree. node heavy on left. + // the node will become balanced + tree->balanceFactor = balanced; + reviseBalanceFactor = 0; + } + // went right from balanced node. will create + // node heavy on the right. AVL condition OK (case 1) + else if (tree->balanceFactor == balanced) + { + // node is balanced; will become heavy on right + tree->balanceFactor = rightheavy; + reviseBalanceFactor = 1; + } + // went right from node that is right heavy. will + // violate AVL condition; use rotation (case 3) + else + UpdateRightTree(tree, reviseBalanceFactor); + } + else + reviseBalanceFactor = 0; + } } void Tree::UpdateLeftTree (TreeNode* &p, int &reviseBalanceFactor) { - TreeNode *lc; + TreeNode *lc; - lc = p->Left(); // left subtree is also heavy - if (lc->balanceFactor == leftheavy) - { - SingleRotateRight(p); - reviseBalanceFactor = 0; - } - // is right subtree heavy? - else if (lc->balanceFactor == rightheavy) - { - // make a double rotation - DoubleRotateRight(p); - // root is now balance - reviseBalanceFactor = 0; - } + lc = p->Left(); // left subtree is also heavy + if (lc->balanceFactor == leftheavy) + { + SingleRotateRight(p); + reviseBalanceFactor = 0; + } + // is right subtree heavy? + else if (lc->balanceFactor == rightheavy) + { + // make a double rotation + DoubleRotateRight(p); + // root is now balance + reviseBalanceFactor = 0; + } } void Tree::UpdateRightTree (TreeNode* &p, int &reviseBalanceFactor) { - TreeNode *lc; + TreeNode *lc; - lc = p->Right(); // right subtree is also heavy - if (lc->balanceFactor == rightheavy) - { - SingleRotateLeft(p); - reviseBalanceFactor = 0; - } - // is left subtree heavy? - else if (lc->balanceFactor == leftheavy) - { - // make a double rotation - DoubleRotateLeft(p); - // root is now balance - reviseBalanceFactor = 0; - } + lc = p->Right(); // right subtree is also heavy + if (lc->balanceFactor == rightheavy) + { + SingleRotateLeft(p); + reviseBalanceFactor = 0; + } + // is left subtree heavy? + else if (lc->balanceFactor == leftheavy) + { + // make a double rotation + DoubleRotateLeft(p); + // root is now balance + reviseBalanceFactor = 0; + } } void Tree::SingleRotateRight (TreeNode* &p) { - // the left subtree of p is heavy - TreeNode *lc; + // the left subtree of p is heavy + TreeNode *lc; - // assign the left subtree to lc - lc = p->Left(); + // assign the left subtree to lc + lc = p->Left(); - // update the balance factor for parent and left child - p->balanceFactor = balanced; - lc->balanceFactor = balanced; + // update the balance factor for parent and left child + p->balanceFactor = balanced; + lc->balanceFactor = balanced; - // any right subtree st of lc must continue as right - // subtree of lc. do by making it a left subtree of p - p->left = lc->Right(); + // any right subtree st of lc must continue as right + // subtree of lc. do by making it a left subtree of p + p->left = lc->Right(); - // rotate p (larger node) into right subtree of lc - // make lc the pivot node - lc->right = p; - p = lc; + // rotate p (larger node) into right subtree of lc + // make lc the pivot node + lc->right = p; + p = lc; } void Tree::SingleRotateLeft (TreeNode* &p) { - // the right subtree of p is heavy - TreeNode *lc; + // the right subtree of p is heavy + TreeNode *lc; - // assign the left subtree to lc - lc = p->Right(); + // assign the left subtree to lc + lc = p->Right(); - // update the balance factor for parent and left child - p->balanceFactor = balanced; - lc->balanceFactor = balanced; + // update the balance factor for parent and left child + p->balanceFactor = balanced; + lc->balanceFactor = balanced; - // any right subtree st of lc must continue as right - // subtree of lc. do by making it a left subtree of p - p->right = lc->Left(); + // any right subtree st of lc must continue as right + // subtree of lc. do by making it a left subtree of p + p->right = lc->Left(); - // rotate p (larger node) into right subtree of lc - // make lc the pivot node - lc->left = p; - p = lc; + // rotate p (larger node) into right subtree of lc + // make lc the pivot node + lc->left = p; + p = lc; } // double rotation right about node p void Tree::DoubleRotateRight (TreeNode* &p) { - // two subtrees that are rotated - TreeNode *lc, *np; + // two subtrees that are rotated + TreeNode *lc, *np; - // in the tree, node(lc) <= node(np) < node(p) - lc = p->Left(); // lc is left child of parent - np = lc->Right(); // np is right child of lc - - // update balance factors for p, lc, and np - if (np->balanceFactor == rightheavy) - { - p->balanceFactor = balanced; - lc->balanceFactor = rightheavy; - } - else if (np->balanceFactor == balanced) - { - p->balanceFactor = balanced; - lc->balanceFactor = balanced; - } - else - { - p->balanceFactor = rightheavy; - lc->balanceFactor = balanced; - } - np->balanceFactor = balanced; + // in the tree, node(lc) <= node(np) < node(p) + lc = p->Left(); // lc is left child of parent + np = lc->Right(); // np is right child of lc - // before np replaces the parent p, take care of subtrees - // detach old children and attach new children - lc->right = np->Left(); - np->left = lc; - p->left = np->Right(); - np->right = p; - p = np; + // update balance factors for p, lc, and np + if (np->balanceFactor == rightheavy) + { + p->balanceFactor = balanced; + lc->balanceFactor = rightheavy; + } + else if (np->balanceFactor == balanced) + { + p->balanceFactor = balanced; + lc->balanceFactor = balanced; + } + else + { + p->balanceFactor = rightheavy; + lc->balanceFactor = balanced; + } + np->balanceFactor = balanced; + + // before np replaces the parent p, take care of subtrees + // detach old children and attach new children + lc->right = np->Left(); + np->left = lc; + p->left = np->Right(); + np->right = p; + p = np; } void Tree::DoubleRotateLeft (TreeNode* &p) { - // two subtrees that are rotated - TreeNode *lc, *np; + // two subtrees that are rotated + TreeNode *lc, *np; - // in the tree, node(lc) <= node(np) < node(p) - lc = p->Right(); // lc is right child of parent - np = lc->Left(); // np is left child of lc - - // update balance factors for p, lc, and np - if (np->balanceFactor == leftheavy) - { - p->balanceFactor = balanced; - lc->balanceFactor = leftheavy; - } - else if (np->balanceFactor == balanced) - { - p->balanceFactor = balanced; - lc->balanceFactor = balanced; - } - else - { - p->balanceFactor = leftheavy; - lc->balanceFactor = balanced; - } - np->balanceFactor = balanced; + // in the tree, node(lc) <= node(np) < node(p) + lc = p->Right(); // lc is right child of parent + np = lc->Left(); // np is left child of lc - // before np replaces the parent p, take care of subtrees - // detach old children and attach new children - lc->left = np->Right(); - np->right = lc; - p->right = np->Left(); - np->left = p; - p = np; + // update balance factors for p, lc, and np + if (np->balanceFactor == leftheavy) + { + p->balanceFactor = balanced; + lc->balanceFactor = leftheavy; + } + else if (np->balanceFactor == balanced) + { + p->balanceFactor = balanced; + lc->balanceFactor = balanced; + } + else + { + p->balanceFactor = leftheavy; + lc->balanceFactor = balanced; + } + np->balanceFactor = balanced; + + // before np replaces the parent p, take care of subtrees + // detach old children and attach new children + lc->left = np->Right(); + np->right = lc; + p->right = np->Left(); + np->left = p; + p = np; } // if item is in the tree, delete it void Tree::Delete(const int& item) { - // DNodePtr = pointer to node D that is deleted - // PNodePtr = pointer to parent P of node D - // RNodePtr = pointer to node R that replaces D - TreeNode *DNodePtr, *PNodePtr, *RNodePtr; + // DNodePtr = pointer to node D that is deleted + // PNodePtr = pointer to parent P of node D + // RNodePtr = pointer to node R that replaces D + TreeNode *DNodePtr, *PNodePtr, *RNodePtr; - // search for a node containing data value item. obtain its - // node address and that of its parent - if ((DNodePtr = FindNode (item, PNodePtr)) == NULL) - return; + // search for a node containing data value item. obtain its + // node address and that of its parent + if ((DNodePtr = FindNode (item, PNodePtr)) == NULL) + return; - // If D has NULL pointer, the - // replacement node is the one on the other branch - if (DNodePtr->right == NULL) - RNodePtr = DNodePtr->left; - else if (DNodePtr->left == NULL) - RNodePtr = DNodePtr->right; - // Both pointers of DNodePtr are non-NULL - else - { - // Find and unlink replacement node for D - // Starting on the left branch of node D, - // find node whose data value is the largest of all - // nodes whose values are less than the value in D - // Unlink the node from the tree + // If D has NULL pointer, the + // replacement node is the one on the other branch + if (DNodePtr->right == NULL) + RNodePtr = DNodePtr->left; + else if (DNodePtr->left == NULL) + RNodePtr = DNodePtr->right; + // Both pointers of DNodePtr are non-NULL + else + { + // Find and unlink replacement node for D + // Starting on the left branch of node D, + // find node whose data value is the largest of all + // nodes whose values are less than the value in D + // Unlink the node from the tree - // PofRNodePtr = pointer to parent of replacement node - TreeNode *PofRNodePtr = DNodePtr; + // PofRNodePtr = pointer to parent of replacement node + TreeNode *PofRNodePtr = DNodePtr; - // frist possible replacement is left child D - RNodePtr = DNodePtr->left; + // frist possible replacement is left child D + RNodePtr = DNodePtr->left; - // descend down right subtree of the left child of D - // keeping a record of current node and its parent. - // when we stop, we have found the replacement - while (RNodePtr->right != NULL) - { - PofRNodePtr = RNodePtr; - RNodePtr = RNodePtr; - } + // descend down right subtree of the left child of D + // keeping a record of current node and its parent. + // when we stop, we have found the replacement + while (RNodePtr->right != NULL) + { + PofRNodePtr = RNodePtr; + RNodePtr = RNodePtr; + } - if (PofRNodePtr == DNodePtr) - // left child of deleted node is the replacement - // assign right subtree of D to R - RNodePtr->right = DNodePtr->right; - else - { - // we moved at least one node down a right brance - // delete replacement node from tree by assigning - // its left branc to its parent - PofRNodePtr->right = RNodePtr->left; + if (PofRNodePtr == DNodePtr) + // left child of deleted node is the replacement + // assign right subtree of D to R + RNodePtr->right = DNodePtr->right; + else + { + // we moved at least one node down a right brance + // delete replacement node from tree by assigning + // its left branc to its parent + PofRNodePtr->right = RNodePtr->left; - // put replacement node in place of DNodePtr. - RNodePtr->left = DNodePtr->left; - RNodePtr->right = DNodePtr->right; - } - } + // put replacement node in place of DNodePtr. + RNodePtr->left = DNodePtr->left; + RNodePtr->right = DNodePtr->right; + } + } - // complete the link to the parent node - // deleting the root node. assign new root - if (PNodePtr == NULL) - root = RNodePtr; - // attach R to the correct branch of P - else if (DNodePtr->data < PNodePtr->data) - PNodePtr->left = RNodePtr; - else - PNodePtr->right = RNodePtr; + // complete the link to the parent node + // deleting the root node. assign new root + if (PNodePtr == NULL) + root = RNodePtr; + // attach R to the correct branch of P + else if (DNodePtr->data < PNodePtr->data) + PNodePtr->left = RNodePtr; + else + PNodePtr->right = RNodePtr; - // delete the node from memory and decrement list size - FreeTreeNode(DNodePtr); // this says FirstTreeNode in the book, should be a typo - size--; + // delete the node from memory and decrement list size + FreeTreeNode(DNodePtr); // this says FirstTreeNode in the book, should be a typo + size--; } @@ -529,49 +529,49 @@ void Tree::Delete(const int& item) // assign node value to item; otherwise, insert item in tree void Tree::Update(const int& item) { - if (current !=NULL && current->data == item) - current->data = item; - else - Insert(item, item); + if (current !=NULL && current->data == item) + current->data = item; + else + Insert(item, item); } // create duplicate of tree t; return the new root TreeNode *Tree::CopyTree(TreeNode *t) { - // variable newnode points at each new node that is - // created by a call to GetTreeNode and later attached to - // the new tree. newlptr and newrptr point to the child of - // newnode and are passed as parameters to GetTreeNode - TreeNode *newlptr, *newrptr, *newnode; + // variable newnode points at each new node that is + // created by a call to GetTreeNode and later attached to + // the new tree. newlptr and newrptr point to the child of + // newnode and are passed as parameters to GetTreeNode + TreeNode *newlptr, *newrptr, *newnode; - // stop the recursive scan when we arrive at an empty tree - if (t == NULL) - return NULL; + // stop the recursive scan when we arrive at an empty tree + if (t == NULL) + return NULL; - // CopyTree builds a new tree by scanning the nodes of t. - // At each node in t, CopyTree checks for a left child. if - // present it makes a copy of left child or returns NULL. - // the algorithm similarly checks for a right child. - // CopyTree builds a copy of node using GetTreeNode and - // appends copy of left and right children to node. + // CopyTree builds a new tree by scanning the nodes of t. + // At each node in t, CopyTree checks for a left child. if + // present it makes a copy of left child or returns NULL. + // the algorithm similarly checks for a right child. + // CopyTree builds a copy of node using GetTreeNode and + // appends copy of left and right children to node. - if (t->Left() !=NULL) - newlptr = CopyTree(t->Left()); - else - newlptr = NULL; + if (t->Left() !=NULL) + newlptr = CopyTree(t->Left()); + else + newlptr = NULL; - if (t->Right() !=NULL) - newrptr = CopyTree(t->Right()); - else - newrptr = NULL; + if (t->Right() !=NULL) + newrptr = CopyTree(t->Right()); + else + newrptr = NULL; - // Build new tree from the bottom up by building the two - // children and then building the parent - newnode = GetTreeNode(t->data, newlptr, newrptr); + // Build new tree from the bottom up by building the two + // children and then building the parent + newnode = GetTreeNode(t->data, newlptr, newrptr); - // return a pointer to the newly created node - return newnode; + // return a pointer to the newly created node + return newnode; } @@ -598,16 +598,16 @@ void Tree::DeleteTree(TreeNode *t) // set the root pointer back to NULL void Tree::ClearTree(TreeNode * &t) { - DeleteTree(t); - t = NULL; // root now NULL + DeleteTree(t); + t = NULL; // root now NULL } // delete all nodes in list void Tree::ClearList(void) { - delete root; - delete current; - size = 0; + delete root; + delete current; + size = 0; } #endif diff --git a/lib/poems/poemstreenode.h b/lib/poems/poemstreenode.h index b8f46031a5..a1835ba025 100644 --- a/lib/poems/poemstreenode.h +++ b/lib/poems/poemstreenode.h @@ -3,7 +3,7 @@ * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * DESCRIPTION: SEE READ-ME * * FILE NAME: poemstreenode.h * - * AUTHORS: See Author List * + * AUTHORS: See Author List * * GRANTS: See Grants List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * LICENSE: Please see License Agreement * @@ -11,7 +11,7 @@ * ADMINISTRATOR: Prof. Kurt Anderson * * Computational Dynamics Lab * * Rensselaer Polytechnic Institute * - * 110 8th St. Troy NY 12180 * + * 110 8th St. Troy NY 12180 * * CONTACT: anderk5@rpi.edu * *_________________________________________________________________________*/ @@ -29,23 +29,23 @@ class TreeNode{ private: // points to the left and right children of the node - TreeNode *left; - TreeNode *right; + TreeNode *left; + TreeNode *right; - int balanceFactor; - int data; - void * aux_data; -public: - // make Tree a friend because it needs access to left and right pointer fields of a node - friend class Tree; - TreeNode * Left(); - TreeNode * Right(); - int GetData(); - void * GetAuxData() {return aux_data;}; - void SetAuxData(void * AuxData) {aux_data = AuxData;}; - int GetBalanceFactor(); - TreeNode(const int &item, TreeNode *lptr, TreeNode *rptr, int balfac = 0); - //friend class DCASolver; + int balanceFactor; + int data; + void * aux_data; +public: + // make Tree a friend because it needs access to left and right pointer fields of a node + friend class Tree; + TreeNode * Left(); + TreeNode * Right(); + int GetData(); + void * GetAuxData() {return aux_data;}; + void SetAuxData(void * AuxData) {aux_data = AuxData;}; + int GetBalanceFactor(); + TreeNode(const int &item, TreeNode *lptr, TreeNode *rptr, int balfac = 0); + //friend class DCASolver; }; #endif diff --git a/lib/poems/points.h b/lib/poems/points.h index f8b95c738e..502389759a 100644 --- a/lib/poems/points.h +++ b/lib/poems/points.h @@ -2,8 +2,8 @@ *_________________________________________________________________________* * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * DESCRIPTION: SEE READ-ME * - * FILE NAME: points.h * - * AUTHORS: See Author List * + * FILE NAME: points.h * + * AUTHORS: See Author List * * GRANTS: See Grants List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * LICENSE: Please see License Agreement * @@ -11,7 +11,7 @@ * ADMINISTRATOR: Prof. Kurt Anderson * * Computational Dynamics Lab * * Rensselaer Polytechnic Institute * - * 110 8th St. Troy NY 12180 * + * 110 8th St. Troy NY 12180 * * CONTACT: anderk5@rpi.edu * *_________________________________________________________________________*/ diff --git a/lib/poems/system.h b/lib/poems/system.h index 573044ce33..87b56929ed 100644 --- a/lib/poems/system.h +++ b/lib/poems/system.h @@ -3,7 +3,7 @@ * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * DESCRIPTION: SEE READ-ME * * FILE NAME: system.h * - * AUTHORS: See Author List * + * AUTHORS: See Author List * * GRANTS: See Grants List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * LICENSE: Please see License Agreement * @@ -11,7 +11,7 @@ * ADMINISTRATOR: Prof. Kurt Anderson * * Computational Dynamics Lab * * Rensselaer Polytechnic Institute * - * 110 8th St. Troy NY 12180 * + * 110 8th St. Troy NY 12180 * * CONTACT: anderk5@rpi.edu * *_________________________________________________________________________*/ @@ -22,8 +22,8 @@ #include #include #include -#include -#include +#include +#include #include "poemslist.h" #include "matrices.h" @@ -47,42 +47,42 @@ class Joint; class System{ - private: - int * mappings; - + private: + int * mappings; + public: double time; List bodies; List joints; - + System(); ~System(); void Delete(); - + int GetNumBodies(); - - int * GetMappings(); + + int * GetMappings(); void AddBody(Body* body); - + void AddJoint(Joint* joint); - + void SetTime(double t); - + double GetTime(); - + void ComputeForces(); - + bool ReadIn(std::istream& in); - + void WriteOut(std::ostream& out); - + void ClearBodyIDs(); - - void ClearJointIDs(); + + void ClearJointIDs(); void Create_System_LAMMPS(int numbodies, double *mass,double **inertia, double ** xcm, double ** xjoint,double **vh1,double **omega,double **ex_space, double **ey_space, double **ez_space, int b, int * mapping, int count); - + void Create_DegenerateSystem(int& nfree, int*freelist, double *&masstotal, double **&inertia, double **&xcm, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space); }; diff --git a/lib/poems/virtualcolmatrix.h b/lib/poems/virtualcolmatrix.h index 1548794ca0..e0af8b4ae7 100644 --- a/lib/poems/virtualcolmatrix.h +++ b/lib/poems/virtualcolmatrix.h @@ -3,7 +3,7 @@ * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * DESCRIPTION: SEE READ-ME * * FILE NAME: virtualcolmatrix.h * - * AUTHORS: See Author List * + * AUTHORS: See Author List * * GRANTS: See Grants List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * LICENSE: Please see License Agreement * @@ -11,7 +11,7 @@ * ADMINISTRATOR: Prof. Kurt Anderson * * Computational Dynamics Lab * * Rensselaer Polytechnic Institute * - * 110 8th St. Troy NY 12180 * + * 110 8th St. Troy NY 12180 * * CONTACT: anderk5@rpi.edu * *_________________________________________________________________________*/ @@ -23,22 +23,22 @@ class VirtualColMatrix : public VirtualMatrix { -public: - VirtualColMatrix(); - ~VirtualColMatrix(); - double& operator_2int (int i, int j); // array access - double Get_2int (int i, int j) const; - void Set_2int (int i, int j, double value); - double BasicGet_2int(int i, int j) const; - void BasicSet_2int(int i, int j, double value); - void BasicIncrement_2int(int i, int j, double value); +public: + VirtualColMatrix(); + ~VirtualColMatrix(); + double& operator_2int (int i, int j); // array access + double Get_2int (int i, int j) const; + void Set_2int (int i, int j, double value); + double BasicGet_2int(int i, int j) const; + void BasicSet_2int(int i, int j, double value); + void BasicIncrement_2int(int i, int j, double value); - virtual double& operator_1int (int i) = 0; // array access - virtual double Get_1int(int i) const = 0; - virtual void Set_1int(int i, double value) = 0; - virtual double BasicGet_1int(int i) const = 0; - virtual void BasicSet_1int(int i, double value) = 0; - virtual void BasicIncrement_1int(int i, double value) = 0; + virtual double& operator_1int (int i) = 0; // array access + virtual double Get_1int(int i) const = 0; + virtual void Set_1int(int i, double value) = 0; + virtual double BasicGet_1int(int i) const = 0; + virtual void BasicSet_1int(int i, double value) = 0; + virtual void BasicIncrement_1int(int i, double value) = 0; }; diff --git a/lib/poems/virtualmatrix.h b/lib/poems/virtualmatrix.h index a27c7de047..ba3f5dc673 100644 --- a/lib/poems/virtualmatrix.h +++ b/lib/poems/virtualmatrix.h @@ -3,7 +3,7 @@ * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * DESCRIPTION: SEE READ-ME * * FILE NAME: virtualmatrix.h * - * AUTHORS: See Author List * + * AUTHORS: See Author List * * GRANTS: See Grants List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * LICENSE: Please see License Agreement * @@ -11,7 +11,7 @@ * ADMINISTRATOR: Prof. Kurt Anderson * * Computational Dynamics Lab * * Rensselaer Polytechnic Institute * - * 110 8th St. Troy NY 12180 * + * 110 8th St. Troy NY 12180 * * CONTACT: anderk5@rpi.edu * *_________________________________________________________________________*/ @@ -21,62 +21,62 @@ #include enum MatrixType { - MATRIX = 0, - COLMATRIX = 1, - ROWMATRIX = 2, - MAT3X3 = 3, - VECT3 = 4, - MAT6X6 = 5, - VECT6 = 6, - COLMATMAP = 7, - VECT4 = 8, - MAT4X4 = 9 + MATRIX = 0, + COLMATRIX = 1, + ROWMATRIX = 2, + MAT3X3 = 3, + VECT3 = 4, + MAT6X6 = 5, + VECT6 = 6, + COLMATMAP = 7, + VECT4 = 8, + MAT4X4 = 9 }; class VirtualMatrix { protected: - int numrows, numcols; + int numrows, numcols; public: - VirtualMatrix(); - virtual ~VirtualMatrix(); - int GetNumRows() const; - int GetNumCols() const; + VirtualMatrix(); + virtual ~VirtualMatrix(); + int GetNumRows() const; + int GetNumCols() const; - double& operator() (int i, int j); // array access - double Get(int i, int j) const; - void Set(int i, int j, double value); - double BasicGet(int i, int j) const; - void BasicSet(int i, int j, double value); - void BasicIncrement(int i, int j, double value); + double& operator() (int i, int j); // array access + double Get(int i, int j) const; + void Set(int i, int j, double value); + double BasicGet(int i, int j) const; + void BasicSet(int i, int j, double value); + void BasicIncrement(int i, int j, double value); - double& operator() (int i); // array access - double Get(int i) const; - void Set(int i, double value); - double BasicGet(int i) const; - void BasicSet(int i, double value); - void BasicIncrement(int i, double value); + double& operator() (int i); // array access + double Get(int i) const; + void Set(int i, double value); + double BasicGet(int i) const; + void BasicSet(int i, double value); + void BasicIncrement(int i, double value); - virtual void Const(double value) = 0; - virtual MatrixType GetType() const = 0; - virtual void AssignVM(const VirtualMatrix& A) = 0; - void Zeros(); - void Ones(); - virtual std::ostream& WriteData(std::ostream& c) const; - virtual std::istream& ReadData(std::istream& c); + virtual void Const(double value) = 0; + virtual MatrixType GetType() const = 0; + virtual void AssignVM(const VirtualMatrix& A) = 0; + void Zeros(); + void Ones(); + virtual std::ostream& WriteData(std::ostream& c) const; + virtual std::istream& ReadData(std::istream& c); protected: - virtual double& operator_2int(int i, int j) = 0; - virtual double& operator_1int(int i); - virtual double Get_2int(int i, int j) const = 0; - virtual double Get_1int(int i) const ; - virtual void Set_2int(int i, int j, double value) = 0; - virtual void Set_1int(int i, double value); - virtual double BasicGet_2int(int i, int j) const = 0; - virtual double BasicGet_1int(int i) const ; - virtual void BasicSet_2int(int i, int j, double value) = 0; - virtual void BasicSet_1int(int i, double value); - virtual void BasicIncrement_2int(int i, int j, double value) = 0; - virtual void BasicIncrement_1int(int i, double value); + virtual double& operator_2int(int i, int j) = 0; + virtual double& operator_1int(int i); + virtual double Get_2int(int i, int j) const = 0; + virtual double Get_1int(int i) const ; + virtual void Set_2int(int i, int j, double value) = 0; + virtual void Set_1int(int i, double value); + virtual double BasicGet_2int(int i, int j) const = 0; + virtual double BasicGet_1int(int i) const ; + virtual void BasicSet_2int(int i, int j, double value) = 0; + virtual void BasicSet_1int(int i, double value); + virtual void BasicIncrement_2int(int i, int j, double value) = 0; + virtual void BasicIncrement_1int(int i, double value); }; diff --git a/lib/poems/workspace.h b/lib/poems/workspace.h index 5faaf904dc..7d4d5c8a29 100644 --- a/lib/poems/workspace.h +++ b/lib/poems/workspace.h @@ -3,7 +3,7 @@ * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * DESCRIPTION: SEE READ-ME * * FILE NAME: workspace.h * - * AUTHORS: See Author List * + * AUTHORS: See Author List * * GRANTS: See Grants List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * LICENSE: Please see License Agreement * @@ -11,7 +11,7 @@ * ADMINISTRATOR: Prof. Kurt Anderson * * Computational Dynamics Lab * * Rensselaer Polytechnic Institute * - * 110 8th St. Troy NY 12180 * + * 110 8th St. Troy NY 12180 * * CONTACT: anderk5@rpi.edu * *_________________________________________________________________________*/ @@ -23,8 +23,8 @@ #include #include #include -#include -#include +#include +#include #include @@ -32,57 +32,57 @@ class System; class Solver; struct SysData{ - System * system; - int solver; - int integrator; + System * system; + int solver; + int integrator; }; class Workspace { - SysData * system; // the multibody systems data - int currentIndex; - int maxAlloc; - + SysData * system; // the multibody systems data + int currentIndex; + int maxAlloc; + public: Workspace(); ~Workspace(); - + double Thalf; double Tfull; double ConFac; double KE_val; - int FirstTime; - + int FirstTime; + bool LoadFile(char* filename); - + bool SaveFile(char* filename, int index = -1); System* GetSystem(int index = -1); - - void AddSolver(Solver* s, int index = -1); - - void LobattoOne(double **&xcm, double **&vcm,double **&omega,double **&torque, double **&fcm, double **&ex_space, double **&ey_space, double **&ez_space); - - void LobattoTwo(double **&vcm,double **&omega,double **&torque, double **&fcm); - - + void AddSolver(Solver* s, int index = -1); + + + void LobattoOne(double **&xcm, double **&vcm,double **&omega,double **&torque, double **&fcm, double **&ex_space, double **&ey_space, double **&ez_space); + + void LobattoTwo(double **&vcm,double **&omega,double **&torque, double **&fcm); + + bool MakeSystem(int& nbody, double *&masstotal, double **&inertia, double **&xcm, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space, int &njoint, int **&jointbody, double **&xjoint, int& nfree, int*freelist, double dthalf, double dtv, double tempcon, double KE); - - - bool SaveSystem(int& nbody, double *&masstotal, double **&inertia, double **&xcm, double **&xjoint, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space, double **&acm, double **&alpha, double **&torque, double **&fcm, int **&jointbody, int &njoint); - - bool MakeDegenerateSystem(int& nfree, int*freelist, double *&masstotal, double **&inertia, double **&xcm, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space); + + + bool SaveSystem(int& nbody, double *&masstotal, double **&inertia, double **&xcm, double **&xjoint, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space, double **&acm, double **&alpha, double **&torque, double **&fcm, int **&jointbody, int &njoint); + + bool MakeDegenerateSystem(int& nfree, int*freelist, double *&masstotal, double **&inertia, double **&xcm, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space); int getNumberOfSystems(); - + void SetLammpsValues(double dtv, double dthalf, double tempcon); void SetKE(int temp, double SysKE); - - void RKStep(double **&xcm, double **&vcm,double **&omega,double **&torque, double **&fcm, double **&ex_space, double **&ey_space, double **&ez_space); - - void WriteFile(char* filename); + + void RKStep(double **&xcm, double **&vcm,double **&omega,double **&torque, double **&fcm, double **&ex_space, double **&ey_space, double **&ez_space); + + void WriteFile(char* filename); private: - void allocateNewSystem(); //helper function to handle vector resizing and such for the array of system pointers + void allocateNewSystem(); //helper function to handle vector resizing and such for the array of system pointers }; #endif