Compare commits

...

10 Commits

Author SHA1 Message Date
7207e9e3a9 TUT: add a multi-region finite-area example tutorial 2025-10-12 17:00:17 +02:00
6d2deda470 ENH: revise some regionFaModel parameter naming (#3419)
- the old naming grew organically and was previously restricted
  by avoiding name collisions with volume fields, which resulted
  in some minor consistencies

Common solid shell naming:

  | Keyword  | Default     | Description  | Key(old) | Old Naming     |
  | -------- | ----------- | ------------ | -------- | -------------- |
  | h        | hs (suffix) | thickness    | h        | "h_" + region  |
  | T        | Ts (suffix) | temperature  | -        | "Ts_" + region |

Vibration shells:

  | Keyword  | Default     | Description  | Key(old) | Old Naming     |
  | -------- | ----------- | ------------ | -------- | -------------- |
  |  as      | as (suffix) | acceleration | -        | "as_" + region |
  |  ps      | ps (suffix) | pres on shell| -        | "ps_" + region |
  |  ws      | ws (suffix) | displacement | -        | "ws_" + region |
  |  qs      | qs (suffix  | source field | -        | "qs_" + region |

Other:

  | Keyword  | Default     | Description  | Key(old) |
  | -------- | ----------- | ------------ | -------- |
  | Tprimary | T   | temperature (volume) | T        |

Joule heating: (possibly breaking naming changes)

  | Field    | Name                     | Name(old)                |
  | -------- | ------------------------ | ------------------------ |
  |  V       | \<scope\>:V (suffix)     | \<scope\>:V + region     |
  |  sigma   | \<scope\>:sigma (suffix) | \<scope\>:sigma + region |
2025-10-12 15:54:05 +02:00
c172b588c0 ENH: multi-region finiteArea support [parallel] (#3419)
- redistributePar (partly working)
2025-10-12 15:54:05 +02:00
c075af4f7b ENH: redistributePar cleanup
- remove old dead code (without file-handlers)
- update coding style
2025-10-12 15:54:05 +02:00
a1e5dcee43 ENH: redistributePar cleanup
- update and extend loadOrCreateMesh coding
- support bitSet return values
- accept checks with name/instance/local in IOobject parameter order
2025-10-12 15:54:05 +02:00
f2922f1ae9 ENH: multi-region finiteArea support [parallel] (#3419)
- decomposePar, reconstructPar, reconstructParMesh
2025-10-12 15:54:05 +02:00
1ae48880d2 ENH: multi-region finiteArea support [post-processing] (#3419)
- foamToEnsight, foamToVTK
2025-10-12 15:54:05 +02:00
9fc52d42eb ENH: multi-region finiteArea support [pre-processing] (#3419)
- checkFaMesh, makeFaMesh, setFields
2025-10-12 15:54:05 +02:00
c669f7b736 ENH: provide general static singleton for the faMeshesRegistry objects 2025-10-12 15:54:05 +02:00
27878797e2 ENH: add support for name suffixing in faOption and regionFaModel (#3419)
- in earlier versions, when area fields and volume fields were stored
  together, an automatic suffix of '_' + regionName was appended to
  many of the finite-area fields. This was needed to prevent name
  clashes between 'T' (area) and 'T' (volume) field names.

  This is no longer necessary, but some existing setups may rely on
  the old naming convention. To make this more flexible while also
  minimizing the number of changes, introduced a "suffixing"
  keyword for faOption and regionFaModel.

  Can specify suffixing as "default" to recover the (_ + region)
  naming scheme (can also currently also use true/false/none here).
  Or specify a suffix (eg, _shell) unrelated to any region name.

ENH: improve the code style and alignment in jouleHeatingSource

- make {fa,fv} versions more consistent, for better maintenance
2025-10-12 15:53:29 +02:00
112 changed files with 4198 additions and 1564 deletions

View File

@ -49,8 +49,7 @@ int main(int argc, char *argv[])
Info<< "mesh 0: " << mesh.sortedNames() << nl; Info<< "mesh 0: " << mesh.sortedNames() << nl;
faMeshesRegistry& reg = auto& reg = const_cast<faMeshesRegistry&>(faMeshesRegistry::New(mesh));
const_cast<faMeshesRegistry&>(faMeshesRegistry::New(mesh));
// faMeshesRegistry faReg = faMeshesRegistry(mesh); // faMeshesRegistry faReg = faMeshesRegistry(mesh);

View File

@ -1,3 +1,3 @@
foamToEnsight-check.C foamToEnsight-check.cxx
EXE = $(FOAM_USER_APPBIN)/foamToEnsight-check EXE = $(FOAM_USER_APPBIN)/foamToEnsight-check

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2022-2023 OpenCFD Ltd. Copyright (C) 2022-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -203,6 +203,7 @@ int main(int argc, char *argv[])
argList::addVerboseOption(); argList::addVerboseOption();
#include "addAllRegionOptions.H" #include "addAllRegionOptions.H"
#include "addAllFaRegionOptions.H"
argList::addBoolOption argList::addBoolOption
( (
@ -251,6 +252,14 @@ int main(int argc, char *argv[])
// Handle -allRegions, -regions, -region // Handle -allRegions, -regions, -region
#include "getAllRegionOptions.H" #include "getAllRegionOptions.H"
// Handle -all-area-regions, -area-regions, -area-region
#include "getAllFaRegionOptions.H"
if (!doFiniteArea)
{
areaRegionNames.clear(); // For consistency
}
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
#include "createNamedMeshes.H" #include "createNamedMeshes.H"
@ -259,8 +268,8 @@ int main(int argc, char *argv[])
/// #include "createMeshAccounting.H" /// #include "createMeshAccounting.H"
PtrList<ensightMesh> ensightMeshes(regionNames.size()); PtrList<ensightMesh> ensightMeshes(regionNames.size());
PtrList<faMesh> meshesFa(regionNames.size()); List<PtrList<faMesh>> meshesFa(regionNames.size());
PtrList<ensightFaMesh> ensightMeshesFa(regionNames.size()); List<PtrList<ensightFaMesh>> ensightMeshesFa(regionNames.size());
forAll(regionNames, regioni) forAll(regionNames, regioni)
{ {
@ -273,21 +282,32 @@ int main(int argc, char *argv[])
); );
ensightMeshes[regioni].verbose(optVerbose); ensightMeshes[regioni].verbose(optVerbose);
if (!doFiniteArea)
if (doFiniteArea)
{ {
autoPtr<faMesh> faMeshPtr(faMesh::TryNew(mesh)); continue;
}
meshesFa[regioni].resize_null(areaRegionNames.size());
ensightMeshesFa[regioni].resize_null(areaRegionNames.size());
autoPtr<faMesh> faMeshPtr(faMesh::TryNew(mesh));
forAll(areaRegionNames, areai)
{
const word& areaName = areaRegionNames[areai];
autoPtr<faMesh> faMeshPtr(faMesh::TryNew(areaName, mesh));
if (faMeshPtr) if (faMeshPtr)
{ {
meshesFa.set(regioni, std::move(faMeshPtr)); meshesFa[regioni].set(areai, std::move(faMeshPtr));
ensightMeshesFa.set ensightMeshesFa[regioni].set
( (
regioni, areai,
new ensightFaMesh(meshesFa[regioni]) new ensightFaMesh(meshesFa[regioni][areai])
); );
ensightMeshesFa[regioni].verbose(optVerbose); ensightMeshesFa[regioni][areai].verbose(optVerbose);
} }
} }
} }
@ -295,7 +315,7 @@ int main(int argc, char *argv[])
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
if (Pstream::master()) if (UPstream::master())
{ {
Info<< "Checking " << timeDirs.size() << " time steps" << nl; Info<< "Checking " << timeDirs.size() << " time steps" << nl;
} }
@ -317,17 +337,20 @@ int main(int argc, char *argv[])
auto& ensMesh = ensightMeshes[regioni]; auto& ensMesh = ensightMeshes[regioni];
// Finite-area (can be missing) // Finite-area (can be missing)
auto* ensFaMeshPtr = ensightMeshesFa.get(regioni); auto& ensFaMeshes = ensightMeshesFa[regioni];
if (moving) if (moving)
{ {
ensMesh.expire(); ensMesh.expire();
ensMesh.correct(); ensMesh.correct();
if (ensFaMeshPtr) forAll(areaRegionNames, areai)
{ {
ensFaMeshPtr->expire(); if (auto* ensFaMeshPtr = ensFaMeshes.get(areai))
ensFaMeshPtr->correct(); {
ensFaMeshPtr->expire();
ensFaMeshPtr->correct();
}
} }
} }
@ -340,9 +363,15 @@ int main(int argc, char *argv[])
printInfo(ensMesh, optVerbose); printInfo(ensMesh, optVerbose);
if (ensFaMeshPtr) // finite-area
forAll(areaRegionNames, areai)
{ {
printInfo(*ensFaMeshPtr, optVerbose); auto* ensFaMeshPtr = ensFaMeshes.get(areai);
if (ensFaMeshPtr)
{
printInfo(*ensFaMeshPtr, optVerbose);
}
} }
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2021-2023 OpenCFD Ltd. Copyright (C) 2021-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -28,7 +28,7 @@ Application
makeFaMesh makeFaMesh
Description Description
Check a finiteArea mesh Check a finite-area mesh
Original Authors Original Authors
Zeljko Tukovic, FAMENA Zeljko Tukovic, FAMENA
@ -39,6 +39,7 @@ Original Authors
#include "Time.H" #include "Time.H"
#include "argList.H" #include "argList.H"
#include "faMesh.H" #include "faMesh.H"
#include "faMeshTools.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "areaFaMesh.H" #include "areaFaMesh.H"
#include "edgeFaMesh.H" #include "edgeFaMesh.H"
@ -47,7 +48,7 @@ Original Authors
#include "processorFaPatch.H" #include "processorFaPatch.H"
#include "foamVtkIndPatchWriter.H" #include "foamVtkIndPatchWriter.H"
#include "foamVtkLineWriter.H" #include "foamVtkLineWriter.H"
#include "faMeshTools.H" #include "regionProperties.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -59,7 +60,7 @@ int main(int argc, char *argv[])
{ {
argList::addNote argList::addNote
( (
"Check a finiteArea mesh" "Check a finite-area mesh"
); );
argList::addBoolOption argList::addBoolOption
@ -77,9 +78,15 @@ int main(int argc, char *argv[])
); );
#include "addRegionOption.H" #include "addRegionOption.H"
#include "addFaRegionOption.H" #include "addAllFaRegionOptions.H"
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
// Handle -all-area-regions, -area-regions, -area-region
#include "getAllFaRegionOptions.H"
// ------------------------------------------------------------------------
#include "createNamedPolyMesh.H" #include "createNamedPolyMesh.H"
int geometryOrder(1); int geometryOrder(1);
@ -91,16 +98,41 @@ int main(int argc, char *argv[])
faMesh::geometryOrder(geometryOrder); faMesh::geometryOrder(geometryOrder);
} }
#include "createNamedFaMesh.H" for (const word& areaName : areaRegionNames)
Info<< "Time = " << runTime.timeName() << nl << endl;
// Mesh information (verbose)
faMeshTools::printMeshChecks(aMesh);
if (args.found("write-vtk"))
{ {
#include "faMeshWriteVTK.H" Info<< "Create faMesh";
if (!polyMesh::regionName(areaName).empty())
{
Info<< " [" << areaName << "]";
}
Info<< " for time = " << runTime.timeName() << nl;
autoPtr<faMesh> faMeshPtr(faMesh::TryNew(areaName, mesh));
if (!faMeshPtr)
{
Info<< " ...failed to create area-mesh";
if (!polyMesh::regionName(areaName).empty())
{
Info<< " [" << areaName << "]";
}
Info<< endl;
continue;
}
else
{
Info<< endl;
}
const auto& aMesh = faMeshPtr();
// Mesh information (verbose)
faMeshTools::printMeshChecks(aMesh);
if (args.found("write-vtk"))
{
#include "faMeshWriteVTK.H"
}
} }
Info<< "\nEnd\n" << endl; Info<< "\nEnd\n" << endl;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2021-2023 OpenCFD Ltd. Copyright (C) 2021-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later. This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -15,6 +15,16 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
// The base name for output files
word vtkBaseFileName(aMesh.regionName());
if (polyMesh::regionName(vtkBaseFileName).empty())
{
vtkBaseFileName = "finiteArea";
}
Info<< nl;
Info<< "Write faMesh in vtk format:" << nl;
{ {
// finiteArea - faces // finiteArea - faces
vtk::uindirectPatchWriter writer vtk::uindirectPatchWriter writer
@ -23,7 +33,7 @@ Description
// vtk::formatType::INLINE_ASCII, // vtk::formatType::INLINE_ASCII,
fileName fileName
( (
aMesh.time().globalPath() / "finiteArea" aMesh.time().globalPath() / vtkBaseFileName
) )
); );
@ -32,7 +42,7 @@ Description
globalIndex procAddr(aMesh.nFaces()); globalIndex procAddr(aMesh.nFaces());
labelList cellIDs; labelList cellIDs;
if (Pstream::master()) if (UPstream::master())
{ {
cellIDs.resize(procAddr.totalSize()); cellIDs.resize(procAddr.totalSize());
for (const labelRange& range : procAddr.ranges()) for (const labelRange& range : procAddr.ranges())
@ -53,8 +63,7 @@ Description
writer.beginPointData(1); writer.beginPointData(1);
writer.write("normal", aMesh.pointAreaNormals()); writer.write("normal", aMesh.pointAreaNormals());
Info<< nl Info<< " " << writer.output().name() << nl;
<< "Wrote faMesh in vtk format: " << writer.output().name() << nl;
} }
{ {
@ -66,7 +75,7 @@ Description
// vtk::formatType::INLINE_ASCII, // vtk::formatType::INLINE_ASCII,
fileName fileName
( (
aMesh.time().globalPath() / "finiteArea-edges" aMesh.time().globalPath() / (vtkBaseFileName + "-edges")
) )
); );
@ -88,8 +97,7 @@ Description
writer.beginPointData(1); writer.beginPointData(1);
writer.write("normal", aMesh.pointAreaNormals()); writer.write("normal", aMesh.pointAreaNormals());
Info<< nl Info<< " " << writer.output().name() << nl;
<< "Wrote faMesh in vtk format: " << writer.output().name() << nl;
} }
{ {
@ -108,7 +116,7 @@ Description
// vtk::formatType::INLINE_ASCII, // vtk::formatType::INLINE_ASCII,
fileName fileName
( (
aMesh.time().globalPath() / "finiteArea-edgesCentres" aMesh.time().globalPath() / (vtkBaseFileName + "-edgesCentres")
) )
); );
@ -134,8 +142,7 @@ Description
writer.write("normal", fld); writer.write("normal", fld);
} }
Info<< nl Info<< " " << writer.output().name() << nl;
<< "Wrote faMesh in vtk format: " << writer.output().name() << nl;
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2023 OpenCFD Ltd. Copyright (C) 2023-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later. This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -15,7 +15,7 @@ Description
Input Input
mesh (polyMesh) mesh (polyMesh)
meshDefDict (system/faMeshDefintion) meshDefDict (system/finite-area/faMeshDefinition)
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -25,13 +25,16 @@ Input
const polyBoundaryMesh& pbm = mesh.boundaryMesh(); const polyBoundaryMesh& pbm = mesh.boundaryMesh();
wordRes polyPatchNames; labelList patchIDs;
meshDefDict.readIfPresent("polyMeshPatches", polyPatchNames);
const labelList patchIDs if
( (
pbm.indices(polyPatchNames, true) // useGroups wordRes select;
); meshDefDict.readIfPresent("polyMeshPatches", select)
)
{
patchIDs = pbm.indices(select, true); // useGroups
}
label nFaceLabels = 0; label nFaceLabels = 0;
for (const label patchi : patchIDs) for (const label patchi : patchIDs)

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2021-2024 OpenCFD Ltd. Copyright (C) 2021-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later. This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -13,6 +13,18 @@ License
Description Description
Search for the appropriate faMeshDefinition dictionary... Search for the appropriate faMeshDefinition dictionary...
Expects to find a faMeshDefinition file in a location specified
by the command-line option, or one of the standard locations.
For default area region (region0):
(1) system/finite-area/faMeshDefinition
(2) system/faMeshDefinition [legacy location - v2312 and earlier]
For a named area region:
(1) system/finite-area/<area-name>/faMeshDefinition
(2) system/finite-area/faMeshDefinition.<area-name>
[symmetric with faOptions]
Required Classes Required Classes
- Foam::polyMesh - Foam::polyMesh
- Foam::IOdictionary - Foam::IOdictionary
@ -24,81 +36,185 @@ Required Variables
- runTime [Time] - runTime [Time]
Provided Variables Provided Variables
- meshDefDict [IOdictionary] - faMeshDefinitionPtr [autoPtr<IOdictionary>]
- meshDictPtr [autoPtr<IOdictionary>]
If the dictionary cannot be found, exits with an error message or
reports a warning (dry-run mode)
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
const word dictName("faMeshDefinition"); const word dictName("faMeshDefinition");
autoPtr<IOdictionary> meshDictPtr; autoPtr<IOdictionary> faMeshDefinitionPtr;
{ {
fileName dictPath; // Exit unless dry-run?
const word& regionDir = Foam::polyMesh::regionName(regionName); const bool exitOnFailure = (!args.dryRun());
const word& areaRegionDir = Foam::polyMesh::regionName(areaRegionName);
if (args.readIfPresent("dict", dictPath)) const word& regionDir = polyMesh::regionName(regionName);
const word& areaRegionDir = polyMesh::regionName(areaRegionName);
// Canonical location
fileName dictPath
(
runTime.system()/regionDir
/ faMesh::prefix()/areaRegionDir/dictName
);
// Dictionary specified on the command-line ...
const bool specified = args.readIfPresent("dict", dictPath);
if (specified)
{ {
// Dictionary specified on the command-line ...
if (isDir(dictPath)) if (isDir(dictPath))
{ {
dictPath /= dictName; dictPath /= dictName;
} }
} }
else if
(
// Dictionary under system/faMeshDefinition ?
// (v2312 and earlier)
areaRegionDir.empty()
&& exists
(
runTime.path()/runTime.caseSystem()
/ regionDir/faMesh::meshSubDir/dictName
)
)
{
// Dictionary present directly in system/ (v2312 and earlier)
dictPath = runTime.system()/regionDir/dictName;
}
else
{
// Use system/finite-area/ directory, with region qualifications
dictPath =
(
runTime.system()/regionDir
/ faMesh::prefix()/areaRegionDir/dictName
);
}
IOobject meshDictIO IOobject meshDictIO
( (
dictPath, dictPath,
runTime, runTime,
IOobject::MUST_READ, IOobjectOption::MUST_READ,
IOobject::NO_WRITE, IOobjectOption::NO_WRITE,
IOobject::NO_REGISTER, IOobjectOption::NO_REGISTER,
true // is globalObject true // is globalObject
); );
if (!meshDictIO.typeHeaderOk<IOdictionary>(true)) refPtr<IOobject> meshDictIOPtr;
bool foundIOobject = meshDictIO.typeHeaderOk<IOdictionary>(true);
// For reporting any alternative locations
dictPath.clear();
if (!foundIOobject && !specified)
{ {
FatalErrorInFunction if (!areaRegionDir.empty())
<< meshDictIO.objectPath() << nl {
<< exit(FatalError); // Alternative location
// - system/finite-area/faMeshDefinition.<area-name>
dictPath =
(
runTime.system()/regionDir
/ faMesh::prefix()/IOobject::groupName(dictName, areaRegionDir)
);
}
else
{
// legacy location (v2312 and earlier)
// - system/faMeshDefinition
dictPath = runTime.system()/regionDir/dictName;
}
if (!dictPath.empty())
{
auto ioptr = autoPtr<IOobject>::New
(
dictPath,
runTime,
IOobjectOption::MUST_READ,
IOobjectOption::NO_WRITE,
IOobjectOption::NO_REGISTER,
true // is globalObject
);
foundIOobject =
(
ioptr && ioptr->typeHeaderOk<IOdictionary>(true)
);
if (foundIOobject)
{
// Use if found
meshDictIOPtr = std::move(ioptr);
}
// Generally retain dictPath for error messages,
// but don't mention the really old legacy location
if (areaRegionDir.empty())
{
dictPath.clear();
}
}
} }
Info<< "Creating faMesh from definition: " // Alternative location or regular location?
<< meshDictIO.objectRelPath() << endl; if (!meshDictIOPtr)
{
meshDictIOPtr.cref(meshDictIO);
}
const auto& io = meshDictIOPtr();
meshDictPtr = autoPtr<IOdictionary>::New(meshDictIO);
// Handle final success or failure
if (foundIOobject)
{
Info<< "----------------" << nl
<< "Using area-mesh definition";
if (!areaRegionDir.empty())
{
Info<< " [" << areaRegionName << "]";
}
Info<< nl
<< " " << io.objectRelPath() << nl << endl;
faMeshDefinitionPtr = autoPtr<IOdictionary>::New(io);
}
else
{
// Failure
if (exitOnFailure)
{
auto& err =
FatalErrorInFunction
<< "Did not find area-mesh definition";
if (!areaRegionDir.empty())
{
err<< " [" << areaRegionName << "]";
}
err << nl
<< " " << io.objectRelPath() << nl;
if (!dictPath.empty())
{
err << " " << dictPath << nl;
}
FatalError<< exit(FatalError);
}
else
{
// dry-run: warning
auto& err =
Warning << nl
<< "----------------" << nl
<< "Did not find area-mesh definition";
if (!areaRegionDir.empty())
{
err << " [" << areaRegionName << "]";
}
err << nl
<< " " << io.objectRelPath() << nl;
if (!dictPath.empty())
{
err << " " << dictPath << nl;
}
}
}
} }
IOdictionary& meshDefDict = *meshDictPtr;
// ************************************************************************* // // ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2021-2023 OpenCFD Ltd. Copyright (C) 2021-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -40,7 +40,6 @@ Original Authors
#include "Time.H" #include "Time.H"
#include "argList.H" #include "argList.H"
#include "OSspecific.H"
#include "faMesh.H" #include "faMesh.H"
#include "faMeshTools.H" #include "faMeshTools.H"
#include "IOdictionary.H" #include "IOdictionary.H"
@ -53,6 +52,7 @@ Original Authors
#include "PtrListOps.H" #include "PtrListOps.H"
#include "foamVtkLineWriter.H" #include "foamVtkLineWriter.H"
#include "foamVtkIndPatchWriter.H" #include "foamVtkIndPatchWriter.H"
#include "regionProperties.H"
#include "syncTools.H" #include "syncTools.H"
#include "OBJstream.H" #include "OBJstream.H"
@ -104,12 +104,14 @@ int main(int argc, char *argv[])
); );
#include "addRegionOption.H" #include "addRegionOption.H"
#include "addFaRegionOption.H" #include "addAllFaRegionOptions.H"
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
#include "createNamedPolyMesh.H" #include "createNamedPolyMesh.H"
#include "getFaRegionOption.H" // Handle -all-area-regions, -area-regions, -area-region
#include "getAllFaRegionOptions.H"
const bool doDecompose = !args.found("no-decompose"); const bool doDecompose = !args.found("no-decompose");
const bool doDecompFields = !args.found("no-fields"); const bool doDecompFields = !args.found("no-fields");
@ -123,56 +125,83 @@ int main(int argc, char *argv[])
Info<< "Skip decompose of finiteArea fields" << nl; Info<< "Skip decompose of finiteArea fields" << nl;
} }
// Reading faMeshDefinition dictionary // ------------------------------------------------------------------------
#include "findMeshDefinitionDict.H"
// Inject/overwrite name for optional 'empty' patch for (const word& areaRegionName : areaRegionNames)
word patchName;
if (args.readIfPresent("empty-patch", patchName))
{ {
meshDefDict.add("emptyPatch", patchName, true); // Reading faMeshDefinition dictionary
} #include "findMeshDefinitionDict.H"
// Preliminary checks if (!faMeshDefinitionPtr)
#include "checkPatchTopology.H" {
if (args.dryRun())
{
break;
}
else
{
FatalErrorInFunction
<< "Did not find area-mesh definition"<< nl
<< exit(FatalError);
}
}
Info << "Create areaMesh"; auto& meshDefDict = (*faMeshDefinitionPtr);
if (!Foam::polyMesh::regionName(areaRegionName).empty())
{
Foam::Info << ' ' << areaRegionName;
}
Info << " for polyMesh at time = " << runTime.timeName() << nl;
// Create
faMesh aMesh(areaRegionName, mesh, meshDefDict);
// Mesh information (less verbose) // Inject/overwrite name for optional 'empty' patch
faMeshTools::printMeshChecks(aMesh, 0); if (word name; args.readIfPresent("empty-patch", name))
{
meshDefDict.add("emptyPatch", name, true);
}
if (args.found("write-edges-obj")) // Preliminary checks
{ #include "checkPatchTopology.H"
#include "faMeshWriteEdgesOBJ.H"
}
if (args.found("write-vtk")) Info<< "Create area-mesh";
{ if (!polyMesh::regionName(areaRegionName).empty())
#include "faMeshWriteVTK.H" {
} Info<< " [" << areaRegionName << "]";
}
Info<< " with polyMesh at time = " << runTime.timeName() << nl;
if (args.dryRun()) // Create
{ faMesh aMesh(areaRegionName, mesh, meshDefDict);
Info<< "\ndry-run: not writing mesh or decomposing fields\n" << nl;
}
else
{
// More precision (for points data)
IOstream::minPrecision(10);
Info<< nl << "Write finite area mesh." << nl; // Mesh information (less verbose)
aMesh.write(); faMeshTools::printMeshChecks(aMesh, 0);
Info<< endl; if (args.found("write-edges-obj"))
#include "decomposeFaFields.H" {
#include "faMeshWriteEdgesOBJ.H"
}
if (args.found("write-vtk"))
{
#include "faMeshWriteVTK.H"
}
if (args.dryRun())
{
Info<< "\ndry-run: not writing mesh or decomposing fields\n" << nl;
}
else
{
// More precision (for points data)
IOstream::minPrecision(10);
Info<< nl << "Write finite area mesh";
if (const word& name = aMesh.regionName(); !name.empty())
{
Info<< " [" << name << "]";
}
Info<< nl;
aMesh.write();
Info<< endl;
#include "decomposeFaFields.H"
}
} }
Info<< "\nEnd\n" << endl; Info<< "\nEnd\n" << endl;

