-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the deformDynMesh utility. (#756)
- Loading branch information
1 parent
1931104
commit 7c38ac1
Showing
3 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
deformDynMesh.C | ||
|
||
EXE = $(DAFOAM_ROOT_PATH)/OpenFOAM/sharedBins/deformDynMesh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
EXE_INC = \ | ||
-std=c++11 \ | ||
-Wno-old-style-cast \ | ||
-Wno-conversion-null \ | ||
-Wno-deprecated-copy \ | ||
-I$(LIB_SRC)/finiteVolume/lnInclude \ | ||
-I$(LIB_SRC)/meshTools/lnInclude \ | ||
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ | ||
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \ | ||
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude | ||
|
||
EXE_LIBS = \ | ||
-lfiniteVolume \ | ||
-lmeshTools \ | ||
-lturbulenceModels \ | ||
-lincompressibleTurbulenceModels \ | ||
-lcompressibleTurbulenceModels | ||
|
145 changes: 145 additions & 0 deletions
145
src/utilities/preProcessing/deformDynMesh/deformDynMesh.C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/*---------------------------------------------------------------------------*\ | ||
DAFoam : Discrete Adjoint with OpenFOAM | ||
Version : v4 | ||
Description | ||
Deform the mesh for field inversion | ||
\*---------------------------------------------------------------------------*/ | ||
|
||
#include "fvCFD.H" | ||
#include "argList.H" | ||
#include "Time.H" | ||
#include "fvMesh.H" | ||
#include "OFstream.H" | ||
|
||
using namespace Foam; | ||
|
||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
|
||
Info << "Deform the mesh for field inversion...." << endl; | ||
|
||
argList::addOption( | ||
"origin", | ||
"(0 0 0)", | ||
"prescribe the origin to deform the mesh"); | ||
|
||
argList::addOption( | ||
"axis", | ||
"(0 0 0)", | ||
"prescribe the axis to deform the mesh"); | ||
|
||
argList::addOption( | ||
"omega", | ||
"0", | ||
"prescribe the angular velocity to deform the mesh"); | ||
|
||
argList::addOption( | ||
"time", | ||
"-1", | ||
"prescribe a specific time to deform the mesh"); | ||
|
||
#include "setRootCase.H" | ||
#include "createTime.H" | ||
#include "createMesh.H" | ||
|
||
|
||
vector origin={0.0, 0.0, 0.0}; | ||
if (args.readIfPresent("origin", origin)) | ||
{ | ||
Info<< "The origin to rotate the mesh: " << origin << endl; | ||
} | ||
else | ||
{ | ||
Info << "origin not set!" << endl; | ||
} | ||
|
||
vector axis={0, 0, 0}; | ||
if (args.readIfPresent("axis", axis)) | ||
{ | ||
Info<< "The axis to rotate the mesh: " << axis << endl; | ||
} | ||
else | ||
{ | ||
Info << "axis center not set!" << endl; | ||
} | ||
|
||
scalar omega = 0.0; | ||
if (args.readIfPresent("omega", omega)) | ||
{ | ||
Info<< "The angular velocity to rotate the mesh: " << omega << endl; | ||
} | ||
else | ||
{ | ||
Info << "omega not set! Don't rotate mesh." << endl; | ||
} | ||
|
||
scalar time = -1.0; | ||
if (args.optionFound("time")) | ||
{ | ||
time = readScalar(args.optionLookup("time")()); | ||
if (time == 9999) | ||
{ | ||
Info << "Deform latestTime" << endl; | ||
} | ||
else | ||
{ | ||
Info << "Deform time = " << time << endl; | ||
} | ||
} | ||
else | ||
{ | ||
Info << "Time not set! Deform all time instances." << endl; | ||
} | ||
|
||
Info << "Deforming the mesh..." << endl; | ||
|
||
while (runTime.run()) | ||
{ | ||
++runTime; | ||
|
||
Info<< "Time = " << runTime.timeName() << nl << endl; | ||
|
||
pointField ourNewPoints(mesh.points()); | ||
scalar theta = omega * runTime.deltaT().value(); | ||
scalar cosTheta = std::cos(theta); | ||
scalar sinTheta = std::sin(theta); | ||
|
||
forAll(ourNewPoints, pointI) | ||
{ | ||
scalar xTemp = ourNewPoints[pointI][0] - origin[0]; | ||
scalar yTemp = ourNewPoints[pointI][1] - origin[1]; | ||
|
||
ourNewPoints[pointI][0] = cosTheta * xTemp - sinTheta * yTemp + origin[0]; | ||
ourNewPoints[pointI][1] = sinTheta * xTemp + cosTheta * yTemp + origin[1]; | ||
} | ||
|
||
mesh.movePoints(ourNewPoints); | ||
|
||
pointIOField writePoints | ||
( | ||
IOobject | ||
( | ||
"points", | ||
runTime.timeName(), | ||
"polyMesh", | ||
mesh, | ||
IOobject::NO_READ, | ||
IOobject::AUTO_WRITE | ||
), | ||
mesh.points() | ||
); | ||
|
||
runTime.write(); | ||
} | ||
|
||
Info << "Finished!" << endl; | ||
|
||
return 0; | ||
} | ||
|
||
// ************************************************************************* // |