mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: fvMeshAdd: support dimensionedFields
This commit is contained in:
@ -2,8 +2,8 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -28,6 +28,14 @@ License
|
|||||||
#include "faceCoupleInfo.H"
|
#include "faceCoupleInfo.H"
|
||||||
#include "fvMesh.H"
|
#include "fvMesh.H"
|
||||||
|
|
||||||
|
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(fvMeshAdder, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
//- Calculate map from new patch faces to old patch faces. -1 where
|
//- Calculate map from new patch faces to old patch faces. -1 where
|
||||||
@ -108,6 +116,12 @@ Foam::autoPtr<Foam::mapAddedPolyMesh> Foam::fvMeshAdder::add
|
|||||||
fvMeshAdder::MapSurfaceFields<symmTensor>(mapPtr, mesh0, mesh1);
|
fvMeshAdder::MapSurfaceFields<symmTensor>(mapPtr, mesh0, mesh1);
|
||||||
fvMeshAdder::MapSurfaceFields<tensor>(mapPtr, mesh0, mesh1);
|
fvMeshAdder::MapSurfaceFields<tensor>(mapPtr, mesh0, mesh1);
|
||||||
|
|
||||||
|
fvMeshAdder::MapDimFields<scalar>(mapPtr, mesh0, mesh1);
|
||||||
|
fvMeshAdder::MapDimFields<vector>(mapPtr, mesh0, mesh1);
|
||||||
|
fvMeshAdder::MapDimFields<sphericalTensor>(mapPtr, mesh0, mesh1);
|
||||||
|
fvMeshAdder::MapDimFields<symmTensor>(mapPtr, mesh0, mesh1);
|
||||||
|
fvMeshAdder::MapDimFields<tensor>(mapPtr, mesh0, mesh1);
|
||||||
|
|
||||||
return mapPtr;
|
return mapPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -26,7 +26,7 @@ Class
|
|||||||
|
|
||||||
Description
|
Description
|
||||||
Adds two fvMeshes without using any polyMesh morphing.
|
Adds two fvMeshes without using any polyMesh morphing.
|
||||||
Uses fvMeshAdder.
|
Uses polyMeshAdder.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
fvMeshAdder.C
|
fvMeshAdder.C
|
||||||
@ -42,6 +42,7 @@ SourceFiles
|
|||||||
#include "fvPatchFieldsFwd.H"
|
#include "fvPatchFieldsFwd.H"
|
||||||
#include "fvsPatchFieldsFwd.H"
|
#include "fvsPatchFieldsFwd.H"
|
||||||
#include "fvPatchFieldMapper.H"
|
#include "fvPatchFieldMapper.H"
|
||||||
|
#include "DimensionedField.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -101,8 +102,22 @@ private:
|
|||||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& fldToAdd
|
const GeometricField<Type, fvsPatchField, surfaceMesh>& fldToAdd
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Update single dimensionedField.
|
||||||
|
template<class Type>
|
||||||
|
static void MapDimField
|
||||||
|
(
|
||||||
|
const mapAddedPolyMesh& meshMap,
|
||||||
|
|
||||||
|
DimensionedField<Type, volMesh>& fld,
|
||||||
|
const DimensionedField<Type, volMesh>& fldToAdd
|
||||||
|
);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// Declare name of the class and its debug switch
|
||||||
|
ClassName("fvMeshAdder");
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Inplace add mesh to fvMesh. Maps all stored fields. Returns map.
|
//- Inplace add mesh to fvMesh. Maps all stored fields. Returns map.
|
||||||
@ -131,6 +146,15 @@ public:
|
|||||||
const fvMesh& mesh,
|
const fvMesh& mesh,
|
||||||
const fvMesh& meshToAdd
|
const fvMesh& meshToAdd
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Map all DimensionedFields of Type
|
||||||
|
template<class Type>
|
||||||
|
static void MapDimFields
|
||||||
|
(
|
||||||
|
const mapAddedPolyMesh&,
|
||||||
|
const fvMesh& mesh,
|
||||||
|
const fvMesh& meshToAdd
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -280,6 +280,12 @@ void Foam::fvMeshAdder::MapVolFields
|
|||||||
++fieldIter
|
++fieldIter
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "MapVolFields : Storing old time for " << fieldIter()->name()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
const_cast<GeometricField<Type, fvPatchField, volMesh>*>(fieldIter())
|
const_cast<GeometricField<Type, fvPatchField, volMesh>*>(fieldIter())
|
||||||
->storeOldTimes();
|
->storeOldTimes();
|
||||||
}
|
}
|
||||||
@ -304,6 +310,12 @@ void Foam::fvMeshAdder::MapVolFields
|
|||||||
const GeometricField<Type, fvPatchField, volMesh>& fldToAdd =
|
const GeometricField<Type, fvPatchField, volMesh>& fldToAdd =
|
||||||
*fieldsToAdd[fld.name()];
|
*fieldsToAdd[fld.name()];
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "MapVolFields : mapping " << fld.name()
|
||||||
|
<< " and " << fldToAdd.name() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
MapVolField<Type>(meshMap, fld, fldToAdd);
|
MapVolField<Type>(meshMap, fld, fldToAdd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -585,8 +597,13 @@ void Foam::fvMeshAdder::MapSurfaceFields
|
|||||||
++fieldIter
|
++fieldIter
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const_cast<fldType*>(fieldIter())
|
if (debug)
|
||||||
->storeOldTimes();
|
{
|
||||||
|
Pout<< "MapSurfaceFields : Storing old time for "
|
||||||
|
<< fieldIter()->name() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
const_cast<fldType*>(fieldIter())->storeOldTimes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -604,6 +621,12 @@ void Foam::fvMeshAdder::MapSurfaceFields
|
|||||||
{
|
{
|
||||||
const fldType& fldToAdd = *fieldsToAdd[fld.name()];
|
const fldType& fldToAdd = *fieldsToAdd[fld.name()];
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "MapSurfaceFields : mapping " << fld.name()
|
||||||
|
<< " and " << fldToAdd.name() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
MapSurfaceField<Type>(meshMap, fld, fldToAdd);
|
MapSurfaceField<Type>(meshMap, fld, fldToAdd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -617,4 +640,80 @@ void Foam::fvMeshAdder::MapSurfaceFields
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::fvMeshAdder::MapDimField
|
||||||
|
(
|
||||||
|
const mapAddedPolyMesh& meshMap,
|
||||||
|
|
||||||
|
DimensionedField<Type, volMesh>& fld,
|
||||||
|
const DimensionedField<Type, volMesh>& fldToAdd
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const fvMesh& mesh = fld.mesh();
|
||||||
|
|
||||||
|
// Store old field
|
||||||
|
Field<Type> oldField(fld);
|
||||||
|
|
||||||
|
fld.setSize(mesh.nCells());
|
||||||
|
|
||||||
|
fld.rmap(oldField, meshMap.oldCellMap());
|
||||||
|
fld.rmap(fldToAdd, meshMap.addedCellMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::fvMeshAdder::MapDimFields
|
||||||
|
(
|
||||||
|
const mapAddedPolyMesh& meshMap,
|
||||||
|
const fvMesh& mesh,
|
||||||
|
const fvMesh& meshToAdd
|
||||||
|
)
|
||||||
|
{
|
||||||
|
typedef DimensionedField<Type, volMesh> fldType;
|
||||||
|
|
||||||
|
// Note: use strict flag on lookupClass to avoid picking up
|
||||||
|
// volFields
|
||||||
|
HashTable<const fldType*> fields
|
||||||
|
(
|
||||||
|
mesh.objectRegistry::lookupClass<fldType>(true)
|
||||||
|
);
|
||||||
|
|
||||||
|
HashTable<const fldType*> fieldsToAdd
|
||||||
|
(
|
||||||
|
meshToAdd.objectRegistry::lookupClass<fldType>(true)
|
||||||
|
);
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
typename HashTable<const fldType*>::
|
||||||
|
iterator fieldIter = fields.begin();
|
||||||
|
fieldIter != fields.end();
|
||||||
|
++fieldIter
|
||||||
|
)
|
||||||
|
{
|
||||||
|
fldType& fld = const_cast<fldType&>(*fieldIter());
|
||||||
|
|
||||||
|
if (fieldsToAdd.found(fld.name()))
|
||||||
|
{
|
||||||
|
const fldType& fldToAdd = *fieldsToAdd[fld.name()];
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "MapDimFields : mapping " << fld.name()
|
||||||
|
<< " and " << fldToAdd.name() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
MapDimField<Type>(meshMap, fld, fldToAdd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarningIn("fvMeshAdder::MapDimFields(..)")
|
||||||
|
<< "Not mapping field " << fld.name()
|
||||||
|
<< " since not present on mesh to add"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
Reference in New Issue
Block a user