Problem
As part of my work on #519, I was going to implement a concrete active stress class (UniformUnsteadyActiveStress) that replicates what is currently implemented by the <Fiber_reinforcement_stress> tag, that is reads a time-dependent active tension transient from file.
It seems to me that the natural way of doing this is to place an object of type fcType inside UniformUnsteadyActiveStress, construct that object as part of the active stress object initialization, and evaluate it as part of the active tension evaluation method.
However, I encountered a few issues which I think are worth addressing in a more focused refactoring of fcType:
fcType is defined in ComMod.h, but I cannot include ComMod.h in active_stress.h (or derived), due to circular dependencies. This can probably be worked around with forward declarations and access through a pointer, but it feels needlessly convoluted.
ifft takes in input a ComMod instance, even though it only uses its time member. It would be more natural for ifft to take the evaluation time directly.
Solution
The issues above prompted me to think about a cleaner restructuring of the whole fft, ifft and fcType infrastructure, which I think is worth addressing independently of #519, since it's more general.
I propose the following changes:
- move
fcType to its own file, so that it can be included and used independently of ComMod.h;
- encapsulate reading data from file and calling
fft as a method of the fcType class; this might be done either in the class constructor or in an initialization method (I lean in favor of the constructor);
- modify
ifft so that it only takes the desired time in input, not the whole ComMod;
- encapsulate evaluating the interpolated data at a given time point as a method of the
fcType class, say fcType::evaluate.
After these changes, fft and ifft would become internal implementation details of fcType, so their code could be moved to that class.
Additionally, I suggest taking the opportunity to give the fcType class a more explicit name (I figure that fc stands for Fourier coefficients, but that might not be immediately obvious to someone unfamiliar with the code). I suggest for example FourierInterpolation or TimeInterpolation (I slightly lean in favor of the latter, because it leaves open the possibility of expanding the class to include other interpolation methods, e.g. splines or piecewise linear, while retaining the same interface).
Additional context
No response
Code of Conduct
Problem
As part of my work on #519, I was going to implement a concrete active stress class (
UniformUnsteadyActiveStress) that replicates what is currently implemented by the<Fiber_reinforcement_stress>tag, that is reads a time-dependent active tension transient from file.It seems to me that the natural way of doing this is to place an object of type
fcTypeinsideUniformUnsteadyActiveStress, construct that object as part of the active stress object initialization, and evaluate it as part of the active tension evaluation method.However, I encountered a few issues which I think are worth addressing in a more focused refactoring of
fcType:fcTypeis defined inComMod.h, but I cannot includeComMod.hinactive_stress.h(or derived), due to circular dependencies. This can probably be worked around with forward declarations and access through a pointer, but it feels needlessly convoluted.iffttakes in input aComModinstance, even though it only uses itstimemember. It would be more natural forifftto take the evaluation time directly.Solution
The issues above prompted me to think about a cleaner restructuring of the whole
fft,ifftandfcTypeinfrastructure, which I think is worth addressing independently of #519, since it's more general.I propose the following changes:
fcTypeto its own file, so that it can be included and used independently ofComMod.h;fftas a method of thefcTypeclass; this might be done either in the class constructor or in an initialization method (I lean in favor of the constructor);ifftso that it only takes the desired time in input, not the wholeComMod;fcTypeclass, sayfcType::evaluate.After these changes,
fftandifftwould become internal implementation details offcType, so their code could be moved to that class.Additionally, I suggest taking the opportunity to give the
fcTypeclass a more explicit name (I figure thatfcstands for Fourier coefficients, but that might not be immediately obvious to someone unfamiliar with the code). I suggest for exampleFourierInterpolationorTimeInterpolation(I slightly lean in favor of the latter, because it leaves open the possibility of expanding the class to include other interpolation methods, e.g. splines or piecewise linear, while retaining the same interface).Additional context
No response
Code of Conduct