@@ -2119,6 +2119,7 @@ MORPHO_ENDCLASS
2119
2119
* ---------------------------------------------- */
2120
2120
2121
2121
static value linearelasticity_referenceproperty ;
2122
+ static value linearelasticity_weightbyreferenceproperty ;
2122
2123
static value linearelasticity_poissonproperty ;
2123
2124
2124
2125
typedef struct {
@@ -3890,6 +3891,7 @@ typedef struct {
3890
3891
value method ; // Method dictionary
3891
3892
objectmesh * mref ; // Reference mesh
3892
3893
vm * v ;
3894
+ bool weightbyref ; // Use reference mesh for the element
3893
3895
} integralref ;
3894
3896
3895
3897
/* ----------------------------------------------
@@ -4206,12 +4208,14 @@ bool integral_prepareref(objectinstance *self, objectmesh *mesh, grade g, object
4206
4208
bool success = false;
4207
4209
value func = MORPHO_NIL ;
4208
4210
value mref = MORPHO_NIL ;
4211
+ value wtbyref = MORPHO_NIL ;
4209
4212
value field = MORPHO_NIL ;
4210
4213
value method = MORPHO_NIL ;
4211
4214
ref -> v = NULL ;
4212
4215
ref -> nfields = 0 ;
4213
4216
ref -> method = MORPHO_NIL ;
4214
4217
ref -> mref = NULL ;
4218
+ ref -> weightbyref = false;
4215
4219
4216
4220
if (objectinstance_getpropertyinterned (self , scalarpotential_functionproperty , & func ) &&
4217
4221
MORPHO_ISCALLABLE (func )) {
@@ -4222,6 +4226,9 @@ bool integral_prepareref(objectinstance *self, objectmesh *mesh, grade g, object
4222
4226
MORPHO_ISMESH (mref )) {
4223
4227
ref -> mref = MORPHO_GETMESH (mref );
4224
4228
}
4229
+ if (objectinstance_getpropertyinterned (self , linearelasticity_weightbyreferenceproperty , & wtbyref )) {
4230
+ ref -> weightbyref = !morpho_isfalse (wtbyref );
4231
+ }
4225
4232
if (objectinstance_getpropertyinterned (self , functional_methodproperty , & method )) {
4226
4233
ref -> method = method ;
4227
4234
}
@@ -4352,12 +4359,15 @@ value LineIntegral_init(vm *v, int nargs, value *args) {
4352
4359
int nfixed ;
4353
4360
value method = MORPHO_NIL ;
4354
4361
value mref = MORPHO_NIL ;
4362
+ value wtbyref = MORPHO_NIL ;
4355
4363
4356
- if (builtin_options (v , nargs , args , & nfixed , 2 ,
4364
+ if (builtin_options (v , nargs , args , & nfixed , 3 ,
4357
4365
functional_methodproperty , & method ,
4358
- linearelasticity_referenceproperty , & mref )) {
4366
+ linearelasticity_referenceproperty , & mref ,
4367
+ linearelasticity_weightbyreferenceproperty , & wtbyref )) {
4359
4368
if (MORPHO_ISDICTIONARY (method )) objectinstance_setproperty (self , functional_methodproperty , method );
4360
4369
if (MORPHO_ISMESH (mref )) objectinstance_setproperty (self , linearelasticity_referenceproperty , mref );
4370
+ if (MORPHO_ISBOOL (wtbyref )) objectinstance_setproperty (self , linearelasticity_weightbyreferenceproperty , wtbyref );
4361
4371
} else {
4362
4372
morpho_runtimeerror (v , LINEINTEGRAL_ARGS );
4363
4373
return MORPHO_NIL ;
@@ -4447,8 +4457,12 @@ bool areaintegral_integrand(vm *v, objectmesh *mesh, elementid id, int nv, int *
4447
4457
elref .iref = & iref ;
4448
4458
elref .vertexposn = x ;
4449
4459
elref .qgrad = qgrad ;
4450
-
4451
- if (!functional_elementsize (v , mesh , MESH_GRADE_AREA , id , nv , vid , & elref .elementsize )) return false;
4460
+
4461
+ if (iref .weightbyref ) {
4462
+ if (!functional_elementsize (v , iref .mref , MESH_GRADE_AREA , id , nv , vid , & elref .elementsize )) return false;
4463
+ } else {
4464
+ if (!functional_elementsize (v , mesh , MESH_GRADE_AREA , id , nv , vid , & elref .elementsize )) return false;
4465
+ }
4452
4466
4453
4467
iref .v = v ;
4454
4468
for (unsigned int i = 0 ; i < nv ; i ++ ) {
@@ -4621,7 +4635,7 @@ MORPHO_ENDCLASS
4621
4635
* Initialization
4622
4636
* ********************************************************************** */
4623
4637
4624
- double ff (double x ) {
4638
+ /* double ff(double x) {
4625
4639
return exp(x);
4626
4640
}
4627
4641
@@ -4632,7 +4646,7 @@ double dff(double x) {
4632
4646
void functional_fdtest(void) {
4633
4647
double h1 = 1e-8;
4634
4648
4635
- //double xi[] = { -100, -10, -1.0, 0.0, 1e-7, 1e-5, 1e-2, 0.1, 1, 10, 100, 1e100 /* Terminator */ };
4649
+ //double xi[] = { -100, -10, -1.0, 0.0, 1e-7, 1e-5, 1e-2, 0.1, 1, 10, 100, 1e100 };
4636
4650
4637
4651
for (int i=-6; i<3; i++) {
4638
4652
double x = pow(10.0, (double) i);
@@ -4646,7 +4660,7 @@ void functional_fdtest(void) {
4646
4660
printf("%g: %g %g %g\n", x, fex, fabs((f1-fex)/fex), fabs((f2-fex)/fex));
4647
4661
}
4648
4662
4649
- }
4663
+ }*/
4650
4664
4651
4665
void functional_initialize (void ) {
4652
4666
fddelta1 = pow (MORPHO_EPS , 1.0 /3.0 );
@@ -4657,6 +4671,7 @@ void functional_initialize(void) {
4657
4671
scalarpotential_functionproperty = builtin_internsymbolascstring (SCALARPOTENTIAL_FUNCTION_PROPERTY );
4658
4672
scalarpotential_gradfunctionproperty = builtin_internsymbolascstring (SCALARPOTENTIAL_GRADFUNCTION_PROPERTY );
4659
4673
linearelasticity_referenceproperty = builtin_internsymbolascstring (LINEARELASTICITY_REFERENCE_PROPERTY );
4674
+ linearelasticity_weightbyreferenceproperty = builtin_internsymbolascstring (LINEARELASTICITY_WTBYREF_PROPERTY );
4660
4675
linearelasticity_poissonproperty = builtin_internsymbolascstring (LINEARELASTICITY_POISSON_PROPERTY );
4661
4676
hydrogel_aproperty = builtin_internsymbolascstring (HYDROGEL_A_PROPERTY );
4662
4677
hydrogel_bproperty = builtin_internsymbolascstring (HYDROGEL_B_PROPERTY );
0 commit comments