|
[Sponsors] |
How to write a vector into a file in volVectorField type |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 3, 2015, 02:52 |
How to write a vector into a file in volVectorField type
|
#1 |
Member
methma Rajamuni
Join Date: Jul 2015
Location: Victoria, Australia
Posts: 40
Rep Power: 11 |
Hi,
I am new to OpenFOAM. Currently I am working on implementing a new solver. Inside this solver I am calculating a value in each time step and create a vector, y2, from that. Now I want to write that vector as a volVectorField together with the time into a dictionary. Can you please help me to do this with your ideas and/or references. Thank you Methma |
|
November 3, 2015, 03:38 |
|
#2 |
Senior Member
|
Hi,
1. Create volVectorField (let us call it myLovelyVectorField further) with NO_READ and AUTO_WRITE flags (see for example pressure field in interFoam, $FOAM_APP/solvers/multiphase/interFoam/createFields.H, keep in mind pressure is scalar, you need vector). 2. Calculated y2, assign y2 to created volVectorField. Either using myLovelyVectorField.internalField() = y2, if your y2 is simple vector, or myLovelyVectorField = y2, if your y2 is dimensioned vector (you can find examples of assignment in different solvers, for example in alphaEnq.H of the same interFoam). |
|
November 3, 2015, 18:40 |
|
#3 |
Member
methma Rajamuni
Join Date: Jul 2015
Location: Victoria, Australia
Posts: 40
Rep Power: 11 |
Hi Alexey Matveichev,
Thank you for your reply It help me a lot. I have another question for you. In my solver I am calculating motion of a solid sphere due to the fluid, and y2 is the displacement vector of the sphere. It is simply a vector calculate in each time step, I recently realised that it's not a volVectorFeild. What I need to do is write a file in the following format Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2.3.1 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; object solidDisplacementData; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // solidDis { t150 (0 1 0); t151 (0 2 0); t152 (0 3 0); t153 (0 4 0); } Can you please give your ideas and references to do this? Best, Methma Last edited by meth; November 3, 2015 at 21:03. |
|
November 5, 2015, 06:19 |
|
#4 |
Senior Member
|
Hi,
The way you store y2 should be solely defined by the purpose of y2. Here is code snippet, which writes vectors in constant/solidDisplacementDict file: Code:
#include "fvCFD.H" using namespace Foam; int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" IOdictionary test (IOobject ("solidDisplacementDict", runTime.constant(), runTime)); vector v(vector::zero); dictionary t("values"); t.add<vector>(runTime.timeName(), v); test.set("solidDisplacement", t); static_cast<regIOobject*>(&test)->write(); while (runTime.loop()) { v.x() += 1.0; test.subDict("solidDisplacement").add<vector>(runTime.timeName(), v); static_cast<regIOobject*>(&test)->write(); } return 0; } Code:
solidDisplacement { 0 ( 0 0 0 ); 0.005 ( 1 0 0 ); 0.01 ( 2 0 0 ); 0.015 ( 3 0 0 ); 0.02 ( 4 0 0 ); 0.025 ( 5 0 0 ); 0.03 ( 6 0 0 ); 0.035 ( 7 0 0 ); 0.04 ( 8 0 0 ); ... } If you need to visualize this vector, save it as volVectorField, this is the easiest way. |
|
June 8, 2018, 04:58 |
Solid motion
|
#5 |
Member
Ben 017
Join Date: Nov 2017
Posts: 70
Rep Power: 9 |
Hello Foamers,
I want to simulate the motion of cylinder when hydrodynamic forces apply. so far, i have modeled its motion with undamped free vibration equation (x"+w^2 x=0), i solved it with Runge kutter 5th order to find the displacement X at each time step(C++ codes). Now i consider the center of the cylinder as vector y(0,x,0), each time step the center chamges as x changes. the radius is 0.05 Can you help to know how this can be achieved in any solver? |
|
June 8, 2018, 05:22 |
|
#6 |
Member
methma Rajamuni
Join Date: Jul 2015
Location: Victoria, Australia
Posts: 40
Rep Power: 11 |
Hi Ben,
In this case, you can use either a dynamic mesh technique to update the deformed mesh according to the new position of the cylinder or can solve the fully coupled fluid-solid system by modelling the cylinder in a reference frame attached to the centre of the cylinder. The second method is far more efficient than the first one and can apply for a single body FSI problem. If you are interested on the second method, you can read my paper, 'Transversely flow-induced vibration of a sphere' https://www.cambridge.org/core/journ...A9BAC7A505CB35 Best, Methma |
|
June 8, 2018, 06:22 |
|
#7 | |
Member
Ben 017
Join Date: Nov 2017
Posts: 70
Rep Power: 9 |
Quote:
Thank you, I have read a bit your approach in that paper. May you share the used FSI solver(vivicoFoam). I may start from there and know how to handle my case. i would appreciate your support! Best regard! Ben |
||
Tags |
openfoam |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Helyx OS] Helyx-OS (GUI for SnappyHexMesh | elvis | OpenFOAM Community Contributions | 210 | January 30, 2017 19:57 |
Error during initialization of "rhoSimpleFoam" | kornickel | OpenFOAM Running, Solving & CFD | 8 | September 17, 2013 06:37 |
[swak4Foam] build problem swak4Foam OF 2.2.0 | mcathela | OpenFOAM Community Contributions | 14 | April 23, 2013 14:59 |
[swak4Foam] Air Conditioned room groovyBC | Sebaj | OpenFOAM Community Contributions | 7 | October 31, 2012 15:16 |
ParaView Compilation | jakaranda | OpenFOAM Installation | 3 | October 27, 2008 12:46 |