diff --git a/applications/test/DynamicField/DynamicFieldTest.C b/applications/test/DynamicField/DynamicFieldTest.C index e78747fb0f88ce68b700dbc2c9133e46705f0e4d..3e5a8dfc547c6fa7d99623ade1aa6a991a752839 100644 --- a/applications/test/DynamicField/DynamicFieldTest.C +++ b/applications/test/DynamicField/DynamicFieldTest.C @@ -43,6 +43,9 @@ int main(int argc, char *argv[]) dl.append(2); dl.append(1); Pout<< "appending : dl:" << dl << endl; + + dl[2] *= 10; + Pout<< "assigning : dl:" << dl << endl; } { diff --git a/src/Allwmake b/src/Allwmake index 4da8d4f7192d83bb7946bc5ff1c1923f92b0e2af..e1589a404671a1aeaefe194c70f1426c2759342a 100755 --- a/src/Allwmake +++ b/src/Allwmake @@ -17,7 +17,7 @@ wmakeLnInclude OpenFOAM wmakeLnInclude OSspecific/$WM_OSTYPE Pstream/Allwmake -wmake libo OSspecific/$WM_OSTYPE +OSspecific/$WM_OSTYPE/Allwmake wmake libso OpenFOAM wmake libso lagrangian/basic diff --git a/src/OSspecific/POSIX/Allwmake b/src/OSspecific/POSIX/Allwmake new file mode 100755 index 0000000000000000000000000000000000000000..7819ce885bf8f0b9b61ce2306f7c0554f9c7a341 --- /dev/null +++ b/src/OSspecific/POSIX/Allwmake @@ -0,0 +1,21 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + +# +# use <sys/inotify.h> if available (Linux) +# unless otherwise specified (with FOAM_USE_STAT) +# +# eg, ./Allwmake FOAM_USE_STAT +# +if [ -f /usr/include/sys/inotify.h -a "${1%USE_STAT}" = "$1" ] +then + unset FOAM_FILE_MONITOR +else + export FOAM_FILE_MONITOR="-DFOAM_USE_STAT" +fi + + +# make (non-shared) object +wmake libo + +# ----------------------------------------------------------------- end-of-file diff --git a/src/OSspecific/POSIX/Make/options b/src/OSspecific/POSIX/Make/options index b7e9d7211b0d99053035f413a747854a47144187..be643469df3ff9007881b6a0c6f20fee04e8a377 100644 --- a/src/OSspecific/POSIX/Make/options +++ b/src/OSspecific/POSIX/Make/options @@ -1,3 +1 @@ -#ifdef SunOS64 -EXE_INC = -DFOAM_USE_STAT -#endif +EXE_INC = $(FOAM_FILE_MONITOR) diff --git a/src/OSspecific/POSIX/fileMonitor.C b/src/OSspecific/POSIX/fileMonitor.C index f7f0246c9869314fc353c0846ebab05e1503115b..a812dec9429b112fde68be45fe65b709dd76e8db 100644 --- a/src/OSspecific/POSIX/fileMonitor.C +++ b/src/OSspecific/POSIX/fileMonitor.C @@ -37,7 +37,6 @@ Class # include "regIOobject.H" // for fileModificationSkew symbol #else # include <sys/inotify.h> -# include <stropts.h> # include <sys/ioctl.h> #endif @@ -49,8 +48,8 @@ template<> const char* Foam::NamedEnum<Foam::fileMonitor::fileState, 3>::names[] = { "unmodified", - "deleted", - "modified" + "modified", + "deleted" }; const Foam::NamedEnum<Foam::fileMonitor::fileState, 3> Foam::fileMonitor::fileStateNames_; @@ -58,7 +57,7 @@ const Foam::NamedEnum<Foam::fileMonitor::fileState, 3> namespace Foam { - // Reduction operator for PackedList of fileState + //- Reduction operator for PackedList of fileState class reduceFileStates { public: @@ -89,7 +88,7 @@ namespace Foam } }; - // Combine operator for PackedList of fileState + //- Combine operator for PackedList of fileState class combineReduceFileStates { public: @@ -98,22 +97,101 @@ namespace Foam x = reduceFileStates()(x, y); } }; + + + + //! @cond internalClass + //- Internal tracking via stat(3p) or inotify(7) + class fileMonitorWatcher + { + public: + +#ifdef FOAM_USE_STAT + //- From watch descriptor to modified time + HashTable<label, time_t> lastMod; + + //- initialize HashTable size + inline fileMonitorWatcher(const label sz = 20) + : + lastMod(sz) + {} + + inline label addWatch(const fileName& fName) + { + const label watchFd = lastMod.size(); + lastMod.insert(watchFd, lastModified(fName)); + return watchFd; + } + + inline bool removeWatch(const label watchFd) + { + return lastMod.erase(watchFd); + } + +#else + //- File descriptor for the inotify instance + int fd; + + //- Pre-allocated structure containing file descriptors + fd_set fdSet; + + //- initialize inotify + inline fileMonitorWatcher(const label dummy = 0) + : + fd(inotify_init()) + { + // Add notify descriptor to select fd_set + FD_ZERO(&fdSet); + FD_SET(fd, &fdSet); + } + + //- test if file descriptor is set + inline bool isSet() const + { + return FD_ISSET(fd, &fdSet); + } + + //- reset file descriptor + inline void reset() + { + FD_SET(fd, &fdSet); + } + + inline label addWatch(const fileName& fName) + { + return inotify_add_watch + ( + fd, + fName.c_str(), + // IN_ALL_EVENTS + IN_CLOSE_WRITE | IN_DELETE_SELF | IN_MODIFY + ); + } + + inline bool removeWatch(const label watchFd) + { + return inotify_rm_watch(fd, int(watchFd)) == 0; + } +#endif + + }; + //! @endcond } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -#ifdef FOAM_USE_STAT void Foam::fileMonitor::checkFiles() const { +#ifdef FOAM_USE_STAT for ( - HashTable<label, time_t>::iterator iter = lastModified_.begin(); - iter != lastModified_.end(); + HashTable<label, time_t>::iterator iter = watcher_->lastMod.begin(); + iter != watcher_->lastMod.end(); ++iter ) { - label watchFd = iter.key(); + const label watchFd = iter.key(); const fileName& fName = watchFile_[watchFd]; time_t newTime = lastModified(fName); @@ -135,21 +213,18 @@ void Foam::fileMonitor::checkFiles() const } } } -} #else -void Foam::fileMonitor::checkFiles() const -{ while (true) { struct timeval zeroTimeout = {0, 0}; int ready = select ( - inotifyFd_+1, // num filedescriptors in watchSet_ - &watchSet_, // watchSet_ with only inotifyFd - NULL, - NULL, - &zeroTimeout + watcher_->fd+1, // num filedescriptors in fdSet + &(watcher_->fdSet), // fdSet with only inotifyFd + NULL, // No writefds + NULL, // No errorfds + &zeroTimeout // eNo timeout ); if (ready < 0) @@ -158,14 +233,14 @@ void Foam::fileMonitor::checkFiles() const << "Problem in issuing select." << abort(FatalError); } - else if (FD_ISSET(inotifyFd_, &watchSet_)) + else if (watcher_->isSet()) { struct inotify_event inotifyEvent; // Read first event ssize_t nBytes = read ( - inotifyFd_, + watcher_->fd, &inotifyEvent, sizeof(inotifyEvent) ); @@ -178,9 +253,9 @@ void Foam::fileMonitor::checkFiles() const << abort(FatalError); } - //Pout<< "mask:" << inotifyEvent.mask << endl; - //Pout<< "watchFd:" << inotifyEvent.wd << endl; - //Pout<< "watchName:" << watchFile_[inotifyEvent.wd] << endl; + // Pout<< "mask:" << inotifyEvent.mask << nl + // << "watchFd:" << inotifyEvent.wd << nl + // << "watchName:" << watchFile_[inotifyEvent.wd] << endl; switch (inotifyEvent.mask) { @@ -204,51 +279,37 @@ void Foam::fileMonitor::checkFiles() const } else { - // No data. Reset watchSet_ - FD_SET(inotifyFd_, &watchSet_); + // No data - reset + watcher_->reset(); return; } } -} #endif +} // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Null constructor -#ifdef FOAM_USE_STAT Foam::fileMonitor::fileMonitor() : state_(20), watchFile_(20), - lastModified_(20) + watcher_(new fileMonitorWatcher(20)) {} -#else - -Foam::fileMonitor::fileMonitor() -: - state_(20), - watchFile_(20), - inotifyFd_(inotify_init()) -{ - //- Add notify descriptor to select set - FD_ZERO(&watchSet_); - FD_SET(inotifyFd_, &watchSet_); -} - -#endif // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::fileMonitor::~fileMonitor() { - // Remove any remaining files + // Remove watch on any remaining files List<label> watchFds(state_.toc()); forAll(watchFds, i) { removeWatch(watchFds[i]); } + + delete watcher_; } @@ -257,18 +318,7 @@ Foam::fileMonitor::~fileMonitor() Foam::label Foam::fileMonitor::addWatch(const fileName& fName) { -#ifdef FOAM_USE_STAT - label watchFd = lastModified_.size(); - lastModified_.insert(watchFd, lastModified(fName)); -#else - label watchFd = inotify_add_watch - ( - inotifyFd_, - fName.c_str(), - //IN_ALL_EVENTS - IN_CLOSE_WRITE | IN_DELETE_SELF | IN_MODIFY - ); -#endif + const label watchFd = watcher_->addWatch(fName); if (debug) { @@ -300,11 +350,7 @@ bool Foam::fileMonitor::removeWatch(const label watchFd) state_.erase(watchFd); watchFile_.erase(watchFd); -#ifdef FOAM_USE_STAT - return lastModified_.erase(watchFd); -#else - return inotify_rm_watch(inotifyFd_, int(watchFd)) == 0; -#endif + return watcher_->removeWatch(watchFd); } @@ -331,7 +377,7 @@ void Foam::fileMonitor::updateStates(const bool syncPar) const label i = 0; forAllConstIter(Map<fileState>, state_, iter) { - stats[i++] = (unsigned int)(iter()); + stats[i++] = static_cast<unsigned int>(iter()); } // Save local state for warning message below PackedList<2> thisProcStats(stats); @@ -378,7 +424,7 @@ void Foam::fileMonitor::updateStates(const bool syncPar) const void Foam::fileMonitor::setUnmodified(const label watchFd) { #ifdef FOAM_USE_STAT - lastModified_[watchFd] = lastModified(watchFile_[watchFd]); + watcher_->lastMod[watchFd] = lastModified(watchFile_[watchFd]); #endif Map<fileState>::iterator iter = state_.find(watchFd); diff --git a/src/OSspecific/POSIX/fileMonitor.H b/src/OSspecific/POSIX/fileMonitor.H index b9922eb3e2a45a69f9dba7963ddda640206dd4f3..fbb0c4e2d64fd642f0c3cbf5c27d45b0cd660fd2 100644 --- a/src/OSspecific/POSIX/fileMonitor.H +++ b/src/OSspecific/POSIX/fileMonitor.H @@ -27,13 +27,13 @@ Class Description Checking for changes to files. -!!!!!!!NOTE: - Default is to use inotify (Linux specific, since 2.6.13) +Note + The default is to use inotify (Linux specific, since 2.6.13) - Compile with FOAM_USE_STAT to use the stat function call. + Compiling with FOAM_USE_STAT (or if /usr/include/sys/inotify.h + does not exist) uses the stat function call. - - - works fine except for if file gets deleted and recreated + - works fine except when a file is deleted and recreated: it stops monitoring the file! (does work though if the file gets moved) @@ -48,7 +48,6 @@ SourceFiles #include <sys/types.h> #include "Map.H" #include "NamedEnum.H" -#include "labelList.H" #include "className.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -57,9 +56,10 @@ namespace Foam { class fileMonitor; +class fileMonitorWatcher; /*---------------------------------------------------------------------------*\ - Class fileMonitor Declaration + Class fileMonitor Declaration \*---------------------------------------------------------------------------*/ class fileMonitor @@ -73,8 +73,8 @@ public: enum fileState { UNMODIFIED = 0, - DELETED = 1, - MODIFIED = 2 + MODIFIED = 1, + DELETED = 2, }; static const NamedEnum<fileState, 3> fileStateNames_; @@ -84,22 +84,16 @@ private: //- State for all watchFds mutable Map<fileState> state_; - + //- From watch descriptor to filename HashTable<fileName, label> watchFile_; -#ifdef FOAM_USE_STAT + //- Watch mechanism (stat or inotify) + mutable fileMonitorWatcher *watcher_; - //- From watch descriptor to modified time - mutable HashTable<label, time_t> lastModified_; -#else - //- File descriptor for the inotify instance - int inotifyFd_; - //- Pre-allocated structure containing file descriptors - mutable fd_set watchSet_; + // Private Member Functions -#endif //- Update state_ from any events. void checkFiles() const; @@ -121,14 +115,13 @@ public: fileMonitor(); - // Destructor - - ~fileMonitor(); + //- Destructor + ~fileMonitor(); // Member Functions - //- Add file to watch. Returns watch descriptor + //- Add file to watch. Return watch descriptor label addWatch(const fileName&); //- Remove file to watch. Return true if successful diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H index d9bd00b1b198d9254240b59fbe5dfdf23adf2ea0..f5967cf5b382ff21649e08a10687cd1e40e8b4cb 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H @@ -310,7 +310,7 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append const T& t ) { - label elemI = List<T>::size(); + const label elemI = List<T>::size(); setSize(elemI + 1); this->operator[](elemI) = t; @@ -361,7 +361,7 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> inline T Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::remove() { - label elemI = List<T>::size() - 1; + const label elemI = List<T>::size() - 1; if (elemI < 0) { diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H index 17e3398a2055650cbf2880e373f61fd0e12d3c00..2999e0886ed5826b974c121b9ce2f8c53ad6f6b6 100644 --- a/src/OpenFOAM/containers/Lists/List/List.H +++ b/src/OpenFOAM/containers/Lists/List/List.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -180,6 +180,9 @@ public: //- Clear the list, i.e. set size to zero. void clear(); + //- Append an element at the end of the list + inline void append(const T&); + //- Append a List at the end of this list inline void append(const UList<T>&); diff --git a/src/OpenFOAM/containers/Lists/List/ListI.H b/src/OpenFOAM/containers/Lists/List/ListI.H index 51abd2d55edfe4b6cc9ae235c9d70af34b0cd8a6..24b5c41996a3b57dccd4f459d9f400445ebdf7e6 100644 --- a/src/OpenFOAM/containers/Lists/List/ListI.H +++ b/src/OpenFOAM/containers/Lists/List/ListI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -93,6 +93,13 @@ inline Foam::Xfer<Foam::List<T> > Foam::List<T>::xfer() } +template<class T> +inline void Foam::List<T>::append(const T& t) +{ + setSize(size()+1, t); +} + + template<class T> inline void Foam::List<T>::append(const UList<T>& lst) { diff --git a/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H b/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H index a7715b245ac34d0cf375222116e7c7a698711e75..a464ac9d2243ca7dab8128e3ca8b5f0e0d3df0ff 100644 --- a/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H +++ b/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -175,10 +175,7 @@ public: inline void operator=(const tmp<DynamicField<Type> >&); //- Return element of Field. - inline Type& operator[](const label i); - - //- Return element of constant Field. - inline const Type& operator[](const label) const; + using Field<Type>::operator[]; // IOstream operators diff --git a/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H b/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H index b48db1520448272f169038395b37cdd9cd936b55..bc54c71fbd07242671b3ca68ce383421c42a04b3 100644 --- a/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H +++ b/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,15 +25,10 @@ License #include "DynamicField.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class Type> -DynamicField<Type>::DynamicField() +Foam::DynamicField<Type>::DynamicField() : Field<Type>(), capacity_(0) @@ -41,7 +36,7 @@ DynamicField<Type>::DynamicField() template<class Type> -DynamicField<Type>::DynamicField(const label size) +Foam::DynamicField<Type>::DynamicField(const label size) : Field<Type>(size), capacity_(Field<Type>::size()) @@ -73,7 +68,7 @@ inline Foam::DynamicField<Type>::DynamicField template<class Type> -DynamicField<Type>::DynamicField +Foam::DynamicField<Type>::DynamicField ( const UList<Type>& mapF, const labelList& mapAddressing @@ -85,7 +80,7 @@ DynamicField<Type>::DynamicField template<class Type> -DynamicField<Type>::DynamicField +Foam::DynamicField<Type>::DynamicField ( const UList<Type>& mapF, const labelListList& mapAddressing, @@ -99,7 +94,7 @@ DynamicField<Type>::DynamicField //- Construct by mapping from the given field template<class Type> -DynamicField<Type>::DynamicField +Foam::DynamicField<Type>::DynamicField ( const UList<Type>& mapF, const FieldMapper& map @@ -111,7 +106,7 @@ DynamicField<Type>::DynamicField template<class Type> -DynamicField<Type>::DynamicField(const DynamicField<Type>& f) +Foam::DynamicField<Type>::DynamicField(const DynamicField<Type>& f) : Field<Type>(f), capacity_(Field<Type>::size()) @@ -119,7 +114,7 @@ DynamicField<Type>::DynamicField(const DynamicField<Type>& f) template<class Type> -DynamicField<Type>::DynamicField(DynamicField<Type>& f, bool reUse) +Foam::DynamicField<Type>::DynamicField(DynamicField<Type>& f, bool reUse) : Field<Type>(f, reUse), capacity_(Field<Type>::size()) @@ -127,7 +122,7 @@ DynamicField<Type>::DynamicField(DynamicField<Type>& f, bool reUse) template<class Type> -DynamicField<Type>::DynamicField(const Xfer<DynamicField<Type> >& f) +Foam::DynamicField<Type>::DynamicField(const Xfer<DynamicField<Type> >& f) : Field<Type>(f), capacity_(Field<Type>::size()) @@ -137,14 +132,14 @@ DynamicField<Type>::DynamicField(const Xfer<DynamicField<Type> >& f) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> -Foam::label DynamicField<Type>::capacity() const +Foam::label Foam::DynamicField<Type>::capacity() const { return capacity_; } template<class Type> -void DynamicField<Type>::append(const Type& t) +void Foam::DynamicField<Type>::append(const Type& t) { label elemI = Field<Type>::size(); setSize(elemI + 1); @@ -156,7 +151,7 @@ void DynamicField<Type>::append(const Type& t) // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class Type> -void DynamicField<Type>::operator=(const DynamicField<Type>& rhs) +void Foam::DynamicField<Type>::operator=(const DynamicField<Type>& rhs) { if (this == &rhs) { @@ -171,7 +166,7 @@ void DynamicField<Type>::operator=(const DynamicField<Type>& rhs) template<class Type> -void DynamicField<Type>::operator=(const UList<Type>& rhs) +void Foam::DynamicField<Type>::operator=(const UList<Type>& rhs) { Field<Type>::operator=(rhs); capacity_ = Field<Type>::size(); @@ -179,7 +174,7 @@ void DynamicField<Type>::operator=(const UList<Type>& rhs) template<class Type> -void DynamicField<Type>::operator=(const tmp<DynamicField>& rhs) +void Foam::DynamicField<Type>::operator=(const tmp<DynamicField>& rhs) { if (this == &(rhs())) { @@ -196,25 +191,7 @@ void DynamicField<Type>::operator=(const tmp<DynamicField>& rhs) } -template<class Type> -Type& DynamicField<Type>::operator[](const label i) -{ - return Field<Type>::operator[](i); -} - - -template<class Type> -const Type& DynamicField<Type>::operator[](const label i) const -{ - return Field<Type>::operator[](i); -} - - // * * * * * * * * * * * * * * * IOstream Operator * * * * * * * * * * * * * // -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C index 76e0bd0f8940fbfe8a3cccf44553dbc1b9e0fe5c..80b3ab92986986a1a242af87eec2e0082cf66a0d 100644 --- a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C +++ b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C @@ -38,7 +38,7 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -//- Append all mapped elements of a list to a DynamicList +// Append all mapped elements of a list to a DynamicList void Foam::polyMeshAdder::append ( const labelList& map, @@ -50,7 +50,7 @@ void Foam::polyMeshAdder::append forAll(lst, i) { - label newElem = map[lst[i]]; + const label newElem = map[lst[i]]; if (newElem != -1) { @@ -60,7 +60,7 @@ void Foam::polyMeshAdder::append } -//- Append all mapped elements of a list to a DynamicList +// Append all mapped elements of a list to a DynamicList void Foam::polyMeshAdder::append ( const labelList& map, @@ -73,7 +73,7 @@ void Foam::polyMeshAdder::append forAll(lst, i) { - label newElem = map[lst[i]]; + const label newElem = map[lst[i]]; if (newElem != -1 && findSortedIndex(sortedLst, newElem) == -1) { @@ -170,8 +170,8 @@ void Foam::polyMeshAdder::mergePatchNames ) { // Insert the mesh0 patches and zones - append(patches0.names(), allPatchNames); - append(patches0.types(), allPatchTypes); + allPatchNames.append(patches0.names()); + allPatchTypes.append(patches0.types()); // Patches @@ -924,9 +924,7 @@ void Foam::polyMeshAdder::mergePointZones ) { zoneNames.setCapacity(pz0.size() + pz1.size()); - - // Names - append(pz0.names(), zoneNames); + zoneNames.append(pz0.names()); from1ToAll.setSize(pz1.size()); @@ -959,7 +957,7 @@ void Foam::polyMeshAdder::mergePointZones forAll(pz1, zoneI) { // Relabel all points of zone and add to correct pzPoints. - label allZoneI = from1ToAll[zoneI]; + const label allZoneI = from1ToAll[zoneI]; append ( @@ -991,8 +989,7 @@ void Foam::polyMeshAdder::mergeFaceZones ) { zoneNames.setCapacity(fz0.size() + fz1.size()); - - append(fz0.names(), zoneNames); + zoneNames.append(fz0.names()); from1ToAll.setSize(fz1.size()); @@ -1092,8 +1089,7 @@ void Foam::polyMeshAdder::mergeCellZones ) { zoneNames.setCapacity(cz0.size() + cz1.size()); - - append(cz0.names(), zoneNames); + zoneNames.append(cz0.names()); from1ToAll.setSize(cz1.size()); forAll(cz1, zoneI) @@ -1108,14 +1104,14 @@ void Foam::polyMeshAdder::mergeCellZones forAll(cz0, zoneI) { // Insert mesh0 cells - append(cz0[zoneI], czCells[zoneI]); + czCells[zoneI].append(cz0[zoneI]); } // Cell mapping is trivial. forAll(cz1, zoneI) { - label allZoneI = from1ToAll[zoneI]; + const label allZoneI = from1ToAll[zoneI]; append(from1ToAllCells, cz1[zoneI], czCells[allZoneI]); } diff --git a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.H b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.H index 90612cad909332e962a1a45c896e3413c577597c..1283da8b577625b0ace24268c9404e64a96718d6 100644 --- a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.H +++ b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.H @@ -66,10 +66,6 @@ private: // Private Member Functions - //- Append all elements of a list to a DynamicList - template<class T> - static void append(const List<T>&, DynamicList<T>&); - //- Append all mapped elements of a list to a DynamicList static void append ( @@ -315,12 +311,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository -# include "polyMeshAdderTemplates.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/dynamicMesh/polyMeshAdder/polyMeshAdderTemplates.C b/src/dynamicMesh/polyMeshAdder/polyMeshAdderTemplates.C deleted file mode 100644 index a5a4ff4e80d2cc21706eeece91332b96f71aa819..0000000000000000000000000000000000000000 --- a/src/dynamicMesh/polyMeshAdder/polyMeshAdderTemplates.C +++ /dev/null @@ -1,41 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -//- Append all elements of a list to a DynamicList -template<class T> -void Foam::polyMeshAdder::append(const List<T>& lst, DynamicList<T>& dynLst) -{ - dynLst.setCapacity(dynLst.size() + lst.size()); - - forAll(lst, i) - { - dynLst.append(lst[i]); - } -} - -// ************************************************************************* //