View File

@ -334,6 +334,7 @@ int main(int argc, char *argv[])
); );
#include "addAllRegionOptions.H" #include "addAllRegionOptions.H"
#include "addAllFaRegionOptions.H"
argList::addDryRunOption argList::addDryRunOption
( (
@ -442,7 +443,6 @@ int main(int argc, char *argv[])
bool decomposeFieldsOnly = args.found("fields"); bool decomposeFieldsOnly = args.found("fields");
bool forceOverwrite = args.found("force"); bool forceOverwrite = args.found("force");
// Set time from database // Set time from database
#include "createTime.H" #include "createTime.H"
@ -491,9 +491,17 @@ int main(int argc, char *argv[])
decompDictFile = runTime.globalPath()/decompDictFile; decompDictFile = runTime.globalPath()/decompDictFile;
} }
// Get region names // Handle -allRegions, -regions, -region
#include "getAllRegionOptions.H" #include "getAllRegionOptions.H"
// Handle -all-area-regions, -area-regions, -area-region
#include "getAllFaRegionOptions.H"
if (!doFiniteArea)
{
areaRegionNames.clear(); // For consistency
}
const bool optRegions = const bool optRegions =
(regionNames.size() != 1 || regionNames[0] != polyMesh::defaultRegion); (regionNames.size() != 1 || regionNames[0] != polyMesh::defaultRegion);
@ -813,56 +821,76 @@ int main(int argc, char *argv[])
// Field objects at this time // Field objects at this time
IOobjectList objects; IOobjectList objects;
IOobjectList faObjects;
// faMesh fields - can have multiple finite-area per volume
HashTable<IOobjectList> faObjects;
if (doDecompFields) if (doDecompFields)
{ {
// List of volume mesh objects for this instance // List of volume mesh objects for this instance
objects = IOobjectList(mesh, runTime.timeName()); objects = IOobjectList(mesh, runTime.timeName());
// List of area mesh objects (assuming single region)
faObjects = IOobjectList
(
mesh.time(),
runTime.timeName(),
faMesh::dbDir(mesh, word::null),
IOobjectOption::NO_REGISTER
);
// Ignore generated fields: (cellDist) // Ignore generated fields: (cellDist)
objects.remove("cellDist"); objects.remove("cellDist");
// Lists of finite-area fields
faObjects.reserve(areaRegionNames.size());
for (const word& areaName : areaRegionNames)
{
// The finite-area objects for this area region
IOobjectList objs
(
faMesh::Registry(mesh),
runTime.timeName(),
polyMesh::regionName(areaName),
IOobjectOption::NO_REGISTER
);
if (!objs.empty())
{
faObjects.emplace_set(areaName, std::move(objs));
}
}
} }
// Finite area handling // Finite area handling
autoPtr<faMeshDecomposition> faMeshDecompPtr; // - all area regions use the same volume decomposition
HashPtrTable<faMeshDecomposition> faMeshDecompHashes;
if (doFiniteArea) if (doFiniteArea)
{ {
const word boundaryInst = const word boundaryInst =
mesh.time().findInstance(mesh.meshDir(), "boundary"); mesh.time().findInstance(mesh.meshDir(), "boundary");
IOobject io for (const word& areaName : areaRegionNames)
(
"faBoundary",
boundaryInst,
faMesh::meshDir(mesh, word::null),
mesh.time(),
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
);
if (io.typeHeaderOk<faBoundaryMesh>(true))
{ {
// Always based on the volume decomposition! IOobject io
faMeshDecompPtr.reset
( (
new faMeshDecomposition "faBoundary",
( boundaryInst,
mesh, faMesh::meshDir(mesh, areaName),
mesh.nProcs(), mesh.time(),
mesh.model() IOobject::READ_IF_PRESENT,
) IOobject::NO_WRITE,
IOobject::NO_REGISTER
); );
if (io.typeHeaderOk<faBoundaryMesh>(true))
{
// Always based on the volume decomposition!
faMeshDecompHashes.set
(
areaName,
autoPtr<faMeshDecomposition>::New
(
areaName,
mesh,
mesh.nProcs(),
mesh.model()
)
);
}
} }
} }
@ -1066,7 +1094,7 @@ int main(int argc, char *argv[])
processorDb.setTime(runTime); processorDb.setTime(runTime);
// read the mesh // Read the mesh
if (!procMeshList.set(proci)) if (!procMeshList.set(proci))
{ {
procMeshList.set procMeshList.set
@ -1273,12 +1301,15 @@ int main(int argc, char *argv[])
} }
// Finite area mesh and field decomposition // Finite-area mesh and field decomposition
if (faMeshDecompPtr) for (auto& iter : faMeshDecompHashes.sorted())
{ {
Info<< "\nFinite area mesh decomposition" << endl; const word& areaName = iter.key();
faMeshDecomposition& aMesh = faMeshDecompPtr(); faMeshDecomposition& aMesh = *(iter.val());
Info<< "\nFinite area mesh decomposition: "
<< areaName << endl;
aMesh.decomposeMesh(); aMesh.decomposeMesh();
aMesh.writeDecomposition(); aMesh.writeDecomposition();
@ -1289,9 +1320,13 @@ int main(int argc, char *argv[])
faFieldDecomposer::fieldsCache areaFieldCache; faFieldDecomposer::fieldsCache areaFieldCache;
if (doDecompFields) if
(
const auto objs = faObjects.cfind(areaName);
doDecompFields && objs.good()
)
{ {
areaFieldCache.readAllFields(aMesh, faObjects); areaFieldCache.readAllFields(aMesh, objs.val());
} }
const label nAreaFields = areaFieldCache.size(); const label nAreaFields = areaFieldCache.size();
@ -1322,7 +1357,7 @@ int main(int argc, char *argv[])
processorDb.setTime(runTime); processorDb.setTime(runTime);
// Read the mesh // Read the volume mesh
fvMesh procFvMesh fvMesh procFvMesh
( (
IOobject IOobject
@ -1333,7 +1368,7 @@ int main(int argc, char *argv[])
) )
); );
faMesh procMesh(procFvMesh); faMesh procMesh(areaName, procFvMesh);
// // Does not work. HJ, 15/Aug/2017 // // Does not work. HJ, 15/Aug/2017
// const labelIOList& faceProcAddressing = // const labelIOList& faceProcAddressing =
@ -1392,7 +1427,11 @@ int main(int argc, char *argv[])
boundaryProcAddressing boundaryProcAddressing
); );
areaFieldCache.decomposeAllFields(fieldDecomposer); areaFieldCache.decomposeAllFields
(
fieldDecomposer,
args.verbose() // report
);
} }
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2023 OpenCFD Ltd. Copyright (C) 2015-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -91,6 +91,7 @@ int main(int argc, char *argv[])
argList::noParallel(); argList::noParallel();
#include "addAllRegionOptions.H" #include "addAllRegionOptions.H"
#include "addAllFaRegionOptions.H"
argList::addVerboseOption(); argList::addVerboseOption();
argList::addOption argList::addOption
@ -201,9 +202,17 @@ int main(int argc, char *argv[])
const bool newTimes = args.found("newTimes"); const bool newTimes = args.found("newTimes");
// Get region names // Handle -allRegions, -regions, -region
#include "getAllRegionOptions.H" #include "getAllRegionOptions.H"
// Handle -all-area-regions, -area-regions, -area-region
#include "getAllFaRegionOptions.H"
if (!doFiniteArea)
{
areaRegionNames.clear(); // For consistency
}
// Determine the processor count // Determine the processor count
label nProcs{0}; label nProcs{0};
@ -391,19 +400,30 @@ int main(int argc, char *argv[])
IOobjectOption::NO_REGISTER IOobjectOption::NO_REGISTER
); );
IOobjectList faObjects; // The finite-area fields (multiple finite-area per volume)
HashTable<IOobjectList> faObjects;
if (doFiniteArea && doFields) if (doFiniteArea && doFields)
{ {
// List of area mesh objects (assuming single region) // Lists of finite-area fields - scan on processor0
// - scan on processor0 faObjects.reserve(areaRegionNames.size());
faObjects = IOobjectList
( for (const word& areaName : areaRegionNames)
procMeshes.meshes()[0], {
databases[0].timeName(), // The finite-area objects for this area region
faMesh::dbDir(word::null), // local relative to mesh IOobjectList objs
IOobjectOption::NO_REGISTER (
); procMeshes.meshes()[0],
databases[0].timeName(),
faMesh::dbDir(areaName), // local relative to mesh
IOobjectOption::NO_REGISTER
);
if (!objs.empty())
{
faObjects.emplace_set(areaName, std::move(objs));
}
}
} }
if (doFields) if (doFields)
@ -553,42 +573,60 @@ int main(int argc, char *argv[])
} }
// If there are any FA fields, reconstruct them // Reconstruct any finite-area fields
if (doFiniteArea)
if (!doFiniteArea)
{ {
bool hadFaFields = false;
for (const word& areaName : areaRegionNames)
{
const auto objs = faObjects.cfind(areaName);
if (!objs.good())
{
continue;
}
const auto& faObjs = objs.val();
if
(
!faObjs.count(fieldTypes::is_area)
&& !faObjs.count<edgeScalarField>()
)
{
continue;
}
hadFaFields = true;
Info<< "Reconstructing finite-area fields ["
<< polyMesh::regionName(areaName)
<< "]" << nl << endl;
const faMesh aMesh(areaName, mesh);
processorFaMeshes procFaMeshes
(
procMeshes.meshes(),
areaName
);
faFieldReconstructor reconstructor
(
aMesh,
procFaMeshes.meshes(),
procFaMeshes.edgeProcAddressing(),
procFaMeshes.faceProcAddressing(),
procFaMeshes.boundaryProcAddressing()
);
reconstructor.reconstructAllFields(faObjs);
}
if (!hadFaFields)
{
Info << "No finite-area fields" << nl << endl;
}
} }
else if
(
faObjects.count<areaScalarField>()
|| faObjects.count<areaVectorField>()
|| faObjects.count<areaSphericalTensorField>()
|| faObjects.count<areaSymmTensorField>()
|| faObjects.count<areaTensorField>()
|| faObjects.count<edgeScalarField>()
)
{
Info << "Reconstructing FA fields" << nl << endl;
faMesh aMesh(mesh);
processorFaMeshes procFaMeshes(procMeshes.meshes());
faFieldReconstructor reconstructor
(
aMesh,
procFaMeshes.meshes(),
procFaMeshes.edgeProcAddressing(),
procFaMeshes.faceProcAddressing(),
procFaMeshes.boundaryProcAddressing()
);
reconstructor.reconstructAllFields(faObjects);
}
else
{
Info << "No FA fields" << nl << endl;
}
if (doReconstructSets) if (doReconstructSets)
{ {

View File

@ -119,17 +119,10 @@ autoPtr<faceCoupleInfo> determineCoupledFaces
const polyBoundaryMesh& masterPatches = masterMesh.boundaryMesh(); const polyBoundaryMesh& masterPatches = masterMesh.boundaryMesh();
DynamicList<label> masterFaces DynamicList<label> masterFaces(masterMesh.nBoundaryFaces());
(
masterMesh.nFaces()
- masterMesh.nInternalFaces()
);
for (const polyPatch& pp : masterPatches)
forAll(masterPatches, patchi)
{ {
const polyPatch& pp = masterPatches[patchi];
if (isA<processorPolyPatch>(pp)) if (isA<processorPolyPatch>(pp))
{ {
for for
@ -139,11 +132,8 @@ autoPtr<faceCoupleInfo> determineCoupledFaces
proci++ proci++
) )
{ {
const string toProcString("to" + name(proci)); const string toProcString("to" + Foam::name(proci));
if ( if (pp.name().ends_with(toProcString))
pp.name().rfind(toProcString)
== (pp.name().size()-toProcString.size())
)
{ {
label meshFacei = pp.start(); label meshFacei = pp.start();
forAll(pp, i) forAll(pp, i)
@ -156,7 +146,6 @@ autoPtr<faceCoupleInfo> determineCoupledFaces
} }
} }
masterFaces.shrink();
// Pick up all patches on meshToAdd ending in "procBoundaryDDDtoYYY" // Pick up all patches on meshToAdd ending in "procBoundaryDDDtoYYY"
@ -164,16 +153,10 @@ autoPtr<faceCoupleInfo> determineCoupledFaces
const polyBoundaryMesh& addPatches = meshToAdd.boundaryMesh(); const polyBoundaryMesh& addPatches = meshToAdd.boundaryMesh();
DynamicList<label> addFaces DynamicList<label> addFaces(meshToAdd.nBoundaryFaces());
(
meshToAdd.nFaces()
- meshToAdd.nInternalFaces()
);
forAll(addPatches, patchi) for (const polyPatch& pp : addPatches)
{ {
const polyPatch& pp = addPatches[patchi];
if (isA<processorPolyPatch>(pp)) if (isA<processorPolyPatch>(pp))
{ {
bool isConnected = false; bool isConnected = false;
@ -215,7 +198,6 @@ autoPtr<faceCoupleInfo> determineCoupledFaces
} }
} }
} }
addFaces.shrink();
return autoPtr<faceCoupleInfo>::New return autoPtr<faceCoupleInfo>::New
( (
@ -502,15 +484,14 @@ void writeMaps
Info<< " pointProcAddressing" << endl; Info<< " pointProcAddressing" << endl;
ioAddr.rename("pointProcAddressing"); ioAddr.rename("pointProcAddressing");
IOList<label>::writeContents(ioAddr, pointProcAddressing); labelIOList::writeContents(ioAddr, pointProcAddressing);
// From processor face to reconstructed mesh face // From processor face to reconstructed mesh face
Info<< " faceProcAddressing" << endl; // - add turning index to faceProcAddressing.
ioAddr.rename("faceProcAddressing"); // See reconstructPar for meaning of turning index.
labelIOList faceProcAddr(ioAddr, faceProcAddressing);
labelList faceProcAddr(faceProcAddressing);
// Now add turning index to faceProcAddressing.
// See reconstructPar for meaning of turning index.
forAll(faceProcAddr, procFacei) forAll(faceProcAddr, procFacei)
{ {
const label masterFacei = faceProcAddr[procFacei]; const label masterFacei = faceProcAddr[procFacei];
@ -545,19 +526,21 @@ void writeMaps
} }
} }
faceProcAddr.write(); Info<< " faceProcAddressing" << endl;
ioAddr.rename("faceProcAddressing");
labelIOList::writeContents(ioAddr, faceProcAddr);
faceProcAddr.clear();
// From processor cell to reconstructed mesh cell // From processor cell to reconstructed mesh cell
Info<< " cellProcAddressing" << endl; Info<< " cellProcAddressing" << endl;
ioAddr.rename("cellProcAddressing"); ioAddr.rename("cellProcAddressing");
IOList<label>::writeContents(ioAddr, cellProcAddressing); labelIOList::writeContents(ioAddr, cellProcAddressing);
// From processor patch to reconstructed mesh patch // From processor patch to reconstructed mesh patch
Info<< " boundaryProcAddressing" << endl; Info<< " boundaryProcAddressing" << endl;
ioAddr.rename("boundaryProcAddressing"); ioAddr.rename("boundaryProcAddressing");
IOList<label>::writeContents(ioAddr, boundProcAddressing); labelIOList::writeContents(ioAddr, boundProcAddressing);
Info<< endl; Info<< endl;
} }
@ -645,7 +628,8 @@ void sortFaEdgeMapping
{ {
// From faMeshReconstructor.C - edge shuffling on patches // From faMeshReconstructor.C - edge shuffling on patches
Map<label> remapGlobal(2*onePatch.nEdges()); Map<label> remapGlobal;
remapGlobal.reserve(onePatch.nEdges());
for (label edgei = 0; edgei < onePatch.nInternalEdges(); ++edgei) for (label edgei = 0; edgei < onePatch.nInternalEdges(); ++edgei)
{ {
remapGlobal.insert(edgei, remapGlobal.size()); remapGlobal.insert(edgei, remapGlobal.size());
@ -779,6 +763,11 @@ int main(int argc, char *argv[])
); );
#include "addAllRegionOptions.H" #include "addAllRegionOptions.H"
#include "addAllFaRegionOptions.H"
// Prevent volume fields [with regionFaModels] from incidental
// triggering finite-area
regionModels::allowFaModels(false);
// Prevent volume BCs from triggering finite-area // Prevent volume BCs from triggering finite-area
regionModels::allowFaModels(false); regionModels::allowFaModels(false);
@ -841,9 +830,17 @@ int main(int argc, char *argv[])
} }
} }
// Get region names // Handle -allRegions, -regions, -region
#include "getAllRegionOptions.H" #include "getAllRegionOptions.H"
// Handle -all-area-regions, -area-regions, -area-region
#include "getAllFaRegionOptions.H"
if (!doFiniteArea)
{
areaRegionNames.clear(); // For consistency
}
// Determine the processor count // Determine the processor count
label nProcs{0}; label nProcs{0};
@ -935,7 +932,8 @@ int main(int argc, char *argv[])
polyMesh::meshDir(regionName), polyMesh::meshDir(regionName),
databases[0], databases[0],
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE,
IOobject::NO_REGISTER
); );
// Problem: faceCompactIOList recognises both 'faceList' and // Problem: faceCompactIOList recognises both 'faceList' and
@ -1405,8 +1403,12 @@ int main(int argc, char *argv[])
// Read finite-area // Read finite-area
PtrList<faMesh> procFaMeshes(databases.size()); // For each named area region that exists create a HashTable
// entry that will contain the PtrList for all processors
PtrList<polyMesh> procMeshes(databases.size()); PtrList<polyMesh> procMeshes(databases.size());
HashTable<PtrList<faMesh>> procAreaRegionMeshes;
procAreaRegionMeshes.reserve(areaRegionNames.size());
forAll(databases, proci) forAll(databases, proci)
{ {
@ -1414,20 +1416,16 @@ int main(int argc, char *argv[])
<< "Read processor mesh: " << "Read processor mesh: "
<< (databases[proci].caseName()/regionDir) << endl; << (databases[proci].caseName()/regionDir) << endl;
procMeshes.set const polyMesh& procMesh = procMeshes.emplace
( (
proci, proci,
new polyMesh IOobject
( (
IOobject regionName,
( databases[proci].timeName(),
regionName, databases[proci]
databases[proci].timeName(),
databases[proci]
)
) )
); );
const polyMesh& procMesh = procMeshes[proci];
writeMaps writeMaps
( (
@ -1450,38 +1448,67 @@ int main(int argc, char *argv[])
"boundary" "boundary"
); );
IOobject io for (const word& areaName : areaRegionNames)
(
"faBoundary",
boundaryInst,
faMesh::meshDir(procMesh, word::null),
procMesh.time(),
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
);
if (io.typeHeaderOk<faBoundaryMesh>(true))
{ {
// Always based on the volume decomposition! IOobject io
procFaMeshes.set(proci, new faMesh(procMesh)); (
"faBoundary",
boundaryInst,
faMesh::meshDir(procMesh, areaName),
procMesh.time(),
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
);
if (io.typeHeaderOk<faBoundaryMesh>(true))
{
// Always based on the volume decomposition!
auto& procFaMeshes = procAreaRegionMeshes(areaName);
procFaMeshes.resize(databases.size());
procFaMeshes.set
(
proci,
new faMesh(areaName, procMesh)
);
}
} }
} }
} }
// Finite-area mapping // A finite-area mapping exists if procFaMeshes was filled
doFiniteArea = false;
forAll(procFaMeshes, proci) // Re-read reconstructed polyMesh. Note: could probably be avoided
// by merging into loops above.
refPtr<polyMesh> masterPolyMeshPtr;
if (!procAreaRegionMeshes.empty())
{ {
if (procFaMeshes.set(proci)) masterPolyMeshPtr.reset
{ (
doFiniteArea = true; new polyMesh
} (
IOobject
(
regionName,
runTime.timeName(),
runTime
),
true
)
);
} }
if (doFiniteArea) // Process any finite-area meshes
for (const auto& iter : procAreaRegionMeshes.csorted())
{ {
const auto& areaName = iter.key();
const auto& procFaMeshes = iter.val();
const polyMesh& masterMesh = masterPolyMeshPtr();
// Addressing from processor to reconstructed case // Addressing from processor to reconstructed case
labelListList faFaceProcAddressing(nProcs); labelListList faFaceProcAddressing(nProcs);
labelListList faEdgeProcAddressing(nProcs); labelListList faEdgeProcAddressing(nProcs);
@ -1499,32 +1526,10 @@ int main(int argc, char *argv[])
faBoundProcAddressing[proci] = identity(bm.size()); faBoundProcAddressing[proci] = identity(bm.size());
// Mark processor patches // Mark processor patches
for faBoundProcAddressing[proci].slice(bm.nNonProcessor()) = -1;
(
label patchi = bm.nNonProcessor();
patchi < bm.size();
++patchi
)
{
faBoundProcAddressing[proci][patchi] = -1;
}
} }
// Re-read reconstructed polyMesh. Note: could probably be avoided
// by merging into loops above.
const polyMesh masterMesh
(
IOobject
(
regionName,
runTime.timeName(),
runTime
),
true
);
// faceProcAddressing // faceProcAddressing
// ~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~
@ -1559,13 +1564,13 @@ int main(int argc, char *argv[])
// Construct without patches // Construct without patches
faMesh masterFaMesh faMesh masterFaMesh
( (
areaName,
masterMesh, masterMesh,
std::move(masterFaceLabels), std::move(masterFaceLabels),
io io
); );
const uindirectPrimitivePatch& masterPatch = const auto& masterPatch = masterFaMesh.patch();
masterFaMesh.patch();
// pointProcAddressing // pointProcAddressing
@ -1577,7 +1582,7 @@ int main(int argc, char *argv[])
const auto& procPatch = procFaMeshes[proci].patch(); const auto& procPatch = procFaMeshes[proci].patch();
const auto& mp = procPatch.meshPoints(); const auto& mp = procPatch.meshPoints();
labelList& pointAddr = faPointProcAddressing[proci]; auto& pointAddr = faPointProcAddressing[proci];
pointAddr.resize_nocopy(mp.size()); pointAddr.resize_nocopy(mp.size());
forAll(mp, i) forAll(mp, i)
@ -1626,8 +1631,7 @@ int main(int argc, char *argv[])
label nPatches = 0; label nPatches = 0;
forAll(completePatches, patchi) forAll(completePatches, patchi)
{ {
const labelList& patchEdgeLabels = const auto& patchEdgeLabels = singlePatchEdgeLabels[patchi];
singlePatchEdgeLabels[patchi];
const faPatch& fap = procMesh0.boundary()[patchi]; const faPatch& fap = procMesh0.boundary()[patchi];
@ -1658,11 +1662,11 @@ int main(int argc, char *argv[])
// Serial mesh - no parallel communication // Serial mesh - no parallel communication
const bool oldParRun = Pstream::parRun(false); const bool oldParRun = UPstream::parRun(false);
masterFaMesh.addFaPatches(completePatches); masterFaMesh.addFaPatches(completePatches);
Pstream::parRun(oldParRun); // Restore parallel state UPstream::parRun(oldParRun); // Restore parallel state
// Write mesh & individual addressing // Write mesh & individual addressing

View File

@ -33,99 +33,266 @@ License
#include "decomposedBlockData.H" #include "decomposedBlockData.H"
#include "IFstream.H" #include "IFstream.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
bool Foam::checkFileExistence(const fileName& fName) // Trimmed-down version of lookupAndCacheProcessorsPath
// with Foam::exists() check. No caching.
// Check for two conditions:
// - file has to exist
// - if collated the entry has to exist inside the file
// Note: bypass fileOperation::filePath(IOobject&) since has problems
// with going to a different number of processors
// (in collated format). Use file-based searching instead
namespace Foam
{ {
// Trimmed-down version of lookupAndCacheProcessorsPath
// with Foam::exists() check. No caching.
// Check for two conditions: // If indeed collated format:
// - file has to exist // Collect block-number in individual filenames
// - if collated the entry has to exist inside the file // (might differ on different processors)
static bool checkFileExistenceCollated
// Note: bypass fileOperation::filePath(IOobject&) since has problems (
// with going to a different number of processors const Foam::fileOperation& handler,
// (in collated format). Use file-based searching instead const Foam::fileName& fName
)
const auto& handler = Foam::fileHandler(); {
typedef fileOperation::procRangeType procRangeType; // using namespace Foam;
fileName path, pDir, local;
procRangeType group;
label numProcs;
const label proci =
fileOperation::splitProcessorPath
(fName, path, pDir, local, group, numProcs);
bool found = false; bool found = false;
if (proci != -1)
{ {
// Read all directories to see any beginning with processor const label handlerComm = handler.comm();
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const fileNameList dirEntries const label globalProci = UPstream::myProcNo(UPstream::worldComm);
( const label handlerProci = UPstream::myProcNo(handlerComm);
handler.readDir(path, fileName::Type::DIRECTORY) const label nHandlerProcs = UPstream::nProcs(handlerComm);
);
// Extract info from processorN or processorsNN // Determine my local block number
// - highest processor number label myBlockNumber = -1;
// - directory+offset containing data for proci
// label nProcs = 0;
for (const fileName& dirN : dirEntries)
{ {
// Analyse directory name fileOperation::procRangeType group;
label rNum(-1); label proci = fileOperation::detectProcessorPath(fName, group);
const label readProci =
fileOperation::detectProcessorPath(dirN, group, &rNum);
if (proci == readProci) if (proci == -1 && group.empty())
{ {
// Found "processorN" // 'processorsXXX' format so contains all ranks
if (Foam::exists(path/dirN/local)) // according to worldComm
{ myBlockNumber = globalProci;
found = true;
break;
}
} }
else if (rNum != -1) else
{ {
// "processorsNN" or "processorsNN_start-end" // 'processorsXXX_n-m' format so check for relative rank
if (group.empty()) myBlockNumber = handlerProci;
{
// "processorsNN"
if (proci < rNum && Foam::exists(path/dirN/local))
{
found = true;
break;
}
}
else if (group.contains(proci))
{
// "processorsNN_start-end"
// - save the local proc offset
if (Foam::exists(path/dirN/local))
{
found = true;
break;
}
}
} }
} }
}
if (!found) // Since we are streaming anyhow, could also pack as tuple:
{ // Tuple2<fileName, label>
found = Foam::exists(fName);
// Collect file names on master of local communicator
const fileNameList fNames
(
Pstream::listGatherValues
(
fName,
handlerComm,
UPstream::msgType()
)
);
// Collect block numbers on master of local communicator
const labelList myBlockNumbers
(
Pstream::listGatherValues
(
myBlockNumber,
handlerComm,
UPstream::msgType()
)
);
// Determine for all whether the filename exists in the collated file.
boolList allFound;
if (UPstream::master(handlerComm))
{
allFound.resize(nHandlerProcs, false);
// Store nBlocks and index of file that was used for nBlocks
label nBlocks = -1;
label blockRanki = -1;
forAll(fNames, ranki)
{
if
(
blockRanki == -1
|| (fNames[ranki] != fNames[blockRanki])
)
{
blockRanki = ranki;
IFstream is(fNames[ranki]);
nBlocks = decomposedBlockData::getNumBlocks(is);
}
allFound[ranki] = (myBlockNumbers[ranki] < nBlocks);
}
}
// Scatter using the handler communicator
found = Pstream::listScatterValues
(
allFound,
handlerComm,
UPstream::msgType()
);
} }
return found; return found;
} }
} // End namespace
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
Foam::bitSet Foam::haveProcessorFile
(
const word& name, // eg "faces"
const fileName& instance, // eg "constant"
const fileName& local, // eg, polyMesh
const Time& runTime,
const bool verbose
)
{
const auto& handler = Foam::fileHandler();
const fileName fName
(
handler.filePath(runTime.path()/instance/local/name)
);
bool found = handler.isFile(fName);
// Assume non-collated (as fallback value).
// If everyone claims to have the file, use master to verify if
// collated is involved.
bool isCollated = false;
if (returnReduceAnd(found, UPstream::worldComm))
{
// Test for collated format.
// Note: can test only world-master. Since even host-collated will have
// same file format type for all processors
if (UPstream::master(UPstream::worldComm))
{
const bool oldParRun = UPstream::parRun(false);
if (IFstream is(fName); is.good())
{
IOobject io(name, instance, local, runTime);
io.readHeader(is);
isCollated = decomposedBlockData::isCollatedType(io);
}
UPstream::parRun(oldParRun);
}
Pstream::broadcast(isCollated, UPstream::worldComm);
}
// For collated, check that the corresponding blocks exist
if (isCollated)
{
found = checkFileExistenceCollated(handler, fName);
}
// Globally consistent information about who has the file
bitSet haveFileOnProc = bitSet::allGather(found, UPstream::worldComm);
if (verbose)
{
Info<< "Per processor availability of \""
<< name << "\" file in " << instance/local << nl
<< " " << flatOutput(haveFileOnProc) << nl << endl;
}
return haveFileOnProc;
}
Foam::boolList Foam::haveMeshFile
(
const word& name, // eg "faces"
const fileName& instance, // eg "constant"
const fileName& local, // eg, polyMesh
const Time& runTime,
const bool verbose
)
{
const auto& handler = Foam::fileHandler();
const fileName fName
(
handler.filePath(runTime.path()/instance/local/name)
);
bool found = handler.isFile(fName);
// Assume non-collated (as fallback value).
// If everyone claims to have the file, use master to verify if
// collated is involved.
bool isCollated = false;
if (returnReduceAnd(found, UPstream::worldComm))
{
// Test for collated format.
// Note: can test only world-master. Since even host-collated will have
// same file format type for all processors
if (UPstream::master(UPstream::worldComm))
{
const bool oldParRun = UPstream::parRun(false);
if (IFstream is(fName); is.good())
{
IOobject io(name, instance, local, runTime);
io.readHeader(is);
isCollated = decomposedBlockData::isCollatedType(io);
}
UPstream::parRun(oldParRun);
}
Pstream::broadcast(isCollated, UPstream::worldComm);
}
// For collated, check that the corresponding blocks exist
if (isCollated)
{
found = checkFileExistenceCollated(handler, fName);
}
// Globally consistent information about who has a mesh
boolList haveFileOnProc
(
UPstream::allGatherValues<bool>(found, UPstream::worldComm)
);
if (verbose)
{
Info<< "Per processor availability of \""
<< name << "\" file in " << instance/local << nl
<< " " << flatOutput(haveFileOnProc) << nl << endl;
}
return haveFileOnProc;
}
Foam::boolList Foam::haveMeshFile Foam::boolList Foam::haveMeshFile
( (
@ -135,143 +302,49 @@ Foam::boolList Foam::haveMeshFile
const bool verbose const bool verbose
) )
{ {
#if 0
// Simple directory scanning - too fragile
bool found = checkFileExistence(runTime.path()/meshPath/meshFile);
#else
// Trimmed-down version of lookupAndCacheProcessorsPath
// with Foam::exists() check. No caching.
// Check for two conditions:
// - file has to exist
// - if collated the entry has to exist inside the file
// Note: bypass fileOperation::filePath(IOobject&) since has problems
// with going to a different number of processors
// (in collated format). Use file-based searching instead
const auto& handler = Foam::fileHandler(); const auto& handler = Foam::fileHandler();
typedef fileOperation::procRangeType procRangeType;
const fileName fName const fileName fName
( (
handler.filePath(runTime.path()/meshPath/meshFile) handler.filePath(runTime.path()/meshPath/meshFile)
); );
bool found = handler.isFile(fName); bool found = handler.isFile(fName);
if (returnReduceAnd(found)) // worldComm
// Assume non-collated (as fallback value).
// If everyone claims to have the file, use master to verify if
// collated is involved.
bool isCollated = false;
if (returnReduceAnd(found, UPstream::worldComm))
{ {
// Bit tricky: avoid having all slaves open file since this involves // Test for collated format.
// reading it on master and broadcasting it. This fails if file > 2G.
// So instead only read on master
bool isCollated = false;
// Note: can test only world-master. Since even host-collated will have // Note: can test only world-master. Since even host-collated will have
// same file format type for all processors // same file format type for all processors
if (UPstream::master(UPstream::worldComm)) if (UPstream::master(UPstream::worldComm))
{ {
const bool oldParRun = UPstream::parRun(false); const bool oldParRun = UPstream::parRun(false);
IFstream is(fName); if (IFstream is(fName); is.good())
if (is.good())
{ {
IOobject io(meshFile, meshPath, runTime); IOobject io(meshFile, meshPath, runTime);
io.readHeader(is); io.readHeader(is);
isCollated = decomposedBlockData::isCollatedType(io); isCollated = decomposedBlockData::isCollatedType(io);
} }
UPstream::parRun(oldParRun); UPstream::parRun(oldParRun);
} }
Pstream::broadcast(isCollated); //UPstream::worldComm Pstream::broadcast(isCollated, UPstream::worldComm);
// Collect block-number in individual filenames (might differ
// on different processors)
if (isCollated)
{
const label nProcs = UPstream::nProcs(fileHandler().comm());
const label myProcNo = UPstream::myProcNo(fileHandler().comm());
// Collect file names on master of local communicator
const fileNameList fNames
(
Pstream::listGatherValues
(
fName,
fileHandler().comm(),
UPstream::msgType()
)
);
// Collect local block number
label myBlockNumber = -1;
{
procRangeType group;
label proci = fileOperation::detectProcessorPath(fName, group);
if (proci == -1 && group.empty())
{
// 'processorsXXX' format so contains all ranks
// according to worldComm
myBlockNumber = UPstream::myProcNo(UPstream::worldComm);
}
else
{
// 'processorsXXX_n-m' format so check for the
// relative rank
myBlockNumber = myProcNo;
}
}
const labelList myBlockNumbers
(
Pstream::listGatherValues
(
myBlockNumber,
fileHandler().comm(),
UPstream::msgType()
)
);
// Determine for all whether the filename exists in the collated
// file.
boolList allFound(nProcs, false);
if (UPstream::master(fileHandler().comm()))
{
// Store nBlocks and index of file that was used for nBlocks
label nBlocks = -1;
label blockRanki = -1;
forAll(fNames, ranki)
{
if
(
blockRanki == -1
|| (fNames[ranki] != fNames[blockRanki])
)
{
blockRanki = ranki;
IFstream is(fNames[ranki]);
nBlocks = decomposedBlockData::getNumBlocks(is);
}
allFound[ranki] = (myBlockNumbers[ranki] < nBlocks);
}
}
found = Pstream::listScatterValues
(
allFound,
fileHandler().comm(),
UPstream::msgType()
);
}
} }
#endif
// For collated, check that the corresponding blocks exist
if (isCollated)
{
found = checkFileExistenceCollated(handler, fName);
}
// Globally consistent information about who has a mesh // Globally consistent information about who has a mesh
boolList haveFileOnProc boolList haveFileOnProc

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012 OpenFOAM Foundation Copyright (C) 2012 OpenFOAM Foundation
Copyright (C) 2022-2023 OpenCFD Ltd. Copyright (C) 2022-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -48,15 +48,32 @@ namespace Foam
// Forward Declarations // Forward Declarations
class faMesh; class faMesh;
//- Check for availability of given file //- Check for availability of specified file (on all ranks)
bool checkFileExistence(const fileName& fName); bitSet haveProcessorFile
(
const word& name, // eg, "faces"
const fileName& instance, // eg, "constant"
const fileName& local, // eg, "polyMesh"
const Time& runTime,
const bool verbose = true
);
//- Check for availability of specified mesh file (default: "faces") //- Check for availability of specified file (on all ranks)
boolList haveMeshFile
(
const word& name, // eg, "faces"
const fileName& instance, // eg, "constant"
const fileName& local, // eg, "polyMesh"
const Time& runTime,
const bool verbose = true
);
//- Check for availability of specified mesh file
boolList haveMeshFile boolList haveMeshFile
( (
const Time& runTime, const Time& runTime,
const fileName& meshPath, const fileName& meshPath,
const word& meshFile = "faces", const word& meshFile,
const bool verbose = true const bool verbose = true
); );
@ -75,7 +92,7 @@ void masterMeshInstance
fileName& pointsInstance fileName& pointsInstance
); );
} } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -21,44 +21,59 @@ Requires
// Initially all possible objects that are available at the final time // Initially all possible objects that are available at the final time
List<wordHashSet> availableRegionObjectNames(meshes.size()); List<wordHashSet> availableRegionObjectNames(meshes.size());
List<wordHashSet> availableFaRegionObjectNames(meshes.size()); List<HashTable<wordHashSet>> availableFaRegionObjectNames(meshes.size());
forAll(meshes, regioni) forAll(meshes, regioni)
{ {
const auto& mesh = meshes[regioni]; const auto& mesh = meshes[regioni];
IOobjectList objects; IOobjectList objects;
IOobjectList faObjects; HashTable<IOobjectList> faObjects;
if (doConvertFields && !timeDirs.empty()) if (doConvertFields && !timeDirs.empty())
{ {
// const word& checkTimeDir = timeDirs.back().name();
// List of volume mesh objects for this instance // List of volume mesh objects for this instance
objects = IOobjectList(mesh, timeDirs.back().name()); objects = IOobjectList(mesh, timeDirs.back().name());
// List of area mesh objects (assuming single region)
faObjects = IOobjectList
(
mesh.time(),
timeDirs.back().name(),
faMesh::dbDir(mesh, word::null),
IOobjectOption::NO_REGISTER
);
if (fieldSelector) if (fieldSelector)
{ {
objects.filterObjects(fieldSelector); objects.filterObjects(fieldSelector);
faObjects.filterObjects(fieldSelector);
} }
// Remove "*_0" restart fields // Remove "*_0" restart fields
objects.prune_0(); objects.prune_0();
faObjects.prune_0();
if (!doPointValues) if (!doPointValues)
{ {
// Prune point fields if disabled // Prune point fields if disabled
objects.filterClasses(Foam::fieldTypes::is_point, true); objects.filterClasses(Foam::fieldTypes::is_point, true);
} }
// The finite-area regions and their fields for this volume region
// and instance
faObjects.reserve(areaRegionNames.size());
for (const word& areaName : areaRegionNames)
{
IOobjectList objs
(
faMesh::Registry(mesh),
timeDirs.back().name(),
polyMesh::regionName(areaName),
IOobjectOption::NO_REGISTER
);
if (fieldSelector)
{
objs.filterObjects(fieldSelector);
}
// Remove "*_0" restart fields
objs.prune_0();
faObjects(areaName) = std::move(objs);
}
} }
// Volume fields // Volume fields
@ -78,20 +93,29 @@ forAll(meshes, regioni)
} }
// Area fields // Area fields
if (!faObjects.empty()) for (const word& areaName : areaRegionNames)
{ {
wordList objectNames(faObjects.sortedNames()); wordList objectNames;
// Check availability for all times... (assuming single region) if (const auto iter = faObjects.cfind(areaName); iter.good())
checkData {
objectNames = iter.val().sortedNames();
// Check availability for all times...
checkData
(
faMesh::Registry(mesh),
timeDirs,
objectNames,
polyMesh::regionName(areaName)
);
}
availableFaRegionObjectNames[regioni].emplace_set
( (
mesh.time(), areaName,
timeDirs, std::move(objectNames)
objectNames,
faMesh::dbDir(mesh, word::null)
); );
availableFaRegionObjectNames[regioni] = objectNames;
} }
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2021-2022 OpenCFD Ltd. Copyright (C) 2021-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later. This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -15,12 +15,14 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
// Cases and meshes per volume region
PtrList<ensightCase> ensightCases(regionNames.size()); PtrList<ensightCase> ensightCases(regionNames.size());
PtrList<ensightMesh> ensightMeshes(regionNames.size()); PtrList<ensightMesh> ensightMeshes(regionNames.size());
PtrList<faMesh> meshesFa(regionNames.size()); // Per volume region can have multiple finite-area regions
PtrList<ensightCase> ensightCasesFa(regionNames.size()); List<PtrDynList<faMesh>> meshesFa(regionNames.size());
PtrList<ensightFaMesh> ensightMeshesFa(regionNames.size()); List<PtrDynList<ensightCase>> ensightCasesFa(regionNames.size());
List<PtrDynList<ensightFaMesh>> ensightMeshesFa(regionNames.size());
{ {
forAll(regionNames, regioni) forAll(regionNames, regioni)
@ -45,6 +47,7 @@ PtrList<ensightFaMesh> ensightMeshesFa(regionNames.size());
} }
} }
// Volume mesh
ensightMeshes.set ensightMeshes.set
( (
regioni, regioni,
@ -59,33 +62,60 @@ PtrList<ensightFaMesh> ensightMeshesFa(regionNames.size());
new ensightCase(ensCasePath, ensCaseName, caseOpts) new ensightCase(ensCasePath, ensCaseName, caseOpts)
); );
if (doFiniteArea) if (!doFiniteArea)
{ {
autoPtr<faMesh> faMeshPtr(faMesh::TryNew(mesh)); continue;
}
// Note: not every volume region is guaranteed to have
// any or all area region(s)
meshesFa[regioni].reserve_exact(areaRegionNames.size());
for (const word& areaName : areaRegionNames)
{
auto faMeshPtr = faMesh::TryNew(areaName, mesh);
if (faMeshPtr) if (faMeshPtr)
{ {
ensightCasesFa.set meshesFa[regioni].push_back(std::move(faMeshPtr));
(
regioni,
new ensightCase
(
ensCasePath/"finite-area",
"finite-area",
caseOpts
)
);
meshesFa.set(regioni, std::move(faMeshPtr));
ensightMeshesFa.set
(
regioni,
new ensightFaMesh(meshesFa[regioni])
);
ensightMeshesFa[regioni].verbose(optVerbose);
} }
} }
// Setup the ensight components
const label nAreas = meshesFa[regioni].size();
ensightCasesFa[regioni].reserve_exact(nAreas);
ensightMeshesFa[regioni].reserve_exact(nAreas);
for (const faMesh& areaMesh : meshesFa[regioni])
{
// Use regionName() - automatically filters for defaultRegion
const word& areaName = areaMesh.regionName();
if (areaName.empty())
{
// single-region
ensightCasesFa[regioni].emplace_back
(
ensCasePath/"finite-area",
"finite-area",
caseOpts
);
}
else
{
// multi-region
ensightCasesFa[regioni].emplace_back
(
ensCasePath/"finite-area"/areaName,
areaName,
caseOpts
);
}
auto& ensFaMesh = ensightMeshesFa[regioni].emplace_back(areaMesh);
ensFaMesh.verbose(optVerbose);
}
} }
} }

