Problem type transformation

Moderator: GiD Team

Post Reply
fcdiass
Posts: 16
Joined: Fri Nov 08, 2019 8:04 pm

Problem type transformation

Post by fcdiass »

Hi,

I am developing a problem type based on the customlib. Every newly released version, I would like to transform my models into the new version of my problem type (from data tree version 0.5.0 to 0.6.0 for instance). But the following error occurs every time and all data in the data tree is lost.

Code: Select all

Error (l685): Attribute "active" not found!
STACK:
Attribute "active" not found!
    while executing
"$node @active"
    (procedure "import_units_from" line 13)
    invoked from within
"import_units_from -force $domNode_from"
    (procedure "gid_groups_conds::transform_problemtype_no_messages" line 36)
    invoked from within
"gid_groups_conds::transform_problemtype_no_messages $spd_file"
    (procedure "gid_groups_conds::transform_problemtype" line 3)
    invoked from within
"gid_groups_conds::transform_problemtype $filename_spd"
    (procedure "::GiD_Private_Event_AfterTransformProblemType" line 5)
How can I manage this?

Regards,
Francisco Dias.
User avatar
escolano
Posts: 1918
Joined: Sun Sep 05, 1982 10:51 pm

Re: Problem type transformation

Post by escolano »

attach a zip with all information required to reproduce it. (in a private message if required)
-the problemtype 0.5.0
-the problemtype 0.6.0
-the model saved with old 0.5.0 data
fcdiass
Posts: 16
Joined: Fri Nov 08, 2019 8:04 pm

Re: Problem type transformation

Post by fcdiass »

I have noticed that this problem does not happen when I remove the following part of code:

Code: Select all

    <units>
        <unit_magnitude n="Angle" pn="Angle" default="deg" SI_base="rad">
            <unit n="deg" pn="degree" p="1" factor="0.01745329251994" help="degree=1/180[pi.rad]"/>
            <unit n="rad" pn="radian" p="2" units_system="SI" factor="1.0"/>
            <unit n="°" pn="degree" p="3" factor="0.01745329251994" printable_name="deg"/>
        </unit_magnitude>
        <unit_magnitude n="F" pn="Force" default="kN" SI_base="N" basic="L*M/T^2">
            <unit n="N" pn="newton" p="2" units_system="SI" factor="1.0" help="Newton=[Kg.m/s2]"/>
            <unit n="kN" pn="kilonewton" p="1" units_system="SI"/>
        </unit_magnitude>
        <unit_magnitude n="L" pn="Length" default="m" SI_base="m">
            <unit n="m" pn="meter" p="1" units_system="SI" factor="1.0"/>
            <unit n="cm" pn="centimeter" p="2" units_system="SI"/>
            <unit n="mm" pn="millimeter" p="2" units_system="SI"/>
            <unit n="um" pn="micrometer" p="2" factor="1.0e-6"/>
            <unit n="µm" pn="micrometer" p="2" printable_name="um" units_system="SI"/>
        </unit_magnitude>
        <unit_magnitude n="P" pn="Pressure" default="kPa" SI_base="Pa" basic="F/L^2">
            <unit n="Pa" pn="pascal" p="2" units_system="SI" factor="1.0" help="Pascal=[N/m2]"/>
            <unit n="kPa" pn="kilopascal" p="1" units_system="SI"/>
            <unit n="MPa" pn="megapascal" p="2" units_system="SI"/>
        </unit_magnitude>
        <unit_magnitude n="Temp" pn="Temperature" default="°C" SI_base="K">
            <unit n="°C" pn="degree Celsius" p="1" units_system="SI" factor="1.0" addend="273.15" help="V[default]=(V[unit]+addend)*factor" printable_name="oC"/>
            <unit n="K" pn="kelvin" p="2" units_system="SI" factor="1.0"/>
            <unit n="°F" pn="degree Farenheit" p="3" units_system="imperial" factor="0.5555555555555556" addend="459.67" help="V[default]=(V[unit]+addend)*factor" printable_name="oF"/>
        </unit_magnitude>
    </units>
Is there a problem with this code snippet?

Explaning the reason that I wrote this code snippet:
To define the units in the model, I use an approach similar to "cmas2d_customlib" available in the problem type examples. There, the field 'units' is discribed with the following comment: "by now it is compulsory define this node if units are used (could be empty if defaults are enough)".
I use the field 'units' to change default unit (eg. Force -> kN, Angle -> deg, etc...) and to change the priority of units (field 'p' of 'unit', that assumes values 1,2 or 3).

Yet based on "cmas2d_customlib", use the following structure to allow the user change the units:

Code: Select all

	<value n='units_mesh' pn='Geometry units' unit_mesh_definition="1"/>
	<value n='units_system' pn='Units system' units_system_definition="1">
		<dependencies node="//*[@unit_definition or @unit_mesh_definition='1']" att1='change_units_system' v1='{@v}'/> 
	</value>
	<container n="basic_units" pn="Basic units" icon="tree/BasicUnits" help="Basic units to be used in the analysis.">
    	<value n="units_angle" pn="Angle" unit_definition="Angle"/>
		<value n="units_force" pn="Force" unit_definition="F"/>
		<value n='units_length' pn='Length' unit_definition="L"/>
		<value n="units_pressure" pn="Pressure" unit_definition="P"/>
		<value n="units_temperature" pn="Temperature" unit_definition="Temp"/>
	</container>
