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

vectorVield all z-entries to zero

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 10, 2024, 08:38
Exclamation vectorVield all z-entries to zero
  #1
New Member
 
S03r3n
Join Date: Feb 2024
Posts: 6
Rep Power: 2
S03r3n is on a distinguished road
Hello together,

I have the following expression for a vectorField:

const vectorField buffer=(Up - n*(n & Up));

And I want to set all z-entries to zero.
How does it work?

Thanks in advance!

Best regards
S03r3n is offline   Reply With Quote

Old   April 11, 2024, 02:43
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,685
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by S03r3n View Post
Hello together,

I have the following expression for a vectorField:

const vectorField buffer=(Up - n*(n & Up));

And I want to set all z-entries to zero.
How does it work?

Thanks in advance!

Best regards
The first one I thought of (there might be better solutions):
Code:
vectorField buffer=(Up - n*(n & Up));

// Set z value
for (auto& val : buffer)
{
    val.z() = 0;
}
olesen is offline   Reply With Quote

Old   April 11, 2024, 03:12
Default
  #3
New Member
 
S03r3n
Join Date: Feb 2024
Posts: 6
Rep Power: 2
S03r3n is on a distinguished road
Thanks for your reply!

I've tested your approach, but an error occured:

Code:
error: assignment of read-only location ‘(& val)->Foam::Vector<double>::z()’
  151 |         val.z() = 0;
      |         ~~~~~~~~^~~
Can you help me?


SOLVED:

Remove const in front of vectorField.

Code:
vectorField buffer=(Up - n*(n & Up));
S03r3n is offline   Reply With Quote

Old   April 11, 2024, 08:55
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,685
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
my example was without 'const'
olesen is offline   Reply With Quote

Reply

Tags
vectorfield


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
[snappyHexMesh] FOAM Warning: Not all entries in refinementSurfaces dictionary were used. MohdShaeq OpenFOAM Meshing & Mesh Conversion 4 August 29, 2023 23:12
[snappyHexMesh] Not all entries in refinementSurfaces dictionary were used will_ca OpenFOAM Meshing & Mesh Conversion 5 November 4, 2021 21:04
[solids4Foam] SOLVED: Paraview can't read solids files (duplicate entries with keyword value) tschenkel OpenFOAM CC Toolkits for Fluid-Structure Interaction 11 March 23, 2020 04:48
Defining entries for VolTensorField depending on velocity components katab OpenFOAM Programming & Development 0 February 20, 2019 08:53
ill defined primitiveEntry starting at keyword 'value' on line 197 ChangeDictionary Struggle_Achieve OpenFOAM Pre-Processing 2 December 20, 2017 03:58


All times are GMT -4. The time now is 18:36.