CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (http://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   Transform rotatetranslate patch (http://www.cfd-online.com/Forums/openfoam-pre-processing/62013-transform-rotatetranslate-patch.html)

erik023 December 15, 2008 13:16

dear all, i have been looking
 
dear all,
i have been looking at some of the exsiting utilities in order to transform my mesh before running interfoam. what i like to do is to be able to rotate and/or translate part of my mesh (a patch), say a box. imagine i have a certain waterlevel in my domain and before the sim. starts i like to tranform the box as explained to evealuate differents setups.

in order to do this i looked at the rotatemesh utility and the transformpoints which are similar but only works for the whole mesh, if i understand this right?

further i looked at making some sort of submesh and transform this but still i run in to problems specifying the part i like to move and move this without errors.

has anybody tried something like this?
anybody who could maybe have an idea how to implement if there is no way already?

thank you
Erik

deepsterblue December 15, 2008 17:40

Erik, Do try this: //
 
Erik,

Do try this:


// Rotate all points belonging to the patch-name 'patchName' by 'theta'
// about an axis p1-p2, translate by a distance defined by 't', and update the mesh
void rotatePoints
(

fvMesh& mesh,
word patchName,
doubleScalar theta,
vector p1,
vector p2,
vector t
)
{

label patchID = -1;
vector p_orig, p, q;
doubleScalar costheta = Foam::cos(theta), sintheta = Foam::sin(theta);

// Define the rotation axis and normalize it
vector r = (p2-p1)/mag(p2-p1);

// Fetch the mesh-points
pointField meshPoints = mesh.points();

// Find the box patch
forAll (mesh.boundary(), patchI)
{
<blockquote>
if(mesh.boundary()[patchI].name() == patchName) {
patchID = patchI;
break;
}
}

// Move points that lie on the box patch
const labelList& boxPoints = mesh.boundaryMesh()[patchID].meshPoints();

forAll (boxPoints, index)
{

q = vector::zero;
// Fetch the point
p_orig = p = meshPoints[boxPoints[index]] + t;
// Translate to the origin
p -= p1;
// Apply the rotation matrix
q.x() += (costheta + (1 - costheta) * r.x() * r.x()) * p.x();
q.x() += ((1 - costheta) * r.x() * r.y() - r.z() * sintheta) * p.y();
q.x() += ((1 - costheta) * r.x() * r.z() + r.y() * sintheta) * p.z();

q.y() += ((1 - costheta) * r.x() * r.y() + r.z() * sintheta) * p.x();
q.y() += (costheta + (1 - costheta) * r.y() * r.y()) * p.y();
q.y() += ((1 - costheta) * r.y() * r.z() - r.x() * sintheta) * p.z();

q.z() += ((1 - costheta) * r.x() * r.z() - r.y() * sintheta) * p.x();
q.z() += ((1 - costheta) * r.y() * r.z() + r.x() * sintheta) * p.y();
q.z() += (costheta + (1 - costheta) * r.z() * r.z()) * p.z();
// Translate back to original location
q += p1;
// Assign to the mesh
meshPoints[boxPoints[index]] = q;
}

// Move the boundary points
mesh.movePoints(meshPoints);
</blockquote>
}


erik023 December 16, 2008 13:52

Sandeep, Thank you! i will
 
Sandeep,
Thank you!

i will implement this to try when i get some time over, just have a bit much now, really appreciate your help!

sincerely
Erik

erik023 December 17, 2008 15:59

brilliant, thank you, i have u
 
brilliant, thank you, i have understood the general idea!
i had some trouble thinking how to move mesh without iterating over all the points but now this works and thats happiness!
Erik

erik023 January 4, 2009 15:19

hi again, i thought i got it w
 
hi again, i thought i got it working.
in fact, nothing happends.
i see when running that the "solving for celldisplacement" is doing nothing. any idea?
thanks

deepsterblue January 4, 2009 21:53

You haven't provided BC inform
 
You haven't provided BC information to the motionSolver. Looks like you're using the displacement-based motion solvers, so you'll have to assign it using pointPatchFields. For a hint, look at:

http://www.cfd-online.com/cgi-bin/Op...=8407#POST8407


All times are GMT -4. The time now is 17:29.