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

Class word

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 28, 2018, 04:13
Default Class word
  #1
New Member
 
Jose
Join Date: Dec 2017
Location: Madrid
Posts: 6
Rep Power: 8
jlorenzo is on a distinguished road
Dear all,

I'm trying to code a solver where some boundaries are moved according to the solution, and I need the user to specify in a file NumericalParameters the names of the patches whose nodes will be displaced.

I do this with the following piece of code in createFields.H:
Code:
IOdictionary numericalParameters
(
    IOobject
    (
	"numericalParameters",
	runTime.constant(),
	mesh,
	IOobject::MUST_READ,
	IOobject::NO_WRITE
    )
);

scalar gamma(readScalar(numericalParameters.lookup("gamma")));
label incount(readLabel(numericalParameters.lookup("incount")));
wordList movingPatches(numericalParameters.lookup("movingPatches"));
Then at some point in the main .C file I have something like this
Code:
forAll(movingPatches,i)
{
    const word& patchName = movingPatches[i];
    label patchID = mesh.boundaryMesh().findPatchID(patchName);

    // Extra code
}
It seems that the code fails in
Code:
label patchID = mesh.boundaryMesh().findPatchID(patchName);
As if the wordList movingPatches didn't store the actual list that is provided by the user. In fact, I have observed that when using the command Info to show the list elements everything seems OK, but when using the command cout I get the list elements followed by \n1 (new line and 1). I have also tried movingPatches[i].value but this doesn't work.

Thank you in advance.
__________________
Jose
jlorenzo is offline   Reply With Quote

Old   April 3, 2018, 04:32
Default
  #2
Member
 
Jibran
Join Date: Oct 2012
Location: UK
Posts: 61
Blog Entries: 1
Rep Power: 14
Jibran is on a distinguished road
​ Hi,

It would be useful if you could post the error as well. My guess is that the word list is not stored properly. Can you access all of the patches?
Code:
forAll(movingPatches,i)
{
    const word& patchName = movingPatches[i];
    Info << "patch name = " << patchName << endl;
}
Moreover, I would recommend implementing boundary conditions outside of your main solver just like standard OpenFOAM BCs. You can easily read fields from your solver within the new boundary condition through 'lookupPatchField' or 'lookupObject' member functions (search the forum for its usage). ​
__________________
Jibran Haider
https://jibranhaider.com/
Jibran 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
problem during mpi in server: expected Scalar, found on line 0 the word 'nan' muth OpenFOAM Running, Solving & CFD 3 August 27, 2018 04:18
error with reactingFoam BakedAlmonds OpenFOAM Running, Solving & CFD 4 June 22, 2016 02:21
The udf.h headers are unable to open- in VISUAL STUDIO 13 sanjeetlimbu Fluent UDF and Scheme Programming 4 May 2, 2016 05:38
Run time Selection Mechanism - Some help required to understand jaswi OpenFOAM Programming & Development 3 October 29, 2015 13:42
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug unoder OpenFOAM Installation 11 January 30, 2008 20:30


All times are GMT -4. The time now is 09:38.