To reaffirm: only removing the first piece of code solves the transformation problem, but I lose the ability to control the standard units and the priority of each one.

How should I proceed in this case?

Regards,
Francisco Dias.
User avatar
compassis
Posts: 3
Joined: Thu Apr 09, 2015 9:29 am
Contact:

Re: Problem type transformation

Post by compassis »

We have fixed this issue and it will be available in the future GiD versions. In this way, it will be possible to work with <unit_magnitude/> nodes without defining the boolean attribute called 'active', which allows to activate or deactivate these nodes.

By the way, the problem when transforming models can also be avoided in current GiD versions, by adding the attribute active="1" to all the <unit_magnitude> nodes, as follows:

<units>
<unit_magnitude n="Angle" pn="Angle" default="deg" SI_base="rad" active="1">
<unit n="deg" pn="degree" p="1" factor="0.01745329251994" help="degree=1/180[pi.rad]"/>
<unit n="rad" pn="radian" p="2" units_system="SI" factor="1.0"/>
<unit n="°" pn="degree" p="3" factor="0.01745329251994" printable_name="deg"/>
</unit_magnitude>
<unit_magnitude n="F" pn="Force" default="kN" SI_base="N" basic="L*M/T^2" active="1">
<unit n="N" pn="newton" p="2" units_system="SI" factor="1.0" help="Newton=[Kg.m/s2]"/>
<unit n="kN" pn="kilonewton" p="1" units_system="SI"/>
</unit_magnitude>
<unit_magnitude n="L" pn="Length" default="m" SI_base="m" active="1">
<unit n="m" pn="meter" p="1" units_system="SI" factor="1.0"/>
<unit n="cm" pn="centimeter" p="2" units_system="SI"/>
<unit n="mm" pn="millimeter" p="2" units_system="SI"/>
<unit n="um" pn="micrometer" p="2" factor="1.0e-6"/>
<unit n="µm" pn="micrometer" p="2" printable_name="um" units_system="SI"/>
</unit_magnitude>
<unit_magnitude n="P" pn="Pressure" default="kPa" SI_base="Pa" basic="F/L^2" active="1">
<unit n="Pa" pn="pascal" p="2" units_system="SI" factor="1.0" help="Pascal=[N/m2]"/>
<unit n="kPa" pn="kilopascal" p="1" units_system="SI"/>
<unit n="MPa" pn="megapascal" p="2" units_system="SI"/>
</unit_magnitude>
<unit_magnitude n="Temp" pn="Temperature" default="°C" SI_base="K" active="1">
<unit n="°C" pn="degree Celsius" p="1" units_system="SI" factor="1.0" addend="273.15" help="V[default]=(V[unit]+addend)*factor" printable_name="oC"/>
<unit n="K" pn="kelvin" p="2" units_system="SI" factor="1.0"/>
<unit n="°F" pn="degree Farenheit" p="3" units_system="imperial" factor="0.5555555555555556" addend="459.67" help="V[default]=(V[unit]+addend)*factor" printable_name="oF"/>
</unit_magnitude>
</units>
fcdiass
Posts: 16
Joined: Fri Nov 08, 2019 8:04 pm

Re: Problem type transformation

Post by fcdiass »

Thank you for your answer.

I would like to make the following observations:
  1. Your suggestion solves the problem with transformation. I could replicate your code in my problem type with no problems.
  2. I am using the field "include" in the *_default.spd file. I am able to include different spd files and split my code. The only field that does not work with include is the field "units". I am sure that in previous versions the "include" option worked with the "units" field. Now, I am using the "units" definition inside the *_default.spd file. It does not really please me because the main file gets a mess.
