CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

moveDynamicMesh BCs

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes
  • 2 Post By kayla1994
  • 2 Post By kayla1994
  • 2 Post By tladd

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 9, 2018, 08:03
Cool moveDynamicMesh BCs
  #1
Member
 
Massachusetts
Join Date: Jun 2015
Posts: 46
Rep Power: 11
kayla1994 is on a distinguished road
Hello everybody,
I need to move the surface points of my mesh according to a surface sensitivity.
I found this code

http://www.tfd.chalmers.se/~hani/kur..._corrected.pdf

but the problem is that my boundary has a complex geometry and I cannot define simply one fixed normal vector in the boundary conditions. So I would like to know what type of boundary I should set to get all the normal vector (and not a single one) in the pointDisplacement file.

Best regards
atulkjoy and xiangxiang like this.
kayla1994 is offline   Reply With Quote

Old   October 9, 2018, 12:15
Default
  #2
Member
 
Massachusetts
Join Date: Jun 2015
Posts: 46
Rep Power: 11
kayla1994 is on a distinguished road
Some more details.
This is part of the code. The goal is to move surface "wall" according to a displacement proportional to the "sensitivity".

Code:
word patchName = "wall";
label patchID = mesh.boundaryMesh().findPatchID(patchName);

pointVectorField& PointDisplacement = const_cast<pointVectorField&>
(
	mesh.objectRegistry::lookupObject<pointVectorField>
	(
		"pointDisplacement"
	)
);


// GETTING THE PATCH VECTOR FIELD
vectorField &pDisp = refCast<vectorField>(PointDisplacement.boundaryFieldRef()[patchID]);

// FIND THE RELEVANT SIZE OF THE VECTOR AND DECLARE A VECTORFIELD
int Psize = pDisp.size();
vectorField dispVals(Psize);

// SETTING-UP INTERPOLATOR
primitivePatchInterpolation patchInterpolator(mesh.boundaryMesh()[patchID]);

// DISPLACEMENT BASED ON SURFACE SENSITIVITY
scalarField sensitivityPatch = sensitivity.boundaryFieldRef()[patchID];

// INTERPOLATION
scalarField faceValues = patchInterpolator.faceToPointInterpolate(sensitivityPatch);

vectorField &PointPointer = refCast<vectorField>(PointDisplacement.boundaryFieldRef()[patchID]);

vectorField PointNormalVector = mesh.boundaryMesh()[patchID].pointNormals();


// LOOP OVER ALL POINTS
forAll(dispVals,index)
{
	dispVals[index].x() = PointPointer[index].x() -alpha.value() * faceValues[index] * PointNormalVector[index].x();

	dispVals[index].y() = PointPointer[index].y() - alpha.value() * faceValues[index] * PointNormalVector[index].y();

	dispVals[index].z() = PointPointer[index].z() - alpha.value() * faceValues[index] * PointNormalVector[index].z();

}


// ONCE THE VALUES HAVE BEEN ASSIGNED TO DISPVALS ASSIGN THEM TO cellDisplacement boundaryField

PointDisplacement.boundaryFieldRef()[patchID] == dispVals;


while (runTime.loop())
{
	Info<< "Time = " << runTime.timeName() << endl;

	mesh.movePoints(motionPtr->newPoints());

	runTime.write();

	Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
	<< "  ClockTime = " << runTime.elapsedClockTime() << " s"
	<< nl << endl;
}
This is how I set the pointDisplacement file.

Code:
dimensions      [0 1 0 0 0 0 0];

internalField   uniform (0 0 0);

boundaryField
{

    wall
    {
        type            fixedValue;
	value	  nonuniform List<vector> 
11566();
\\ Here a list of the normal vectors at the surface wall for every point
    }
    
   
    inlet
    {
        type            fixedValue;
	value	  uniform (0 0 0);
    }
    
    outlet
    {
        type            fixedValue;
	value	  uniform (0 0 0);
    }
   
}
I don't want deformation at inlet and outlet boundary.
Unfortunately I got the following error telling me
Code:
--> FOAM FATAL IO ERROR: 
size 11566 is not equal to the given value of 23132
It's strange because, obviously, it's the same mesh and the value required is exactly double of what I'm giving. I suppose that what I gave was the cells center vector and not the vertex vector.
To calculate the normal I used this code
Code:
        
normal.boundaryFieldRef()[patchID] ==
mesh.Sf().boundaryField()[patchID]/mesh.magSf().boundaryField()[patchID]
Probably I didn't also understand the meaning of the boundary conditions or the code is not set to perform this operation for complex surface.
atulkjoy and Michael@UW like this.
kayla1994 is offline   Reply With Quote

Old   October 9, 2018, 13:17
Default
  #3
Member
 
Tony Ladd
Join Date: Aug 2013
Posts: 48
Rep Power: 13
tladd is on a distinguished road
Kayla


What you are trying to do should be supported by Vitaliy Starchenko's normalMotionSlip boundary condition https://github.com/vitst/libsFoamAux. It implements a variable normal displacement on the boundary and solves a Laplace equation to relax the rest of the mesh. If you simply move the points (without relaxation) the mesh will get tangled in a few steps.


The easiest thing to do might be to install OF-v1706 and then the dissolFoam-v1706 package from https://github.com/vitst/dissolFoam/releases. This contains a (slightly outdated) version of the codes and cases, linked to OF-v1706. There are some cases implementing a moving boundary in response to a normal gradient of a scalar field. You might try some of them to get the feel for what the code can do.



