Commit 31dd5faf authored by mattijs's avatar mattijs
Browse files

sliced fields as unallocated copies

parent 0b4d8e58
......@@ -97,6 +97,68 @@ slicedBoundaryField
}
template
<
class Type,
template<class> class PatchField,
template<class> class SlicedPatchField,
class GeoMesh
>
Foam::tmp<Foam::FieldField<PatchField, Type> >
Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
slicedBoundaryField
(
const Mesh& mesh,
const FieldField<PatchField, Type>& bField,
const bool preserveCouples
)
{
tmp<FieldField<PatchField, Type> > tbf
(
new FieldField<PatchField, Type>(mesh.boundary().size())
);
FieldField<PatchField, Type>& bf = tbf();
forAll (mesh.boundary(), patchi)
{
if (preserveCouples && mesh.boundary()[patchi].coupled())
{
// For coupled patched construct the correct patch field type
bf.set
(
patchi,
PatchField<Type>::New
(
mesh.boundary()[patchi].type(),
mesh.boundary()[patchi],
*this
)
);
// Assign field
bf[patchi] == bField[patchi];
}
else
{
// Create unallocated copy of patch field
bf.set
(
patchi,
new SlicedPatchField<Type>
(
mesh.boundary()[patchi],
DimensionedField<Type, GeoMesh>::null()
)
);
bf[patchi].UList<Type>::operator=(bField[patchi]);
}
}
return tbf;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
......@@ -204,6 +266,64 @@ SlicedGeometricField
}
template
<
class Type,
template<class> class PatchField,
template<class> class SlicedPatchField,
class GeoMesh
>
Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
SlicedGeometricField
(
const IOobject& io,
const GeometricField<Type, PatchField, GeoMesh>& gf,
const bool preserveCouples
)
:
GeometricField<Type, PatchField, GeoMesh>
(
io,
gf.mesh(),
gf.dimensions(),
Field<Type>(),
slicedBoundaryField(gf.mesh(), gf.boundaryField(), preserveCouples)
)
{
// Set the internalField to the supplied internal field
UList<Type>::operator=(gf.internalField());
correctBoundaryConditions();
}
template
<
class Type,
template<class> class PatchField,
template<class> class SlicedPatchField,
class GeoMesh
>
Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
SlicedGeometricField
(
const SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>& gf
)
:
GeometricField<Type, PatchField, GeoMesh>
(
gf,
gf.mesh(),
gf.dimensions(),
Field<Type>(),
slicedBoundaryField(gf.mesh(), gf.boundaryField(), true)
)
{
// Set the internalField to the supplied internal field
UList<Type>::operator=(gf.internalField());
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template
......
......@@ -87,8 +87,17 @@ private:
const bool preserveCouples
);
//- Disallow default bitwise copy construct
SlicedGeometricField(const SlicedGeometricField&);
//- Slice the given field and a create a PtrList of SlicedPatchField
// from which the boundary field is built
tmp<FieldField<PatchField, Type> > slicedBoundaryField
(
const Mesh& mesh,
const FieldField<PatchField, Type>& bField,
const bool preserveCouples
);
////- Disallow default bitwise copy construct
//SlicedGeometricField(const SlicedGeometricField&);
//- Disallow default bitwise assignment
void operator=(const SlicedGeometricField&);
......@@ -128,6 +137,27 @@ public:
const bool preserveCouples=true
);
//- Construct from GeometricField. Reuses full internal and
// patch fields except on couples (preserveCouples=true).
SlicedGeometricField
(
const IOobject&,
const GeometricField<Type, PatchField, GeoMesh>&,
const bool preserveCouples=true
);
//- Construct as copy
SlicedGeometricField
(
const SlicedGeometricField
<
Type,
PatchField,
SlicedPatchField,
GeoMesh
>&
);
// Destructor
......
......@@ -56,13 +56,7 @@ slicedFvPatchField<Type>::slicedFvPatchField
)
:
fvPatchField<Type>(p, iF)
{
notImplemented
(
"slicedFvPatchField<Type>::"
"slicedFvPatchField(const fvPatch&, const Field<Type>&)"
);
}
{}
template<class Type>
......
......@@ -75,7 +75,7 @@ public:
const Field<Type>&
);
//- Construct from patch and internal field
//- Construct from patch and internal field. Assign value later.
slicedFvPatchField
(
const fvPatch&,
......
......@@ -56,13 +56,7 @@ slicedFvsPatchField<Type>::slicedFvsPatchField
)
:
fvsPatchField<Type>(p, iF)
{
notImplemented
(
"slicedFvsPatchField<Type>::"
"slicedFvsPatchField(const fvPatch&, const Field<Type>&)"
);
}
{}
template<class Type>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment