Added constrained types for immersedBoundary patch

This commit is contained in:
Hrvoje Jasak 2017-12-13 18:58:31 +00:00
parent 1b36d98057
commit b77d52e39b
11 changed files with 760 additions and 32 deletions

View file

@ -4,7 +4,8 @@ immersedPoly/distanceFunctions/triSurfaceDistance/triSurfaceDistance.C
immersedBoundaryPolyPatch/immersedBoundaryPolyPatch.C
immersedBoundaryPointPatch/immersedBoundaryPointPatch.C
immersedBoundaryFvPatch/immersedBoundaryFvPatch.C
immersedBoundaryFvPatchField/immersedBoundaryFvPatchFields.C
immersedBoundaryFvsPatchField/immersedBoundaryFvsPatchFields.C
mixedIbFvPatchField/mixedIbFvPatchFields.C
/* immersedBoundaryFvsPatchField/immersedBoundaryFvsPatchFields.C */
LIB = $(FOAM_LIBBIN)/libimmersedBoundary

View file

@ -0,0 +1,227 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / 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 "immersedBoundaryFvPatchField.H"
#include "fvPatchFieldMapper.H"
#include "fvMatrix.H"
#include "surfaceWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
immersedBoundaryFvPatchField<Type>::immersedBoundaryFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF
)
:
fvPatchField<Type>(p, iF),
ibPatch_(refCast<const immersedBoundaryFvPatch>(p))
{}
template<class Type>
immersedBoundaryFvPatchField<Type>::immersedBoundaryFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const dictionary& dict
)
:
fvPatchField<Type>(p, iF), // Do not read mixed data
ibPatch_(refCast<const immersedBoundaryFvPatch>(p))
{
if (!isType<immersedBoundaryFvPatch>(p))
{
FatalIOErrorIn
(
"immersedBoundaryFvPatchField<Type>::"
"immersedBoundaryFvPatchField\n"
"(\n"
" const fvPatch& p,\n"
" const Field<Type>& field,\n"
" const dictionary& dict\n"
")\n",
dict
) << "\n patch type '" << p.type()
<< "' not constraint type '" << typeName << "'"
<< "\n for patch " << p.name()
<< " of field " << this->dimensionedInternalField().name()
<< " in file " << this->dimensionedInternalField().objectPath()
<< exit(FatalIOError);
}
Field<Type>::operator=(this->patchInternalField());
}
template<class Type>
immersedBoundaryFvPatchField<Type>::immersedBoundaryFvPatchField
(
const immersedBoundaryFvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fvPatchField<Type>(p, iF), // Do not map base data
ibPatch_(refCast<const immersedBoundaryFvPatch>(p))
{
// Note: NO MAPPING. Fields are created on the immersed boundary
// HJ, 12/Apr/2012
if (!isType<immersedBoundaryFvPatch>(p))
{
FatalErrorIn
(
"immersedBoundaryFvPatchField<Type>::"
"immersedBoundaryFvPatchField\n"
"(\n"
" const immersedBoundaryFvPatchField<Type>&,\n"
" const fvPatch& p,\n"
" const DimensionedField<Type, volMesh>& iF,\n"
" const fvPatchFieldMapper& mapper\n"
")\n"
) << "\n patch type '" << p.type()
<< "' not constraint type '" << typeName << "'"
<< "\n for patch " << p.name()
<< " of field " << this->dimensionedInternalField().name()
<< " in file " << this->dimensionedInternalField().objectPath()
<< exit(FatalIOError);
}
// On creation of the mapped field, the internal field is dummy and
// cannot be used. Initialise the value to avoid errors
// HJ, 1/Dec/2017
Field<Type>::operator=(Field<Type>(p.size(), pTraits<Type>::zero));
}
template<class Type>
immersedBoundaryFvPatchField<Type>::immersedBoundaryFvPatchField
(
const immersedBoundaryFvPatchField<Type>& ptf
)
:
fvPatchField<Type>(ptf),
ibPatch_(ptf.ibPatch())
{}
template<class Type>
immersedBoundaryFvPatchField<Type>::immersedBoundaryFvPatchField
(
const immersedBoundaryFvPatchField<Type>& ptf,
const DimensionedField<Type, volMesh>& iF
)
:
fvPatchField<Type>(ptf, iF),
ibPatch_(ptf.ibPatch())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void immersedBoundaryFvPatchField<Type>::autoMap
(
const fvPatchFieldMapper& m
)
{
// Use internal values
Field<Type>::operator=(this->patchInternalField());
}
template<class Type>
void immersedBoundaryFvPatchField<Type>::rmap
(
const fvPatchField<Type>& ptf,
const labelList&
)
{
// Use internal values
Field<Type>::operator=(this->patchInternalField());
}
template<class Type>
void immersedBoundaryFvPatchField<Type>::evaluate
(
const Pstream::commsTypes
)
{
// Use internal values
Field<Type>::operator=(this->patchInternalField());
fvPatchField<Type>::evaluate();
}
template<class Type>
void immersedBoundaryFvPatchField<Type>::write(Ostream& os) const
{
// Resolve post-processing issues. HJ, 1/Dec/2017
fvPatchField<Type>::write(os);
// The value entry needs to be written with zero size
Field<Type>::null().writeEntry("value", os);
// Write VTK on master only
if (Pstream::master())
{
// Add parallel reduction of all faces and data to proc 0
// and write the whola patch together
// Write immersed boundary data as a vtk file
autoPtr<surfaceWriter<Type> > writerPtr =
surfaceWriter<Type>::New("vtk");
// Get the intersected patch
const standAlonePatch& ts = ibPatch_.ibPolyPatch().ibPatch();
writerPtr->write
(
this->dimensionedInternalField().path(),
ibPatch_.name(),
ts.points(),
ts,
this->dimensionedInternalField().name(),
*this,
surfaceWriterBase::FACE_DATA
);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,200 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / 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::immersedBoundaryFvPatchField
Description
Constrained immersedBoundaryFvPatchField of calculated functionality
with appropriate resizing on topo change or motion of the immersed surface.
The patch field shall take the values of intersected cells.
Note: This patch field is used instead of the calculated type in the
immersedBoundaryFvPatch. It does not support discretisation.
For matrix operations, use the mixedIbFvPatchField.
Author
Hrvoje Jasak
SourceFiles
immersedBoundaryFvPatchField.C
\*---------------------------------------------------------------------------*/
#ifndef immersedBoundaryFvPatchField_H
#define immersedBoundaryFvPatchField_H
#include "fvPatchField.H"
#include "immersedBoundaryFvPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class immersedBoundaryFvPatchField Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class immersedBoundaryFvPatchField
:
public fvPatchField<Type>
{
// Private data
//- Local reference to immersed boundary patch
const immersedBoundaryFvPatch& ibPatch_;
public:
//- Runtime type information: constrained type
TypeName(immersedBoundaryFvPatch::typeName_());
// Constructors
//- Construct from patch and internal field
immersedBoundaryFvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&
);
//- Construct from patch, internal field and dictionary
immersedBoundaryFvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const dictionary&
);
//- Construct by mapping given immersedBoundaryFvPatchField
// onto a new patch
immersedBoundaryFvPatchField
(
const immersedBoundaryFvPatchField<Type>&,
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
immersedBoundaryFvPatchField
(
const immersedBoundaryFvPatchField<Type>&
);
//- Construct and return a clone
virtual tmp<fvPatchField<Type> > clone() const
{
return tmp<fvPatchField<Type> >
(
new immersedBoundaryFvPatchField<Type>(*this)
);
}
//- Construct as copy setting internal field reference
immersedBoundaryFvPatchField
(
const immersedBoundaryFvPatchField<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 immersedBoundaryFvPatchField<Type>(*this, iF)
);
}
//- Destructor
virtual ~immersedBoundaryFvPatchField()
{}
// Member functions
// Access
//- Return reference to immersed boundary patch
const immersedBoundaryFvPatch& ibPatch() const
{
return ibPatch_;
}
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchField<Type>&,
const labelList&
);
// Evaluation functions
//- Evaluate the patch field
virtual void evaluate
(
const Pstream::commsTypes commsType = Pstream::blocking
);
// I-O
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "immersedBoundaryFvPatchField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,44 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / 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 "volFields.H"
#include "surfaceFields.H"
#include "immersedBoundaryFvPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makePatchFields(immersedBoundary);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / 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 immersedBoundaryFvPatchFields_H
#define immersedBoundaryFvPatchFields_H
#include "immersedBoundaryFvPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeFieldTypedefs(immersedBoundary)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,51 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / 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 immersedBoundaryFvPatchFieldsFwd_H
#define immersedBoundaryFvPatchFieldsFwd_H
#include "fvPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> class immersedBoundaryFvPatchField;
makePatchTypeFieldTypedefs(immersedBoundary)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -32,6 +32,19 @@ License
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void immersedBoundaryFvsPatchField<Type>::updateSize()
{
if (this->patch().size() != this->size())
{
Info<< "RESIZING immersedBoundaryFvsPatchField" << endl;
this->setSize(this->patch().size());
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
@ -96,18 +109,47 @@ immersedBoundaryFvsPatchField<Type>::immersedBoundaryFvsPatchField
{}
// template<class Type>
// void immersedBoundaryFvsPatchField<Type>::operator=
// (
// const fvPatchField<Type>& ptf
// )
// {
// const immersedBoundaryFvPatchField<Type>& ibf =
// refCast<const immersedBoundaryFvPatchField<Type> > (ptf);
template<class Type>
void immersedBoundaryFvsPatchField<Type>::autoMap
(
const fvPatchFieldMapper& m
)
{
Info<< "immersedBoundaryFvsPatchField<Type><Type>::autoMap" << endl;
Field<Type>::operator=
(
Field<Type>(this->patch().size(), pTraits<Type>::zero)
);
}
// this->check(ptf);
// fvsPatchField<Type>::operator=(ptf);
// }
template<class Type>
void immersedBoundaryFvsPatchField<Type>::rmap
(
const fvsPatchField<Type>& ptf,
const labelList& addr
)
{
Field<Type>::operator=
(
Field<Type>(this->patch().size(), pTraits<Type>::zero)
);
}
template<class Type>
void immersedBoundaryFvsPatchField<Type>::evaluate
(
const Pstream::commsTypes
)
{
Info<< "immersedBoundaryFvsPatchField<Type>::evaluate" << endl;
this->updateSize();
Field<Type>::operator=
(
Field<Type>(this->patch().size(), pTraits<Type>::zero)
);
}
template<class Type>
@ -118,6 +160,88 @@ void immersedBoundaryFvsPatchField<Type>::write(Ostream& os) const
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Type>
void immersedBoundaryFvsPatchField<Type>::operator=
(
const UList<Type>& ul
)
{
this->updateSize();
Field<Type>::operator=(ul);
}
template<class Type>
void immersedBoundaryFvsPatchField<Type>::operator=
(
const fvsPatchField<Type>& ptf
)
{
this->check(ptf);
this->updateSize();
Field<Type>::operator=(ptf);
}
template<class Type>
void immersedBoundaryFvsPatchField<Type>::operator=
(
const fvPatchField<Type>& ptf
)
{
this->check(ptf);
this->updateSize();
fvsPatchField<Type>::operator=(ptf);
}
template<class Type>
void immersedBoundaryFvsPatchField<Type>::operator=
(
const Type& t
)
{
this->updateSize();
Field<Type>::operator=(t);
}
// Force an assignment, overriding fixedValue status
template<class Type>
void immersedBoundaryFvsPatchField<Type>::operator==
(
const fvsPatchField<Type>& ptf
)
{
this->updateSize();
Field<Type>::operator=(ptf);
}
template<class Type>
void immersedBoundaryFvsPatchField<Type>::operator==
(
const Field<Type>& tf
)
{
this->updateSize();
Field<Type>::operator=(tf);
}
template<class Type>
void immersedBoundaryFvsPatchField<Type>::operator==
(
const Type& t
)
{
this->updateSize();
Field<Type>::operator=(t);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View file

@ -66,6 +66,12 @@ class immersedBoundaryFvsPatchField
const immersedBoundaryFvPatch& ibPatch_;
// Private Member Functions
//- Update field size to match the patch
void updateSize();
public:
//- Runtime type information
@ -141,6 +147,15 @@ public:
// Member functions
// Access
//- Return reference to immersed boundary patch
const immersedBoundaryFvPatch& ibPatch() const
{
return ibPatch_;
}
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
@ -152,18 +167,19 @@ public:
//- Reverse map the given fvsPatchField onto this fvsPatchField
virtual void rmap
(
const fvPatchField<Type>&,
const fvsPatchField<Type>&,
const labelList&
);
// Member functions
// Evaluation functions
//- Evaluate the patch field, sets Updated to false
virtual void evaluate
(
const Pstream::commsTypes commsType = Pstream::blocking
);
//- Return reference to immersed boundary patch
const immersedBoundaryFvPatch& ibPatch() const
{
return ibPatch_;
}
//- Write
virtual void write(Ostream&) const;
@ -171,7 +187,23 @@ public:
// Member operators
// virtual void operator=(const fvPatchField<Type>&);
// Note: All assignment operators can check size and resize
// Other operators cannot, as they assume an existing valid value
// HJ, 13/Dec/2017
virtual void operator=(const UList<Type>&);
virtual void operator=(const fvsPatchField<Type>&);
virtual void operator=(const fvPatchField<Type>&);
virtual void operator=(const Type&);
// Force an assignment irrespective of form of patch
virtual void operator==(const fvsPatchField<Type>&);
virtual void operator==(const Field<Type>&);
virtual void operator==(const Type&);
};

View file

@ -27,7 +27,6 @@ License
#include "fvsPatchFields.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "immersedBoundaryFvPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -31,9 +31,6 @@ License
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
@ -320,8 +317,10 @@ void mixedIbFvPatchField<Type>::evaluate
template<class Type>
void mixedIbFvPatchField<Type>::write(Ostream& os) const
{
// to resolve the post-processing issues. HJ, 1/Dec/2017
// Resolve post-processing issues. HJ, 1/Dec/2017
fvPatchField<Type>::write(os);
os.writeKeyword("patchType")
<< immersedBoundaryFvPatch::typeName << token::END_STATEMENT << nl;
triValue_.writeEntry("triValue", os);
triGrad_.writeEntry("triGradient", os);
triValueFraction_.writeEntry("triValueFraction", os);
@ -338,7 +337,7 @@ void mixedIbFvPatchField<Type>::write(Ostream& os) const
{
// Add parallel reduction of all faces and data to proc 0
// and write the whola patch together
// Write immersed boundary data as a vtk file
autoPtr<surfaceWriter<Type> > writerPtr =
surfaceWriter<Type>::New("vtk");

View file

@ -47,7 +47,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class mixedIbFvPatchField Declaration
Class mixedIbFvPatchField Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
@ -176,11 +176,13 @@ public:
// Member functions
//- Return reference to immersed boundary patch
const immersedBoundaryFvPatch& ibPatch() const
{
return ibPatch_;
}
// Access
//- Return reference to immersed boundary patch
const immersedBoundaryFvPatch& ibPatch() const
{
return ibPatch_;
}
// Return defining fields