Then if you want to take it further there are updates at https://github.com/vitst to libsFoamAux, dissolFoam, dissolCases and dissolUtilities. These introduce coded boundary conditions where you can add your own stuff with a small include file. But this is a bit more complex than just installing the release version; you will need to clone and compile the various libraries and source codes.



Eventually you might find the dissolFrac_codedMotionBC interesting. It does more or less what you are trying to do in its Mesh step. Note that the version in the master branch is missing a couple of files. Until we get that updated you will need to use the development version.
Viet-Dung and scleakey like this.
tladd is offline   Reply With Quote

Old   December 10, 2018, 12:26
Default OpenFOAM - Local scour around a cylinder
  #4
New Member
 
Viet-Dung NGUYEN
Join Date: Aug 2018
Posts: 4
Rep Power: 8
Viet-Dung is on a distinguished road
Hi,

I would like to model the scour around a cylinder like this study : http://water.engr.psu.edu/liu/openFOAM-local-scour.html

I downloaded your code and compiled it but two files miss : fluidSolutionControl.H; fftw3.h

Thank you for help,
best regards,
Viet-Dung
Attached Images
File Type: jpg scour_cylinder_4.jpg (32.1 KB, 28 views)
Viet-Dung is offline   Reply With Quote

Old   December 10, 2018, 18:02
Default
  #5
Member
 
Tony Ladd
Join Date: Aug 2013
Posts: 48
Rep Power: 13
tladd is on a distinguished road
The file fluidSolutionControl.H is part of the OF development release:
OpenFOAM-dev/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/fluidSolutionControl/fluidSolutionControl.H.



Are you using OpenFOAM-v1706? Other versions may have the things in different places. I don't think this file is in v1706 which is likely why it is not being found. OF is changing so rapidly that codes usually have to be compiled against specific versions, since the developers don't maintain back compatibility. So try v1706 or v1712.


The fftw3.h is the FFT library. It might be in 3rd party. If not it can be downloaded and built in the usual way.


Good luck


Tony
tladd is offline   Reply With Quote

Old   September 30, 2021, 13:01
Default
  #6
New Member
 
haungxili
Join Date: Sep 2021
Posts: 3
Rep Power: 5
daydayup is on a distinguished road
Quote:
Originally Posted by Viet-Dung View Post
Hi,

I would like to model the scour around a cylinder like this study : http://water.engr.psu.edu/liu/openFOAM-local-scour.html

I downloaded your code and compiled it but two files miss : fluidSolutionControl.H; fftw3.h

Thank you for help,
best regards,
Viet-Dung
Hello, I am doing the same work as you. Have you succeeded in the simulation? I have encountered some problems now. I really need some help, may I ask you for advice? Thank you very much.my email is day-day-up@sjtu.edu.cn
daydayup is offline   Reply With Quote

Old   September 30, 2021, 16:50
Default
  #7
Member
 
Tony Ladd
Join Date: Aug 2013
Posts: 48
Rep Power: 13
tladd is on a distinguished road
Quote:
Originally Posted by daydayup View Post
Hello, I am doing the same work as you. Have you succeeded in the simulation? I have encountered some problems now. I really need some help, may I ask you for advice? Thank you very much.my email is day-day-up@sjtu.edu.cn
Can you be more specific about the issues you are having.
tladd is offline   Reply With Quote

Old   October 4, 2021, 23:14
Default
  #8
New Member
 
haungxili
Join Date: Sep 2021
Posts: 3
Rep Power: 5
daydayup is on a distinguished road
Quote:
Originally Posted by tladd View Post
Can you be more specific about the issues you are having.
Thank you for your reply. I am very sorry to reply you so late. The main problem I encountered is how to discretize the convection term in the exner equation. After the boundary mesh is deformed, I have no idea on how to handle the Non-orthogonality and the skewness of the mesh, I am also very confused about how to interpolate the value of the face centers to the points, can you give me some advices on how to realise in openfoam,I look forward to your reply
daydayup is offline   Reply With Quote

Old   October 4, 2021, 23:25
Default
  #9
Member
 
Tony Ladd
Join Date: Aug 2013
Posts: 48
Rep Power: 13
tladd is on a distinguished road
You choose a convection scheme in system/fvSchemes. The OF documentation describes how. For steady problems we found Gauss linear upwind was effective, but you may need to experiment yourself.

Unless you are digging deep into the OF source code, you should not need to worry about interpolation. OF will handle that automatically, using teh methods specified in fvSchemes.

In dissolFoam we need to interpolate the velocities at the face centers (on the boundary patches) to vertexes. But that is handled automatically by dissolFoam in the standard OF way.

I suggest you try to run one of the test cases and see what happens.


TOny
tladd is offline   Reply With Quote

Old   October 4, 2021, 23:37
Default
  #10
New Member
 
haungxili
Join Date: Sep 2021
Posts: 3
Rep Power: 5
daydayup is on a distinguished road
I got what you mean,I will explore how dissolFoam handles these problems,thanks for your reply sincerely!
daydayup is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set BCs programmatically incompressible OpenFOAM Programming & Development 6 November 20, 2017 03:47
chtMultiRegionSimpleFoam: inconsistency between BCs and results Diro7 OpenFOAM Running, Solving & CFD 1 March 2, 2017 05:36
Difference between HF and Temperature BCs Catthan FLUENT 0 August 7, 2013 06:59
Dealing with BC's in OF 1.6 vkrastev OpenFOAM Running, Solving & CFD 5 September 4, 2012 12:58
Understanding Code behind BCs Linse OpenFOAM Programming & Development 8 January 9, 2012 09:58


All times are GMT -4. The time now is 00:46.