Refactor decompose/reconstruct tools for load balancing

This commit is contained in:
Hrvoje Jasak 2018-05-01 15:57:12 +01:00
parent 7174595839
commit 1e8847d71e
16 changed files with 1047 additions and 212 deletions

View file

@ -1,6 +1,9 @@
passivePatches/passiveProcessorPolyPatch/passiveProcessorPolyPatch.C
passivePatches/passiveProcessorFvPatch/passiveProcessorFvPatch.C
passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchFields.C
passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchFields.C
decomposeTools/finiteVolume/domainDecomposition.C
decomposeTools/finiteVolume/distributeCells.C
decomposeTools/finiteVolume/decomposeMesh.C

View file

@ -207,14 +207,6 @@ Foam::autoPtr<Foam::fvMesh> Foam::domainDecomposition::processorMesh
}
// Create processor mesh without a boundary
Pout<< "RAW MESH: points: " << procPoints.size()
<< " faces: " << procFaces.size()
<< " owner: " << procOwner.size()
<< " procNeighbour: " << procNeighbour.size() << nl
<< "curPatchSizes: " << procPatchSize_[procI] << nl
<< " curPatchStarts: " << procPatchStartIndex_[procI] << nl
<< endl;
// Create the mesh
autoPtr<fvMesh> procMeshPtr
(
new fvMesh

View file

@ -253,8 +253,7 @@ public:
);
// Destructor
//- Destructor
~fvFieldDecomposer();

View file

@ -47,37 +47,44 @@ fvFieldDecomposer::decomposeField
// Create and map the patch field values
PtrList<fvPatchField<Type> > patchFields(boundaryAddressing_.size());
forAll (boundaryAddressing_, patchi)
forAll (boundaryAddressing_, patchI)
{
if (boundaryAddressing_[patchi] >= 0)
if (boundaryAddressing_[patchI] >= 0)
{
patchFields.set
(
patchi,
patchI,
fvPatchField<Type>::New
(
field.boundaryField()[boundaryAddressing_[patchi]],
procMesh_.boundary()[patchi],
field.boundaryField()[boundaryAddressing_[patchI]],
procMesh_.boundary()[patchI],
DimensionedField<Type, volMesh>::null(),
*patchFieldDecomposerPtrs_[patchi]
*patchFieldDecomposerPtrs_[patchI]
)
);
}
else
{
// This will be a processor or passiveProcessor field,
// depending on the patch type. Construct it first and set the
// data by hand
patchFields.set
(
patchi,
new processorFvPatchField<Type>
patchI,
fvPatchField<Type>::New
// new processorFvPatchField<Type>
(
procMesh_.boundary()[patchi],
DimensionedField<Type, volMesh>::null(),
procMesh_.boundary()[patchI].type(),
procMesh_.boundary()[patchI],
DimensionedField<Type, volMesh>::null()
)
);
patchFields[patchI] ==
Field<Type>
(
field.internalField(),
*processorVolPatchFieldDecomposerPtrs_[patchi]
)
)
*processorVolPatchFieldDecomposerPtrs_[patchI]
);
}
}
@ -135,7 +142,9 @@ fvFieldDecomposer::decomposeField
// faces and faces from cyclic boundaries. This is a bit of a hack, but
// I cannot find a better solution without making the internal storage
// mechanism for surfaceFields correspond to the one of faces in polyMesh
// (i.e. using slices)
// (i.e. using slices). HJ, date unknown, before 2004
// Copy all face data into a single array across all patches
Field<Type> allFaceField(field.mesh().nFaces());
forAll (field.internalField(), i)
@ -143,11 +152,11 @@ fvFieldDecomposer::decomposeField
allFaceField[i] = field.internalField()[i];
}
forAll (field.boundaryField(), patchi)
forAll (field.boundaryField(), patchI)
{
const Field<Type> & p = field.boundaryField()[patchi];
const Field<Type> & p = field.boundaryField()[patchI];
const label patchStart = field.mesh().boundaryMesh()[patchi].start();
const label patchStart = field.mesh().boundaryMesh()[patchI].start();
forAll (p, i)
{
@ -158,37 +167,44 @@ fvFieldDecomposer::decomposeField
// Create and map the patch field values
PtrList<fvsPatchField<Type> > patchFields(boundaryAddressing_.size());
forAll (boundaryAddressing_, patchi)
forAll (boundaryAddressing_, patchI)
{
if (boundaryAddressing_[patchi] >= 0)
if (boundaryAddressing_[patchI] >= 0)
{
patchFields.set
(
patchi,
patchI,
fvsPatchField<Type>::New
(
field.boundaryField()[boundaryAddressing_[patchi]],
procMesh_.boundary()[patchi],
field.boundaryField()[boundaryAddressing_[patchI]],
procMesh_.boundary()[patchI],
DimensionedField<Type, surfaceMesh>::null(),
*patchFieldDecomposerPtrs_[patchi]
*patchFieldDecomposerPtrs_[patchI]
)
);
}
else
{
// This will be a processor or passiveProcessor field,
// depending on the patch type. Construct it first and set the
// data by hand
patchFields.set
(
patchi,
new processorFvsPatchField<Type>
patchI,
fvsPatchField<Type>::New
// new processorFvsPatchField<Type>
(
procMesh_.boundary()[patchi],
DimensionedField<Type, surfaceMesh>::null(),
procMesh_.boundary()[patchI].type(),
procMesh_.boundary()[patchI],
DimensionedField<Type, surfaceMesh>::null()
)
);
patchFields[patchI] ==
Field<Type>
(
allFaceField,
*processorSurfacePatchFieldDecomposerPtrs_[patchi]
)
)
*processorSurfacePatchFieldDecomposerPtrs_[patchI]
);
}
}

View file

@ -0,0 +1,112 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "passiveProcessorFvPatchField.H"
#include "passiveProcessorFvPatch.H"
#include "IPstream.H"
#include "OPstream.H"
#include "transformField.H"
#include "coeffFields.H"
#include "demandDrivenData.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::passiveProcessorFvPatchField<Type>::passiveProcessorFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF
)
:
fvPatchField<Type>(p, iF)
{}
template<class Type>
Foam::passiveProcessorFvPatchField<Type>::passiveProcessorFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const Field<Type>& f
)
:
fvPatchField<Type>(p, iF, f)
{}
template<class Type>
Foam::passiveProcessorFvPatchField<Type>::passiveProcessorFvPatchField
(
const passiveProcessorFvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fvPatchField<Type>(ptf, p, iF, mapper)
{}
template<class Type>
Foam::passiveProcessorFvPatchField<Type>::passiveProcessorFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const dictionary& dict
)
:
fvPatchField<Type>(p, iF, dict)
{}
template<class Type>
Foam::passiveProcessorFvPatchField<Type>::passiveProcessorFvPatchField
(
const passiveProcessorFvPatchField<Type>& ptf
)
:
fvPatchField<Type>(ptf)
{}
template<class Type>
Foam::passiveProcessorFvPatchField<Type>::passiveProcessorFvPatchField
(
const passiveProcessorFvPatchField<Type>& ptf,
const DimensionedField<Type, volMesh>& iF
)
:
fvPatchField<Type>(ptf, iF)
{}
// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
template<class Type>
Foam::passiveProcessorFvPatchField<Type>::~passiveProcessorFvPatchField()
{}
// ************************************************************************* //

View file

