August 13, 2020, 00:00
|
Combining dynamicInkjetFvmesh with layeradditionremoval
|
#1
|
New Member
heo
Join Date: Oct 2019
Posts: 3
Rep Power: 5
|
hello everyone.
I am modifying the source code of dynamicInkejetFvmesh to implement piston motion.
One problem occurred during code development, which is that the top first grid in the domain area is loosened very long.
In order to solve this problem, I thought it would be desirable to add layers in the expanded grid, and I'm looking for ways to add layers using layeradditionremoval.c and movingconetopoFvMesh.c.
What I want is to add layers as the grid relaxes, although the domain shape is fixed.
The attached code is an update part of movingconetopoFvMesh.c. As far as I know, <mapPolyMesh> is a function that implements grid movement. I wonder if there is a way to create layers without changing the grid geometry.
Code:
bool Foam::movingConeTopoFvMesh::update()
317 {
318 // Do mesh changes (use inflation - put new points in topoChangeMap)
319 autoPtr<mapPolyMesh> topoChangeMap = topoChanger_.changeMesh(true);
320
321 // Calculate the new point positions depending on whether the
322 // topological change has happened or not
323 pointField newPoints;
324
325 vector curMotionVel_ =
326 motionVelAmplitude_*
327 Foam::sin(time().value()*M_PI/motionVelPeriod_);
328
329 Pout<< "time:" << time().value() << " curMotionVel_:" << curMotionVel_
330 << " curLeft:" << curLeft_ << " curRight:" << curRight_
331 << endl;
332
333 if (topoChangeMap.valid())
334 {
335 Info<< "Topology change. Calculating motion points" << endl;
336
337 if (topoChangeMap().hasMotionPoints())
338 {
339 Info<< "Topology change. Has premotion points" << endl;
340
341 motionMask_ =
342 vertexMarkup
343 (
344 topoChangeMap().preMotionPoints(),
345 curLeft_,
346 curRight_
347 );
348
349 // Move points inside the motionMask
350 newPoints =
351 topoChangeMap().preMotionPoints()
352 + (
353 pos(0.5 - mag(motionMask_)) // cells above the body
354 )*curMotionVel_*time().deltaT().value();
355 }
356 else
357 {
358 Info<< "Topology change. Already set mesh points" << endl;
359
360 motionMask_ =
361 vertexMarkup
362 (
363 points(),
364 curLeft_,
365 curRight_
366 );
367
368 // Move points inside the motionMask
369 newPoints =
370 points()
371 + (
372 pos(0.5 - mag(motionMask_)) // cells above the body
373 )*curMotionVel_*time().deltaT().value();
374 }
375 }
376 else
377 {
378 Info<< "No topology change" << endl;
379 // Set the mesh motion
380 newPoints =
381 points()
382 + (
383 pos(0.5 - mag(motionMask_)) // cells above the body
384 )*curMotionVel_*time().deltaT().value();
385 }
386
387 // The mesh now contains the cells with zero volume
388 Info << "Executing mesh motion" << endl;
389 movePoints(newPoints);
390 // The mesh now has got non-zero volume cells
391
392 curLeft_ = average
393 (
394 faceZones()
395 [
396 faceZones().findZoneID("leftExtrusionFaces")
397 ]().localPoints()
398 ).x() - SMALL;
399
400 curRight_ = average
401 (
402 faceZones()
403 [
404 faceZones().findZoneID("rightExtrusionFaces")
405 ]().localPoints()
406 ).x() + SMALL;
407
408
409 return true;
410 }
|
|
|