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

How to read freestream velocity vector in a new boundary condition?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By fumiya

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 5, 2013, 11:49
Default How to read freestream velocity vector in a new boundary condition?
  #1
Member
 
Roberto Pieri
Join Date: Feb 2012
Location: Milan
Posts: 57
Rep Power: 14
robyTKD is on a distinguished road
Hi to everyone,

I would like to build a new boundary condition for adjointShapeOptimizationFoam.
I need to read the freestream velocity vector (which I named U_inf); my ideas to do this are:
  1. adding U_inf in the transportProperties dictionary and reading from it;
  2. defining a new dictionary and reading the vector from this new dictionary;
  3. reading the velocity from the inlet patch.

Which of these ones is the best? How can I implement it?

Attached below you find the file.

Thank you
Roberto
Attached Files
File Type: c adjointCdWallVelocityFvPatchVectorField.C (3.5 KB, 27 views)
robyTKD is offline   Reply With Quote

Old   April 5, 2013, 23:30
Default
  #2
Senior Member
 
fumiya's Avatar
 
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 266
Blog Entries: 1
Rep Power: 19
fumiya is on a distinguished road
Hi Roberto,

Are you addressing the drag coefficient minimization problems by the adjoint method?

Personally, I think it is the most desirable approach to read a freestreamValue from U file,
because we don't have to define another dictionary.
Unfortunately, I don't know how to do that, but you can try the approach 1,2 by following
the instructions:

http://albertopassalacqua.com/?p=947

Hope this helps,
Fumiya
fumiya is offline   Reply With Quote

Old   April 6, 2013, 19:29
Default
  #3
Member
 
Roberto Pieri
Join Date: Feb 2012
Location: Milan
Posts: 57
Rep Power: 14
robyTKD is on a distinguished road
Thank you for the reply.

Quote:
Originally Posted by fumiya View Post
Are you addressing the drag coefficient minimization problems by the adjoint method?
Yes. The first step is to solve the adjoint problem for drag and lift in laminar regime.

I followed the instructions from the link you suggested to me, but, unfortunately, it doesn't work.
The modified BC is attached below while this is the error:

