Commit 2d36cc97 authored by sergio's avatar sergio
Browse files

Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop

parents dbb8b04f d29a8afb
Test-faces.C
EXE = $(FOAM_USER_APPBIN)/Test-faces
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -21,54 +21,63 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
Test-faces
Description
Template to write generalized field components
Simple tests for various faces
\*---------------------------------------------------------------------------*/
#include "ensightParts.H"
#include "argList.H"
#include "labelledTri.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
template<class Type>
void Foam::ensightParts::writeField
(
ensightFile& os,
const GeometricField<Type, fvPatchField, volMesh>& field
) const
int main(int argc, char *argv[])
{
// find offset to patch parts (ie, the first face data)
label patchOffset = 0;
forAll(partsList_, partI)
face f1{ 1, 2, 3, 4 };
Info<< "face:" << f1 << nl;
triFace t1{ 1, 2, 3 };
Info<< "triFace:" << t1 << nl;
f1 = t1;
Info<< "face:" << f1 << nl;
f1 = t1.triFaceFace();
Info<< "face:" << f1 << nl;
// expect these to fail
FatalError.throwExceptions();
try
{
if (partsList_[partI].isFaceData())
{
patchOffset = partI;
break;
}
labelledTri l1{ 1, 2, 3, 10, 24 };
Info<< "labelled:" << l1 << nl;
}
forAll(partsList_, partI)
catch (Foam::error& err)
{
label patchi = partI - patchOffset;
if (partsList_[partI].isCellData())
{
partsList_[partI].writeField
(
os,
field
);
}
else if (patchi < field.boundaryField().size())
{
partsList_[partI].writeField
(
os,
field.boundaryField()[patchi]
);
}
WarningInFunction
<< "Caught FatalError " << err << nl << endl;
}
FatalError.dontThrowExceptions();
labelledTri l2{ 1, 2, 3 };
Info<< "labelled:" << l2 << nl;
labelledTri l3{ 1, 2, 3, 10 };
Info<< "labelled:" << l3 << nl;
t1.flip();
l3.flip();
Info<< "flip:" << t1 << nl;
Info<< "flip:" << l3 << nl;
return 0;
}
......
......@@ -34,6 +34,8 @@ Description
#include "labelList.H"
#include "DynamicList.H"
#include "face.H"
#include "pointField.H"
#include "DynamicField.H"
using namespace Foam;
......@@ -45,7 +47,10 @@ using namespace Foam;
int main(int argc, char *argv[])
{
List<label> lstA(10);
List<label> lstC(IStringStream("(1 2 3 4)")());
List<label> lstC
{
1, 2, 3, 4
};
forAll(lstA, i)
{
......@@ -128,6 +133,57 @@ int main(int argc, char *argv[])
Info<< "f1: " << f1 << endl;
Info<< "f3: " << f3 << endl;
{
Info<<"\nTest xfer with fields:" << endl;
List<point> list1
{
{ 0, 1, 2 },
{ 3, 4, 5 },
{ 6, 7, 8 },
{ 9, 10, 11 },
};
// Field from Xfer<List>
pointField field1(list1.xfer());
Info<<nl
<< "xfer construct from List" << nl
<<"input (list) = " << list1 << nl
<<"output (field) = " << field1 << nl;
// Field from Xfer<List> ... again
pointField field2(field1.xfer());
Info<<nl
<<"xfer construct from Field (as List): " << nl
<<"input (field) = " << field1 << nl
<<"output (field) = " << field2 << nl;
// Field from Xfer<Field>
pointField field3(xferMove(field2));
Info<<nl
<<"xfer construct from Field (as Field): " << nl
<<"input (field) = " << field2 << nl
<<"output (field) = " << field3 << nl;
// Field from Xfer<Field> .. again
pointField field4(xferCopy(field3));
Info<<nl
<<"xfer copy construct from Field (as Field): " << nl
<<"input (field) = " << field3 << nl
<<"output (field) = " << field4 << nl;
DynamicField<point> dyfield1(xferCopy(field4));
Info<<nl
<<"xfer copy construct from Field (as Field): " << nl
<<"input (field) = " << field4 << nl
<<"output (dyn-field) = " << dyfield1 << nl;
}
return 0;
}
......
......@@ -6,6 +6,7 @@ cd ${0%/*} || exit 1 # Run from this directory
# Parse arguments for compilation (at least for error catching)
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
# Get version info and arch-path
. $WM_PROJECT_DIR/etc/config.sh/functions
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio)
......
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Parse arguments for library compilation
# Parse arguments for compilation (at least for error catching)
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
# get METIS_VERSION, METIS_ARCH_PATH
if settings=`$WM_PROJECT_DIR/bin/foamEtcFile config.sh/metis`
# Only build if libraries already exist
if [ -e $FOAM_LIBBIN/libccm.so ]
then
. $settings
echo "using METIS_ARCH_PATH=$METIS_ARCH_PATH"
if [ -r $METIS_ARCH_PATH/lib/libmetis.so ]
then
wmake $targetType
fi
echo "Building optional ccm conversion components."
wmake $targetType ccmToFoam
wmake $targetType foamToCcm
else
echo
echo "Error: no config.sh/metis settings"
echo
echo "Skipping optional ccm conversion components (no libccm.so)."
fi
#------------------------------------------------------------------------------
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/conversion/lnInclude \
-I$(LIB_SRC)/conversion/ccm/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lgenericPatchFields \
-lmeshTools \
-lconversion -lccm
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 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/>.
Application
ccmToFoam
Group
grpMeshConversionUtilities
Description
Reads CCM files as written by PROSTAR/STARCCM and writes an
OPENFOAM polyMesh.
Usage
\b ccmToFoam [OPTION] ccmMesh
Options:
- \par -ascii
Write in ASCII format instead of binary
- \par -export
re-export mesh in CCM format for post-processing
- \par -list
List some information about the geometry
- \par -name \<name\>
Provide alternative base name for export. Default is <tt>meshExport</tt>.
- \par -combine
Combine identically named patches
- \par -noBaffles
Remove any baffles by merging the faces.
- \par -merge
Merge in-place interfaces
- \par -numbered
Use numbered patch/zone (not names) directly from ccm ids.
- \par -remap \<name\>
use specified remapping dictionary instead of <tt>constant/remapping</tt>
- \par -scale \<factor\>
Specify an alternative geometry scaling factor.
The default is \b 1 (no scaling).
- \par -solids
Treat any solid cells present just like fluid cells.
The default is to remove them.
Note
- sub-domains (fluid | solid | porosity) are stored as separate domains
within the CCM file. These are merged together to form a single mesh.
- baffles are written as interfaces for later use
See also
Foam::ccm::reader for more information about the File Locations
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "ccm.H"
#include "regionSplit.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::addNote
(
"Reads CCM files as written by PROSTAR/STARCCM and writes an"
" OPENFOAM polyMesh."
);
argList::noParallel();
argList::validArgs.append("ccmMesh");
argList::addBoolOption
(
"ascii",
"write in ASCII format instead of binary"
);
argList::addBoolOption
(
"export",
"re-export mesh in CCM format for post-processing"
);
argList::addBoolOption
(
"list",
"list some information about the geometry"
);
argList::addOption
(
"remap",
"name",
"use specified remapping dictionary instead of <constant/remapping>"
);
argList::addOption
(
"name",
"name",
"provide alternative base name when re-exporting (implies -export). "
"Default is <meshExport>."
);
argList::addBoolOption
(
"combine",
"combine identically named patches"
);
argList::addBoolOption
(
"noBaffles",
"remove any baffles by merging the faces"
);
argList::addBoolOption
(
"merge",
"merge in-place interfaces"
);
argList::addBoolOption
(
"numbered",
"use numbered names (eg, patch_0, zone_0) only"
);
argList::addOption
(
"scale",
"scale",
"geometry scaling factor - default is 1 (ie, no scaling)"
);
argList::addBoolOption
(
"withSolid",
"treat any solid cells present just like fluid cells. "
"the default is to remove them."
);
argList args(argc, argv);
Time runTime(args.rootPath(), args.caseName());
runTime.functionObjects().off();
const bool optList = args.optionFound("list");
// exportName only has a size when export is in effect
fileName exportName;
if (args.optionReadIfPresent("name", exportName))
{
const word ext = exportName.ext();
// strip erroneous extension (.ccm, .ccmg, .ccmp)
if (ext == "ccm" || ext == "ccmg" || ext == "ccmp")
{
exportName = exportName.lessExt();
}
}
else if (args.optionFound("export"))
{
exportName = ccm::writer::defaultMeshName;
if (args.optionFound("case"))
{
exportName += '-' + args.globalCaseName();
}
}
// By default, no scaling
const scalar scaleFactor = args.optionLookupOrDefault("scale", 1.0);
// Default to binary output, unless otherwise specified
const IOstream::streamFormat format =
(
args.optionFound("ascii")
? IOstream::ASCII
: IOstream::BINARY
);
// Increase the precision of the points data
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
// Read control options
// ~~~~~~~~~~~~~~~~~~~~
ccm::reader::options rOpts;
rOpts.removeBaffles(args.optionFound("noBaffles"));
rOpts.mergeInterfaces(args.optionFound("merge"));
if (args.optionFound("numbered"))
{
rOpts.useNumberedNames(true);
}
else if (args.optionFound("combine"))
{
rOpts.combineBoundaries(true);
}
if (args.optionFound("solids"))
{
Info<< "treating solids like fluids" << endl;
rOpts.keepSolid(true);
}
else
{
rOpts.keepSolid(false);
}
// CCM reader for reading geometry/solution
ccm::reader reader(args[1], rOpts);
// list the geometry information
if (optList)
{
Info<< "mesh geometry information:" << endl;
if (reader.hasGeometry())
{
Info<< nl << "cellTable:" << reader.cellTableInfo()
<< nl << "boundaryRegion:" << reader.boundaryTableInfo()
<< nl << "interfaces:" << reader.interfaceDefinitionsInfo()
<< endl;
if
(
args.optionFound("remap")
? reader.remapMeshInfo(runTime, args["remap"])
: reader.remapMeshInfo(runTime)
)
{
Info<< nl
<< "Remapped cellTable:" << reader.cellTableInfo() << nl
<< "Remapped boundaryRegion:" << reader.boundaryTableInfo()
<< endl;
}
}
else
{
Info<< "NONE" << endl;
}
return 0;
}
else if (reader.readGeometry(scaleFactor))
{
autoPtr<polyMesh> mesh =
(
args.optionFound("remap")
? reader.mesh(runTime, args["remap"])
: reader.mesh(runTime)
);
// report mesh bounding box information
Info<< nl << "Bounding box size: " << mesh().bounds().span() << nl;
// check number of regions
regionSplit rs(mesh);
Info<< "Number of regions: " << rs.nRegions();
if (rs.nRegions() == 1)
{
Info<< " (OK)." << nl;
}
else
{
Info<< nl << nl
<< "**************************************************" << nl
<< "** WARNING: the mesh has disconnected regions **" << nl
<< "**************************************************" << nl;
}
Info<< endl;
reader.writeMesh(mesh, format);
// exportName only has a size when export is in effect
if (exportName.size())
{
const fileName geomName = exportName + ".ccmg";
Info<< nl << "Re-exporting geometry as " << geomName << nl;
ccm::writer(geomName, mesh).writeGeometry();
}
}
else
{
FatalErrorIn("ccmToFoam")
<< "could not read geometry"
<< exit(FatalError);
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/conversion/lnInclude \
-I$(LIB_SRC)/conversion/ccm/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lgenericPatchFields \
-lconversion -lccm
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 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/>.