View File

@ -124,6 +124,7 @@ Usage
#include "OFstream.H" #include "OFstream.H"
#include "Pstream.H" #include "Pstream.H"
#include "HashOps.H" #include "HashOps.H"
#include "PtrDynList.H"
#include "regionProperties.H" #include "regionProperties.H"
#include "fvc.H" #include "fvc.H"
@ -172,6 +173,7 @@ int main(int argc, char *argv[])
argList::addVerboseOption(); argList::addVerboseOption();
#include "addAllRegionOptions.H" #include "addAllRegionOptions.H"
#include "addAllFaRegionOptions.H"
argList::addBoolOption argList::addBoolOption
( (
@ -439,6 +441,14 @@ int main(int argc, char *argv[])
// Handle -allRegions, -regions, -region // Handle -allRegions, -regions, -region
#include "getAllRegionOptions.H" #include "getAllRegionOptions.H"
// Handle -all-area-regions, -area-regions, -area-region
#include "getAllFaRegionOptions.H"
if (!doFiniteArea)
{
areaRegionNames.clear(); // For consistency
}
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// Directory management // Directory management
@ -518,29 +528,32 @@ int main(int argc, char *argv[])
polyMesh::readUpdateState meshState = mesh.readUpdate(); polyMesh::readUpdateState meshState = mesh.readUpdate();
const bool moving = (meshState != polyMesh::UNCHANGED); const bool moving = (meshState != polyMesh::UNCHANGED);
// Ensight // Ensight (fvMesh)
auto& ensCase = ensightCases[regioni]; auto& ensCase = ensightCases[regioni];
auto& ensMesh = ensightMeshes[regioni]; auto& ensMesh = ensightMeshes[regioni];
// Finite-area (can be missing)
auto* ensFaCasePtr = ensightCasesFa.get(regioni);
auto* ensFaMeshPtr = ensightMeshesFa.get(regioni);
ensCase.setTime(timeDirs[timei], timeIndex); ensCase.setTime(timeDirs[timei], timeIndex);
if (ensFaCasePtr)
// Finite-area (optional)
// Accounting exists for each volume region but may be empty
auto& ensFaCases = ensightCasesFa[regioni];
auto& ensFaMeshes = ensightMeshesFa[regioni];
for (auto& ensFaCase : ensFaCases)
{ {
ensFaCasePtr->setTime(timeDirs[timei], timeIndex); ensFaCase.setTime(timeDirs[timei], timeIndex);
} }
// Movement
if (moving) if (moving)
{ {
ensMesh.expire(); ensMesh.expire();
ensMesh.correct(); ensMesh.correct();
if (ensFaMeshPtr) for (auto& ensFaMesh : ensFaMeshes)
{ {
ensFaMeshPtr->expire(); ensFaMesh.expire();
ensFaMeshPtr->correct(); ensFaMesh.correct();
} }
} }
@ -555,15 +568,19 @@ int main(int argc, char *argv[])
} }
// finite-area // finite-area
if (ensFaCasePtr && ensFaMeshPtr) forAll(ensFaMeshes, areai)
{ {
autoPtr<ensightGeoFile> os = const auto& ensFaCase = ensFaCases[areai];
ensFaCasePtr->newGeometry(hasMovingMesh); const auto& ensFaMesh = ensFaMeshes[areai];
ensFaMeshPtr->write(os.ref()); autoPtr<ensightGeoFile> os =
ensFaCase.newGeometry(hasMovingMesh);
ensFaMesh.write(os.ref());
} }
} }
// Objects at this time // Objects at this time
IOobjectList objects(mesh, runTime.timeName()); IOobjectList objects(mesh, runTime.timeName());
@ -575,23 +592,37 @@ int main(int argc, char *argv[])
// Volume, internal, point fields // Volume, internal, point fields
#include "convertVolumeFields.H" #include "convertVolumeFields.H"
// The finite-area objects at this time // finite-area
IOobjectList faObjects; forAll(ensFaMeshes, areai)
if (ensFaMeshPtr)
{ {
faObjects = auto* ensFaCasePtr = ensFaCases.get(areai);
IOobjectList(ensFaMeshPtr->mesh(), runTime.timeName()); auto* ensFaMeshPtr = ensFaMeshes.get(areai);
faObjects.filterObjects // The finite-area region objects at this time
( IOobjectList faObjects;
availableFaRegionObjectNames[regioni]
); if (ensFaMeshPtr)
{
const word& areaName = ensFaMeshPtr->mesh().name();
faObjects = IOobjectList
(
faMesh::Registry(mesh),
runTime.timeName(),
polyMesh::regionName(areaName),
IOobjectOption::NO_REGISTER
);
faObjects.filterObjects
(
availableFaRegionObjectNames[regioni](areaName)
);
}
// The finiteArea fields
#include "convertAreaFields.H"
} }
// The finiteArea fields
#include "convertAreaFields.H"
// Lagrangian fields // Lagrangian fields
#include "convertLagrangian.H" #include "convertLagrangian.H"
} }
@ -604,14 +635,13 @@ int main(int argc, char *argv[])
// Write cases // Write cases
forAll(ensightCases, regioni) forAll(ensightCases, regioni)
{ {
// finite-volume
ensightCases[regioni].write(); ensightCases[regioni].write();
}
forAll(ensightCasesFa, regioni) // Finite-area (if any)
{ for (const auto& ensFaCase : ensightCasesFa[regioni])
if (ensightCasesFa.set(regioni))
{ {
ensightCasesFa[regioni].write(); ensFaCase.write();
} }
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2023 OpenCFD Ltd. Copyright (C) 2018-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -26,7 +26,6 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "readFields.H" #include "readFields.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
@ -42,26 +41,30 @@ Foam::label Foam::checkData
wordHashSet goodFields; wordHashSet goodFields;
IOobject io
(
"any-name", // placeholder
"constant", // placeholder
local,
obr,
IOobjectOption::NO_READ,
IOobjectOption::NO_WRITE,
IOobjectOption::NO_REGISTER
);
for (const word& fieldName : objectNames) for (const word& fieldName : objectNames)
{ {
// // If prune_0() not previously used... // In case prune_0() not previously used...
// if (objectNames.ends_with("_0")) continue; if (fieldName.ends_with("_0")) continue;
bool good = false; bool good = false;
for (const instant& inst : timeDirs) for (const instant& inst : timeDirs)
{ {
good = io.resetHeader(fieldName);
IOobject io.instance() = inst.name();
(
fieldName, good = io.typeHeaderOk<regIOobject>(false, false);
inst.name(),
local,
obr,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
).typeHeaderOk<volScalarField>(false, false);
if (!good) if (!good)
{ {

View File

@ -22,24 +22,66 @@ Description
// //
// No subsetting! // No subsetting!
if (doFiniteArea) if (doFiniteArea && !areaRegionNames.empty())
{ {
using reportFields = foamToVtkReportFields; using reportFields = foamToVtkReportFields;
autoPtr<faMesh> faMeshPtr; // The (region) polyMesh being used. No subsetting possible
const auto& basePolyMesh = meshProxy.baseMesh();
const label nAreaFields = faObjects.count(Foam::fieldTypes::is_area); for (const word& areaName : areaRegionNames)
if (nAreaFields || withMeshIds)
{ {
faMeshPtr = faMesh::TryNew(meshProxy.baseMesh()); const bool isDefaultRegion(polyMesh::regionName(areaName).empty());
}
if (faMeshPtr && (nAreaFields || withMeshIds)) // CAUTION
{ // If we want to have constant access to the HashTable:
const faMesh& areaMesh = faMeshPtr(); //
// (SEGFAULT)
// const auto& faObjs = faObjects.lookup(areaName, IOobjectList());
//
// Use an empty fallback to avoid binding to a temporary:
//
// const IOobjectList emptyObjectList;
// const auto& faObjs = faObjects.lookup(areaName, emptyObjectList);
reportFields::area(Info, faObjects); // Since we do not need the area fields afterwards,
// just move them out from the HashTable
IOobjectList faObjs;
if (auto iter = faObjects.find(areaName); iter.good())
{
faObjs = std::move(iter.val());
}
const label nAreaFields = faObjs.count(Foam::fieldTypes::is_area);
autoPtr<faMesh> faMeshPtr;
if (nAreaFields || withMeshIds)
{
faMeshPtr = faMesh::TryNew(areaName, basePolyMesh);
}
if (!faMeshPtr)
{
if (!isDefaultRegion)
{
// Report any area region specified but missing
// - silently ignore region0
Info<< "No area-mesh [" << polyMesh::regionName(areaName)
<< "] on volume-region ["
<< basePolyMesh.regionName() << "]" << endl;
}
continue;
}
const auto& areaMesh = faMeshPtr();
Info<< "Using area-mesh [" << polyMesh::regionName(areaName)
<< "] on volume-region ["
<< basePolyMesh.regionName() << "]" << endl;
reportFields::area(Info, faObjs);
const auto& pp = faMeshPtr->patch(); const auto& pp = faMeshPtr->patch();
@ -49,7 +91,12 @@ if (doFiniteArea)
writeOpts, writeOpts,
( (
outputDir/regionDir/"finite-area" outputDir/regionDir/"finite-area"
/ "finiteArea" + timeDesc / (
isDefaultRegion
? fileName("finiteArea")
: fileName(areaName/areaName)
)
+ timeDesc
), ),
UPstream::parRun() UPstream::parRun()
); );
@ -96,7 +143,7 @@ if (doFiniteArea)
( (
writer, writer,
areaMesh, areaMesh,
faObjects, faObjs,
true // syncPar true // syncPar
); );

View File

@ -135,13 +135,13 @@ Note
#include "emptyPolyPatch.H" #include "emptyPolyPatch.H"
#include "volPointInterpolation.H" #include "volPointInterpolation.H"
#include "faceZoneMesh.H" #include "faceZoneMesh.H"
#include "faMesh.H"
#include "areaFields.H" #include "areaFields.H"
#include "fvMeshSubsetProxy.H" #include "fvMeshSubsetProxy.H"
#include "faceSet.H" #include "faceSet.H"
#include "pointSet.H" #include "pointSet.H"
#include "HashOps.H" #include "HashOps.H"
#include "regionProperties.H" #include "regionProperties.H"
#include "stringListOps.H" // For stringListOps::findMatching()
#include "Cloud.H" #include "Cloud.H"
#include "readFields.H" #include "readFields.H"
@ -434,6 +434,7 @@ int main(int argc, char *argv[])
argList::addOptionCompat("one-boundary", {"allPatches", 1806}); argList::addOptionCompat("one-boundary", {"allPatches", 1806});
#include "addAllRegionOptions.H" #include "addAllRegionOptions.H"
#include "addAllFaRegionOptions.H"
argList::addOption argList::addOption
( (
@ -630,6 +631,16 @@ int main(int argc, char *argv[])
// Handle -allRegions, -regions, -region // Handle -allRegions, -regions, -region
#include "getAllRegionOptions.H" #include "getAllRegionOptions.H"
// Handle -all-area-regions, -area-regions, -area-region
#include "getAllFaRegionOptions.H"
if (!doFiniteArea)
{
areaRegionNames.clear(); // For consistency
}
// ------------------------------------------------------------------------
// Names for sets and zones // Names for sets and zones
word cellSelectionName; word cellSelectionName;
word faceSetName; word faceSetName;
@ -777,8 +788,11 @@ int main(int argc, char *argv[])
} }
} }
// fvMesh fields
IOobjectList objects; IOobjectList objects;
IOobjectList faObjects;
// faMesh fields (multiple finite-area regions per volume region)
HashTable<IOobjectList> faObjects;
if (doConvertFields) if (doConvertFields)
{ {
@ -786,33 +800,51 @@ int main(int argc, char *argv[])
objects = objects =
IOobjectList(meshProxy.baseMesh(), runTime.timeName()); IOobjectList(meshProxy.baseMesh(), runTime.timeName());
// List of area mesh objects (assuming single region)
faObjects =
IOobjectList
(
runTime,
runTime.timeName(),
faMesh::dbDir(meshProxy.baseMesh(), word::null),
IOobjectOption::NO_REGISTER
);
if (fieldSelector) if (fieldSelector)
{ {
objects.filterObjects(fieldSelector); objects.filterObjects(fieldSelector);
faObjects.filterObjects(fieldSelector);
} }
// Remove "*_0" restart fields // Remove "*_0" restart fields
objects.prune_0(); objects.prune_0();
faObjects.prune_0();
if (!doPointValues) if (!doPointValues)
{ {
// Prune point fields if disabled // Prune point fields if disabled
objects.filterClasses(Foam::fieldTypes::is_point, true); objects.filterClasses(Foam::fieldTypes::is_point, true);
} }
// Lists of finite-area fields
faObjects.reserve(areaRegionNames.size());
for (const word& areaName : areaRegionNames)
{
// The finite-area objects for given area region.
// Add as method to faMeshesRegistry?
IOobjectList objs
(
faMesh::Registry(meshProxy.baseMesh()),
runTime.timeName(),
polyMesh::regionName(areaName),
IOobjectOption::NO_REGISTER
);
if (fieldSelector)
{
objs.filterObjects(fieldSelector);
}
// Remove "*_0" restart fields
objs.prune_0();
if (!objs.empty())
{
faObjects.emplace_set(areaName, std::move(objs));
}
}
} }
if (processorFieldsOnly) if (processorFieldsOnly)
{ {
// Processor-patches only and continue // Processor-patches only and continue

View File

@ -1,10 +1,10 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/finiteArea/lnInclude \ -I$(LIB_SRC)/finiteArea/lnInclude
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lmeshTools \
-lfiniteVolume \ -lfiniteVolume \
-lfiniteArea \ -lfiniteArea \
-lmeshTools \
-lgenericPatchFields -lgenericPatchFields

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2022-2024 OpenCFD Ltd. Copyright (C) 2022-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -47,6 +47,7 @@ Description
#include "areaFields.H" #include "areaFields.H"
#include "coupledFvPatch.H" #include "coupledFvPatch.H"
#include "coupledFaPatch.H" #include "coupledFaPatch.H"
#include "regionProperties.H"
using namespace Foam; using namespace Foam;
@ -86,17 +87,18 @@ bool consumeUnusedType(const fieldDescription& fieldDesc, Istream& is)
//? typedef GeometricField<Type, faePatchField, areaMesh> fieldType3; //? typedef GeometricField<Type, faePatchField, areaMesh> fieldType3;
//? typedef GeometricField<Type, fvsPatchField, volMesh> fieldType4; //? typedef GeometricField<Type, fvsPatchField, volMesh> fieldType4;
if const bool isExpectedType
( (
fieldDesc.type() == fieldType1::typeName fieldDesc.type() == fieldType1::typeName
|| fieldDesc.type() == fieldType2::typeName || fieldDesc.type() == fieldType2::typeName
) );
if (isExpectedType)
{ {
(void) pTraits<Type>(is); (void) pTraits<Type>(is);
return true;
} }
return false; return isExpectedType;
} }
@ -122,13 +124,18 @@ bool setCellFieldType
( (
const fieldDescription& fieldDesc, const fieldDescription& fieldDesc,
const fvMesh& mesh, const fvMesh& mesh,
const labelList& selectedCells, const labelUList& selectedCells,
Istream& is Istream& is
) )
{ {
typedef GeometricField<Type, fvPatchField, volMesh> fieldType; typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
if (fieldDesc.type() != fieldType::typeName) const bool isExpectedType
(
fieldDesc.type() == fieldType::typeName
);
if (!isExpectedType)
{ {
return false; return false;
} }
@ -143,7 +150,9 @@ bool setCellFieldType
fieldDesc.name(), fieldDesc.name(),
mesh.thisDb().time().timeName(), mesh.thisDb().time().timeName(),
mesh.thisDb(), mesh.thisDb(),
IOobject::MUST_READ IOobjectOption::MUST_READ,
IOobjectOption::NO_WRITE,
IOobjectOption::NO_REGISTER
); );
bool found = fieldHeader.typeHeaderOk<fieldType>(true); bool found = fieldHeader.typeHeaderOk<fieldType>(true);
@ -151,13 +160,8 @@ bool setCellFieldType
if (!found) if (!found)
{ {
// Fallback to "constant" directory // Fallback to "constant" directory
fieldHeader = IOobject fieldHeader.resetHeader();
( fieldHeader.instance() = mesh.thisDb().time().constant();
fieldDesc.name(),
mesh.thisDb().time().constant(),
mesh.thisDb(),
IOobject::MUST_READ
);
found = fieldHeader.typeHeaderOk<fieldType>(true); found = fieldHeader.typeHeaderOk<fieldType>(true);
} }
@ -171,7 +175,7 @@ bool setCellFieldType
fieldType field(fieldHeader, mesh, false); fieldType field(fieldHeader, mesh, false);
if (isNull(selectedCells) || selectedCells.size() == field.size()) if (isNull(selectedCells) || (selectedCells.size() == field.size()))
{ {
field.primitiveFieldRef() = fieldValue; field.primitiveFieldRef() = fieldValue;
} }
@ -204,7 +208,7 @@ bool setCellFieldType
<< "Field " << fieldDesc.name() << " not found" << endl; << "Field " << fieldDesc.name() << " not found" << endl;
} }
return true; return isExpectedType;
} }
@ -216,13 +220,18 @@ bool setAreaFieldType
( (
const fieldDescription& fieldDesc, const fieldDescription& fieldDesc,
const faMesh& mesh, const faMesh& mesh,
const labelList& selectedFaces, const labelUList& selectedFaces,
Istream& is Istream& is
) )
{ {
typedef GeometricField<Type, faPatchField, areaMesh> fieldType; typedef GeometricField<Type, faPatchField, areaMesh> fieldType;
if (fieldDesc.type() != fieldType::typeName) const bool isExpectedType
(
fieldDesc.type() == fieldType::typeName
);
if (!isExpectedType)
{ {
return false; return false;
} }
@ -237,7 +246,9 @@ bool setAreaFieldType
fieldDesc.name(), fieldDesc.name(),
mesh.thisDb().time().timeName(), mesh.thisDb().time().timeName(),
mesh.thisDb(), mesh.thisDb(),
IOobject::MUST_READ IOobjectOption::MUST_READ,
IOobjectOption::NO_WRITE,
IOobjectOption::NO_REGISTER
); );
bool found = fieldHeader.typeHeaderOk<fieldType>(true); bool found = fieldHeader.typeHeaderOk<fieldType>(true);
@ -245,13 +256,8 @@ bool setAreaFieldType
if (!found) if (!found)
{ {
// Fallback to "constant" directory // Fallback to "constant" directory
fieldHeader = IOobject fieldHeader.resetHeader();
( fieldHeader.instance() = mesh.thisDb().time().constant(),
fieldDesc.name(),
mesh.thisDb().time().constant(),
mesh.thisDb(),
IOobject::MUST_READ
);
found = fieldHeader.typeHeaderOk<fieldType>(true); found = fieldHeader.typeHeaderOk<fieldType>(true);
} }
@ -292,7 +298,7 @@ bool setAreaFieldType
<< "Field " << fieldDesc.name() << " not found" << endl; << "Field " << fieldDesc.name() << " not found" << endl;
} }
return true; return isExpectedType;
} }
@ -304,13 +310,18 @@ bool setFaceFieldType
( (
const fieldDescription& fieldDesc, const fieldDescription& fieldDesc,
const fvMesh& mesh, const fvMesh& mesh,
const labelList& selectedFaces, const labelUList& selectedFaces,
Istream& is Istream& is
) )
{ {
typedef GeometricField<Type, fvPatchField, volMesh> fieldType; typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
if (fieldDesc.type() != fieldType::typeName) const bool isExpectedType
(
fieldDesc.type() == fieldType::typeName
);
if (!isExpectedType)
{ {
return false; return false;
} }
@ -325,7 +336,9 @@ bool setFaceFieldType
fieldDesc.name(), fieldDesc.name(),
mesh.thisDb().time().timeName(), mesh.thisDb().time().timeName(),
mesh.thisDb(), mesh.thisDb(),
IOobject::MUST_READ IOobjectOption::MUST_READ,
IOobjectOption::NO_WRITE,
IOobjectOption::NO_REGISTER
); );
bool found = fieldHeader.typeHeaderOk<fieldType>(true); bool found = fieldHeader.typeHeaderOk<fieldType>(true);
@ -333,13 +346,8 @@ bool setFaceFieldType
if (!found) if (!found)
{ {
// Fallback to "constant" directory // Fallback to "constant" directory
fieldHeader = IOobject fieldHeader.resetHeader();
( fieldHeader.instance() = mesh.thisDb().time().constant();
fieldDesc.name(),
mesh.thisDb().time().constant(),
mesh.thisDb(),
IOobject::MUST_READ
);
found = fieldHeader.typeHeaderOk<fieldType>(true); found = fieldHeader.typeHeaderOk<fieldType>(true);
} }
@ -355,15 +363,14 @@ bool setFaceFieldType
// Create flat list of selected faces and their value. // Create flat list of selected faces and their value.
Field<Type> allBoundaryValues(mesh.nBoundaryFaces()); Field<Type> allBoundaryValues(mesh.nBoundaryFaces());
forAll(field.boundaryField(), patchi) for (const auto& pfld : field.boundaryField())
{ {
SubField<Type> SubField<Type>
( (
allBoundaryValues, allBoundaryValues,
field.boundaryField()[patchi].size(), pfld.size(),
field.boundaryField()[patchi].patch().start() pfld.patch().offset()
- mesh.nInternalFaces() ) = pfld;
) = field.boundaryField()[patchi];
} }
// Override // Override
@ -424,8 +431,7 @@ bool setFaceFieldType
( (
allBoundaryValues, allBoundaryValues,
fieldBf[patchi].size(), fieldBf[patchi].size(),
fieldBf[patchi].patch().start() fieldBf[patchi].patch().offset()
- mesh.nInternalFaces()
); );
} }
} }
@ -445,7 +451,7 @@ bool setFaceFieldType
<< "Field " << fieldDesc.name() << " not found" << endl; << "Field " << fieldDesc.name() << " not found" << endl;
} }
return true; return isExpectedType;
} }
@ -460,7 +466,7 @@ struct setCellField
( (
const fieldDescription& fieldDesc, const fieldDescription& fieldDesc,
const fvMesh& m, const fvMesh& m,
const labelList& selectedCells, const labelUList& selectedCells,
Istream& is Istream& is
) )
{ {
@ -477,11 +483,11 @@ struct setCellField
class iNew class iNew
{ {
const fvMesh& mesh_; const fvMesh& mesh_;
const labelList& selected_; const labelUList& selected_;
public: public:
iNew(const fvMesh& mesh, const labelList& selectedCells) iNew(const fvMesh& mesh, const labelUList& selectedCells) noexcept
: :
mesh_(mesh), mesh_(mesh),
selected_(selectedCells) selected_(selectedCells)
@ -528,7 +534,7 @@ struct setFaceField
( (
const fieldDescription& fieldDesc, const fieldDescription& fieldDesc,
const fvMesh& m, const fvMesh& m,
const labelList& selectedFaces, const labelUList& selectedFaces,
Istream& is Istream& is
) )
{ {
@ -545,11 +551,11 @@ struct setFaceField
class iNew class iNew
{ {
const fvMesh& mesh_; const fvMesh& mesh_;
const labelList& selected_; const labelUList& selected_;
public: public:
iNew(const fvMesh& mesh, const labelList& selectedFaces) iNew(const fvMesh& mesh, const labelUList& selectedFaces) noexcept
: :
mesh_(mesh), mesh_(mesh),
selected_(selectedFaces) selected_(selectedFaces)
@ -596,7 +602,7 @@ struct setAreaField
( (
const fieldDescription& fieldDesc, const fieldDescription& fieldDesc,
const faMesh& m, const faMesh& m,
const labelList& selectedFaces, const labelUList& selectedFaces,
Istream& is Istream& is
) )
{ {
@ -613,11 +619,11 @@ struct setAreaField
class iNew class iNew
{ {
const faMesh& mesh_; const faMesh& mesh_;
const labelList& selected_; const labelUList& selected_;
public: public:
iNew(const faMesh& mesh, const labelList& selectedFaces) iNew(const faMesh& mesh, const labelUList& selectedFaces) noexcept
: :
mesh_(mesh), mesh_(mesh),
selected_(selectedFaces) selected_(selectedFaces)
@ -675,6 +681,7 @@ int main(int argc, char *argv[])
); );
#include "addRegionOption.H" #include "addRegionOption.H"
#include "addAllFaRegionOptions.H"
// ------------------------- // -------------------------
@ -686,15 +693,59 @@ int main(int argc, char *argv[])
#include "createNamedMesh.H" #include "createNamedMesh.H"
autoPtr<faMesh> faMeshPtr; // Handle -all-area-regions, -area-regions, -area-region
#include "getAllFaRegionOptions.H"
if (!args.found("no-finite-area")) if (args.found("no-finite-area"))
{ {
faMeshPtr = faMesh::TryNew(mesh); areaRegionNames.clear(); // For consistency
} }
if (faMeshPtr)
// ------------------------------------------------------------------------
PtrList<faMesh> faMeshes;
// Setup all area meshes on this region
if (!areaRegionNames.empty()) // ie, !args.found("no-finite-area")
{ {
Info<< "Detected finite-area mesh" << nl; faMeshes.resize(areaRegionNames.size());
label nGoodRegions(0);
for (const word& areaName : areaRegionNames)
{
autoPtr<faMesh> faMeshPtr = faMesh::TryNew(areaName, mesh);
if (faMeshPtr)
{
faMeshes.set(nGoodRegions++, std::move(faMeshPtr));
}
}
faMeshes.resize(nGoodRegions);
}
if (faMeshes.size() == 1)
{
Info<< "Using finite-area mesh";
if
(
const word& name = polyMesh::regionName(faMeshes[0].name());
!name.empty()
)
{
Info<< " [" << name << "]";
}
Info<< nl;
}
else if (faMeshes.size() > 1)
{
Info<< "Detected finite-area meshes:";
for (const faMesh& areaMesh : faMeshes)
{
Info<< " [" << areaMesh.name() << "]";
}
Info<< nl;
} }
const word dictName("setFieldsDict"); const word dictName("setFieldsDict");
@ -712,37 +763,45 @@ int main(int argc, char *argv[])
// Default field values // Default field values
if
(
const auto* eptr
= setFieldsDict.findEntry("defaultFieldValues", keyType::LITERAL)
)
{ {
const entry* eptr = ITstream& is = eptr->stream();
setFieldsDict.findEntry("defaultFieldValues", keyType::LITERAL);
if (eptr) Info<< "Setting volume field default values" << endl;
PtrList<setCellField> defaultFieldValues
(
is,
setCellField::iNew(mesh, labelList::null())
);
for (const faMesh& areaMesh : faMeshes)
{ {
ITstream& is = eptr->stream(); Info<< "Setting area field default values";
Info<< "Setting volume field default values" << endl; if
PtrList<setCellField> defaultFieldValues
( (
is, const word& name = polyMesh::regionName(areaMesh.name());
setCellField::iNew(mesh, labelList::null()) !name.empty()
); )
if (faMeshPtr)
{ {
const faMesh& areaMesh = faMeshPtr(); Info<< " [" << name << "]";
is.rewind();
Info<< "Setting area field default values" << endl;
PtrList<setAreaField> defaultFieldValues
(
is,
setAreaField::iNew(areaMesh, labelList::null())
);
} }
Info<< endl; Info<< endl;
is.rewind();
PtrList<setAreaField> defaultAreaFieldValues
(
is,
setAreaField::iNew(areaMesh, labelList::null())
);
} }
Info<< endl;
} }
@ -768,11 +827,15 @@ int main(int argc, char *argv[])
labelList selectedCells(subset.sortedToc()); labelList selectedCells(subset.sortedToc());
Info<< " Selected " {
<< returnReduce(selectedCells.size(), sumOp<label>()) FixedList<label, 2> stats;
<< '/' stats[0] = selectedCells.size();
<< returnReduce(mesh.nCells(), sumOp<label>()) stats[1] = mesh.nCells();
<< " cells" << nl; reduce(stats, sumOp<label>());
Info<< " Selected " << stats[0] << '/' << stats[1]
<< " cells" << nl;
}
ITstream& is = region.dict().lookup("fieldValues"); ITstream& is = region.dict().lookup("fieldValues");
@ -806,10 +869,8 @@ int main(int argc, char *argv[])
setFaceField::iNew(mesh, selectedFaces) setFaceField::iNew(mesh, selectedFaces)
); );
if (faMeshPtr) for (const faMesh& areaMesh : faMeshes)
{ {
const faMesh& areaMesh = faMeshPtr();
const labelUList& faceLabels = areaMesh.faceLabels(); const labelUList& faceLabels = areaMesh.faceLabels();
// Transcribe from mesh faces to finite-area addressing // Transcribe from mesh faces to finite-area addressing
@ -828,11 +889,15 @@ int main(int argc, char *argv[])
} }
areaFaces.resize(nUsed); areaFaces.resize(nUsed);
Info<< " Selected " {
<< returnReduce(areaFaces.size(), sumOp<label>()) FixedList<label, 2> stats;
<< '/' stats[0] = areaFaces.size();
<< returnReduce(faceLabels.size(), sumOp<label>()) stats[1] = faceLabels.size();
<< " area faces" << nl; reduce(stats, sumOp<label>());
Info<< " Selected " << stats[0] << '/' << stats[1]
<< " area faces for " << areaMesh.name() << endl;
}
is.rewind(); is.rewind();

View File

@ -9,7 +9,7 @@ faceSetOption/faceSetOption.C
derivedSources=sources/derived derivedSources=sources/derived
$(derivedSources)/externalHeatFluxSource/externalHeatFluxSource.C $(derivedSources)/externalHeatFluxSource/externalHeatFluxSource.C
$(derivedSources)/jouleHeatingSource/jouleHeatingSource.C $(derivedSources)/jouleHeatingSource/jouleHeatingSource.cxx
$(derivedSources)/contactHeatFluxSource/contactHeatFluxSource.C $(derivedSources)/contactHeatFluxSource/contactHeatFluxSource.C
$(derivedSources)/externalFileSource/externalFileSource.C $(derivedSources)/externalFileSource/externalFileSource.C

View File

@ -81,6 +81,33 @@ Foam::fa::option::option
active_(dict.getOrDefault("active", true)), active_(dict.getOrDefault("active", true)),
log(true) log(true)
{ {
// Suffix hint for variable names
if
(
coeffs_.readIfPresent("suffixing", suffixHint_)
|| dict.readIfPresent("suffixing", suffixHint_)
)
{
Switch sw = Switch::find(suffixHint_);
if (sw.good())
{
if (!sw) // No suffix
{
suffixHint_.clear();
}
}
else if (suffixHint_ == "default")
{
sw = true;
}
if (sw) // Default suffix
{
suffixHint_ = '_' + regionName_;
}
}
if (dict.readIfPresent("area", areaName_)) if (dict.readIfPresent("area", areaName_))
{ {
if (!sameRegionNames(areaName_, defaultAreaName)) if (!sameRegionNames(areaName_, defaultAreaName))
@ -95,9 +122,14 @@ Foam::fa::option::option
} }
} }
Log << incrIndent << indent << "Source: " << name_ Log << incrIndent << indent << "Source: " << name_;
<< " [" << polyMesh::regionName(areaName_) << ']' << endl
<< decrIndent; if (!polyMesh::regionName(areaName_).empty())
{
Log<< " [" << areaName_ << ']';
}
Info<< decrIndent << endl;
} }
@ -117,13 +149,20 @@ Foam::autoPtr<Foam::fa::option> Foam::fa::option::New
coeffs.readIfPresent("area", areaName); coeffs.readIfPresent("area", areaName);
Info<< indent Info<< indent
<< "Selecting finite-area option, type " << modelType << "Selecting finite-area option, type " << modelType;
<< " [" << polyMesh::regionName(areaName) << ']';
if (!sameRegionNames(areaName, defaultAreaName)) if (sameRegionNames(areaName, defaultAreaName))
{ {
Info<< " != " << defaultAreaName << nl; if (!polyMesh::regionName(areaName).empty())
{
Info<< " [" << areaName << ']';
}
} }
else
{
Info<< " [" << areaName << "] != [" << defaultAreaName << ']';
}
Info<< endl; Info<< endl;
mesh.time().libs().open mesh.time().libs().open

View File

@ -65,10 +65,13 @@ Usage
--> the selected faOption settings | dictionary | no | - --> the selected faOption settings | dictionary | no | -
active | Flag to (de)activate faOption | bool | no | true active | Flag to (de)activate faOption | bool | no | true
log | Flag to log faOption-related info | bool | no | true log | Flag to log faOption-related info | bool | no | true
suffixing | Suffix hint for option variables | word | no | -
\endtable \endtable
Note Note
- Source/sink options are to be added to the right-hand side of equations. - Source/sink options are to be added to the right-hand side of equations.
- Suffixing (true|false|none|default|...) currently selects between
no suffix and ('_'+region).
SourceFiles SourceFiles
faOption.C faOption.C
@ -136,6 +139,9 @@ protected:
//- The model region name (finite-area) //- The model region name (finite-area)
word regionName_; word regionName_;
//- Suffix hint for variable names (default: "")
word suffixHint_;
// Protected Member Functions // Protected Member Functions
@ -273,7 +279,7 @@ public:
//- The source name //- The source name
const word& name() const noexcept { return name_; } const word& name() const noexcept { return name_; }
//- Return const access to the mesh database //- Return const access to the volume mesh
const fvMesh& mesh() const noexcept { return mesh_; } const fvMesh& mesh() const noexcept { return mesh_; }
//- Return dictionary //- Return dictionary
@ -304,6 +310,18 @@ public:
inline bool active(bool on) noexcept; inline bool active(bool on) noexcept;
// Helper Functions
//- The suffix hint when generating variable names
const word& suffixHint() const noexcept { return suffixHint_; }
//- Return the concatenation of \p base and the suffix hint
inline word suffixed(const char* base) const;
//- Return the concatenation of \p base and the suffix hint
inline word suffixed(const std::string& base) const;
// Checks // Checks
//- Is the source active? //- Is the source active?

View File

@ -61,4 +61,18 @@ inline const Foam::volSurfaceMapping& Foam::fa::option::vsm() const
} }
inline Foam::word
Foam::fa::option::suffixed(const char* base) const
{
return word(base + suffixHint_);
}
inline Foam::word
Foam::fa::option::suffixed(const std::string& base) const
{
return word(base + suffixHint_);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -27,7 +27,6 @@ License
#include "faOptions.H" #include "faOptions.H"
#include "faMesh.H" #include "faMesh.H"
#include "faMeshesRegistry.H"
#include "Time.H" #include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -68,7 +67,7 @@ Foam::IOobject createIOobject
lookupName, lookupName,
mesh.time().constant(), mesh.time().constant(),
// located under finite-area // located under finite-area
faMeshesRegistry::New(mesh).thisDb(), faMesh::Registry(mesh),
IOobjectOption::MUST_READ, IOobjectOption::MUST_READ,
IOobjectOption::NO_WRITE, IOobjectOption::NO_WRITE,
IOobjectOption::REGISTER IOobjectOption::REGISTER
@ -188,11 +187,7 @@ Foam::fa::options& Foam::fa::options::New
); );
// Registered under finite-area? // Registered under finite-area?
auto* ptr = auto* ptr = faMesh::Registry(mesh).getObjectPtr<fa::options>(lookupName);
faMeshesRegistry::New(mesh).thisDb().getObjectPtr<fa::options>
(
lookupName
);
if (!ptr && polyMesh::regionName(defaultAreaName).empty()) if (!ptr && polyMesh::regionName(defaultAreaName).empty())
{ {

View File

@ -30,7 +30,6 @@ License
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "volFields.H" #include "volFields.H"
#include "famSup.H" #include "famSup.H"
#include "zeroGradientFaPatchFields.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
@ -57,13 +56,10 @@ Foam::fa::contactHeatFluxSource::contactHeatFluxSource
: :
fa::faceSetOption(sourceName, modelType, dict, mesh, defaultAreaName), fa::faceSetOption(sourceName, modelType, dict, mesh, defaultAreaName),
TName_(dict.getOrDefault<word>("T", "T")), TName_(dict.getOrDefault<word>("T", "T")),
TprimaryName_(dict.get<word>("Tprimary")), TprimaryName_(dict.getOrDefault<word>("Tprimary", "T")),
Tprimary_(mesh_.lookupObject<volScalarField>(TprimaryName_)), Tprimary_(mesh_.lookupObject<volScalarField>(TprimaryName_)),
thicknessLayers_(),
kappaLayers_(),
contactRes_(0), contactRes_(0),
curTimeIndex_(-1), curTimeIndex_(-1)
coupling_()
{ {
fieldNames_.resize(1, TName_); fieldNames_.resize(1, TName_);
@ -131,30 +127,30 @@ void Foam::fa::contactHeatFluxSource::addSup
const label fieldi const label fieldi
) )
{ {
if (isActive()) if (!isActive())
{ {
DebugInfo return;
<< name() << ": applying source to " }
<< eqn.psi().name() << endl;
if (curTimeIndex_ != mesh().time().timeIndex()) DebugInfo<< name() << ": applying source to " << eqn.psi().name() << endl;
{
tmp<DimensionedField<scalar, areaMesh>> htcw(htc());
// Wall temperature - mapped from primary field to finite-area if (curTimeIndex_ != mesh().time().timeIndex())
auto Twall = DimensionedField<scalar, areaMesh>::New {
( tmp<DimensionedField<scalar, areaMesh>> htcw(htc());
"Tw_" + option::name(),
regionMesh(),
dimensionedScalar(dimTemperature, Zero)
);
vsm().mapInternalToSurface<scalar>(Tprimary_, Twall.ref().field()); // Wall temperature - mapped from primary field to finite-area
auto Twall = DimensionedField<scalar, areaMesh>::New
(
"Tw_" + option::name(),
regionMesh(),
dimensionedScalar(dimTemperature, Zero)
);
eqn += -fam::Sp(htcw(), eqn.psi()) + htcw()*Twall; vsm().mapInternalToSurface<scalar>(Tprimary_, Twall.ref().field());
curTimeIndex_ = mesh().time().timeIndex(); eqn += -fam::Sp(htcw(), eqn.psi()) + htcw()*Twall;
}
curTimeIndex_ = mesh().time().timeIndex();
} }
} }
@ -190,8 +186,14 @@ bool Foam::fa::contactHeatFluxSource::read(const dictionary& dict)
const labelList& patches = regionMesh().whichPolyPatches(); const labelList& patches = regionMesh().whichPolyPatches();
coupling_.clear(); if (patches.empty())
coupling_.resize(patches.empty() ? 0 : (patches.last()+1)); {
coupling_.clear();
}
else
{
coupling_.resize_null(patches.back()+1);
}
for (const label patchi : patches) for (const label patchi : patches)
{ {

View File

@ -40,6 +40,8 @@ Usage
{ {
// Mandatory entries (unmodifiable) // Mandatory entries (unmodifiable)
type contactHeatFluxSource; type contactHeatFluxSource;
// Optional entries (unmodifiable)
Tprimary <TprimaryFieldName>; Tprimary <TprimaryFieldName>;
// Optional entries (runtime modifiable) // Optional entries (runtime modifiable)
@ -60,12 +62,19 @@ Usage
\table \table
Property | Description | Type | Reqd | Dflt Property | Description | Type | Reqd | Dflt
type | Type name: contactHeatFluxSource | word | yes | - type | Type name: contactHeatFluxSource | word | yes | -
Tprimary | Name of primary temperature field | word | yes | -
T | Name of operand temperature field | word | no | T T | Name of operand temperature field | word | no | T
Tprimary | Name of primary temperature field | word | no | T
thicknessLayers | List of thicknesses of layers | scalarList | no | - thicknessLayers | List of thicknesses of layers | scalarList | no | -
kappaLayers | List of conductivities of layers | scalarList | cndtnl | - kappaLayers | List of conductivities of layers | scalarList | cndtnl | -
\endtable \endtable
Fields/variables used:
\table
Property | Description | Type | Deflt
T | Temperature | shell | T
Tprimary | Temperature | volume | T
\endtable
The inherited entries are elaborated in: The inherited entries are elaborated in:
- \link faOption.H \endlink - \link faOption.H \endlink
- \link faceSetOption.H \endlink - \link faceSetOption.H \endlink
@ -124,13 +133,13 @@ class contactHeatFluxSource
// Private Data // Private Data
//- Name of temperature field //- Name of shell temperature field (default: "T")
word TName_; word TName_;
//- Name of primary temperature field //- Name of volume temperature field (default: "T")
word TprimaryName_; const word TprimaryName_;
//- Primary region temperature //- Primary (volume) region temperature
const volScalarField& Tprimary_; const volScalarField& Tprimary_;
//- Thickness of layers //- Thickness of layers

View File

@ -72,10 +72,6 @@ Foam::fa::externalHeatFluxSource::externalHeatFluxSource
fa::faceSetOption(sourceName, modelType, dict, m, defaultAreaName), fa::faceSetOption(sourceName, modelType, dict, m, defaultAreaName),
mode_(operationModeNames.get("mode", dict)), mode_(operationModeNames.get("mode", dict)),
TName_(dict.getOrDefault<word>("T", "T")), TName_(dict.getOrDefault<word>("T", "T")),
Q_(nullptr),
q_(nullptr),
h_(nullptr),
Ta_(nullptr),
emissivity_(dict.getOrDefault<scalar>("emissivity", 0)) emissivity_(dict.getOrDefault<scalar>("emissivity", 0))
{ {
fieldNames_.resize(1, TName_); fieldNames_.resize(1, TName_);
@ -205,6 +201,11 @@ bool Foam::fa::externalHeatFluxSource::read(const dictionary& dict)
mode_ = operationModeNames.get("mode", dict); mode_ = operationModeNames.get("mode", dict);
Q_.reset(nullptr);
q_.reset(nullptr);
h_.reset(nullptr);
Ta_.reset(nullptr);
switch (mode_) switch (mode_)
{ {
case fixedPower: case fixedPower:

View File

@ -103,7 +103,7 @@ Usage
\verbatim \verbatim
power | Use fixed power (supply Q) power | Use fixed power (supply Q)
flux | Use fixed heat flux (supply q) flux | Use fixed heat flux (supply q)
coefficient | Use fixes heat transfer coefficient (supply h and T) coefficient | Use fixes heat transfer coefficient (supply h and Ta)
\endverbatim \endverbatim
See also See also
@ -159,7 +159,7 @@ private:
//- Operation mode //- Operation mode
operationMode mode_; operationMode mode_;
//- Name of temperature field //- Name of shell temperature field (default: "T")
word TName_; word TName_;
//- Heat power [W] //- Heat power [W]
@ -174,7 +174,7 @@ private:
//- Ambient temperature [K] //- Ambient temperature [K]
autoPtr<Function1<scalar>> Ta_; autoPtr<Function1<scalar>> Ta_;
//- Optional surface emissivity for radiative transfer to ambient //- Surface emissivity for radiative transfer to ambient (default: 0)
scalar emissivity_; scalar emissivity_;

View File

@ -115,23 +115,30 @@ Usage
- \link faceSetOption.H \endlink - \link faceSetOption.H \endlink
Note Note
- \c anisotropicElectricalConductivity=true enables If the \c sigma entry is present, the electrical conductivity is specified
anisotropic (tensorial) electrical conductivity. as a function of temperature using a \c Function1 type, otherwise
- \c anisotropicElectricalConductivity=false enables the \c sigma field will be read from file.
isotropic (scalar) electrical conductivity. When the \c anisotropicElectricalConductivity flag is set to \c true,
- The electrical conductivity can be specified using either: \c sigma should be specified as a \em tensor quantity instead of as
- If the \c sigma entry is present the electrical conductivity is specified an isotropic \em scalar quantity.
as a function of temperature using a \c Function1 type.
- If not present the \c sigma field will be read from file. BREAKING Naming changes from 2056 and earlier for the fields:
- If the \c anisotropicElectricalConductivity flag is set to \c true, \table
\c sigma should be specified as a tensor quantity. Field | Scoped names | Scoped names (old)
V | \<scope\>:V (suffix) | \<scope\>:V_ + regionName
sigma | \<scope\>:sigma (suffix) | \<scope\>:sigma_ + regionName
\endtable
It is possible to replicate the older naming by specifying
the \c suffixing to ('_' + regionName).
See also See also
- Foam::Function1 - Foam::Function1
- Foam::fv::jouleHeatingSource
SourceFiles SourceFiles
jouleHeatingSource.C jouleHeatingSource.cxx
jouleHeatingSourceTemplates.C jouleHeatingSourceImpl.cxx
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -188,13 +195,13 @@ class jouleHeatingSource
void initialiseSigma void initialiseSigma
( (
const dictionary& dict, const dictionary& dict,
autoPtr<Function1<Type>>& sigmaVsTPtr autoPtr<Function1<Type>>& sigmaFunctionPtr
); );
//- Update the electrical conductivity field //- Update the electrical conductivity field
template<class Type> template<class Type>
const GeometricField<Type, faPatchField, areaMesh>& const GeometricField<Type, faPatchField, areaMesh>&
updateSigma(const autoPtr<Function1<Type>>& sigmaVsTPtr) const; updateSigma(const autoPtr<Function1<Type>>& sigmaFunctionPtr) const;
public: public:
@ -229,22 +236,22 @@ public:
// Member Functions // Member Functions
// Evaluation // Evaluation
//- Add explicit contribution to compressible momentum equation //- Add explicit contribution to energy equation
virtual void addSup virtual void addSup
( (
const areaScalarField& h, const areaScalarField& h,
const areaScalarField& rho, const areaScalarField& rho,
faMatrix<scalar>& eqn, faMatrix<scalar>& eqn,
const label fieldi const label fieldi
); );
// IO // IO
//- Read source dictionary //- Read source dictionary
virtual bool read(const dictionary& dict); virtual bool read(const dictionary& dict);
}; };
@ -255,12 +262,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "jouleHeatingSourceTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -42,6 +42,12 @@ namespace fa
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Implementation
#include "jouleHeatingSourceImpl.cxx"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fa::jouleHeatingSource::jouleHeatingSource Foam::fa::jouleHeatingSource::jouleHeatingSource
@ -59,7 +65,7 @@ Foam::fa::jouleHeatingSource::jouleHeatingSource
( (
IOobject IOobject
( (
IOobject::scopedName(typeName, "V_" + regionName_), suffixed(IOobject::scopedName(typeName, "V")),
regionMesh().thisDb().time().timeName(), regionMesh().thisDb().time().timeName(),
regionMesh().thisDb(), regionMesh().thisDb(),
IOobject::MUST_READ, IOobject::MUST_READ,
@ -68,8 +74,6 @@ Foam::fa::jouleHeatingSource::jouleHeatingSource
), ),
regionMesh() regionMesh()
), ),
scalarSigmaVsTPtr_(nullptr),
tensorSigmaVsTPtr_(nullptr),
curTimeIndex_(-1), curTimeIndex_(-1),
nIter_(1), nIter_(1),
anisotropicElectricalConductivity_(false) anisotropicElectricalConductivity_(false)
@ -78,6 +82,8 @@ Foam::fa::jouleHeatingSource::jouleHeatingSource
fa::option::resetApplied(); fa::option::resetApplied();
read(dict);
if (anisotropicElectricalConductivity_) if (anisotropicElectricalConductivity_)
{ {
Info<< " Using tensor electrical conductivity" << endl; Info<< " Using tensor electrical conductivity" << endl;
@ -90,8 +96,6 @@ Foam::fa::jouleHeatingSource::jouleHeatingSource
initialiseSigma(coeffs_, scalarSigmaVsTPtr_); initialiseSigma(coeffs_, scalarSigmaVsTPtr_);
} }
read(dict);
} }
@ -105,12 +109,14 @@ void Foam::fa::jouleHeatingSource::addSup
const label fieldi const label fieldi
) )
{ {
if (isActive()) if (!isActive())
{ {
DebugInfo return;
<< name() << ": applying source to " }
<< eqn.psi().name() << endl;
DebugInfo<< name() << ": applying source to " << eqn.psi().name() << endl;
{
if (curTimeIndex_ != mesh().time().timeIndex()) if (curTimeIndex_ != mesh().time().timeIndex())
{ {
for (label i = 0; i < nIter_; ++i) for (label i = 0; i < nIter_; ++i)
@ -118,8 +124,7 @@ void Foam::fa::jouleHeatingSource::addSup
if (anisotropicElectricalConductivity_) if (anisotropicElectricalConductivity_)
{ {
// Update sigma as a function of T if required // Update sigma as a function of T if required
const areaTensorField& sigma = const auto& sigma = updateSigma(tensorSigmaVsTPtr_);
updateSigma(tensorSigmaVsTPtr_);
// Solve the electrical potential equation // Solve the electrical potential equation
faScalarMatrix VEqn(fam::laplacian(h*sigma, V_)); faScalarMatrix VEqn(fam::laplacian(h*sigma, V_));
@ -129,8 +134,7 @@ void Foam::fa::jouleHeatingSource::addSup
else else
{ {
// Update sigma as a function of T if required // Update sigma as a function of T if required
const areaScalarField& sigma = const auto& sigma = updateSigma(scalarSigmaVsTPtr_);
updateSigma(scalarSigmaVsTPtr_);
// Solve the electrical potential equation // Solve the electrical potential equation
faScalarMatrix VEqn(fam::laplacian(h*sigma, V_)); faScalarMatrix VEqn(fam::laplacian(h*sigma, V_));
@ -145,7 +149,7 @@ void Foam::fa::jouleHeatingSource::addSup
// Add the Joule heating contribution // Add the Joule heating contribution
const word sigmaName const word sigmaName
( (
IOobject::scopedName(typeName, "sigma_" + regionName_) IOobject::scopedName(typeName, "sigma") + suffixHint()
); );
areaVectorField gradV("gradV", fac::grad(V_)); areaVectorField gradV("gradV", fac::grad(V_));
@ -162,15 +166,13 @@ void Foam::fa::jouleHeatingSource::addSup
if (anisotropicElectricalConductivity_) if (anisotropicElectricalConductivity_)
{ {
const auto& sigma = const auto& sigma = obr.lookupObject<areaTensorField>(sigmaName);
obr.lookupObject<areaTensorField>(sigmaName);
tsource = (h*sigma & gradV) & gradV; tsource = (h*sigma & gradV) & gradV;
} }
else else
{ {
const auto& sigma = const auto& sigma = obr.lookupObject<areaScalarField>(sigmaName);
obr.lookupObject<areaScalarField>(sigmaName);
tsource = (h*sigma*gradV) & gradV; tsource = (h*sigma*gradV) & gradV;
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2024 OpenCFD Ltd. Copyright (C) 2019-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -33,16 +33,21 @@ template<class Type>
void Foam::fa::jouleHeatingSource::initialiseSigma void Foam::fa::jouleHeatingSource::initialiseSigma
( (
const dictionary& dict, const dictionary& dict,
autoPtr<Function1<Type>>& sigmaVsTPtr autoPtr<Function1<Type>>& sigmaFunctionPtr
) )
{ {
typedef GeometricField<Type, faPatchField, areaMesh> FieldType; typedef GeometricField<Type, faPatchField, areaMesh> FieldType;
const word sigmaName
(
IOobject::scopedName(typeName, "sigma") + suffixHint()
);
auto& obr = regionMesh().thisDb(); auto& obr = regionMesh().thisDb();
IOobject io IOobject io
( (
IOobject::scopedName(typeName, "sigma_" + regionName_), sigmaName,
obr.time().timeName(), obr.time().timeName(),
obr, obr,
IOobject::NO_READ, IOobject::NO_READ,
@ -52,11 +57,11 @@ void Foam::fa::jouleHeatingSource::initialiseSigma
autoPtr<FieldType> tsigma; autoPtr<FieldType> tsigma;
if (dict.found("sigma")) // Is sigma defined using a Function1 type?
{ sigmaFunctionPtr = Function1<Type>::NewIfPresent("sigma", dict, &mesh_);
// Sigma to be defined using a Function1 type
sigmaVsTPtr = Function1<Type>::New("sigma", dict, &mesh_);
if (sigmaFunctionPtr)
{
tsigma.reset tsigma.reset
( (
new FieldType new FieldType
@ -89,31 +94,34 @@ template<class Type>
const Foam::GeometricField<Type, Foam::faPatchField, Foam::areaMesh>& const Foam::GeometricField<Type, Foam::faPatchField, Foam::areaMesh>&
Foam::fa::jouleHeatingSource::updateSigma Foam::fa::jouleHeatingSource::updateSigma
( (
const autoPtr<Function1<Type>>& sigmaVsTPtr const autoPtr<Function1<Type>>& sigmaFunctionPtr
) const ) const
{ {
typedef GeometricField<Type, faPatchField, areaMesh> FieldType; typedef GeometricField<Type, faPatchField, areaMesh> FieldType;
const word sigmaName
(
IOobject::scopedName(typeName, "sigma") + suffixHint()
);
const auto& obr = regionMesh().thisDb(); const auto& obr = regionMesh().thisDb();
auto& sigma = auto& sigma = obr.lookupObjectRef<FieldType>(sigmaName);
obr.lookupObjectRef<FieldType>
(
IOobject::scopedName(typeName, "sigma_" + regionName_)
);
if (!sigmaVsTPtr) if (!sigmaFunctionPtr)
{ {
// Electrical conductivity field, sigma, was specified by the user // Electrical conductivity field, sigma, was specified by the user
return sigma; return sigma;
} }
const auto& sigmaFunction = sigmaFunctionPtr();
const auto& T = obr.lookupObject<areaScalarField>(TName_); const auto& T = obr.lookupObject<areaScalarField>(TName_);
// Internal field // Internal field
forAll(sigma, i) forAll(sigma, i)
{ {
sigma[i] = sigmaVsTPtr->value(T[i]); sigma[i] = sigmaFunction.value(T[i]);
} }
@ -127,7 +135,7 @@ Foam::fa::jouleHeatingSource::updateSigma
const scalarField& Tbf = T.boundaryField()[patchi]; const scalarField& Tbf = T.boundaryField()[patchi];
forAll(pf, facei) forAll(pf, facei)
{ {
pf[facei] = sigmaVsTPtr->value(Tbf[facei]); pf[facei] = sigmaFunction.value(Tbf[facei]);
} }
} }
} }

View File

@ -28,6 +28,7 @@ License
#include "faMesh.H" #include "faMesh.H"
#include "faMeshBoundaryHalo.H" #include "faMeshBoundaryHalo.H"
#include "faMeshesRegistry.H"
#include "faGlobalMeshData.H" #include "faGlobalMeshData.H"
#include "Time.H" #include "Time.H"
#include "polyMesh.H" #include "polyMesh.H"
@ -159,6 +160,12 @@ const Foam::objectRegistry* Foam::faMesh::registry(const polyMesh& pMesh)
// return obr.cfindObject<objectRegistry>(faMesh::prefix()); // return obr.cfindObject<objectRegistry>(faMesh::prefix());
// } // }
// Forwarding
const Foam::objectRegistry& Foam::faMesh::Registry(const polyMesh& pMesh)
{
return faMeshesRegistry::Registry(pMesh);
}
const Foam::faMesh& Foam::faMesh::mesh const Foam::faMesh& Foam::faMesh::mesh
( (

View File

@ -751,10 +751,14 @@ public:
// Database // Database
//- The parent registry containing all finite-area meshes //- Find the singleton parent registry (on the polyMesh)
//- on the polyMesh. //- that contains all objects related to finite-area.
static const objectRegistry* registry(const polyMesh& pMesh); static const objectRegistry* registry(const polyMesh& pMesh);
//- Return the singleton parent registry (on the polyMesh)
//- that contains all objects related to finite-area.
static const objectRegistry& Registry(const polyMesh& pMesh);
//- The single-region finite-area region on the polyMesh. //- The single-region finite-area region on the polyMesh.
//- Uses lookupObject semantics - Fatal if non-existent //- Uses lookupObject semantics - Fatal if non-existent
static const faMesh& mesh(const polyMesh& pMesh); static const faMesh& mesh(const polyMesh& pMesh);

View File

@ -27,8 +27,8 @@ License
#include "faMesh.H" #include "faMesh.H"
#include "faMeshesRegistry.H" #include "faMeshesRegistry.H"
#include "Time.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -43,6 +43,7 @@ Foam::faMeshRegistry::faMeshRegistry
IOobject IOobject
( (
(areaName.empty() ? polyMesh::defaultRegion : areaName), (areaName.empty() ? polyMesh::defaultRegion : areaName),
mesh.thisDb().time().timeName(),
faMeshesRegistry::New(mesh).thisDb(), faMeshesRegistry::New(mesh).thisDb(),
IOobjectOption::NO_READ, IOobjectOption::NO_READ,
IOobjectOption::AUTO_WRITE, IOobjectOption::AUTO_WRITE,

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2023-2024 OpenCFD Ltd. Copyright (C) 2023-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -86,6 +86,8 @@ bool Foam::faMeshesRegistry::writeObject
const bool writeOnProc const bool writeOnProc
) const ) const
{ {
// Could also restrict to faMesh only...
//
// for (const faMesh& m : objects_.csorted<faMesh>()) // for (const faMesh& m : objects_.csorted<faMesh>())
// { // {
// m.write(writeOnProc); // m.write(writeOnProc);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2023-2024 OpenCFD Ltd. Copyright (C) 2023-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -144,14 +144,34 @@ public:
explicit faMeshesRegistry(const polyMesh& mesh); explicit faMeshesRegistry(const polyMesh& mesh);
// Factory Methods
//- Return the registry of objects on the singleton.
// Same as New(mesh).thisDb()
FOAM_NO_DANGLING_REFERENCE //< Reference stored in registry
static const objectRegistry& Registry(const polyMesh& mesh)
{
return MeshObject_type::New(mesh).thisDb();
}
// Database // Database
//- Return the object registry // It redirects to the private objects but uses some
// objectRegistry method naming
//- The registry of the objects
const objectRegistry& thisDb() const noexcept const objectRegistry& thisDb() const noexcept
{ {
return objects_; return objects_;
} }
//- Local relative to time
const fileName& dbDir() const
{
return objects_.dbDir();
}
//- The polyMesh reference //- The polyMesh reference
const polyMesh& mesh() const noexcept const polyMesh& mesh() const noexcept
{ {

View File

@ -14,7 +14,7 @@ $(derivedSources)/buoyancyEnergy/buoyancyEnergy.C
$(derivedSources)/buoyancyForce/buoyancyForce.C $(derivedSources)/buoyancyForce/buoyancyForce.C
$(derivedSources)/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C $(derivedSources)/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C
$(derivedSources)/explicitPorositySource/explicitPorositySource.C $(derivedSources)/explicitPorositySource/explicitPorositySource.C
$(derivedSources)/jouleHeatingSource/jouleHeatingSource.C $(derivedSources)/jouleHeatingSource/jouleHeatingSource.cxx
$(derivedSources)/meanVelocityForce/meanVelocityForce.C $(derivedSources)/meanVelocityForce/meanVelocityForce.C
$(derivedSources)/meanVelocityForce/patchMeanVelocityForce/patchMeanVelocityForce.C $(derivedSources)/meanVelocityForce/patchMeanVelocityForce/patchMeanVelocityForce.C
$(derivedSources)/multiphaseStabilizedTurbulence/multiphaseStabilizedTurbulence.C $(derivedSources)/multiphaseStabilizedTurbulence/multiphaseStabilizedTurbulence.C

View File

@ -137,25 +137,28 @@ Note
anisotropic (vectorial) electrical conductivity. anisotropic (vectorial) electrical conductivity.
- \c anisotropicElectricalConductivity=false enables - \c anisotropicElectricalConductivity=false enables
isotropic (scalar) electrical conductivity. isotropic (scalar) electrical conductivity.
- The electrical conductivity can be specified using either:
The electrical conductivity can be specified using either:
- If the \c sigma entry is present the electrical conductivity is specified - If the \c sigma entry is present the electrical conductivity is specified
as a function of temperature using a \c Function1 type. as a function of temperature using a \c Function1 type.
- If not present the \c sigma field will be read from file. - If not present the \c sigma field will be read from file.
- If the \c anisotropicElectricalConductivity flag is set to \c true, - If the \c anisotropicElectricalConductivity flag is set to \c true,
\c sigma should be specified as a vector quantity. \c sigma should be specified as a vector quantity.
.
See also See also
- Foam::Function1 - Foam::Function1
- Foam::coordSystem - Foam::coordSystem
- Foam::fa::jouleHeatingSource
SourceFiles SourceFiles
jouleHeatingSource.C jouleHeatingSource.cxx
jouleHeatingSourceTemplates.C jouleHeatingSourceImpl.cxx
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef fv_jouleHeatingSource_H #ifndef Foam_fv_jouleHeatingSource_H
#define fv_jouleHeatingSource_H #define Foam_fv_jouleHeatingSource_H
#include "fvOption.H" #include "fvOption.H"
#include "Function1.H" #include "Function1.H"
@ -185,9 +188,6 @@ class jouleHeatingSource
//- Electrical potential field / [V] //- Electrical potential field / [V]
volScalarField V_; volScalarField V_;
//- Flag to indicate that the electrical conductivity is anisotropic
bool anisotropicElectricalConductivity_;
//- Electrical conductivity as a scalar function of temperature //- Electrical conductivity as a scalar function of temperature
autoPtr<Function1<scalar>> scalarSigmaVsTPtr_; autoPtr<Function1<scalar>> scalarSigmaVsTPtr_;
@ -200,6 +200,9 @@ class jouleHeatingSource
//- Current time index (used for updating) //- Current time index (used for updating)
label curTimeIndex_; label curTimeIndex_;
//- Flag to indicate that the electrical conductivity is anisotropic
bool anisotropicElectricalConductivity_;
// Private Member Functions // Private Member Functions
@ -214,13 +217,13 @@ class jouleHeatingSource
void initialiseSigma void initialiseSigma
( (
const dictionary& dict, const dictionary& dict,
autoPtr<Function1<Type>>& sigmaVsTPtr autoPtr<Function1<Type>>& sigmaFunctionPtr
); );
//- Update the electrical conductivity field //- Update the electrical conductivity field
template<class Type> template<class Type>
const GeometricField<Type, fvPatchField, volMesh>& const GeometricField<Type, fvPatchField, volMesh>&
updateSigma(const autoPtr<Function1<Type>>& sigmaVsTPtr) const; updateSigma(const autoPtr<Function1<Type>>& sigmaFunctionPtr) const;
public: public:
@ -253,21 +256,21 @@ public:
// Member Functions // Member Functions
// Evaluation // Evaluation
//- Add explicit contribution to compressible momentum equation //- Add explicit contribution to energy equation
virtual void addSup virtual void addSup
( (
const volScalarField& rho, const volScalarField& rho,
fvMatrix<scalar>& eqn, fvMatrix<scalar>& eqn,
const label fieldi const label fieldi
); );
// IO // IO
//- Read source dictionary //- Read source dictionary
virtual bool read(const dictionary& dict); virtual bool read(const dictionary& dict);
}; };
@ -278,12 +281,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "jouleHeatingSourceTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -29,7 +29,6 @@ License
#include "fvMatrices.H" #include "fvMatrices.H"
#include "fvmLaplacian.H" #include "fvmLaplacian.H"
#include "fvcGrad.H" #include "fvcGrad.H"
#include "zeroGradientFvPatchField.H"
#include "basicThermo.H" #include "basicThermo.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
@ -45,6 +44,12 @@ namespace fv
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Implementation
#include "jouleHeatingSourceImpl.cxx"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::tmp<Foam::volSymmTensorField> Foam::tmp<Foam::volSymmTensorField>
@ -115,11 +120,8 @@ Foam::fv::jouleHeatingSource::jouleHeatingSource
), ),
mesh mesh
), ),
anisotropicElectricalConductivity_(false), curTimeIndex_(-1),
scalarSigmaVsTPtr_(nullptr), anisotropicElectricalConductivity_(false)
vectorSigmaVsTPtr_(nullptr),
csysPtr_(nullptr),
curTimeIndex_(-1)
{ {
// Set the field name to that of the energy // Set the field name to that of the energy
// field from which the temperature is obtained // field from which the temperature is obtained
@ -162,7 +164,7 @@ void Foam::fv::jouleHeatingSource::addSup
else else
{ {
// Update sigma as a function of T if required // Update sigma as a function of T if required
const volScalarField& sigma = updateSigma(scalarSigmaVsTPtr_); const auto& sigma = updateSigma(scalarSigmaVsTPtr_);
// Solve the electrical potential equation // Solve the electrical potential equation
fvScalarMatrix VEqn(fvm::laplacian(sigma, V_)); fvScalarMatrix VEqn(fvm::laplacian(sigma, V_));
@ -226,7 +228,7 @@ bool Foam::fv::jouleHeatingSource::read(const dictionary& dict)
initialiseSigma(coeffs_, scalarSigmaVsTPtr_); initialiseSigma(coeffs_, scalarSigmaVsTPtr_);
csysPtr_.clear(); // Do not need coordinate system csysPtr_.reset(nullptr); // Do not need coordinate system
} }
return true; return true;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2024 OpenCFD Ltd. Copyright (C) 2016-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -27,18 +27,25 @@ License
#include "emptyFvPatchField.H" #include "emptyFvPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
void Foam::fv::jouleHeatingSource::initialiseSigma void Foam::fv::jouleHeatingSource::initialiseSigma
( (
const dictionary& dict, const dictionary& dict,
autoPtr<Function1<Type>>& sigmaVsTPtr autoPtr<Function1<Type>>& sigmaFunctionPtr
) )
{ {
typedef GeometricField<Type, fvPatchField, volMesh> FieldType; typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
const word sigmaName
(
IOobject::scopedName(typeName, "sigma")
);
IOobject io IOobject io
( (
IOobject::scopedName(typeName, "sigma"), sigmaName,
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_.thisDb(), mesh_.thisDb(),
IOobject::NO_READ, IOobject::NO_READ,
@ -48,11 +55,11 @@ void Foam::fv::jouleHeatingSource::initialiseSigma
autoPtr<FieldType> tsigma; autoPtr<FieldType> tsigma;
if (dict.found("sigma")) // Is sigma defined using a Function1 ?
{ sigmaFunctionPtr = Function1<Type>::NewIfPresent("sigma", dict, &mesh_);
// Sigma to be defined using a Function1 type
sigmaVsTPtr = Function1<Type>::New("sigma", dict, &mesh_);
if (sigmaFunctionPtr)
{
tsigma.reset tsigma.reset
( (
new FieldType new FieldType
@ -85,28 +92,32 @@ template<class Type>
const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>& const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&
Foam::fv::jouleHeatingSource::updateSigma Foam::fv::jouleHeatingSource::updateSigma
( (
const autoPtr<Function1<Type>>& sigmaVsTPtr const autoPtr<Function1<Type>>& sigmaFunctionPtr
) const ) const
{ {
typedef GeometricField<Type, fvPatchField, volMesh> FieldType; typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
auto& sigma = mesh_.lookupObjectRef<FieldType> const word sigmaName
( (
IOobject::scopedName(typeName, "sigma") IOobject::scopedName(typeName, "sigma")
); );
if (!sigmaVsTPtr) auto& sigma = mesh_.lookupObjectRef<FieldType>(sigmaName);
if (!sigmaFunctionPtr)
{ {
// Electrical conductivity field, sigma, was specified by the user // Electrical conductivity field, sigma, was specified by the user
return sigma; return sigma;
} }
const auto& sigmaFunction = sigmaFunctionPtr();
const auto& T = mesh_.lookupObject<volScalarField>(TName_); const auto& T = mesh_.lookupObject<volScalarField>(TName_);
// Internal field // Internal field
forAll(sigma, i) forAll(sigma, i)
{ {
sigma[i] = sigmaVsTPtr->value(T[i]); sigma[i] = sigmaFunction.value(T[i]);
} }
@ -120,7 +131,7 @@ Foam::fv::jouleHeatingSource::updateSigma
const scalarField& Tbf = T.boundaryField()[patchi]; const scalarField& Tbf = T.boundaryField()[patchi];
forAll(pf, facei) forAll(pf, facei)
{ {
pf[facei] = sigmaVsTPtr->value(Tbf[facei]); pf[facei] = sigmaFunction.value(Tbf[facei]);
} }
} }
} }

View File

@ -480,6 +480,7 @@ void Foam::faMeshReconstructor::createMesh()
( (
new faMesh new faMesh
( (
procMesh_.name(),
*serialVolMesh_, *serialVolMesh_,
identity(singlePatchFaces_.size()) // faceLabels identity(singlePatchFaces_.size()) // faceLabels
) )

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2023 OpenCFD Ltd. Copyright (C) 2019-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -144,11 +144,23 @@ KirchhoffShell::KirchhoffShell
) )
: :
vibrationShellModel(modelType, mesh, dict), vibrationShellModel(modelType, mesh, dict),
h_
(
IOobject
(
dict.getOrDefault<word>("h", suffixed("hs")),
regionMesh().time().timeName(),
regionMesh().thisDb(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
regionMesh()
),
ps_ ps_
( (
IOobject IOobject
( (
"ps_" + regionName_, dict.getOrDefault<word>("ps", suffixed("ps")),
regionMesh().time().timeName(), regionMesh().time().timeName(),
regionMesh().thisDb(), regionMesh().thisDb(),
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
@ -157,23 +169,11 @@ KirchhoffShell::KirchhoffShell
regionMesh(), regionMesh(),
dimensionedScalar(dimPressure, Zero) dimensionedScalar(dimPressure, Zero)
), ),
h_
(
IOobject
(
"h_" + regionName_,
regionMesh().time().timeName(),
regionMesh().thisDb(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
regionMesh()
),
laplaceW_ laplaceW_
( (
IOobject IOobject
( (
"laplaceW_" + regionName_, suffixed("laplaceW"),
regionMesh().time().timeName(), regionMesh().time().timeName(),
regionMesh().thisDb(), regionMesh().thisDb(),
IOobject::NO_READ, IOobject::NO_READ,
@ -186,7 +186,7 @@ KirchhoffShell::KirchhoffShell
( (
IOobject IOobject
( (
"laplace2W_" + regionName_, suffixed("laplace2W"),
regionMesh().time().timeName(), regionMesh().time().timeName(),
regionMesh().thisDb(), regionMesh().thisDb(),
IOobject::NO_READ, IOobject::NO_READ,
@ -199,7 +199,7 @@ KirchhoffShell::KirchhoffShell
( (
IOobject IOobject
( (
"w0_" + regionName_, suffixed("w0"),
regionMesh().time().timeName(), regionMesh().time().timeName(),
regionMesh().thisDb(), regionMesh().thisDb(),
IOobject::NO_READ, IOobject::NO_READ,
@ -212,7 +212,7 @@ KirchhoffShell::KirchhoffShell
( (
IOobject IOobject
( (
"w00_" + regionName_, suffixed("w00"),
regionMesh().time().timeName(), regionMesh().time().timeName(),
regionMesh().thisDb(), regionMesh().thisDb(),
IOobject::NO_READ, IOobject::NO_READ,
@ -225,7 +225,7 @@ KirchhoffShell::KirchhoffShell
( (
IOobject IOobject
( (
"laplaceW0_" + regionName_, suffixed("laplaceW0"),
regionMesh().time().timeName(), regionMesh().time().timeName(),
regionMesh().thisDb(), regionMesh().thisDb(),
IOobject::NO_READ, IOobject::NO_READ,
@ -238,7 +238,7 @@ KirchhoffShell::KirchhoffShell
( (
IOobject IOobject
( (
"laplace2W0_" + regionName_, suffixed("laplace2W0"),
regionMesh().time().timeName(), regionMesh().time().timeName(),
regionMesh().thisDb(), regionMesh().thisDb(),
IOobject::NO_READ, IOobject::NO_READ,
@ -256,6 +256,7 @@ KirchhoffShell::KirchhoffShell
init(dict); init(dict);
} }
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void KirchhoffShell::preEvolveRegion() void KirchhoffShell::preEvolveRegion()

View File

@ -24,7 +24,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::regionFaModels::KirchhoffShell Foam::regionModels::KirchhoffShell (Foam::regionFaModels)
Description Description
Vibration-shell finite-area model. Vibration-shell finite-area model.
@ -51,9 +51,25 @@ Usage
\table \table
Property | Description | Type | Reqd | Deflt Property | Description | Type | Reqd | Deflt
vibrationShellModel | Type name: KirchhoffShell | word | yes | - vibrationShellModel | Type name: KirchhoffShell | word | yes | -
f0 | Damping coefficient [1/s] | scalar | yes | - f0 | Damping coefficient [1/s] | scalar | yes | -
f1 | Damping coefficient [1/s] | scalar | yes | - f1 | Damping coefficient [1/s] | scalar | yes | -
f2 | Damping coefficient [1/s] | scalar | yes | - f2 | Damping coefficient [1/s] | scalar | yes | -
h | Name of thickness field | word | no | hs (suffix)
ps | Name of pressure field | word | no | ps (suffix)
\endtable
Fields/variables used:
\table
Property | Description | Type | Deflt
h | Thickness | shell | hs (suffix)
ps | Pressure on shell | shell | ps (suffix)
\endtable
Naming changes from 2056 and earlier:
\table
Keyword | Description | Keyword (old) | Deflt (old)
h | Thickness (shell) | - | "h_" + regionName
ps | Pressure (shell) | - | "ps_" + regionName
\endtable \endtable
The inherited entries are elaborated in: The inherited entries are elaborated in:
@ -90,12 +106,12 @@ class KirchhoffShell
// Source term fields // Source term fields
//- Shell thickness [m]
areaScalarField h_;
//- External surface source [Pa] //- External surface source [Pa]
const areaScalarField ps_; const areaScalarField ps_;
//- Thickness [m]
areaScalarField h_;
//- Laplace of the displacement //- Laplace of the displacement
areaScalarField laplaceW_; areaScalarField laplaceW_;

View File

@ -27,7 +27,6 @@ License
#include "regionFaModel.H" #include "regionFaModel.H"
#include "faMesh.H" #include "faMesh.H"
#include "faMeshesRegistry.H"
#include "Time.H" #include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -74,7 +73,7 @@ Foam::IOobject createModelIOobject
( (
objName, objName,
mesh.time().constant(), mesh.time().constant(),
faMeshesRegistry::New(mesh).thisDb(), faMesh::Registry(mesh),
IOobjectOption::NO_READ, IOobjectOption::NO_READ,
IOobjectOption::NO_WRITE, IOobjectOption::NO_WRITE,
IOobjectOption::REGISTER IOobjectOption::REGISTER
@ -141,12 +140,71 @@ Foam::IOobject createPropertiesIOobject
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
void Foam::regionModels::regionFaModel::constructMeshObjects() void Foam::regionModels::regionFaModel::constructMeshObjects
(
// Just for error reference
const dictionary& dict
)
{ {
regionMeshPtr_.reset(nullptr);
#if 1
regionMeshPtr_.reset regionMeshPtr_.reset
( (
new faMesh(areaName_, primaryMesh_) new faMesh(areaName_, primaryMesh_)
); );
#else
// With try/catch and error messages
// DIY
// regionMeshPtr_ = faMesh::TryNew(areaName_, primaryMesh_);
// More heavy handed, but gives a better chance of locating
// the source of the error.
{
const bool oldThrowingError = FatalError.throwing(true);
const bool oldThrowingIOerr = FatalIOError.throwing(true);
try
{
regionMeshPtr_.reset
(
new faMesh(areaName_, primaryMesh_)
);
}
catch (const Foam::error& err)
{
Warning << err << nl << endl;
// Trickery to get original message
err.write(Warning, false);
}
catch (const Foam::IOerror& err)
{
Warning << err << nl << endl;
// Trickery to get original message
err.write(Warning, false);
}
FatalError.throwing(oldThrowingError);
FatalIOError.throwing(oldThrowingIOerr);
}
if (!regionMeshPtr_)
{
FatalError
<< "Failed to create finite-area mesh [" << areaName_
<< "] for model: "<< modelName_ << nl
<< "A common cause is an incorrect or"
" missing 'area' entry in the setup" << nl
<< ">>>>" << nl
<< dict.relativeName() << dict << "<<<<" << endl
<< exit(FatalError);
}
#endif
} }
@ -234,7 +292,35 @@ Foam::regionModels::regionFaModel::regionFaModel
regionName_(dict.get<word>("region")), regionName_(dict.get<word>("region")),
coeffs_(dict.subOrEmptyDict(modelName + "Coeffs")) coeffs_(dict.subOrEmptyDict(modelName + "Coeffs"))
{ {
constructMeshObjects(); // Suffix hint for variable names
if
(
coeffs_.readIfPresent("suffixing", suffixHint_)
|| dict.readIfPresent("suffixing", suffixHint_)
)
{
Switch sw = Switch::find(suffixHint_);
if (sw.good())
{
if (!sw) // No suffix
{
suffixHint_.clear();
}
}
else if (suffixHint_ == "default")
{
// Use default suffix
sw = true;
}
if (sw) // Default suffix
{
suffixHint_ = '_' + regionName_;
}
}
constructMeshObjects(dict);
initialise(); initialise();
if (readFields) if (readFields)
@ -250,9 +336,14 @@ void Foam::regionModels::regionFaModel::evolve()
{ {
if (active_) if (active_)
{ {
Info<< "\nEvolving " << modelName_ << " for region " Info<< "\nEvolving " << modelName_
<< regionMesh().name() << " : " << " for region " << regionMesh().name();
<< polyMesh::regionName(areaName_) << endl;
if (!polyMesh::regionName(areaName_).empty())
{
Info<< " [" << areaName_ << "]";
}
Info<< endl;
preEvolveRegion(); preEvolveRegion();
@ -265,7 +356,7 @@ void Foam::regionModels::regionFaModel::evolve()
{ {
Info<< incrIndent; Info<< incrIndent;
info(); info();
Info<< endl << decrIndent; Info<< decrIndent << endl;
} }
} }
} }

View File

@ -57,9 +57,20 @@ Usage
region | Name of operand region | word | yes | - region | Name of operand region | word | yes | -
area | Name of the finite-area mesh | word | no | region0 area | Name of the finite-area mesh | word | no | region0
active | Flag to activate the model | bool | yes | - active | Flag to activate the model | bool | yes | -
suffixing | Suffix hint for model variables | word | no | -
infoOutput | Flag to activate information output | bool | no | false infoOutput | Flag to activate information output | bool | no | false
\endtable \endtable
Note
The \c suffixing parameter is a hint that individual models may use
when automatically generating variable names internally. For example,
a model \em may provide ("T" + suffixing) and ("q" + suffixing)
as its default names temperature and flux fields, respectively.
If the user specifies \c suffixing = "_foo", those \em default names
would then become "T_foo" and "q_foo", respectively.
Suffixing (true|false|none|default|...) currently selects between
no suffix and ('_'+region).
SourceFiles SourceFiles
regionFaModelI.H regionFaModelI.H
regionFaModel.C regionFaModel.C
@ -90,7 +101,7 @@ class regionFaModel
// Private Member Functions // Private Member Functions
//- Construct region mesh and fields //- Construct region mesh and fields
void constructMeshObjects(); void constructMeshObjects(const dictionary&);
//- Initialise the region //- Initialise the region
void initialise(); void initialise();
@ -118,18 +129,21 @@ protected:
//- Model name //- Model name
const word modelName_; const word modelName_;
//- The finite-area mesh name //- Suffix hint for automatic model variable names (default: "")
word suffixHint_;
//- The finite-area mesh name (default: region0)
word areaName_; word areaName_;
//- Region name //- Region name
word regionName_; word regionName_;
//- Pointer to the region mesh database
autoPtr<faMesh> regionMeshPtr_;
//- Model coefficients dictionary //- Model coefficients dictionary
dictionary coeffs_; dictionary coeffs_;
//- Pointer to the region mesh database
autoPtr<faMesh> regionMeshPtr_;
//- Dictionary of output properties //- Dictionary of output properties
autoPtr<IOdictionary> outputPropertiesPtr_; autoPtr<IOdictionary> outputPropertiesPtr_;
@ -224,6 +238,15 @@ public:
//- Return mapping between surface and volume fields //- Return mapping between surface and volume fields
const volSurfaceMapping& vsm() const; const volSurfaceMapping& vsm() const;
//- The suffix hint for automatic model variable names
const word& suffixHint() const noexcept { return suffixHint_; }
//- Return the concatenation of \p base and the suffix hint
inline word suffixed(const char* base) const;
//- Return the concatenation of \p base and the suffix hint
inline word suffixed(const std::string& base) const;
// Evolution // Evolution

View File

@ -27,7 +27,7 @@ License
#include "regionFaModel.H" #include "regionFaModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::faMesh& Foam::regionModels::regionFaModel::regionMesh() const inline const Foam::faMesh& Foam::regionModels::regionFaModel::regionMesh() const
{ {
@ -106,4 +106,18 @@ inline bool Foam::regionModels::regionFaModel::isRegionPatch
} }
inline Foam::word
Foam::regionModels::regionFaModel::suffixed(const char* base) const
{
return word(base + suffixHint_);
}
inline Foam::word
Foam::regionModels::regionFaModel::suffixed(const std::string& base) const
{
return word(base + suffixHint_);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -123,14 +123,29 @@ thermalShell::thermalShell
) )
: :
thermalShellModel(modelType, mesh, dict), thermalShellModel(modelType, mesh, dict),
hName_(dict.getOrDefault<word>("h", suffixed("hs"))),
qsName_(dict.getOrDefault<word>("qs", suffixed("qs"))),
qrName_(dict.getOrDefault<word>("qr", "none")),
nNonOrthCorr_(1), nNonOrthCorr_(1),
// Only need/want thermal solid properties // Only need/want thermal solid properties
thermo_(dict.subDict("thermo"), solidProperties::THERMAL), thermo_(dict.subDict("thermo"), solidProperties::THERMAL),
h_
(
IOobject
(
hName_,
regionMesh().time().timeName(),
regionMesh().thisDb(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
regionMesh()
),
qs_ qs_
( (
IOobject IOobject
( (
"qs_" + regionName_, qsName_,
regionMesh().time().timeName(), regionMesh().time().timeName(),
regionMesh().thisDb(), regionMesh().thisDb(),
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
@ -139,19 +154,6 @@ thermalShell::thermalShell
regionMesh(), regionMesh(),
dimensionedScalar(dimPower/dimArea, Zero) dimensionedScalar(dimPower/dimArea, Zero)
), ),
h_
(
IOobject
(
"h_" + regionName_,
regionMesh().time().timeName(),
regionMesh().thisDb(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
regionMesh()
),
qrName_(dict.getOrDefault<word>("qr", "none")),
thickness_(dict.getOrDefault<scalar>("thickness", 0)) thickness_(dict.getOrDefault<scalar>("thickness", 0))
{ {
init(dict); init(dict);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -56,11 +56,28 @@ Usage
where the entries mean: where the entries mean:
\table \table
Property | Description | Type | Reqd | Deflt Property | Description | Type | Reqd | Deflt
thermalShellModel | Type name: thermalShell | word | yes | - thermalShellModel | Type name: thermalShell | word | yes | -
thermo | Solid thermal properties | dictionary | yes | - h | Name of thickness field | word | no | hs (suffix)
qr | Name of radiative heat flux field | word | no | none qs | Name of source field | word | no | qs (suffix)
thickness | Uniform film thickness [m] | scalar | choice | - qr | Name of radiative heat flux field | word | no | none
thermo | Solid thermal properties | dict | yes | -
thickness | Uniform shell thickness [m] | scalar | choice | -
\endtable
Fields/variables used:
\table
Property | Description | Type | Deflt
h | Thickness | shell | hs (suffix)
qs | Source field | shell | qs (suffix)
qr | Radiative heat flux field | volume | none
\endtable
Note the following naming changes from 2056 and earlier:
\table
Keyword | Description | Keyword (old) | Deflt (old)
h | Temperature (volume) | h | "h_" + regionName
qs | Temperature (shell) | qs | "qs_" + regionName
\endtable \endtable
The inherited entries are elaborated in: The inherited entries are elaborated in:
@ -68,7 +85,6 @@ Usage
SourceFiles SourceFiles
thermalShell.C thermalShell.C
thermalShellI.H
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -108,31 +124,38 @@ protected:
// Protected Data // Protected Data
// Solution parameters //- Name of shell thickness [height] field (default: "hs" + suffix)
const word hName_;
//- Number of non orthogonal correctors //- Name of surface energy source (default: "qs" + suffix)
label nNonOrthCorr_; const word qsName_;
//- Name of (volume) radiative flux field (default: none)
const word qrName_;
// Thermo properties // Solution Parameters
//- Solid properties //- Number of non orthogonal correctors
solidProperties thermo_; label nNonOrthCorr_;
// Source term fields // Thermo properties
//- External surface energy source [J/m2/s] //- Solid properties
areaScalarField qs_; solidProperties thermo_;
//- Film thickness [m]
areaScalarField h_;
//- Name of the primary region radiative flux // Source term fields
const word qrName_;
//- Uniform film thickness [m] //- Shell thickness field [m]
scalar thickness_; areaScalarField h_;
//- External surface energy source [J/m2/s]
areaScalarField qs_;
//- Uniform shell thickness [m]
scalar thickness_;
// Protected Member Functions // Protected Member Functions
@ -174,7 +197,7 @@ public:
// Fields // Fields
//- Return the film specific heat capacity [J/kg/K] //- Return the shell specific heat capacity [J/kg/K]
const tmp<areaScalarField> Cp() const; const tmp<areaScalarField> Cp() const;
//- Return density [kg/m3] //- Return density [kg/m3]

View File

@ -50,13 +50,14 @@ thermalShellModel::thermalShellModel
) )
: :
regionFaModel(mesh, "thermalShell", modelType, dict, true), regionFaModel(mesh, "thermalShell", modelType, dict, true),
TName_(dict.get<word>("T")), TName_(dict.getOrDefault<word>("T", suffixed("Ts"))),
Tp_(mesh.lookupObject<volScalarField>(TName_)), TprimaryName_(dict.getOrDefault<word>("Tprimary", "T")),
Tp_(mesh.lookupObject<volScalarField>(TprimaryName_)),
T_ T_
( (
IOobject IOobject
( (
"Ts_" + regionName_, TName_,
regionMesh().time().timeName(), regionMesh().time().timeName(),
regionMesh().thisDb(), regionMesh().thisDb(),
IOobject::MUST_READ, IOobject::MUST_READ,
@ -71,8 +72,8 @@ thermalShellModel::thermalShellModel
{ {
if (faOptions_.optionList::empty()) if (faOptions_.optionList::empty())
{ {
Info<< "No finite area options present for area : " Info<< "No finite-area options present for area:"
<< polyMesh::regionName(regionFaModel::areaName()) << endl; << regionFaModel::areaName() << endl;
} }
} }

View File

@ -24,7 +24,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::regionModels::thermalShellModels::thermalShellModel Foam::regionModels::thermalShellModel
Description Description
Intermediate class for thermal-shell finite-area models. Intermediate class for thermal-shell finite-area models.
@ -34,12 +34,12 @@ Usage
\verbatim \verbatim
<patchName> <patchName>
{ {
// Mandatory entries
T <word>;
// Optional entries // Optional entries
thermalShellModel <word>; thermalShellModel <word>;
T <word>;
Tprimary <word>;
// Inherited entries // Inherited entries
... ...
} }
@ -47,12 +47,27 @@ Usage
where the entries mean: where the entries mean:
\table \table
Property | Description | Type | Reqd | Deflt Property | Description | Type | Reqd | Deflt
T | Name of operand temperature field | word | yes | - T | Name of operand temperature field | word | no | Ts (suffix)
thermalShellModel | Name of thermal-shell model <!-- Tprimary | Name of primary temperature field | word | no | T
thermalShellModel | Name of thermalShellModel thermal-shell model <!--
--> | word | choice | - --> | word | choice | -
\endtable \endtable
Fields/variables used:
\table
Property | Description | Type | Deflt
T | Temperature | shell | Ts (suffix)
Tprimary | Temperature | volume | T
\endtable
\b BREAKING Naming changes from 2056 and earlier:
\table
Keyword | Description | Keyword (old) | Deflt (old)
T | Temperature (shell) | - | "Ts_" + regionName
Tprimary | Temperature (volume) | T | -
\endtable
The inherited entries are elaborated in: The inherited entries are elaborated in:
- \link regionFaModel.H \endlink - \link regionFaModel.H \endlink
@ -89,8 +104,11 @@ protected:
// Protected Data // Protected Data
//- Name of the temperature field //- Name of shell temperature field (default: "Ts" + suffix)
word TName_; const word TName_;
//- Name of volume temperature field (default: "T")
const word TprimaryName_;
//- Primary (volume) region temperature //- Primary (volume) region temperature
const volScalarField& Tp_; const volScalarField& Tp_;

View File

@ -53,7 +53,7 @@ vibrationShellModel::vibrationShellModel
( (
IOobject IOobject
( (
"ws_" + regionName_, dict.getOrDefault<word>("ws", suffixed("ws")),
regionMesh().time().timeName(), regionMesh().time().timeName(),
regionMesh().thisDb(), regionMesh().thisDb(),
IOobject::MUST_READ, IOobject::MUST_READ,
@ -65,7 +65,7 @@ vibrationShellModel::vibrationShellModel
( (
IOobject IOobject
( (
"as_" + regionName_, dict.getOrDefault<word>("as", suffixed("as")),
regionMesh().time().timeName(), regionMesh().time().timeName(),
regionMesh().thisDb(), regionMesh().thisDb(),
IOobject::NO_READ, IOobject::NO_READ,

View File

@ -24,7 +24,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::regionModels::thermalShellModels::vibrationShellModel Foam::regionModels::vibrationShellModel
Description Description
Intermediate class for vibration-shell finite-area models. Intermediate class for vibration-shell finite-area models.
@ -52,9 +52,19 @@ Usage
\table \table
Property | Description | Type | Reqd | Deflt Property | Description | Type | Reqd | Deflt
vibrationShellModel | Name of vibration-shell model | word | yes | - vibrationShellModel | Name of vibration-shell model | word | yes | -
p | Name of the coupled field in the primary <!-- p | Name of primary pressure field | word | yes | -
--> region | word | yes | - solid | Solid properties | dict | yes | -
solid | Solid properties | dictionary | yes | - as | Name of shell acceleration field | word | no | as (suffix)
ps | Name of pressure (source) on shell | word | no | ps (suffix)
ws | Name of shell displacement field | word | no | ws (suffix)
\endtable
Naming changes from 2056 and earlier:
\table
Keyword | Description | Keyword (old) | Deflt (old)
as | Acceleration (shell) | - | "as_" + regionName
ps | Pressure on shell | - | "ps_" + regionName
ws | Displacement (shell) | - | "ws_" + regionName
\endtable \endtable
The inherited entries are elaborated in: The inherited entries are elaborated in:
@ -93,19 +103,19 @@ protected:
// Protected Data // Protected Data
//- Shell displacement //- Shell displacement [m]
areaScalarField w_; areaScalarField w_;
//- Shell acceleration //- Shell acceleration [m/s2]
areaScalarField a_; areaScalarField a_;
//- Solid properties //- Solid properties
solidProperties solid_; solidProperties solid_;
//- Name of the coupled field in the primary region //- Name of primary region acoustic pressure field
word pName_; word pName_;
//- Primary region acoustic pressure //- Primary region acoustic pressure [Pa]
const volScalarField& pa_; const volScalarField& pa_;
//- Reference to faOptions //- Reference to faOptions
@ -167,26 +177,26 @@ public:
// Member Functions // Member Functions
//- Return primary region pa //- Return the primary region presssure
const volScalarField& pa() const noexcept { return pa_; } const volScalarField& pa() const noexcept { return pa_; }
//- Return shell displacement //- Return the shell displacement
const areaScalarField& w() const noexcept { return w_; } const areaScalarField& w() const noexcept { return w_; }
//- Return shell acceleration //- Return the shell acceleration
const areaScalarField& a() const noexcept { return a_; } const areaScalarField& a() const noexcept { return a_; }
//- Return faOptions //- Return faOptions
Foam::fa::options& faOptions() noexcept { return faOptions_; } Foam::fa::options& faOptions() noexcept { return faOptions_; }
//- Return solid properties //- Return solid properties
const solidProperties& solid() const noexcept { return solid_; } const solidProperties& solid() const noexcept { return solid_; }
// Evolution // Evolution
//- Pre-evolve region //- Pre-evolve region
virtual void preEvolveRegion(); virtual void preEvolveRegion();
}; };

View File

@ -10,7 +10,7 @@ FoamFile
version 2.0; version 2.0;
format ascii; format ascii;
class areaScalarField; class areaScalarField;
object h_ceilingShell; object hs;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -10,7 +10,7 @@ FoamFile
version 2.0; version 2.0;
format ascii; format ascii;
class areaScalarField; class areaScalarField;
object wS; object ws;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -41,7 +41,7 @@ boundaryField
nu 0.22; nu 0.22;
} }
region vibrationShell; region vibration;
vibrationShellModel KirchhoffShell; vibrationShellModel KirchhoffShell;
f0 0.04; f0 0.04;

View File

@ -17,12 +17,13 @@ FoamFile
pressure pressure
{ {
type externalFileSource; type externalFileSource;
fieldName ws_vibrationShell; //fieldName ws_shell;
fieldName ws;
tableName p; tableName p;
active true; active true;
timeStart 0.001; timeStart 0.001;
duration 0.03; duration 0.03;
region vibrationShell; region vibration;
selectionMode all; selectionMode all;
sampleFormat ensight; sampleFormat ensight;

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
| ========= | | | ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 | | \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com | | \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | | | \\/ M anipulation | |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -26,8 +26,9 @@ d2dt2Schemes
gradSchemes gradSchemes
{ {
default leastSquares; default leastSquares;
grad(ws_vibrationShell) leastSquares; grad(ws) leastSquares;
grad(ws_shell) leastSquares;
} }
divSchemes divSchemes

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
| ========= | | | ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 | | \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com | | \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | | | \\/ M anipulation | |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -16,7 +16,7 @@ FoamFile
solvers solvers
{ {
ws_vibrationShell "(ws|ws_.*)"
{ {
solver diagonal; solver diagonal;
preconditioner DILU; preconditioner DILU;

View File

@ -0,0 +1,31 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object IDefault;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [ 1 0 -3 0 0 0 0 ];
internalField uniform 0;
boundaryField
{
".*"
{
type greyDiffusiveRadiation;
value uniform 0;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,80 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object T;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 1 0 0 0];
internalField uniform 300;
boundaryField
{
"floor.*"
{
type fixedValue;
type compressible::thermalShell;
active true;
area floor;
region lower;
thermalShellModel thermalShell;
thermo
{
// Thermal properties
rho 1000;
kappa 200;
Cp 600;
emissivity 0;
}
qr qr;
thickness 1e-3;
value uniform 700;
}
"ceiling.*"
{
type compressible::thermalShell;
active true;
area ceiling;
region upper;
thermalShellModel thermalShell;
thermo
{
// Thermal properties
rho 1000;
kappa 200;
Cp 600;
emissivity 0;
}
qr qr;
thickness 1e-3;
value uniform 300;
}
"fixedWall.*"
{
type zeroGradient;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,30 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
".*"
{
type noSlip;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,31 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object alphat;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -1 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
".*"
{
type compressible::alphatWallFunction;
value uniform 0;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,31 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object epsilon;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -3 0 0 0 0];
internalField uniform 0.01;
boundaryField
{
".*"
{
type epsilonWallFunction;
value uniform 0.01;
}
}
// ************************************************************************* //

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
| ========= | | | ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 | | \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com | | \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | | | \\/ M anipulation | |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -10,7 +10,7 @@ FoamFile
version 2.0; version 2.0;
format ascii; format ascii;
class areaScalarField; class areaScalarField;
object Ts_ceilingShell; object Ts;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
| ========= | | | ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 | | \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com | | \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | | | \\/ M anipulation | |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -10,7 +10,7 @@ FoamFile
version 2.0; version 2.0;
format ascii; format ascii;
class areaScalarField; class areaScalarField;
object h_ceilingShell; object hs;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -27,4 +27,4 @@ boundaryField
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,31 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class areaScalarField;
object Ts;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 1 0 0 0];
internalField uniform 300;
boundaryField
{
"side.*"
{
type fixedValue;
value uniform 300;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,30 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class areaScalarField;
object hs;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 0 0 0 0 0];
internalField uniform 1e-3;
boundaryField
{
"side.*"
{
type zeroGradient;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,31 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0.1;
boundaryField
{
".*"
{
type kqRWallFunction;
value uniform 0.1;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,31 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object nut;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
".*"
{
type nutkWallFunction;
value uniform 0;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -1 -2 0 0 0 0];
internalField uniform 1e5;
boundaryField
{
"floor.*"
{
type calculated;
value $internalField;
}
"ceiling.*"
{
type calculated;
value $internalField;
}
"fixedWall.*"
{
type calculated;
value $internalField;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p_rgh;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -1 -2 0 0 0 0];
internalField uniform 1e5;
boundaryField
{
"floor.*"
{
type fixedFluxPressure;
value $internalField;
}
"ceiling.*"
{
type fixedFluxPressure;
value $internalField;
}
"fixedWall.*"
{
type fixedFluxPressure;
value $internalField;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,15 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions
#------------------------------------------------------------------------------
cleanCase
## foamListRegions -finite-area
for region in ceiling floor
do
cleanFaMesh -region "$region"
rmdir "constant/finite-area/$region" 2>/dev/null
done
#------------------------------------------------------------------------------

View File

@ -0,0 +1,12 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
./Allrun.pre
runApplication makeFaMesh -all-area-regions
runApplication $(getApplication)
#------------------------------------------------------------------------------

View File

@ -0,0 +1,16 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
runApplication blockMesh
runApplication topoSet
runApplication createPatch -overwrite
runApplication makeFaMesh
# runApplication $(getApplication)
#------------------------------------------------------------------------------

View File

@ -0,0 +1,16 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
./Allrun.pre
runParallel -s decompose redistributePar -decompose -no-finite-area
runParallel makeFaMesh -all-area-regions
runParallel $(getApplication)
# runParallel -s reconstruct redistributePar -reconstruct
#------------------------------------------------------------------------------

View File

@ -0,0 +1,16 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
./Allrun.pre
runApplication makeFaMesh -all-area-regions
runApplication decomposePar -all-area-regions
runParallel $(getApplication)
runApplication reconstructPar -all-area-regions
#------------------------------------------------------------------------------

View File

@ -0,0 +1,12 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
runApplication blockMesh
runApplication topoSet
runApplication createPatch -overwrite
#------------------------------------------------------------------------------

View File

@ -0,0 +1 @@
Demonstrates/tests some multi-regions with finite-area

View File

@ -0,0 +1,26 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object boundaryRadiationProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
".*"
{
type lookup;
emissivity 0.7;
absorptivity 0.7;
transmissivity 0.0;
}
// ************************************************************************* //

View File

@ -0,0 +1,23 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant/finite-area";
object regionProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
regions
(
shell (ceiling floor)
);
// ************************************************************************* //

View File

@ -0,0 +1,21 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class uniformDimensionedVectorField;
object g;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -2 0 0 0 0];
value (0 -9.81 0);
// ************************************************************************* //

View File

@ -0,0 +1,46 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object radiationProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
radiation on;
radiationModel fvDOM;
fvDOMCoeffs
{
nPhi 3;
nTheta 5;
maxIter 10;
tolerance 1e-3;
}
// Number of flow iterations per radiation iteration
solverFreq 10;
absorptionEmissionModel constantAbsorptionEmission;
constantAbsorptionEmissionCoeffs
{
absorptivity absorptivity [ m^-1 ] 0.01;
emissivity emissivity [ m^-1 ] 0.01;
E E [ kg m^-1 s^-3 ] 0;
}
scatterModel none;
sootModel none;
// ************************************************************************* //

View File

@ -0,0 +1,49 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object thermophysicalProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
thermoType
{
type heRhoThermo;
mixture pureMixture;
transport const;
thermo hConst;
equationOfState perfectGas;
specie specie;
energy sensibleEnthalpy;
}
pRef 100000;
mixture
{
specie
{
molWeight 28.9;
}
thermodynamics
{
Cp 1000;
Hf 0;
}
transport
{
mu 1.8e-05;
Pr 0.7;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,25 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object turbulenceProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType RAS;
RAS
{
RASModel kEpsilon;
}
// ************************************************************************* //

View File

@ -0,0 +1,103 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scale 1;
vertices
(
(0 0 0)
(10 0 0)
(10 5 0)
(0 5 0)
(0 0 10)
(10 0 10)
(10 5 10)
(0 5 10)
);
blocks
(
hex (0 1 2 3 4 5 6 7) (20 10 20) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
floor
{
type wall;
faces
(
(1 5 4 0)
);
}
ceiling
{
type wall;
faces
(
(3 7 6 2)
);
}
ceiling2
{
type wall;
faces ();
}
fixedWall1
{
type wall;
faces
(
(0 4 7 3)
);
}
fixedWall2
{
type wall;
faces
(
(2 6 5 1)
);
}
fixedWall3
{
type wall;
faces
(
(0 3 2 1)
);
}
fixedWall4
{
type wall;
faces
(
(4 5 6 7)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //

View File

@ -0,0 +1,52 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application buoyantPimpleFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 400;
deltaT 1;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
adjustTimeStep no;
maxCo 0.5;
// ************************************************************************* //

View File

@ -0,0 +1,41 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object createPatchDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
pointSync false;
// Patches to create.
patches
(
{
// Name of new patch
name ceiling2;
// Type of new patch
patchInfo
{
type patch;
}
// How to construct: either from 'patches' or 'set'
constructFrom set;
// If constructFrom = set : name of faceSet
set f0;
}
);
// ************************************************************************* //

View File

@ -0,0 +1,27 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 4;
method hierarchical;
coeffs
{
n (2 1 2);
}
// ************************************************************************* //

View File

@ -0,0 +1,52 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object faMeshDefinition;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
polyMeshPatches ( "ceiling.*" );
boundary
{
side1
{
type patch;
neighbourPolyPatch fixedWall1;
}
side2
{
type patch;
neighbourPolyPatch fixedWall2;
}
side3
{
type patch;
neighbourPolyPatch fixedWall3;
}
side4
{
type patch;
neighbourPolyPatch fixedWall4;
}
}
// defaultPatch
// {
// type patch;
// name side;
// }
// ************************************************************************** //

View File

@ -0,0 +1,51 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object faSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
grad(jouleHeatingSource:V) Gauss linear;
}
divSchemes
{
default none;
}
laplacianSchemes
{
default none;
laplacian((hs*jouleHeatingSource:sigma),jouleHeatingSource:V) Gauss linear corrected;
laplacian((kappas*hs),Ts) Gauss linear corrected;
}
interpolationSchemes
{
default linear;
}
lnGradSchemes
{
default corrected;
}
// ************************************************************************* //

View File

@ -0,0 +1,44 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object faSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
"(Ts|Ts_.*)"
{
solver PBiCGStab;
preconditioner DIC;
tolerance 1e-07;
relTol 0.01;
}
jouleHeatingSource:V
{
solver PBiCGStab;
preconditioner DIC;
tolerance 1e-07;
relTol 0.01;
}
}
nNonOrthCorr 1;
relaxationFactors
{
T 1;
}
// ************************************************************************* //

View File

@ -0,0 +1,52 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object faMeshDefinition;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
polyMeshPatches ( "floor.*" );
boundary
{
side1
{
type patch;
neighbourPolyPatch fixedWall1;
}
side2
{
type patch;
neighbourPolyPatch fixedWall2;
}
side3
{
type patch;
neighbourPolyPatch fixedWall3;
}
side4
{
type patch;
neighbourPolyPatch fixedWall4;
}
}
// defaultPatch
// {
// type patch;
// name side;
// }
// ************************************************************************** //

View File

@ -0,0 +1,49 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object faOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
exterior
{
type externalHeatFluxSource;
active true;
region upper;
selectionMode all;
mode coefficient;
T Ts;
Ta constant 290;
h 10;
}
// contactHeatFluxSource is the coupling of the shell-2D and the 3D mesh
contact
{
type contactHeatFluxSource;
active true;
region upper;
selectionMode all;
T Ts;
Tprimary T;
kappaMethod fluidThermo;
thicknessLayers (0.001);
kappaLayers (0.02);
}
//************************************************************************** //

View File

@ -0,0 +1,48 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object faOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
exterior
{
type externalHeatFluxSource;
active true;
region lower;
selectionMode all;
mode coefficient;
T Ts;
Ta constant 1000;
h 10;
}
// contactHeatFluxSource is the coupling of the shell-2D and the 3D mesh
contact
{
type contactHeatFluxSource;
active true;
region lower;
selectionMode all;
T Ts;
Tprimary T;
kappaMethod fluidThermo;
thicknessLayers (0.001);
kappaLayers (0.02);
}
//************************************************************************** //

View File

@ -0,0 +1,51 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object faSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
grad(jouleHeatingSource:V) Gauss linear;
}
divSchemes
{
default none;
}
laplacianSchemes
{
default none;
laplacian((hs*jouleHeatingSource:sigma),jouleHeatingSource:V) Gauss linear corrected;
laplacian((kappas*hs),Ts) Gauss linear corrected;
}
interpolationSchemes
{
default linear;
}
lnGradSchemes
{
default corrected;
}
// ************************************************************************* //

View File

@ -0,0 +1,44 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object faSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
"(Ts|Ts_.*)"
{
solver PBiCGStab;
preconditioner DIC;
tolerance 1e-07;
relTol 0.01;
}
jouleHeatingSource:V
{
solver PBiCGStab;
preconditioner DIC;
tolerance 1e-07;
relTol 0.01;
}
}
nNonOrthCorr 1;
relaxationFactors
{
T 1;
}
// ************************************************************************* //

Some files were not shown because too many files have changed in this diff Show More