mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Finite area port, Hrvoje Jasak
- with sphereSurfactantFoam and sphereTransport test case
This commit is contained in:
committed by
Andrew Heather
parent
4c81ee202d
commit
0c64622341
@ -1,3 +1,5 @@
|
||||
processorFaMeshes.C
|
||||
faFieldReconstructor.C
|
||||
reconstructPar.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/reconstructPar
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/finiteArea/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
@ -10,6 +11,7 @@ EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lgenericPatchFields \
|
||||
-llagrangian \
|
||||
-lfiniteArea \
|
||||
-ldynamicMesh \
|
||||
-lmeshTools \
|
||||
-lreconstruct \
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2016-2017 Wikki Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "faFieldReconstructor.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::faFieldReconstructor::faFieldReconstructor
|
||||
(
|
||||
faMesh& mesh,
|
||||
const PtrList<faMesh>& procMeshes,
|
||||
const PtrList<labelIOList>& edgeProcAddressing,
|
||||
const PtrList<labelIOList>& faceProcAddressing,
|
||||
const PtrList<labelIOList>& boundaryProcAddressing
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
procMeshes_(procMeshes),
|
||||
edgeProcAddressing_(edgeProcAddressing),
|
||||
faceProcAddressing_(faceProcAddressing),
|
||||
boundaryProcAddressing_(boundaryProcAddressing)
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,205 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2016-2017 Wikki Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
faFieldReconstructor
|
||||
|
||||
Description
|
||||
FA area and edge field reconstructor.
|
||||
|
||||
Author
|
||||
Zeljko Tukovic, FSB Zagreb
|
||||
Hrvoje Jasak, Wikki Ltd.
|
||||
|
||||
SourceFiles
|
||||
faFieldReconstructor.C
|
||||
faFieldReconstructorReconstructFields.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef faFieldReconstructor_H
|
||||
#define faFieldReconstructor_H
|
||||
|
||||
#include "PtrList.H"
|
||||
#include "faMesh.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "faPatchFieldMapper.H"
|
||||
#include "labelIOList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class faFieldReconstructor Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class faFieldReconstructor
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Reconstructed mesh reference
|
||||
faMesh& mesh_;
|
||||
|
||||
//- List of processor meshes
|
||||
const PtrList<faMesh>& procMeshes_;
|
||||
|
||||
//- List of processor edge addressing lists
|
||||
const PtrList<labelIOList>& edgeProcAddressing_;
|
||||
|
||||
//- List of processor face addressing lists
|
||||
const PtrList<labelIOList>& faceProcAddressing_;
|
||||
|
||||
//- List of processor boundary addressing lists
|
||||
const PtrList<labelIOList>& boundaryProcAddressing_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
faFieldReconstructor(const faFieldReconstructor&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const faFieldReconstructor&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
class faPatchFieldReconstructor
|
||||
:
|
||||
public faPatchFieldMapper
|
||||
{
|
||||
label size_;
|
||||
label sizeBeforeMapping_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given size
|
||||
faPatchFieldReconstructor
|
||||
(
|
||||
const label size,
|
||||
const label sizeBeforeMapping
|
||||
)
|
||||
:
|
||||
size_(size),
|
||||
sizeBeforeMapping_(sizeBeforeMapping)
|
||||
{}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
virtual label size() const
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
|
||||
virtual label sizeBeforeMapping() const
|
||||
{
|
||||
return sizeBeforeMapping_;
|
||||
}
|
||||
|
||||
virtual bool direct() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool hasUnmapped() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual const labelUList& directAddressing() const
|
||||
{
|
||||
return labelUList::null();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
faFieldReconstructor
|
||||
(
|
||||
faMesh& mesh,
|
||||
const PtrList<faMesh>& procMeshes,
|
||||
const PtrList<labelIOList>& edgeProcAddressing,
|
||||
const PtrList<labelIOList>& faceProcAddressing,
|
||||
const PtrList<labelIOList>& boundaryProcAddressing
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Reconstruct area field
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, faPatchField, areaMesh> >
|
||||
reconstructFaAreaField
|
||||
(
|
||||
const IOobject& fieldIoObject
|
||||
);
|
||||
|
||||
//- Reconstruct edge field
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, faePatchField, edgeMesh> >
|
||||
reconstructFaEdgeField
|
||||
(
|
||||
const IOobject& fieldIoObject
|
||||
);
|
||||
|
||||
//- Reconstruct and write all area fields
|
||||
template<class Type>
|
||||
void reconstructFaAreaFields
|
||||
(
|
||||
const IOobjectList& objects
|
||||
);
|
||||
|
||||
//- Reconstruct and write all area fields
|
||||
template<class Type>
|
||||
void reconstructFaEdgeFields
|
||||
(
|
||||
const IOobjectList& objects
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "faFieldReconstructorReconstructFields.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,642 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2016-2017 Wikki Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "faFieldReconstructor.H"
|
||||
#include "Time.H"
|
||||
#include "PtrList.H"
|
||||
#include "faPatchFields.H"
|
||||
#include "emptyFaPatch.H"
|
||||
#include "emptyFaPatchField.H"
|
||||
#include "emptyFaePatchField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::GeometricField<Type, Foam::faPatchField, Foam::areaMesh> >
|
||||
Foam::faFieldReconstructor::reconstructFaAreaField
|
||||
(
|
||||
const IOobject& fieldIoObject
|
||||
)
|
||||
{
|
||||
// Read the field for all the processors
|
||||
PtrList<GeometricField<Type, faPatchField, areaMesh> > procFields
|
||||
(
|
||||
procMeshes_.size()
|
||||
);
|
||||
|
||||
forAll (procMeshes_, procI)
|
||||
{
|
||||
procFields.set
|
||||
(
|
||||
procI,
|
||||
new GeometricField<Type, faPatchField, areaMesh>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldIoObject.name(),
|
||||
procMeshes_[procI].time().timeName(),
|
||||
procMeshes_[procI](),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
procMeshes_[procI]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Create the internalField
|
||||
Field<Type> internalField(mesh_.nFaces());
|
||||
|
||||
// Create the patch fields
|
||||
PtrList<faPatchField<Type> > patchFields(mesh_.boundary().size());
|
||||
|
||||
|
||||
// Create global mesh patchs starts
|
||||
|
||||
labelList gStarts(mesh_.boundary().size(), -1);
|
||||
|
||||
if (mesh_.boundary().size() > 0)
|
||||
{
|
||||
gStarts[0] = mesh_.nInternalEdges();
|
||||
}
|
||||
|
||||
for(label i=1; i<mesh_.boundary().size(); i++)
|
||||
{
|
||||
gStarts[i] = gStarts[i-1] + mesh_.boundary()[i-1].labelList::size();
|
||||
}
|
||||
|
||||
forAll (procMeshes_, procI)
|
||||
{
|
||||
const GeometricField<Type, faPatchField, areaMesh>& procField =
|
||||
procFields[procI];
|
||||
|
||||
// Set the face values in the reconstructed field
|
||||
internalField.rmap
|
||||
(
|
||||
procField.internalField(),
|
||||
faceProcAddressing_[procI]
|
||||
);
|
||||
|
||||
|
||||
|
||||
// Set the boundary patch values in the reconstructed field
|
||||
|
||||
labelList starts(procMeshes_[procI].boundary().size(), -1);
|
||||
|
||||
if(procMeshes_[procI].boundary().size() > 0)
|
||||
{
|
||||
starts[0] = procMeshes_[procI].nInternalEdges();
|
||||
}
|
||||
|
||||
for(label i=1; i<procMeshes_[procI].boundary().size(); i++)
|
||||
{
|
||||
starts[i] =
|
||||
starts[i-1]
|
||||
+ procMeshes_[procI].boundary()[i-1].labelList::size();
|
||||
}
|
||||
|
||||
forAll(boundaryProcAddressing_[procI], patchI)
|
||||
{
|
||||
// Get patch index of the original patch
|
||||
const label curBPatch = boundaryProcAddressing_[procI][patchI];
|
||||
|
||||
// Get addressing slice for this patch
|
||||
|
||||
// const labelList::subList cp =
|
||||
// procMeshes_[procI].boundary()[patchI].patchSlice
|
||||
// (
|
||||
// edgeProcAddressing_[procI]
|
||||
// );
|
||||
|
||||
const labelList::subList cp =
|
||||
labelList::subList
|
||||
(
|
||||
edgeProcAddressing_[procI],
|
||||
procMeshes_[procI].boundary()[patchI].size(),
|
||||
starts[patchI]
|
||||
);
|
||||
|
||||
// check if the boundary patch is not a processor patch
|
||||
if (curBPatch >= 0)
|
||||
{
|
||||
// Regular patch. Fast looping
|
||||
|
||||
if (!patchFields(curBPatch))
|
||||
{
|
||||
patchFields.set
|
||||
(
|
||||
curBPatch,
|
||||
faPatchField<Type>::New
|
||||
(
|
||||
procField.boundaryField()[patchI],
|
||||
mesh_.boundary()[curBPatch],
|
||||
DimensionedField<Type, areaMesh>::null(),
|
||||
faPatchFieldReconstructor
|
||||
(
|
||||
mesh_.boundary()[curBPatch].size(),
|
||||
procField.boundaryField()[patchI].size()
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const label curPatchStart = gStarts[curBPatch];
|
||||
// mesh_.boundary()[curBPatch].start();
|
||||
|
||||
labelList reverseAddressing(cp.size());
|
||||
|
||||
forAll(cp, edgeI)
|
||||
{
|
||||
// Subtract one to take into account offsets for
|
||||
// face direction.
|
||||
// reverseAddressing[edgeI] = cp[edgeI] - 1 - curPatchStart;
|
||||
reverseAddressing[edgeI] = cp[edgeI] - curPatchStart;
|
||||
}
|
||||
|
||||
patchFields[curBPatch].rmap
|
||||
(
|
||||
procField.boundaryField()[patchI],
|
||||
reverseAddressing
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
const Field<Type>& curProcPatch =
|
||||
procField.boundaryField()[patchI];
|
||||
|
||||
// In processor patches, there's a mix of internal faces (some
|
||||
// of them turned) and possible cyclics. Slow loop
|
||||
forAll(cp, edgeI)
|
||||
{
|
||||
// Subtract one to take into account offsets for
|
||||
// face direction.
|
||||
// label curE = cp[edgeI] - 1;
|
||||
label curE = cp[edgeI];
|
||||
|
||||
// Is the face on the boundary?
|
||||
if (curE >= mesh_.nInternalEdges())
|
||||
{
|
||||
// label curBPatch = mesh_.boundary().whichPatch(curE);
|
||||
label curBPatch = -1;
|
||||
|
||||
forAll (mesh_.boundary(), pI)
|
||||
{
|
||||
if
|
||||
(
|
||||
curE >= gStarts[pI]
|
||||
&& curE <
|
||||
(
|
||||
gStarts[pI]
|
||||
+ mesh_.boundary()[pI].labelList::size()
|
||||
)
|
||||
)
|
||||
{
|
||||
curBPatch = pI;
|
||||
}
|
||||
}
|
||||
|
||||
if (!patchFields(curBPatch))
|
||||
{
|
||||
patchFields.set
|
||||
(
|
||||
curBPatch,
|
||||
faPatchField<Type>::New
|
||||
(
|
||||
mesh_.boundary()[curBPatch].type(),
|
||||
mesh_.boundary()[curBPatch],
|
||||
DimensionedField<Type, areaMesh>::null()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// add the edge
|
||||
// label curPatchEdge =
|
||||
// mesh_.boundary()
|
||||
// [curBPatch].whichEdge(curE);
|
||||
|
||||
label curPatchEdge = curE - gStarts[curBPatch];
|
||||
|
||||
patchFields[curBPatch][curPatchEdge] =
|
||||
curProcPatch[edgeI];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
forAll(mesh_.boundary(), patchI)
|
||||
{
|
||||
// add empty patches
|
||||
if
|
||||
(
|
||||
typeid(mesh_.boundary()[patchI]) == typeid(emptyFaPatch)
|
||||
&& !patchFields(patchI)
|
||||
)
|
||||
{
|
||||
patchFields.set
|
||||
(
|
||||
patchI,
|
||||
faPatchField<Type>::New
|
||||
(
|
||||
emptyFaPatchField<Type>::typeName,
|
||||
mesh_.boundary()[patchI],
|
||||
DimensionedField<Type, areaMesh>::null()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Now construct and write the field
|
||||
// setting the internalField and patchFields
|
||||
return tmp<GeometricField<Type, faPatchField, areaMesh> >
|
||||
(
|
||||
new GeometricField<Type, faPatchField, areaMesh>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldIoObject.name(),
|
||||
mesh_.time().timeName(),
|
||||
mesh_(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
procFields[0].dimensions(),
|
||||
internalField,
|
||||
patchFields
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::GeometricField<Type, Foam::faePatchField, Foam::edgeMesh> >
|
||||
Foam::faFieldReconstructor::reconstructFaEdgeField
|
||||
(
|
||||
const IOobject& fieldIoObject
|
||||
)
|
||||
{
|
||||
// Read the field for all the processors
|
||||
PtrList<GeometricField<Type, faePatchField, edgeMesh> > procFields
|
||||
(
|
||||
procMeshes_.size()
|
||||
);
|
||||
|
||||
forAll (procMeshes_, procI)
|
||||
{
|
||||
procFields.set
|
||||
(
|
||||
procI,
|
||||
new GeometricField<Type, faePatchField, edgeMesh>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldIoObject.name(),
|
||||
procMeshes_[procI].time().timeName(),
|
||||
procMeshes_[procI](),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
procMeshes_[procI]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Create the internalField
|
||||
Field<Type> internalField(mesh_.nInternalEdges());
|
||||
|
||||
// Create the patch fields
|
||||
PtrList<faePatchField<Type> > patchFields(mesh_.boundary().size());
|
||||
|
||||
|
||||
labelList gStarts(mesh_.boundary().size(), -1);
|
||||
|
||||
if(mesh_.boundary().size() > 0)
|
||||
{
|
||||
gStarts[0] = mesh_.nInternalEdges();
|
||||
}
|
||||
|
||||
for(label i=1; i<mesh_.boundary().size(); i++)
|
||||
{
|
||||
gStarts[i] = gStarts[i-1] + mesh_.boundary()[i-1].labelList::size();
|
||||
}
|
||||
|
||||
|
||||
forAll (procMeshes_, procI)
|
||||
{
|
||||
const GeometricField<Type, faePatchField, edgeMesh>& procField =
|
||||
procFields[procI];
|
||||
|
||||
// Set the face values in the reconstructed field
|
||||
|
||||
// It is necessary to create a copy of the addressing array to
|
||||
// take care of the face direction offset trick.
|
||||
//
|
||||
{
|
||||
labelList curAddr(edgeProcAddressing_[procI]);
|
||||
|
||||
// forAll (curAddr, addrI)
|
||||
// {
|
||||
// curAddr[addrI] -= 1;
|
||||
// }
|
||||
|
||||
internalField.rmap
|
||||
(
|
||||
procField.internalField(),
|
||||
curAddr
|
||||
);
|
||||
}
|
||||
|
||||
// Set the boundary patch values in the reconstructed field
|
||||
|
||||
labelList starts(procMeshes_[procI].boundary().size(), -1);
|
||||
|
||||
if(procMeshes_[procI].boundary().size() > 0)
|
||||
{
|
||||
starts[0] = procMeshes_[procI].nInternalEdges();
|
||||
}
|
||||
|
||||
for(label i=1; i<procMeshes_[procI].boundary().size(); i++)
|
||||
{
|
||||
starts[i] =
|
||||
starts[i-1]
|
||||
+ procMeshes_[procI].boundary()[i-1].labelList::size();
|
||||
}
|
||||
|
||||
forAll(boundaryProcAddressing_[procI], patchI)
|
||||
{
|
||||
// Get patch index of the original patch
|
||||
const label curBPatch = boundaryProcAddressing_[procI][patchI];
|
||||
|
||||
// Get addressing slice for this patch
|
||||
|
||||
// const labelList::subList cp =
|
||||
// procMeshes_[procI].boundary()[patchI].patchSlice
|
||||
// (
|
||||
// faceProcAddressing_[procI]
|
||||
// );
|
||||
|
||||
const labelList::subList cp =
|
||||
labelList::subList
|
||||
(
|
||||
edgeProcAddressing_[procI],
|
||||
procMeshes_[procI].boundary()[patchI].size(),
|
||||
starts[patchI]
|
||||
);
|
||||
|
||||
// check if the boundary patch is not a processor patch
|
||||
if (curBPatch >= 0)
|
||||
{
|
||||
// Regular patch. Fast looping
|
||||
|
||||
if (!patchFields(curBPatch))
|
||||
{
|
||||
patchFields.set
|
||||
(
|
||||
curBPatch,
|
||||
faePatchField<Type>::New
|
||||
(
|
||||
procField.boundaryField()[patchI],
|
||||
mesh_.boundary()[curBPatch],
|
||||
DimensionedField<Type, edgeMesh>::null(),
|
||||
faPatchFieldReconstructor
|
||||
(
|
||||
mesh_.boundary()[curBPatch].size(),
|
||||
procField.boundaryField()[patchI].size()
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const label curPatchStart = gStarts[curBPatch];
|
||||
// mesh_.boundary()[curBPatch].start();
|
||||
|
||||
labelList reverseAddressing(cp.size());
|
||||
|
||||
forAll(cp, edgeI)
|
||||
{
|
||||
// Subtract one to take into account offsets for
|
||||
// face direction.
|
||||
// reverseAddressing[faceI] = cp[faceI] - 1 - curPatchStart;
|
||||
reverseAddressing[edgeI] = cp[edgeI] - curPatchStart;
|
||||
}
|
||||
|
||||
patchFields[curBPatch].rmap
|
||||
(
|
||||
procField.boundaryField()[patchI],
|
||||
reverseAddressing
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
const Field<Type>& curProcPatch =
|
||||
procField.boundaryField()[patchI];
|
||||
|
||||
// In processor patches, there's a mix of internal faces (some
|
||||
// of them turned) and possible cyclics. Slow loop
|
||||
forAll(cp, edgeI)
|
||||
{
|
||||
// label curF = cp[edgeI] - 1;
|
||||
label curE = cp[edgeI];
|
||||
|
||||
// Is the face turned the right side round
|
||||
if (curE >= 0)
|
||||
{
|
||||
// Is the face on the boundary?
|
||||
if (curE >= mesh_.nInternalEdges())
|
||||
{
|
||||
// label curBPatch =
|
||||
// mesh_.boundary().whichPatch(curF);
|
||||
|
||||
label curBPatch = -1;
|
||||
|
||||
forAll (mesh_.boundary(), pI)
|
||||
{
|
||||
if
|
||||
(
|
||||
curE >= gStarts[pI]
|
||||
&& curE <
|
||||
(
|
||||
gStarts[pI]
|
||||
+ mesh_.boundary()[pI].labelList::size()
|
||||
)
|
||||
)
|
||||
{
|
||||
curBPatch = pI;
|
||||
}
|
||||
}
|
||||
|
||||
if (!patchFields(curBPatch))
|
||||
{
|
||||
patchFields.set
|
||||
(
|
||||
curBPatch,
|
||||
faePatchField<Type>::New
|
||||
(
|
||||
mesh_.boundary()[curBPatch].type(),
|
||||
mesh_.boundary()[curBPatch],
|
||||
DimensionedField<Type, edgeMesh>
|
||||
::null()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// add the face
|
||||
// label curPatchFace =
|
||||
// mesh_.boundary()
|
||||
// [curBPatch].whichEdge(curF);
|
||||
|
||||
label curPatchEdge = curE - gStarts[curBPatch];
|
||||
|
||||
patchFields[curBPatch][curPatchEdge] =
|
||||
curProcPatch[edgeI];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Internal face
|
||||
internalField[curE] = curProcPatch[edgeI];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
forAll(mesh_.boundary(), patchI)
|
||||
{
|
||||
// add empty patches
|
||||
if
|
||||
(
|
||||
typeid(mesh_.boundary()[patchI]) == typeid(emptyFaPatch)
|
||||
&& !patchFields(patchI)
|
||||
)
|
||||
{
|
||||
patchFields.set
|
||||
(
|
||||
patchI,
|
||||
faePatchField<Type>::New
|
||||
(
|
||||
emptyFaePatchField<Type>::typeName,
|
||||
mesh_.boundary()[patchI],
|
||||
DimensionedField<Type, edgeMesh>::null()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Now construct and write the field
|
||||
// setting the internalField and patchFields
|
||||
return tmp<GeometricField<Type, faePatchField, edgeMesh> >
|
||||
(
|
||||
new GeometricField<Type, faePatchField, edgeMesh>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldIoObject.name(),
|
||||
mesh_.time().timeName(),
|
||||
mesh_(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
procFields[0].dimensions(),
|
||||
internalField,
|
||||
patchFields
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Reconstruct and write all area fields
|
||||
template<class Type>
|
||||
void Foam::faFieldReconstructor::reconstructFaAreaFields
|
||||
(
|
||||
const IOobjectList& objects
|
||||
)
|
||||
{
|
||||
const word& fieldClassName =
|
||||
GeometricField<Type, faPatchField, areaMesh>::typeName;
|
||||
|
||||
IOobjectList fields = objects.lookupClass(fieldClassName);
|
||||
|
||||
if (fields.size())
|
||||
{
|
||||
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
|
||||
|
||||
for
|
||||
(
|
||||
IOobjectList::const_iterator fieldIter = fields.begin();
|
||||
fieldIter != fields.end();
|
||||
++fieldIter
|
||||
)
|
||||
{
|
||||
Info << " " << fieldIter()->name() << endl;
|
||||
|
||||
reconstructFaAreaField<Type>(*fieldIter())().write();
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
// Reconstruct and write all edge fields
|
||||
template<class Type>
|
||||
void Foam::faFieldReconstructor::reconstructFaEdgeFields
|
||||
(
|
||||
const IOobjectList& objects
|
||||
)
|
||||
{
|
||||
const word& fieldClassName =
|
||||
GeometricField<Type, faePatchField, edgeMesh>::typeName;
|
||||
|
||||
IOobjectList fields = objects.lookupClass(fieldClassName);
|
||||
|
||||
if (fields.size())
|
||||
{
|
||||
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
|
||||
|
||||
for
|
||||
(
|
||||
IOobjectList::const_iterator fieldIter = fields.begin();
|
||||
fieldIter != fields.end();
|
||||
++fieldIter
|
||||
)
|
||||
{
|
||||
Info<< " " << fieldIter()->name() << endl;
|
||||
|
||||
reconstructFaEdgeField<Type>(*fieldIter())().write();
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,260 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2016-2017 Wikki Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "processorFaMeshes.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::processorFaMeshes::read()
|
||||
{
|
||||
forAll (fvMeshes_, procI)
|
||||
{
|
||||
meshes_.set
|
||||
(
|
||||
procI,
|
||||
new faMesh(fvMeshes_[procI])
|
||||
);
|
||||
|
||||
pointProcAddressing_.set
|
||||
(
|
||||
procI,
|
||||
new labelIOList
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"pointProcAddressing",
|
||||
meshes_[procI].time().findInstance
|
||||
(
|
||||
meshes_[procI].meshDir(),
|
||||
"pointProcAddressing"
|
||||
),
|
||||
meshes_[procI].meshSubDir,
|
||||
fvMeshes_[procI],
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
edgeProcAddressing_.set
|
||||
(
|
||||
procI,
|
||||
new labelIOList
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"edgeProcAddressing",
|
||||
meshes_[procI].time().findInstance
|
||||
(
|
||||
meshes_[procI].meshDir(),
|
||||
"edgeProcAddressing"
|
||||
),
|
||||
meshes_[procI].meshSubDir,
|
||||
fvMeshes_[procI],
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
faceProcAddressing_.set
|
||||
(
|
||||
procI,
|
||||
new labelIOList
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"faceProcAddressing",
|
||||
meshes_[procI].time().findInstance
|
||||
(
|
||||
meshes_[procI].meshDir(),
|
||||
"faceProcAddressing"
|
||||
),
|
||||
meshes_[procI].meshSubDir,
|
||||
fvMeshes_[procI],
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
boundaryProcAddressing_.set
|
||||
(
|
||||
procI,
|
||||
new labelIOList
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"boundaryProcAddressing",
|
||||
meshes_[procI].time().findInstance
|
||||
(
|
||||
meshes_[procI].meshDir(),
|
||||
"faceProcAddressing"
|
||||
),
|
||||
meshes_[procI].meshSubDir,
|
||||
fvMeshes_[procI],
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::processorFaMeshes::processorFaMeshes
|
||||
(
|
||||
const PtrList<fvMesh>& processorFvMeshes
|
||||
)
|
||||
:
|
||||
fvMeshes_(processorFvMeshes),
|
||||
meshes_(processorFvMeshes.size()),
|
||||
pointProcAddressing_(processorFvMeshes.size()),
|
||||
edgeProcAddressing_(processorFvMeshes.size()),
|
||||
faceProcAddressing_(processorFvMeshes.size()),
|
||||
boundaryProcAddressing_(processorFvMeshes.size())
|
||||
{
|
||||
read();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Foam::fvMesh::readUpdateState Foam::processorFaMeshes::readUpdate()
|
||||
// {
|
||||
// fvMesh::readUpdateState stat = fvMesh::UNCHANGED;
|
||||
|
||||
// forAll (databases_, procI)
|
||||
// {
|
||||
// // Check if any new meshes need to be read.
|
||||
// fvMesh::readUpdateState procStat = meshes_[procI].readUpdate();
|
||||
|
||||
// /*
|
||||
// if (procStat != fvMesh::UNCHANGED)
|
||||
// {
|
||||
// Info<< "Processor " << procI
|
||||
// << " at time " << databases_[procI].timeName()
|
||||
// << " detected mesh change " << procStat
|
||||
// << endl;
|
||||
// }
|
||||
// */
|
||||
|
||||
// // Combine into overall mesh change status
|
||||
// if (stat == fvMesh::UNCHANGED)
|
||||
// {
|
||||
// stat = procStat;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (stat != procStat)
|
||||
// {
|
||||
// FatalErrorIn("processorFaMeshes::readUpdate()")
|
||||
// << "Processor " << procI
|
||||
// << " has a different polyMesh at time "
|
||||
// << databases_[procI].timeName()
|
||||
// << " compared to any previous processors." << nl
|
||||
// << "Please check time " << databases_[procI].timeName()
|
||||
// << " directories on all processors for consistent"
|
||||
// << " mesh files."
|
||||
// << exit(FatalError);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if
|
||||
// (
|
||||
// stat == fvMesh::TOPO_CHANGE
|
||||
// || stat == fvMesh::TOPO_PATCH_CHANGE
|
||||
// )
|
||||
// {
|
||||
// // Reread all meshes and addresssing
|
||||
// read();
|
||||
// }
|
||||
// return stat;
|
||||
// }
|
||||
|
||||
|
||||
// void Foam::processorFaMeshes::reconstructPoints(fvMesh& mesh)
|
||||
// {
|
||||
// // Read the field for all the processors
|
||||
// PtrList<pointIOField> procsPoints(meshes_.size());
|
||||
|
||||
// forAll (meshes_, procI)
|
||||
// {
|
||||
// procsPoints.set
|
||||
// (
|
||||
// procI,
|
||||
// new pointIOField
|
||||
// (
|
||||
// IOobject
|
||||
// (
|
||||
// "points",
|
||||
// meshes_[procI].time().timeName(),
|
||||
// polyMesh::meshSubDir,
|
||||
// meshes_[procI],
|
||||
// IOobject::MUST_READ,
|
||||
// IOobject::NO_WRITE
|
||||
// )
|
||||
// )
|
||||
// );
|
||||
// }
|
||||
|
||||
// // Create the new points
|
||||
// vectorField newPoints(mesh.nPoints());
|
||||
|
||||
// forAll (meshes_, procI)
|
||||
// {
|
||||
// const vectorField& procPoints = procsPoints[procI];
|
||||
|
||||
// // Set the cell values in the reconstructed field
|
||||
|
||||
// const labelList& pointProcAddressingI = pointProcAddressing_[procI];
|
||||
|
||||
// if (pointProcAddressingI.size() != procPoints.size())
|
||||
// {
|
||||
// FatalErrorIn("processorFaMeshes")
|
||||
// << "problem :"
|
||||
// << " pointProcAddressingI:" << pointProcAddressingI.size()
|
||||
// << " procPoints:" << procPoints.size()
|
||||
// << abort(FatalError);
|
||||
// }
|
||||
|
||||
// forAll(pointProcAddressingI, pointI)
|
||||
// {
|
||||
// newPoints[pointProcAddressingI[pointI]] = procPoints[pointI];
|
||||
// }
|
||||
// }
|
||||
|
||||
// mesh.movePoints(newPoints);
|
||||
// mesh.write();
|
||||
// }
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,142 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2016-2017 Wikki Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
processorFaMeshes
|
||||
|
||||
Description
|
||||
Container for processor mesh addressing.
|
||||
|
||||
Author
|
||||
Zeljko Tukovic, FSB Zagreb
|
||||
|
||||
SourceFiles
|
||||
processorFaMeshes.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef processorFaMeshes_H
|
||||
#define processorFaMeshes_H
|
||||
|
||||
#include "PtrList.H"
|
||||
#include "fvMesh.H"
|
||||
#include "faMesh.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "labelIOList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class processorFaMeshes Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class processorFaMeshes
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- List of processor finite volume meshes
|
||||
const PtrList<fvMesh>& fvMeshes_;
|
||||
|
||||
//- List of processor finite area meshes
|
||||
PtrList<faMesh> meshes_;
|
||||
|
||||
//- List of processor point addressing lists
|
||||
PtrList<labelIOList> pointProcAddressing_;
|
||||
|
||||
//- List of processor face addressing lists
|
||||
PtrList<labelIOList> edgeProcAddressing_;
|
||||
|
||||
//- List of processor cell addressing lists
|
||||
PtrList<labelIOList> faceProcAddressing_;
|
||||
|
||||
//- List of processor boundary addressing lists
|
||||
PtrList<labelIOList> boundaryProcAddressing_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Read all meshes
|
||||
void read();
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
processorFaMeshes(const processorFaMeshes&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const processorFaMeshes&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
processorFaMeshes(const PtrList<fvMesh>& processorFvMeshes);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Update the meshes based on the mesh files saved in
|
||||
// time directories
|
||||
// fvMesh::readUpdateState readUpdate();
|
||||
|
||||
//- Reconstruct point position after motion in parallel
|
||||
// void reconstructPoints(faMesh& mesh);
|
||||
|
||||
PtrList<faMesh>& meshes()
|
||||
{
|
||||
return meshes_;
|
||||
}
|
||||
const PtrList<labelIOList>& pointProcAddressing() const
|
||||
{
|
||||
return pointProcAddressing_;
|
||||
}
|
||||
PtrList<labelIOList>& edgeProcAddressing()
|
||||
{
|
||||
return edgeProcAddressing_;
|
||||
}
|
||||
const PtrList<labelIOList>& faceProcAddressing() const
|
||||
{
|
||||
return faceProcAddressing_;
|
||||
}
|
||||
const PtrList<labelIOList>& boundaryProcAddressing() const
|
||||
{
|
||||
return boundaryProcAddressing_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -44,6 +44,11 @@ Description
|
||||
#include "pointFieldReconstructor.H"
|
||||
#include "reconstructLagrangian.H"
|
||||
|
||||
#include "faCFD.H"
|
||||
#include "faMesh.H"
|
||||
#include "processorFaMeshes.H"
|
||||
#include "faFieldReconstructor.H"
|
||||
|
||||
#include "cellSet.H"
|
||||
#include "faceSet.H"
|
||||
#include "pointSet.H"
|
||||
@ -710,6 +715,47 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
// If there are any FA fields, reconstruct them
|
||||
|
||||
if
|
||||
(
|
||||
objects.lookupClass(areaScalarField::typeName).size()
|
||||
|| objects.lookupClass(areaVectorField::typeName).size()
|
||||
|| objects.lookupClass(areaSphericalTensorField::typeName).size()
|
||||
|| objects.lookupClass(areaSymmTensorField::typeName).size()
|
||||
|| objects.lookupClass(areaTensorField::typeName).size()
|
||||
|| objects.lookupClass(edgeScalarField::typeName).size()
|
||||
)
|
||||
{
|
||||
Info << "Reconstructing FA fields" << nl << endl;
|
||||
|
||||
faMesh aMesh(mesh);
|
||||
|
||||
processorFaMeshes procFaMeshes(procMeshes.meshes());
|
||||
|
||||
faFieldReconstructor faReconstructor
|
||||
(
|
||||
aMesh,
|
||||
procFaMeshes.meshes(),
|
||||
procFaMeshes.edgeProcAddressing(),
|
||||
procFaMeshes.faceProcAddressing(),
|
||||
procFaMeshes.boundaryProcAddressing()
|
||||
);
|
||||
|
||||
faReconstructor.reconstructFaAreaFields<scalar>(objects);
|
||||
faReconstructor.reconstructFaAreaFields<vector>(objects);
|
||||
faReconstructor
|
||||
.reconstructFaAreaFields<sphericalTensor>(objects);
|
||||
faReconstructor.reconstructFaAreaFields<symmTensor>(objects);
|
||||
faReconstructor.reconstructFaAreaFields<tensor>(objects);
|
||||
|
||||
faReconstructor.reconstructFaEdgeFields<scalar>(objects);
|
||||
}
|
||||
else
|
||||
{
|
||||
Info << "No FA fields" << nl << endl;
|
||||
}
|
||||
|
||||
if (!noReconstructSets)
|
||||
{
|
||||
// Scan to find all sets
|
||||
|
||||
Reference in New Issue
Block a user