diff --git a/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C b/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C index aa8b89c033..93d385104f 100644 --- a/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C +++ b/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C @@ -52,10 +52,11 @@ Note #include "timeSelector.H" #include "Time.H" #include "polyMesh.H" -#include "keyedSurface.H" -#include "meshedSurface.H" #include "triSurface.H" +#include "MeshedSurfaces.H" +#include "UnsortedMeshedSurfaces.H" + using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -69,7 +70,7 @@ int main(int argc, char *argv[]) argList::validOptions.insert("clean", ""); argList::validOptions.insert("scale", "scale"); argList::validOptions.insert("triSurface", ""); - argList::validOptions.insert("keyed", ""); + argList::validOptions.insert("unsorted", ""); # include "setRootCase.H" const stringList& params = args.additionalArgs(); @@ -122,9 +123,9 @@ int main(int argc, char *argv[]) // write sorted by region surf.write(exportName, true); } - else if (args.options().found("keyed")) + else if (args.options().found("unsorted")) { - keyedSurface surf(importName); + unsortedMeshedSurface surf(importName); if (args.options().found("clean")) { diff --git a/bin/foamTemplates/source/foamTemplate.C b/bin/foamTemplates/source/foamTemplate.C index 99bea11c39..fc947cf9b4 100644 --- a/bin/foamTemplates/source/foamTemplate.C +++ b/bin/foamTemplates/source/foamTemplate.C @@ -31,7 +31,7 @@ License const dataType Foam::className::staticData(); -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -71,10 +71,16 @@ Foam::className::~className() {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // void Foam::className::operator=(const className& rhs) { @@ -87,11 +93,10 @@ void Foam::className::operator=(const className& rhs) } } - -// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * * // -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * // // ************************************************************************* // diff --git a/bin/foamTemplates/sourceTemplate/foamTemplateTemplate.C b/bin/foamTemplates/sourceTemplate/foamTemplateTemplate.C index 92038d8199..f0955b92e4 100644 --- a/bin/foamTemplates/sourceTemplate/foamTemplateTemplate.C +++ b/bin/foamTemplates/sourceTemplate/foamTemplateTemplate.C @@ -32,7 +32,7 @@ template const dataType Foam::ClassName::staticData(); -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -84,10 +84,16 @@ Foam::ClassName::~ClassName() {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // template void Foam::ClassName::operator= @@ -108,10 +114,10 @@ void Foam::ClassName::operator= } -// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * * // -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * // // ************************************************************************* // diff --git a/src/OpenFOAM/db/memberFunctionSelection/addToMemberFunctionSelectionTable.H b/src/OpenFOAM/db/memberFunctionSelection/addToMemberFunctionSelectionTable.H index 03f2a1ea58..eb7698e79d 100644 --- a/src/OpenFOAM/db/memberFunctionSelection/addToMemberFunctionSelectionTable.H +++ b/src/OpenFOAM/db/memberFunctionSelection/addToMemberFunctionSelectionTable.H @@ -35,6 +35,8 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// add to hash-table of functions with typename as the key #define addToMemberFunctionSelectionTable\ (baseType,thisType,memberFunction,argNames) \ \ @@ -42,6 +44,9 @@ Description baseType::add##memberFunction##argNames##MemberFunctionToTable \ add##thisType##memberFunction##argNames##MemberFunctionTo##baseType##Table_ + + +// add to hash-table of functions with 'lookup' as the key #define addNamedToMemberFunctionSelectionTable\ (baseType,thisType,memberFunction,argNames,lookup) \ \ @@ -49,6 +54,11 @@ Description baseType::add##memberFunction##argNames##MemberFunctionToTable \ add_##lookup##_##thisType##memberFunction##argNames##MemberFunctionTo##baseType##Table_(#lookup) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// add to hash-table of functions with typename as the key // use when baseType doesn't need a template argument (eg, is a typedef) #define addTemplateToMemberFunctionSelectionTable\ (baseType,thisType,Targ,memberFunction,argNames) \ @@ -57,6 +67,8 @@ Description baseType::add##memberFunction##argNames##MemberFunctionToTable > \ add##thisType##Targ##memberFunction##argNames##MemberFunctionTo##baseType##Table_ + +// add to hash-table of functions with 'lookup' as the key // use when baseType doesn't need a template argument (eg, is a typedef) #define addNamedTemplateToMemberFunctionSelectionTable\ (baseType,thisType,Targ,memberFunction,argNames,lookup) \ @@ -82,6 +94,29 @@ Description add_##lookup##_##thisType##Targ##memberFunction##argNames##MemberFunctionTo##baseType##Targ##Table_(#lookup) +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// add to hash-table of functions with typename as the key +// use when baseType requires the Targ template argument as well +#define addTemplatedToMemberFunctionSelectionTable\ +(baseType,thisType,Targ,memberFunction,argNames) \ + \ + /* Add the thisType memberFunction to the table */ \ + baseType::add##memberFunction##argNames##MemberFunctionToTable > \ + add##thisType##Targ##memberFunction##argNames##MemberFunctionTo##baseType##Targ##Table_ + + +// add to hash-table of functions with 'lookup' as the key +// use when baseType requires the Targ template argument as well +#define addNamedTemplatedToMemberFunctionSelectionTable\ +(baseType,thisType,Targ,memberFunction,argNames,lookup) \ + \ + /* Add the thisType memberFunction to the table, find by lookup name */ \ + baseType::add##memberFunction##argNames##MemberFunctionToTable > \ + add_##lookup##_##thisType##Targ##memberFunction##argNames##MemberFunctionTo##baseType##Targ##Table_(#lookup) + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/src/OpenFOAM/db/memberFunctionSelection/memberFunctionSelectionTables.H b/src/OpenFOAM/db/memberFunctionSelection/memberFunctionSelectionTables.H index b91e0fd682..851092375c 100644 --- a/src/OpenFOAM/db/memberFunctionSelection/memberFunctionSelectionTables.H +++ b/src/OpenFOAM/db/memberFunctionSelection/memberFunctionSelectionTables.H @@ -39,6 +39,10 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// external use: +// ~~~~~~~~~~~~~ +// declare a run-time selection: #define declareMemberFunctionSelectionTable\ (returnType,baseType,memberFunction,argNames,argList,parList) \ \ @@ -86,6 +90,8 @@ Description static void destroy##memberFunction##argNames##MemberFunctionTables() +// internal use: +// constructor aid #define defineMemberFunctionSelectionTableMemberFunction\ (baseType,memberFunction,argNames) \ \ @@ -103,6 +109,9 @@ Description } \ } + +// internal use: +// destructor aid #define defineMemberFunctionSelectionTableDestructor\ (baseType,memberFunction,argNames) \ \ @@ -116,6 +125,9 @@ Description } \ } + +// internal use: +// create pointer to hash-table of functions #define defineMemberFunctionSelectionTablePtr\ (baseType,memberFunction,argNames) \ \ @@ -123,6 +135,8 @@ Description baseType::memberFunction##argNames##MemberFunctionTable* \ baseType::memberFunction##argNames##MemberFunctionTablePtr_ = NULL + +// not much in use: #define defineTemplateMemberFunctionSelectionTablePtr\ (baseType,memberFunction,argNames) \ \ @@ -130,7 +144,14 @@ Description typename baseType::memberFunction##argNames##MemberFunctionTable* \ baseType::memberFunction##argNames##MemberFunctionTablePtr_ = NULL -#define defineMemberFunctionSelectionTable(baseType,memberFunction,argNames) \ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// external use: +// ~~~~~~~~~~~~~ +// define run-time selection table +#define defineMemberFunctionSelectionTable\ +(baseType,memberFunction,argNames) \ \ defineMemberFunctionSelectionTablePtr \ (baseType,memberFunction,argNames); \ @@ -139,6 +160,11 @@ Description defineMemberFunctionSelectionTableDestructor \ (baseType,memberFunction,argNames) + +// external use: +// ~~~~~~~~~~~~~ +// define run-time selection table for template classes +// use when baseType doesn't need a template argument (eg, is a typedef) #define defineTemplateMemberFunctionSelectionTable\ (baseType,memberFunction,argNames) \ \ @@ -155,6 +181,74 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// internal use: +// constructor aid +// use when baseType requires the Targ template argument +#define defineTemplatedMemberFunctionSelectionTableMemberFunction\ +(baseType,memberFunction,argNames,Targ) \ + \ + /* Table memberFunction called from the table add function */ \ + void baseType::construct##memberFunction##argNames##MemberFunctionTables()\ + { \ + static bool constructed = false; \ + \ + if (!constructed) \ + { \ + baseType::memberFunction##argNames##MemberFunctionTablePtr_ \ + = new baseType::memberFunction##argNames##MemberFunctionTable;\ + \ + constructed = true; \ + } \ + } + + +// internal use: +// destructor aid +// use when baseType requires the Targ template argument +#define defineTemplatedMemberFunctionSelectionTableDestructor\ +(baseType,memberFunction,argNames,Targ) \ + \ + /* Table destructor called from the table add function destructor */ \ + void baseType::destroy##memberFunction##argNames##MemberFunctionTables() \ + { \ + if (baseType::memberFunction##argNames##MemberFunctionTablePtr_) \ + { \ + delete baseType::memberFunction##argNames##MemberFunctionTablePtr_;\ + baseType::memberFunction##argNames##MemberFunctionTablePtr_ = NULL;\ + } \ + } + + +// internal use: +// create pointer to hash-table of functions +// use when baseType requires the Targ template argument +#define defineTemplatedMemberFunctionSelectionTablePtr\ +(baseType,memberFunction,argNames,Targ) \ + \ + /* Define the memberFunction table */ \ + baseType::memberFunction##argNames##MemberFunctionTable* \ + baseType::memberFunction##argNames##MemberFunctionTablePtr_ = NULL + + +// external use: +// ~~~~~~~~~~~~~ +// define run-time selection table for template classes +// use when baseType requires the Targ template argument +#define defineTemplatedMemberFunctionSelectionTable\ +(baseType,memberFunction,argNames,Targ) \ + \ + template<> \ + defineTemplatedMemberFunctionSelectionTablePtr \ + (baseType,memberFunction,argNames,Targ); \ + template<> \ + defineTemplatedMemberFunctionSelectionTableMemberFunction \ + (baseType,memberFunction,argNames,Targ) \ + template<> \ + defineTemplatedMemberFunctionSelectionTableDestructor \ + (baseType,memberFunction,argNames,Targ) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* // diff --git a/src/OpenFOAM/db/runTimeSelection/addToRunTimeSelectionTable.H b/src/OpenFOAM/db/runTimeSelection/addToRunTimeSelectionTable.H index 78837835e5..5081883663 100644 --- a/src/OpenFOAM/db/runTimeSelection/addToRunTimeSelectionTable.H +++ b/src/OpenFOAM/db/runTimeSelection/addToRunTimeSelectionTable.H @@ -35,6 +35,8 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// add to hash-table of functions with typename as the key #define addToRunTimeSelectionTable\ (baseType,thisType,argNames) \ \ @@ -42,6 +44,8 @@ Description baseType::add##argNames##ConstructorToTable \ add##thisType##argNames##ConstructorTo##baseType##Table_ + +// add to hash-table of functions with 'lookup' as the key #define addNamedToRunTimeSelectionTable\ (baseType,thisType,argNames,lookup) \ \ @@ -49,6 +53,10 @@ Description baseType::add##argNames##ConstructorToTable \ add_##lookup##_##thisType##argNames##ConstructorTo##baseType##Table_(#lookup) +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// add to hash-table of functions with typename as the key // use when baseType doesn't need a template argument (eg, is a typedef) #define addTemplateToRunTimeSelectionTable\ (baseType,thisType,Targ,argNames) \ @@ -57,6 +65,8 @@ Description baseType::add##argNames##ConstructorToTable > \ add##thisType##Targ##argNames##ConstructorTo##baseType##Table_ + +// add to hash-table of functions with 'lookup' as the key // use when baseType doesn't need a template argument (eg, is a typedef) #define addNamedTemplateToRunTimeSelectionTable\ (baseType,thisType,Targ,argNames,lookup) \ @@ -65,6 +75,11 @@ Description baseType::add##argNames##ConstructorToTable > \ add_##lookup##_##thisType##Targ##argNames##ConstructorTo##baseType##Table_(#lookup) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// add to hash-table of functions with typename as the key // use when baseType requires the Targ template argument as well #define addTemplatedToRunTimeSelectionTable\ (baseType,thisType,Targ,argNames) \ @@ -73,6 +88,8 @@ Description baseType::add##argNames##ConstructorToTable > \ add##thisType##Targ##argNames##ConstructorTo##baseType##Targ##Table_ + +// add to hash-table of functions with 'lookup' as the key // use when baseType requires the Targ template argument as well #define addNamedTemplatedToRunTimeSelectionTable\ (baseType,thisType,Targ,argNames,lookup) \ @@ -81,6 +98,7 @@ Description baseType::add##argNames##ConstructorToTable > \ add_##lookup##_##thisType##Targ##argNames##ConstructorTo##baseType##Targ##Table_(#lookup) + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/src/OpenFOAM/db/runTimeSelection/runTimeSelectionTables.H b/src/OpenFOAM/db/runTimeSelection/runTimeSelectionTables.H index f2bad6ae83..45174dd82a 100644 --- a/src/OpenFOAM/db/runTimeSelection/runTimeSelectionTables.H +++ b/src/OpenFOAM/db/runTimeSelection/runTimeSelectionTables.H @@ -40,6 +40,10 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// external use: +// ~~~~~~~~~~~~~ +// declare a run-time selection: #define declareRunTimeSelectionTable\ (autoPtr,baseType,argNames,argList,parList) \ \ @@ -86,7 +90,10 @@ Description static void destroy##argNames##ConstructorTables() -#define defineRunTimeSelectionTableConstructor(baseType,argNames) \ +// internal use: +// constructor aid +#define defineRunTimeSelectionTableConstructor\ +(baseType,argNames) \ \ /* Table constructor called from the table add function */ \ void baseType::construct##argNames##ConstructorTables() \ @@ -102,7 +109,11 @@ Description } \ } -#define defineRunTimeSelectionTableDestructor(baseType,argNames) \ + +// internal use: +// destructor aid +#define defineRunTimeSelectionTableDestructor\ +(baseType,argNames) \ \ /* Table destructor called from the table add function destructor */ \ void baseType::destroy##argNames##ConstructorTables() \ @@ -114,24 +125,43 @@ Description } \ } -#define defineRunTimeSelectionTablePtr(baseType,argNames) \ + +// internal use: +// create pointer to hash-table of functions +#define defineRunTimeSelectionTablePtr\ +(baseType,argNames) \ \ /* Define the constructor function table */ \ baseType::argNames##ConstructorTable* \ baseType::argNames##ConstructorTablePtr_ = NULL + +// not much in use: #define defineTemplateRunTimeSelectionTablePtr(baseType,argNames) \ \ /* Define the constructor function table */ \ typename baseType::argNames##ConstructorTable* \ baseType::argNames##ConstructorTablePtr_ = NULL -#define defineRunTimeSelectionTable(baseType,argNames) \ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// external use: +// ~~~~~~~~~~~~~ +// define run-time selection table +#define defineRunTimeSelectionTable\ +(baseType,argNames) \ \ defineRunTimeSelectionTablePtr(baseType,argNames); \ defineRunTimeSelectionTableConstructor(baseType,argNames) \ defineRunTimeSelectionTableDestructor(baseType,argNames) + +// external use: +// ~~~~~~~~~~~~~ +// define run-time selection table for template classes +// use when baseType doesn't need a template argument (eg, is a typedef) #define defineTemplateRunTimeSelectionTable(baseType,argNames) \ \ template<> \ @@ -142,6 +172,73 @@ Description defineRunTimeSelectionTableDestructor(baseType,argNames) +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// internal use: +// constructor aid +// use when baseType requires the Targ template argument +#define defineTemplatedRunTimeSelectionTableConstructor\ +(baseType,argNames,Targ) \ + \ + /* Table constructor called from the table add function */ \ + void baseType::construct##argNames##ConstructorTables() \ + { \ + static bool constructed = false; \ + \ + if (!constructed) \ + { \ + baseType::argNames##ConstructorTablePtr_ \ + = new baseType::argNames##ConstructorTable; \ + \ + constructed = true; \ + } \ + } + + +// internal use: +// destructor aid +// use when baseType requires the Targ template argument +#define defineTemplatedRunTimeSelectionTableDestructor\ +(baseType,argNames,Targ) \ + \ + /* Table destructor called from the table add function destructor */ \ + void baseType::destroy##argNames##ConstructorTables() \ + { \ + if (baseType::argNames##ConstructorTablePtr_) \ + { \ + delete baseType::argNames##ConstructorTablePtr_; \ + baseType::argNames##ConstructorTablePtr_ = NULL; \ + } \ + } + + +// internal use: +// create pointer to hash-table of functions +// use when baseType requires the Targ template argument +#define defineTemplatedRunTimeSelectionTablePtr\ +(baseType,argNames,Targ) \ + \ + /* Define the constructor function table */ \ + baseType::argNames##ConstructorTable* \ + baseType::argNames##ConstructorTablePtr_ = NULL + + +// external use: +// ~~~~~~~~~~~~~ +// define run-time selection table for template classes +// use when baseType requires the Targ template argument +#define defineTemplatedRunTimeSelectionTable\ +(baseType,argNames,Targ) \ + \ + template<> \ + defineTemplatedRunTimeSelectionTablePtr(baseType,argNames,Targ); \ + template<> \ + defineTemplatedRunTimeSelectionTableConstructor(baseType,argNames,Targ) \ + template<> \ + defineTemplatedRunTimeSelectionTableDestructor(baseType,argNames,Targ) + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/src/surfMesh/Make/files b/src/surfMesh/Make/files index def352062d..5273d67404 100644 --- a/src/surfMesh/Make/files +++ b/src/surfMesh/Make/files @@ -2,27 +2,24 @@ surfGroup/surfGroup.C surfGroup/surfGroupIOList.C surfPatchIdentifier/surfPatchIdentifier.C -keyedSurface/keyedSurface.C -keyedSurface/keyedSurfaceCleanup.C -keyedSurface/newKeyedSurface.C +MeshedSurface/MeshedSurfaces.C +UnsortedMeshedSurface/UnsortedMeshedSurfaces.C -meshedSurface/meshedSurface.C -meshedSurface/meshedSurfaceCleanup.C -meshedSurface/newMeshedSurface.C - -fileFormats = keyedSurface/fileFormats -$(fileFormats)/ac3d/AC3DfileFormat.C -$(fileFormats)/ftr/FTRfileFormat.C -$(fileFormats)/gts/GTSfileFormat.C -$(fileFormats)/nas/NASfileFormat.C -$(fileFormats)/obj/OBJfileFormat.C -$(fileFormats)/off/OFFfileFormat.C -$(fileFormats)/smesh/SMESHfileFormat.C -$(fileFormats)/starcd/STARCDfileFormat.C -$(fileFormats)/stl/STLfileFormat.C -$(fileFormats)/stl/STLfileFormatASCII.L -$(fileFormats)/tri/TRIfileFormat.C -$(fileFormats)/vtk/VTKfileFormat.C +surfaceFormats = surfaceFormats +$(surfaceFormats)/surfaceFormatsCore.C +$(surfaceFormats)/ac3d/AC3DsurfaceFormatRunTime.C +$(surfaceFormats)/ftr/FTRsurfaceFormatRunTime.C +$(surfaceFormats)/gts/GTSsurfaceFormatRunTime.C +$(surfaceFormats)/nas/NASsurfaceFormatRunTime.C +$(surfaceFormats)/obj/OBJsurfaceFormatRunTime.C +$(surfaceFormats)/off/OFFsurfaceFormatRunTime.C +$(surfaceFormats)/smesh/SMESHsurfaceFormatRunTime.C +$(surfaceFormats)/starcd/STARCDsurfaceFormatRunTime.C +$(surfaceFormats)/stl/STLsurfaceFormatRunTime.C +$(surfaceFormats)/stl/STLsurfaceFormatASCII.L +$(surfaceFormats)/stl/STLsurfaceFormatCore.C +$(surfaceFormats)/tri/TRIsurfaceFormatRunTime.C +$(surfaceFormats)/vtk/VTKsurfaceFormatRunTime.C LIB = $(FOAM_LIBBIN)/libsurfMesh diff --git a/src/surfMesh/meshedSurface/meshedSurface.C b/src/surfMesh/MeshedSurface/MeshedSurface.C similarity index 55% rename from src/surfMesh/meshedSurface/meshedSurface.C rename to src/surfMesh/MeshedSurface/MeshedSurface.C index ecb37996c9..f973379004 100644 --- a/src/surfMesh/meshedSurface/meshedSurface.C +++ b/src/surfMesh/MeshedSurface/MeshedSurface.C @@ -24,8 +24,8 @@ License \*---------------------------------------------------------------------------*/ -#include "meshedSurface.H" -#include "keyedSurface.H" +#include "MeshedSurface.H" +#include "UnsortedMeshedSurface.H" #include "demandDrivenData.H" #include "IFstream.H" #include "OFstream.H" @@ -41,280 +41,142 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -namespace Foam + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +template +Foam::fileName Foam::MeshedSurface::triSurfInstance(const Time& d) { - -defineTypeNameAndDebug(meshedSurface, 0); - -defineMemberFunctionSelectionTable -( - meshedSurface, - write, - fileExtension -); - -} - -// File extension for 'native' raw format -//! @cond localscope -const char * const nativeExt = "ofs"; -//! @endcond localscope - -// * * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * // - -Foam::fileName Foam::meshedSurface::triSurfInstance(const Time& d) -{ - fileName foamName(d.caseName() + "." + nativeExt); - - // Search back through the time directories list to find the time - // closest to and lower than current time - - instantList ts = d.times(); - label i; - - for (i=ts.size()-1; i>=0; i--) - { - if (ts[i].value() <= d.timeOutputValue()) - { - break; - } - } - - // Noting that the current directory has already been searched - // for mesh data, start searching from the previously stored time directory - - if (i>=0) - { - for (label j=i; j>=0; j--) - { - if (file(d.path()/ts[j].name()/typeName/foamName)) - { - if (debug) - { - Pout<< " meshedSurface::triSurfInstance(const Time& d)" - << "reading " << foamName - << " from " << ts[j].name()/typeName - << endl; - } - - return ts[j].name(); - } - } - } - - if (debug) - { - Pout<< " meshedSurface::triSurfInstance(const Time& d)" - << "reading " << foamName - << " from constant/" << endl; - } - - return "constant"; + return triSurfInstance(d, typeName); } -Foam::fileName Foam::meshedSurface::triSurfName(const Time& d) +template +Foam::fileName Foam::MeshedSurface::triSurfName(const Time& d) { - fileName foamName(d.caseName() + "." + nativeExt); - - // Search back through the time directories list to find the time - // closest to and lower than current time - - instantList ts = d.times(); - label i; - - for (i=ts.size()-1; i>=0; i--) - { - if (ts[i].value() <= d.timeOutputValue()) - { - break; - } - } - - // Noting that the current directory has already been searched - // for mesh data, start searching from the previously stored time directory - - if (i>=0) - { - for (label j=i; j>=0; j--) - { - fileName testName(d.path()/ts[j].name()/typeName/foamName); - - if (file(testName)) - { - if (debug) - { - Pout<< " meshedSurface::triSurfName(const Time& d)" - << "reading " << foamName - << " from " << ts[j].name()/typeName - << endl; - } - - return testName; - } - } - } - - if (debug) - { - Pout<< " meshedSurface::triSurfName(const Time& d)" - << "reading " << foamName - << " from constant/" << endl; - } - - return d.path()/"constant"/typeName/foamName; + return triSurfName(d, typeName); } - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::meshedSurface::onePatch() +template +bool Foam::MeshedSurface::canRead(const word& ext, const bool verbose) { - // set single default patch - patches_.setSize(1); - patches_[0] = surfGroup - ( - "patch0", - size(), // patch size - 0, // patch start - 0 // patch index - ); + // handle 'native' format directly + if (isNative(ext)) + { + return true; + } + + return UnsortedMeshedSurface::canRead(ext, verbose); } -void Foam::meshedSurface::checkPatches() +template +bool Foam::MeshedSurface::canWrite(const word& ext, const bool verbose) { - // extra safety, ensure we have at some patches, - // and they cover all the faces - // fix start silently - if (patches_.size() > 1) - { - label count = 0; - forAll(patches_, patchI) - { - patches_[patchI].start() = count; - count += patches_[patchI].size(); - } + // perhaps sent an entire name + word fExt(ext); - if (count < size()) + string::size_type dot = ext.find_last_of("."); + if (dot != string::npos) + { + fExt = ext.substr(dot+1); + } + + // handle 'native' format directly + if (isNative(fExt)) + { + return true; + } + + typename writefileExtensionMemberFunctionTable::iterator mfIter = + writefileExtensionMemberFunctionTablePtr_->find(fExt); + + if (mfIter == writefileExtensionMemberFunctionTablePtr_->end()) + { + if (verbose) { - WarningIn + SortableList known ( - "meshedSurface::checkPatches()\n" - ) - << "more nFaces " << size() - << " than patches " << count - << " ... extending final patch" - << endl; + writefileExtensionMemberFunctionTablePtr_->toc() + ); - patches_[patches_.size()-1].size() += count - size(); - } - else if (count > size()) - { - FatalErrorIn - ( - "meshedSurface::checkPatches()\n" - ) - << "more patches " << count - << " than nFaces " << size() - << exit(FatalError); + Info<<"Unknown file extension for writing: " << fExt << nl; + // compact output: + Info<<"Valid types: ( " << nativeExt; + forAll(known, i) + { + Info<<" " << known[i]; + } + Info<<" )" << endl; } + + return false; } - else if (patches_.size() == 1) - { - // like onePatch, but preserve the name - patches_[0].start() = 0; - patches_[0].size() = size(); - if (!patches_[0].name().size()) - { - patches_[0].name() = "patch0"; - } - } - else - { - onePatch(); - } + + return true; } -void Foam::meshedSurface::sortFacesByRegion +template +void Foam::MeshedSurface::write ( - const List