Commit e23999e5 authored by mattijs's avatar mattijs
Browse files

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

parents 404aa759 4af3d6cb
......@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
#include "createTime.H"
#include "createDynamicFvMesh.H"
#include "initContinuityErrs.H"
#include "createControl.H"
pimpleControl pimple(mesh);
#include "createTimeControls.H"
#include "createDyMControls.H"
#include "createFields.H"
......
......@@ -46,6 +46,13 @@
phiHbyA += phig;
if (adjustFringe)
{
fvc::makeRelative(phiHbyA, U);
oversetAdjustPhi(phiHbyA, U);
fvc::makeAbsolute(phiHbyA, U);
}
// Update the pressure BCs to ensure flux consistency
constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF);
......@@ -72,7 +79,8 @@
"minGradP",
fvc::reconstruct((phig - p_rghEqn.flux())/rAUf)
);
U = HbyA + rAU*cellMask*minGradP;
//U = HbyA + rAU*cellMask*minGradP;
U = fvc::reconstruct(phi);
U.correctBoundaryConditions();
fvOptions.correct(U);
}
......
......@@ -11,5 +11,6 @@ moveMeshOuterCorrectors =
massFluxInterpolation =
pimple.dict().lookupOrDefault("massFluxInterpolation", false);
ddtCorr =
pimple.dict().lookupOrDefault("ddtCorr", true);
\ No newline at end of file
ddtCorr = pimple.dict().lookupOrDefault("ddtCorr", true);
adjustFringe = pimple.dict().lookupOrDefault("oversetAdjustPhi", false);
......@@ -41,10 +41,15 @@ using namespace Foam;
autoPtr<triSurface> loadSurface
(
const Foam::Time& runTime,
const fileName& surfName
const fileName& surfName,
const scalar scaleFactor
)
{
Info<< "Reading surface " << surfName << endl;
Info<< "Reading surface " << surfName << nl;
if (scaleFactor > 0)
{
Info<<"Scaling : " << scaleFactor << nl;
}
const fileName fallback =
runTime.constantPath()/triSurfaceMesh::meshSubDir/surfName;
......@@ -52,11 +57,11 @@ autoPtr<triSurface> loadSurface
autoPtr<triSurface> surfPtr;
if (isFile(surfName))
{
surfPtr.set(new triSurface(surfName));
surfPtr.set(new triSurface(surfName, scaleFactor));
}
else if (isFile(fallback))
{
surfPtr.set(new triSurface(fallback));
surfPtr.set(new triSurface(fallback, scaleFactor));
}
else
{
......@@ -102,6 +107,12 @@ int main(int argc, char *argv[])
"mergeTol",
"merge points (and edges) using the specified tolerance"
);
argList::addOption
(
"scale",
"factor",
"geometry scaling factor"
);
#include "addDictOption.H"
......@@ -117,16 +128,18 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
#include "createTime.H"
const scalar scaleFactor = args.optionLookupOrDefault<scalar>("scale", -1);
const word outputFile(args.executable() + ".obj");
const fileName surf1Name(args[1]);
triSurface surf1 = loadSurface(runTime, surf1Name)();
triSurface surf1 = loadSurface(runTime, surf1Name, scaleFactor)();
Info<< surf1Name << " statistics:" << endl;
surf1.writeStats(Info);
Info<< endl;
const fileName surf2Name(args[2]);
triSurface surf2 = loadSurface(runTime, surf2Name)();
triSurface surf2 = loadSurface(runTime, surf2Name, scaleFactor)();
Info<< surf2Name << " statistics:" << endl;
surf2.writeStats(Info);
Info<< endl;
......
Test-surfaceMeshConvert.C
EXE = $(FOAM_APPBIN)/Test-surfaceMeshConvert
......@@ -22,17 +22,16 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
surfaceMeshConvertTesting
Test-surfaceMeshConvert
Group
grpSurfaceUtilities
Description
Converts from one surface mesh format to another, but primarily
used for testing functionality.
Test conversions from one surface mesh format to another.
Usage
\b surfaceMeshConvertTesting inputFile outputFile [OPTION]
\b Test-surfaceMeshConvert inputFile outputFile [OPTION]
Options:
- \par -clean
......
......@@ -91,7 +91,7 @@ int main(int argc, char *argv[])
// ~~~~~~~~~~~~~~~~~~~~~
fileFormats::FIREMeshWriter::binary = !args.optionFound("ascii");
// default: rescale from [m] to [mm]
// Default: no rescaling
scalar scaleFactor = 1;
if (args.optionReadIfPresent("scale", scaleFactor))
{
......
......@@ -43,8 +43,8 @@ Usage
or -yawPitchRoll (yawdegrees pitchdegrees rolldegrees)
or -rollPitchYaw (rolldegrees pitchdegrees yawdegrees)
-scale vector
Scales the points by the given vector.
-scale scalar|vector
Scales the points by the given scalar or vector.
The any or all of the three options may be specified and are processed
in the above order.
......@@ -182,9 +182,9 @@ int main(int argc, char *argv[])
argList::addOption
(
"scale",
"vector",
"scale by the specified amount - eg, '(0.001 0.001 0.001)' for a "
"uniform [mm] to [m] scaling"
"scalar | vector",
"scale by the specified amount - eg, for a uniform [mm] to [m] scaling "
"use either (0.001 0.001 0.001)' or simply '0.001'"
);
#include "addRegionOption.H"
......@@ -262,10 +262,10 @@ int main(int argc, char *argv[])
<< " pitch " << v.y() << nl
<< " yaw " << v.z() << nl;
// Convert to radians
// degToRad
v *= pi/180.0;
quaternion R(quaternion::rotationSequence::XYZ, v);
const quaternion R(quaternion::rotationSequence::XYZ, v);
Info<< "Rotating points by quaternion " << R << endl;
points = transform(R, points);
......@@ -282,16 +282,10 @@ int main(int argc, char *argv[])
<< " pitch " << v.y() << nl
<< " roll " << v.z() << nl;
// Convert to radians
// degToRad
v *= pi/180.0;
scalar yaw = v.x();
scalar pitch = v.y();
scalar roll = v.z();
quaternion R = quaternion(vector(0, 0, 1), yaw);
R *= quaternion(vector(0, 1, 0), pitch);
R *= quaternion(vector(1, 0, 0), roll);
const quaternion R(quaternion::rotationSequence::ZYX, v);
Info<< "Rotating points by quaternion " << R << endl;
points = transform(R, points);
......@@ -302,13 +296,34 @@ int main(int argc, char *argv[])
}
}
if (args.optionReadIfPresent("scale", v))
if (args.optionFound("scale"))
{
Info<< "Scaling points by " << v << endl;
// Use readList to handle single or multiple values
const List<scalar> scaling = args.optionReadList<scalar>("scale");
points.replace(vector::X, v.x()*points.component(vector::X));
points.replace(vector::Y, v.y()*points.component(vector::Y));
points.replace(vector::Z, v.z()*points.component(vector::Z));
if (scaling.size() == 1)
{
Info<< "Scaling points uniformly by " << scaling[0] << nl;
points *= scaling[0];
}
else if (scaling.size() == 3)
{
Info<< "Scaling points by ("
<< scaling[0] << " "
<< scaling[1] << " "
<< scaling[2] << ")" << nl;
points.replace(vector::X, scaling[0]*points.component(vector::X));
points.replace(vector::Y, scaling[1]*points.component(vector::Y));
points.replace(vector::Z, scaling[2]*points.component(vector::Z));
}
else
{
FatalError
<< "-scale with 1 or 3 components only" << nl
<< "given: " << args["scale"] << endl
<< exit(FatalError);
}
}
// Set the precision of the points data to 10
......
......@@ -160,13 +160,59 @@ public:
const std::string& datasetName
);
//- Add names to array selection
template<class StringType>
static label addToArray
(
vtkDataArraySelection* select,
const std::string& prefix,
const UList<StringType>& names
);
//- Add names to array selection
template<class StringType>
static label addToArray
(
vtkDataArraySelection* select,
const UList<StringType>& names,
const std::string& suffix = string::null
);
//- Add objects of Type to array selection
template<class Type>
static label addToSelection
(
vtkDataArraySelection* select,
const std::string& prefix,
const IOobjectList& objects
);
//- Add objects of Type to array selection
template<class Type>
static label addToSelection
(
vtkDataArraySelection* select,
const IOobjectList& objects,
const std::string& prefix = string::null
const std::string& suffix = string::null
);
//- Add objects of Type to array selection
template<class Type>
static label addToSelection
(
vtkDataArraySelection* select,
const std::string& prefix,
const HashTable<wordHashSet>& objects
);
//- Add objects of Type to array selection
template<class Type>
static label addToSelection
(
vtkDataArraySelection* select,
const HashTable<wordHashSet>& objects,
const std::string& suffix = string::null
);
......
......@@ -28,25 +28,53 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
Foam::label Foam::foamPvCore::addToSelection
template<class StringType>
Foam::label Foam::foamPvCore::addToArray
(
vtkDataArraySelection *select,
const IOobjectList& objects,
const std::string& prefix
const std::string& prefix,
const UList<StringType>& names
)
{
const wordList names = objects.sortedNames(Type::typeName);
if (prefix.empty())
{
for (const auto& name : names)
{
select->AddArray(name.c_str());
}
}
else
{
for (const auto& name : names)
{
select->AddArray((prefix + name).c_str());
}
}
return names.size();
}
forAll(names, i)
template<class StringType>
Foam::label Foam::foamPvCore::addToArray
(
vtkDataArraySelection *select,
const UList<StringType>& names,
const std::string& suffix
)
{
if (suffix.empty())
{
if (prefix.empty())
for (const auto& name : names)
{
select->AddArray(names[i].c_str());
select->AddArray(name.c_str());
}
else
}
else
{
for (const auto& name : names)
{
select->AddArray((prefix + names[i]).c_str());
select->AddArray((name + suffix).c_str());
}
}
......@@ -54,6 +82,68 @@ Foam::label Foam::foamPvCore::addToSelection
}
template<class Type>
Foam::label Foam::foamPvCore::addToSelection
(
vtkDataArraySelection *select,
const std::string& prefix,
const IOobjectList& objects
)
{
return addToArray(select, prefix, objects.sortedNames(Type::typeName));
}
template<class Type>
Foam::label Foam::foamPvCore::addToSelection
(
vtkDataArraySelection *select,
const IOobjectList& objects,
const std::string& suffix
)
{
return addToArray(select, objects.sortedNames(Type::typeName), suffix);
}
template<class Type>
Foam::label Foam::foamPvCore::addToSelection
(
vtkDataArraySelection *select,
const std::string& prefix,
const HashTable<wordHashSet>& objects
)
{
auto iter = objects.cfind(Type::typeName);
if (iter.found())
{
return addToArray(select, prefix, iter.object().sortedToc());
}
return 0;
}
template<class Type>
Foam::label Foam::foamPvCore::addToSelection
(
vtkDataArraySelection *select,
const HashTable<wordHashSet>& objects,
const std::string& suffix
)
{
auto iter = objects.cfind(Type::typeName);
if (iter.found())
{
return addToArray(select, iter.object().sortedToc(), suffix);
}
return 0;
}
template<class AnyValue, class AnyHasher>
void Foam::foamPvCore::setSelectedArrayEntries
(
......
......@@ -155,7 +155,10 @@ class vtkPVFoam
vtkSmartPointer<dataType> getCopy() const
{
auto copy = vtkSmartPointer<dataType>::New();
copy->ShallowCopy(vtkgeom);
if (vtkgeom)
{
copy->ShallowCopy(vtkgeom);
}
return copy;
}
......@@ -163,7 +166,10 @@ class vtkPVFoam
void reuse()
{
dataset = vtkSmartPointer<dataType>::New();
dataset->ShallowCopy(vtkgeom);
if (vtkgeom)
{
dataset->ShallowCopy(vtkgeom);
}
}
//- Set the geometry and make a shallow copy to dataset
......
......@@ -85,11 +85,11 @@ Foam::wordList Foam::vtkPVFoam::getZoneNames
wordList names(zmesh.size());
label nZone = 0;
forAll(zmesh, zonei)
for (const auto& zn : zmesh)
{
if (!zmesh[zonei].empty())
if (!zn.empty())
{
names[nZone++] = zmesh[zonei].name();
names[nZone++] = zn.name();
}
}
names.setSize(nZone);
......@@ -100,8 +100,6 @@ Foam::wordList Foam::vtkPVFoam::getZoneNames
Foam::wordList Foam::vtkPVFoam::getZoneNames(const word& zoneType) const
{
wordList names;
// mesh not loaded - read from file
IOobject ioObj
(
......@@ -119,14 +117,17 @@ Foam::wordList Foam::vtkPVFoam::getZoneNames(const word& zoneType) const
false
);
wordList names;
if (ioObj.typeHeaderOk<cellZoneMesh>(false, false))
{
zonesEntries zones(ioObj);
names.setSize(zones.size());
forAll(zones, zonei)
label nZone = 0;
for (const auto& zn : zones)
{
names[zonei] = zones[zonei].keyword();
names[nZone++] = zn.keyword();
}
}
......@@ -167,7 +168,7 @@ void Foam::vtkPVFoam::updateInfoLagrangian
<< " " << dbPtr_->timePath()/cloud::prefix << endl;
}
// use the db directly since this might be called without a mesh,
// Use the db directly since this might be called without a mesh,
// but the region must get added back in
fileName lagrangianPrefix(cloud::prefix);
if (meshRegion_ != polyMesh::defaultRegion)
......@@ -175,23 +176,24 @@ void Foam::vtkPVFoam::updateInfoLagrangian
lagrangianPrefix = meshRegion_/cloud::prefix;
}
// Search for list of lagrangian objects for this time
fileNameList cloudDirs
(
readDir(dbPtr_->timePath()/lagrangianPrefix, fileName::DIRECTORY)
);
// List of lagrangian objects across all times
HashSet<fileName> names;
rangeLagrangian_.reset(select->GetNumberOfArrays());
forAll(cloudDirs, cloudi)
for (const instant& t : dbPtr_().times())
{
// Add cloud to GUI list
select->AddArray
names.insert
(
("lagrangian/" + cloudDirs[cloudi]).c_str()
readDir
(
dbPtr_->path()/t.name()/lagrangianPrefix,
fileName::DIRECTORY
)
);
++rangeLagrangian_;
}
rangeLagrangian_.reset(select->GetNumberOfArrays());
rangeLagrangian_ += addToArray(select, "lagrangian/", names.sortedToc());
if (debug)
{
Info<< "<end> " << FUNCTION_NAME << endl;
......@@ -257,39 +259,26 @@ void Foam::vtkPVFoam::updateInfoPatches
const polyPatch& pp = patches[patchId];
if (pp.size())
{
enabledEntries.insert
(
"patch/" + pp.name()
);
enabledEntries.insert("patch/" + pp.name());
}
}
}
}
// Sort group names
Foam::sort(displayNames);
for (const auto& name : displayNames)
{
select->AddArray(name.c_str());
++rangePatches_;
}
Foam::sort(displayNames); // Sorted group names
rangePatches_ += addToArray(select, displayNames);
// Add (non-zero) patches to the list of mesh parts
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (!reader_->GetShowGroupsOnly())
{
forAll(patches, patchi)
for (const polyPatch& pp : patches)
{