|
[Sponsors] |
UDF problem---setting an external force on surface in 6DOF |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 28, 2021, 00:52 |
UDF problem---setting an external force on surface in 6DOF
|
#1 |
New Member
Join Date: Feb 2020
Posts: 26
Rep Power: 6 |
Background:
Hello everyone: I want to simulate compression of oil film, in my case, I assigned a force to push the moving wall move along y axis, details have been shown in Figure 1. The force consists of lots of points shown in Figure 2, which cannot be expressed by a function, thus, I need to read them and then set them as input, in this case, I used UDF(UDF code has been presented below) to solve this problem. The question is: UDF can be successfully compiled and the txt data can be successfully read(shown in Figure 3), but either in preview mesh motion or calculation, the expected moving wall fails to move, I guess there must be something wrong with my UDF code, but I cannot figure it out, can someone help me out? cause this problem puzzles me for a long time. Thanks for your time and attention. Regards, Figure 1 Figure 2 Figure 3 My UDF code #include <iostream> #include <fstream> #include <iterator> #include <vector> #include "udf.h" using namespace std; static vector<pair<real, real>> Fvec; /* creating a container for time-force points */ /* UDF macro for reading time-force points in txt file */ DEFINE_EXECUTE_ON_LOADING(External_force_import, libname) { cout << "The contents of the file are as follows: " << endl; ifstream Force_file("force_sin.txt"); /* read time-force points */ /* save the file("force_sin.txt") data into container 'v' */ vector<real> f( (istream_iterator<real>(Force_file)), istream_iterator<real>() ); /* separate time and force, and save them into container Fvec */ for (auto i = f.begin(); i != f.end(); i += 2) { Fvec.push_back(pair<real, real>(*i, *(i + 1))); } for (const auto &i : Fvec) { cout << i.first << "\t" << i.second << endl; } } /* UDF macro for six DOF solver */ DEFINE_SDOF_PROPERTIES(Piston_force, prop, dt, time, dtime) { real Force_value; /* assign force value to variable Force_value */ for (auto i = Fvec.begin(); i != Fvec.end() - 1; ++i) { if ( (i->first <= CURRENT_TIME) && ((i+1)->first > CURRENT_TIME) ) { Force_value = i->second; break; } } /* Basic properties */ prop[SDOF_MASS] = 0.1; /* mass */ prop[SDOF_LOAD_F_Y] = Force_value; /* external force assigned on moving wall */; /* Translation constraint */ prop[SDOF_ZERO_TRANS_X] = TRUE; prop[SDOF_ZERO_TRANS_Z] = TRUE; /* Rotation constraint */ prop[SDOF_ZERO_ROT_X] = TRUE; prop[SDOF_ZERO_ROT_Y] = TRUE; prop[SDOF_ZERO_ROT_Z] = TRUE; } |
|
March 28, 2021, 12:56 |
|
#2 |
Member
Yasser Selima
Join Date: Mar 2009
Location: Canada
Posts: 51
Rep Power: 19 |
May be you need to change the force direction!
Also print a Message showing the force to make sure you are reading the correct value |
|
March 29, 2021, 03:16 |
|
#3 | |
New Member
Join Date: Feb 2020
Posts: 26
Rep Power: 6 |
Quote:
Thanks for your suggestion! The problem has now been solved! I found that it is one syntax in my UDF that prevent me realizing the wall motion. One more question, either after loading UDF or previewing mesh motion, there popped out many same messages, for example, in previewing mesh motion, in every step, the message “force value: xxx” will be displayed on console 82 times(I know this comes from my syntax “ cout << “Force_value: Force_value” ”), which is shown in Figure 4. For this problem, I guess there must be a 82 times loop when running the UDF, but I do not know how to control the displaying times?(I just one to see this message for only one time) Regards Figure 4 |
||
March 29, 2021, 08:42 |
|
#4 |
Member
Yasser Selima
Join Date: Mar 2009
Location: Canada
Posts: 51
Rep Power: 19 |
This is because every node displays one message ... but I doubt having 82 nodes. Try this and see what happens
#if RP_HOST Message(" .... ", ...); #end if |
|
May 13, 2021, 05:06 |
|
#5 | |
New Member
Join Date: Feb 2020
Posts: 26
Rep Power: 6 |
Quote:
Sorry for such a late reply, since I was assigned to another program, I could not read your answer in time. Today, I am free from that, and I looked up the directives you gave in UDF manual and wrote it in UDF, then, I found that there still exists two lines of message. For this, in my opinion, it is because my computer has two hosts?(My computer has 24 cores-48threads, maybe 1host contain 12 cores.) And for why there were 82 lines before, I don’t figure it out yet, the situation was: at that time, I set 40 solver processes, which displayed 82lines, and today, I tried different number of processes, such as 4, 10, and the corresponding message lines is: 10 lines for 4 processes, 22 lines for 10 processes, I found number of lines follows the function: lines = 2*processes + 2(Is this the number of host?), but I don’t know why... Above is my guess, I do not know if it is right of wrong, please correct me if I am wrong, thanks! Regards, Silence |
||
Tags |
6dof, dynamic mesh, force, udf code |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Fluent Parallelization Problem After AC Power Dropped | pawl | Hardware | 5 | November 13, 2016 07:08 |
[Gmsh] Problem with Gmsh | nishant_hull | OpenFOAM Meshing & Mesh Conversion | 23 | August 5, 2015 03:09 |
[snappyHexMesh] determining displacement for added points | CFDnewbie147 | OpenFOAM Meshing & Mesh Conversion | 1 | October 22, 2013 10:53 |
Cells with t below lower limit | Purushothama | Siemens | 2 | May 31, 2010 22:58 |
gravitational force for free surface flow | Jongtae Kim | Main CFD Forum | 1 | July 2, 2000 12:57 |