About Adding New Classes to OpenSees

Forum for OpenSees users to post questions, comments, etc. on the use of the OpenSees interpreter, OpenSees.exe

Moderators: silvia, selimgunay, Moderators

Post Reply
shiro
Posts: 53
Joined: Tue May 26, 2020 1:19 am

About Adding New Classes to OpenSees

Post by shiro » Thu Apr 22, 2021 8:51 pm

I would like to adding New Classes to OpenSees.

I would like to adding the new class to the VisualStudio 2019 project
and Makefiles to be compiled/linked with the rest of the OpenSees classes.

I referred to the following workshop materials.

 ・QuakeCoRE OpenSees Training Workshop 2016

   Adding a New Material or Element to OpenSees


The files I want to add are:

 777.h
 777.cpp

p10:

class 777 : public UniaxialMaterial


The following parts have been added with reference to the material.


(1)TclModelBuilderUniaxialMaterialCommand.cpp


p25

extern void *OPS_777(void);

p26

else if (strcmp(argv[1], "777") == 0) {
void *theMat = OPS_777();

if (theMat != 0)
theMaterial = (UniaxialMaterial *)theMat;
else
return TCL_ERROR;
}


(2)classTags.h

p27

#define MAT_TAG_777 1


(3)SRC/actor/objectBroker/FEM_ObjectBrokerAllClasses.cpp

#include <777.h>


When I modify the above and compile with VisualStudio 2019 project,
the following error will occur.


/**********************************************************************************************************************/

error LNK2019

The unresolved external symbol "void * __cdecl OPS_777 (void)" (? OPS_777 @@ YAPEAXXZ) is referenced by the function
"int __cdecl TclModelBuilderUniaxialMaterialCommand (void *, struct Tcl_Interp *, int, char const * *, class Domain *)"
(? TclModelBuilderUniaxialMaterialCommand @@ YAHPEAXPEAUTcl_Interp @@ HPEAPEBDPEAVDomain @@@ Z)

OpenSees C: \ Users \ *** \ Documents \ OpenSees-3.2.0 \ Win64 \ proj \ openSees
\ material.lib (TclModelBuilderUniaxialMaterialCommand.obj)

/**********************************************************************************************************************/


I would appreciate it if you could tell me how to compile successfully.

shiro
Posts: 53
Joined: Tue May 26, 2020 1:19 am

Re: About Adding New Classes to OpenSees

Post by shiro » Wed May 12, 2021 1:21 am

As an alternative, I also tried the following methods.

https://opensees.berkeley.edu/OpenSees/ ... urCode.pdf

I connected to TortoiseSVN but couldn't.
Therefore, I could not download by accessing the following address.

svn://opensees.berkeley.edu/usr/local/svn/OpenSees/trunk/DEVELOPER


So, I tried to create ElasticPPcpp dll in Visual Studio 2019 as the text says.
I carried out from p21 to p36 of the text.

I was able to do the same up to p34, but I get a compile error at the last p35.
I get 54 errors as below.

I would be grateful if you could give me some advice on how to successfully compile the ElasticPPcpp.dll file.




error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\BinaryFileStream.cpp 121
error C4996 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\BinaryFileStream.cpp 573
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\DataFileStream.cpp 51
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\DataFileStream.cpp 69
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\DataFileStream.cpp 135
error C4996 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\DataFileStream.cpp 700
error C1083 include Unable to open the file. 'SectionForceDeformation.h':No such file or directory ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\Domain.cpp 71
error C1083 include Unable to open the file. 'bool.h':No such file or directory ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\EigenSOE.h 24
error C4996 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\Element.cpp 423
error C4996 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\Element.cpp 432
error C4996 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\Element.cpp 443
error C4996 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\Element.cpp 453
error C4996 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\Element.cpp 463
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\File.cpp 105
error C4996 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\File.cpp 106
error C4996 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\File.cpp 107
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\File.cpp 110
error C4996 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\File.cpp 126
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\File.cpp 127
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\File.cpp 130
error C4996 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\File.cpp 148
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\File.cpp 149
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\File.cpp 163
error C4996 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\File.cpp 164
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\File.cpp 166
error C4996 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\File.cpp 167
error C1083 include Unable to open the file. 'bool.h':No such file or directory ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\EigenSOE.h 24
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\Information.cpp 175
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\Information.cpp 179
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\Information.cpp 183
error C4996 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\Node.cpp 1841
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\Renderer.cpp 94
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\SimulationInformation.cpp 50
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\SimulationInformation.cpp 51
error C4996 'ctime': This function or variable may be unsafe. Consider using ctime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\SimulationInformation.cpp 104
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\SimulationInformation.cpp 105
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\SimulationInformation.cpp 112
error C4996 'ctime': This function or variable may be unsafe. Consider using ctime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\SimulationInformation.cpp 124
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\SimulationInformation.cpp 125
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\SimulationInformation.cpp 149
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\SimulationInformation.cpp 169
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\SimulationInformation.cpp 189
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\SimulationInformation.cpp 209
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\SimulationInformation.cpp 229
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\SimulationInformation.cpp 249
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\SimulationInformation.cpp 269
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\SimulationInformation.cpp 410
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\SimulationInformation.cpp 415
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\StandardStream.cpp 40
error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\StringContainer.cpp 98
error C4996 'strtok': This function or variable may be unsafe. Consider using strtok_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\UniaxialMaterial.cpp 275
error C4996 'strtok': This function or variable may be unsafe. Consider using strtok_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\UniaxialMaterial.cpp 276
error C4996 'strtok': This function or variable may be unsafe. Consider using strtok_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\UniaxialMaterial.cpp 283
error C4996 'strtok': This function or variable may be unsafe. Consider using strtok_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. ElasticPPcpp C:\Users\777\Desktop\DEVELOPER\core\UniaxialMaterial.cpp 284

shiro
Posts: 53
Joined: Tue May 26, 2020 1:19 am

Re: About Adding New Classes to OpenSees

Post by shiro » Thu May 13, 2021 1:23 am

When I ran it as follows, the error disappeared and the compilation was finished.


1)Added sectionforcedeformation.h and bool.h to the \core folder and source folder

2)Added CrdTransf.cpp and sectionforcedeformation.cpp to the \core folder and source folder

3)project properties>preprocessor definitions by adding "_CRT_SECURE_NO_WARNINGS"

4)Rebuild solution.


It compiles succesfully without displaying errors in Visual Studio 2019.

I put the ElasticPPcpp.dll file in the same folder as example1.tcl and ran the calculation.
However, the calculation was not executed without recognizing ElasticPPcpp.


OpenSees > source example1.tcl
WARNING could not create uniaxialMaterial ElasticPPcpp


Since the project was compiled in 64-bit, debug mode, I tried compiling it in release mode, but the result was the same.

How do I compile ElasticPPcpp.dll to link when OpenSees.exe runs?

I would appreciate your advice.

Post Reply