Commit 07979425 authored by Franjo's avatar Franjo

Implemented scalig of surface meshes for anisotrpic meshing

parent b512d9aa
......@@ -4,6 +4,9 @@ meshSurfacePartitioner = utilities/surfaceTools/meshSurfacePartitioner
boundaryLayers = utilities/boundaryLayers
checkMeshDict = utilities/checkMeshDict
anisotropicMeshing = utilities/anisotropicMeshing
coordinateModification = $(anisotropicMeshing)/coordinateModification
meshSurfaceCheckInvertedVertices = utilities/surfaceTools/meshSurfaceCheckInvertedVertices
meshSurfaceCheckEdgeTypes = utilities/surfaceTools/meshSurfaceCheckEdgeTypes
meshSurfaceCutter = utilities/surfaceTools/meshSurfaceCutter
......@@ -136,6 +139,13 @@ $(polyMeshGen)/polyMeshGenCells.C
$(polyMeshGen2DEngine)/polyMeshGen2DEngine.C
$(coordinateModification)/coordinateModification.C
$(coordinateModification)/newCoordinateModification.C
$(coordinateModification)/planeTranslation.C
$(coordinateModification)/boxScaling.C
$(coordinateModification)/coordinateModifier.C
$(boundaryPatch)/boundaryPatchBase.C
$(boundaryPatch)/boundaryPatch.C
$(boundaryPatch)/processorBoundaryPatch.C
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "boxScaling.H"
#include "addToRunTimeSelectionTable.H"
#include "boundBox.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(boxScaling, 0);
addToRunTimeSelectionTable(coordinateModification, boxScaling, dictionary);
// * * * * * * * * * * * * * * Private member functions* * * * * * * * * * * //
void boxScaling::calculateBndBox()
{
pMin_ = centre_ - 0.5 * lengthVec_;
pMax_ = centre_ + 0.5 * lengthVec_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
boxScaling::boxScaling()
:
coordinateModification(),
centre_(),
lengthVec_(0.0, 0.0, 0.0),
scaleVec_(1.0, 1.0, 1.0),
pMin_(),
pMax_()
{
calculateBndBox();
}
boxScaling::boxScaling
(
const word& name,
const point& centre,
const scalar lengthX,
const scalar lengthY,
const scalar lengthZ,
const scalar scaleX,
const scalar scaleY,
const scalar scaleZ
)
:
coordinateModification(),
centre_(centre),
lengthVec_(lengthX, lengthY, lengthZ),
scaleVec_(scaleX, scaleY, scaleZ),
pMin_(),
pMax_()
{
calculateBndBox();
setName(name);
}
boxScaling::boxScaling
(
const word& name,
const dictionary& dict
)
:
coordinateModification(name, dict)
{
this->operator=(dict);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
point boxScaling::origin() const
{
return centre_;
}
void boxScaling::translateAndModifyObject(const vector& disp)
{
centre_ += disp;
for(direction i=0;i<vector::nComponents;++i)
lengthVec_[i] /= scaleVec_[i];
calculateBndBox();
}
vector boxScaling::displacement(const point& p) const
{
vector disp;
for(direction i=0;i<vector::nComponents;++i)
{
const scalar dispVec = lengthVec_[i] * ((1.0/scaleVec_[i]) - 1.0);
if( p[i] < pMin_[i] )
{
disp[i] = 0.0;
}
else if( (p[i] >= pMin_[i]) && (p[i] < pMax_[i]) )
{
disp[i] = ((p[i] - pMin_[i]) / lengthVec_[i]) * dispVec;
}
else
{
disp[i] = dispVec;
}
}
return disp;
}
vector boxScaling::backwardDisplacement(const point& p) const
{
vector disp;
for(direction i=0;i<vector::nComponents;++i)
{
const scalar dispVec =
lengthVec_[i] * ((1.0/scaleVec_[i]) - 1.0) * scaleVec_[i];
if( p[i] < pMin_[i] )
{
disp[i] = 0.0;
}
else if( (p[i] >= pMin_[i]) && (p[i] < pMax_[i]) )
{
disp[i] = -((p[i] - pMin_[i]) / lengthVec_[i]) * dispVec;
}
else
{
disp[i] = -dispVec;
}
}
return disp;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionary boxScaling::dict(bool ignoreType) const
{
dictionary dict;
dict.add("type", type());
dict.add("centre", centre_);
dict.add("lengthX", lengthVec_.x());
dict.add("lengthY", lengthVec_.y());
dict.add("lengthZ", lengthVec_.z());
dict.add("scaleX", scaleVec_.x());
dict.add("scaleY", scaleVec_.y());
dict.add("scaleZ", scaleVec_.z());
return dict;
}
void boxScaling::write(Ostream& os) const
{
os << " type: " << type()
<< " centre: " << centre_
<< " lengthX: " << lengthVec_.x()
<< " lengthY: " << lengthVec_.y()
<< " lengthZ: " << lengthVec_.z()
<< " scaleX: " << scaleVec_.x()
<< " scaleY: " << scaleVec_.y()
<< " scaleZ: " << scaleVec_.z()
<< endl;
}
void boxScaling::writeDict(Ostream& os, bool subDict) const
{
if( subDict )
{
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
}
// only write type for derived types
if( type() != typeName_() )
{
os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
}
os.writeKeyword("centre") << centre_ << token::END_STATEMENT << nl;
os.writeKeyword("lengthX") << lengthVec_.x() << token::END_STATEMENT << nl;
os.writeKeyword("lengthY") << lengthVec_.y() << token::END_STATEMENT << nl;
os.writeKeyword("lengthZ") << lengthVec_.z() << token::END_STATEMENT << nl;
os.writeKeyword("scaleX") << scaleVec_.x() << token::END_STATEMENT << nl;
os.writeKeyword("scaleY") << scaleVec_.y() << token::END_STATEMENT << nl;
os.writeKeyword("scaleZ") << scaleVec_.z() << token::END_STATEMENT << nl;
if( subDict )
{
os << decrIndent << indent << token::END_BLOCK << endl;
}
}
void boxScaling::operator=(const dictionary& d)
{
// allow as embedded sub-dictionary "coordinateSystem"
const dictionary& dict =
(
d.found(typeName_())
? d.subDict(typeName_())
: d
);
// unspecified centre is (0 0 0)
if( dict.found("centre") )
{
dict.lookup("centre") >> centre_;
}
else
{
FatalErrorIn
(
"void boxScaling::operator=(const dictionary& d)"
) << "Entry centre is not sopecified!" << exit(FatalError);
centre_ = vector::zero;
}
// specify lengthX
if( dict.found("lengthX") )
{
lengthVec_.x() = readScalar(dict.lookup("lengthX"));
}
else
{
FatalErrorIn
(
"void boxScaling::operator=(const dictionary& d)"
) << "Entry lengthX is not sopecified!" << exit(FatalError);
lengthVec_.x() = 0.0;
}
// specify lengthY
if( dict.found("lengthY") )
{
lengthVec_.y() = readScalar(dict.lookup("lengthY"));
}
else
{
FatalErrorIn
(
"void boxScaling::operator=(const dictionary& d)"
) << "Entry lengthY is not sopecified!" << exit(FatalError);
lengthVec_.y() = 0.0;
}
// specify lengthZ
if( dict.found("lengthZ") )
{
lengthVec_.z() = readScalar(dict.lookup("lengthZ"));
}
else
{
FatalErrorIn
(
"void boxScaling::operator=(const dictionary& d)"
) << "Entry lengthZ is not sopecified!" << exit(FatalError);
lengthVec_.z() = 0.0;
}
// specify scaleX
if( dict.found("scaleX") )
{
scaleVec_.x() = readScalar(dict.lookup("scaleX"));
}
else
{
scaleVec_.x() = 1.0;
}
// specify scaleY
if( dict.found("scaleY") )
{
scaleVec_.y() = readScalar(dict.lookup("scaleY"));
}
else
{
scaleVec_.y() = 1.0;
}
// specify scaleX
if( dict.found("scaleZ") )
{
scaleVec_.z() = readScalar(dict.lookup("scaleZ"));
}
else
{
scaleVec_.z() = 1.0;
}
calculateBndBox();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Ostream& boxScaling::operator<<(Ostream& os) const
{
os << "name " << name() << nl;
write(os);
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
boxScaling
Description
Checks if a box is contained inside the box object
SourceFiles
boxScaling.C
\*---------------------------------------------------------------------------*/
#ifndef boxScaling_H
#define boxScaling_H
#include "coordinateModification.H"
#include "point.H"
#include "typeInfo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class boxScaling Declaration
\*---------------------------------------------------------------------------*/
class boxScaling
:
public coordinateModification
{
// Private data
//- centre of the box
point centre_;
//- length of box sides
vector lengthVec_;
//- scaling factors in all directions
vector scaleVec_;
//- min point
point pMin_;
//- max point
point pMax_;
// Private member functions
//- calculate bounding box points
void calculateBndBox();
public:
//- Runtime type information
TypeName("boxScaling");
// Constructors
//- Null construct
boxScaling();
//- Construct from name, cell size, centre and sizes and scaling factors
boxScaling
(
const word& name,
const point& centre,
const scalar lengthX,
const scalar lengthY,
const scalar lengthZ,
const scalar scaleX = 1.0,
const scalar scaleY = 1.0,
const scalar scaleZ = 1.0
);
//- Construct from dictionary
boxScaling(const word& name, const dictionary& dict);
//- Construct and return a clone
virtual autoPtr<coordinateModification> clone
(
const boxScaling& bs
) const
{
return autoPtr<coordinateModification>
(
new boxScaling
(
bs.name(),
bs.centre_,
bs.lengthVec_.x(),
bs.lengthVec_.y(),
bs.lengthVec_.z(),
bs.scaleVec_.x(),
bs.scaleVec_.y(),
bs.scaleVec_.z()
)
);
}
// Member Functions
//- return the centre of the box
virtual point origin() const;
//- translate the object to the modified coordinates
//- this is needed for backward transformation
virtual void translateAndModifyObject(const vector&);
//- calculate the displacement vector for box scaling
virtual vector displacement(const point&) const;
//- calculate the displacement vector for box scaling
virtual vector backwardDisplacement(const point&) const;
//- Return as dictionary of entries
dictionary dict(bool ignoreType = false) const;
// Write
//- Write
void write(Ostream&) const;
//- Write dictionary
void writeDict(Ostream&, bool subDict = true) const;
// Member Operators
//- assign from dictionary
void operator=(const dictionary&);
// IOstream Operators
Ostream& operator<<(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "IOstream.H"
#include "coordinateModification.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(coordinateModification, 0);
defineRunTimeSelectionTable(coordinateModification, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
coordinateModification::coordinateModification()
:
name_()
{}
coordinateModification::coordinateModification
(
const word& name,
const dictionary& dict
)
:
name_(name)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
coordinateModification::~coordinateModification()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Ostream& operator<<(Ostream& os, const coordinateModification& cm)
{
os << cm.name() << nl;
cm.writeDict(os, true);
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.