More info about the problem in the second point:
  • I have enabled the Customlib in my problem type, using the following fields in the *.xml file:
    <CustomLibAutomatic>1</CustomLibAutomatic>
    <CustomLibNativeGroups>1</CustomLibNativeGroups>
  • In the *_default.spd file I put the following code:
    <include n="units_def" active="1" path="xml/units_def.spd"/>
  • Inside the folder "xml", I put the file "units_def.spd".
  • The "units_def.spd" contents is exactly the following:

    Code: Select all

    <?xml version="1.0" encoding="utf-8"?>
    <units>
        <unit_magnitude n="Angle" pn="Angle" default="deg" SI_base="rad" active="1">
            <unit n="deg" pn="degree" p="1" factor="0.01745329251994" help="degree=1/180[pi.rad]"/>
            <unit n="rad" pn="radian" p="2" units_system="SI" factor="1.0"/>
            <unit n="°" pn="degree" p="3" factor="0.01745329251994" printable_name="deg"/>
        </unit_magnitude>
        <unit_magnitude n="F" pn="Force" default="kN" SI_base="N" basic="L*M/T^2" active="1">
            <unit n="N" pn="newton" p="2" units_system="SI" factor="1.0" help="Newton=[Kg.m/s2]"/>
            <unit n="kN" pn="kilonewton" p="1" units_system="SI"/>
        </unit_magnitude>
        <unit_magnitude n="L" pn="Length" default="m" SI_base="m" active="1">
            <unit n="m" pn="meter" p="1" units_system="SI" factor="1.0"/>
            <unit n="cm" pn="centimeter" p="2" units_system="SI"/>
            <unit n="mm" pn="millimeter" p="2" units_system="SI"/>
            <unit n="um" pn="micrometer" p="2" factor="1.0e-6"/>
            <unit n="µm" pn="micrometer" p="2" printable_name="um" units_system="SI"/>
        </unit_magnitude>
        <unit_magnitude n="P" pn="Pressure" default="kPa" SI_base="Pa" basic="F/L^2" active="1">
            <unit n="Pa" pn="pascal" p="2" units_system="SI" factor="1.0" help="Pascal=[N/m2]"/>
            <unit n="kPa" pn="kilopascal" p="1" units_system="SI"/>
            <unit n="MPa" pn="megapascal" p="2" units_system="SI"/>
        </unit_magnitude>
        <unit_magnitude n="Temp" pn="Temperature" default="°C" SI_base="K" active="1">
            <unit n="°C" pn="degree Celsius" p="1" units_system="SI" factor="1.0" addend="273.15" help="V[default]=(V[unit]+addend)*factor" printable_name="oC"/>
            <unit n="K" pn="kelvin" p="2" units_system="SI" factor="1.0"/>
            <unit n="°F" pn="degree Farenheit" p="3" units_system="imperial" factor="0.5555555555555556" addend="459.67" help="V[default]=(V[unit]+addend)*factor" printable_name="oF"/>
        </unit_magnitude>
    </units>
    
  • Using these configurations, when I try to load my problem type I have the following error:

    Code: Select all

    Error (l685): invalid command name ""
    STACK:
    invalid command name ""
        while executing
    "$parent appendChild [$node1 cloneNode]"
        (procedure "import_units_from" line 27)
        invoked from within
    "import_units_from $domNode_from"
        (procedure "units_get_global" line 4)
        invoked from within
    "units_get_global"
        (procedure "gid_groups_conds::begin_problemtype" line 20)
        invoked from within
    "gid_groups_conds::begin_problemtype $filename_spd $filename_user_defaults "" 0           "
        (procedure "gid_common_problemtype_init_customlib_automatic" line 29)
        invoked from within
    "gid_common_problemtype_init_customlib_automatic $dir"
        (procedure "::GiD_Private_Event_BeforeInitGIDProject" line 8)
        invoked from within
    "::GiD_Private_Event_BeforeInitGIDProject {D:/Program Files/GiD/GiD 14.0.5/problemtypes/GiD2GeMA.gid}"
    
Can you help me with this problem?
User avatar
mrpeyrau
Posts: 4
Joined: Fri Oct 23, 2020 5:22 pm

Re: Problem type transformation

Post by mrpeyrau »

I have checked in GiD 15.0.1 version, that a problem type can be loaded successfully adding <include n="units_def" active="1" path="xml/units_def.spd"/> folder, and the units file given by 'units_def.spd' file. Maybe the version of GiD you are working on is an older one.

It should be noted that I have used 'cmas2d_customlib.gid' problem type, and GiD 15.0.1 to check this issue. The main file 'cmas2d_customlib.spd' is as follows:

<?xml version="1.0" encoding="utf-8"?><!-- -*- coding: utf-8; mode: SGML -*- -->

<cmas2d_customlib_data version='1.0'>
<style show_menubutton_about='0' show_menubutton_search='1'>
</style>
<display_options frame_width="151" is_frame_open="1"/>
<!-- units -->
<include n="units_def" active="1" path="xml/units_def.spd"/>

.....


By the way, the 'xml' folder contains the file 'units_def.spd', defined by:

<?xml version="1.0" encoding="utf-8"?>
<units>
....
</units>
Maria Rosa Peyrau Rubio
Dept. Pre and Postprocessing CIMNE
fcdiass
Posts: 16
Joined: Fri Nov 08, 2019 8:04 pm

Re: Problem type transformation

Post by fcdiass »

Yes, I am using GiD version 14.0.5.
I am limited by my company, which bought only version 14.
There is any possibility of you release a new version (e.g. 14.0.6), which solves these bugs reported here?
User avatar
mrpeyrau
Posts: 4
Joined: Fri Oct 23, 2020 5:22 pm

Re: Problem type transformation

Post by mrpeyrau »

It should be emphasized that we have not fixed any bugs in GiD. Therefore, we will not release a GiD 14.* version. In fact, the node <unit_magnitude/> always requires 'active' attribute to work properly. The only improvement has been to allow the mistake in which the user does not define this attribute in the *.spd file. In this case, active="1" is used by default. By the way, keep the <units/> information in the '*_default.spd' file to be able to load your problem type successfully in Gid 14.0.5. The current GiD 15.0.1 version already allows to use <include/> node, when defining units. Kind regards.
Maria Rosa Peyrau Rubio
Dept. Pre and Postprocessing CIMNE
Post Reply