Adding initial version of the mesquiteMotionSolver, and associated tutorial.

Also including modifications to the include path for icoDyMFoam
This commit is contained in:
Sandeep Menon 2010-10-17 13:08:28 -04:00
parent aa01c38435
commit 34693bd858
25 changed files with 55918 additions and 2 deletions

View file

@ -1,6 +1,6 @@
EXE_INC = \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude

View file

@ -5,6 +5,7 @@ set -x
# Make meshMotion solvers
wmake libso fvMotionSolver
wmake libso RBFMotionSolver
wmake libso mesquiteMotionSolver
(cd tetDecompositionMotionSolver ; ./Allwmake)
# ----------------------------------------------------------------- end-of-file

View file

@ -4,3 +4,4 @@ set -x
wmakeLnInclude fvMotionSolver
wmakeLnInclude RBFMotionSolver
wmakeLnInclude mesquiteMotionSolver

View file

@ -0,0 +1,3 @@
mesquiteMotionSolver.C
LIB = $(FOAM_LIBBIN)/libmesquiteMotionSolver

View file

@ -0,0 +1,9 @@
EXE_INC = \
-I$(WM_THIRD_PARTY_DIR)/mesquite-2.1.2/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/dynamicMesh/lnInclude \
LIB_LIBS = \
-lmeshTools \
-ldynamicMesh \
-lmesquite

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,301 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
mesquiteMotionSolver
Description
Thin interface to the Mesquite Mesh Improvement library.
Also provides surface-mesh smoothing capabilities.
SourceFiles
mesquiteMotionSolver.C
\*---------------------------------------------------------------------------*/
#ifndef mesquiteMotionSolver_H
#define mesquiteMotionSolver_H
#include "motionSolver.H"
#include "Time.H"
#include "Map.H"
#include "Switch.H"
#include "edgeList.H"
#include "pointIOField.H"
#include "HashSet.H"
// Have gcc ignore certain warnings while including mesquite headers
#pragma GCC diagnostic ignored "-Wold-style-cast"
#include "Mesquite_all_headers.hpp"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Class forward declarations
class polyMesh;
/*---------------------------------------------------------------------------*\
Class mesquiteMotionSolver Declaration
\*---------------------------------------------------------------------------*/
class mesquiteMotionSolver
:
public motionSolver
{
// Private data
//- The mesh to be moved
const polyMesh& Mesh_;
//- Mesh characteristics [2D/3D]
Switch twoDMesh_;
//- Number of points
unsigned long nPoints_;
//- Number of elements
unsigned long nCells_;
//- Number of auxiliary points
label nAuxPoints_;
//- Number of auxiliary elements
label nAuxCells_;
//- Switch to toggle surface smoothing
Switch surfaceSmoothing_;
//- Switch to toggle volume correction
Switch volumeCorrection_;
//- Specify tolerance for volume correction
scalar volCorrTolerance_;
//- Specify max volume correction iterations
label volCorrMaxIter_;
// Specify tolerance for the CG solver
scalar tolerance_;
//- Specify multiple mesh-motion sweeps
label nSweeps_;
//- Specify the surface-smoothing interval
label surfInterval_;
//- Specify a relaxation factor for surface-smoothing
scalar relax_;
//- Vertex coordinate array passed into Mesquite
mutable double* vtxCoords_;
//- Connectivity array passed into mesquite
mutable unsigned long* cellToNode_;
//- Flag array for vertices (fixed/free)
mutable int* fixFlags_;
//- Reference points
mutable pointIOField refPoints_;
//- Original points prior to surface-smoothing
mutable pointField origPoints_;
//- Map for the auxiliary entities
Map<Map<label> > auxPointMap_;
Map<Map<label> > auxSurfPointMap_;
//- The quality metric
word qMetric_;
//- Pointers to base element metric class
HashTable<autoPtr<Mesquite::QualityMetric> > qMetricTable_;
//- Pointer to base objective function
autoPtr<Mesquite::ObjectiveFunction> objFunction_;
//- Pointer to base optimization algorithm (vertex mover)
autoPtr<Mesquite::VertexMover> optAlgorithm_;
//- Termination criteria
Mesquite::TerminationCriterion tcInner_;
Mesquite::TerminationCriterion tcOuter_;
//- Data specific to Laplacian surface smoothing
labelList pIDs_;
labelList offsets_;
List<vectorField> pNormals_;
List<vectorField> gradEdge_;
List<vectorField> localPts_;
List<scalarField> edgeMarker_;
Map<vectorField> sendFields_;
Map<vectorField> recvFields_;
//- Explicit patch coupling for surface smoothing
Map<label> patchCoupling_;
// Fields for the CG solver
vectorField bV_;
vectorField xV_;
vectorField pV_;
vectorField rV_;
vectorField wV_;
vectorField bdy_;
scalarField pointMarker_;
scalar oldVolume_;
// Private Member Functions
// Sparse Matrix multiply
void A(const vectorField& p, vectorField& w);
// Dot-product
scalar dot(const vectorField& f1, const vectorField& f2);
// CG solver
label CG
(
const vectorField& b,
vectorField& p,
vectorField& r,
vectorField& w,
vectorField& x
);
// Compute the normalization factor for the matrix
scalar normFactor
(
const vectorField& x,
const vectorField& b,
const vectorField& w,
vectorField& tmpField
);
// Component-wise sumMag
scalar cmptSumMag(const vectorField& field);
// Transfer buffers after divergence compute.
void transferBuffers(vectorField &field);
// Apply boundary conditions
void applyBCs(vectorField &field);
// Private member function to compute connectivity data
void initArrays();
// Private member function to construct parallel connectivity data
void initParallelConnectivity();
// Copy auxiliary points to/from buffers
void copyAuxiliaryPoints(bool copyBack = false);
// Private member functions to read dictionary options
void readOptions();
// Apply fixed-value boundary conditions, if any.
void applyFixedValuePatches();
// Private member function to perform Laplacian surface smoothing
void smoothSurfaces();
// Compute quality of a tetrahedral cell
scalar tetQuality
(
const label cIndex,
const pointField& pField
);
// Private member function to check for invalid
// cells and correct if necessary.
void correctInvalidCells();
// Enforce cylindrical constraints for slip-patches
void enforceCylindricalConstraints();
// Prepare point-normals with updated point positions
void preparePointNormals();
// Utility method to check validity of cells connected to a point.
bool checkValidity
(
const vector& x,
const labelList& jList,
scalar& beta
);
// Clear out addressing
void clearOut();
public:
//- Runtime type information
ClassName("mesquiteMotionSolver");
// Constructors
//- Construct from polyMesh
mesquiteMotionSolver(const polyMesh& mesh);
mesquiteMotionSolver(const polyMesh& mesh, Istream& msData);
// Destructor
virtual ~mesquiteMotionSolver();
// Member Functions
//- Return reference to the mesh to be moved
const polyMesh& mesh() const
{
return Mesh_;
}
//- Return point location obtained from the current motion field
virtual tmp<pointField> curPoints() const;
//- Solve for motion
virtual void solve();
//- Update topology
virtual void updateMesh(const mapPolyMesh&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,54 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class tetPointVectorField;
object motionU;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
bottomWall
{
type fixedValue;
value uniform (0 0 0);
}
sideWall
{
type slip;
}
topWall
{
type oscillatingFixedValue;
refValue uniform (0 0 0);
amplitude uniform (0 0 0.5);
frequency 0.1;
//type fixedValue;
//value uniform (0 0 0.1);
}
outlet
{
type fixedValue;
value uniform (0 0 0);
}
}
// ************************************************************************* //

View file

@ -0,0 +1,14 @@
#!/bin/sh
currDir=`pwd`
application=`basename $currDir`
cases="circCylinder3d"
tutorialPath=`dirname $0`/..
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
for case in $cases
do
cleanTimeDirectories $case
done

View file

@ -0,0 +1,11 @@
#!/bin/bash
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
# Get application name
application=`getApplication`
#parentDir=`dirname $PWD`
#application=`basename $parentDir`
runApplication $application

View file

@ -0,0 +1,109 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object dynamicMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Select the type of dynamicFvMesh, and load custom library
dynamicFvMesh dynamicMotionSolverFvMesh;
// Load custom libraries
motionSolverLibs ("libmesquiteMotionSolver.so");
solver mesquiteMotionSolver;
mesquiteOptions
{
// Optimization metric
optMetric AspectRatioGamma;
// Objective function
objFunction LPtoP;
// Optimization algorithm
optAlgorithm FeasibleNewton;
// Termination criteria sub-dictionary
// (takes default values if not specified)
// Specifying an empty sub-dictionary
// terminates with available options
tcInner
{
absGradL2 1e-4;
cpuTime 0.5;
}
// tcOuter
// {}
// For composite functions, two objectives need to be specified
// firstFunction LPtoP;
// secondFunction LInf;
// For scaled functions, scale and objective needs to be specified
// scaleFunction PMeanP;
// scale 1.5;
// Power value for the LPtoP objective function
pValue 2;
power 2;
// Specify a tolerance for the surface-smoothing CG solver
tolerance 1e-2;
// Specify number of CG sweeps for surface-smoothing
nSweeps 2;
// Specify slip patches for the motionSolver
slipPatches
{
sideWall;
topWall;
}
cylindricalConstraints
{
// Specify options per slip patch
sideWall
{
axisPoint (0.0 0.0 0.0);
axisVector (0.0 0.0 1.0);
radius 1.0;
}
}
// Specify fixedValue patches for the motionSolver
fixedValuePatches
{
topWall
{
//type angularOscillatingDisplacement;
//amplitude -0.0125;
type oscillatingDisplacement;
amplitude (0 0 -0.01);
axis (1 0 0);
origin (0 0 3);
angle0 0.0;
omega 0.15;
value uniform (0 0 0);
}
}
// Specify interval for surface smoothing
surfInterval 1;
}
// ************************************************************************* //

View file

@ -0,0 +1,47 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class polyBoundaryMesh;
location "constant/polyMesh";
object boundary;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
4
(
outlet
{
type patch;
nFaces 29;
startFace 16089;
}
bottomWall
{
type wall;
nFaces 174;
startFace 16118;
}
topWall
{
type wall;
nFaces 175;
startFace 16292;
}
sideWall
{
type wall;
nFaces 1068;
startFace 16467;
}
)
// ************************************************************************* //

View file

@ -0,0 +1,23 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class regIOobject;
location "constant/polyMesh";
object cellZones;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
0
(
)
// ************************************************************************* //

View file

@ -0,0 +1,23 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class regIOobject;
location "constant/polyMesh";
object faceZones;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
0
(
)
// ************************************************************************* //

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,23 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class regIOobject;
location "constant/polyMesh";
object pointZones;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
0
(
)
// ************************************************************************* //

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,34 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class wordList;
location "constant/polyMesh";
object zoneToPatchName;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
9
(
unknown
unknown
unknown
outlet
bottomWall
topWall
sideWall
unknown
default-interior
)
// ************************************************************************* //

View file

@ -0,0 +1,52 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application moveDynamicMesh;
startTime 0;
startFrom latestTime;
endTime 20.0;
stopAt endTime;
deltaT 0.1;
adjustTimeStep no;
maxCo 0.8;
writeControl timeStep;
writeInterval 20;
writeFormat ascii;
writeCompression uncompressed;
timeFormat general;
timePrecision 11;
runTimeModifiable yes;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -0,0 +1,39 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 4;
method metis;
tolerance 5e-16;
distributed no;
simpleCoeffs
{
n (1 1 1);
delta 0.001;
}
roots
(
);
// ************************************************************************* //

View file

@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default none;
}
gradSchemes
{
default none;
}
divSchemes
{
default none;
}
laplacianSchemes
{
default none;
}
interpolationSchemes
{
default none;
}
snGradSchemes
{
default none;
}
fluxRequired
{
default none;
}
// ************************************************************************* //

View file

@ -0,0 +1,26 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{}
PISO
{}
// ************************************************************************* //

View file

@ -0,0 +1,24 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object tetFemTolerances;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
motionU ICCG 1e-9 0.001;
}
// ************************************************************************* //