Code:
adjointCdWallVelocity/adjointCdWallVelocityFvPatchVectorField.C: In member function 'virtual void Foam::adjointCdWallVelocityFvPatchVectorField::updateCoeffs()':
adjointCdWallVelocity/adjointCdWallVelocityFvPatchVectorField.C:113:44: error: no matching function for call to 'Foam::Field<double>::Field(Foam::dimensioned<double>)'
adjointCdWallVelocity/adjointCdWallVelocityFvPatchVectorField.C:113:44: note: candidates are:
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:193:9: note: Foam::Field<Type>::Field(const Foam::word&, const Foam::dictionary&, Foam::label) [with Type = double, Foam::label = int]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:193:9: note:   candidate expects 3 arguments, 1 provided
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:190:9: note: Foam::Field<Type>::Field(Foam::Istream&) [with Type = double]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:190:9: note:   no known conversion for argument 1 from 'Foam::dimensioned<double>' to 'Foam::Istream&'
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:186:9: note: Foam::Field<Type>::Field(const Foam::tmp<Foam::Field<Type> >&) [with Type = double]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:186:9: note:   no known conversion for argument 1 from 'Foam::dimensioned<double>' to 'const Foam::tmp<Foam::Field<double> >&'
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:177:9: note: Foam::Field<Type>::Field(const Foam::Xfer<Foam::Field<Type> >&) [with Type = double]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:177:9: note:   no known conversion for argument 1 from 'Foam::dimensioned<double>' to 'const Foam::Xfer<Foam::Field<double> >&'
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:174:9: note: Foam::Field<Type>::Field(Foam::Field<Type>&, bool) [with Type = double]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:174:9: note:   candidate expects 2 arguments, 1 provided
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:171:9: note: Foam::Field<Type>::Field(const Foam::Field<Type>&) [with Type = double]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:171:9: note:   no known conversion for argument 1 from 'Foam::dimensioned<double>' to 'const Foam::Field<double>&'
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:164:9: note: Foam::Field<Type>::Field(const Foam::tmp<Foam::Field<Type> >&, const Foam::FieldMapper&) [with Type = double]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:164:9: note:   candidate expects 2 arguments, 1 provided
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:157:9: note: Foam::Field<Type>::Field(const Foam::UList<T>&, const Foam::FieldMapper&) [with Type = double]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:157:9: note:   candidate expects 2 arguments, 1 provided
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:149:9: note: Foam::Field<Type>::Field(const Foam::tmp<Foam::Field<Type> >&, const labelListList&, const scalarListList&) [with Type = double, Foam::labelListList = Foam::List<Foam::List<int> >, Foam::scalarListList = Foam::List<Foam::List<double> >]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:149:9: note:   candidate expects 3 arguments, 1 provided
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:141:9: note: Foam::Field<Type>::Field(const Foam::UList<T>&, const labelListList&, const scalarListList&) [with Type = double, Foam::labelListList = Foam::List<Foam::List<int> >, Foam::scalarListList = Foam::List<Foam::List<double> >]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:141:9: note:   candidate expects 3 arguments, 1 provided
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:134:9: note: Foam::Field<Type>::Field(const Foam::tmp<Foam::Field<Type> >&, const labelUList&) [with Type = double, Foam::labelUList = Foam::UList<int>]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:134:9: note:   candidate expects 2 arguments, 1 provided
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:127:9: note: Foam::Field<Type>::Field(const Foam::UList<T>&, const labelUList&) [with Type = double, Foam::labelUList = Foam::UList<int>]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:127:9: note:   candidate expects 2 arguments, 1 provided
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:124:18: note: Foam::Field<Type>::Field(const Foam::Xfer<Foam::List<T> >&) [with Type = double]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:124:18: note:   no known conversion for argument 1 from 'Foam::dimensioned<double>' to 'const Foam::Xfer<Foam::List<double> >&'
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:121:18: note: Foam::Field<Type>::Field(const Foam::UList<T>&) [with Type = double]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:121:18: note:   no known conversion for argument 1 from 'Foam::dimensioned<double>' to 'const Foam::UList<double>&'
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:118:9: note: Foam::Field<Type>::Field(Foam::label, const Type&) [with Type = double, Foam::label = int]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:118:9: note:   candidate expects 2 arguments, 1 provided
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:115:18: note: Foam::Field<Type>::Field(Foam::label) [with Type = double, Foam::label = int]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:115:18: note:   no known conversion for argument 1 from 'Foam::dimensioned<double>' to 'int'
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:111:9: note: Foam::Field<Type>::Field() [with Type = double]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.H:111:9: note:   candidate expects 0 arguments, 1 provided
adjointCdWallVelocity/adjointCdWallVelocityFvPatchVectorField.C:115:35: error: no matching function for call to 'Foam::Field<Foam::Vector<double> >::Field(Foam::dimensioned<Foam::Vector<double> >)'
adjointCdWallVelocity/adjointCdWallVelocityFvPatchVectorField.C:115:35: note: candidates are:
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:205:1: note: Foam::Field<Type>::Field(const Foam::word&, const Foam::dictionary&, Foam::label) [with Type = Foam::Vector<double>, Foam::label = int]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:205:1: note:   candidate expects 3 arguments, 1 provided
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:198:1: note: Foam::Field<Type>::Field(Foam::Istream&) [with Type = Foam::Vector<double>]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:198:1: note:   no known conversion for argument 1 from 'Foam::dimensioned<Foam::Vector<double> >' to 'Foam::Istream&'
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:188:1: note: Foam::Field<Type>::Field(const Foam::tmp<Foam::Field<Type> >&) [with Type = Foam::Vector<double>]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:188:1: note:   no known conversion for argument 1 from 'Foam::dimensioned<Foam::Vector<double> >' to 'const Foam::tmp<Foam::Field<Foam::Vector<double> > >&'
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:163:1: note: Foam::Field<Type>::Field(const Foam::Xfer<Foam::Field<Type> >&) [with Type = Foam::Vector<double>]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:163:1: note:   no known conversion for argument 1 from 'Foam::dimensioned<Foam::Vector<double> >' to 'const Foam::Xfer<Foam::Field<Foam::Vector<double> > >&'
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:149:1: note: Foam::Field<Type>::Field(Foam::Field<Type>&, bool) [with Type = Foam::Vector<double>]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:149:1: note:   candidate expects 2 arguments, 1 provided
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:141:1: note: Foam::Field<Type>::Field(const Foam::Field<Type>&) [with Type = Foam::Vector<double>]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:141:1: note:   no known conversion for argument 1 from 'Foam::dimensioned<Foam::Vector<double> >' to 'const Foam::Field<Foam::Vector<double> >&'
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:128:1: note: Foam::Field<Type>::Field(const Foam::tmp<Foam::Field<Type> >&, const Foam::FieldMapper&) [with Type = Foam::Vector<double>]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:128:1: note:   candidate expects 2 arguments, 1 provided
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:115:1: note: Foam::Field<Type>::Field(const Foam::UList<T>&, const Foam::FieldMapper&) [with Type = Foam::Vector<double>]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:115:1: note:   candidate expects 2 arguments, 1 provided
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:101:1: note: Foam::Field<Type>::Field(const Foam::tmp<Foam::Field<Type> >&, const labelListList&, const scalarListList&) [with Type = Foam::Vector<double>, Foam::labelListList = Foam::List<Foam::List<int> >, Foam::scalarListList = Foam::List<Foam::List<double> >]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:101:1: note:   candidate expects 3 arguments, 1 provided
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:87:1: note: Foam::Field<Type>::Field(const Foam::UList<T>&, const labelListList&, const scalarListList&) [with Type = Foam::Vector<double>, Foam::labelListList = Foam::List<Foam::List<int> >, Foam::scalarListList = Foam::List<Foam::List<double> >]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:87:1: note:   candidate expects 3 arguments, 1 provided
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:74:1: note: Foam::Field<Type>::Field(const Foam::tmp<Foam::Field<Type> >&, const labelUList&) [with Type = Foam::Vector<double>, Foam::labelUList = Foam::UList<int>]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:74:1: note:   candidate expects 2 arguments, 1 provided
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:61:1: note: Foam::Field<Type>::Field(const Foam::UList<T>&, const labelUList&) [with Type = Foam::Vector<double>, Foam::labelUList = Foam::UList<int>]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:61:1: note:   candidate expects 2 arguments, 1 provided
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:156:1: note: Foam::Field<Type>::Field(const Foam::Xfer<Foam::List<T> >&) [with Type = Foam::Vector<double>]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:156:1: note:   no known conversion for argument 1 from 'Foam::dimensioned<Foam::Vector<double> >' to 'const Foam::Xfer<Foam::List<Foam::Vector<double> > >&'
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:179:1: note: Foam::Field<Type>::Field(const Foam::UList<T>&) [with Type = Foam::Vector<double>]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:179:1: note:   no known conversion for argument 1 from 'Foam::dimensioned<Foam::Vector<double> >' to 'const Foam::UList<Foam::Vector<double> >&'
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:54:1: note: Foam::Field<Type>::Field(Foam::label, const Type&) [with Type = Foam::Vector<double>, Foam::label = int]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:54:1: note:   candidate expects 2 arguments, 1 provided
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:47:1: note: Foam::Field<Type>::Field(Foam::label) [with Type = Foam::Vector<double>, Foam::label = int]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:47:1: note:   no known conversion for argument 1 from 'Foam::dimensioned<Foam::Vector<double> >' to 'int'
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:40:1: note: Foam::Field<Type>::Field() [with Type = Foam::Vector<double>]
/Users/roberto/OpenFOAM/OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/Field.C:40:1: note:   candidate expects 0 arguments, 1 provided
make: *** [Make/darwinIntel64Gcc46DPOpt/adjointCdWallVelocityFvPatchVectorField.o] Error 1
make: *** Waiting for unfinished jobs....
Thank you all,
Roberto
Attached Files
File Type: c adjointCdWallVelocityFvPatchVectorField.C (3.9 KB, 22 views)
robyTKD is offline   Reply With Quote