@ -0,0 +1,151 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::passiveProcessorFvPatchField
Description
This patch field is used in parallel load balancing to communicate
future passiveProcessor data in parallel decomposition
SourceFiles
passiveProcessorFvPatchField.C
\*---------------------------------------------------------------------------*/
#ifndef passiveProcessorFvPatchField_H
#define passiveProcessorFvPatchField_H
#include "fvPatchField.H"
#include "passiveProcessorFvPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class passiveProcessorFvPatchField Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class passiveProcessorFvPatchField
:
public fvPatchField<Type>
{
public:
//- Runtime type information
TypeName(passiveProcessorFvPatch::typeName_());
// Constructors
//- Construct from patch and internal field
passiveProcessorFvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&
);
//- Construct from patch and internal field and patch field
passiveProcessorFvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const Field<Type>&
);
//- Construct from patch, internal field and dictionary
passiveProcessorFvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const dictionary&
);
//- Construct by mapping given passiveProcessorFvPatchField
// onto a new patch
passiveProcessorFvPatchField
(
const passiveProcessorFvPatchField<Type>&,
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
passiveProcessorFvPatchField
(
const passiveProcessorFvPatchField<Type>&
);
//- Construct and return a clone
virtual tmp<fvPatchField<Type> > clone() const
{
return tmp<fvPatchField<Type> >
(
new passiveProcessorFvPatchField<Type>(*this)
);
}
//- Construct as copy setting internal field reference
passiveProcessorFvPatchField
(
const passiveProcessorFvPatchField<Type>&,
const DimensionedField<Type, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchField<Type> > clone
(
const DimensionedField<Type, volMesh>& iF
) const
{
return tmp<fvPatchField<Type> >
(
new passiveProcessorFvPatchField<Type>(*this, iF)
);
}
//- Destructor
virtual ~passiveProcessorFvPatchField();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "passiveProcessorFvPatchField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "passiveProcessorFvPatchFields.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makePatchFields(passiveProcessor);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef passiveProcessorFvPatchFields_H
#define passiveProcessorFvPatchFields_H
#include "passiveProcessorFvPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeFieldTypedefs(passiveProcessor)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,51 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef passiveProcessorFvPatchFieldsFwd_H
#define passiveProcessorFvPatchFieldsFwd_H
#include "fvPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> class passiveProcessorFvPatchField;
makePatchTypeFieldTypedefs(passiveProcessor)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,116 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "passiveProcessorFvsPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
passiveProcessorFvsPatchField<Type>::passiveProcessorFvsPatchField
(
const fvPatch& p,
const DimensionedField<Type, surfaceMesh>& iF
)
:
fvsPatchField<Type>(p, iF)
{}
template<class Type>
passiveProcessorFvsPatchField<Type>::passiveProcessorFvsPatchField
(
const fvPatch& p,
const DimensionedField<Type, surfaceMesh>& iF,
const Field<Type>& f
)
:
fvsPatchField<Type>(p, iF, f)
{}
// Construct by mapping given passiveProcessorFvsPatchField<Type>
template<class Type>
passiveProcessorFvsPatchField<Type>::passiveProcessorFvsPatchField
(
const passiveProcessorFvsPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, surfaceMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fvsPatchField<Type>(ptf, p, iF, mapper)
{}
template<class Type>
passiveProcessorFvsPatchField<Type>::passiveProcessorFvsPatchField
(
const fvPatch& p,
const DimensionedField<Type, surfaceMesh>& iF,
const dictionary& dict
)
:
fvsPatchField<Type>(p, iF, dict)
{}
template<class Type>
passiveProcessorFvsPatchField<Type>::passiveProcessorFvsPatchField
(
const passiveProcessorFvsPatchField<Type>& ptf
)
:
fvsPatchField<Type>(ptf)
{}
template<class Type>
passiveProcessorFvsPatchField<Type>::passiveProcessorFvsPatchField
(
const passiveProcessorFvsPatchField<Type>& ptf,
const DimensionedField<Type, surfaceMesh>& iF
)
:
fvsPatchField<Type>(ptf, iF)
{}
// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
template<class Type>
passiveProcessorFvsPatchField<Type>::~passiveProcessorFvsPatchField()
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,151 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::passiveProcessorFvsPatchField
Description
This patch field is used in parallel load balancing to communicate
future processor data in parallel decomposition
SourceFiles
passiveProcessorFvsPatchField.C
\*---------------------------------------------------------------------------*/
#ifndef passiveProcessorFvsPatchField_H
#define passiveProcessorFvsPatchField_H
#include "fvsPatchField.H"
#include "passiveProcessorFvPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class passiveProcessorFvsPatch Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class passiveProcessorFvsPatchField
:
public fvsPatchField<Type>
{
public:
//- Runtime type information
TypeName(passiveProcessorFvPatch::typeName_());
// Constructors
//- Construct from patch and internal field
passiveProcessorFvsPatchField
(
const fvPatch&,
const DimensionedField<Type, surfaceMesh>&
);
//- Construct from patch and internal field and patch field
passiveProcessorFvsPatchField
(
const fvPatch&,
const DimensionedField<Type, surfaceMesh>&,
const Field<Type>&
);
//- Construct from patch, internal field and dictionary
passiveProcessorFvsPatchField
(
const fvPatch&,
const DimensionedField<Type, surfaceMesh>&,
const dictionary&
);
//- Construct by mapping given passiveProcessorFvsPatchField
// onto a new patch
passiveProcessorFvsPatchField
(
const passiveProcessorFvsPatchField<Type>&,
const fvPatch&,
const DimensionedField<Type, surfaceMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
passiveProcessorFvsPatchField
(
const passiveProcessorFvsPatchField<Type>&
);
//- Construct and return a clone
virtual tmp<fvsPatchField<Type> > clone() const
{
return tmp<fvsPatchField<Type> >
(
new passiveProcessorFvsPatchField<Type>(*this)
);
}
//- Construct as copy setting internal field reference
passiveProcessorFvsPatchField
(
const passiveProcessorFvsPatchField<Type>&,
const DimensionedField<Type, surfaceMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvsPatchField<Type> > clone
(
const DimensionedField<Type, surfaceMesh>& iF
) const
{
return tmp<fvsPatchField<Type> >
(
new passiveProcessorFvsPatchField<Type>(*this, iF)
);
}
//- Destructor
virtual ~passiveProcessorFvsPatchField();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "passiveProcessorFvsPatchField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,44 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "passiveProcessorFvsPatchFields.H"
#include "fvPatchFields.H"
#include "fvsPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeFvsPatchFields(passiveProcessor);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef passiveProcessorFvsPatchFields_H
#define passiveProcessorFvsPatchFields_H
#include "passiveProcessorFvsPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makeFvsPatchTypeFieldTypedefs(passiveProcessor)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,51 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef passiveProcessorFvsPatchFieldsFwd_H
#define passiveProcessorFvsPatchFieldsFwd_H
#include "fvsPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> class passiveProcessorFvsPatchField;
makeFvsPatchTypeFieldTypedefs(passiveProcessor)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -153,16 +153,31 @@ public:
// Member Functions
// Single field reconstruction
//- Reconstruct volume field data into a given field
// If a PtrList slot is empty, it is skipped
template<class Type>
void reconstructFvVolumeField
void reconstructField
(
GeometricField<Type, fvPatchField, volMesh>& reconField,
const PtrList<GeometricField<Type, fvPatchField, volMesh> >&
procFields
) const;
//- Reconstruct volume field data into a given field
// If a PtrList slot is empty, it is skipped
template<class Type>
void reconstructField
(
GeometricField<Type, fvsPatchField, surfaceMesh>& reconField,
const PtrList<GeometricField<Type, fvsPatchField, surfaceMesh> >&
procFields
) const;
// Reconstruct and return a single field
//- Reconstruct volume field
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh> >
@ -171,16 +186,6 @@ public:
const IOobject& fieldIoObject
) const;
//- Reconstruct volume field data into a given field
// If a PtrList slot is empty, it is skipped
template<class Type>
void reconstructFvSurfaceField
(
GeometricField<Type, fvsPatchField, surfaceMesh>& reconField,
const PtrList<GeometricField<Type, fvsPatchField, surfaceMesh> >&
procFields
) const;
//- Reconstruct surface field
template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
@ -189,6 +194,9 @@ public:
const IOobject& fieldIoObject
) const;
// Reconstruct and write all/selected fields
//- Reconstruct and write all/selected volume fields
template<class Type>
void reconstructFvVolumeFields

View file

@ -37,7 +37,7 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::fvFieldReconstructor::reconstructFvVolumeField
void Foam::fvFieldReconstructor::reconstructField
(
GeometricField<Type, fvPatchField, volMesh>& reconField,
const PtrList<GeometricField<Type, fvPatchField, volMesh> >& procFields
@ -135,6 +135,124 @@ void Foam::fvFieldReconstructor::reconstructFvVolumeField
}
template<class Type>
void Foam::fvFieldReconstructor::reconstructField
(
GeometricField<Type, fvsPatchField, surfaceMesh>& reconField,
const PtrList<GeometricField<Type, fvsPatchField, surfaceMesh> >& procFields
) const
{
// Create the internalField
Field<Type>& iField = reconField.internalField();
typename GeometricField<Type, fvsPatchField, surfaceMesh>::
GeometricBoundaryField& bouField = reconField.boundaryField();
forAll (procFields, procI)
{
if (procFields.set(procI))
{
const GeometricField<Type, fvsPatchField, surfaceMesh>& 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(faceProcAddressing_[procI]);
forAll (curAddr, addrI)
{
curAddr[addrI] -= 1;
}
iField.rmap
(
procField.internalField(),
curAddr
);
}
// Set the boundary patch values in the reconstructed field
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]
);
// Check if the boundary patch is not a processor patch
if (curBPatch >= 0)
{
// Regular patch. Fast looping
const label curPatchStart =
mesh_.boundaryMesh()[curBPatch].start();
labelList reverseAddressing(cp.size());
forAll (cp, faceI)
{
// Subtract one to take into account offsets for
// face direction.
reverseAddressing[faceI] =
cp[faceI] - 1 - curPatchStart;
}
bouField[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, faceI)
{
label curF = cp[faceI] - 1;
// Is the face turned the right side round
if (curF >= 0)
{
// Is the face on the boundary?
if (curF >= mesh_.nInternalFaces())
{
label curBPatch =
mesh_.boundaryMesh().whichPatch(curF);
// Add the face
label curPatchFace =
mesh_.boundaryMesh()
[curBPatch].whichFace(curF);
bouField[curBPatch][curPatchFace] =
curProcPatch[faceI];
}
else
{
// Internal face
iField[curF] = curProcPatch[faceI];
}
}
}
}
}
}
}
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::fvFieldReconstructor::reconstructFvVolumeField
@ -262,7 +380,7 @@ Foam::fvFieldReconstructor::reconstructFvVolumeField
);
// Reconstruct field
reconstructFvVolumeField
this->reconstructField
(
treconField(),
procFields
@ -272,124 +390,6 @@ Foam::fvFieldReconstructor::reconstructFvVolumeField
}
template<class Type>
void Foam::fvFieldReconstructor::reconstructFvSurfaceField
(
GeometricField<Type, fvsPatchField, surfaceMesh>& reconField,
const PtrList<GeometricField<Type, fvsPatchField, surfaceMesh> >& procFields
) const
{
// Create the internalField
Field<Type>& iField = reconField.internalField();
typename GeometricField<Type, fvsPatchField, surfaceMesh>::
GeometricBoundaryField& bouField = reconField.boundaryField();
forAll (procFields, procI)
{
if (procFields.set(procI))
{
const GeometricField<Type, fvsPatchField, surfaceMesh>& 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(faceProcAddressing_[procI]);
forAll (curAddr, addrI)
{
curAddr[addrI] -= 1;
}
iField.rmap
(
procField.internalField(),
curAddr
);
}
// Set the boundary patch values in the reconstructed field
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]
);
// Check if the boundary patch is not a processor patch
if (curBPatch >= 0)
{
// Regular patch. Fast looping
const label curPatchStart =
mesh_.boundaryMesh()[curBPatch].start();
labelList reverseAddressing(cp.size());
forAll (cp, faceI)
{
// Subtract one to take into account offsets for
// face direction.
reverseAddressing[faceI] =
cp[faceI] - 1 - curPatchStart;
}
bouField[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, faceI)
{
label curF = cp[faceI] - 1;
// Is the face turned the right side round
if (curF >= 0)
{
// Is the face on the boundary?
if (curF >= mesh_.nInternalFaces())
{
label curBPatch =
mesh_.boundaryMesh().whichPatch(curF);
// Add the face
label curPatchFace =
mesh_.boundaryMesh()
[curBPatch].whichFace(curF);
bouField[curBPatch][curPatchFace] =
curProcPatch[faceI];
}
else
{
// Internal face
iField[curF] = curProcPatch[faceI];
}
}
}
}
}
}
}
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
Foam::fvFieldReconstructor::reconstructFvSurfaceField
@ -517,7 +517,7 @@ Foam::fvFieldReconstructor::reconstructFvSurfaceField
);
// Reconstruct field
reconstructFvSurfaceField
reconstructField
(
treconField(),
procFields