Hi @Louis Googl, I created a pull request with a new version of the k-g converter: https://github.com/BRL-CAD/brlcad/pull/127 Please, review it, test it on Windows, and compare it with the old one. Would you recommend to replace the old k-g with this new one?
Hello @Daniel Rossberg , I will start with it today.
Hi @Daniel Rossberg , I have done some testing and found some issues,
1- if the part name contains a space the reagion name will contain the space and it's not possible to draw that part separitly in mged
colorOftheBotsisthesame.png
2- all parts has the same color which isn't the case in the old k-g also the space in the name is replaced by an underscore
OLDDifferentColorsNospaceinPartName.png
3- while trying to convert a .k file which is distributed with LS-Dyna 2023 I encountard an assertion error in the new k-g, which didn't happen in the old one
assertionFaild.png
OLDNoassertionErrorSPR4.png
4- another .k file distributed as example produces an unhandeled exception in the new k-g while it is converted normally with the old k-g
unhandeledException.png
oldVersionCanConvertBucklingFilewithDifferentColors.png
5- *ElEMENT_SOLID and *SECTION_SOLID_TITLE are unhandeled in the new version
unexpectedComand.png
as also was mentioned by @starseeker on GitHub
the first issue is easy to handle using std::replace
image.png
Regarding the other issues, I can work on fixing them if you think it's a good improvment. Regarding the comparison with the old version, I still need to read the code more thoroughly, but despite the issues the new code is much more organized and clear, also the definition of parsing logic in the k_parser.cpp is much more convinent, same for region_list.cpp. I think this is the correct way to go after fixing the issues and implementation of *ELEMENT_SOLID.
just for the future, do prefer that I write a document instead of sending long massages here?
You have to put the object name in quotes if it has a space
draw "this object"
Louis Googl said:
Regarding the other issues, I can work on fixing them if you think it's a good improvment. Regarding the comparison with the old version, I still need to read the code more thoroughly, but despite the issues the new code is much more organized and clear, also the definition of parsing logic in the k_parser.cpp is much more convinent, same for region_list.cpp. I think this is the correct way to go after fixing the issues and implementation of *ELEMENT_SOLID.
You could still find the old k-g.cpp in the version control system, but because of all the shortcomings, I make it the git way: I created a new branch devel_k-g with the new converter. You can use this as the base for your development and send your pull requests there. I'll keep my hands off as long as you work on it.
The new k-g is a back-port from a brlcad.dll application. There, some things are different. And, I had only one file to test :wink: I don't have LS-Dyna.
Sean said:
You have to put the object name in quotes if it has a space
@Louis Googl, if possible, keep the names as they are. This makes it easier to maintain the part list for both sides.
On BRL-CAD's side, just about anything is allowed in names .. to a fault even as handling spaces/slashes/quotes will vary from command to command. Most do handle spaces if they're quoted though, just like shell. But at the database level, it's anything up to the nul character.
There are a few helper functions like bu_vls_encode()+bu_vls_decode() to wrap in quotes, and bu_vls_simplify() to automatically replace unwanted chars, and bu_str_escape()+bu_str_unexscape() to manage levels of escape sequences.
Daniel Rossberg said:
You could still find the old k-g.cpp in the version control system, but because of all the shortcomings, I make it the git way: I created a new branch devel_k-g with the new converter. You can use this as the base for your development and send your pull requests there. I'll keep my hands off as long as you work on it.
that is great, I will continue the testing and comparison so I understand better, then I will start the implemention.
Daniel Rossberg said:
The new k-g is a back-port from a brlcad.dll application. There, some things are different. And, I had only one file to test :wink: I don't have LS-Dyna.
what do you mean by back-port?
Sean said:
There are a few helper functions like bu_vls_encode()+bu_vls_decode() to wrap in quotes, and bu_vls_simplify() to automatically replace unwanted chars, and bu_str_escape()+bu_str_unexscape() to manage levels of escape sequences.
Thank you for the information @Sean.
Louis Googl said:
Daniel Rossberg said:
The new k-g is a back-port from a brlcad.dll application. There, some things are different. And, I had only one file to test :wink: I don't have LS-Dyna.
what do you mean by back-port?
Usually, I don't program directly on the BRL-CAD core, but use the C++ API.
I just got mail from GSOC that proposal have been accepted.. Thanks a lot @Sean @Daniel Rossberg @Himanshu Sekhar Nayak
I will give my best to the organization. It means a lot to me
:heart:
I also got the email from GSOC, I am glad that my project is accepted and even more glad to get to work with you again @Daniel Rossberg @Sean, thank you.
@Louis Googl Likewise, very much looking forward to working with you again and all that you're planning on working on. Coupling cad to cae/cam is pretty darn important, but you have the experience for it!
@Sean it is indeed important, I will do my best to have a nice project with you and GSOC. On another note I am intersted in your idea realted to Ray tracing and FE solvers or multi body dynamics solvers, maybe if you will have some time we can talk about it.
@Louis Googl, meanwhile, there where some changes in the main branch on how brlcad is build. Please tell me, if I should merge these into devel_k-g.
Yes, can you please merge the changes into devel_k-g. I think it's better if the building process is the same.
Okay, done.
well...I had the feeling this will come back and bit me, the configuration has faild on windows and ubuntu, where can I check for the new building procedure?
WhatsApp-Image-2024-05-27-at-6.10.10-PM.jpeg
propably the windows error is my fault I am reinstalling all developing tools
but the ubunto seems more complicated
Screenshot-from-2024-05-27-21-05-53.png
Screenshot-from-2024-05-27-21-14-20.png
I need some help please.
MaBe, this https://brlcad.zulipchat.com/#narrow/stream/104062-brlcad/topic/build can help.
a3e80727663b0 I think will help with that error - the warning is OK.
starseeker said:
a3e80727663b0 I think will help with that error - the warning is OK.
Merged into devel_k-g.
thank you, I will let you know how it goes .
I have successful build on windows and ubuntu, thank you for help. I am starting to fix the bugs
I found the reason for the assertion error when converting this file
spr4.k, first when you find a triangle in the first part
image.png
the new iterator it_ is pointing to something it shouldn't point to
image.png
I tried putting a condition to avoid this problem but still there is another assertion error when adding the triangle
image.png
trying to find the reason. but still it's not obvious to me why do you want to go back to the previous part when you find a triangle.
I could imagine, that this is a left-over from development. Have you tried it without this code?
yes it works perfectly without that part. should I delete it?
If it woks with your test files: Yes.
I'm just compiling the devel_k-g branch. It needs some time.
image.png
yes, the conversion on spr4.k works without this piece of code.
still the unexpeted command which I will get to after
image.png
Daniel Rossberg said:
I'm just compiling the devel_k-g branch. It needs some time.
take your time. no worries
Regarding unexpected commands: This are commands, currently not handled by the program. I.e., you have to write the code which handles them. What is a PART_ADAPTIVE_FAILURE?
yes, I will write a code to handle all unexpected comands. Part_ADAPTIVE_FAILURE isn't a part it seems to be a property of part 4.
image.png
it doesn't have similar properties to other parts like secid, mid and eosid ..etc
image.png
I am looking around to see exactly what is it.
should I prepare a pull request to remove the code that is causing the problem?
Louis Googl said:
I am looking around to see exactly what is it.
image.png
found it, it tells which part have adaptive meshing and when it starts hence the properties are pid (part id) and t (adaptive mesh starting time)
Louis Googl said:
should I prepare a pull request to remove the code that is causing the problem?
Yes, I'm keen to see it.
I will do some more tests and prepare the pull request. thanks
Louis Googl said:
Louis Googl said:
I am looking around to see exactly what is it.
image.png
found it, it tells which part have adaptive meshing and when it starts hence the properties are pid (part id) and t (adaptive mesh starting time)
Therefore, it is something non-geometric. We could ignore it - or write it as an attribute in the region. See https://github.com/BRL-CAD/MOOSE/blob/main/src/Database/Object.cpp for some example code on how to read and write attributes (e.g., look at how SetAttribute() is implemented).
I will check it out. and prepare separate pull request for it.
@Daniel Rossberg I have created a pull request. please let me know if you have any notes
Louis Googl said:
Daniel Rossberg I have created a pull request. please let me know if you have any notes
:)))) Why not
if (n3 == n4)
add one bot
else
add two bots
(this is pseudo code, of course). There is no need for partOnlyOfTriangles/triangularElement, isn't it?
I had the idea but using bool seemed cooler :sweat_smile:. You are right there is no need for triangularElement. I will resubmit
Is it okay if I add a comment? clarifying that when n3=n4 the element is triangular. Maybe it's not common knowledge
It's okay, but the code says it too. However...
done. new pull request
Daniel Rossberg said:
Therefore, it is something non-geometric. We could ignore it - or write it as an attribute in the region. See https://github.com/BRL-CAD/MOOSE/blob/main/src/Database/Object.cpp for some example code on how to read and write attributes (e.g., look at how SetAttribute() is implemented).
I was working on this, the easy way would be to ignore it but I chose the hard way ( write it as an attribute in the region) because we might encountre attributes that we can't ignore and I would like to learn how to add an attribute.
while reading the object.cpp which is a part of MOOSE, I searched for equivelent operation in BRL-CAD, I found them in avs.c/avs.h like
bu_avs_add(struct bu_attribute_value_set *avsp, const char *name, const char *value)
but the thing I don't know how to do is where to write the attribute set. I checked the region structure it seems the region has its own properties
1_name_headp_mat_op.png
2_combproperties.png
like material for example.
I was searching how bu_avs_get() is used and found something in matter.cpp, but still I don't understand how to add an attribute to the reagion.
image.png
@Daniel Rossberg Can you give me some hints please. and if you have some notes on the startegy I followed please let me know if this is the correct way to approach a problem.
I pointed you to Object.cpp in MOOSE, because it contains examples on how to use bu_avs_add(), for example. If you look at Object::SetAttribute() and following its code at Object::GetAvs() you may come up with something like
//(rt_db_internal*)ip
//(const char*)key
//(const char*)value
bu_avs_add(ip->idb_avs, key, value);
This can be done for every BRL-CAD database object, including combinations.
thank you for the help.
I did something like this
struct rt_db_internal region_internal;
struct directory* dp ;
struct db_i *dbip ;
bu_attribute_value_set* avs;
dbip = wdbp->dbip;
dp = db_lookup(dbip, region_name.c_str(), 0);//after the reagion was created
rt_db_get_internal(®ion_internal, dp, dbip, bn_mat_identity, &rt_uniresource);
avs = ®ion_internal.idb_avs;
const char* key= "adabtive_Mesh";
const char* value= "0.2";
bu_avs_add(avs, key, value);
but I don't see the attributes when I use the (l) command in Mged. what do you think?
You have to write the updated attributes back to the database. See the attr set command, for example: https://github.com/BRL-CAD/brlcad/blob/1d5773d243fc4f0de96cfd7d2186686c55514b16/src/librt/attr.cpp#L612
it works :tada:
image.png
@Daniel Rossberg I will clean the code and submite a pull request.
I created a pull request to handle *PART_ADAPTIVE_FAILURE, pull.
It is much bigger than I expected, and I assume there is some mistakes, but I checked that it build and converts correctly and the addition of the attribute to the BOT appears in Mged.
one mistake that I know of is the handeling of unintialized bu_attribute_value_pair. the else statment in the following picture.
image.png
but still I don't know if the entire idea is correct. please let me know what do you think.
How about adding std::map<std::string, std::string> attributes;
to KPart. This would make it more general and reusable, in case there will be more than one attribute.
In addition, the attributes should be written into the region. Therefore, RegionList should get this map too, and a setAttribues()
method. (Or, addRegion()
an additional parameter?)
Finaly, RegionList::create()
should write the attributes into the BRL-CAD database.
Surely the map is better, we will need to add the color attribute also. I will work on adding the attributes to the region too.
I just relized that the region_list already contains the attributs in the bot, we just need to wirte them to the data base . or I would creat an attribute list inside region list and creat setAttrebutes(), getAttributes(), and writeAttributes().
image.png
which way do you think is better?
Ah, interesting.
The attributes have to go into the region (combination), i.e. the object created with mk_lfcomb() in RegionList::create().
And, you are right, the region list ha to be extended. Currently, it has the member std::map<std::string, Bot> m_list;
, where std::string are the names of the regions and Bot are the affiliated bots. With attributes, you could do:
struct Region {
Bot bot;
std::map<std::string, std::string> attributes;
};
class RegionList {
....
private
std::map<std::string, Region> m_list;
};
or
struct Region {
Bot bot;
std::map<std::string, std::string>* attributes;
Region(void) : bot(), attributes(nullptr) {}
};
for example.
That's nicer, working on it.
KAMPANAT THUMWONG
I created a new pull request . I followed this approach
struct Region {
Bot bot;
std::map<std::string, std::string> attributes;
};
class RegionList {
....
private
std::map<std::string, Region> m_list;
};
but now I am getting an Access violation error when freeing the BOTs, I think it's becaue now the bot gets deleted by Region before getting deleted by it's own destructor Bot::~Bot(void) . or am I wrong?
trying to fix this error, if you have any suggestions please let me know.
I found the problem. I will fix the pull reqest and send it again
fixed. let me know if it needs any modifications.
Okay, some first comments:
1- working on it.
2- K-Parser now doesn't do anything with the database
image.png
image.png
image.png
I am storing the attributes in
KData& data
data.parts[pid].attributes["ADAPTIVE_FAILURE_STARTING_TIME"]=tokens[1];
which is the intermediate data structure. or am I worng?
Louis Googl said:
1- working on it.
2- K-Parser now doesn't do anything with the database
image.png
image.png
image.png
I am storing the attributes inKData& data data.parts[pid].attributes["ADAPTIVE_FAILURE_STARTING_TIME"]=tokens[1];
which is the intermediate data structure. or am I worng?
You are right, K-Parser doesn't touch the database. I got something wrong there. Sorry for that.
No worries, I will finish the 3rd point and update the pull request. thank you for the notes.
@Daniel Rossberg New pull request.
I have some remarks. When I see code ... :crazy:
I saw the comments, I will fix them tonight so I can do something new tomorrow
new Pull
you asked about why PART_ADAPTIVE_FAILURE_STARTING_TIME?
its because the attribute Part_Adaptive_Failure in LS-DYNA refers to the time when the adaptive mesh should start. we could call it ADAPTIVE_FAILURE_MESH_STARTING_TIME. I am open for any other suggestions
image.png
My question was whether to start the flag with PART_ or not.
Now I understand, sorry I read it fast. If we add PART_ it's more clear. I will modify it
I found the bug related to the conversion of this key file
image.png
image.png
some nodes has very small values for the coordinates, which are out of the rang of std::stod()
I am working on a fix
Louis Googl said:
You do not need to create a new pull request after every change. Instead, you can update your old one. The usual work-flow is:
git checkout -b my_devel_k-g devel_k-g
(i.e., it inherits the devel_k-g branch)In case you want to update your pull request:
I knew I was doing something wrong :sweat_smile:. I will follow this work flow from now on, thank you.
(deleted)
I modifeid the pull request.
Okay, one point left open: To check the success of rt_db_get_internal and maybe db_lookup. See my comment in the PR.
I saw the comment, I will modify it tonight
Louis Googl said:
I found the bug related to the conversion of this key file
image.png
What do you think about this one ?
Louis Googl said:
I am working on a fix
I've read this ... and no questions anymore.
It seems to be an issue of the C/C++ parser with numbers other than doubles.
I was implicitly asking if it's a good thing to work on :sweat_smile:. I Should have asked more clearly.
That's a pretty extreme small number...
I also find it weird but the file I am using B3_Frame_linear_buckl.key is distributed with LS-DYNA as an example and the old k-g converter was able to convert it with no problems.
Upon a closer look, there are numbers with two many dots. Obviously, the numbers are not space separated, but have fix positions in the lines ("FORTRAN format"). Do you know which?
Higher precision than double would be unexpected. Such kind of simulations often work with float precision only, for less memory consumption and higher speed.
Eight characters per number, does this make sense?
I was just going to text. I thought that the file was currpted when opening it on LS-DYNA and saving it again the file converts correctly with the new k-g converter.
Daniel Rossberg said:
Eight characters per number, does this make sense?
image.png
I don't think so, as you can see in the photo it doesn't seem to have any pattern
image.png
This is the same file after I resaved it using LS-PrePost
well I found a pattern the numbers maximaly take 16 characters each
but the node ID takes 8 characters
should I modify parse_line() to include this case, or catch the exception and ask the user to resave the file?
It looks like the NODE needs a special 8-16-16-... parser. Even the resaved file follows this pattern. You can reparse line in KState::Node.
What does the documentation say, do all lines with numbers follow this pattern?
I am checking out the documentations. first find the input is case insensitve
image.png
for the numbers format I am trying to understand. there are mutiple cases
(deleted)
the format is I8,3E16.0,2F8.0 but the node key word is not followed by ( - ) as shown in the documentation
image.png
image.png
(deleted)
Sounds good, you have something to do :wink:
What I don't understand is: We get the standard format without the "-" after NODE :thinking:
this is more clear
image.png
Daniel Rossberg said:
Sounds good, you have something to do :wink:
- Case insensitive check of the key-words
- Implement a read_line_node_standard() (or similar), which is called in the Node state
there are more things to do also realted to format :octopus:
image.png
So, there are two formats for the NODEs: standard and long. What's default, can be set with the KEYWORD command, and can be set individually for every NODE section by adding a + or -, right?
that is what I understood from the documentation. but I havent yet found any file where the node keyword is followd by - or +.
I am writing the code for the standard case, and I will try to creat a file with the long format in LS-PrePost. then I will check if its possible to see the (+) in the key file
Louis Googl said:
that is what I understood from the documentation. but I havent yet found any file where the node keyword is followd by - or +.
Okay, that's not optimal.
But, in case we want to handle this, we would need two status variables:
and a line counter "nodeLinesRead". But then, could it me merged with "partLinesRead" and "sectionLinesRead" to a general "linesRead"?
I don't think it can be merged to a general linesRead because the format could change from "Card" to another, so a node could occupy a single line or occupy two lines. but maybe we can increase the step of linesReed accourdingly
image.png
also there is the fixed format which is comma separated.
I came up with two implementations and tested them 1:
image.png
image.png
what do you think? any of them is good?
The first one is easier to understand, but the second one is better because you check the length of the line there.
Okay, I will prepare a pull request with the second one. What about the hard coded numbers. Is it fine like that?
Yeah, this are fixed, well defined formats. Therefore, hardcoded numbers are okay.
I created a PR for the standard format. now I will organize the ideas from the documentations to include all possible formats (fixed, free, long...etc)
I will also prepare a pull requst for the case insensitive commands.
I figured out the formats: Ls-Dyna Has 3 formats Standard, Long and I10, Standard for *Node is I8,3E16.0,2F8.0. in the Long format every field that was less or equal to 20 charachters in the standard format becomes 20 caracters and any field that was longer than 20 becomes 160 which makes the *Node I20,3E20.0,2F20. while the I10 extends any 8 characher field in the standard format to 10 charachter field so node becomes I10,3E16.0,2F10. This is what LS-PrePost can write
While it can read the same ubove mentioned formats as they are and also comma separated. which they call free format. but it's not possible to write a file with comma separated fields.
In older versions (also old documentation) when the long format is invoked, the number of lines belonging to the *Node key word becomes two lines instead of one. while in the new versions the number of lines is one for either standard or long formats.
the signs (+) for (long) and (-) for (standard) are not writtine by LS-PrePost when the file is saved. but can be used by the user in the command line or if they user has written his own .key file. consequently these formats can be mixed by the author of the .key file for example *Node+ (some node) *Node-(some other node)
A file written by LS-PrePost in the long format can be distingueshe by LONG=Y written after the *Keyword, while nothing is written after the *NODE
image.png
image.png
image.png
while a file saved in the I10 format can be distingushed by I10=Y written after the *Keyword or the percentage sign written after *NODE %
image.png
image.png
image.png
Okey, therefore we need
do we want to read anything LS-PrePost can read or only the things that it can save? because
Long=Y means (read long write long), Long=s means (read standard write long) , long=k means ( read long write standard). what about the comma separated case should we implement it?
yes we need nodeHalfLine variable if we want to read older versions with long format.
Ideally, we should be able to read everything what's a valid key-file...
Okay, I will work on the points you mentioned then we can plan for the other points
I have submitted a draft pull request so you can see the way things are going, and I don't go very far in the wrong direction :grinning_face_with_smiling_eyes: .
I think it's better insetead of defaultNodeFormat to put File format, because the *KEYWORD defines the format for the entire file, then I defined a node format to test for each node if it's format corresponds to the file format or not. This is a thing we can do to all other Blocs/Cards. I tested the code using the saving formats from LS-PrePost (standard, Long,I10), and I modified a standard file to include a long node
image.png
Now I am trying to get an old version of LS-PrePost to prepare the code for nodeHalfLine;
You code looks good. I added some comments, how it could be improved, but your direction is the right one.
I have been trying to reproduce a node with two lines for the entire day. No sucess even if I write it by myself the LS-PrePost gives an error. should I just take the documentations word for it and write the code correspondingly, or keep trying to find a file with two lines nodes?
I would say, do your best and implement it following the documentation. We will probably never see a LS-Dyna keyword file with the 2-line node format in real live.
okay, I will do it following the documentations.
while playing with the save options I found an addtional case, the option Non-Default Only, the format doesn't change but the zero fileds are replaced by spaces
image.png
image.png
I also found the option for saving the file in Freeformat, sorry that I said it wasn't possible before.
In Freeformat the zeros aren't recorded as you see in the picture, and if the zero fields are the end they aren't even delimenated by commas.
image.png
image.png
image.png
I will prepare a pull requst for all these cases.
Hmm, stod() of an empty string (or spaces only) should be 0, or throw an exception?
it throws an exception for both.
I updated the pull request to include the case where the node occupies two lines. also the comma separated format and the non default only format. take your time to check it out. In case the ideas are fine I will do more tests and clean up the code for final PR. meanwhile I will start working on the unhandeled command *ElEMENT_SOLID
Well, PR #144 looks good. You can clean it up. I added only one comment regarding the comma separated format.
Great, I will prepare it tonight
I cleaned up the PR. hopfully :grinning_face_with_smiling_eyes:
Regarding the solid element we need to change some data structures or add a new one like KElement, here I added the extra noods, but they will not be used in case the element was shell. I keep it like this or define two new structs KElement_shell and KElement_solid?
and I think the solution for adding the element solid is using arb8, what do you think?
another doubt, the only important information in section_solid is the ID, the elform (Element formulation options) and aet (Ambient element type) has nothing to do with the geometry but if one wants to convert again from .g to .k they are important information, should we register them somewhere?
image.png
if you wish to see the development they are on my github in a new branch mydevel_k-g. still not ready for a pull request
Sorry for not responding. It's a busy time currently, very stressful. I hope to find time to analyse it soon.
Yeah don't worry, I will just leave the doubts here. You can check it when it's convenient for you
Louis Googl said:
Regarding the solid element we need to change some data structures or add a new one like KElement, here I added the extra noods, but they will not be used in case the element was shell. I keep it like this or define two new structs KElement_shell and KElement_solid?
struct KElement {
std::vector<int> nodes;
};
?
Louis Googl said:
and I think the solution for adding the element solid is using arb8, what do you think?
Yes, it looks very much like an arb8, including its reduced versions arb4, ..., arb7.
Louis Googl said:
another doubt, the only important information in section_solid is the ID, the elform (Element formulation options) and aet (Ambient element type) has nothing to do with the geometry but if one wants to convert again from .g to .k they are important information, should we register them somewhere?
image.png
Can you translate them to attributes?
How about having a superclass Geometry
of Bot
and Arb8
(I would call it this, because it wraps this BRL-CAD object) with a member variable type
, where you can get its type?
Yes it's possible to add them as attributes, but I will have to add them to the elements not to the region, because they are an attribute of the elements that have that section
The super class is a good idea, I will work on it. Thank you for the notes
I wrote a prilimenary code for creating the arbs and adding them into a region.
I have a question regarding the superclass Geometry, in order to creat the super class I need to have the class Solid already implmented then put Bot and Solid inside Geomtry? or should I delete the Bot class and the Geomtry class will include everything related to bot and solid?
image.png
(deleted)
Okay - I think we need to go a step back. Can a Part have mixed Shell and Solid Elements?
In this case, from an API point of view, we would need in k-g.cpp, line 70:
Geometry& geometry = regions.addRegion(partName);
with methods geometry.setThickness()
, geometry.addTriangle(point1, point2, point3)
, and geometry.addArb8(point1, point2, point3, point4, point5, point6, point7, point8, )
.
Daniel Rossberg said:
Okay - I think we need to go a step back. Can a Part have mixed Shell and Solid Elements?
I will check this.
Daniel Rossberg said:
In this case, from an API point of view, we would need in k-g.cpp, line 70:
Geometry& geometry = regions.addRegion(partName);
with methods
geometry.setThickness()
,geometry.addTriangle(point1, point2, point3)
, andgeometry.addArb8(point1, point2, point3, point4, point5, point6, point7, point8, )
.
I was writing an Arb class and a solid class that contains a fake Bag of Arbs which would be a vector of Arb inside the solid class. because If we want to have gemotry.addArb8(), we need a place to add it to. geomtry.addTriangle() adds the triangle to a BOT
also this is necessary if we want to write the arbs in regions.creat(). there should be Geomtry.write() similar to what is now bot.write(). so the m_list of RegionList should contain the bag of arbs and the bag of triangles. or am I worng?
I think, you are going in the right direction. However, I like to speak in code ;)
class Solid {
public:
void setThickness(double value) {
bot.setThickness(value);
}
void addTriangle(const point_t& point1,
const point_t& point2,
const point_t& point3) {
bot.addTriangle(point1, point2, point3);
}
void addArb(const point_t& point1,
const point_t& point2,
const point_t& point3,
const point_t& point4,
const point_t& point5,
const point_t& point6,
const point_t& point7,
const point_t& point8) {
arbs.push_back(Arb(point1, point2, point3, point4, point5, point6, point7, point8));
}
void write(rt_wdb* wdbp) {
if (bot.notEmpty())
bot.write(wdbp);
for (std::vector<Arb>::const_iterator it = arbs.begin; it != arbs.end; ++it)
it->write(wdbp);
}
private:
Bot bot;
std::vector<Arb> arbs;
};
Is it this, what you have in mind? (The above sketched code is in no sense complete or functional.)
image.png
a part cannot contain two different kinds of elements
image.png
ls-Prepost created an additional part autormatically because I wrote a solid element in a part that had shell elements
what I have in mind is
class Arb {
public:
Arb(void);
~Arb(void);
void setName(const char* value);
void addNodes(
const point_t& point1,
const point_t& point2,
const point_t& point3,
const point_t& point4,
const point_t& point5,
const point_t& point6,
const point_t& point7,
const point_t& point8);
const char* getName(void) const;
void write(rt_wdb* wdbp);
private:
std::string name; //The name will be the element number from .k file
rt_arb_internal arb_internal;
};
then a class Solid
class Solid {
public:
void setName(const char* value);
void addArb( struct Arb);
private:
std::string name; // the name will be the part name from .k file
std::vector<Arb> arbs; // fake Bag of arbs
};
Then finally a Geomtry class :
class Geomtry{
public:
//necessary functions
private:
Solid solid;
Bot bot;
};
what do you think?
I created a draft PR so maybe you can see better the classes that I implemented Solid and Arb. I hope the code is not to dirty to understand :octopus: . My plan is to merge Bot and Solid classes in the Geomtry class. if you agree on the approach I will prepare a better code. the Region list will contain the Geomtry class insted of bot and solid as I did now, this code is just for demonstartion purposes.
I wouldn't separate Solid and Arb. We don't separate Bot and Triangles either. Create an Arbs class which behaves similar to Bot - with an addArb() method.
Keep in mind that the Bot class refers explicitly to the bot BRL-CAD object. Arbs should do this too. The stuff in k_parser does not. It's BRL-CAD agnostic.
So I don't need a Solid class?
The Arbs class will refer to the BRL-CAD object through rt_arb_internal or there is another way?
I will start with it tomorrow, today I am having a very nasty headache :pensive:
Louis Googl said:
So I don't need a Solid class?
The Arbs class will refer to the BRL-CAD object through rt_arb_internal or there is another way?
There are other ways, e.g. maintaining an intermediate list of the points std::vector<double[3][8]>
, but std::vector<rt_arb_internal>
is more straight forward, or?
Louis Googl said:
I will start with it tomorrow, today I am having a very nasty headache :pensive:
Get well soon!
I updated the PR with the Arbs class, it's still missy in Region_list I will make it better when we decide on the Geomtry class. I didn't find that writing a getArb() method is necessary, but getArbs() is the one we need for writing the arbs in the data base inside regions.creat() . let me know what you think.
if you think Arbs is fine, I can creat a Geomtry class with Bot and Arbs as members and the type variable, then modify the logic in k-g and region_list
I have implemented the Geomtry class in the way I imagned it, mayb it's more clear now. Please let me know what you think. I also created a pull reqest for case insensitve keywords
I was also checking out some other examples from LS-DYNA I found in the sloshing example two commands that we didn't implement, *MESH_SURFACE_NODE and *MESH_SURFACE_ELEMENT, but I couldn't fine anything about these two commands in the documentations.
mesh_fluid.k
image.png
image.png
@Louis Googl this is all outstanding progress -- are you able to handle this one yet? https://www.dynaexamples.com/implicit/yaris-static-suspension-system-loading/zip-for-download.zip
Hi @Sean actually the file doesn't convert totally, I can convert the ground but not the car yet, still there is some problems. I am working on the problems I think I will be able to convert it today.
image.png
I was faster than I expected :rolling_on_the_floor_laughing: , the car is converting but not perfectly. I still need to handle *ElEMENT_BEAM, *ELEMENT_DISCRETE , *ELEMENT_MASS, *SECTION_BEAM and *SECTION_DISCRETE.
additionally I need to color it as you can see it's difficult to recognize the parts
That's still awesome! Impressive progress. There are a whole host of sample .k files on that site that will be good test cases. Some are very simple, some very complex.
Thank you. I think I need to modify the approach instead of using examples and checking if something is wrong I will go through the documentation and implement all kinds of elements and sections.
One issue that is still not clear to me is the command *INCLUDED_TRANSFORM, this command causes a shift in elements IDs, a coordinate transformation and scaling, but it's not obvious from the documentation how that happens
I will read more and see if I can figure it out
It's of course good to revisit the docs, but I also would check examples from time to time since that's the practical validation that will actually matter. We've implemented many many converters over the years and I can tell you there have been many times when the docs say the format should have one thing, but actual files have something else entirely. It's good to check both.
This is still pretty early stages, so not surprising that there are still elements, sections, and transforms to consider. I was surprised you got anywhere near as far as you did with the car since that was a non-trivial test case.
That said, there are much much simpler test cases on that same site that demonstrate specific concepts. They might actually help with understanding what the docs describe, or help understand how elements are encoded, where data is stored, etc.
For example, https://www.dynaexamples.com/introduction and https://www.dynaexamples.com/introduction/examples-manual and https://www.dynaexamples.com/implicit/basic-examples and https://www.dynaexamples.com/show-cases
Nice overview of all the keywords on this site: https://2021.help.altair.com/2021.2/hwsolvers/rad/topics/solvers/rad/ls_dyna_keywords_r.htm
ah, interesting, INCLUDE_TRANSFORM is like a #include but lets you change that file dynamically (e.g., to map it to different location, or different units, or different ID ranges, etc)
(source: https://ftp.lstc.com/anonymous/outgoing/jday/manuals/ls-dyna_971_manual_k_rev1.pdf)
Regarding the primitives' names: How about having std::vector<std::string> Bot::write(rt_wdb* wdbp)
and std::vector<std::string> Arbs::write(rt_wdb* wdbp)
? Then, you could write
std::vector<std::string> Geometry::write(rt_wdb* wdbp)
{
std::vector<std::string> ret = m_bot.write(wdbp);
std::vector<std::string> arbNames = m_arbs.write(wdbp);
ret.insert(ret.end(), arbNames.begin(), arbNames.end());
return ret;
}
The return of this had to be used in RegionList::create()
. If doing so, there would be no need for a geometry type.
The name of the bot is <base-name>.bot. The names of the arbs can be determined on write as <base-name>.<index>.arb, or?
@Daniel Rossberg you are right, I don't know why I got stuck on trying to name the objects immediatly when the Geomtry class is named. I didn't consider to name the bot inside the write function of m_bot and m_arbs, I will update the pull request. Thank you for the advice.
@Sean True, a mixed approach between examples and documentation is the way to go. I will check out the soruces you sent me. Thanks for the support.
@Daniel Rossberg the only thing that is missing is we need Part_Name.arbs equivelent to Part_Name.bot, because in the Bot we don't name the single triangle, but in the fake bag of arbs we have names for the individual arb, I will find a work around
I updated the PR, hopfully it solves the naming problems. let me know what you think
Louis Googl said:
Daniel Rossberg the only thing that is missing is we need Part_Name.arbs equivelent to Part_Name.bot, because in the Bot we don't name the single triangle, but in the fake bag of arbs we have names for the individual arb, I will find a work around
I saw, you found it :grinning_face_with_smiling_eyes:
I am implementing *PART_CONTACT, this increases the number of parameters related to the Part, but they are not geometrical properties so I would just need to add a case partLineRead 2 . Does it need a comment?
image.png
image.png
Yes, like "some part types like CONTACT have an additional line of non-geomatric data" (only a suggestion).
I am claning up the Geometry pull request I will let you know when I update the PR.
I asked you some questions about the constructors on the github reveiw, did you have time to see them?
Do you mean the one, I've answered some minutes ago?
yes I jsut saw it, needed to refresh the page :grinning_face_with_smiling_eyes:
Added something regarding the Geometry class: The standard ones should do it.
I cleaned up the PR, but still I didn't handle the other types of arb. I was searching in the code I didn't find something similar to ID_ARB8, like ID_ARB7 or ID_ARB6...etc to be used with wdb_export(). I will keep on it tommorrow.
Arb4 through Arb7 are all stored as Arb8, just encoded as duplicate vertices in a specific way.
* -------+-------------------------
* Solid | Redundant storage
* Type | of some of the vertices
* -------+-------------------------
* ARB4 | 3=0, 5=6=7=4
* ARB5 | 5=6=7=4
* ARB6 | 5=4, 7=6
* ARB7 | 7=4
* ARB8 |
* -------+-------------------------
Calling rt_arb_get_cgtype(&type, ...) returns 4 through 8 in'type' to indicate which it is.
okay that's great, so I just need to dublicate the verticies in the correct way.
I saw something similar in arb8.cpp
image.png
but it wasn't about vertices, it's about faces and edges
Yes, there are a handful of tables like that, all because of the overloaded array encoding.
In fact, I posted the wrong table originally, just updated with the right duplications.
rt_arb_std_type() is another function that returns the type instead of taking it as a param, and takes an rt_db_internal instead of an internal.
Sean said:
the duplication is clear, but what does it mean 3=0 for arb4 ?
So an arb4 has 4 vertices, that means it's duplicated as follows:
[0]=..; [1]=..; [2]=..; [3]=[0]; [4]=..; [5]=[4]; [6]=[4]; [7]=[4];
so if I were to print it, I'd print [0], [1], [2], [4].
programing in matlab for 3 years, I forgot that 0 can be an index :melting_face:
They're some deeper reason why they're not simply the first 4 for arb4, but that's what it is.
arb4 is 01204444
arb5 is 01234444
arb6 is 01234466
arb7 is 01234564
arb8 is 01234567
what is the reason?
Honestly, I don't remember, I just remember that there was some deep reason from way back in a time when it mattered.
Almost certainly doesn't matter to that extent any longer, but I have a vague recollection that it was multiple reasons. Something to do with being able to replicate the face, edge, and vertex editing logic so that there's not 5 case blocks everywhere. I think there was also some very low-level disk optimization too (probably not as important any more). Also think there was some compatibility with GIFT (another geometry system) which ARB8 was based on.
Would have to dig through code and old docs to remind ourselves for sure.
the code is huge, there are a lot of things to learn, also it is intersting how old solutions affects what we do now.
You can use MOOSE as reference, e.g. Arb8.cpp.
I updated the PR, either AddArb is correct or it's very wrong :grimacing:, let me know what you think.
I was reading in the documentaion about elements with higher number of nodes
do we need to write all the nodes in the .g file or just the nodes that are sufficient to get the geometry?
image.png
image.png
Ideally, the ones that are sufficient to get the geometry only.
@Louis Googl: I'm just reviewing your "Geometry class" PR, and I wonder, why Arbs::addArb()
has the arbName
parameter. It make the whole thing a more complicated. Without it, you could write in k-g.cpp
else if (kData.elements[*itr].nodes.size() == 8)
AddArb(kData.elements[*itr].nodes[0],
kData.elements[*itr].nodes[1],
kData.elements[*itr].nodes[2],
kData.elements[*itr].nodes[3],
kData.elements[*itr].nodes[4],
kData.elements[*itr].nodes[5],
kData.elements[*itr].nodes[6],
kData.elements[*itr].nodes[7],
kData, geometry);
and in Arbs
declare arbs
as std::vector<rt_arb_internal>
write
std::vector<std::string> Arbs::write
(
rt_wdb* wdbp
){
std::vector<std::string> ret;
for (size_t i = 0; i < arbs.size(); ++i) {
std::string arbName = name;
arbName += ".";
arbName += std::to_string(i);
arbName += ".arb";
ret.push_back(arbName);
you are right the code you wrote is nicer, but I added the arbName because the elements number in LS-DYNA doesn't start always from 1 and go on ascending order. the thing is I wanted to preserve the element number as is written in the .k file. if you find this unneccessary I can modify the code. what do you think?
image.png
I am also working on a new PR related to unhandeled sections, elements and parts, but it relies on the Geometry class, so I will submit it after we close the Geometry PR.
regarding the ELEMENT_BEAM do we want to draw it as a line or we take the section and extrude it? in LS-PrePost they draw it as a line. the beams in the following image have an I section (section 1 in the second image) but they are represented as a line.
image.png
image.png
another thing I am working on is the distinction between different commands and a command with options
for example *PART and *PART_ADAPTIVE_FAILURE are two different commands, but *PART and *PART_CONTACT are the same *PART command with the option CONTACT, also because the order of the options defines what the following cards (lines) contains, so I think we are going to need a vector of strings to hold the options and we need to combine the logic to check partLinesRead and the options vector to know what card we are reading. This will not be necessary for all the options as most of them aren't related to the geometry.
image.png
image.png
another issue is that an option can override properties that are defined in other places, for example if we have *SECTION_BEAM with a certain thickness and then *ELEMENT_BEAM with the option THICKNESS i.e *ELEMENT_BEAM_THICKNESS the latter command overrides the thickness defined in the former command. I am trying to find a way to protect the information provided by the superiour command so it doesn't change if the *SECTION_BEAM comes after *ELEMENT_BEAM_THICKNESS
I submitted a PR to handle the element options, similarly this will be the way to handle the section's options. and eventually if we want to handle all elements we will need this code or a similar one. @Daniel Rossberg let me know what you think :salute:.
Louis Googl said:
regarding the ELEMENT_BEAM do we want to draw it as a line or we take the section and extrude it? in LS-PrePost they draw it as a line. the beams in the following image have an I section (section 1 in the second image) but they are represented as a line.
image.png
image.png
For BRL-CAD, we need all elements as solids. I.e., they should have the real beam shape, if feasible. If that's too complicated or the real shape isn't well defined, a cuboid with corresponding line-of-sight value would be possible.
Louis Googl said:
another thing I am working on is the distinction between different commands and a command with options
for example *PART and *PART_ADAPTIVE_FAILURE are two different commands, but *PART and *PART_CONTACT are the same *PART command with the option CONTACT, also because the order of the options defines what the following cards (lines) contains, so I think we are going to need a vector of strings to hold the options and we need to combine the logic to check partLinesRead and the options vector to know what card we are reading. This will not be necessary for all the options as most of them aren't related to the geometry.
image.png
image.png
In the converter, the distinction is done with the KState enumeration. This addresses the real different stuff. E.g., PART and PART_INERTIA are in fact the same, PART_ADAPTIVE_FAILURE is something different.
Regarding the options, I'll review your proposal in the PR.
Daniel Rossberg said:
For BRL-CAD, we need all elements as solids. I.e., they should have the real beam shape, if feasible. If that's too complicated or the real shape isn't well defined, a cuboid with corresponding line-of-sight value would be possible.
is there some example code I can look at?.
for a beam that have a T section we can devided to two arbs? or is there a methode for extrusion from the section?
image.png
Hmm, theoretically, we have the extrude primitive, which extrudes a 2D sketch along a line. Using arbs would be possible too (overlaps wouldn't matter).
Regarding the options: Do we have a kind of stack there? E.g., for every option a global, section and element value? WE could think about crating an option object, which reacts on the enter section, enter element, exit element, and exit section events. (I don't know, if we can really say when we "exit" something, maybe we can see the "enter"s only.)
the option card or line follows directly under the command say we have Element_Beam_Section card3 will be there and card2 wouldn't. this is the way to know that you are exiting an element, number of lines is equal to the required card pluse the number of options.
image.png
Louis Googl said:
another issue is that an option can override properties that are defined in other places, for example if we have *SECTION_BEAM with a certain thickness and then *ELEMENT_BEAM with the option THICKNESS i.e *ELEMENT_BEAM_THICKNESS the latter command overrides the thickness defined in the former command. I am trying to find a way to protect the information provided by the superiour command so it doesn't change if the *SECTION_BEAM comes after *ELEMENT_BEAM_THICKNESS
I understood that *SECTION_BEAM and *ELEMENT_BEAM can be in any order anywhere in the data. The link will be created when parsing KData via the IDs. I.e., the thicknesses have to be stored in the data and evaluated when parsing it.
yes, now I understand what you meant. exactly the the ID is the link. but after storing the thickness from ELMENT_BEAM_THICKNESS it needs to be protected from change, and if it's taken from SECTION_BEAM it should be modifiable.
You need a kind of std::map<std::string, std::string>
or std::map<std::string, double>
for the options:
thickness := default
if SECTION.options[THICKNESS] then
thickness := SECTION.options[THICKNESS]
if ELEMENT.options[THICKNESS] then
thickness := ELEMENT.options[THICKNESS]
(That's pseudo-code, of course.)
Examples of sketch+extrude are at https://brlcad.org/wiki/Sketch and https://brlcad.org/wiki/Extrude
I updated the PR, I did it for the ELEMENT_BEAM options. I have used an options counter to indecate which card we are dealing with and a switch statment to handle all possible options, and I think it's better than using elementLinesRead. Let me know what you think @Daniel Rossberg
I don't think that it makes sense to distinct between elementOptions
, sectionOptions
, elementBeamOptions
in k_parser.cpp. Every set of options belongs to the current state there. The merging of e.g. elements and sections has to be done when the KData structure is evaluated in k-g.cpp.
yes I agree. I will creat a single enum to include all kinds of options.
about the element and section merging I think it's better if we expand Kelement to include more information. because usually the Part has a section id which get inhereted by the elements that belong to that Part, but an element with the option Section overrides these information only for that element. I am thinking about it, I will update the code and maybe it will be clearer
it's a littile bit more complicated than I imagened, say that we have a shell element number 2000 in Part number 1, associated to section number 2 and another shell element 3000 that belongs also to Part 1 and has the section option activated, then element 3000 will have different thickness than element 2000. but on the brlcad side we can set the thickness to the entire bag of triangles do we want to creat a different BoT everytime we have an element with different thickness? or Ignore this option in shell elements?
also we are already ignoring indvidual thicknesses at the nodes, because we are taking the avrage
image.png
I updated the PR, I don't know if it's a good idea to stuff all the option card values in a vector then interpret them later in k-g.cpp. what do you think?
I also have been trying to implement the coloring for the regions for a while, but I didn't find random coloring in MOOSE. I tried also to use bu_color_rand() but I didn't find a way to convert bu_color to rgb. it can be done as in the old k-g converter though
image.png
Louis Googl said:
I updated the PR, I don't know if it's a good idea to stuff all the option card values in a vector then interpret them later in k-g.cpp. what do you think?
I think that this is the only possibility. We need the complete information from all cards to generate the BRL-CAD geometry.
Regarding BoTs with varying thickness: A triangle can have only one thickness, but you can set an individual thickness for every triangle in a BoT.
Louis Googl said:
I also have been trying to implement the coloring for the regions for a while, but I didn't find random coloring in MOOSE. I tried also to use bu_color_rand() but I didn't find a way to convert bu_color to rgb. it can be done as in the old k-g converter though
image.png
bu_color codes the values as floats between 0 and 1. You can use bu_color_to_rgb_chars() to get them as ints between 0 and 255.
If only I have read 10 more lines in color.h :melting_face:
I remember that you merged this pull request PR but I can't find the functions read_line_node_long() read_line_node_i10(). I also tried to check subsequent pull requests I have not delete them. what do you think happened?
image.png
I don't think we can do something like this on BRL-CAD side. no?
I updated the PR with element Pulley and I submitted a PR for the random region color.
let me know what you think about the
struct KElementPulley
we will have to creat another new Kelement also for *ELEMENT_BEARING
image.png
the examples server is down :octopus:
image.png
Louis Googl said:
image.png
I don't think we can do something like this on BRL-CAD side. no?
If there are parameters that describe the thread/yarn/cable radius, it could probably be encoded as a pipe primitive.
I meant pulling out of the yarn. This element will be a point at t=0 until there is a force to pull on the yarn
Louis Googl said:
I remember that you merged this pull request PR but I can't find the functions read_line_node_long() read_line_node_i10(). I also tried to check subsequent pull requests I have not delete them. what do you think happened?
Ups, it looks like your PR #147 removed them.
Louis Googl said:
I meant pulling out of the yarn. This element will be a point at t=0 until there is a force to pull on the yarn
Understood -- the point was that the state at t=whatever can probably be "somewhat easily" described geometrically as a pipe primitive. At t=0, there are some quantity of pipe bends implied in an increasing count depending on the width of the wire and width of the spool. As it's pulled out, each t=XX would geometrically reduce the number of bends/rotations.
That's not to say that there's currently a function to do that, but that it's not terribly complicated to think about what would be needed for a simple/naive implementation (sans and sort of compression).
That would be nice to implement
Daniel Rossberg said:
Louis Googl said:
I remember that you merged this pull request PR but I can't find the functions read_line_node_long() read_line_node_i10(). I also tried to check subsequent pull requests I have not delete them. what do you think happened?
Ups, it looks like your PR #147 removed them.
I will include them in the next pull request.
I added Element_Beam_Source and Element_Bearing, @Daniel Rossberg let me know if you have any objections .
I am also working on the corresponding sections and then I think I will move from the parser side to BRL-CAD. Or do you think I should finish all the elements on the parsing side first?
Louis Googl said:
I added Element_Beam_Source and Element_Bearing, Daniel Rossberg let me know if you have any objections .
Don't worry about elementLinesRead, I am going to replace all LinesRead variables with one variable cardCounter
and maybe eventually we replace the cardCounter and optionCounter with a lineCounter variable, I am trying to see if it's possible to generalize.
Louis Googl said:
I added Element_Beam_Source and Element_Bearing, Daniel Rossberg let me know if you have any objections .
This is probably the ways how this has to be done.
Louis Googl said:
I am also working on the corresponding sections and then I think I will move from the parser side to BRL-CAD. Or do you think I should finish all the elements on the parsing side first?
Well, your GSoC time is approaching its end. There are only 2 weeks left.
...
However, maybe you can have a look at the g-k side and make a proposal or proof of concept how this could be done.
yes, I know that the end time is getting closer. I will propably keep working on the project after the end of GSOC.
I don't think I will be able to finish the element Bearing but at least I will prepare the section extrusion for the beam element.
image.png
these people at LS-DYNA spend there days inventing ways to change the order of the cards in .k files :laughing:
Their data format is closely connected to the features: If someone introduces a new feature, which needs to store some data, they hack it among the others branching with wild flags.
it is a very versatile software. I tested for the first 7 charachtes like this
image.png
I'm currently workin on an implemtation of the beam elment with cross section type 1 which is a circular tube. The plan is to implemente it as a pipe primative
"cross section type 1": Is this the I-shape?
No this is the Tubular
image.png
image.png
for the resultant beam type 1 is the I-shape.
how do you like my addBeam() function :grinning_face_with_smiling_eyes:
image.png
this is how it looks like using the Pipe premative, this is a part of the Yaris car model
image.png
image.png
it's not perfect though. considering each element by itself will only provide the C0 continuity. This is because the bend radious is not provided by the .k file.
image.png
what do you think?
Hmm, some thoughts:
1- I put a constant value for bending radious, because I read in the documentation that bending radious can't be zero.
2- I was thinking about this, but I though if I put all the beam elements in 1 pipe premative they are going to be connected together using the facke bending radious I used. I will check the link you provided and modify.
3- yes I agree, I called it beam because I was thinking to put all beams inside it, but maybe it's going to be very messy. let's call this one pipe and maybe in the future we can combine all beam elements in one class
That the bend radius is "fake" isn't so bad. What is its minimum value? 2 times the outer radius, or the ray-trace will complain?
image.png
it will depend on the inner and outer diameter
I should have finished the modifications yesterday but I faced a problem, when I use the wdb_export() on line 77 it works, but the one on line 88 prduces export failure, to me the lines are the same but I coudn't know why it produces this error
image.png
image.png
the lines are the same because rt_pipe_internal* m_pipe; should be equivelent to rt_pipe_internal* pipe_wdb;
Why does it depend on the inner diameter too? The most extreme torus would be one with no hole, i.e. the bend radius is two times the pipe or torus radius. See e.g. https://github.com/BRL-CAD/brlcad/blob/main/src/librt/primitives/pipe/pipe.c#L4320
No you are right. I just guessed that it might be dependent on the inner radious :melting_face:. I will put it as 2 times the external radius.
Louis Googl said:
the lines are the same because rt_pipe_internal* m_pipe; should be equivelent to rt_pipe_internal* pipe_wdb;
Hmm, I don't have your full code, but in https://github.com/BRL-CAD/brlcad/pull/151 there is //rt_pipe_internal m_pipe;
, i.e. without the * pointer declaration.
I just pushed the code. the comment is old, now it is rt_pipe_internal* m_pipe
ThreebeamIn1.k
there is this small file if you want to test, the car model taks long time
Lines 33 and 34 of pipe.cpp
m_pipe->pipe_segs_head.magic = RT_PIPE_INTERNAL_MAGIC;
m_pipe->pipe_count= 0;
look suspicious, especially the first one, with the RT_PIPE_INTERNAL_MAGIC. BU_LIST_INIT does already the right things.
I think I found it, it is not the suspicious lines. If I check the first element in the list before calling BU_LIST_APPEND_LIST I see the correct information, but when I check it after calling it everything disappers. it seems like BU_LIST_APPEND_LIST is deleating the pointer or freeing it
image.png
image.png
The wiki is down, do you know what is wrong?
also I just received an email from GSOC to prepare the final submission. do you have any specifications? or shoud I do a wiki page like last time?
should I start a new pull request for the sketch and extrude or keep working\adding on the same pull request?
Louis Googl said:
should I start a new pull request for the sketch and extrude or keep working\adding on the same pull request?
If you think that a pull request is ready for merging, please tell me.
Louis Googl said:
also I just received an email from GSOC to prepare the final submission. do you have any specifications? or shoud I do a wiki page like last time?
I've no other requirements than last time ... if the wiki is up again.
I have cleaned up the Pipe class, if you have no objections I think it's ready to be merged.
I think it's better if I creat a GitHub gist, maybe the wiki will still have some problems. I will share the link with you as soon as it's ready.
Louis Googl said:
I think it's better if I creat a GitHub gist, maybe the wiki will still have some problems. I will share the link with you as soon as it's ready.
Possible, or a alihaider93.github.io page?
I fixed the file endings
also the sketch is going well, I still have to do the extrusion
image.png
@Daniel Rossberg I am preparing the final report. it's not ready, but the general theme is set, if you have some time please let me know if you think it's fine like this Report
Looks good :smiling_face:
Thank you :heart_eyes: . I am still improving it, and I will add the sketch and extrude PR link, after we close the current one.
I though I fixied the issue with the thrid node yesterday. But I was wrong :sunglasses: . now it's fine.
Just wondered :thinking:
because I added a big chunk of code on my local repository, but I didn't push it yet, so the line that I commented yesterday isn't the correct line to solve the problem.
Next bunch of issues (errors):
[ 79%] Building CXX object src/conv/k-g/CMakeFiles/k-g.dir/k_parser.cpp.o
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp: In function ‘bool parse_k(const char*, KDat
a&)’:
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Bl
anking’ not handled in switch [-Werror=switch]
596 | switch (state) {
| ^
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Di
rect_Matrix_Input’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Di
screte’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Di
screte_Sphere’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Ge
neralized_Shell’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Ge
neralized_Solid’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_In
ertia’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_In
terpolation_Shell’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_In
terpolation_Solid’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_La
ncing’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Ma
ss’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Ma
ss_Matrix’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Ma
ss_Part’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Pl
otel’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Se
atbealt’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Se
atbealt_Accelerometer’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Se
atbealt_Pretensioner’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Se
atbealt_Retractor’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Se
atbealt_Sensor’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Se
atbealt_Slipring’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Sh
ell_Nurbs_Patch’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Sh
ell_Source_Sink’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_So
lid_Nurbs_Patch’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_So
lid_Peri’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Sp
h’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Tr
im’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Element_Ts
hell’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Section_Be
am_AISC’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Section_Di
screte’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Section_Fp
d’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Section_Po
int_Source’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Section_Po
int_source_Mixture’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Section_Se
atbelt’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Section_So
lid_Peri’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Section_Sp
h’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:596:24: error: enumeration value ‘Section_Ts
hell’ not handled in switch [-Werror=switch]
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:242:34: error: unused variable ‘cardCounter’
[-Werror=unused-variable]
242 | size_t cardCounter = 0;// this will replace sectionLinesRead elementLinesRead, and
partLinesRead
| ^~~~~~~~~~~
/home/rossberg/Devel/BRL-CAD/brlcad.devel_k-g/src/conv/k-g/k_parser.cpp:247:34: error: unused variable ‘CST’ [-Werro
r=unused-variable]
247 | int CST = 0;
| ^~~
cc1plus: all warnings being treated as errors
Maybe, you can comment out (//
) unused flags?
Do you have a Linux to test it?
I will comment the unused flags.
yes I also have a linux machine. but it will take a littile while to setup. I will let you know after I test
Screenshot-from-2024-08-23-20-59-17.png
small problem with Ubuntu, any advice?
It was a time ago, when the devel_k-g branch was created. The CMake build got since some fixes and improvements.
However, what can help is
I don't know if you had some time to check the new PR. I wanted to ask you if it's okay to do the vector math inside the function Sketch::creatSketch() or should I do it inside k-g.cpp?
image.png
I also didn't put checks on the cross product because I assume a valid .k model will never have colinear nodes n1 n2 n3 because n3 is used to define the cross-section's plain. I am also assuming that the length of these vectors will never by zero.
I am currently working on the extrude class.
Before I forget: There is a build error on macOS: https://github.com/BRL-CAD/brlcad/actions/runs/10538897404/job/29201886436
/Users/runner/work/brlcad/brlcad/src/conv/k-g/k_parser.cpp:1169:19: error: variable 'eid' is uninitialized when passed as a const reference argument here [-Werror,-Wuninitialized-const-reference]
data.elements[eid] = element;
^~~
Maybe, you can initialize eid
to some default value?
will fix it. I am still trying to build on ubuntu. I will test everything also there.
Louis Googl said:
I don't know if you had some time to check the new PR. I wanted to ask you if it's okay to do the vector math inside the function Sketch::creatSketch() or should I do it inside k-g.cpp?
image.png
It's better to do this in the Sketch class, as you did, because this is sketch specific stuff, not k-file specific.
extrusion is working on a small .k file I wrote.
image.png
image.png
image.png
we have same issue of C0 continuity, but I don't think a real model will have I beams arranged like that
I think, we can get over for now. Maybe sometime, someone wants to add a gold edge :wink:
what is a gold edge? :grinning_face_with_smiling_eyes:
Louis Googl said:
I think I found it, it is not the suspicious lines. If I check the first element in the list before calling BU_LIST_APPEND_LIST I see the correct information, but when I check it after calling it everything disappers. it seems like BU_LIST_APPEND_LIST is deleating the pointer or freeing it
image.png
BU_LIST_APPEND_LIST requires there to be a head pointer, which it iterates around until it gets back to the start. If you initialize without one, you're going to get list corruption which will be behavior like you saw.
Louis Googl said:
image.png
The wiki is down, do you know what is wrong?
I'm working on it. The server started doing some major upgrades which pulled the rug out from under php's modules and required a major php upgrade. That then was incompatible with mediawiki.
General practice for adding pipe lists would be something like this:
pipe_ip->pipe_magic = RT_PIPE_INTERNAL_MAGIC;
BU_LIST_INIT(&pipe_ip->pipe_segs_head);
for (int i = 0; i < 2; i++) {
BU_ALLOC(pipe_pp, struct wdb_pipe_pnt);
pipe_pp->l.magic = WDB_PIPESEG_MAGIC;
VSETALL(pipe_pp->pp_coord, i);
pipe_pp->pp_od = 1;
pipe_pp->pp_id = 0.1 * pipe_pp->pp_od;
pipe_pp->pp_bendradius = pipe_pp->pp_od;
BU_LIST_INSERT(&pipe_ip->pipe_segs_head, &pipe_pp->l);
}
Louis Googl said:
what is a gold edge? :grinning_face_with_smiling_eyes:
It's a decoration, e.g. for dishes: https://www.ebay.com/itm/304972582544
I looks good, but isn't usually functional.
Beauty will save the world :laughing:
Sean said:
Louis Googl said:
image.png
The wiki is down, do you know what is wrong?I'm working on it. The server started doing some major upgrades which pulled the rug out from under php's modules and required a major php upgrade. That then was incompatible with mediawiki.
I added the link to my daily blog on the wiki to the GSoC report, would it be a problem if it's not working by the end of the project? The final report is on github no problem with that.
@Daniel Rossberg I did some modifications. let me know what you think about the PR
Guess how many tries does a civil engineer needs to plot a regular Hexagon? :joy:
image.png
image.png
image.png
Only the result matters :wink:
In this case is it okay to creat two sketches and extrude them? one for the inner rectangle and one for the outer
image.png
No need it can be done with one sketch
image.png
Louis Googl said:
No need it can be done with one sketch
image.png
I was going to say, you can but don't need to. The sketch primitive uses parity on interior loops so you could even add another interior, then subtract something from it, and so on. It's even pretty graceful on crossings, but not recommended as some cases are ill-defined. For simple boxes in boxes, though, that's definitely the way to go.
I had the idea that a sketch might accept only one closed shape, but then I tried and it worked.
Finally I finished all the sections, it took some time because I had to go to a conference. @Daniel Rossberg it would be nice if you have some time to check the pull request, I think it's ready for closing.
image.png
Very nice.
It's ready for accepting/merging, I hope :wink:
I hope to :grinning_face_with_smiling_eyes:
I did some stylistic tweaks and created a pull request for the main branch: https://github.com/BRL-CAD/brlcad/pull/163
That's great. I will check it out. How the turning tables :rolling_on_the_floor_laughing:
Joking :grinning_face_with_smiling_eyes: . I'm uploading my thesis in 8 days, after that I will continue working on the development branch
@Daniel Rossberg I checked the changes, I have no objections.
@Louis Googl, best wishes for your PhD thesis!
@Sean, @starseeker: What do you think about PR #163?
Thank you:heart:
Very nice - I went ahead and merged. Looks like the regression failure was due to some of the files somehow being hard-set to one particular line ending style - I think I fixed that.
@starseeker, thanks for looking at it. It surprises me that such a line ending mismatch is possible. I thought, the version control system takes care of it. I may need to pay more attention to it.
Last updated: Nov 15 2024 at 00:49 UTC