Old   April 6, 2013, 21:00
Default
  #4
Senior Member
 
fumiya's Avatar
 
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 266
Blog Entries: 1
Rep Power: 19
fumiya is on a distinguished road
There is no problem with the descriptions in the link.
The errors you encountered are related to how to use your variable U_inf.

You might want to try
Code:
scalar C_inf(.5*pow(mag(U_inf.value()), 2));
vector d(U_inf.value()/mag(U_inf.value()));
instead of
Code:
scalarField C_inf(.5*pow(mag(U_inf), 2));
vectorField d(U_inf/mag(U_inf));
Hope this helps,
Fumiya
samiam1000 likes this.
fumiya is offline   Reply With Quote

Old   April 7, 2013, 17:37
Default
  #5
Member
 
Roberto Pieri
Join Date: Feb 2012
Location: Milan
Posts: 57
Rep Power: 14
robyTKD is on a distinguished road
Thank you very much Fumiya, your help was precise and useful; now it compiles without errors.

I have two other questions:
  1. How can I import differential operators? Probably I'll need to add this term in my BC: nut*snGrad(phiap/patch().magSf()) and I would like to know what I have to include in the file;
  2. a useful improvement is to build a "freestream-like" boundary condition, which will select Inlet or Outlet condition for the unknowns of the adjoint problem. Do you know how to modify freestream and freestreamPressure boundary conditions in order to do this?

Unfortunately I built my mesh with only FARFIELD patch and it isn't so easy to divide in Inlet and Outlet.

Best regards,
Roberto
robyTKD is offline   Reply With Quote

Old   April 24, 2013, 10:43
Default
  #6
Member
 
Roberto Pieri
Join Date: Feb 2012
Location: Milan
Posts: 57
Rep Power: 14
robyTKD is on a distinguished road
Any idea about question number 2 of previous post?

Roberto
robyTKD is offline   Reply With Quote

Reply

Tags
adjointshapeoptimization, boundary condition


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
Freestream boundary condition YJ Lee OpenFOAM Running, Solving & CFD 14 June 5, 2020 03:54
Difficulty in calculating angular velocity of Savonius turbine simulation alfaruk CFX 14 March 17, 2017 07:08
Massflow or average velocity boundary condition Sideshore OpenFOAM Pre-Processing 6 September 27, 2016 16:09
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem Attesz OpenFOAM Meshing & Mesh Conversion 12 May 2, 2013 11:52
velocity boundary condition Logan Page OpenFOAM 0 November 19, 2010 18:59


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