mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -396,7 +396,7 @@ meshQualityControls
|
||||
// Flags for optional output
|
||||
// 0 : only write final meshes
|
||||
// 1 : write intermediate meshes
|
||||
// 2 : write volScalarField with cellLevel for postprocessing
|
||||
// 2 : write volScalarFields with cellLevel and cell centres for postprocessing
|
||||
// 4 : write current intersections as .obj files
|
||||
debug 0;
|
||||
|
||||
|
||||
@ -25,25 +25,32 @@ Application
|
||||
singleCellMesh
|
||||
|
||||
Description
|
||||
Removes all but one cells of the mesh. Used to generate mesh and fields
|
||||
Reads all fields and maps them to a mesh with all internal faces removed
|
||||
(singleCellFvMesh) which gets written to region "singleCell".
|
||||
|
||||
Used to generate mesh and fields
|
||||
that can be used for boundary-only data.
|
||||
Might easily result in illegal mesh though so only look at boundaries
|
||||
in paraview.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "argList.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "Time.H"
|
||||
#include "ReadFields.H"
|
||||
#include "singleCellFvMesh.H"
|
||||
#include "timeSelector.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Name of region to create
|
||||
const string singleCellName = "singleCell";
|
||||
|
||||
|
||||
template<class GeoField>
|
||||
void interpolateFields
|
||||
(
|
||||
@ -65,19 +72,82 @@ void interpolateFields
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# include "addOverwriteOption.H"
|
||||
# include "addTimeOptions.H"
|
||||
// constant, not false
|
||||
timeSelector::addOptions(true, false);
|
||||
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
// Get times list
|
||||
instantList Times = runTime.times();
|
||||
# include "checkTimeOptions.H"
|
||||
runTime.setTime(Times[startTime], startTime);
|
||||
# include "createMesh.H"
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
const bool overwrite = args.optionFound("overwrite");
|
||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||
|
||||
# include "createNamedMesh.H"
|
||||
|
||||
if (regionName == singleCellName)
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Cannot convert region " << singleCellName
|
||||
<< " since result would overwrite it. Please rename your region."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Create the mesh
|
||||
Info<< "Creating singleCell mesh" << nl << endl;
|
||||
autoPtr<singleCellFvMesh> scMesh
|
||||
(
|
||||
new singleCellFvMesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
singleCellName,
|
||||
mesh.polyMesh::instance(),
|
||||
runTime,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
)
|
||||
);
|
||||
// For convenience create any fv* files
|
||||
if (!exists(scMesh().fvSolution::objectPath()))
|
||||
{
|
||||
mkDir(scMesh().fvSolution::path());
|
||||
ln("../fvSolution", scMesh().fvSolution::objectPath());
|
||||
}
|
||||
if (!exists(scMesh().fvSchemes::objectPath()))
|
||||
{
|
||||
mkDir(scMesh().fvSolution::path());
|
||||
ln("../fvSchemes", scMesh().fvSchemes::objectPath());
|
||||
}
|
||||
|
||||
|
||||
forAll(timeDirs, timeI)
|
||||
{
|
||||
runTime.setTime(timeDirs[timeI], timeI);
|
||||
|
||||
Info<< nl << "Time = " << runTime.timeName() << endl;
|
||||
|
||||
|
||||
// Check for new mesh
|
||||
if (mesh.readUpdate() != polyMesh::UNCHANGED)
|
||||
{
|
||||
Info<< "Detected changed mesh. Recreating singleCell mesh." << endl;
|
||||
scMesh.clear(); // remove any registered objects
|
||||
scMesh.reset
|
||||
(
|
||||
new singleCellFvMesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
singleCellName,
|
||||
mesh.polyMesh::instance(),
|
||||
runTime,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Read objects in time directory
|
||||
@ -99,38 +169,18 @@ int main(int argc, char *argv[])
|
||||
PtrList<volTensorField> vtFlds;
|
||||
ReadFields(mesh, objects, vtFlds);
|
||||
|
||||
|
||||
if (!overwrite)
|
||||
{
|
||||
runTime++;
|
||||
}
|
||||
|
||||
// Create the mesh
|
||||
singleCellFvMesh scMesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
mesh.name(),
|
||||
mesh.polyMesh::instance(),
|
||||
runTime,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
);
|
||||
|
||||
|
||||
// Map and store the fields on the scMesh.
|
||||
interpolateFields(scMesh, vsFlds);
|
||||
interpolateFields(scMesh, vvFlds);
|
||||
interpolateFields(scMesh, vstFlds);
|
||||
interpolateFields(scMesh, vsymtFlds);
|
||||
interpolateFields(scMesh, vtFlds);
|
||||
interpolateFields(scMesh(), vsFlds);
|
||||
interpolateFields(scMesh(), vvFlds);
|
||||
interpolateFields(scMesh(), vstFlds);
|
||||
interpolateFields(scMesh(), vsymtFlds);
|
||||
interpolateFields(scMesh(), vtFlds);
|
||||
|
||||
|
||||
// Write
|
||||
Info<< "Writing mesh to time " << runTime.timeName() << endl;
|
||||
scMesh.write();
|
||||
scMesh().write();
|
||||
}
|
||||
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
@ -864,7 +864,7 @@ bool Foam::ln(const fileName& src, const fileName& dst)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!exists(src))
|
||||
if (src.isAbsolute() && !exists(src))
|
||||
{
|
||||
WarningIn("ln(const fileName&, const fileName&)")
|
||||
<< "source " << src << " does not exist." << endl;
|
||||
|
||||
@ -112,6 +112,9 @@ public:
|
||||
//- Assignment from UList of addressed elements
|
||||
inline void operator=(const UList<T>&);
|
||||
|
||||
//- Assignment from UIndirectList of addressed elements
|
||||
inline void operator=(const UIndirectList<T>&);
|
||||
|
||||
//- Assignment of all entries to the given value
|
||||
inline void operator=(const T&);
|
||||
|
||||
|
||||
@ -144,6 +144,25 @@ inline void Foam::UIndirectList<T>::operator=(const UList<T>& ae)
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::UIndirectList<T>::operator=(const UIndirectList<T>& ae)
|
||||
{
|
||||
if (addressing_.size() != ae.size())
|
||||
{
|
||||
FatalErrorIn("UIndirectList<T>::operator=(const UIndirectList<T>&)")
|
||||
<< "Addressing and list of addressed elements "
|
||||
"have different sizes: "
|
||||
<< addressing_.size() << " " << ae.size()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
forAll(addressing_, i)
|
||||
{
|
||||
completeList_[addressing_[i]] = ae[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::UIndirectList<T>::operator=(const T& t)
|
||||
{
|
||||
|
||||
@ -2200,6 +2200,7 @@ void Foam::meshRefinement::dumpRefinementLevel() const
|
||||
{
|
||||
// Note: use time().timeName(), not meshRefinement::timeName()
|
||||
// so as to dump the fields to 0, not to constant.
|
||||
{
|
||||
volScalarField volRefLevel
|
||||
(
|
||||
IOobject
|
||||
@ -2224,8 +2225,10 @@ void Foam::meshRefinement::dumpRefinementLevel() const
|
||||
}
|
||||
|
||||
volRefLevel.write();
|
||||
}
|
||||
|
||||
|
||||
// Dump pointLevel
|
||||
{
|
||||
const pointMesh& pMesh = pointMesh::New(mesh_);
|
||||
|
||||
pointScalarField pointRefLevel
|
||||
@ -2251,6 +2254,29 @@ void Foam::meshRefinement::dumpRefinementLevel() const
|
||||
}
|
||||
|
||||
pointRefLevel.write();
|
||||
}
|
||||
|
||||
// Dump cell centres
|
||||
{
|
||||
for (direction i=0; i<vector::nComponents; i++)
|
||||
{
|
||||
volScalarField cci
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"cc" + word(vector::componentNames[i]),
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
mesh_.C().component(i)
|
||||
);
|
||||
|
||||
cci.write();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user