febiosoftware / FEBio

FEBio Suite Solver
https://febio.org/
MIT License
174 stars 65 forks source link

add Functionality for plugins to define parameters in input file #59

Closed steffenger closed 9 months ago

steffenger commented 1 year ago

I think it would be useful to define parameters for a callbackplugin in an inputfile like:

' BEGIN_FECORE_CLASS(MyCallback, FECallBack); ADD_PARAMETER(m_test, FE_RANGE_GREATER(0.0), "test"); END_FECORE_CLASS(); ' One way could be to add the virtual functions

' void theClass::BuildParamList() ' to the FECallBack class but i am not really sure about this.
If there is already way to use this functionality in FEBio, please let me know.

best regards

Steffen

SteveMaas1978 commented 1 year ago

Hi Steffen,

I think you can already do this, or maybe I don't understand the question. Since FECallBack inherits FECoreBase, derived classes use the BEGIN_FECORE_CLASS and END_FECORE_CLASS macros to define their parameter lists. In the FEBio input file, you reference the callback in the Code section: `

...

`

Does that answer your question?

Steve

steffenger commented 1 year ago

Hi Steve,

My mistake was that i forgot the

DECLARE_FECORE_CLASS();

at the end in the header file of the plugin. Now the plugin has compiled but i am not sure where to put this testparameter in the input file.

BEGIN_FECORE_CLASS(MyCallback, FECallBack); ADD_PARAMETER(m_test, FE_RANGE_GREATER(0.0), "test"); END_FECORE_CLASS();

My best guess was this

input file
`

         <test>1.0</test>
       </Code>`

but the tag is not recognized this way.

thanks for the help and best regards,

steffen

SteveMaas1978 commented 1 year ago

Hi Steffen,

Did you register your class in your plugin? (See here)

Best,

Steve

steffenger commented 1 year ago

Hi Steve,

The callback is registered this way inside the plugin:

FECORE_PLUGIN void PluginInitialize(FECoreKernel& fecore) { FECoreKernel::SetInstance(&fecore); fecore.RegisterDomain(new FEMixDomainFactory);

fecore.SetActiveModule("solid");
fecore.CreateModule("biphasic"); 
fecore.SetModuleDependency("solid"); 
    REGISTER_FECORE_CLASS_EXPLICIT(MyCallback, FECALLBACK_ID, "my_callback");
   ...
    fecore.SetActiveModule(0);

}

best regards,

Steffen

SteveMaas1978 commented 1 year ago

Hi Steffen,

Let's take this conversation offline. Can you please email me the source code of your plugin? You may email me at steve dot maas at utah dot edu. I'll see if I can reproduce the issue on my end.

Thanks,

Steve

steffenger commented 1 year ago

Hi Steve,

I am sorry, i forgot to answer. I will send you an email